use of blue.orchestra.blueSynthBuilder.BSBObjectEntry in project blue by kunstmusik.
the class BSBEditPane method setupPopupMenus.
private void setupPopupMenus(BSBObjectEntry[] bsbObjectEntries) {
popupMenu = new ContextMenu();
EventHandler<ActionEvent> al = e -> {
MenuItem m = (MenuItem) e.getSource();
Class<? extends BSBObject> clazz = (Class<? extends BSBObject>) m.getUserData();
try {
BSBObject bsbObj = clazz.newInstance();
bsbObj.setX(addX);
bsbObj.setY(addY);
currentBSBGroup.addBSBObject(bsbObj);
} catch (InstantiationException | IllegalAccessException ex) {
Exceptions.printStackTrace(ex);
}
};
for (BSBObjectEntry entry : bsbObjectEntries) {
MenuItem m = new MenuItem("Add " + entry.label);
m.setUserData(entry.bsbObjectClass);
m.setOnAction(al);
popupMenu.getItems().add(m);
}
MenuItem paste = new MenuItem("Paste");
paste.setOnAction(ae -> paste(addX, addY));
paste.disableProperty().bind(Bindings.createBooleanBinding(() -> selection.copyBufferProperty().size() == 0, selection.copyBufferProperty()));
popupMenu.getItems().addAll(new SeparatorMenuItem(), paste);
nonEditPopupMenu = new ContextMenu();
MenuItem randomize = new MenuItem("Randomize");
randomize.setOnAction(ae -> {
if (bsbInterface != null) {
bsbInterface.getRootGroup().randomize();
}
});
nonEditPopupMenu.getItems().add(randomize);
}
Aggregations