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 74480 | Differences between
and this patch

Collapse All | Expand All

(-)contexts_Debugger.xml (-5 / +17 lines)
Lines 5-11 Link Here
5
	Copyright (c) IBM Corporation and others 2000, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.
5
	Copyright (c) IBM Corporation and others 2000, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page.
6
	
6
	
7
	All Platform Debug contexts, those for org.eclipse.debug.ui, are located in this file
7
	All Platform Debug contexts, those for org.eclipse.debug.ui, are located in this file
8
	All contexts are gouped by their relation, with all relations grouped alphabetically.
8
	All contexts are grouped by their relation, with all relations grouped alphabetically.
9
-->
9
-->
10
<!--
10
<!--
11
	Breakpoints View
11
	Breakpoints View
Lines 558-564 Link Here
558
   		<topic label="Working Sets..." href="reference/views/breakpoints/ref-workingsets_viewaction.htm"/>
558
   		<topic label="Working Sets..." href="reference/views/breakpoints/ref-workingsets_viewaction.htm"/>
559
   	</context>
559
   	</context>
560
   	<context id="delete_associated_launch_configs_dialog">
560
   	<context id="delete_associated_launch_configs_dialog">
561
   		<description>This dialog prompts users to clean up launch configuraitons that are associated with, or used to launch code from, the project that is being deleted </description>
561
   		<description>This dialog prompts users to clean up launch configurations that are associated with, or used to launch code from, the project that is being deleted </description>
562
   		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
562
   		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
563
		<topic label="Creating a Java application launch configuration" href="tasks/tasks-java-local-configuration.htm"/>
563
		<topic label="Creating a Java application launch configuration" href="tasks/tasks-java-local-configuration.htm"/>
564
   	</context>
564
   	</context>
Lines 572-578 Link Here
572
   		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
572
   		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
573
		<topic label="Creating a Java application launch configuration" href="tasks/tasks-java-local-configuration.htm"/>
573
		<topic label="Creating a Java application launch configuration" href="tasks/tasks-java-local-configuration.htm"/>
574
   	</context>
574
   	</context>
575
575
	<context id="select_launch_method_dialog">
576
		<description>This dialog allows you to select a way that you would like to launch the currently selected resource.</description>
577
		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
578
		<topic label="Creating a Java application launch configuration" href="tasks/tasks-java-local-configuration.htm"/>
579
	</context>
576
580
577
581
578
<!--
582
<!--
Lines 677-683 Link Here
677
		<topic label="Source Attachments" href="reference/ref-124.htm"/>
681
		<topic label="Source Attachments" href="reference/ref-124.htm"/>
678
	</context>
682
	</context>
679
	<context  id="launch_configuration_dialog_launchers_tab" >
683
	<context  id="launch_configuration_dialog_launchers_tab" >
680
		<description>This tab allows you to a specific launchers to use with the selected launch configuration in the event ther is more than one available.</description>
684
		<description>This tab allows you to a specific launchers to use with the selected launch configuration in the event there is more than one available.</description>
681
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
685
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
682
	</context>
686
	</context>
683
687
Lines 794-800 Link Here
794
	</context> 
798
	</context> 
795
799
796
<!--
800
<!--
797
	Multiview Action conetxts
801
	Multiview Action contexts
798
-->
802
-->
799
	<context id="find_element_context">
803
	<context id="find_element_context">
800
		<description>This command finds an element by name.</description>
804
		<description>This command finds an element by name.</description>
Lines 867-872 Link Here
867
		<topic label="Debug Preferences" href="reference/preferences/ref-debug.htm"/>
871
		<topic label="Debug Preferences" href="reference/preferences/ref-debug.htm"/>
868
		<topic label="Debugger Concepts" href="concepts/cdebugger.htm"/>
872
		<topic label="Debugger Concepts" href="concepts/cdebugger.htm"/>
869
	</context>
873
	</context>
874
	<context id="contextual_launch_preference_page">
875
		<description>This page allows you to change settings that apply to contextual launching</description>
876
		<topic label="Debug Preferences" href="reference/preferences/ref-debug.htm"/>
877
		<topic label="Debugger Concepts" href="concepts/cdebugger.htm"/>
878
	</context>
870
	
879
	
871
<!-- 
880
<!-- 
872
	Property Pages 
881
	Property Pages 
Lines 880-885 Link Here
880
	<context id="TableRenderingPropertiesPage_context" >
889
	<context id="TableRenderingPropertiesPage_context" >
881
		<description>This page displays properties from the selected memory.</description>
890
		<description>This page displays properties from the selected memory.</description>
882
	</context>
891
	</context>
892
	<context id="default_launchconfiguration_property_page">
893
		<description>This page displays the properties for default launch configurations for the selected resource</description>
894
	</context>
883
895
884
<!--
896
<!--
885
	Run Menu
897
	Run Menu
(-)core/org/eclipse/debug/core/ILaunchConfiguration.java (-6 / +11 lines)
Lines 374-390 Link Here
374
	
374
	
375
	/**
375
	/**
376
	 * Returns a working copy of this launch configuration.
376
	 * Returns a working copy of this launch configuration.
377
	 * If the this method is called on a working copy, a nested working 
378
	 * copy is created (a working copy of a working copy).
377
	 * Changes to the working copy will be applied to this
379
	 * Changes to the working copy will be applied to this
378
	 * launch configuration when saved. The working copy will
380
	 * launch configuration when saved, or to the parent working copy. 
379
	 * refer to this launch configuration as its original
381
	 * The working copy will refer to this launch configuration as its original
380
	 * launch configuration.
382
	 * launch configuration, or the working copy it was created from.
381
	 * <p>
383
	 * <p>
382
	 * When a working copy (B) is created from a working copy (A), the newly
384
	 * When a working copy (B) is created from a working copy (A), the newly
383
	 * created working copy (B) is initialized with the attributes from
385
	 * created working copy (B) is initialized with the attributes from
384
	 * the first working copy (A). Whenever a working copy is saved, it is written
386
	 * the first working copy (A). Whenever a working copy is saved, it is written
385
	 * back to the original non-working copy configuration.
387
	 * back to the working copy from which it was created: in this example working 
388
	 * copy B will write back to working copy A, and A will write back to the 
389
	 * original launch configuration.
386
	 * </p>
390
	 * </p>
387
	 * @return a working copy of this launch configuration
391
	 * @return a working copy of this launch configuration, or a nested working copy if called
392
	 * on an instance of <code>ILaunchConfigurationWorkingCopy</code>
388
	 * @exception CoreException if this method fails. Reasons include:
393
	 * @exception CoreException if this method fails. Reasons include:
389
	 * <ul>
394
	 * <ul>
390
	 * <li>An exception occurs while initializing the contents of the
395
	 * <li>An exception occurs while initializing the contents of the
Lines 396-402 Link Here
396
	
401
	
397
	/**
402
	/**
398
	 * Returns whether this launch configuration is stored
403
	 * Returns whether this launch configuration is stored
399
	 * locally with the workspace. This is a handle-only method.
404
	 * locally within the workspace. This is a handle-only method.
400
	 * 
405
	 * 
401
	 * @return whether this launch configuration is stored
406
	 * @return whether this launch configuration is stored
402
	 *  locally with the workspace
407
	 *  locally with the workspace
(-)core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java (-27 / +2 lines)
Lines 111-120 Link Here
111
	
111
	
112
	/**
112
	/**
113
	 * Returns the original launch configuration this working copy
113
	 * Returns the original launch configuration this working copy
114
	 * was created from, or <code>null</code> if this is a new
114
	 * was created from or <code>null</code> if this is a new
115
	 * working copy created from a launch configuration type.
115
	 * working copy created from a launch configuration type.
116
	 * 
116
	 * 
117
	 * @return the original launch configuration, or <code>null</code>
117
	 * @return the original launch configuration, working copy, or <code>null</code>
118
	 */
118
	 */
119
	public ILaunchConfiguration getOriginal();
119
	public ILaunchConfiguration getOriginal();
120
	
120
	
Lines 254-284 Link Here
254
	public void removeModes(Set modes);
254
	public void removeModes(Set modes);
255
	
255
	
256
	/**
256
	/**
257
	 * Returns a working copy of this working copy. Changes to the working copy will
258
	 * be applied to this working copy when saved. The working copy will
259
	 * refer to this launch configuration as its parent. Changes are only
260
	 * saved to the underlying original configuration when the root working
261
	 * copy is saved.
262
	 * 
263
	 * @return a working copy of this working copy
264
	 * @exception CoreException if this method fails. Reasons include:
265
	 * <ul>
266
	 * <li>An exception occurs while initializing the contents of the
267
	 * working copy from this configuration's underlying storage.</li>
268
	 * </ul>
269
	 * @see ILaunchConfigurationWorkingCopy#getOriginal()
270
	 * @see ILaunchConfigurationWorkingCopy#getParent()
271
	 * @since 3.3
272
	 * <p>
273
	 * <strong>EXPERIMENTAL</strong>. This method has been added as
274
	 * part of a work in progress. There is no guarantee that this API will
275
	 * remain unchanged during the 3.3 release cycle. Please do not use this API
276
	 * without consulting with the Platform/Debug team.
277
	 * </p>
278
	 */
279
	public ILaunchConfigurationWorkingCopy getNestedWorkingCopy() throws CoreException;	
280
	
281
	/**
282
	 * Returns the parent of this working copy or <code>null</code> if this working
257
	 * Returns the parent of this working copy or <code>null</code> if this working
283
	 * copy is not a nested copy of another working copy.
258
	 * copy is not a nested copy of another working copy.
284
	 * 
259
	 * 
(-)core/org/eclipse/debug/internal/core/LaunchManager.java (-16 / +14 lines)
Lines 2437-2443 Link Here
2437
		}
2437
		}
2438
		return null;
2438
		return null;
2439
	}
2439
	}
2440
2440
	
2441
	/* (non-Javadoc)
2441
	/* (non-Javadoc)
2442
	 * @see org.eclipse.debug.core.ILaunchManager#setDefaultConfiguration(org.eclipse.core.resources.IResource, org.eclipse.debug.core.ILaunchConfiguration)
2442
	 * @see org.eclipse.debug.core.ILaunchManager#setDefaultConfiguration(org.eclipse.core.resources.IResource, org.eclipse.debug.core.ILaunchConfiguration)
2443
	 */
2443
	 */
Lines 2454-2485 Link Here
2454
			}
2454
			}
2455
		}
2455
		}
2456
		
2456
		
2457
		// remove previous settings, if any
2457
		// get preference nodes
2458
		org.osgi.service.prefs.Preferences projectNode = getProjectNode(resource);
2458
		org.osgi.service.prefs.Preferences projectNode = getProjectNode(resource);
2459
		projectNode.remove(DEFAULT_CONFIGURATION);
2460
		flush(projectNode);
2461
		org.osgi.service.prefs.Preferences instanceNode = getInstanceNode(resource);
2459
		org.osgi.service.prefs.Preferences instanceNode = getInstanceNode(resource);
2462
		instanceNode.remove(DEFAULT_CONFIGURATION);
2463
		flush(instanceNode);
2464
		
2465
		if (configuration != null) {
2460
		if (configuration != null) {
2466
			org.osgi.service.prefs.Preferences node = null;
2467
			String configurationValue = null;
2468
			if (configuration.isLocal()) {
2461
			if (configuration.isLocal()) {
2469
				// for local configurations, use workspace (instance) scope preferences
2462
				// for local configurations, use workspace (instance) scope preferences
2470
				node = instanceNode;
2471
				if (!configuration.isWorkingCopy()) {
2463
				if (!configuration.isWorkingCopy()) {
2472
					configurationValue = configuration.getMemento();
2464
					instanceNode.put(DEFAULT_CONFIGURATION, configuration.getMemento());
2465
					projectNode.remove(DEFAULT_CONFIGURATION);
2473
				}
2466
				}
2467
				
2474
			} else {
2468
			} else {
2475
				// for shared configurations, use project scope preferences
2469
				// for shared configurations, use project scope preferences
2476
				node = projectNode;
2470
				projectNode.put(DEFAULT_CONFIGURATION, configuration.getFile().getProjectRelativePath().toPortableString());
2477
				configurationValue = configuration.getFile().getProjectRelativePath().toPortableString();
2471
				instanceNode.remove(DEFAULT_CONFIGURATION);
2478
			}
2472
			}
2479
			node.put(DEFAULT_CONFIGURATION, configurationValue);
2480
			flush(node);
2481
		}
2473
		}
2482
		
2474
		else {
2475
			//remove nodes because the default has been un-set
2476
			projectNode.remove(DEFAULT_CONFIGURATION);
2477
			instanceNode.remove(DEFAULT_CONFIGURATION);
2478
		}
2479
		flush(projectNode);
2480
		flush(instanceNode);
2483
	}	
2481
	}	
2484
	
2482
	
2485
	/**
2483
	/**
(-)core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java (-57 / +49 lines)
Lines 55-60 Link Here
55
	private LaunchConfiguration fOriginal;
55
	private LaunchConfiguration fOriginal;
56
	
56
	
57
	/**
57
	/**
58
	 * Handle to a parent working copy
59
	 * @since 3.3
60
	 */
61
	private LaunchConfigurationWorkingCopy fParent =  null;
62
	
63
	/**
58
	 * Working copy of attributes.
64
	 * Working copy of attributes.
59
	 */
65
	 */
60
	private LaunchConfigurationInfo fInfo;
66
	private LaunchConfigurationInfo fInfo;
Lines 87-98 Link Here
87
	private IContainer fContainer;
