Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 89178 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/debug/internal/ui/actions/LaunchShortcutAction.java (-2 / +37 lines)
Lines 17-27 Link Here
17
import org.eclipse.core.expressions.Expression;
17
import org.eclipse.core.expressions.Expression;
18
import org.eclipse.core.expressions.IEvaluationContext;
18
import org.eclipse.core.expressions.IEvaluationContext;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
23
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.ILaunchShortcut;
22
import org.eclipse.jface.action.Action;
25
import org.eclipse.jface.action.Action;
23
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.jface.viewers.StructuredSelection;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.widgets.Event;
25
import org.eclipse.ui.IEditorPart;
31
import org.eclipse.ui.IEditorPart;
26
import org.eclipse.ui.IWorkbenchPage;
32
import org.eclipse.ui.IWorkbenchPage;
27
import org.eclipse.ui.IWorkbenchWindow;
33
import org.eclipse.ui.IWorkbenchWindow;
Lines 44-51 Link Here
44
		fShortcut = shortcut;
50
		fShortcut = shortcut;
45
		updateEnablement();
51
		updateEnablement();
46
	}
52
	}
47
	
48
	
49
53
50
	/**
54
	/**
51
	 * Runs with either the active editor or workbench selection.
55
	 * Runs with either the active editor or workbench selection.
Lines 72-77 Link Here
72
		}
76
		}
73
	}
77
	}
74
	
78
	
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
81
	 */
82
	public void runWithEvent(Event event) {
83
		if ((event.stateMask & SWT.MOD1) > 0) {
84
			IWorkbenchWindow wb = DebugUIPlugin.getActiveWorkbenchWindow();
85
			ILaunchConfiguration config = null;
86
			if (wb != null) {
87
				IWorkbenchPage page = wb.getActivePage();
88
				if (page != null) {
89
					if (page.getActivePart() == page.getActiveEditor()) {
90
						IEditorPart editor = page.getActiveEditor();
91
						if (editor != null) {
92
							config = fShortcut.getAssociatedLaunchConfig(editor);
93
						}
94
					} else {
95
						ISelection selection = page.getSelection();
96
						if (selection instanceof IStructuredSelection) {
97
							config = fShortcut.getAssociatedLaunchConfig(selection);
98
						}
99
					}
100
				}
101
			}
102
			IStructuredSelection selection = new StructuredSelection(config);
103
			String id = DebugUITools.getLaunchGroup(config, fMode).getIdentifier();
104
			DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, id);
105
		} else {
106
			run();
107
		}
108
	}
109
75
	/**
110
	/**
76
	 * Since these actions are re-created each time the run/debug as menu is
111
	 * Since these actions are re-created each time the run/debug as menu is
77
	 * filled, the enablement of this action is static.
112
	 * filled, the enablement of this action is static.
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutExtension.java (-3 / +31 lines)
Lines 29-38 Link Here
29
import org.eclipse.core.expressions.IEvaluationContext;
29
import org.eclipse.core.expressions.IEvaluationContext;
30
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.CoreException;
31
import org.eclipse.core.runtime.IConfigurationElement;
31
import org.eclipse.core.runtime.IConfigurationElement;
32
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.debug.internal.ui.DebugUIPlugin;
33
import org.eclipse.debug.internal.ui.DebugUIPlugin;
33
import org.eclipse.debug.internal.ui.Pair;
34
import org.eclipse.debug.internal.ui.Pair;
34
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
35
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
35
import org.eclipse.debug.ui.ILaunchShortcut;
36
import org.eclipse.debug.ui.ILaunchShortcut;
37
import org.eclipse.debug.ui.ILaunchShortcut2;
36
import org.eclipse.jface.resource.ImageDescriptor;
38
import org.eclipse.jface.resource.ImageDescriptor;
37
import org.eclipse.jface.viewers.ISelection;
39
import org.eclipse.jface.viewers.ISelection;
38
import org.eclipse.jface.viewers.StructuredSelection;
40
import org.eclipse.jface.viewers.StructuredSelection;
Lines 45-55 Link Here
45
/**
47
/**
46
 * Proxy to a launch shortcut extension
48
 * Proxy to a launch shortcut extension
47
 */
49
 */
