Commits

Anonymous committed bd10eab

Removed load-in file and added load file menu items.

Comments (0)

Files changed (4)

org.lispdev.main/plugin.xml

             nameFilter="*.lisp"
             objectClass="org.eclipse.core.resources.IFile">
          <action
-               class="org.lispdev.main.LoadFileInAction"
+               class="org.lispdev.main.LoadFileAction"
                enablesFor="+"
                icon="icons/lisp-file.gif"
                id="org.lispdev.main.LoadLispFileAction"
-               label="Load In"
-               menubarPath="group.add"
-               style="pulldown">
+               label="Load"
+               menubarPath="group.add">
          </action>
       </objectContribution>
       <objectContribution
             nameFilter="*.cl"
             objectClass="org.eclipse.core.resources.IFile">
          <action
-               class="org.lispdev.main.LoadFileInAction"
+               class="org.lispdev.main.LoadFileAction"
                enablesFor="+"
                icon="icons/lisp-file.gif"
                id="org.lispdev.main.LoadCLFileAction"
-               label="Load In"
-               menubarPath="group.add"
-               style="pulldown">
+               label="Load"
+               menubarPath="group.add">
          </action>
       </objectContribution>
    </extension>

org.lispdev.main/src/org/lispdev/main/LoadFileAction.java

+package org.lispdev.main;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.lispdev.repl.AbstractRepl;
+import org.lispdev.repl.ReplPlugin;
+import org.lispdev.swank.ISwank;
+import org.lispdev.swank.SwankPlugin;
+import org.lispdev.swank.debug.LispProcess;
+import org.lispdev.swank.runnables.SwankCompilationRunnable;
+
+public class LoadFileAction implements IObjectActionDelegate
+{
+  private IAction action;
+  private IStructuredSelection selection;
+  private IWorkbenchPart part;
+  private ILaunchConfiguration config = null;
+
+  @Override
+  public void run(IAction action)
+  {
+    loadIn(selection,config);
+  }
+
+  @Override
+  public void selectionChanged(IAction action, ISelection selection)
+  {
+    if( action != this.action )
+    {
+      this.action = action;
+      config = SwankPlugin.get().getActiveConfig();
+      action.setEnabled(config != null);
+    }
+    if( selection instanceof IStructuredSelection )
+    {
+      this.selection = (IStructuredSelection)selection;
+    }
+    else
+    {
+      this.selection = null;
+    }
+  }
+
+  private void loadIn(IStructuredSelection files,
+      final ILaunchConfiguration pr)
+  {
+    if( files == null || pr == null ) return;
+    LispProcess process = SwankPlugin.get().getProcess(pr);
+    if( process == null )
+    {
+      MessageBox mbox =
+        new MessageBox(part.getSite().getShell(), SWT.CANCEL | SWT.ICON_ERROR
+            | SWT.APPLICATION_MODAL);
+      mbox.setText("Error");
+      mbox.setMessage(pr.getName() + " is not started");
+      mbox.open();
+      return;
+    }
+    ISwank swank = process.getSwank();
+    Assert.isNotNull(swank);
+    if( !swank.isConnected() )
+    {
+      swank.connect();
+    }
+    for( Object obj : files.toList() )
+    {
+      if( obj instanceof IFile )
+      {
+        final IFile file = (IFile)obj;
+        swank.sendCompileFile(file.getLocation().toOSString(),
+        new SwankCompilationRunnable(process.getSwank().getLispImplementation())
+        {
+          @Override
+          public void run()
+          {
+            CompilationInfo info = getInfo();
+            final IProject proj = file.getProject();
+
+            AbstractRepl repl = ReplPlugin.get().getRepl(pr);
+            repl.appendOut("Loaded " + file.getName() + "\n");
+            repl.doInput();
+            LoadProjectAction.addCompilationMarkers(info, proj);
+          }
+        });
+      }
+    }
+  }
+
+  @Override
+  public void setActivePart(IAction action, IWorkbenchPart targetPart)
+  {
+    part = targetPart;
+  }
+
+}