93
	private IContainer fContainer;
88
	
94
	
89
	/**
95
	/**
90
	 * Parent working copy.
91
	 * @since 3.3
92
	 */
93
	private LaunchConfigurationWorkingCopy fParent = null;
94
	
95
	/**
96
	 * Constructs a working copy of the specified launch 
96
	 * Constructs a working copy of the specified launch 
97
	 * configuration.
97
	 * configuration.
98
	 * 
98
	 * 
Lines 173-214 Link Here
173
	 * @see ILaunchConfigurationWorkingCopy#doSave()
173
	 * @see ILaunchConfigurationWorkingCopy#doSave()
174
	 */
174
	 */
175
	public synchronized ILaunchConfiguration doSave() throws CoreException {
175
	public synchronized ILaunchConfiguration doSave() throws CoreException {
176
		if (fParent == null) {
176
		if (getParent() != null) {
177
			if (isDirty()) {
177
			// save to parent working copy
178
				boolean useRunnable= true;
178
			LaunchConfigurationWorkingCopy wc = (LaunchConfigurationWorkingCopy) getParent();
179
				if (isLocal()) {
179
			wc.setName(getName());
180
					if (isMoved()) {
180
			wc.copyFrom(this);
181
						// If this config was moved from a shared location, saving
181
			return wc;
182
						// it will delete the original from the workspace. Use runnable.
182
		}
183
						useRunnable= !isNew() && !getOriginal().isLocal();
183
		else {
184
					} else {
184
			boolean useRunnable= true;
185
						useRunnable= false;
185
			if (isLocal()) {
186
					}
186
				if (isMoved()) {
187
				}
187
					// If this config was moved from a shared location, saving
188
	
188
					// it will delete the original from the workspace. Use runnable.
189
				if (useRunnable) {
189
					useRunnable= !isNew() && !getOriginal().isLocal();
190
					IWorkspaceRunnable wr = new IWorkspaceRunnable() {
191
						public void run(IProgressMonitor pm) throws CoreException {
192
							doSave0();
193
						}
194
					};
195
					
196
					ResourcesPlugin.getWorkspace().run(wr, null, 0, null);
197
				} else {
190
				} else {
198
					//file is persisted in the metadata not the workspace
191
					useRunnable= false;
199
					doSave0();
200
				}
192
				}
201
	
202
				getLaunchManager().setMovedFromTo(null, null);
203
			}
193
			}
204
	
194
			if (useRunnable) {
205
			return new LaunchConfiguration(getLocation());
195
				IWorkspaceRunnable wr = new IWorkspaceRunnable() {
206
		} else {
196
					public void run(IProgressMonitor pm) throws CoreException {
207
			// save to parent working copy
197
						doSave0();
208
			fParent.setName(getName());
198
					}
209
			fParent.copyFrom(this);
199
				};
210
			return fParent;
200
				
201
				ResourcesPlugin.getWorkspace().run(wr, null, 0, null);
202
			} else {
203
				//file is persisted in the metadata not the workspace
204
				doSave0();
205
			}
206
			getLaunchManager().setMovedFromTo(null, null);
211
		}
207
		}
208
		return new LaunchConfiguration(getLocation());
212
	}
209
	}
213
210
214
	
211
	
Lines 364-370 Link Here
364
	 * @see ILaunchConfigurationWorkingCopy#getOriginal()
361
	 * @see ILaunchConfigurationWorkingCopy#getOriginal()
365
	 */
362
	 */
366
	public ILaunchConfiguration getOriginal() {
363
	public ILaunchConfiguration getOriginal() {
367
		return fOriginal;
364
		ILaunchConfiguration config = fOriginal;
365
		ILaunchConfigurationWorkingCopy parent = fParent;
366
		while(parent != null) {
367
			config = parent.getOriginal();
368
			parent = parent.getParent();
369
		}
370
		return config;
371
	}
372
	
373
	/**
374
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getParent()
375
	 */
376
	public ILaunchConfigurationWorkingCopy getParent() {
377
		return fParent;
368
	}
378
	}
369
	
379
	
370
	/**
380
	/**
Lines 670-694 Link Here
670
	 * @see org.eclipse.debug.internal.core.LaunchConfiguration#getWorkingCopy()
680
	 * @see org.eclipse.debug.internal.core.LaunchConfiguration#getWorkingCopy()
671
	 */
681
	 */
672
	public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException {
682
	public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException {
673
		if (fParent == null) {
674
			return super.getWorkingCopy();
675
		} else {
676
			return getNestedWorkingCopy();
677
		}
678
	}
679
680
	/* (non-Javadoc)
681
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getNestedWorkingCopy()
682
	 */
683
	public ILaunchConfigurationWorkingCopy getNestedWorkingCopy() throws CoreException {
684
		return new LaunchConfigurationWorkingCopy(this);
683
		return new LaunchConfigurationWorkingCopy(this);
685
	}
684
	}
686
687
	/* (non-Javadoc)
688
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#getParent()
689
	 */
690
	public ILaunchConfigurationWorkingCopy getParent() {
691
		return fParent;
692
	}
693
}
685
}
694
686
(-)tests/org/eclipse/jdt/debug/tests/launching/LaunchConfigurationTests.java (-1 / +1 lines)
Lines 738-744 Link Here
738
		 
738
		 
739
		 // get a working copy
739
		 // get a working copy
740
		 wc = handle.getWorkingCopy();
740
		 wc = handle.getWorkingCopy();
741
		 ILaunchConfigurationWorkingCopy nested = wc.getNestedWorkingCopy();
741
		 ILaunchConfigurationWorkingCopy nested = wc.getWorkingCopy();
742
		 
742
		 
743
		 // verify nested is same as original
743
		 // verify nested is same as original
744
		 assertEquals("String1 should be String1", nested.getAttribute("String1", "Missing"), "String1");
744
		 assertEquals("String1 should be String1", nested.getAttribute("String1", "Missing"), "String1");
(-)ui/org/eclipse/debug/internal/ui/actions/AbstractDebugActionDelegate.java (-5 / +5 lines)
Lines 32-39 Link Here
32
 * This class is an abstract implementation of common features for a debug <code>IViewActionDelegate</code>
32
 * This class is an abstract implementation of common features for a debug <code>IViewActionDelegate</code>
33
 *
33
 *
34
 * This class is intended to be extended by clients
34
 * This class is intended to be extended by clients
35
 * @see {@link IViewActionDelegate}
35
 * @see implemented interface {@link IViewActionDelegate}
36
 * @see {@link IActionDelegate2}
36
 * @see implemented interface {@link IActionDelegate2}
37
 */
37
 */
38
public abstract class AbstractDebugActionDelegate implements IViewActionDelegate, IActionDelegate2 {
38
public abstract class AbstractDebugActionDelegate implements IViewActionDelegate, IActionDelegate2 {
39
	
39
	
Lines 48-54 Link Here
48
	private IViewPart fViewPart;
48
	private IViewPart fViewPart;
49
	
49
	
50
	/**
50
	/**
51
	 * Cache of the most recent seletion
51
	 * Cache of the most recent selection
52
	 */
52
	 */
53
	private IStructuredSelection fSelection = StructuredSelection.EMPTY;
53
	private IStructuredSelection fSelection = StructuredSelection.EMPTY;
54
	
54
	
Lines 58-64 Link Here
58
	private boolean fInitialized = false;
58
	private boolean fInitialized = false;
59
	
59
	
60
	/**
60
	/**
61
	 * It's crucial that delegate actions have a zero-arg constructor so that
61
	 * It's crucial that delegate actions have a zero-argument constructor so that
62
	 * they can be reflected into existence when referenced in an action set
62
	 * they can be reflected into existence when referenced in an action set
63
	 * in the plugin's plugin.xml file.
63
	 * in the plugin's plugin.xml file.
64
	 */
64
	 */
Lines 257-263 Link Here
257
	}
257
	}
258
258
259
	/**
259
	/**
260
	 * Sets the initialized state of this aciton to the specified boolean value
260
	 * Sets the initialized state of this action to the specified boolean value
261
	 * @param initialized the value to set the initialized state to
261
	 * @param initialized the value to set the initialized state to
262
	 */
262
	 */
263
	protected void setInitialized(boolean initialized) {
263
	protected void setInitialized(boolean initialized) {
(-)ui/org/eclipse/debug/internal/ui/actions/LaunchablePropertyTester.java (-6 / +25 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 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 11-16 Link Here
11
package org.eclipse.debug.internal.ui.actions;
11
package org.eclipse.debug.internal.ui.actions;
12
12
13
import org.eclipse.core.expressions.PropertyTester;
13
import org.eclipse.core.expressions.PropertyTester;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
import org.eclipse.debug.ui.actions.ILaunchable;
18
import org.eclipse.debug.ui.actions.ILaunchable;
Lines 20-35 Link Here
20
 */
22
 */
21
public class LaunchablePropertyTester extends PropertyTester {
23
public class LaunchablePropertyTester extends PropertyTester {
22
24
23
	/* (non-Javadoc)
25
	/**
24
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
26
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
25
	 */
27
	 */
26
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
28
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
27
		if (property.equals("launchable")) { //$NON-NLS-1$
29
		if ("launchable".equals(property)) { //$NON-NLS-1$
28
			if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
30
				if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
29
				return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
31
					return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
30
			}
32
				}
33
		}
34
		else if("resource".equals(property)) { //$NON-NLS-1$
35
			return getResource(receiver) != null;
31
		}
36
		}
32
		return false;
37
		return false;
33
	}
38
	}
34
39
40
	/**
41
	 * Returns the resource this property page is open on.
42
	 * 
43
	 * @return resource
44
	 */
45
	protected IResource getResource(Object element) {
46
		IResource resource = null;
47
		if (element instanceof IResource) {
48
			resource = (IResource) element;
49
		} else if (element instanceof IAdaptable) {
50
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
51
		}
52
		return resource;
53
	}
35
}
54
}
(-)ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java (-5 / +8 lines)
Lines 26-34 Link Here
26
		super();
26
		super();
27
	}
27
	}
28
28
29
	/*
29
	/**
30
	 * (non-Javadoc)
31
	 * 
32
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
30
	 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
33
	 */
31
	 */
34
	public void initializeDefaultPreferences() {
32
	public void initializeDefaultPreferences() {
Lines 51-56 Link Here
51
		prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_BREAKPOINTS, true);
49
		prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_ALL_BREAKPOINTS, true);
52
		prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER, true);
50
		prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER, true);
53
		
51
		
52
	//contextual launching preference page
53
		prefs.setDefault(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, false);
54
		
54
		//View Management preference page
55
		//View Management preference page
55
		prefs.setDefault(IDebugUIConstants.PREF_MANAGE_VIEW_PERSPECTIVES, IDebugUIConstants.ID_DEBUG_PERSPECTIVE);
56
		prefs.setDefault(IDebugUIConstants.PREF_MANAGE_VIEW_PERSPECTIVES, IDebugUIConstants.ID_DEBUG_PERSPECTIVE);
56
		prefs.setDefault(IInternalDebugUIConstants.PREF_TRACK_VIEWS, true);
57
		prefs.setDefault(IInternalDebugUIConstants.PREF_TRACK_VIEWS, true);
Lines 111-120 Link Here
111
		prefs.setDefault(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE, 
112
		prefs.setDefault(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE, 
112
				IDebugPreferenceConstants.DEFAULT_EBCDIC_CP);
113
				IDebugPreferenceConstants.DEFAULT_EBCDIC_CP);
113
		
114
		
114
		if (MemoryViewUtil.isLinuxGTK())
115
		if (MemoryViewUtil.isLinuxGTK()) {
115
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, false);
116
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, false);
116
		else
117
		}
118
		else {
117
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, true);
119
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, true);
120
		}
118
		
121
		
119
		prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
122
		prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
120
		prefs.setDefault(IDebugPreferenceConstants.PREF_RESET_MEMORY_BLOCK, IDebugPreferenceConstants.RESET_VISIBLE);
123
		prefs.setDefault(IDebugPreferenceConstants.PREF_RESET_MEMORY_BLOCK, IDebugPreferenceConstants.RESET_VISIBLE);
(-)ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java (-4 / +3 lines)
Lines 86-91 Link Here
86
	public static final String LAUNCH_CONFIGURATION_PREFERENCE_PAGE = PREFIX + "launch_configuration_preference_page_context"; //$NON-NLS-1$
86
	public static final String LAUNCH_CONFIGURATION_PREFERENCE_PAGE = PREFIX + "launch_configuration_preference_page_context"; //$NON-NLS-1$
87
	public static final String VIEW_MANAGEMENT_PREFERENCE_PAGE = PREFIX + "view_management_preference_page_context"; //$NON-NLS-1$
87
	public static final String VIEW_MANAGEMENT_PREFERENCE_PAGE = PREFIX + "view_management_preference_page_context"; //$NON-NLS-1$
88
	public static final String LAUNCH_DELEGATES_PREFERENCE_PAGE = PREFIX + "launch_delegate_preference_page_context"; //$NON-NLS-1$
88
	public static final String LAUNCH_DELEGATES_PREFERENCE_PAGE = PREFIX + "launch_delegate_preference_page_context"; //$NON-NLS-1$
89
	public static final String CONTEXTUAL_LAUNCHING_PREFERENCE_PAGE = PREFIX + "contextual_launch_preference_page"; //$NON-NLS-1$
89
	
90
	
90
	// Dialogs
91
	// Dialogs
91
	public static final String LAUNCH_CONFIGURATION_DIALOG = PREFIX + "launch_configuration_dialog"; //$NON-NLS-1$
92
	public static final String LAUNCH_CONFIGURATION_DIALOG = PREFIX + "launch_configuration_dialog"; //$NON-NLS-1$
Lines 111-120 Link Here
111
	public static final String DELETE_ASSOCIATED_LAUNCH_CONFIGS_DIALOG = PREFIX + "delete_associated_launch_configs_dialog"; //$NON-NLS-1$
112
	public static final String DELETE_ASSOCIATED_LAUNCH_CONFIGS_DIALOG = PREFIX + "delete_associated_launch_configs_dialog"; //$NON-NLS-1$
112
	public static final String SELECT_LAUNCH_MODES_DIALOG = PREFIX + "select_launch_modes_dialog"; //$NON-NLS-1$
113
	public static final String SELECT_LAUNCH_MODES_DIALOG = PREFIX + "select_launch_modes_dialog"; //$NON-NLS-1$
113
	public static final String SELECT_LAUNCHERS_DIALOG = PREFIX + "select_launchers_dialog"; //$NON-NLS-1$
114
	public static final String SELECT_LAUNCHERS_DIALOG = PREFIX + "select_launchers_dialog"; //$NON-NLS-1$
115
	public static final String SELECT_LAUNCH_METHOD_DIALOG = PREFIX + "select_launch_method_dialog"; //$NON-NLS-1$
114
	
116
	
115
	// Property pages
117
	// Property pages
116
	public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
118
	public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
117
	public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
119
	public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
120
	public static final String DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE = PREFIX + "default_launchconfiguration_property_page"; //$NON-NLS-1$
118
	
121
	
119
	// Launch configuration dialog pages
122
	// Launch configuration dialog pages
120
	public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$
123
	public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$
Lines 131-139 Link Here
131
	
134
	
132
	//Editor	
135
	//Editor	
133
	public static final String NO_SOURCE_EDITOR = PREFIX + "debugger_editor_no_source_common";//$NON-NLS-1$
136
	public static final String NO_SOURCE_EDITOR = PREFIX + "debugger_editor_no_source_common";//$NON-NLS-1$
134
135
136
    
137
	
138
}
137
}
139
138
(-)ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java (-4 / +12 lines)
Lines 131-137 Link Here
131
    public static final String IMG_ADD_SRC_DIR_WIZ = "IMG_ADD_SRC_DIRECTORY"; //$NON-NLS-1$
131
    public static final String IMG_ADD_SRC_DIR_WIZ = "IMG_ADD_SRC_DIRECTORY"; //$NON-NLS-1$
132
    public static final String IMG_EDIT_SRC_DIR_WIZ = "IMG_EDIT_SRC_DIRECTORY"; //$NON-NLS-1$
132
    public static final String IMG_EDIT_SRC_DIR_WIZ = "IMG_EDIT_SRC_DIRECTORY"; //$NON-NLS-1$
133
    
133
    
134
    // internal preferenes
134
    // internal preferences
135
    /**
135
    /**
136
     * XML for perspective settings - see PerspectiveManager.
136
     * XML for perspective settings - see PerspectiveManager.
137
     * @since 3.0
137
     * @since 3.0
Lines 145-158 Link Here
145
    public static final String EMPTY_STRING = ""; //$NON-NLS-1$
145
    public static final String EMPTY_STRING = ""; //$NON-NLS-1$
146
    
146
    
147
    /**
147
    /**
148
     * Preference for enabling/disabling launch configuration filtering based on project accessibilty status
148
     * Preference for enabling/disabling launch configuration filtering based on project accessibility status
149
     * 
149
     * 
150
     * @since 3.2
150
     * @since 3.2
151
     */
151
     */
152
    public static final String PREF_FILTER_LAUNCH_CLOSED = IDebugUIConstants.PLUGIN_ID + ".PREF_FILTER_LAUNCH_CLOSED"; //$NON-NLS-1$
152
    public static final String PREF_FILTER_LAUNCH_CLOSED = IDebugUIConstants.PLUGIN_ID + ".PREF_FILTER_LAUNCH_CLOSED"; //$NON-NLS-1$
153
    
153
    
154
    /**
154
    /**
155
     * Preference for enabling/disabling launch configuraiton filtering based on project context
155
     * Preference for enabling/disabling launch configuration filtering based on project context
156
     * 
156
     * 
157
     * @since 3.2
157
     * @since 3.2
158
     */
158
     */
Lines 202-207 Link Here
202
    public static final String DETAIL_PANE_FONT= "org.eclipse.debug.ui.DetailPaneFont"; //$NON-NLS-1$   
202
    public static final String DETAIL_PANE_FONT= "org.eclipse.debug.ui.DetailPaneFont"; //$NON-NLS-1$   
203
203
204
    /**
204
    /**
205
     * Boolean preference indicating if contextual launch options should be visible
206
     * to the user rather than the "run as" menu.
207
     * 
208
     * @since 3.3
209
     */ 
210
    public static final String PREF_USE_CONTEXTUAL_LAUNCH= IDebugUIConstants.PLUGIN_ID + ".UseContextualLaunch"; //$NON-NLS-1$
211
    
212
    /**
205
     * String preference controlling whether editors are saved before launching.
213
     * String preference controlling whether editors are saved before launching.
206
     * Valid values are either "always", "never", or "prompt".
214
     * Valid values are either "always", "never", or "prompt".
207
     * If "always" or "never", launching will save editors (or not) automatically.
215
     * If "always" or "never", launching will save editors (or not) automatically.
Lines 212-218 Link Here
212
    public static final String PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH = IDebugUIConstants.PLUGIN_ID + ".save_dirty_editors_before_launch"; //$NON-NLS-1$
220
    public static final String PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH = IDebugUIConstants.PLUGIN_ID + ".save_dirty_editors_before_launch"; //$NON-NLS-1$
213
    
221
    
214
    /**
222
    /**
215
     * Preference specifiying that all launches should be DEBUG_MODE if breakpoints exist in the workspace
223
     * Preference specifying that all launches should be DEBUG_MODE if breakpoints exist in the workspace
216
     * @since 3.0
224
     * @since 3.0
217
     */
225
     */
218
    public static final String PREF_RELAUNCH_IN_DEBUG_MODE = IDebugUIConstants.PLUGIN_ID + ".relaunch_in_debug_mode"; //$NON-NLS-1$
226
    public static final String PREF_RELAUNCH_IN_DEBUG_MODE = IDebugUIConstants.PLUGIN_ID + ".relaunch_in_debug_mode"; //$NON-NLS-1$
(-)ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java (-1 / +7 lines)
Lines 39-44 Link Here
39
import org.eclipse.debug.core.model.IVariable;
39
import org.eclipse.debug.core.model.IVariable;
40
import org.eclipse.debug.core.model.IWatchExpression;
40
import org.eclipse.debug.core.model.IWatchExpression;
41
import org.eclipse.debug.core.model.IWatchpoint;
41
import org.eclipse.debug.core.model.IWatchpoint;
42
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
42
import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
43
import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
43
import org.eclipse.debug.ui.IDebugUIConstants;
44
import org.eclipse.debug.ui.IDebugUIConstants;
44
import org.eclipse.jface.resource.ImageDescriptor;
45
import org.eclipse.jface.resource.ImageDescriptor;
Lines 69-74 Link Here
69
			}
70
			}
70
			return null;
71
			return null;
71
		}
72
		}
73
		if(element instanceof LaunchShortcutExtension) {
74
			return ((LaunchShortcutExtension)element).getImageDescriptor().createImage();
75
		}
72
		return DebugPluginImages.getImage(key);
76
		return DebugPluginImages.getImage(key);
73
	}
77
	}
74
	
78
	
Lines 155-161 Link Here
155
					DebugUIPlugin.log(e);
159
					DebugUIPlugin.log(e);
156
					return null;
160
					return null;
157
				}
161
				}
158
			} 
162
			}
159
		}
163
		}
160
		return null;		
164
		return null;		
161
	}
165
	}
Lines 206-211 Link Here
206
						name = delegate.getContributorName();
210
						name = delegate.getContributorName();
207
					}
211
					}
208
					label.append(name);
212
					label.append(name);