48
public class LaunchShortcutExtension implements ILaunchShortcut, IPluginContribution {
50
public class LaunchShortcutExtension implements ILaunchShortcut2, IPluginContribution {
49
	
51
	
50
	private ImageDescriptor fImageDescriptor = null;
52
	private ImageDescriptor fImageDescriptor = null;
51
	private List fPerspectives = null;
53
	private List fPerspectives = null;
52
	private ILaunchShortcut fDelegate = null;
54
	private ILaunchShortcut2 fDelegate = null;
53
	private Set fModes = null;
55
	private Set fModes = null;
54
	private IConfigurationElement fContextualLaunchConfigurationElement = null;
56
	private IConfigurationElement fContextualLaunchConfigurationElement = null;
55
	private Expression fContextualLaunchExpr = null;
57
	private Expression fContextualLaunchExpr = null;
Lines 342-348 Link Here
342
	protected ILaunchShortcut getDelegate() {
344
	protected ILaunchShortcut getDelegate() {
343
		if (fDelegate == null) {
345
		if (fDelegate == null) {
344
			try {
346
			try {
345
				fDelegate = (ILaunchShortcut)fConfig.createExecutableExtension("class"); //$NON-NLS-1$
347
				fDelegate = (ILaunchShortcut2)fConfig.createExecutableExtension("class"); //$NON-NLS-1$
346
			} catch (CoreException e) {
348
			} catch (CoreException e) {
347
				DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.LaunchShortcutExtension_Error_4, LaunchConfigurationsMessages.LaunchShortcutExtension_Unable_to_use_launch_shortcut_5, e.getStatus()); // 
349
				DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.LaunchShortcutExtension_Error_4, LaunchConfigurationsMessages.LaunchShortcutExtension_Unable_to_use_launch_shortcut_5, e.getStatus()); // 
348
			}
350
			}
Lines 421-425 Link Here
421
	public String getPluginId() {
423
	public String getPluginId() {
422
		return fConfig.getContributor().getName();
424
		return fConfig.getContributor().getName();
423
	}
425
	}
426
427
	/* (non-Javadoc)
428
	 * @see org.eclipse.debug.ui.ILaunchShortcut#getAssociatedLaunchConfig(org.eclipse.jface.viewers.ISelection, java.lang.String)
429
	 */
430
	public ILaunchConfiguration getAssociatedLaunchConfig(ISelection selection) {
431
		if(fDelegate == null) {
432
			getDelegate();
433
		}
434
		if(fDelegate != null) {
435
			return fDelegate.getAssociatedLaunchConfig(selection);
436
		}
437
		return null;
438
	}
439
440
	/* (non-Javadoc)
441
	 * @see org.eclipse.debug.ui.ILaunchShortcut#getAssociatedLaunchConfig(org.eclipse.ui.IEditorPart, java.lang.String)
442
	 */
443
	public ILaunchConfiguration getAssociatedLaunchConfig(IEditorPart editor) {
444
		if(fDelegate == null) {
445
			getDelegate();
446
		}
447
		if(fDelegate != null) {
448
			return fDelegate.getAssociatedLaunchConfig(editor);
449
		}
450
		return null;
451
	}
424
}
452
}
425
453
(-)ui/org/eclipse/debug/ui/ILaunchShortcut2.java (+42 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.ui;
12
13
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.ui.IEditorPart;
16
17
/**
18
 * Provides new capabilities to have access to the associated <code>ILaunchCongfiguration</code>.
19
 * This interface is intended to be used in the event your launch shortcut will provide access to 
20
 * the <code>LaunchConfigurationsDialog</code> via the Ctrl+Click mechanism
21
 * @since 3.3
22
 */
23
public interface ILaunchShortcut2 extends ILaunchShortcut {
24
	
25
	/**
26
	 * Locates and returns the associated <code>ILaunchConfiguration</code> for the specified
27
	 * <code>ISelection</code>. This method can return <code>null</code>.
28
	 * @param selection the selection to search for a config for
29
	 * @return the associated <code>ILaunchConfiguration</code> or <code>null</code> if none found
30
	 * @since 3.3
31
	 */
32
	public ILaunchConfiguration getAssociatedLaunchConfig(ISelection selection);
33
	
34
	/**
35
	 * Locates and returns the associated <code>ILaunchConfiguration</code> for the specified
36
	 * <code>IEditorPart</code>. This method can return <code>null</code>.
37
	 * @param editor the editor to search for the associated config for
38
	 * @return the associated <code>IlaunchConfiguration</code> or <code>null</code> if none found.
39
	 * @since 3.3
40
	 */
41
	public ILaunchConfiguration getAssociatedLaunchConfig(IEditorPart editor);
42
}
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaLaunchShortcut.java (-3 / +60 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 22-28 Link Here
22
import org.eclipse.debug.core.ILaunchManager;
22
import org.eclipse.debug.core.ILaunchManager;
23
import org.eclipse.debug.ui.DebugUITools;
23
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.IDebugModelPresentation;
24
import org.eclipse.debug.ui.IDebugModelPresentation;
25
import org.eclipse.debug.ui.ILaunchShortcut;
25
import org.eclipse.debug.ui.ILaunchShortcut2;
26
import org.eclipse.jdt.core.IJavaElement;
26
import org.eclipse.jdt.core.IJavaElement;
27
import org.eclipse.jdt.core.IType;
27
import org.eclipse.jdt.core.IType;
28
import org.eclipse.jdt.core.JavaModelException;
28
import org.eclipse.jdt.core.JavaModelException;
Lines 48-54 Link Here
48
 * 
48
 * 
49
 * @since 3.2
49
 * @since 3.2
50
 */
50
 */
51
public abstract class JavaLaunchShortcut implements ILaunchShortcut {
51
public abstract class JavaLaunchShortcut implements ILaunchShortcut2 {
52
	
52
	
53
	/**
53
	/**
54
	 * @param search the java elements to search for a main type
54
	 * @param search the java elements to search for a main type
Lines 118-123 Link Here
118
	}
118
	}
119
	
119
	
120
	/**
120
	/**
121
	 * Searches for the associated launch configuration for the specified items
122
	 * @param items the items to search against
123
	 * @param mode the mode to constrain to 
124
	 * @return the associated launch configuraiton or null if none found
125
	 * @since 3.3
126
	 */
127
	protected ILaunchConfiguration findConfiguration(Object[] items) {
128
		try {
129
			IType[] types = findTypes(items, PlatformUI.getWorkbench().getProgressService());
130
			IType type = null;
131
			if (types.length == 0) {
132
				return null;
133
			} 
134
			else if (types.length > 1) {
135
				try {
136
					type = chooseType(types, getTypeSelectionTitle());
137
				} catch (JavaModelException e) {
138
					reportErorr(e); 
139
					return null;
140
				}
141
			} 
142
			else {
143
				type = types[0];
144
			}
145
			if(type != null) {
146
				return findLaunchConfiguration(type, getConfigurationType());
147
			}
148
		}
149
		catch(CoreException ce) {JDIDebugUIPlugin.log(ce);}
150
		catch(InterruptedException ie) {JDIDebugUIPlugin.log(ie);}
151
		return null;
152
	}
153
	
154
	/* (non-Javadoc)
155
	 * @see org.eclipse.debug.ui.ILaunchShortcut#getAssociatedLaunchConfig(org.eclipse.ui.IEditorPart, java.lang.String)
156
	 */
157
	public ILaunchConfiguration getAssociatedLaunchConfig(IEditorPart editor) {
158
		IEditorInput input = editor.getEditorInput();
159
		IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class);
160
		if (je != null) {
161
			return findConfiguration(new Object[] {je});
162
		}
163
		return null;
164
	}
165
166
	/* (non-Javadoc)
167
	 * @see org.eclipse.debug.ui.ILaunchShortcut#getAssociatedLaunchConfig(org.eclipse.jface.viewers.ISelection, java.lang.String)
168
	 */
169
	public ILaunchConfiguration getAssociatedLaunchConfig(ISelection selection) {
170
		if (selection instanceof IStructuredSelection) {
171
			return findConfiguration(((IStructuredSelection)selection).toArray());
172
		}
173
		return null;
174
	}
175
176
	
177
	/**
121
	 * Launches a configuration for the given type
178
	 * Launches a configuration for the given type
122
	 */
179
	 */
123
	protected void launch(IType type, String mode) {
180
	protected void launch(IType type, String mode) {

Return to bug 89178