Search in sources :

Example 11 with PresetGroup

use of blue.orchestra.blueSynthBuilder.PresetGroup in project blue by kunstmusik.

the class PresetsManagerDialog method editPresetGroup.

public PresetGroup editPresetGroup(PresetGroup presetGroup) {
    PresetGroup groupCopy = new PresetGroup(presetGroup);
    setPresetGroup(groupCopy);
    this.setVisible(true);
    PresetGroup returnValue = retVal;
    retVal = null;
    return returnValue;
}
Also used : PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup)

Example 12 with PresetGroup

use of blue.orchestra.blueSynthBuilder.PresetGroup in project blue by kunstmusik.

the class PresetsTreeDropTarget method drop.

@Override
public void drop(DropTargetDropEvent dtde) {
    Point pt = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
    Object node = parentpath.getLastPathComponent();
    if (!(node instanceof PresetGroup)) {
        dtde.rejectDrop();
        return;
    }
    try {
        Transferable tr = dtde.getTransferable();
        DataFlavor[] flavors = tr.getTransferDataFlavors();
        for (int i = 0; i < flavors.length; i++) {
            if (tr.isDataFlavorSupported(flavors[i])) {
                dtde.acceptDrop(dtde.getDropAction());
                Object transferNode = tr.getTransferData(flavors[i]);
                PresetsTreeModel presetsTreeModel = (PresetsTreeModel) tree.getModel();
                PresetGroup parentNode = (PresetGroup) node;
                if (transferNode instanceof Preset) {
                    Preset preset = (Preset) transferNode;
                    // presetsTreeModel.removePreset(preset);
                    presetsTreeModel.addPreset(parentNode, preset);
                    dtde.dropComplete(true);
                } else if (transferNode instanceof PresetGroup) {
                    PresetGroup presetGroup = (PresetGroup) transferNode;
                    // presetsTreeModel.removePresetGroup(presetGroup);
                    presetsTreeModel.addPresetGroup(parentNode, presetGroup);
                    dtde.dropComplete(true);
                } else {
                    dtde.rejectDrop();
                }
                return;
            }
        }
        dtde.rejectDrop();
    } catch (UnsupportedFlavorException | IOException e) {
        e.printStackTrace();
    }
}
Also used : Preset(blue.orchestra.blueSynthBuilder.Preset) DropTargetContext(java.awt.dnd.DropTargetContext) Transferable(java.awt.datatransfer.Transferable) Point(java.awt.Point) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) Point(java.awt.Point) DataFlavor(java.awt.datatransfer.DataFlavor) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup)

Example 13 with PresetGroup

use of blue.orchestra.blueSynthBuilder.PresetGroup in project blue by kunstmusik.

the class PresetsTreeModel method getIndexOfChild.

/*
     * (non-Javadoc)
     * 
     * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,
     *      java.lang.Object)
     */
@Override
public int getIndexOfChild(Object parent, Object child) {
    PresetGroup presetGroup = (PresetGroup) parent;
    if (presetGroup == null || child == null) {
        return -1;
    }
    int retVal = presetGroup.getSubGroups().indexOf(child);
    if (retVal >= 0) {
        return retVal;
    }
    retVal = presetGroup.getPresets().indexOf(child);
    if (retVal >= 0) {
        return retVal + presetGroup.getSubGroups().size();
    }
    return -1;
}
Also used : PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup)

Example 14 with PresetGroup

use of blue.orchestra.blueSynthBuilder.PresetGroup in project blue by kunstmusik.

the class PresetsUtilities method synchronizePresets.

public static void synchronizePresets(PresetGroup presetGroup, BSBGraphicInterface gInterface) {
    if (presetGroup == null || gInterface == null) {
        System.err.println("Null error in PresetsUtilities");
        return;
    }
    ArrayList<PresetGroup> subGroups = presetGroup.getSubGroups();
    for (int i = 0; i < subGroups.size(); i++) {
        synchronizePresets(subGroups.get(i), gInterface);
    }
    ArrayList<Preset> presets = presetGroup.getPresets();
    for (int i = 0; i < presets.size(); i++) {
        Preset preset = presets.get(i);
        preset.synchronizeWithInterface(gInterface);
    }
}
Also used : Preset(blue.orchestra.blueSynthBuilder.Preset) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup)

Aggregations

PresetGroup (blue.orchestra.blueSynthBuilder.PresetGroup)14 Preset (blue.orchestra.blueSynthBuilder.Preset)6 TreeModelEvent (javax.swing.event.TreeModelEvent)3 TreePath (javax.swing.tree.TreePath)3 BSBGraphicInterface (blue.orchestra.blueSynthBuilder.BSBGraphicInterface)2 Point (java.awt.Point)2 DropTargetContext (java.awt.dnd.DropTargetContext)2 JTree (javax.swing.JTree)2 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)1 PresetsManagerDialog (blue.orchestra.editor.blueSynthBuilder.PresetsManagerDialog)1 ObjectBuilder (blue.soundObject.ObjectBuilder)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ContextMenu (javafx.scene.control.ContextMenu)1 Menu (javafx.scene.control.Menu)1 MenuItem (javafx.scene.control.MenuItem)1 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)1