213
				} else if(element instanceof LaunchShortcutExtension) {
214
					label.append(((LaunchShortcutExtension)element).getLabel());
209
				} else if (element instanceof String) {
215
				} else if (element instanceof String) {
210
					label.append(element);
216
					label.append(element);
211
				} else {
217
				} else {
(-)plugin.xml (-4 / +116 lines)
Lines 155-160 Link Here
155
               id="org.eclipse.debug.ui.launchDelegatesKeywords">
155
               id="org.eclipse.debug.ui.launchDelegatesKeywords">
156
         </keywordReference>
156
         </keywordReference>
157
      </page>
157
      </page>
158
      <page
159
            category="org.eclipse.debug.ui.DebugPreferencePage"
160
            class="org.eclipse.debug.internal.ui.preferences.ContextLaunchingPreferencePage"
161
            id="org.eclipse.debug.ui.contextualLaunchingPage"
162
            name="%ContextualLaunchingPrefPage.name">
163
         <keywordReference
164
               id="org.eclipse.debug.ui.contextLaunching">
165
         </keywordReference>
166
      </page>
158
   </extension>
167
   </extension>
159
   <extension point="org.eclipse.ui.actionSets">
168
   <extension point="org.eclipse.ui.actionSets">
160
   		<actionSet
169
   		<actionSet
Lines 874-880 Link Here
874
               id="org.eclipse.debug.ui.contextualLaunch.profile.submenu">
883
               id="org.eclipse.debug.ui.contextualLaunch.profile.submenu">
875
        </action>    
884
        </action>    
876
        <enablement>
885
        <enablement>
877
         	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
886
          <and>
887
          	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
888
          	<not>
889
          		<test property="org.eclipse.debug.ui.contextlaunch" />
890
          	</not>
891
          </and>
878
        </enablement>        
892
        </enablement>        
879
      </objectContribution>
893
      </objectContribution>
880
      <objectContribution
894
      <objectContribution
Lines 889-895 Link Here
889
               id="org.eclipse.debug.ui.contextualLaunch.debug.submenu">
903
               id="org.eclipse.debug.ui.contextualLaunch.debug.submenu">
890
         </action>
904
         </action>
891
         <enablement>
905
         <enablement>
892
         	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
906
          <and>
907
          	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
908
          	<not>
909
          		<test property="org.eclipse.debug.ui.contextlaunch" />
910
          	</not>
911
          </and>
893
         </enablement>     
912
         </enablement>     
894
       </objectContribution>    
913
       </objectContribution>    
895
       <objectContribution
914
       <objectContribution
Lines 904-913 Link Here
904
               id="org.eclipse.debug.ui.contextualLaunch.run.submenu">
923
               id="org.eclipse.debug.ui.contextualLaunch.run.submenu">
905
         </action>                  
924
         </action>                  
906
         <enablement>
925
         <enablement>
907
         	<test property="org.eclipse.debug.ui.launchable" value="run"/>
926
          <and>
927
          	<test property="org.eclipse.debug.ui.launchable" value="run"/>
928
          	<not>
929
          		<test property="org.eclipse.debug.ui.contextlaunch" />
930
          	</not>
931
          </and>
908
         </enablement>
932
         </enablement>
909
      </objectContribution>
933
      </objectContribution>
934
       <objectContribution
935
             id="org.eclipse.debug.ui.contextlaunch.debugas"
936
             objectClass="org.eclipse.core.runtime.IAdaptable">
937
          <action
938
                class="org.eclipse.debug.internal.ui.contextlaunching.DebugContextLaunchingAction"
939
                enablesFor="1"
940
                icon="icons/full/etool16/debug_exc.gif"
941
                id="org.eclipse.debug.ui.contextlaunch.debugas"
942
                label="%ContextLaunchingDebugMenu.name"
943
                menubarPath="additions"
944
                tooltip="%ContextLaunchingDebugMenu.tooltip">
945
          </action>
946
          <enablement>
947
          <and>
948
            <test property="org.eclipse.debug.ui.resource" />
949
          	<test property="org.eclipse.debug.ui.contextlaunch" />
950
          	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
951
          </and>
952
         </enablement>
953
       </objectContribution>
954
       <objectContribution
955
             id="org.eclipse.debug.ui.contextlaunch.profileas"
956
             objectClass="org.eclipse.core.runtime.IAdaptable">
957
          <action
958
                class="org.eclipse.debug.internal.ui.contextlaunching.ProfileContextLaunchingAction"
959
                enablesFor="1"
960
                icon="icons/full/etool16/profile_exc.gif"
961
                id="org.eclipse.debug.ui.contextlaunch.profileas"
962
                label="%ContextLaunchingProfileMenu.name"
963
                menubarPath="additions"
964
                tooltip="%ContextLaunchingProfileMenu.tooltip">
965
          </action>
966
          <enablement>
967
          <and>
968
            <test property="org.eclipse.debug.ui.resource" />
969
          	<test property="org.eclipse.debug.ui.contextlaunch" />
970
          	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
971
          </and>
972
         </enablement> 
973
       </objectContribution>
910
   <!-- console additions -->
974
   <!-- console additions -->
975
      <objectContribution
976
            id="org.eclipse.debug.ui.contextlaunch.runas"
977
            objectClass="org.eclipse.core.runtime.IAdaptable">
978
         <action
979
               class="org.eclipse.debug.internal.ui.contextlaunching.RunContextLaunchingAction"
980
               enablesFor="1"
981
               icon="icons/full/etool16/run_exc.gif"
982
               id="org.eclipse.debug.ui.contextlaunch.runas"
983
               label="%ContextLaunchingRunMenu.name"
984
               menubarPath="additions"
985
               tooltip="%ContextLaunchingRunMenu.tooltip">
986
         </action>
987
         <enablement>
988
          <and>
989
          	<test property="org.eclipse.debug.ui.contextlaunch" />
990
          	<test property="org.eclipse.debug.ui.resource" />
991
          	<test property="org.eclipse.debug.ui.launchable" value="run"/>
992
          </and>
993
         </enablement> 
994
      </objectContribution>
911
      <viewerContribution
995
      <viewerContribution
912
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
996
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
913
             id="org.eclipse.debug.ui.processConsoleContextMenu">
997
             id="org.eclipse.debug.ui.processConsoleContextMenu">
Lines 1394-1399 Link Here
1394
            </or>
1478
            </or>
1395
         </enabledWhen>
1479
         </enabledWhen>
1396
      </page>
1480
      </page>
1481
      <page
1482
            class="org.eclipse.debug.internal.ui.preferences.DefaultLaunchConfigurationsPropertiesPage"
1483
            id="org.eclipse.debug.ui.properties.defaultLaunchConfigurations"
1484
            name="%DefaultLaunchConfigurationsPropPage.name"
1485
            >
1486
         <enabledWhen>
1487
            <and>
1488
               <adapt
1489
                     type="org.eclipse.core.resources.IResource">
1490
               </adapt>
1491
               <test property="org.eclipse.debug.ui.contextlaunch" />
1492
               <test
1493
                     property="org.eclipse.debug.ui.resource">
1494
               </test>
1495
            </and>
1496
         </enabledWhen>
1497
      </page>
1397
   </extension>
1498
   </extension>
1398
<!-- commands and their bindings
1499
<!-- commands and their bindings
1399
NOTE: 
1500
NOTE: 
Lines 2032-2038 Link Here
2032
      </propertyTester>
2133
      </propertyTester>
2033
	  <propertyTester
2134
	  <propertyTester
2034
			namespace="org.eclipse.debug.ui"
2135
			namespace="org.eclipse.debug.ui"
2035
			properties="launchable"
2136
			properties="launchable, resource"
2036
			type="java.lang.Object"
2137
			type="java.lang.Object"
2037
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2138
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2038
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
2139
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
Lines 2050-2055 Link Here
2050
            properties="getModelIdentifier,isTerminatedOrDisconnected"
2151
            properties="getModelIdentifier,isTerminatedOrDisconnected"
2051
            type="org.eclipse.core.runtime.IAdaptable">
2152
            type="org.eclipse.core.runtime.IAdaptable">
2052
      </propertyTester>
2153
      </propertyTester>
2154
      <propertyTester
2155
            class="org.eclipse.debug.internal.ui.preferences.ContextLaunchingPropertyTester"
2156
            id="org.eclipse.debug.ui.contextlaunching.IAdaptableTester"
2157
            namespace="org.eclipse.debug.ui"
2158
            properties="contextlaunch"
2159
            type="org.eclipse.core.runtime.IAdaptable">
2160
      </propertyTester>
2053
   </extension>
2161
   </extension>
2054
<!-- Context extensions -->
2162
<!-- Context extensions -->
2055
  <extension
2163
  <extension
Lines 2235-2240 Link Here
2235
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2343
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2236
             label="%preferenceKeywords.launchDelegates">
2344
             label="%preferenceKeywords.launchDelegates">
2237
       </keyword>
2345
       </keyword>
2346
       <keyword
2347
             id="org.eclipse.debug.ui.contextLaunching"
2348
             label="%preferenceKeywords.contextLaunching">
2349
       </keyword>
2238
    </extension>
2350
    </extension>
2239
    <extension
2351
    <extension
2240
          point="org.eclipse.ui.importWizards">
2352
          point="org.eclipse.ui.importWizards">
(-)plugin.properties (+14 lines)
Lines 27-32 Link Here
27
BreakpointOrganizersName=Breakpoint Organizers
27
BreakpointOrganizersName=Breakpoint Organizers
28
VariableValueEditorsName=Variable Value Editors
28
VariableValueEditorsName=Variable Value Editors
29
29
30
ContextLaunchingRunMenu.name=&Run
31
ContextLaunchingRunMenu.tooltip=Run the selected item
32
33
ContextLaunchingDebugMenu.name=&Debug
34
ContextLaunchingDebugMenu.tooltip=Debug the selected item
35
36
ContextLaunchingProfileMenu.name=&Profile
37
ContextLaunchingProfileMenu.tooltip=Profile the selected item
38
39
ContextualLaunchingPrefPage.name=Contextual Launching
40
41
DefaultLaunchConfigurationsPropPage.name=Default Launch Configurations
42
30
BreakpointActionSet.label=Breakpoints
43
BreakpointActionSet.label=Breakpoints
31
CollapseAll.label=Collapse All
44
CollapseAll.label=Collapse All
32
CollapseAll.tooltip= Collapse All
45
CollapseAll.tooltip= Collapse All
Lines 328-333 Link Here
328
preferenceKeywords.viewManagement=views
341
preferenceKeywords.viewManagement=views
329
preferenceKeywords.perspective=perspectives switching assign automatic run debug
342
preferenceKeywords.perspective=perspectives switching assign automatic run debug
330
preferenceKeywords.launchConfigurations=filters launch migration configurations run debug
343
preferenceKeywords.launchConfigurations=filters launch migration configurations run debug
344
preferenceKeywords.contextLaunching=run debug profile launch contextual delegate configuration execute
331
preferenceKeywords.launchDelegates=launch delegate duplicate run debug profile mode configuration launchers launcher modes
345
preferenceKeywords.launchDelegates=launch delegate duplicate run debug profile mode configuration launchers launcher modes
332
346
333
exportBreakpoints.label=E&xport Breakpoints...
347
exportBreakpoints.label=E&xport Breakpoints...
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties (+3 lines)
Lines 102-107 Link Here
102
PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4=Unable to open perspectives as specified by launch: {0}
102
PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4=Unable to open perspectives as specified by launch: {0}
103
PerspectiveManager_Unable_to_switch_to_perspective___0__2=Unable to open perspective: {0}
103
PerspectiveManager_Unable_to_switch_to_perspective___0__2=Unable to open perspective: {0}
104
LaunchShortcutExtension_Error_4=Error
104
LaunchShortcutExtension_Error_4=Error
105
LaunchShortcutSelectionDialog_0={0} As...
106
LaunchShortcutSelectionDialog_1=&Select how to {0} {1}: 
107
LaunchShortcutSelectionDialog_2=&Make generated launch configuration the default for [{0}]
105
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
108
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
106
109
107
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
110
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-2 / +12 lines)
Lines 360-366 Link Here
360
	
360
	
361
	/**
361
	/**
362
	 * Creates some help text for the tab group launch types
362
	 * Creates some help text for the tab group launch types
363
	 * @param parent thep arent composite
363
	 * @param parent the parent composite
364
	 * @since 3.2
364
	 * @since 3.2
365
	 */
365
	 */
366
	private void createGettingStarted(Composite parent) {
366
	private void createGettingStarted(Composite parent) {
Lines 492-498 Link Here
492
		ILaunchConfigurationTab[] tabs = getTabs();
492
		ILaunchConfigurationTab[] tabs = getTabs();
493
		if (tabs != null) {
493
		if (tabs != null) {
494
			// update the working copy from the active tab
494
			// update the working copy from the active tab
495
			boolean newwc = !getWorkingCopy().isDirty();
495
			getActiveTab().performApply(getWorkingCopy());
496
			getActiveTab().performApply(getWorkingCopy());
497
			if(getOriginal() instanceof ILaunchConfigurationWorkingCopy && newwc) {
498
				try {
499
					getWorkingCopy().doSave();
500
				} 
501
				catch (CoreException e) {DebugUIPlugin.log(e);}
502
			}
496
			updateButtons();
503
			updateButtons();
497
			// update error ticks
504
			// update error ticks
498
			CTabItem item = null;
505
			CTabItem item = null;
Lines 948-953 Link Here
948
		if (workingCopy == null) {
955
		if (workingCopy == null) {
949
			return false;
956
			return false;
950
		}
957
		}
958
		if(workingCopy.getParent() != null) {
959
			return !workingCopy.getParent().contentsEqual(workingCopy);
960
		}
951
		// Working copy hasn't been saved
961
		// Working copy hasn't been saved
952
		if (workingCopy.getOriginal() == null) {
962
		if (workingCopy.getOriginal() == null) {
953
			return true;
963
			return true;
Lines 1354-1361 Link Here
1354
		try {
1364
		try {
1355
			if(fTabGroup != null) {
1365
			if(fTabGroup != null) {
1356
				fTabGroup.initializeFrom(fOriginal);
1366
				fTabGroup.initializeFrom(fOriginal);
1357
				fWorkingCopy = fOriginal.getWorkingCopy();
1358
				fNameWidget.setText(fOriginal.getName());
1367
				fNameWidget.setText(fOriginal.getName());
1368
				fWorkingCopy = fOriginal.getWorkingCopy();
1359
				refreshStatus();
1369
				refreshStatus();
1360
			}
1370
			}
1361
		} 
1371
		} 
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java (+6 lines)
Lines 106-111 Link Here
106
	public static String LaunchConfigurationTabGroupViewer_13;
106
	public static String LaunchConfigurationTabGroupViewer_13;
107
107
108
	public static String LaunchConfigurationView_0;
108
	public static String LaunchConfigurationView_0;
109
110
	public static String LaunchShortcutSelectionDialog_0;
111
112
	public static String LaunchShortcutSelectionDialog_1;
113
114
	public static String LaunchShortcutSelectionDialog_2;
109
	public static String PerspectiveManager_Error_1;
115
	public static String PerspectiveManager_Error_1;
110
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
116
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
111
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
117
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java (-1 / +4 lines)
Lines 851-857 Link Here
851
	 * @return the shell title
851
	 * @return the shell title
852
	 */
852
	 */
853
	protected String getShellTitle() {
853
	protected String getShellTitle() {
854
		String title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel());
854
		String title = null;
855
		if(getLaunchGroup() != null) {
856
			 title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel());
857
		}
855
		if (title == null) {
858
		if (title == null) {
856
			title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; 
859
			title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; 
857
		}
860
		}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java (-1 / +41 lines)
Lines 32-37 Link Here
32
import javax.xml.parsers.ParserConfigurationException;
32
import javax.xml.parsers.ParserConfigurationException;
33
import javax.xml.transform.TransformerException;
33
import javax.xml.transform.TransformerException;
34
34
35
import org.eclipse.core.expressions.EvaluationContext;
36
import org.eclipse.core.expressions.IEvaluationContext;
35
import org.eclipse.core.resources.IProject;
37
import org.eclipse.core.resources.IProject;
36
import org.eclipse.core.resources.IResource;
38
import org.eclipse.core.resources.IResource;
37
import org.eclipse.core.resources.ISaveContext;
39
import org.eclipse.core.resources.ISaveContext;
Lines 56-61 Link Here
56
import org.eclipse.debug.core.ILaunchManager;
58
import org.eclipse.debug.core.ILaunchManager;
57
import org.eclipse.debug.core.ILaunchMode;
59
import org.eclipse.debug.core.ILaunchMode;
58
import org.eclipse.debug.internal.core.IConfigurationElementConstants;
60
import org.eclipse.debug.internal.core.IConfigurationElementConstants;
61
import org.eclipse.debug.internal.core.LaunchManager;
59
import org.eclipse.debug.internal.ui.DebugPluginImages;
62
import org.eclipse.debug.internal.ui.DebugPluginImages;
60
import org.eclipse.debug.internal.ui.DebugUIPlugin;
63
import org.eclipse.debug.internal.ui.DebugUIPlugin;
61
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
64
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
Lines 594-604 Link Here
594
		}
597
		}
595
		return fLaunchShortcuts;
598
		return fLaunchShortcuts;
596
	}
599
	}
600
601
	/**
602
	 * Returns a listing of all of the <code>ILaunchConfigurationType</code>s that apply to the currently
603
	 * specified <code>IResource</code>.
604
	 * 
605
	 * @param resource the resource context
606
	 * @return a listing of applicable <code>ILaunchConfigurationType</code>s, or an empty list, never <code>null</code>
607
	 * @since 3.3
608
	 */
609
	public List getApplicableConfigurationTypes(IResource resource) {
610
		List types = new ArrayList();
611
		try {
612
			List exts = getLaunchShortcuts();
613
			LaunchShortcutExtension ext = null;
614
			List list = new ArrayList();
615
			list.add(resource);
616
			IEvaluationContext context = new EvaluationContext(null, list);
617
			context.addVariable("selection", list); //$NON-NLS-1$
618
			HashSet set = new HashSet();
619
			for(Iterator iter = exts.iterator(); iter.hasNext();) {
620
				ext = (LaunchShortcutExtension) iter.next();
621
				if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
622
					set.addAll(ext.getAssociatedConfigurationTypes());
623
				}
624
			}
625
			LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
626
			ILaunchConfigurationType type = null;
627
			for(Iterator iter = set.iterator(); iter.hasNext();) {
628
				type = lm.getLaunchConfigurationType((String)iter.next());
629
				if(type != null && !"org.eclipse.ui.externaltools".equals(type.getCategory()) && !types.contains(type)) { //$NON-NLS-1$
630
					types.add(type);
631
				}
632
			}
633
		}
634
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
635
		return types;
636
	}
597
	
637
	
598
	/**
638
	/**
599
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
639
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
600
	 * launch configuration type id.
640
	 * launch configuration type id.
601
	 * @param typeid the id of the launch configuraiton
641
	 * @param typeid the id of the launch configuration
602
	 * @return a listing of <code>LaunchShortcutExtension</code>s that are associated with the specified launch configuration
642
	 * @return a listing of <code>LaunchShortcutExtension</code>s that are associated with the specified launch configuration
603
	 * type id or an empty list, never <code>null</code>
643
	 * type id or an empty list, never <code>null</code>
604
	 * 
644
	 * 
(-)ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties (+15 lines)
Lines 16-21 Link Here
16
ConsolePreferencePage_Standard_In__4=Standard &In text color:
16
ConsolePreferencePage_Standard_In__4=Standard &In text color:
17
ConsolePreferencePage_Standard_Out__2=Standard &Out text color:
17
ConsolePreferencePage_Standard_Out__2=Standard &Out text color:
18
ConsolePreferencePage_Wrap_text_1=Fixed &width console
18
ConsolePreferencePage_Wrap_text_1=Fixed &width console
19
ContextualLaunchPreferencePage_0=This page is used to edit contextual launching options (EXPERIMENTAL).
20
ContextualLaunchPreferencePage_1=&Enable contextual launching.
19
ConsolePreferencePage_Console_width=&Maximum character width:
21
ConsolePreferencePage_Console_width=&Maximum character width:
20
ConsolePreferencePage_Limit_console_output_1=&Limit console output
22
ConsolePreferencePage_Limit_console_output_1=&Limit console output
21
ConsolePreferencePage_Console_buffer_size__characters___2=Console &buffer size (characters):
23
ConsolePreferencePage_Console_buffer_size__characters___2=Console &buffer size (characters):
Lines 127-129 Link Here
127
LaunchDelegatesPreferencePage_4=Launcher Description
129
LaunchDelegatesPreferencePage_4=Launcher Description
128
LaunchPerspectivePreferencePage_0=There is no perspective information available to change.
130
LaunchPerspectivePreferencePage_0=There is no perspective information available to change.
129
LaunchPerspectivePreferencePage_1=The selected types/launchers do not have any common mode sets.
131
LaunchPerspectivePreferencePage_1=The selected types/launchers do not have any common mode sets.
132
DefaultLaunchConfigurationsPropertiesPage_0=This page allows you to select a default way to launch the currently selected resource.
133
DefaultLaunchConfigurationsPropertiesPage_1=&Select default configuration for {0}:
134
DefaultLaunchConfigurationsPropertiesPage_2=&New...
135
DefaultLaunchConfigurationsPropertiesPage_3=Create new launch configuration
136
DefaultLaunchConfigurationsPropertiesPage_4=Du&plicate
137
DefaultLaunchConfigurationsPropertiesPage_5=Duplicate selected launch configuration
138
DefaultLaunchConfigurationsPropertiesPage_6=&Edit...
139
DefaultLaunchConfigurationsPropertiesPage_7=Edit selected launch configuration
140
DefaultLaunchConfigurationsPropertiesPage_8=De&lete
141
DefaultLaunchConfigurationsPropertiesPage_9=Delete selected launch configuration
142
DefaultLaunchConfigurationsPropertiesPage_10=Configuration must be located in project {0}
143
DefaultLaunchConfigurationsPropertiesPage_11=Select Configuration Type
144
DefaultLaunchConfigurationsPropertiesPage_12=&Select the configuration type to create:
(-)ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java (+30 lines)
Lines 32-37 Link Here
32
	public static String ConsolePreferencePage_12;
32
	public static String ConsolePreferencePage_12;
33
	public static String ConsolePreferencePage_13;
33
	public static String ConsolePreferencePage_13;
34
34
35
	public static String ContextualLaunchPreferencePage_0;
36
37
	public static String ContextualLaunchPreferencePage_1;
38
35
	public static String DebugPreferencePage_1;
39
	public static String DebugPreferencePage_1;
36
	public static String DebugPreferencePage_2;
40
	public static String DebugPreferencePage_2;
37
41
Lines 51-56 Link Here
51
	public static String DebugPreferencePage_26;
55
	public static String DebugPreferencePage_26;
52
	public static String DebugPreferencePage_27;
56
	public static String DebugPreferencePage_27;
53
57
58
	public static String DefaultLaunchConfigurationsPropertiesPage_0;
59
60
	public static String DefaultLaunchConfigurationsPropertiesPage_1;
61
62
	public static String DefaultLaunchConfigurationsPropertiesPage_10;
63
64
	public static String DefaultLaunchConfigurationsPropertiesPage_11;
65
66
	public static String DefaultLaunchConfigurationsPropertiesPage_12;
67
68
	public static String DefaultLaunchConfigurationsPropertiesPage_2;
69
70
	public static String DefaultLaunchConfigurationsPropertiesPage_3;
71
72
	public static String DefaultLaunchConfigurationsPropertiesPage_4;
73
74
	public static String DefaultLaunchConfigurationsPropertiesPage_5;
75
76
	public static String DefaultLaunchConfigurationsPropertiesPage_6;
77
78
	public static String DefaultLaunchConfigurationsPropertiesPage_7;
79
80
	public static String DefaultLaunchConfigurationsPropertiesPage_8;
81
82
	public static String DefaultLaunchConfigurationsPropertiesPage_9;
83
54
	public static String LaunchDelegatesPreferencePage_0;
84
	public static String LaunchDelegatesPreferencePage_0;
55
85
56
	public static String LaunchDelegatesPreferencePage_1;
86
	public static String LaunchDelegatesPreferencePage_1;
(-)ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java (-8 / +21 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
import org.eclipse.debug.internal.ui.contextlaunching.ContextLaunchingToolbarAction;
17
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
16
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
18
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
17
import org.eclipse.debug.ui.DebugUITools;
19
import org.eclipse.debug.ui.DebugUITools;
18
import org.eclipse.jface.action.IAction;
20
import org.eclipse.jface.action.IAction;
Lines 54-61 Link Here
54
		if (menu.getItemCount() > 0) {
56
		if (menu.getItemCount() > 0) {
55
			addSeparator(menu);
57
			addSeparator(menu);
56
		}
58
		}
57
59
		if(!getLaunchGroupIdentifier().equals("org.eclipse.ui.externaltools.launchGroup")) { //$NON-NLS-1$
58
		addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
60
			if(ContextRunner.isContextLaunchEnabled()) {
61
				addToMenu(menu, new ContextLaunchingToolbarAction(getLaunchGroupIdentifier()), -1);
62
			}
63
			else {
64
				addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
65
			}
66
		}
59
		addToMenu(menu, getOpenDialogAction(), -1);
67
		addToMenu(menu, getOpenDialogAction(), -1);
60
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
68
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
61
	}
69
	}
Lines 67-84 Link Here
67
	protected IAction getOpenDialogAction() {
75
	protected IAction getOpenDialogAction() {
68
		return new OpenLaunchDialogAction(getLaunchGroupIdentifier());
76
		return new OpenLaunchDialogAction(getLaunchGroupIdentifier());
69
	}
77
	}
70
78
	
71
	/**
79
	/**
72
	 * Launch the last launch, or open the launch config dialog if none.
80
	 * Launch the last launch, or open the launch config dialog if none.
73
	 * 
81
	 * 
74
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
82
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
75
	 */
83
	 */
76
	public void run(IAction action) {
84
	public void run(IAction action) {
77
		ILaunchConfiguration configuration = getLastLaunch();
85
		if(ContextRunner.isContextLaunchEnabled()) {
78
		if (configuration == null) {
86
			ContextRunner.getDefault().run(getMode());
79
			DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier());
87
		}
80
		} else {
88
		else {
81
			DebugUITools.launch(configuration, getMode());
89
			ILaunchConfiguration configuration = getLastLaunch();
90
			if (configuration == null) {
91
				DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier());
92
			} else {
93
				DebugUITools.launch(configuration, getMode());
94
			}
82
		}
95
		}
83
	}	
96
	}	
84
}
97
}
(-)ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java (-2 / +2 lines)
Lines 53-59 Link Here
53
 * An action delegate that builds a context menu with applicable launch shortcuts
53
 * An action delegate that builds a context menu with applicable launch shortcuts
54
 * for a specific launch mode.
54
 * for a specific launch mode.
55
 * <p>
55
 * <p>
56
 * This class can be subclassed and contributed as an object contribution pop-up
56
 * This class can be sub-classed and contributed as an object contribution pop-up
57
 * menu extension action. When invoked, it becomes a sub-menu that dynamically
57
 * menu extension action. When invoked, it becomes a sub-menu that dynamically
58
 * builds a list of applicable launch shortcuts for the current selection.
58
 * builds a list of applicable launch shortcuts for the current selection.
59
 * Each launch shortcut may have optional information to support a context menu action.
59
 * Each launch shortcut may have optional information to support a context menu action.
Lines 171-177 Link Here
171
	/**
171
	/**
172
	 * This method is used to determine if the selected object is in fact a shared launch
172
	 * This method is used to determine if the selected object is in fact a shared launch
173
	 * configuration that can be launched
173
	 * configuration that can be launched
174
	 * @return true if the item is a shared ocnfig , false otherwise
174
	 * @return true if the item is a shared config , false otherwise
175
	 * @since 3.3
175
	 * @since 3.3
176
	 */
176
	 */
177
	private boolean isSharedConfig(Object receiver) {
177
	private boolean isSharedConfig(Object receiver) {
(-)ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java (-2 / +10 lines)
Lines 16-21 Link Here
16
import org.eclipse.debug.core.ILaunchConfigurationType;
16
import org.eclipse.debug.core.ILaunchConfigurationType;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
18
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.contextlaunching.ContextMessages;
19
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
21
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
21
import org.eclipse.debug.ui.DebugUITools;
23
import org.eclipse.debug.ui.DebugUITools;
Lines 59-66 Link Here
59
		fIdentifier = identifier;
61
		fIdentifier = identifier;
60
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
62
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
61
		if (extension != null) {
63
		if (extension != null) {
62
			setText(extension.getLabel() + "..."); //$NON-NLS-1$
64
			if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)
63
			setImageDescriptor(extension.getImageDescriptor());
65
					&& !"org.eclipse.ui.externaltools.launchGroup".equals(identifier)) { //$NON-NLS-1$
66
				setText(ContextMessages.OpenLaunchDialogAction_0);
67
			}
68
			else {
69
				setText(extension.getLabel() + "..."); //$NON-NLS-1$
70
				setImageDescriptor(extension.getImageDescriptor());
71
			}
64
		}
72
		}
65
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
73
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
66
	}
74
	}
(-)ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java (-7 / +14 lines)
Lines 21-26 Link Here
21
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.internal.ui.DebugUIPlugin;
22
import org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener;
22
import org.eclipse.debug.internal.ui.ILaunchHistoryChangedListener;
23
import org.eclipse.debug.internal.ui.actions.ActionMessages;
23
import org.eclipse.debug.internal.ui.actions.ActionMessages;
24
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
24
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
25
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
25
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
26
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
26
import org.eclipse.jface.action.ActionContributionItem;
27
import org.eclipse.jface.action.ActionContributionItem;
Lines 183-200 Link Here
183
	 */
184
	 */
184
	protected String getToolTip(ILaunchConfiguration configuration) {
185
	protected String getToolTip(ILaunchConfiguration configuration) {
185
		String launchName= configuration.getName();
186
		String launchName= configuration.getName();
186
		String mode= getMode();
187
		String label = null;
187
		String label;
188
		if(ContextRunner.isContextLaunchEnabled()) {
189
			launchName = ContextRunner.getDefault().getContextName();
190
		}
191
		String mode = getMode();
188
		if (mode.equals(ILaunchManager.RUN_MODE)) {
192
		if (mode.equals(ILaunchManager.RUN_MODE)) {
189
			label= ActionMessages.AbstractLaunchHistoryAction_1; 
193
			label = ActionMessages.AbstractLaunchHistoryAction_1; 
190
		} else if (mode.equals(ILaunchManager.DEBUG_MODE)){
194
		} else if (mode.equals(ILaunchManager.DEBUG_MODE)){
191
			label= ActionMessages.AbstractLaunchHistoryAction_2; 
195
			label = ActionMessages.AbstractLaunchHistoryAction_2; 
192
		} else if (mode.equals(ILaunchManager.PROFILE_MODE)){
196
		} else if (mode.equals(ILaunchManager.PROFILE_MODE)){
193
			label= ActionMessages.AbstractLaunchHistoryAction_3; 
197
			label = ActionMessages.AbstractLaunchHistoryAction_3; 
194
		} else {
198
		} else {
195
			label= ActionMessages.AbstractLaunchHistoryAction_4; 
199
			label = ActionMessages.AbstractLaunchHistoryAction_4; 
196
		}
200
		}
197
		return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_0, new String[] {label, launchName}); 
201
		return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_0, new String[] {label, launchName});
198
	}
202
	}
199
	
203
	
200
	/**
204
	/**
Lines 337-342 Link Here
337
		if (fAction == null) {
341
		if (fAction == null) {
338
			initialize(action);
342
			initialize(action);
339
		} 
343
		} 
344
		if(ContextRunner.isContextLaunchEnabled()) {
345
			updateTooltip();
346
		}
340
	}
347
	}
341
	
348
	
342
	/**
349
	/**
(-)ui/org/eclipse/debug/internal/ui/preferences/ContextLaunchingPropertyTester.java (+34 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.internal.ui.preferences;
12
13
import org.eclipse.core.expressions.PropertyTester;
14
import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
17
/**
18
 * Tests properties for enabling/disabling popup menu object contributions
19
 * @since 3.3
20
 * 
21
 * EXPERIMENTAL
22
 */
23
public class ContextLaunchingPropertyTester extends PropertyTester {
24
25
	/**
26
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
27
	 */
28
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
29
		if("contextlaunch".equals(property)) { //$NON-NLS-1$
30
			return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
31
		}
32
		return false;
33
	}
34
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingAction.java (+75 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.internal.ui.contextlaunching;
12
13
import org.eclipse.jface.action.IAction;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.swt.widgets.Event;
16
import org.eclipse.ui.IActionDelegate2;
17
18
/**
19
 * A universal context launching action for popup menus. 
20
 * This action gets its immediate context from what was right-clicked
21
 * on to present the action.
22
 * 
23
 * @see {@link ContextRunner}
24
 * @see {@link IActionDelegate2}
25
 * @see {@link RunContextLaunchingAction}
26
 * @see {@link DebugContextLaunchingAction}
27
 * @see {@link ProfileContextLaunchingAction}
28
 * 
29
 * @since 3.3
30
 * EXPERIMENTAL
31
 */
32
public class ContextLaunchingAction implements IActionDelegate2 {
33
34
	/**
35
	 * the mode the action is created on
36
	 */
37
	private String fMode = null;
38
	
39
	/**
40
	 * Constructor
41
	 * @param mode
42
	 */
43
	public ContextLaunchingAction(String mode) {
44
		fMode = mode;
45
	}
46
47
	/**
48
	 * @see org.eclipse.ui.IActionDelegate2#dispose()
49
	 */
50
	public void dispose() {}
51
52
	/**
53
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
54
	 */
55
	public void init(IAction action) {}
56
57
	/**
58
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
59
	 */
60
	public void runWithEvent(IAction action, Event event) {
61
		ContextRunner.getDefault().run(fMode);
62
	}
63
	
64
	/**
65
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
66
	 */
67
	public void run(IAction action) {
68
		//not called
69
	}
70
71
	/**
72
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
73
	 */
74
	public void selectionChanged(IAction action, ISelection selection) {}
75
}
(-)ui/org/eclipse/debug/internal/ui/preferences/ContextLaunchingPreferencePage.java (+104 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.internal.ui.preferences;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.debug.internal.ui.DebugUIPlugin;
17
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
18
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19
import org.eclipse.debug.internal.ui.SWTUtil;
20
import org.eclipse.jface.preference.BooleanFieldEditor;
21
import org.eclipse.jface.preference.FieldEditor;
22
import org.eclipse.jface.preference.PreferencePage;
23
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.ui.IWorkbench;
27
import org.eclipse.ui.IWorkbenchPreferencePage;
28
import org.eclipse.ui.PlatformUI;
29
30
/**
31
 * A preference page for configuring launching preferences.
32
 * 
33
 * @since 3.3
34
 */
35
public class ContextLaunchingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
36
	
37
	/**
38
	 * a list of the field editors
39
	 */
40
	private List fFieldEditors;
41
	
42
	/**
43
	 * The default constructor
44
	 */
45
	public ContextLaunchingPreferencePage() {
46
		super();
47
		setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
48
	}
49
	
50
	/**
51
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
52
	 */
53
	public void createControl(Composite parent) {
54
		super.createControl(parent);
55
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.CONTEXTUAL_LAUNCHING_PREFERENCE_PAGE);
56
	}
57
	
58
	/**
59
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
60
	 */
61
	protected Control createContents(Composite parent) {
62
		fFieldEditors = new ArrayList();
63
		Composite comp = SWTUtil.createComposite(parent, 1, 1, GridData.FILL_BOTH);
64
		
65
		SWTUtil.createWrapLabel(comp, DebugPreferencesMessages.ContextualLaunchPreferencePage_0, 1, 300);
66
		SWTUtil.createVerticalSpacer(comp, 2);
67
		//use contextual launch
68
		FieldEditor edit = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, DebugPreferencesMessages.ContextualLaunchPreferencePage_1, comp);	
69
		fFieldEditors.add(edit);
70
			
71
		//init the field editors
72
		FieldEditor editor;
73
		for(int i = 0; i < fFieldEditors.size(); i++) {
74
			editor = (FieldEditor)fFieldEditors.get(i);
75
			editor.setPreferenceStore(getPreferenceStore());
76
			editor.load();
77
		}
78
		return comp;
79
	}
80
	
81
	/**
82
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
83
	 */
84
	public void init(IWorkbench workbench) {}
85
	
86
	/**
87
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
88
	 */
89
	protected void performDefaults() {
90
		for(int i = 0; i < fFieldEditors.size(); i++) {
91
			((FieldEditor)fFieldEditors.get(i)).loadDefault();
92
		}
93
	}
94
	
95
	/**
96
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
97
	 */
98
	public boolean performOk() {
99
		for(int i = 0; i < fFieldEditors.size(); i++) {
100
			((FieldEditor)fFieldEditors.get(i)).store();
101
		}
102
		return super.performOk();
103
	}
104
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java (+258 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui.contextlaunching;
2
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6
7
import org.eclipse.core.expressions.EvaluationContext;
8
import org.eclipse.core.expressions.IEvaluationContext;
9
import org.eclipse.core.resources.IResource;
10
import org.eclipse.core.runtime.CoreException;
11
import org.eclipse.core.runtime.IAdaptable;
12
import org.eclipse.debug.core.DebugPlugin;
13
import org.eclipse.debug.core.ILaunch;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchListener;
16
import org.eclipse.debug.internal.core.LaunchManager;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutSelectionDialog;
21
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.ISelectionProvider;
25
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.jface.window.Window;
27
import org.eclipse.ui.IEditorInput;
28
import org.eclipse.ui.IEditorPart;
29
import org.eclipse.ui.IWorkbenchPage;
30
import org.eclipse.ui.IWorkbenchPart;
31
import org.eclipse.ui.IWorkbenchPartSite;
32
import org.eclipse.ui.IWorkbenchWindow;
33
34
/**
35
 * Static runner for context launching to provide the base capability of context 
36
 * launching to more than one form of action (drop down, toolbar, view, etc)
37
 * 
38
 * @see {@link ContextLaunchingAction}
39
 * @see {@link ContextLaunchingToolbarAction}
40
 * @see {@link ILaunchListener}
41
 * @see {@link org.eclipse.debug.core.ILaunchManager}
42
 * 
43
 *  @since 3.3
44
 *  EXPERIMENTAL
45
 */
46
public class ContextRunner implements ILaunchListener {
47
	
48
	private static ContextRunner fgInstance = null;
49
	
50
	/**
51
	 * Returns the singleton instance of <code>ContextRunner</code>
52
	 * @return the singleton instance of <code>ContextRunner</code>
53
	 */
54
	public static ContextRunner getDefault() {
55
		if(fgInstance == null) {
56
			fgInstance = new ContextRunner();
57
		}
58
		return fgInstance;
59
	}
60
61
	/**
62
	 * The underlying resource that is derived from the object context of the 
63
	 * run(Object, String) method
64
	 */
65
	private IResource fBackingResource = null;
66
	
67
	/**
68
	 * Performs the context launching given the object context and the mode to launch in
69
	 * @param mode the mode to launch in
70
	 */
71
	public void run(String mode) {
72
		try {
73
			Object context = getCurrentContext();
74
			boolean launched = false;
75
			if(context instanceof IAdaptable) {
76
				IAdaptable adapt = (IAdaptable) context;
77
				IResource resource = (IResource) adapt.getAdapter(IResource.class);
78
				if(resource != null) {
79
					fBackingResource = resource;
80
					ILaunchConfiguration config = getLaunchManager().getDefaultConfiguration(resource);
81
					if(config != null) {
82
						if(config.exists()) {
83
							DebugUITools.launch(config, mode);
84
							launched = true;
85
						}
86
						else {
87
							getLaunchManager().setDefaultConfiguration(resource, null);
88
							selectAndLaunch(adapt, mode);
89
							launched = true;
90
						}
91
					}
92
					else {
93
						selectAndLaunch(adapt, mode);
94
						launched = true;
95
					}
96
				}
97
			}
98
			if(!launched) {
99
				DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP, null);
100
			}
101
		}
102
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
103
	}
104
	
105
	/**
106
	 * Prompts the user to select a way of launching the current resource, where a 'way'
107
	 * is defined as a launch shortcut
108
	 * @param adapt the adaptable type the specified resource was derived from
109
	 * @param resource
110
	 * @return the 'way' to launch the selected resource
111
	 * @throws CoreException
112
	 */
113
	protected void selectAndLaunch(IAdaptable adapt, String mode) throws CoreException {
114
		LaunchShortcutSelectionDialog dialog = new LaunchShortcutSelectionDialog(getLaunchShortcuts(fBackingResource), fBackingResource, mode);
115
		if (dialog.open() == Window.OK) {
116
			Object[] result = dialog.getResult();
117
			if(result.length > 0) {
118
				if(dialog.makeDefault()) {
119
					getLaunchManager().addLaunchListener(this);
120
				}
121
				LaunchShortcutExtension method = (LaunchShortcutExtension) result[0];
122
				if(method != null) {
123
					if(adapt instanceof IEditorInput) {
124
						IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
125
						if(window != null) {
126
							IEditorPart epart = window.getActivePage().getActiveEditor();
127
							method.launch(epart, mode);
128
						}
129
					}
130
					else {
131
						method.launch(new StructuredSelection(adapt), mode);
132
					}
133
				}
134
			}
135
		}
136
	}
137
	
138
	/**
139
	 * Creates a listing of the launch shortcut extensions that are applicable to the underlying resource
140
	 * @param resource the underlying resource
141
	 * @return a listing of applicable launch shortcuts
142
	 * @throws CoreException
143
	 */
144
	protected List getLaunchShortcuts(IResource resource) throws CoreException {
145
		List list = new ArrayList(); 
146
		List sc = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts();
147
		List ctxt = new ArrayList();
148
		ctxt.add(resource);
149
		IEvaluationContext context = new EvaluationContext(null, ctxt);
150
		context.addVariable("selection", ctxt); //$NON-NLS-1$
151
		LaunchShortcutExtension ext = null;
152
		for(Iterator iter = sc.iterator(); iter.hasNext();) {
153
			ext = (LaunchShortcutExtension) iter.next();
154
			if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
155
				if(!list.contains(ext)) {
156
					list.add(ext);
157
				}
158
			}
159
		}
160
		return list;
161
	}
162
	
163
	/**
164
	 * Returns the current context to be considered for launching. 
165
	 * The returned object will be one of:
166
	 * <ol>
167
	 * <li>{@link IEditorInput}<li>
168
	 * <li>{@link Object}, where <i>object</i> is the first element in the selection obtained from the 
169
	 * selection provider of the currently selected workbench part</li>
170
	 * </ol>
171
	 * @return the currently selected context to consider for launching, or <code>null</code>.
172
	 *
173
	 */
174
	public Object getCurrentContext() {
175
		IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
176
		if(window != null) {
177
			IWorkbenchPage page = window.getActivePage();
178
			if(page!= null) {
179
				IWorkbenchPart part = page.getActivePart();
180
				if(part != null) {
181
					if(part instanceof IEditorPart) {
182
						return ((IEditorPart)part).getEditorInput();
183
					}
184
					IWorkbenchPartSite site = part.getSite();
185
					if(site != null) {
186
						ISelectionProvider provider = site.getSelectionProvider();
187
						if(provider != null) {
188
							ISelection sel = provider.getSelection();
189
							if(sel != null) {
190
								return ((StructuredSelection)sel).getFirstElement();
191
							}
192
							return sel;
193
						}
194
					}
195
				}
196
			}
197
			
198
		}
199
		return null;
200
	}
201
	
202
	/**
203
	 * Returns the name of the currently selected context, or the empty string.
204
	 * This method can return null in the event the contributor of the selected context returns <code>null</code>
205
	 * as the resource name.
206
	 * @return the name of the currently selected context or the empty string. 
207
	 */
208
	public String getContextName() {
209
		Object o = getCurrentContext();
210
		if(o instanceof IAdaptable) {
211
			IResource resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
212
			if(resource != null) {
213
				return resource.getName();
214
			}
215
		}
216
		return ""; //$NON-NLS-1$
217
	}
218
	
219
	/**
220
	 * Returns if context launching is enabled
221
	 * @return if context launching is enabled
222
	 */
223
	public static boolean isContextLaunchEnabled() {
224
		return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
225
	}
226
	
227
	/**
228
	 * Returns the launch manager
229
	 * @return the launch manager
230
	 */
231
	protected LaunchManager getLaunchManager() {
232
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
233
	}
234
	
235
	/**
236
	 * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch)
237
	 */
238
	public void launchAdded(ILaunch launch) {
239
		if(fBackingResource != null) {
240
			try {
241
				getLaunchManager().setDefaultConfiguration(fBackingResource, launch.getLaunchConfiguration());
242
				getLaunchManager().removeLaunchListener(this);
243
			}
244
			catch(CoreException ce) {DebugUIPlugin.log(ce);}
245
		}
246
	}
247
248
	/**
249
	 * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch)
250
	 */
251
	public void launchChanged(ILaunch launch) {}
252
253
	/**
254
	 * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
255
	 */
256
	public void launchRemoved(ILaunch launch) {}
257
	
