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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations