Commits

Anonymous committed 59f8d58

When launcher starts repl, perspective is automatically switched to lisp.

Comments (0)

Files changed (4)

META-INF/MANIFEST.MF

  org.lispdev.console;bundle-version="1.0.0",
  org.lispdev.swank;bundle-version="1.0.0",
  org.lispdev.log;bundle-version="1.0.0",
- org.lispdev.repl;bundle-version="1.0.0"
+ org.lispdev.repl;bundle-version="1.0.0",
+ org.lispdev.main;bundle-version="1.0.0"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6

src/org/lispdev/replview/LocalLispLaunchDelegate.java

 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
 import org.eclipse.ui.console.ConsolePlugin;
 import org.eclipse.ui.console.IConsole;
 import org.eclipse.ui.console.IConsoleManager;
+import org.lispdev.main.LispPerspectiveFactory;
 import org.lispdev.repl.SwankRunnableDriver;
 import org.lispdev.swank.BaseLocalLispLaunchDelegate;
 import org.lispdev.swank.LispProcess;
   public void launch(ILaunchConfiguration config, String mode,
       ILaunch launch, IProgressMonitor monitor) throws CoreException
   {
-    Assert.isLegal(ILaunchManager.DEBUG_MODE.equals(mode), "Wrong mode");
+    Assert.isLegal(ILaunchManager.DEBUG_MODE.equals(mode) ||
+        ILaunchManager.RUN_MODE.equals(mode),
+        "Wrong mode");
     LispProcess p = launch(config,launch,new SwankRunnableDriver());
-    ReplConsole c = new ReplConsole("REPL", null, p);
-    IConsoleManager cm = ConsolePlugin.getDefault().getConsoleManager();
+    final ReplConsole c = new ReplConsole("REPL", null, p);
+    final IConsoleManager cm = ConsolePlugin.getDefault().getConsoleManager();
     cm.addConsoles(new IConsole[] {c});
-    cm.showConsoleView(c);
+    final IWorkbench wk = PlatformUI.getWorkbench();
+    wk.getDisplay().asyncExec(new Runnable(){
+      @Override
+      public void run()
+      {
+        try
+        {
+          final IWorkbenchWindow w = wk.getActiveWorkbenchWindow();
+          wk.showPerspective(LispPerspectiveFactory.ID,w);
+          cm.showConsoleView(c);
+        }
+        catch(WorkbenchException e)
+        {
+          e.printStackTrace();
+        }
+      }
+    });
   }
 
 }

src/org/lispdev/replview/ReplConsole.java

 public class ReplConsole extends AbstractConsole
 {
   private final LispProcess process;
-//  private final IConsoleManager fConsoleManager =
-//    ConsolePlugin.getDefault().getConsoleManager();
+  private IPageBookViewPage page;
 
   public ReplConsole(String name, ImageDescriptor imageDescriptor,
       LispProcess pr)
   @Override
   public IPageBookViewPage createPage(IConsoleView view)
   {
-    return new ReplConsolePage(process);
+    page = new ReplConsolePage(process);
+    return page;
+  }
+
+  public void setFocus()
+  {
+    if( page != null )
+    {
+      page.setFocus();
+    }
   }
 
 }

src/org/lispdev/replview/ReplConsolePage.java

 public class ReplConsolePage implements IPageBookViewPage
 {
   private IPageSite fSite;
-  private LispConsole fViewer;
 
   private LispConsole replConsole;
   private Repl repl;
   @Override
   public Control getControl()
   {
-    return fViewer != null ? fViewer.getControl() : null;
+    return replConsole != null ? replConsole.getControl() : null;
   }
 
   @Override
   @Override
   public void setFocus()
   {
-    if( fViewer != null )
+    if( replConsole != null )
     {
-      fViewer.getTextWidget().setFocus();
+      replConsole.getTextWidget().setFocus();
     }
   }