258
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ProfileContextLaunchingAction.java (+35 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.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.core.ILaunchManager;
14
15
/**
16
 * Specialization of <code>ContextLaunchingAction</code> for profile mode
17
 * 
18
 * @see {@link ContextLaunchingAction}
19
 * @see {@link ILaunchManager}
20
 * @see {@link RunContextLaunchingAction}
21
 * @see {@link DebugContextLaunchingAction}
22
 * 
23
 * @since 3.3
24
 * EXPERIMENTAL
25
 */
26
public class ProfileContextLaunchingAction extends ContextLaunchingAction {
27
28
	/**
29
	 * Constructor
30
	 */
31
	public ProfileContextLaunchingAction() {
32
		super(ILaunchManager.PROFILE_MODE);
33
	}
34
35
}
(-)ui/org/eclipse/debug/internal/ui/preferences/DefaultLaunchConfigurationsPropertiesPage.java (+480 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.internal.ui.preferences;
12
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.Comparator;
17
import java.util.HashSet;
18
import java.util.Iterator;
19
import java.util.List;
20
import java.util.Set;
21
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IAdaptable;
25
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.core.ILaunchConfigurationType;
29
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.internal.core.LaunchManager;
31
import org.eclipse.debug.internal.ui.DebugUIPlugin;
32
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
33
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
34
import org.eclipse.debug.internal.ui.SWTUtil;
35
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationComparator;
36
import org.eclipse.debug.ui.DebugUITools;
37
import org.eclipse.debug.ui.IDebugUIConstants;
38
import org.eclipse.jface.viewers.ArrayContentProvider;
39
import org.eclipse.jface.viewers.CheckStateChangedEvent;
40
import org.eclipse.jface.viewers.CheckboxTableViewer;
41
import org.eclipse.jface.viewers.ICheckStateListener;
42
import org.eclipse.jface.viewers.ISelectionChangedListener;
43
import org.eclipse.jface.viewers.IStructuredSelection;
44
import org.eclipse.jface.viewers.SelectionChangedEvent;
45
import org.eclipse.jface.viewers.StructuredSelection;
46
import org.eclipse.jface.window.Window;
47
import org.eclipse.swt.SWT;
48
import org.eclipse.swt.events.SelectionEvent;
49
import org.eclipse.swt.events.SelectionListener;
50
import org.eclipse.swt.layout.GridData;
51
import org.eclipse.swt.layout.GridLayout;
52
import org.eclipse.swt.widgets.Button;
53
import org.eclipse.swt.widgets.Composite;
54
import org.eclipse.swt.widgets.Control;
55
import org.eclipse.swt.widgets.Table;
56
import org.eclipse.ui.PlatformUI;
57
import org.eclipse.ui.dialogs.ListDialog;
58
import org.eclipse.ui.dialogs.PropertyPage;
59
60
import com.ibm.icu.text.MessageFormat;
61
62
/**
63
 * Displays default launch configuration settings for a selected resource - associated launch configurations.
64
 * 
65
 * @see {@link PropertyPage}
66
 * @see {@link ILaunchConfiguration}
67
 * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog}
68
 * @see {@link IDebugHelpContextIds#DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE}
69
 * 
70
 * @since 3.3
71
 */
72
public class DefaultLaunchConfigurationsPropertiesPage extends PropertyPage {
73
	/**
74
	 * Set of configurations to be deleted
75
	 */
76
	private Set fDeletedConfigurations = new HashSet();
77
	
78
	/**
79
	 * Set of original default candidates for the resource
80
	 */
81
	private Set fOriginalCandidates;
82
	
83
	/**
84
	 * List of the applicable launch config types for the backing resource
85
	 */
86
	private List fTypeCandidates = null;
87
	
88
	//widgets
89
	private CheckboxTableViewer fViewer;
90
	private Button fNewButton = null;
91
	private Button fEditButton = null;
92
	private Button fDuplicateButton = null;
93
	private Button fDeleteButton = null;
94
95
	/* (non-Javadoc)
96
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
97
	 */
98
	protected Control createContents(Composite parent) {
99
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE);
100
		
101
		Composite topComposite = SWTUtil.createComposite(parent, 2, 1, GridData.FILL_BOTH);
102
		
103
		SWTUtil.createWrapLabel(topComposite, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_0, 2, 300);
104
		SWTUtil.createVerticalSpacer(topComposite, 2);
105
		SWTUtil.createWrapLabel(topComposite, MessageFormat.format(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_1, new String[]{getResource().getName()}), 2, 300);
106
		
107
		fViewer = createViewer(topComposite);
108
		
109
		Composite buttonComp = SWTUtil.createComposite(topComposite, 1, 1, GridData.FILL_VERTICAL);
110
		GridLayout layout = (GridLayout) buttonComp.getLayout();
111
		layout.marginHeight = 0;
112
		fNewButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_2, null);
113
		fNewButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_3);
114
		fNewButton.addSelectionListener(new SelectionListener() {
115
			public void widgetDefaultSelected(SelectionEvent e) {}
116
			public void widgetSelected(SelectionEvent e) {
117
				handleNew();
118
			}
119
		});
120
		
121
		fDuplicateButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_4, null);
122
		fDuplicateButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_5);
123
		fDuplicateButton.setEnabled(false);
124
		fDuplicateButton.addSelectionListener(new SelectionListener() {
125
			public void widgetDefaultSelected(SelectionEvent e) {}
126
			public void widgetSelected(SelectionEvent e) {
127
				handleCopy();
128
			}
129
		});
130
		fEditButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_6, null);
131
		fEditButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_7);
132
		fEditButton.setEnabled(false);
133
		fEditButton.addSelectionListener(new SelectionListener() {
134
			public void widgetDefaultSelected(SelectionEvent e) {}
135
			public void widgetSelected(SelectionEvent e) {
136
				handleEdit();
137
			}
138
		});
139
		fDeleteButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_8, null);
140
		fDeleteButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_9);
141
		fDeleteButton.setEnabled(false);
142
		fDeleteButton.addSelectionListener(new SelectionListener() {
143
			public void widgetDefaultSelected(SelectionEvent e) {}
144
			public void widgetSelected(SelectionEvent e) {
145
				handleDelete();
146
			}
147
		});
148
		
149
		fViewer.setSelection(new StructuredSelection());
150
		applyDialogFont(topComposite);
151
		return topComposite;
152
	}
153
154
	/**
155
	 * Creates and returns the viewer that will display the possible default configurations.
156
	 * 
157
	 * @param parent parent composite to create the viewer in
158
	 * @return viewer viewer that will display possible default configurations
159
	 */
160
	protected CheckboxTableViewer createViewer(Composite parent){
161
		CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
162
		viewer.setLabelProvider(new DefaultLabelProvider());
163
		viewer.setContentProvider(new ArrayContentProvider());
164
		viewer.setComparator(new LaunchConfigurationComparator());
165
		viewer.addCheckStateListener(new ICheckStateListener() {
166
			public void checkStateChanged(CheckStateChangedEvent event) {
167
				if (event.getChecked()) {
168
					fViewer.setCheckedElements(new Object[] {event.getElement()});
169
				}
170
				else{
171
					fViewer.setCheckedElements(new Object[] {});
172
				}
173
			}
174
		});
175
		Table builderTable = viewer.getTable();
176
		GridData tableGridData = new GridData(GridData.FILL_BOTH);
177
		tableGridData.heightHint = 300;
178
		builderTable.setLayoutData(tableGridData);
179
		
180
		IResource resource = getResource();
181
		viewer.setInput(collectConfigCandidates(resource));
182
		try {
183
			ILaunchConfiguration configuration = getLaunchManager().getDefaultConfiguration(resource);
184
			if (configuration != null) {
185
				Iterator iterator = fOriginalCandidates.iterator();
186
				while (iterator.hasNext()) {
187
					ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
188
					if (configuration.equals(wc.getOriginal())) {
189
						viewer.setChecked(wc, true);
190
						break;
191
					}
192
				}
193
			}
194
		} catch (CoreException e) {
195
			setErrorMessage(e.getMessage());
196
		}
197
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
198
			public void selectionChanged(SelectionChangedEvent event) {
199
				boolean empty = event.getSelection().isEmpty();
200
				fEditButton.setEnabled(!empty);
201
				fDuplicateButton.setEnabled(!empty);
202
				fDeleteButton.setEnabled(!empty);
203
			}
204
		});
205
		
206
		return viewer;
207
	}
208
209
	/**
210
	 * Returns the viewer displaying possible default configurations.
211
	 * 
212
	 * @return viewer
213
	 */
214
	protected CheckboxTableViewer getViewer() {
215
		return fViewer;
216
	}
217
		
218
	/**
219
	 * Returns the launch manager
220
	 * @return the launch manager
221
	 */
222
	protected LaunchManager getLaunchManager() {
223
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
224
	}
225
	
226
	/**
227
	 * Collects the applicable launch configuration types for the backing resource.
228
	 * Default implementation uses the launch shortcut evaluation expressions and leverages the 
229
	 * mapping of launch shortcut to config type id to derive the applicable types.
230
	 * @return the listing of applicable launch configuration types for the backing resource
231
	 */
232
	protected List collectTypeCandidates() {
233
		if(fTypeCandidates == null) {
234
			fTypeCandidates = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getApplicableConfigurationTypes(getResource());
235
			Collections.sort(fTypeCandidates, new Comparator() {
236
				public int compare(Object o1, Object o2) {
237
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
238
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
239
					return t1.getName().compareTo(t2.getName());
240
				}
241
			
242
			});
243
		}
244
		return fTypeCandidates;
245
	}
246
	
247
	/**
248
	 * Returns a set of potential default configurations candidates for the given
249
	 * resource. The configurations are working copies.
250
	 *  
251
	 * @param resource resource
252
	 * @return list of default candidates
253
	 */
254
	protected Set collectConfigCandidates(IResource resource) {
255
		if(fOriginalCandidates == null) {
256
			fOriginalCandidates = new HashSet();
257
			IPath resourcePath = resource.getFullPath();
258
			try {
259
				List types = collectTypeCandidates();
260
				List configs = new ArrayList();
261
				ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations();
262
				for(int i = 0; i < configurations.length; i++) {
263
					if(types.contains(configurations[i].getType())) {
264
						configs.add(configurations[i]);
265
					}
266
				}
267
				ILaunchConfiguration configuration = null;
268
				IResource[] resources = null;
269
				for (Iterator iter = configs.iterator(); iter.hasNext();) {
270
					configuration = (ILaunchConfiguration) iter.next();
271
					if(!DebugUITools.isPrivate(configuration) && !"org.eclipse.ui.externaltools".equals(configuration.getType().getCategory())) { //$NON-NLS-1$
272
						if(configuration.contentsEqual(getLaunchManager().getDefaultConfiguration(resource))) {
273
							fOriginalCandidates.add(configuration.getWorkingCopy());
274
						}
275
						else {
276
							resources = configuration.getMappedResources();
277
							if (resources != null) {
278
								for (int j = 0; j < resources.length; j++) {
279
									if (resource.equals(resources[j]) || resourcePath.isPrefixOf(resources[j].getFullPath()) ||
280
											resources[j].getFullPath().isPrefixOf(resourcePath)) {
281
										fOriginalCandidates.add(configuration.getWorkingCopy());
282
										break;
283
									}
284
								}
285
							}
286
						}
287
					}
288
				}
289
			} catch (CoreException e) {
290
				fOriginalCandidates.clear();
291
				DebugPlugin.log(e);
292
			}
293
		}
294
		return fOriginalCandidates;
295
	}
296
	
297
	/**
298
	 * Returns the resource this property page is open on.
299
	 * 
300
	 * @return resource
301
	 */
302
	protected IResource getResource() {
303
		Object element = getElement();
304
		IResource resource = null;
305
		if (element instanceof IResource) {
306
			resource = (IResource) element;
307
		} else if (element instanceof IAdaptable) {
308
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
309
		}
310
		return resource;
311
	}
312
313
	/* (non-Javadoc)
314
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
315
	 */
316
	public boolean performOk() {
317
		Object[] checked = fViewer.getCheckedElements();
318
		try {
319
			ILaunchConfiguration def = null;
320
			if (checked.length == 1) {
321
					def = (ILaunchConfiguration) checked[0];
322
					def = ((ILaunchConfigurationWorkingCopy)def).doSave();
323
			}
324
			DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
325
		} catch (CoreException e) {
326
			setErrorMessage(e.getMessage());
327
			return false;
328
		}
329
	//delete 
330
		Iterator iter = fDeletedConfigurations.iterator();
331
		while (iter.hasNext()) {
332
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
333
			try{			
334
				if (currentConfig.getOriginal() != null){
335
					currentConfig.getOriginal().delete();
336
				}
337
			} catch (CoreException e) {
338
				DebugPlugin.logMessage("Problem deleting configuration " + currentConfig.getName(), e); //$NON-NLS-1$
339
			}
340
		}
341
	//add
342
		iter = fOriginalCandidates.iterator();
343
		while (iter.hasNext()) {
344
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
345
			if (currentConfig.isDirty()){
346
				try{
347
					currentConfig.doSave();
348
				} catch (CoreException e) {
349
					DebugPlugin.logMessage("Problem saving changes to configuration " + currentConfig.getName(), e); //$NON-NLS-1$
350
				}
351
			}
352
		}
353
		
354
		return super.performOk();
355
	}
356
357
	/* (non-Javadoc)
358
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
359
	 */
360
	protected void performDefaults() {
361
		fViewer.setAllChecked(false);
362
		setErrorMessage(null);
363
		setValid(true);
364
		super.performDefaults();
365
	}
366
	
367
	/**
368
	 * Returns the names of the launch configurations passed in as original input to the tree viewer
369
	 * @return the names of the original launch configurations
370
	 */