org.lispdev.main/src/org/lispdev/main/LoadFileInAction.java

-package org.lispdev.main;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.lispdev.repl.AbstractRepl;
-import org.lispdev.repl.ReplPlugin;
-import org.lispdev.swank.ISwank;
-import org.lispdev.swank.SwankPlugin;
-import org.lispdev.swank.debug.LispProcess;
-import org.lispdev.swank.runnables.SwankCompilationRunnable;
-
-public class LoadFileInAction implements IObjectActionDelegate, IMenuCreator
-{
-  private IAction action;
-  private IStructuredSelection selection;
-  private IWorkbenchPart part;
-
-  @Override
-  public void run(IAction action)
-  {}
-
-  @Override
-  public void selectionChanged(IAction action, ISelection selection)
-  {
-    if( action != this.action )
-    {
-      action.setMenuCreator(this);
-      this.action = action;
-    }
-    if( selection instanceof IStructuredSelection )
-    {
-      this.selection = (IStructuredSelection)selection;
-    }
-    else
-    {
-      this.selection = null;
-    }
-  }
-
-  @Override
-  public void dispose()
-  {}
-
-  @Override
-  public Menu getMenu(Control parent)
-  {
-    return null;
-  }
-
-  @Override
-  public Menu getMenu(Menu parent)
-  {
-    Menu menu = new Menu(parent);
-    for( ILaunchConfiguration p : SwankPlugin.getConfigs() )
-    {
-      final String label = p.getName();
-      final ILaunchConfiguration pr = p;
-      Action a = new Action(label){
-        @Override
-        public void run()
-        {
-          loadIn(selection,pr);
-        }
-      };
-      a.setDescription("Load project in " + label);
-      ActionContributionItem item = new ActionContributionItem(a);
-      item.fill(menu, -1);
-    }
-    return menu;
-  }
-
-  private void loadIn(IStructuredSelection files,
-      final ILaunchConfiguration pr)
-  {
-    if( files == null || pr == null ) return;
-    LispProcess process = SwankPlugin.get().getProcess(pr);
-    if( process == null )
-    {
-      MessageBox mbox =
-        new MessageBox(part.getSite().getShell(), SWT.CANCEL | SWT.ICON_ERROR
-            | SWT.APPLICATION_MODAL);
-      mbox.setText("Error");
-      mbox.setMessage(pr.getName() + " is not started");
-      mbox.open();
-      return;
-    }
-    ISwank swank = process.getSwank();
-    Assert.isNotNull(swank);
-    if( !swank.isConnected() )
-    {
-      swank.connect();
-    }
-    for( Object obj : files.toList() )
-    {
-      if( obj instanceof IFile )
-      {
-        final IFile file = (IFile)obj;
-        swank.sendCompileFile(file.getLocation().toOSString(),
-        new SwankCompilationRunnable(process.getSwank().getLispImplementation())
-        {
-          @Override
-          public void run()
-          {
-            CompilationInfo info = getInfo();
-            final IProject proj = file.getProject();
-
-            AbstractRepl repl = ReplPlugin.get().getRepl(pr);
-            repl.appendOut("Loaded " + file.getName() + "\n");
-            repl.doInput();
-            LoadProjectAction.addCompilationMarkers(info, proj);
-          }
-        });
-      }
-    }
-  }
-
-  @Override
-  public void setActivePart(IAction action, IWorkbenchPart targetPart)
-  {
-    part = targetPart;
-  }
-
-}

org.lispdev.main/todo.txt

 - Delete all saved markers from resources.
 - Get resources associated with new config and add markers from new config.
 
-------------------------
-
-Get lispimplementation, where set rules on how to destructure swank response
-into lispdev structures. I will need to use scripting language for this.