]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsoleView.java
Fixed SCL Console Clear Console active-state when imports are erroneous
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / console / SCLConsoleView.java
index 8b49ea345fac656a70b4027959b297f7c4cfa889..67de0b2ffe9e02571d75ec114c22416498e51274 100644 (file)
@@ -173,40 +173,17 @@ public class SCLConsoleView extends ViewPart {
         store.setDefault(REFRESH_AUTOMATICALLY, true);
         
         this.console = new SCLConsole(parent, SWT.NONE);
-        
-        setRefreshAutomatically(store.getBoolean(REFRESH_AUTOMATICALLY), false);
-        setCurrentImports(readImportPreferences());
-
-        addScriptDropSupport(console);
 
         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() {
@@ -271,7 +248,7 @@ public class SCLConsoleView extends ViewPart {
                 manageImports();
             }
         });
-        
+
         // Show action for running SCL tests if in development mode
         if (Platform.inDevelopmentMode()) {
             toolBarManager.add(new Action("Run tests",
@@ -284,6 +261,12 @@ public class SCLConsoleView extends ViewPart {
         }
         
         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 {