371
	private Set getConfigurationNames() {
372
		Set names = new HashSet();
373
		Iterator iter = fOriginalCandidates.iterator();
374
		Object o = null;
375
		while (iter.hasNext()) {
376
			o = iter.next();
377
			if(o instanceof ILaunchConfiguration) {
378
				names.add(((ILaunchConfiguration)o).getName());
379
			}
380
		}
381
		return names;
382
	}
383
	
384
	/**
385
	 * Returns selected configurations.
386
	 * 
387
	 * @return selected configurations
388
	 */
389
	private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() {
390
		IStructuredSelection ss = (IStructuredSelection) fViewer.getSelection();
391
		return (ILaunchConfigurationWorkingCopy[]) ss.toList().toArray(new ILaunchConfigurationWorkingCopy[ss.size()]);
392
	}
393
394
	/**
395
	 * Copy the selection
396
	 */
397
	private void handleCopy() {
398
		ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0];
399
		try {
400
			ILaunchConfigurationWorkingCopy copy = configuration.copy(
401
					((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).generateUniqueLaunchConfigurationNameFrom(configuration.getName(), getConfigurationNames()));
402
			copy.setAttributes(configuration.getAttributes());
403
			fOriginalCandidates.add(copy);
404
			fViewer.refresh();
405
			fViewer.setSelection(new StructuredSelection(copy));
406
		} catch (CoreException e) {
407
			setErrorMessage(e.getMessage());
408
		}
409
	}
410
411
	/**
412
	 * Delete the selection
413
	 */
414
	private void handleDelete() {
415
		Table table = fViewer.getTable();
416
		int[] indices = table.getSelectionIndices();
417
		Arrays.sort(indices);
418
		ILaunchConfiguration[] configurations = getSelectedConfigurations();
419
		for (int i = 0; i < configurations.length; i++) {
420
			fDeletedConfigurations.add(configurations[i]);
421
			fOriginalCandidates.remove(configurations[i]);
422
		}
423
		fViewer.refresh();
424
		if (indices[0] < table.getItemCount()) {
425
			fViewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData()));
426
		} else if (table.getItemCount() > 0) {
427
			fViewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData()));
428
		}
429
	}
430
431
	/**
432
	 * Edit the selection
433
	 */
434
	private void handleEdit() {
435
		edit(getSelectedConfigurations()[0]);
436
		fViewer.refresh();
437
	}
438
439
	/**
440
	 * Edits the given configuration as a nested working copy.
441
	 * Returns the code from the dialog used to edit the configuration.
442
	 * 
443
	 * @param configuration
444
	 * @return dialog return code - OK or CANCEL
445
	 */
446
	private int edit(ILaunchConfigurationWorkingCopy configuration) {
447
		return DebugUIPlugin.openLaunchConfigurationPropertiesDialog(getShell(), configuration, IDebugUIConstants.ID_RUN_LAUNCH_GROUP, getConfigurationNames(), null);
448
	}
449
450
	/**
451
	 * Create a new configuration
452
	 */
453
	private void handleNew() {
454
		ListDialog dialog = new ListDialog(getShell());
455
		dialog.setTitle(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_11);
456
		dialog.setContentProvider(new ArrayContentProvider());
457
		dialog.setLabelProvider(new DefaultLabelProvider());
458
		dialog.setAddCancelButton(true);
459
		dialog.setMessage(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_12);
460
		dialog.setInput(collectTypeCandidates());
461
		if (dialog.open() == Window.OK) {
462
			Object[] result = dialog.getResult();
463
			if (result.length == 1) {
464
				ILaunchConfigurationType type = (ILaunchConfigurationType) result[0];
465
				try {
466
					ILaunchConfigurationWorkingCopy wc = type.newInstance(null, 
467
							((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).
468
							generateUniqueLaunchConfigurationNameFrom("New_configuration", getConfigurationNames())); //$NON-NLS-1$
469
					if (edit(wc) == Window.OK) {
470
						fOriginalCandidates.add(wc);
471
						fViewer.refresh();
472
						fViewer.setSelection(new StructuredSelection(wc));
473
					}
474
				} catch (CoreException e) {
475
					setErrorMessage(e.getMessage());
476
				}
477
			}
478
		}
479
	}	
480
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/RunContextLaunchingAction.java (+35 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.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.core.ILaunchManager;
14
15
/**
16
 * Specialization of <code>ContextLaunchingAction</code> for run mode
17
 * 
18
 * @see {@link ContextLaunchingAction}
19
 * @see {@link ILaunchManager}
20
 * @see {@link DebugContextLaunchingAction}
21
 * @see {@link ProfileContextLaunchingAction}
22
 * 
23
 * @since 3.3
24
 * EXPERIMENTAL
25
 */
26
public class RunContextLaunchingAction extends ContextLaunchingAction {
27
28
	/**
29
	 * Constructor
30
	 */
31
	public RunContextLaunchingAction() {
32
		super(ILaunchManager.RUN_MODE);
33
	}
34
35
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java (+16 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui.contextlaunching;
2
3
import org.eclipse.osgi.util.NLS;
4
5
public class ContextMessages extends NLS {
6
	private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.contextlaunching.ContextMessages"; //$NON-NLS-1$
7
	public static String ContextRunner_0;
8
	public static String OpenLaunchDialogAction_0;
9
	static {
10
		// initialize resource bundle
11
		NLS.initializeMessages(BUNDLE_NAME, ContextMessages.class);
12
	}
13
14
	private ContextMessages() {
15
	}
16
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingToolbarAction.java (+81 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.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.internal.ui.DebugUIPlugin;
14
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
15
import org.eclipse.jface.action.Action;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.swt.widgets.Event;
19
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
21
22
/**
23
 * A wrapper class for a context launching toolbar action
24
 * 
25
 * @see {@link ContextRunner}
26
 * @see {@link ContextLaunchingAction}
27
 * @see {@link Action}
28
 * @see {@link IWorkbenchWindowActionDelegate}
29
 * 
30
 *  @since 3.3
31
 *  EXPERIMENTAL
32
 */
33
public class ContextLaunchingToolbarAction extends Action implements IWorkbenchWindowActionDelegate {
34
35
	/**
36
	 * The mode this action applies to
37
	 */
38
	private String fMode = null;
39
	
40
	/**
41
	 * Constructor
42
	 * @param id
43
	 */
44
	public ContextLaunchingToolbarAction(String id) {
45
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(id);
46
		if (extension != null) {
47
			fMode = extension.getMode();
48
			setText(extension.getLabel());
49
			setImageDescriptor(extension.getImageDescriptor());
50
		}
51
	}
52
53
	/**
54
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
55
	 */
56
	public void dispose() {}
57
58
	/**
59
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
60
	 */
61
	public void init(IWorkbenchWindow window) {}
62
	
63
	/**
64
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
65
	 */
66
	public void selectionChanged(IAction action, ISelection selection) {}
67
68
	/**
69
	 * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
70
	 */
71
	public void runWithEvent(Event event) {
72
		ContextRunner.getDefault().run(fMode);
73
	}
74
75
	/**
76
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
77
	 */
78
	public void run(IAction action) {
79
		//do nothing
80
	}
81
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java (+123 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.internal.ui.launchConfigurations;
12
13
import java.util.List;
14
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.debug.core.DebugPlugin;
17
import org.eclipse.debug.core.ILaunchMode;
18
import org.eclipse.debug.internal.ui.DebugUIPlugin;
19
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
20
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
21
import org.eclipse.debug.internal.ui.SWTUtil;
22
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.jface.dialogs.IDialogSettings;
24
import org.eclipse.jface.viewers.ArrayContentProvider;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.events.SelectionListener;
28
import org.eclipse.swt.widgets.Button;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.dialogs.ListDialog;
33
34
import com.ibm.icu.text.MessageFormat;
35
36
/**
37
 * Specialized dialog for showing/selecting a specific launch shortcut extension, and allowing it
38
 * to be marked to be set as the default
39
 * 
40
 * @see {@link org.eclipse.debug.internal.ui.actions.ContextLaunchingAction}
41
 * 
42
 * @since 3.3
43
 * EXPERIMENTAL
44
 */
45
public class LaunchShortcutSelectionDialog extends ListDialog {
46
47
	private static final String DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_SHORTCUT_DIALOG"; //$NON-NLS-1$;
48
	
49
	/**
50
	 * The list of input for the dialog
51
	 */
52
	private String fMode = null;
53
	private IResource fResource = null;
54
	private boolean fChecked = false;
55
	
56
	/**
57
	 * Constructor
58
	 * @param input
59
	 * @param resource
60
	 * @param mode
61
	 */
62
	public LaunchShortcutSelectionDialog(List input, IResource resource, String mode) {
63
		super(DebugUIPlugin.getShell());
64
		setShellStyle(getShellStyle() | SWT.RESIZE);
65
		fResource = resource;
66
		fMode = mode;
67
		ILaunchMode lmode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fMode);
68
		String modename = fMode;
69
		if (lmode != null) {
70
			modename = DebugUIPlugin.removeAccelerators(lmode.getLabel());
71
		}
72
		setTitle(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_0, new String[] {modename}));
73
		setAddCancelButton(true);
74
		setMessage(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_1, new String[] {fMode, fResource.getName()}));
75
		setLabelProvider(new DefaultLabelProvider());
76
		setContentProvider(new ArrayContentProvider());
77
		setInput(input);
78
	}
79
80
	/**
81
	 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
82
	 */
83
	protected Control createContents(Composite parent) {
84
		Composite comp = (Composite) super.createContents(parent);
85
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_METHOD_DIALOG);
86
		return comp;
87
	}
88
89
	/**
90
	 * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
91
	 */
92
	protected IDialogSettings getDialogBoundsSettings() {
93
		IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
94
		IDialogSettings section = settings.getSection(DIALOG_SETTINGS);
95
		if (section == null) {
96
			section = settings.addNewSection(DIALOG_SETTINGS);
97
		} 
98
		return section;
99
	}
100
	
101
	/**
102
	 * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
103
	 */
104
	protected Control createDialogArea(Composite container) {
105
		Composite comp = (Composite) super.createDialogArea(container);
106
		Button butt = SWTUtil.createCheckButton(comp, MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_2, new String[] {fResource.getName()}), null, fChecked);
107
		butt.addSelectionListener(new SelectionListener() {
108
			public void widgetDefaultSelected(SelectionEvent e) {}
109
			public void widgetSelected(SelectionEvent e) {
110
				fChecked = ((Button)e.getSource()).getSelection();
111
			}
112
		});
113
		return comp;
114
	}
115
 
116
	/**
117
	 * Returns if the launched config from the selected shortcut should be made the default for the underlying resource
118
	 * @return if the launched config should be made the default
119
	 */
120
	public boolean makeDefault() {
121
		return fChecked;
122
	}
123
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java (+82 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.internal.ui.launchConfigurations;
12
13
import java.util.Arrays;
14
import java.util.Collections;
15
import java.util.Comparator;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.DebugPlugin;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.ILaunchConfigurationType;
25
import org.eclipse.ui.model.WorkbenchViewerComparator;
26
27
/**
28
 * Groups configurations by type.
29
 * 
30
 * @since 3.3
31
 */
32
public class LaunchConfigurationComparator extends WorkbenchViewerComparator {
33
34
	/**
35
	 * the map of categories of <code>ILaunchConfigurationType</code>s to <code>Integer</code>s entries
36
	 */
37
	private static Map fgCategories;
38
	
39
	/**
40
	 * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
41
	 */
42
	public int category(Object element) {
43
		Map map = getCategories();
44
		if (element instanceof ILaunchConfiguration) {
45
			ILaunchConfiguration configuration = (ILaunchConfiguration) element;
46
			try {
47
				Integer i = (Integer) map.get(configuration.getType());
48
				if (i != null) {
49
					return i.intValue();
50
				}
51
			} catch (CoreException e) {
52
			}
53
		}
54
		return map.size();
55
	}
56
	
57
	/**
58
	 * Returns the map of categories
59
	 * @return the map of categories
60
	 */
61
	private Map getCategories() {
62
		if (fgCategories == null) {
63
			fgCategories = new HashMap();
64
			List types = Arrays.asList(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes());
65
			Collections.sort(types, new Comparator() {
66
				public int compare(Object o1, Object o2) {
67
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
68
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
69
					return t1.getName().compareTo(t2.getName());
70
				}
71
			
72
			});
73
			Iterator iterator = types.iterator();
74
			int i = 0;
75
			while (iterator.hasNext()) {
76
				fgCategories.put(iterator.next(), new Integer(i));
77
				i++;
78
			}
79
		}
80
		return fgCategories;
81
	}
82
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties (+2 lines)
Added Link Here
1
ContextRunner_0=The selected context could not be launched
2
OpenLaunchDialogAction_0=&Open Launch Dialog
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/DebugContextLaunchingAction.java (+34 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.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.core.ILaunchManager;
14
15
/**
16
 * Specialization of <code>ContextLaunchingAction</code> for debug mode
17
 * 
18
 * @see {@link ContextLaunchingAction}
19
 * @see {@link ILaunchManager}
20
 * @see {@link RunContextLaunchingAction}
21
 * @see {@link ProfileContextLaunchingAction}
22
 * 
23
 * @since 3.3
24
 * EXPERIMENTAL
25
 */
26
public class DebugContextLaunchingAction extends ContextLaunchingAction {
27
	
28
	/**
29
	 * Constructor
30
	 */
31
	public DebugContextLaunchingAction() {
32
		super(ILaunchManager.DEBUG_MODE);
33
	}
34
}

Return to bug 74480