Skip to content
This repository
Browse code

debug shortcut

  • Loading branch information...
commit 875ae099790b5d226932b5487e75c4d45debc324 1 parent a461513
JP Moresmau authored
5 ...g.ui/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/InteractiveLaunchOperation.java
@@ -20,7 +20,6 @@
20 20 import org.eclipse.debug.core.ILaunchConfiguration;
21 21 import org.eclipse.debug.core.ILaunchConfigurationType;
22 22 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23   -import org.eclipse.debug.core.ILaunchManager;
24 23 import org.eclipse.osgi.util.NLS;
25 24
26 25
@@ -49,7 +48,7 @@
49 48 // methods called from outside
50 49 //////////////////////////////
51 50
52   - void launch( final IResource[] resources,
  51 + void launch( final IResource[] resources,final String mode,
53 52 final IProgressMonitor monitor ) throws CoreException {
54 53 IFile[] filesToLoad = SelectionAnalyzer.getSourcesToLoad( resources );
55 54 if( resources.length > 0 && resources[ 0 ] != null ) {
@@ -58,7 +57,7 @@ void launch( final IResource[] resources,
58 57 ILaunchConfiguration config = getConfiguration( resources,
59 58 filesToLoad );
60 59 if( config != null ) {
61   - config.launch( ILaunchManager.RUN_MODE, monitor );
  60 + config.launch( mode, monitor );
62 61 }
63 62 }
64 63 }
172 ...ug.ui/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/InteractiveLaunchShortcut.java
... ... @@ -1,87 +1,87 @@
1   -// Copyright (c) 2003-2008 by Leif Frenzel. All rights reserved.
2   -// This code is made available under the terms of the Eclipse Public License,
3   -// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
4   -package net.sf.eclipsefp.haskell.debug.ui.internal.launch;
5   -
6   -import java.util.ArrayList;
7   -import java.util.List;
8   -import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
9   -import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
10   -import org.eclipse.core.resources.IResource;
11   -import org.eclipse.core.runtime.CoreException;
12   -import org.eclipse.core.runtime.IProgressMonitor;
13   -import org.eclipse.core.runtime.NullProgressMonitor;
14   -import org.eclipse.debug.ui.ILaunchShortcut;
15   -import org.eclipse.jface.viewers.ISelection;
16   -import org.eclipse.jface.viewers.IStructuredSelection;
17   -import org.eclipse.ui.IEditorPart;
18   -
19   -/** <p>Shortcut to launch interactive sessions from the 'Run' action set.</p>
20   - *
21   - * <p>Subclasses must be declared in the <code>plugin.xml</code> and then
22   - * need only provide an implementation of
23   - * <code>IInteractiveLaunchOperationDelegate</code> that knows about
24   - * specific details.</p>
25   - *
26   - * @author Leif Frenzel
27   - */
28   -public abstract class InteractiveLaunchShortcut implements ILaunchShortcut {
29   -
30   - // methods to be implemented by subclasses
31   - //////////////////////////////////////////
32   -
33   - /** <p>returns the delegate that knows about the specific details
34   - * for launching an interactive environment.</p> */
35   - public abstract IInteractiveLaunchOperationDelegate getDelegate();
36   -
37   -
38   -
39   - // interface methods of ILaunchShortcut
40   - ///////////////////////////////////////
41   -
42   - public void launch( final ISelection selection, final String mode ) {
43   - // launched from workbench selection
44   - if( selection != null && selection instanceof IStructuredSelection ) {
45   - List<IResource> list = new ArrayList<IResource>();
46   - IStructuredSelection ssel = ( IStructuredSelection )selection;
47   - for( Object element: ssel.toList() ) {
48   - IResource res = ResourceUtil.findResource( element );
49   - if( res != null ) {
50   - list.add( res );
51   - }
52   - }
53   - IResource[] ress = toArray( list );
54   - launch( ress );
55   - }
56   - }
57   -
58   - public void launch( final IEditorPart editor, final String mode ) {
59   - // launched from editor part
60   - IResource resource = ResourceUtil.findResource( editor.getEditorInput() );
61   - launch( new IResource[] { resource } );
62   - }
63   -
64   -
65   - // helping methods
66   - //////////////////
67   -
68   - private void launch( final IResource[] resources ) {
69   - // TODO put this into a Job and use the progress monitor
70   - // also: need a public job family in core (with icon in ui)
71   - try {
72   - IProgressMonitor monitor = new NullProgressMonitor();
73   - new InteractiveLaunchOperation( getDelegate() ).launch( resources,
74   - monitor );
75   - } catch( CoreException cex ) {
76   - // TODO show msg box
77   - String msg = "Could not launch Haskell application."; //$NON-NLS-1$
78   - HaskellUIPlugin.log( msg, cex );
79   - }
80   - }
81   -
82   - private IResource[] toArray( final List<IResource> list ) {
83   - IResource[] result = new IResource[ list.size() ];
84   - list.toArray( result );
85   - return result;
86   - }
  1 +// Copyright (c) 2003-2008 by Leif Frenzel. All rights reserved.
  2 +// This code is made available under the terms of the Eclipse Public License,
  3 +// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
  4 +package net.sf.eclipsefp.haskell.debug.ui.internal.launch;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
  9 +import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
  10 +import org.eclipse.core.resources.IResource;
  11 +import org.eclipse.core.runtime.CoreException;
  12 +import org.eclipse.core.runtime.IProgressMonitor;
  13 +import org.eclipse.core.runtime.NullProgressMonitor;
  14 +import org.eclipse.debug.ui.ILaunchShortcut;
  15 +import org.eclipse.jface.viewers.ISelection;
  16 +import org.eclipse.jface.viewers.IStructuredSelection;
  17 +import org.eclipse.ui.IEditorPart;
  18 +
  19 +/** <p>Shortcut to launch interactive sessions from the 'Run' action set.</p>
  20 + *
  21 + * <p>Subclasses must be declared in the <code>plugin.xml</code> and then
  22 + * need only provide an implementation of
  23 + * <code>IInteractiveLaunchOperationDelegate</code> that knows about
  24 + * specific details.</p>
  25 + *
  26 + * @author Leif Frenzel
  27 + */
  28 +public abstract class InteractiveLaunchShortcut implements ILaunchShortcut {
  29 +
  30 + // methods to be implemented by subclasses
  31 + //////////////////////////////////////////
  32 +
  33 + /** <p>returns the delegate that knows about the specific details
  34 + * for launching an interactive environment.</p> */
  35 + public abstract IInteractiveLaunchOperationDelegate getDelegate();
  36 +
  37 +
  38 +
  39 + // interface methods of ILaunchShortcut
  40 + ///////////////////////////////////////
  41 +
  42 + public void launch( final ISelection selection, final String mode ) {
  43 + // launched from workbench selection
  44 + if( selection != null && selection instanceof IStructuredSelection ) {
  45 + List<IResource> list = new ArrayList<IResource>();
  46 + IStructuredSelection ssel = ( IStructuredSelection )selection;
  47 + for( Object element: ssel.toList() ) {
  48 + IResource res = ResourceUtil.findResource( element );
  49 + if( res != null ) {
  50 + list.add( res );
  51 + }
  52 + }
  53 + IResource[] ress = toArray( list );
  54 + launch( ress,mode );
  55 + }
  56 + }
  57 +
  58 + public void launch( final IEditorPart editor, final String mode ) {
  59 + // launched from editor part
  60 + IResource resource = ResourceUtil.findResource( editor.getEditorInput() );
  61 + launch( new IResource[] { resource } ,mode);
  62 + }
  63 +
  64 +
  65 + // helping methods
  66 + //////////////////
  67 +
  68 + private void launch( final IResource[] resources,final String mode ) {
  69 + // TODO put this into a Job and use the progress monitor
  70 + // also: need a public job family in core (with icon in ui)
  71 + try {
  72 + IProgressMonitor monitor = new NullProgressMonitor();
  73 + new InteractiveLaunchOperation( getDelegate() ).launch( resources,mode,
  74 + monitor );
  75 + } catch( CoreException cex ) {
  76 + // TODO show msg box
  77 + String msg = "Could not launch Haskell application."; //$NON-NLS-1$
  78 + HaskellUIPlugin.log( msg, cex );
  79 + }
  80 + }
  81 +
  82 + private IResource[] toArray( final List<IResource> list ) {
  83 + IResource[] result = new IResource[ list.size() ];
  84 + list.toArray( result );
  85 + return result;
  86 + }
87 87 }
2  net.sf.eclipsefp.haskell.debug.ui/plugin.xml
@@ -49,7 +49,7 @@
49 49 label="%ghciShortcut_label"
50 50 icon="icons/etool16/ghci16.gif"
51 51 class="net.sf.eclipsefp.haskell.debug.ui.internal.launch.ghci.GhciLaunchShortcut"
52   - modes="run"
  52 + modes="run, debug"
53 53 id="net.sf.eclipsefp.haskell.debug.ui.internal.launch.ghci.GhciLaunchShortcut">
54 54 <contextualLaunch>
55 55 <enablement>

0 comments on commit 875ae09

Please sign in to comment.
Something went wrong with that request. Please try again.