Search in sources :

Example 6 with InstrumentCategory

use of blue.orchestra.InstrumentCategory in project blue by kunstmusik.

the class InstrumentLibrary method importInstrument.

public void importInstrument(Instrument instr) {
    List categories = rootInstrumentCategory.getSubCategories();
    for (Iterator iter = categories.iterator(); iter.hasNext(); ) {
        InstrumentCategory cat = (InstrumentCategory) iter.next();
        if (cat.getCategoryName().equals("Imported Instruments")) {
            addInstrument(cat, instr);
            return;
        }
    }
    InstrumentCategory cat = new InstrumentCategory();
    cat.setCategoryName("Imported Instruments");
    cat.addInstrument(instr);
    addCategory(rootInstrumentCategory, cat);
}
Also used : InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 7 with InstrumentCategory

use of blue.orchestra.InstrumentCategory in project blue by kunstmusik.

the class UserInstrumentTreePopup method copyNode.

protected void copyNode() {
    if (userObj == instrGUI.iLibrary.getRoot()) {
        return;
    }
    Object bufferedObj;
    if (userObj instanceof Instrument) {
        bufferedObj = ((Instrument) userObj).deepCopy();
    } else {
        bufferedObj = new InstrumentCategory((InstrumentCategory) userObj);
    }
    CopyBuffer.setBufferedObject(CopyBuffer.INSTRUMENT, userObj);
}
Also used : Instrument(blue.orchestra.Instrument) InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 8 with InstrumentCategory

use of blue.orchestra.InstrumentCategory in project blue by kunstmusik.

the class InstrumentTreeDropTarget method dragEnter.

@Override
public void dragEnter(DropTargetDragEvent dtde) {
    if (!dtde.isDataFlavorSupported(TransferableInstrument.INSTR_FLAVOR) && !dtde.isDataFlavorSupported(TransferableInstrument.INSTR_CAT_FLAVOR)) {
        dtde.rejectDrag();
        return;
    }
    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 InstrumentCategory) {
        dtde.acceptDrag(dtde.getDropAction());
    } else if (dtde.isDataFlavorSupported(TransferableInstrument.INSTR_FLAVOR)) {
        dtde.acceptDrag(dtde.getDropAction());
    } else {
        dtde.rejectDrag();
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) DropTargetContext(java.awt.dnd.DropTargetContext) Point(java.awt.Point) InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 9 with InstrumentCategory

use of blue.orchestra.InstrumentCategory in project blue by kunstmusik.

the class InstrumentTreeDragSource 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 Instrument || path.getLastPathComponent() instanceof InstrumentCategory) {
        oldNode = path.getLastPathComponent();
        Object cloneNode = null;
        if (oldNode instanceof Instrument) {
            cloneNode = ((Instrument) oldNode).deepCopy();
        } else if (oldNode instanceof InstrumentCategory) {
            cloneNode = new InstrumentCategory((InstrumentCategory) oldNode);
        }
        transferable = new TransferableInstrument(cloneNode);
        source.startDrag(dge, null, transferable, this);
        DragManager.setDragSource(sourceTree);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) Instrument(blue.orchestra.Instrument) InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 10 with InstrumentCategory

use of blue.orchestra.InstrumentCategory in project blue by kunstmusik.

the class UserInstrumentTreePopup method addInstrument.

private void addInstrument(Instrument instr) {
    Instrument newInstrument = (Instrument) instr.deepCopy();
    InstrumentCategory currentCategory = (InstrumentCategory) userObj;
    instrGUI.iLibrary.addInstrument(currentCategory, newInstrument);
/*
         * BlueUndoManager.setUndoManager("orchestra"); BlueUndoManager.addEdit(
         * new AddEdit(orchTableModel, clone, new Integer(iNum)));
         */
}
Also used : Instrument(blue.orchestra.Instrument) InstrumentCategory(blue.orchestra.InstrumentCategory)

Aggregations

InstrumentCategory (blue.orchestra.InstrumentCategory)14 Instrument (blue.orchestra.Instrument)5 TreeModelEvent (javax.swing.event.TreeModelEvent)3 TreePath (javax.swing.tree.TreePath)3 Point (java.awt.Point)2 DropTargetContext (java.awt.dnd.DropTargetContext)2 JTree (javax.swing.JTree)2 InstrumentLibrary (blue.InstrumentLibrary)1 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)1 Rectangle (java.awt.Rectangle)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1