use of blue.ui.core.mixer.EffectCategory in project blue by kunstmusik.
the class EffectsPopup method populateMenu.
private void populateMenu(EffectCategory category, JMenu menu) {
JMenu currentMenu = menu;
ArrayList categories = category.getSubCategories();
ArrayList effects = category.getEffects();
for (int i = 0; i < categories.size(); i++) {
EffectCategory cat = (EffectCategory) categories.get(i);
JMenu catMenu = new JMenu(cat.getCategoryName());
menu.add(catMenu);
populateMenu(cat, catMenu);
}
int counter = 0;
for (int i = 0; i < effects.size(); i++) {
Effect effect = (Effect) effects.get(i);
AddEffectAction action = new AddEffectAction(effect);
if (counter < 10) {
currentMenu.add(action);
counter++;
} else {
JMenu tempMenu = new JMenu(BlueSystem.getString("menu.more"));
currentMenu.add(tempMenu);
currentMenu = tempMenu;
currentMenu.add(action);
counter = 1;
}
}
}
use of blue.ui.core.mixer.EffectCategory in project blue by kunstmusik.
the class EffectTreeDropTarget 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();
EffectsLibrary eLibrary = EffectsLibrary.getInstance();
if (dtde.isDataFlavorSupported(TransferableEffect.EFFECT_CAT_FLAVOR)) {
if (!(node instanceof EffectCategory)) {
dtde.rejectDrop();
return;
}
if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
dtde.acceptDrop(dtde.getDropAction());
Transferable tr = dtde.getTransferable();
try {
Object transferNode = tr.getTransferData(TransferableEffect.EFFECT_CAT_FLAVOR);
EffectCategory effectCategory = (EffectCategory) transferNode;
EffectCategory parentNode = (EffectCategory) node;
eLibrary.addCategory(parentNode, effectCategory);
dtde.dropComplete(true);
} catch (UnsupportedFlavorException | IOException e) {
dtde.dropComplete(false);
}
} else {
dtde.rejectDrop();
}
} else if (dtde.isDataFlavorSupported(TransferableEffect.EFFECT_FLAVOR)) {
dtde.acceptDrop(dtde.getDropAction());
try {
Transferable tr = dtde.getTransferable();
Object transferNode = tr.getTransferData(TransferableEffect.EFFECT_FLAVOR);
Effect effect = (Effect) transferNode;
effect.clearParameters();
// iLibrary.removeInstrument(instrument);
if (node instanceof EffectCategory) {
EffectCategory parentNode = (EffectCategory) node;
eLibrary.addEffect(parentNode, effect);
} else if (node instanceof Effect) {
EffectCategory parentNode = (EffectCategory) parentpath.getPathComponent(parentpath.getPathCount() - 2);
int index = ListUtil.indexOfByRef(parentNode.getEffects(), node);
int closestRow = tree.getClosestRowForLocation(pt.x, pt.y);
Rectangle bounds = tree.getRowBounds(closestRow);
if (pt.y > bounds.y + bounds.height) {
eLibrary.addEffect(parentNode, effect);
} else {
eLibrary.addEffect(parentNode, index, effect);
}
}
dtde.dropComplete(true);
} catch (UnsupportedFlavorException | IOException e) {
dtde.dropComplete(false);
}
} else {
dtde.rejectDrop();
}
}
use of blue.ui.core.mixer.EffectCategory in project blue by kunstmusik.
the class EffectTreeDropTarget method dragEnter.
@Override
public void dragEnter(DropTargetDragEvent dtde) {
if (!dtde.isDataFlavorSupported(TransferableEffect.EFFECT_FLAVOR) && !dtde.isDataFlavorSupported(TransferableEffect.EFFECT_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 EffectCategory) {
dtde.acceptDrag(dtde.getDropAction());
} else if (dtde.isDataFlavorSupported(TransferableEffect.EFFECT_FLAVOR)) {
dtde.acceptDrag(dtde.getDropAction());
} else {
dtde.rejectDrag();
}
}
Aggregations