From: Tuukka Lehtonen Date: Fri, 26 Jan 2018 11:33:10 +0000 (+0200) Subject: Fixed SCL Console Clear Console active-state when imports are erroneous X-Git-Tag: v1.43.0~136^2~618 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F01%2F1401%2F1;p=simantics%2Fplatform.git Fixed SCL Console Clear Console active-state when imports are erroneous Current imports were set too early in SCLConsoleView which before the SCLConsoleListener that enables the buttons is registered. refs #7727 Change-Id: I7cb0645bea5dc48a4ad54f2147c83cb8dfb2f35f --- diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java index 788615ae0..5a4a58f33 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/Activator.java @@ -98,7 +98,7 @@ public class Activator extends AbstractUIPlugin { public void start(BundleContext context) throws Exception { super.start(context); plugin = this; - this.context = context; + Activator.context = context; Bundle bundle = context.getBundle(); @@ -180,14 +180,6 @@ public class Activator extends AbstractUIPlugin { public void startedExecution() { Simantics.getSession().markUndoPoint(); } - - @Override - public void finishedExecution() { - } - - @Override - public void consoleIsNotEmptyAnymore() { - } }, properties); context.registerService(ImportModulesAction.class, OntologyImportModulesAction.INSTANCE, diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/SCLConsoleListener.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/SCLConsoleListener.java index e5cc30584..f07dfc58e 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/SCLConsoleListener.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/commands/SCLConsoleListener.java @@ -1,7 +1,7 @@ package org.simantics.scl.compiler.commands; public interface SCLConsoleListener { - void startedExecution(); - void finishedExecution(); - void consoleIsNotEmptyAnymore(); + default void startedExecution() {} + default void finishedExecution() {} + default void consoleIsNotEmptyAnymore() {} } diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsoleView.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsoleView.java index 4c0d829f3..67de0b2ff 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsoleView.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsoleView.java @@ -173,11 +173,6 @@ 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(); @@ -253,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", @@ -266,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 { diff --git a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLScriptConsoleView.java b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLScriptConsoleView.java index 71801c690..cef58bb3d 100644 --- a/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLScriptConsoleView.java +++ b/bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLScriptConsoleView.java @@ -26,12 +26,6 @@ public class SCLScriptConsoleView extends ViewPart { toolBarManager.add(clearAction); console.addListener(new SCLConsoleListener() { - @Override - public void startedExecution() { - } - @Override - public void finishedExecution() { - } @Override public void consoleIsNotEmptyAnymore() { clearAction.setEnabled(true);