use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.
the class SettingsUIImpl method getActionSetting.
/**
* {@inheritDoc}
*/
@Override
public IActionSetting getActionSetting(final String label, final String category) {
// Has to be here since it must be executed in the initialize method!
this.prepareActions();
final String cat = category + " - " + label;
final SettableEnumValue categorySetting = this.preferences.getEnumSetting(label + ": Category", cat, this.categoryNames, this.categoryNames[0]);
final Map<String, SettableEnumValue> categoryActionsSettings = new TreeMap<>();
for (final String categoryName : this.categoryNames) {
final String[] actionNames = this.categoriesActionIDs.get(categoryName);
categoryActionsSettings.put(categoryName, this.preferences.getEnumSetting(label + ": " + categoryName + " Actions", cat, actionNames, actionNames[0]));
}
return new ActionSettingImpl(categorySetting, categoryActionsSettings, this.actionIDsNames, this.actionCategories);
}
use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.
the class ActionSettingImpl method set.
/**
* {@inheritDoc}
*/
@Override
public void set(final String actionID) {
final String category = this.actionCategories.get(actionID);
final String actionName = this.actionsMap.get(actionID);
// Could only happen if actions would be removed
if (category == null || actionName == null)
return;
// Select the category of the action
this.categorySetting.set(category);
final SettableEnumValue categoryActionsSetting = this.categoryActionsSettings.get(category);
if (categoryActionsSetting == null)
return;
// Only show the actions list of the category
for (final SettableEnumValue setting : this.categoryActionsSettings.values()) {
if (setting == categoryActionsSetting)
((Setting) setting).show();
else
((Setting) setting).hide();
}
// Finally select the action
categoryActionsSetting.set(actionName);
}
use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.
the class ActionSettingImpl method addValueObserver.
/**
* {@inheritDoc}
*/
@Override
public void addValueObserver(final IValueObserver<String> observer) {
this.observer = observer;
this.categorySetting.addValueObserver(value -> this.notifyOberserver());
for (final SettableEnumValue setting : this.categoryActionsSettings.values()) setting.addValueObserver(value -> this.notifyOberserver());
// Directly fire the current value
observer.update(this.get());
}
use of com.bitwig.extension.controller.api.SettableEnumValue in project DrivenByMoss by git-moss.
the class ActionSettingImpl method get.
/**
* {@inheritDoc}
*/
@Override
public String get() {
// Get the setting for the selected category
final String selectedCategory = this.categorySetting.get();
final SettableEnumValue setting = this.categoryActionsSettings.get(selectedCategory);
if (setting == null)
return this.actionsMap.keySet().iterator().next();
// Get and return the ID of the selected action
final String actionName = setting.get();
for (final Map.Entry<String, String> e : this.actionsMap.entrySet()) {
if (e.getValue().equals(actionName))
return e.getKey();
}
return this.actionsMap.keySet().iterator().next();
}
Aggregations