]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/console/SCLConsole.java
Added SCL Script Output console view.
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / console / SCLConsole.java
index 16a946fbebb86922ee99bd9ad481b5e547d37fd1..dcb56cc3a72d7d29354efd6544fc11af7ff8dcd0 100644 (file)
@@ -58,13 +58,23 @@ public class SCLConsole extends AbstractCommandConsole {
 
     CommandSession session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);
     ContentProposalAdapter contentProposalAdapter;
-    
+
     public SCLConsole(Composite parent, int style) {
-        super(parent, style);
-        
+        this(parent, style, 0);
+    }
+
+    public SCLConsole(Composite parent, int style, int options) {
+        super(parent, style, options);
+        createContentProposalAdapter();
+        addContributedListeners();
+    }
+
+    protected void createContentProposalAdapter() {
+        if (input == null)
+            return;
+
         StyledTextContentAdapter styledTextContentAdapter = new StyledTextContentAdapter();
         SCLContentProposalProvider contentProvider = new SCLContentProposalProvider(session);
-        
         try {
             contentProposalAdapter = new ContentProposalAdapter(
                     input, 
@@ -76,15 +86,13 @@ public class SCLConsole extends AbstractCommandConsole {
         } catch (ParseException e) {
             // No content assist then.
         }
-        
-        addContributedListeners();
     }
 
     @Override
     protected boolean canExecuteCommand() {
-        return !contentProposalAdapter.isProposalPopupOpen();
+        return contentProposalAdapter == null || !contentProposalAdapter.isProposalPopupOpen();
     }
-    
+
     @Override
     public ErrorAnnotation[] validate(String command) {
         if(command.isEmpty())
@@ -216,7 +224,7 @@ public class SCLConsole extends AbstractCommandConsole {
         consoleIsEmpty = true;
     }
 
-    private void addContributedListeners() {
+    protected void addContributedListeners() {
         final BundleContext context = Activator.getInstance().getBundle().getBundleContext();
         new ServiceTracker<SCLConsoleListener, SCLConsoleListener>(context,
                 SCLConsoleListener.class, null) {