Search in sources :

Example 1 with InstrumentCategory

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

the class InstrumentLibrary method removeCategory.

public void removeCategory(InstrumentCategory cat) {
    InstrumentCategory parent = findParent(rootInstrumentCategory, cat);
    int index = getIndexOfChild(parent, cat);
    int[] childIndices = new int[1];
    childIndices[0] = index;
    Object[] children = new Object[1];
    children[0] = cat;
    TreeModelEvent e = new TreeModelEvent(this, getPathForObject(cat), childIndices, children);
    rootInstrumentCategory.removeInstrumentCategory(cat);
    fireNodesRemoved(e);
}
Also used : TreeModelEvent(javax.swing.event.TreeModelEvent) InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 2 with InstrumentCategory

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

the class InstrumentLibrary method getPathForObject.

private Object getPathForObject(InstrumentCategory current, Object obj, Vector v) {
    if (current == obj) {
        return v;
    }
    if (ListUtil.containsByRef(current.getInstruments(), obj)) {
        v.add(current);
        return v;
    }
    for (Iterator iter = current.getSubCategories().iterator(); iter.hasNext(); ) {
        InstrumentCategory cat = (InstrumentCategory) iter.next();
        Object pathObj = getPathForObject(cat, obj, v);
        if (pathObj != null) {
            v.add(current);
            return v;
        }
    }
    return null;
}
Also used : InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 3 with InstrumentCategory

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

the class InstrumentLibrary method getIndexOfChild.

@Override
public int getIndexOfChild(Object parent, Object child) {
    InstrumentCategory category = (InstrumentCategory) parent;
    if (category == null || child == null) {
        return -1;
    }
    int retVal = ListUtil.indexOfByRef(category.getSubCategories(), child);
    if (retVal >= 0) {
        return retVal;
    }
    retVal = ListUtil.indexOfByRef(category.getInstruments(), child);
    if (retVal >= 0) {
        return retVal + category.getSubCategories().size();
    }
    return -1;
}
Also used : InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 4 with InstrumentCategory

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

the class InstrumentLibrary method valueForPathChanged.

/*
     * (non-Javadoc)
     * 
     * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath,
     *      java.lang.Object)
     */
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
    Object obj = path.getLastPathComponent();
    if (obj instanceof InstrumentCategory) {
        ((InstrumentCategory) obj).setCategoryName(newValue.toString());
    } else if (obj instanceof Instrument) {
        ((Instrument) obj).setName(newValue.toString());
    }
    TreeModelEvent e = new TreeModelEvent(this, path);
    fireNodesChanged(e);
}
Also used : TreeModelEvent(javax.swing.event.TreeModelEvent) Instrument(blue.orchestra.Instrument) InstrumentCategory(blue.orchestra.InstrumentCategory)

Example 5 with InstrumentCategory

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

the class InstrumentLibrary method removeInstrument.

public void removeInstrument(Instrument instr) {
    InstrumentCategory parent = findParent(rootInstrumentCategory, instr);
    int index = getIndexOfChild(parent, instr);
    int[] childIndices = new int[1];
    childIndices[0] = index;
    Object[] children = new Object[1];
    children[0] = instr;
    TreeModelEvent e = new TreeModelEvent(this, getPathForObject(instr), childIndices, children);
    rootInstrumentCategory.removeInstrument(instr);
    fireNodesRemoved(e);
}
Also used : TreeModelEvent(javax.swing.event.TreeModelEvent) 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