use of com.willwinder.universalgcodesender.model.BackendAPI in project Universal-G-Code-Sender by winder.
the class startup method process.
@Override
protected void process(Env env, Map<Option, String[]> maps) throws CommandException {
BackendAPI backend = CentralLookup.getDefault().lookup(BackendAPI.class);
String inputFile = null;
int count = 0;
for (String[] files : maps.values()) {
for (String file : files) {
count++;
inputFile = file;
}
}
if (count == 0 || count > 1) {
throw new CommandException(1, "Too many input files provided.");
}
System.out.println("File to open: " + inputFile);
try {
backend.setGcodeFile(new File(inputFile));
} catch (Exception e) {
throw new CommandException(1, "Unable to open input file: " + e.getMessage());
}
}
use of com.willwinder.universalgcodesender.model.BackendAPI 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.universalgcodesender.model.BackendAPI in project Universal-G-Code-Sender by winder.
the class WidgetPreviewer method main.
public static void main(String[] args) throws Exception {
BackendAPI backend = new GUIBackend();
backend.applySettings(SettingsFactory.loadSettings());
JPanel panel = new JPanel();
// Create the main frame.
JFrame frame = new JFrame("Widget Previewer");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
// Button panel...
panel.setLayout(new MigLayout("wrap 1"));
panel.add(frameLauncherButton("ConnectionPanelGroup", new ConnectionPanelGroup(backend, new JogService(backend))));
panel.add(frameLauncherButton("CommandTextArea", new CommandTextArea(backend)));
// panel.add(frameLauncherButton("ConnectionSettingsDialog", new ConnectionSettingsDialog(backend.getSettings()), null, false));
panel.add(dialogLauncherButton("ConnectionSettingsPanel", new UGSSettingsDialog("ConnectionSettingsPanel", backend.getSettings(), new ConnectionSettingsPanel(backend.getSettings()), frame, true)));
panel.add(dialogLauncherButton("ControllerProcessorSettingsPanel", new UGSSettingsDialog("ControllerProcessorSettingsPanel", backend.getSettings(), new ControllerProcessorSettingsPanel(backend.getSettings(), FirmwareUtils.getConfigFiles()), frame, true)));
panel.add(frameLauncherButton("MacroActionPanel", new MacroActionPanel(backend)));
panel.add(frameLauncherButton("MacroPanel", new MacroPanel(backend)));
panel.add(frameLauncherButton("OverridesPanel", new OverridesPanel(backend)));
panel.add(frameLauncherButton("SendStatusLine", new SendStatusLine(backend)));
panel.add(frameLauncherButton("SendStatusPanel", new SendStatusPanel(backend)));
panel.add(frameLauncherButton("ActionButtonPanel", new ActionButtonPanel(backend)));
panel.add(frameLauncherButton("ActionPanel", new ActionPanel(backend)));
panel.add(frameLauncherButton("CommandPanel", new CommandPanel(backend)));
panel.add(frameLauncherButton("JogPanel(true)", new JogPanel(backend, new JogService(backend), true)));
panel.add(frameLauncherButton("JogPanel(false)", new JogPanel(backend, new JogService(backend), false)));
panel.add(frameLauncherButton("MachineStatusPanel", new MachineStatusPanel(backend)));
// Display the main frame.
frame.pack();
frame.setVisible(true);
}
Aggregations