Search in sources :

Example 1 with PresetGroup

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

the class BlueSynthBuilderEditor method editInstrument.

@Override
public void editInstrument(Instrument instr) {
    if (instr == null) {
        this.bsb = null;
        return;
    }
    if (!(instr instanceof BlueSynthBuilder)) {
        this.bsb = null;
        return;
    }
    this.bsb = (BlueSynthBuilder) instr;
    PresetGroup presetGroup = bsb.getPresetGroup();
    BSBGraphicInterface graphicInterface = bsb.getGraphicInterface();
    Platform.runLater(() -> interfaceEditor.editInterface(graphicInterface, presetGroup));
    this.codeEditor.editBlueSynthBuilder(bsb);
    this.udoPanel.editOpcodeList(bsb.getOpcodeList());
}
Also used : BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder)

Example 2 with PresetGroup

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

the class ObjectBuilderEditor method editScoreObject.

@Override
public void editScoreObject(ScoreObject sObj) {
    if (sObj == null || !(sObj instanceof ObjectBuilder)) {
        this.objectBuilder = null;
        System.err.println("[ERROR] ObjectBuilder::editSoundObject - " + "not instance of ObjectBuilder");
        return;
    }
    if (this.objectBuilder != null) {
        final ObjectBuilder temp = this.objectBuilder;
        BlueFX.runOnFXThread(() -> temp.commentProperty().unbind());
    }
    this.objectBuilder = (ObjectBuilder) sObj;
    PresetGroup presetGroup = objectBuilder.getPresetGroup();
    BSBGraphicInterface graphicInterface = objectBuilder.getGraphicInterface();
    this.interfaceEditor.editInterface(graphicInterface, presetGroup);
    this.codeEditor.editObjectBuilder(objectBuilder);
    BlueFX.runOnFXThread(() -> {
        commentTextArea.setText(this.objectBuilder.getComment());
        this.objectBuilder.commentProperty().bind(commentTextArea.textProperty());
    });
}
Also used : BSBGraphicInterface(blue.orchestra.blueSynthBuilder.BSBGraphicInterface) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup) ObjectBuilder(blue.soundObject.ObjectBuilder)

Example 3 with PresetGroup

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

the class PresetPane method setPresetsMenu.

private void setPresetsMenu(PresetGroup pGroup, Menu parent) {
    for (PresetGroup subGroup : pGroup.getSubGroups()) {
        Menu menu = new Menu(subGroup.getPresetGroupName());
        setPresetsMenu(subGroup, menu);
        if (parent == null) {
            rootMenu.getItems().add(menu);
        } else {
            parent.getItems().add(menu);
        }
    }
    for (Preset preset : pGroup.getPresets()) {
        MenuItem item = new MenuItem(preset.getPresetName());
        item.setUserData(preset);
        item.setOnAction(presetSelectedAction);
        if (parent == null) {
            rootMenu.getItems().add(item);
        } else {
            parent.getItems().add(item);
        }
    }
    if (parent == null) {
        rootMenu.getItems().add(new SeparatorMenuItem());
    } else {
        parent.getItems().add(new SeparatorMenuItem());
    }
    MenuItem addFolder = new MenuItem("Add Folder");
    addFolder.setUserData(pGroup);
    addFolder.setOnAction(addFolderAction);
    MenuItem addPreset = new MenuItem("Add Preset");
    addPreset.setUserData(pGroup);
    addPreset.setOnAction(addPresetAction);
    if (parent == null) {
        MenuItem syncPresets = new MenuItem("Synchronize Presets");
        syncPresets.setOnAction(e -> {
            PresetsUtilities.synchronizePresets(getPresetGroup(), bsbInterface);
        });
        MenuItem managePresets = new MenuItem("Manage Presets");
        managePresets.setOnAction(e -> {
            PresetGroup[] retVal = new PresetGroup[1];
            CountDownLatch latch = new CountDownLatch(1);
            SwingUtilities.invokeLater(() -> {
                try {
                    if (presetsManager == null) {
                        presetsManager = new PresetsManagerDialog(WindowManager.getDefault().getMainWindow());
                    }
                    retVal[0] = presetsManager.editPresetGroup(pGroup);
                } finally {
                    latch.countDown();
                }
            });
            try {
                latch.await();
            } catch (InterruptedException ex) {
                Exceptions.printStackTrace(ex);
            }
            if (retVal[0] != null) {
                pGroup.setPresets(retVal[0].getPresets());
                pGroup.setSubGroups(retVal[0].getSubGroups());
                updatePresetMenu();
                Preset preset = pGroup.findPresetByUniqueId(pGroup.getCurrentPresetUniqueId());
                if (preset == null) {
                    pGroup.setCurrentPresetUniqueId(null);
                    pGroup.setCurrentPresetModified(false);
                }
                updateCurrentPresetUI();
            }
        });
        rootMenu.getItems().addAll(addFolder, addPreset, new SeparatorMenuItem(), syncPresets, managePresets);
    } else {
        parent.getItems().addAll(addFolder, addPreset);
    }
}
Also used : Preset(blue.orchestra.blueSynthBuilder.Preset) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ContextMenu(javafx.scene.control.ContextMenu) Menu(javafx.scene.control.Menu) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) CountDownLatch(java.util.concurrent.CountDownLatch) PresetsManagerDialog(blue.orchestra.editor.blueSynthBuilder.PresetsManagerDialog)

Example 4 with PresetGroup

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

the class TransferablePreset method dragGestureRecognized.

@Override
public void dragGestureRecognized(DragGestureEvent dge) {
    TreePath path = sourceTree.getSelectionPath();
    if ((path == null) || (path.getPathCount() <= 1)) {
        // We can't really move the root node (or an empty selection).
        return;
    }
    if (path.getLastPathComponent() instanceof Preset || path.getLastPathComponent() instanceof PresetGroup) {
        oldNode = path.getLastPathComponent();
        transferable = new TransferablePreset(oldNode);
        source.startDrag(dge, null, transferable, this);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) Preset(blue.orchestra.blueSynthBuilder.Preset) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup)

Example 5 with PresetGroup

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

the class PresetsTreeDropTarget method dragEnter.

@Override
public void dragEnter(DropTargetDragEvent dtde) {
    Point p = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath path = tree.getClosestPathForLocation(p.x, p.y);
    if (path.getLastPathComponent() instanceof PresetGroup) {
        dtde.acceptDrag(dtde.getSourceActions());
    } else {
        dtde.rejectDrag();
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) DropTargetContext(java.awt.dnd.DropTargetContext) PresetGroup(blue.orchestra.blueSynthBuilder.PresetGroup) Point(java.awt.Point)

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