use of com.willwinder.ugs.nbp.lib.services.ActionRegistrationService in project Universal-G-Code-Sender by winder.
the class JogActionService method initActions.
/**
* Create the actions, this makes them available for keymapping and makes
* them usable from the drop down menu's.
*/
private void initActions() {
ActionRegistrationService ars = Lookup.getDefault().lookup(ActionRegistrationService.class);
try {
String localized = String.format("Menu/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.jog"));
String category = "Machine";
String localCategory = Localization.getString("platform.menu.machine");
String menuPath = "Menu/" + category + "/Jog";
ars.registerAction(JogActionService.class.getCanonicalName() + ".xPlus", Localization.getString("jogging.xPlus"), category, localCategory, "M-RIGHT", menuPath, localized, new JogAction(jogService, 1, 0));
ars.registerAction(JogActionService.class.getCanonicalName() + ".xMinus", Localization.getString("jogging.xMinus"), category, localCategory, "M-LEFT", menuPath, localized, new JogAction(jogService, -1, 0));
ars.registerAction(JogActionService.class.getCanonicalName() + ".yPlus", Localization.getString("jogging.yPlus"), category, localCategory, "M-UP", menuPath, localized, new JogAction(jogService, 0, 1));
ars.registerAction(JogActionService.class.getCanonicalName() + ".yMinus", Localization.getString("jogging.yMinus"), category, localCategory, "M-DOWN", menuPath, localized, new JogAction(jogService, 0, -1));
ars.registerAction(JogActionService.class.getCanonicalName() + ".zPlus", Localization.getString("jogging.zPlus"), category, localCategory, "SM-UP", menuPath, localized, new JogAction(jogService, 1));
ars.registerAction(JogActionService.class.getCanonicalName() + ".zMinus", Localization.getString("jogging.zMinus"), category, localCategory, "SM-DOWN", menuPath, localized, new JogAction(jogService, -1));
localized = String.format("Menu/%s/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.jog"), Localization.getString("platform.menu.jog.size"));
menuPath = menuPath + "/Step Size";
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".10", "10", category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, 10));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".1", "1", category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, 1));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".01", "0.1", category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, 0.1));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".001", "0.01", category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, 0.01));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".0001", "0.001", category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, 0.001));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".divide", Localization.getString("jogging.divide"), category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, '/'));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".multiply", Localization.getString("jogging.multiply"), category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, '*'));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".decrease", Localization.getString("jogging.decrease"), category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, '-'));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".increase", Localization.getString("jogging.increase"), category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, '+'));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".inch", Localization.getString("mainWindow.swing.inchRadioButton"), category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, Units.INCH));
ars.registerAction(JogSizeAction.class.getCanonicalName() + ".mm", Localization.getString("mainWindow.swing.mmRadioButton"), category, localCategory, "", menuPath, localized, new JogSizeAction(jogService, Units.MM));
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
use of com.willwinder.ugs.nbp.lib.services.ActionRegistrationService in project Universal-G-Code-Sender by winder.
the class MacroService method reInitActions.
public void reInitActions() {
String menuPath = "Menu/Machine/Macros";
String actionCategory = "Macro";
String localCategory = Localization.getString("platform.menu.macros");
String localized = String.format("Menu/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.macros"));
try {
FileObject root = FileUtil.getConfigRoot();
// Clear out the menu items.
FileUtil.createFolder(root, menuPath).delete();
FileUtil.createFolder(root, menuPath);
String actionPath = "/Actions/" + actionCategory;
FileUtil.createFolder(root, actionPath).delete();
// FileObject actionsObject = FileUtil.createFolder(root, actionPath);
ActionRegistrationService ars = Lookup.getDefault().lookup(ActionRegistrationService.class);
BackendAPI backend = CentralLookup.getDefault().lookup(BackendAPI.class);
Settings settings = backend.getSettings();
int numMacros = settings.getNumMacros();
for (int i = 0; i < numMacros; i++) {
Macro m = settings.getMacro(i);
ars.registerAction(MacroAction.class.getCanonicalName() + "." + m.getName(), m.getName(), actionCategory, localCategory, null, menuPath, localized, new MacroAction(settings, backend, i));
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.willwinder.ugs.nbp.lib.services.ActionRegistrationService in project Universal-G-Code-Sender by winder.
the class RunActionService method initActions.
public final void initActions() {
ActionRegistrationService ars = Lookup.getDefault().lookup(ActionRegistrationService.class);
try {
String localized;
String menuPath;
String category;
String localizedCategory;
// Feed Overrides
category = "Overrides";
localizedCategory = Localization.getString("platform.menu.overrides");
menuPath = "Menu/Machine/Overrides";
localized = String.format("Menu/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.overrides"));
String pattern = Localization.getString("overrides.feed") + " (%s)";
ars.registerAction(OverrideAction.class.getCanonicalName() + ".feedOvrCoarseMinus", String.format(pattern, OverridesPanel.MINUS_COARSE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_FEED_OVR_COARSE_MINUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".feedOvrFineMinus", String.format(pattern, OverridesPanel.MINUS_FINE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_FEED_OVR_FINE_MINUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".feedOvrFinePlus", String.format(pattern, OverridesPanel.PLUS_FINE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_FEED_OVR_FINE_PLUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".feedOvrCoarsePlus", String.format(pattern, OverridesPanel.PLUS_COARSE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_FEED_OVR_COARSE_PLUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".feedOvrReset", String.format(pattern, OverridesPanel.RESET_FEED), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_FEED_OVR_RESET));
// Spindle Overrides
menuPath = "Menu/Machine/Overrides";
localized = String.format("Menu/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.overrides"));
pattern = Localization.getString("overrides.spindle") + " (%s)";
ars.registerAction(OverrideAction.class.getCanonicalName() + ".spindleOvrCoarseMinus", String.format(pattern, OverridesPanel.MINUS_COARSE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_SPINDLE_OVR_COARSE_MINUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".spindleOvrFineMinus", String.format(pattern, OverridesPanel.MINUS_FINE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_SPINDLE_OVR_FINE_MINUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".spindleOvrFinePlus", String.format(pattern, OverridesPanel.PLUS_FINE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_SPINDLE_OVR_FINE_PLUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".spindleOvrCoarsePlus", String.format(pattern, OverridesPanel.PLUS_COARSE), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_SPINDLE_OVR_COARSE_PLUS));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".spindleOvrReset", String.format(pattern, Localization.getString("mainWindow.swing.reset")), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_SPINDLE_OVR_RESET));
// Rapid Overrides
menuPath = "Menu/Machine/Overrides";
localized = String.format("Menu/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.overrides"));
pattern = Localization.getString("overrides.rapid") + " (%s)";
ars.registerAction(OverrideAction.class.getCanonicalName() + ".rapidOvrLow", String.format(pattern, OverridesPanel.RAPID_LOW), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_RAPID_OVR_LOW));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".rapidOvrMedium", String.format(pattern, OverridesPanel.RAPID_MEDIUM), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_RAPID_OVR_MEDIUM));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".rapidOvrReset", String.format(pattern, OverridesPanel.RAPID_FULL), category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_RAPID_OVR_RESET));
// Toggles
menuPath = "Menu/Machine/Overrides/Toggles";
localized = String.format("Menu/%s/%s/%s", Localization.getString("platform.menu.machine"), Localization.getString("platform.menu.overrides"), Localization.getString("overrides.toggle.short"));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".toggleSpindle", OverridesPanel.SPINDLE_SHORT, category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_TOGGLE_SPINDLE));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".toogleFloodCoolant", OverridesPanel.FLOOD, category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_TOGGLE_FLOOD_COOLANT));
ars.registerAction(OverrideAction.class.getCanonicalName() + ".toggleMistCoolant", OverridesPanel.MIST, category, localizedCategory, null, menuPath, localized, new OverrideAction(this, Overrides.CMD_TOGGLE_MIST_COOLANT));
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
Aggregations