use of blue.orchestra.editor.blueSynthBuilder.PresetsManagerDialog in project blue by kunstmusik.
the class PresetPane method setPresetsMenu.
private void setPresetsMenu(PresetGroup pGroup, Menu parent) {
for (PresetGroup subGroup : pGroup.getSubGroups()) {
Menu menu = new Menu(subGroup.getPresetGroupName());
setPresetsMenu(subGroup, menu);
if (parent == null) {
rootMenu.getItems().add(menu);
} else {
parent.getItems().add(menu);
}
}
for (Preset preset : pGroup.getPresets()) {
MenuItem item = new MenuItem(preset.getPresetName());
item.setUserData(preset);
item.setOnAction(presetSelectedAction);
if (parent == null) {
rootMenu.getItems().add(item);
} else {
parent.getItems().add(item);
}
}
if (parent == null) {
rootMenu.getItems().add(new SeparatorMenuItem());
} else {
parent.getItems().add(new SeparatorMenuItem());
}
MenuItem addFolder = new MenuItem("Add Folder");
addFolder.setUserData(pGroup);
addFolder.setOnAction(addFolderAction);
MenuItem addPreset = new MenuItem("Add Preset");
addPreset.setUserData(pGroup);
addPreset.setOnAction(addPresetAction);
if (parent == null) {
MenuItem syncPresets = new MenuItem("Synchronize Presets");
syncPresets.setOnAction(e -> {
PresetsUtilities.synchronizePresets(getPresetGroup(), bsbInterface);
});
MenuItem managePresets = new MenuItem("Manage Presets");
managePresets.setOnAction(e -> {
PresetGroup[] retVal = new PresetGroup[1];
CountDownLatch latch = new CountDownLatch(1);
SwingUtilities.invokeLater(() -> {
try {
if (presetsManager == null) {
presetsManager = new PresetsManagerDialog(WindowManager.getDefault().getMainWindow());
}
retVal[0] = presetsManager.editPresetGroup(pGroup);
} finally {
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
if (retVal[0] != null) {
pGroup.setPresets(retVal[0].getPresets());
pGroup.setSubGroups(retVal[0].getSubGroups());
updatePresetMenu();
Preset preset = pGroup.findPresetByUniqueId(pGroup.getCurrentPresetUniqueId());
if (preset == null) {
pGroup.setCurrentPresetUniqueId(null);
pGroup.setCurrentPresetModified(false);
}
updateCurrentPresetUI();
}
});
rootMenu.getItems().addAll(addFolder, addPreset, new SeparatorMenuItem(), syncPresets, managePresets);
} else {
parent.getItems().addAll(addFolder, addPreset);
}
}
Aggregations