public class SCLConsoleView extends ViewPart {
- public static final String PLUGIN_ID = "org.simantics.scl.ui";
- public static final String IMPORTS = "imports";
- public static final String REFRESH_AUTOMATICALLY = "refresh-automatically";
- public static final String SEPARATOR = ";";
- public static final String DISABLED_TAG = "[DISABLED]";
+ public static final String PLUGIN_ID = "org.simantics.scl.ui"; //$NON-NLS-1$
+ public static final String IMPORTS = "imports"; //$NON-NLS-1$
+ public static final String REFRESH_AUTOMATICALLY = "refresh-automatically"; //$NON-NLS-1$
+ public static final String SEPARATOR = ";"; //$NON-NLS-1$
+ public static final String DISABLED_TAG = "[DISABLED]"; //$NON-NLS-1$
IPersistentPreferenceStore store;
SCLConsole console;
disabled = true;
entryString = entryString.substring(DISABLED_TAG.length());
}
- String[] parts = entryString.split("=");
+ String[] parts = entryString.split("="); //$NON-NLS-1$
CommandSessionImportEntry entry;
if(parts.length == 1)
- entry = new CommandSessionImportEntry(parts[0], "", true);
+ entry = new CommandSessionImportEntry(parts[0], "", true); //$NON-NLS-1$
else
entry = new CommandSessionImportEntry(parts[1], parts[0], true);
entry.disabled = disabled;
b.append(DISABLED_TAG);
if(!entry.localName.isEmpty()) {
b.append(entry.localName);
- b.append("=");
+ b.append("="); //$NON-NLS-1$
}
b.append(entry.moduleName);
}
try {
// Bit of a haxx solution to get around a deadlock caused by simply
// running the test with test.run()
- console.execute("import \"Commands/Tests\"");
- console.execute("runByName \"" + test.getName() + "\"");
+ console.execute("import \"Commands/Tests\""); //$NON-NLS-1$
+ console.execute("runByName \"" + test.getName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
// test.run();
} catch (Exception e) {
e.printStackTrace();
@Override
public void createPartControl(Composite parent) {
store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_ID);
- this.console = new SCLConsole(parent, SWT.NONE);
+ store.setDefault(REFRESH_AUTOMATICALLY, true);
- setRefreshAutomatically(store.getBoolean(REFRESH_AUTOMATICALLY), false);
- setCurrentImports(readImportPreferences());
-
- addScriptDropSupport(console);
+ this.console = new SCLConsole(parent, SWT.NONE);
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
// Interrupt action
- final Action interruptAction = new Action("Interrupt current command",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/stop.png")) {
- @Override
- public void run() {
- console.interruptCurrentCommands();
- }
- };
- interruptAction.setDisabledImageDescriptor(
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/stop_disabled.png"));
- interruptAction.setEnabled(false);
+ Action interruptAction = ConsoleActions.createInterruptAction(console);
toolBarManager.add(interruptAction);
// Clear console action
- final Action clearAction = new Action("Clear console",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/clear_console.png")) {
- @Override
- public void run() {
- setEnabled(false);
- console.clear();
- }
- };
- clearAction.setDisabledImageDescriptor(
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/clear_console_disabled.png"));
- clearAction.setEnabled(false);
+ Action clearAction = ConsoleActions.createClearAction(console);
toolBarManager.add(clearAction);
+
console.addListener(new SCLConsoleListener() {
@Override
public void startedExecution() {
});
// Refresh action
- toolBarManager.add(new Action("Refresh modules", IAction.AS_DROP_DOWN_MENU) {
+ toolBarManager.add(new Action(Messages.SCLConsoleView_RefreshModules, IAction.AS_DROP_DOWN_MENU) {
{
- setImageDescriptor(Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png"));
+ setImageDescriptor(Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/arrow_refresh.png")); //$NON-NLS-1$ //$NON-NLS-2$
setMenuCreator(new IMenuCreator() {
Menu menu;
@Override
if(menu == null) {
menu = new Menu(parent);
refreshAutomaticallyItem = new MenuItem(menu, SWT.CHECK);
- refreshAutomaticallyItem.setText("Refresh automatically");
+ refreshAutomaticallyItem.setText(Messages.SCLConsoleView_RefreshAutomatically);
refreshAutomaticallyItem.setSelection(refreshAutomatically);
refreshAutomaticallyItem.addSelectionListener(new SelectionAdapter() {
@Override
public void run() {
console.getSession().getModuleRepository().getSourceRepository().checkUpdates();
console.getSession().updateRuntimeEnvironment(true);
- console.appendOutput("refresh completed\n", console.greenColor, null);
+ console.appendOutput(Messages.SCLConsoleView_RefreshCompleted, console.greenColor, null);
}
});
- toolBarManager.add(new Action("Manage imports",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/configure_imports.png")) {
+ toolBarManager.add(new Action(Messages.SCLConsoleView_ManageImports,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/configure_imports.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
manageImports();
}
});
-
+
// Show action for running SCL tests if in development mode
if (Platform.inDevelopmentMode()) {
- toolBarManager.add(new Action("Run tests",
- Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/run_tests.png")) {
+ toolBarManager.add(new Action(Messages.SCLConsoleView_RunTests,
+ Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/run_tests.png")) { //$NON-NLS-1$ //$NON-NLS-2$
@Override
public void run() {
sclTestDialog();
}
toolBarManager.update(true);
+
+ setRefreshAutomatically(store.getBoolean(REFRESH_AUTOMATICALLY), false);
+ // Do this after the actions and SCLConsoleListener are
+ // registered because it can cause output to the console.
+ setCurrentImports(readImportPreferences());
+ addScriptDropSupport(console);
}
private class ScriptRunningDropTarget extends DropTargetAdapter {
for (String file : files) {
Path p = Paths.get(file).toAbsolutePath();
if (isScriptFile(p)) {
- console.execute("runFromFile \"" + p.toString().replace('\\', '/') + "\"");
+ console.execute("runFromFile \"" + p.toString().replace('\\', '/') + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}