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 (-4 / +16 lines)
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 576-582 Link Here
576
		<description>This dialog is used to select the resources that you wish to save prior to continuing launching. Canceling this dialog will cancel the launch.</description>
576
		<description>This dialog is used to select the resources that you wish to save prior to continuing launching. Canceling this dialog will cancel the launch.</description>
577
		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
577
		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
578
	</context>
578
	</context>
579
579
	<context id="select_launch_method_dialog">
580
		<description>This dialog allows you to select a way that you would like to launch the currently selected resource.</description>
581
		<topic label="Running and Debugging" href="tasks/task-running_and_debugging.htm"/>
582
		<topic label="Creating a Java application launch configuration" href="tasks/tasks-java-local-configuration.htm"/>
583
	</context>
580
584
581
585
582
<!--
586
<!--
Lines 681-687 Link Here
681
		<topic label="Source Attachments" href="reference/ref-124.htm"/>
685
		<topic label="Source Attachments" href="reference/ref-124.htm"/>
682
	</context>
686
	</context>
683
	<context  id="launch_configuration_dialog_launchers_tab" >
687
	<context  id="launch_configuration_dialog_launchers_tab" >
684
		<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>
688
		<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>
685
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
689
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
686
	</context>
690
	</context>
687
691
Lines 798-804 Link Here
798
	</context> 
802
	</context> 
799
803
800
<!--
804
<!--
801
	Multiview Action conetxts
805
	Multiview Action contexts
802
-->
806
-->
803
	<context id="find_element_context">
807
	<context id="find_element_context">
804
		<description>This command finds an element by name.</description>
808
		<description>This command finds an element by name.</description>
Lines 871-876 Link Here
871
		<topic label="Debug Preferences" href="reference/preferences/ref-debug.htm"/>
875
		<topic label="Debug Preferences" href="reference/preferences/ref-debug.htm"/>
872
		<topic label="Debugger Concepts" href="concepts/cdebugger.htm"/>
876
		<topic label="Debugger Concepts" href="concepts/cdebugger.htm"/>
873
	</context>
877
	</context>
878
	<context id="contextual_launch_preference_page">
879
		<description>This page allows you to change settings that apply to contextual launching</description>
880
		<topic label="Debug Preferences" href="reference/preferences/ref-debug.htm"/>
881
		<topic label="Debugger Concepts" href="concepts/cdebugger.htm"/>
882
	</context>
874
	
883
	
875
<!-- 
884
<!-- 
876
	Property Pages 
885
	Property Pages 
Lines 884-889 Link Here
884
	<context id="TableRenderingPropertiesPage_context" >
893
	<context id="TableRenderingPropertiesPage_context" >
885
		<description>This page displays properties from the selected memory.</description>
894
		<description>This page displays properties from the selected memory.</description>
886
	</context>
895
	</context>
896
	<context id="default_launchconfiguration_property_page">
897
		<description>This page displays the properties for default launch configurations for the selected resource</description>
898
	</context>
887
899
888
<!--
900
<!--
889
	Run Menu
901
	Run Menu
(-)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 (-5 / +39 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-18 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.CoreException;
16
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.DebugUIPlugin;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
16
import org.eclipse.debug.ui.actions.ILaunchable;
21
import org.eclipse.debug.ui.actions.ILaunchable;
17
22
18
/**
23
/**
Lines 20-35 Link Here
20
 */
25
 */
21
public class LaunchablePropertyTester extends PropertyTester {
26
public class LaunchablePropertyTester extends PropertyTester {
22
27
23
	/* (non-Javadoc)
28
	/**
24
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
29
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
25
	 */
30
	 */
26
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
31
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
27
		if (property.equals("launchable")) { //$NON-NLS-1$
32
		if ("launchable".equals(property)) { //$NON-NLS-1$
28
			if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
33
				if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
29
				return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
34
					return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
35
				}
36
		}
37
		if("resource".equals(property)) { //$NON-NLS-1$
38
			IResource res = getResource(receiver);
39
			if(res != null) {
40
				return res.isAccessible();
30
			}
41
			}
31
		}
42
		}
43
		if("contextlaunch".equals(property)) { //$NON-NLS-1$
44
			return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
45
		}
46
		if("contextlaunchable".equals(property)) { //$NON-NLS-1$
47
			try {
48
				return ContextRunner.getDefault().getLaunchShortcuts(getResource(receiver)).size() > 0 && ContextRunner.getDefault().isSharedConfig(receiver) == null;
49
			} 
50
			catch (CoreException e) {return false;}
51
		}
32
		return false;
52
		return false;
33
	}
53
	}
34
54
55
	/**
56
	 * Returns the resource this property page is open on.
57
	 * 
58
	 * @return resource
59
	 */
60
	protected IResource getResource(Object element) {
61
		IResource resource = null;
62
		if (element instanceof IResource) {
63
			resource = (IResource) element;
64
		} else if (element instanceof IAdaptable) {
65
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
66
		}
67
		return resource;
68
	}
35
}
69
}
(-)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 112-121 Link Here
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$
114
	public static final String SELECT_RESOURCES_TO_SAVE_DIALOG = PREFIX + "select_resources_to_save_dialog"; //$NON-NLS-1$
115
	public static final String SELECT_RESOURCES_TO_SAVE_DIALOG = PREFIX + "select_resources_to_save_dialog"; //$NON-NLS-1$
116
	public static final String SELECT_LAUNCH_METHOD_DIALOG = PREFIX + "select_launch_method_dialog"; //$NON-NLS-1$
115
	
117
	
116
	// Property pages
118
	// Property pages
117
	public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
119
	public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
118
	public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
120
	public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
121
	public static final String DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE = PREFIX + "default_launchconfiguration_property_page"; //$NON-NLS-1$
119
	
122
	
120
	// Launch configuration dialog pages
123
	// Launch configuration dialog pages
121
	public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$
124
	public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$
Lines 132-140 Link Here
132
	
135
	
133
	//Editor	
136
	//Editor	
134
	public static final String NO_SOURCE_EDITOR = PREFIX + "debugger_editor_no_source_common";//$NON-NLS-1$
137
	public static final String NO_SOURCE_EDITOR = PREFIX + "debugger_editor_no_source_common";//$NON-NLS-1$
135
136
137
    
138
	
139
}
138
}
140
139
(-)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 (-8 / +127 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 382-393 Link Here
382
               menubarPath="org.eclipse.ui.run/runGroup">
391
               menubarPath="org.eclipse.ui.run/runGroup">
383
         </action>
392
         </action>
384
         <action
393
         <action
385
               label="%RunWithConfigurationAction.label"
386
               style="pulldown"
387
               helpContextId="run_with_configuration_action_context"
388
               class="org.eclipse.debug.internal.ui.actions.RunAsAction"
394
               class="org.eclipse.debug.internal.ui.actions.RunAsAction"
395
               helpContextId="run_with_configuration_action_context"
396
               id="org.eclipse.debug.internal.ui.actions.RunWithConfigurationAction"
397
               label="%RunWithConfigurationAction.label"
389
               menubarPath="org.eclipse.ui.run/runGroup"
398
               menubarPath="org.eclipse.ui.run/runGroup"
390
               id="org.eclipse.debug.internal.ui.actions.RunWithConfigurationAction">
399
               style="pulldown">
391
         </action>
400
         </action>
392
         <action
401
         <action
393
               label="%RunHistoryMenuAction.label"
402
               label="%RunHistoryMenuAction.label"
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
949
                  property="org.eclipse.debug.ui.resource"
950
                  />
951
          	<test
952
                 property="org.eclipse.debug.ui.contextlaunch"
953
                 />
954
          	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
955
          </and>
956
         </enablement>
957
       </objectContribution>
958
       <objectContribution
959
             id="org.eclipse.debug.ui.contextlaunch.profileas"
960
             objectClass="org.eclipse.core.runtime.IAdaptable">
961
          <action
962
                class="org.eclipse.debug.internal.ui.contextlaunching.ProfileContextLaunchingAction"
963
                enablesFor="1"
964
                icon="icons/full/etool16/profile_exc.gif"
965
                id="org.eclipse.debug.ui.contextlaunch.profileas"
966
                label="%ContextLaunchingProfileMenu.name"
967
                menubarPath="additions"
968
                tooltip="%ContextLaunchingProfileMenu.tooltip">
969
          </action>
970
          <enablement>
971
          <and>
972
            <test
973
                  property="org.eclipse.debug.ui.resource"
974
                  />
975
          	<test property="org.eclipse.debug.ui.contextlaunch" />
976
          	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
977
          </and>
978
         </enablement> 
979
       </objectContribution>
910
   <!-- console additions -->
980
   <!-- console additions -->
981
      <objectContribution
982
            id="org.eclipse.debug.ui.contextlaunch.runas"
983
            objectClass="org.eclipse.core.runtime.IAdaptable">
984
         <action
985
               class="org.eclipse.debug.internal.ui.contextlaunching.RunContextLaunchingAction"
986
               enablesFor="1"
987
               icon="icons/full/etool16/run_exc.gif"
988
               id="org.eclipse.debug.ui.contextlaunch.runas"
989
               label="%ContextLaunchingRunMenu.name"
990
               menubarPath="additions"
991
               tooltip="%ContextLaunchingRunMenu.tooltip">
992
         </action>
993
         <enablement>
994
          <and>
995
          	<test property="org.eclipse.debug.ui.contextlaunch" />
996
          	<test
997
                 property="org.eclipse.debug.ui.resource"
998
                 />
999
          	<test property="org.eclipse.debug.ui.launchable" value="run"/>
1000
          </and>
1001
         </enablement> 
1002
      </objectContribution>
911
      <viewerContribution
1003
      <viewerContribution
912
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
1004
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
913
             id="org.eclipse.debug.ui.processConsoleContextMenu">
1005
             id="org.eclipse.debug.ui.processConsoleContextMenu">
Lines 1394-1399 Link Here
1394
            </or>
1486
            </or>
1395
         </enabledWhen>
1487
         </enabledWhen>
1396
      </page>
1488
      </page>
1489
      <page
1490
            class="org.eclipse.debug.internal.ui.preferences.RunDebugPropertiesPage"
1491
            id="org.eclipse.debug.ui.properties.defaultLaunchConfigurations"
1492
            name="%DefaultLaunchConfigurationsPropPage.name"
1493
            >
1494
         <enabledWhen>
1495
            <and>
1496
               <adapt
1497
                     type="org.eclipse.core.resources.IResource">
1498
               </adapt>
1499
               <test
1500
                     property="org.eclipse.debug.ui.contextlaunch"
1501
                     />
1502
               <test
1503
                     property="org.eclipse.debug.ui.contextlaunchable"
1504
                     >
1505
               </test>
1506
               <test
1507
                     property="org.eclipse.debug.ui.resource">
1508
               </test>
1509
            </and>
1510
         </enabledWhen>
1511
      </page>
1397
   </extension>
1512
   </extension>
1398
<!-- commands and their bindings
1513
<!-- commands and their bindings
1399
NOTE: 
1514
NOTE: 
Lines 2032-2038 Link Here
2032
      </propertyTester>
2147
      </propertyTester>
2033
	  <propertyTester
2148
	  <propertyTester
2034
			namespace="org.eclipse.debug.ui"
2149
			namespace="org.eclipse.debug.ui"
2035
			properties="launchable"
2150
			properties="launchable, resource, contextlaunch, contextlaunchable"
2036
			type="java.lang.Object"
2151
			type="java.lang.Object"
2037
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2152
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2038
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
2153
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
Lines 2235-2240 Link Here
2235
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2350
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2236
             label="%preferenceKeywords.launchDelegates">
2351
             label="%preferenceKeywords.launchDelegates">
2237
       </keyword>
2352
       </keyword>
2353
       <keyword
2354
             id="org.eclipse.debug.ui.contextLaunching"
2355
             label="%preferenceKeywords.contextLaunching">
2356
       </keyword>
2238
    </extension>
2357
    </extension>
2239
    <extension
2358
    <extension
2240
          point="org.eclipse.ui.importWizards">
2359
          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=Run/Debug Settings
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/ui/actions/LaunchShortcutsAction.java (-80 / +114 lines)
Lines 25-47 Link Here
25
import org.eclipse.debug.core.ILaunchConfigurationType;
25
import org.eclipse.debug.core.ILaunchConfigurationType;
26
import org.eclipse.debug.core.ILaunchMode;
26
import org.eclipse.debug.core.ILaunchMode;
27
import org.eclipse.debug.internal.ui.DebugUIPlugin;
27
import org.eclipse.debug.internal.ui.DebugUIPlugin;
28
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
28
import org.eclipse.debug.internal.ui.actions.ActionMessages;
29
import org.eclipse.debug.internal.ui.actions.ActionMessages;
29
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
30
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
30
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
31
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
32
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager;
31
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
33
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
32
import org.eclipse.debug.ui.ILaunchGroup;
34
import org.eclipse.debug.ui.ILaunchGroup;
33
import org.eclipse.jface.action.Action;
35
import org.eclipse.jface.action.Action;
34
import org.eclipse.jface.action.ActionContributionItem;
36
import org.eclipse.jface.action.ActionContributionItem;
35
import org.eclipse.jface.action.IAction;
37
import org.eclipse.jface.action.IAction;
36
import org.eclipse.jface.action.IMenuCreator;
38
import org.eclipse.jface.action.IMenuCreator;
39
import org.eclipse.jface.util.IPropertyChangeListener;
40
import org.eclipse.jface.util.PropertyChangeEvent;
37
import org.eclipse.jface.viewers.ISelection;
41
import org.eclipse.jface.viewers.ISelection;
38
import org.eclipse.jface.viewers.ISelectionProvider;
42
import org.eclipse.jface.viewers.ISelectionProvider;
39
import org.eclipse.jface.viewers.IStructuredSelection;
43
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.swt.events.MenuAdapter;
44
import org.eclipse.swt.events.MenuAdapter;
41
import org.eclipse.swt.events.MenuEvent;
45
import org.eclipse.swt.events.MenuEvent;
42
import org.eclipse.swt.widgets.Control;
46
import org.eclipse.swt.widgets.Control;
47
import org.eclipse.swt.widgets.Event;
43
import org.eclipse.swt.widgets.Menu;
48
import org.eclipse.swt.widgets.Menu;
44
import org.eclipse.swt.widgets.MenuItem;
49
import org.eclipse.swt.widgets.MenuItem;
50
import org.eclipse.ui.IActionDelegate2;
45
import org.eclipse.ui.IEditorPart;
51
import org.eclipse.ui.IEditorPart;
46
import org.eclipse.ui.IWorkbenchPage;
52
import org.eclipse.ui.IWorkbenchPage;
47
import org.eclipse.ui.IWorkbenchPart;
53
import org.eclipse.ui.IWorkbenchPart;
Lines 61-67 Link Here
61
 * </p>
67
 * </p>
62
 * @since 3.1
68
 * @since 3.1
63
 */
69
 */
64
public class LaunchShortcutsAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
70
public class LaunchShortcutsAction extends Action implements IMenuCreator, IActionDelegate2, IWorkbenchWindowPulldownDelegate2, IPropertyChangeListener {
65
	
71
	
66
	/**
72
	/**
67
	 * Cascading menu 
73
	 * Cascading menu 
Lines 74-82 Link Here
74
	private ILaunchGroup fGroup;
80
	private ILaunchGroup fGroup;
75
	
81
	
76
	/**
82
	/**
77
	 * Whether this actions enablement has been initialized
83
	 * Stores the proxy action to this delegate, if one exists.
78
	 */
84
	 */
79
	private boolean fInitialized = false;
85
	private IAction fAction;
80
		
86
		
81
	/**
87
	/**
82
	 * Creates a cascading menu action to populate with shortcuts in the given
88
	 * Creates a cascading menu action to populate with shortcuts in the given
Lines 85-121 Link Here
85
	 * @param launchGroupIdentifier launch group identifier
91
	 * @param launchGroupIdentifier launch group identifier
86
	 */
92
	 */
87
	public LaunchShortcutsAction(String launchGroupIdentifier) {
93
	public LaunchShortcutsAction(String launchGroupIdentifier) {
88
		super();
94
		DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
89
		fGroup = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(launchGroupIdentifier);
95
		fGroup = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(launchGroupIdentifier);
90
		ILaunchMode mode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fGroup.getMode());
91
		setText(mode.getLaunchAsLabel()); 
92
		setMenuCreator(this);
93
		setEnabled(existsConfigTypesForMode());
94
	}
96
	}
95
	
97
	
96
	/**
98
	/* (non-Javadoc)
97
	 * Returns the launch group associated with this action.
99
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
98
	 * 
99
	 * @return the launch group associated with this action
100
	 */
100
	 */
101
	private ILaunchGroup getLaunchGroup() {
101
	public void runWithEvent(IAction action, Event event) {
102
		return fGroup;
102
		run();
103
	}
103
	}
104
104
	
105
	/**
105
	/* (non-Javadoc)
106
	 * @see IAction#run()
106
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
107
	 */
107
	 */
108
	public void run() {
108
	public void run(IAction action) {
109
		//do nothing, this action just creates a cascading menu.
109
		run();
110
	}
110
	}
111
	
111
	
112
	/**
112
	/**
113
	 * @see IMenuCreator#dispose()
113
	 * @see IMenuCreator#dispose()
114
	 */
114
	 */
115
	public void dispose() {
115
	public void dispose() {
116
		if (getCreatedMenu() != null) {
116
		if (fCreatedMenu != null) {
117
			getCreatedMenu().dispose();
117
			fCreatedMenu.dispose();
118
		}
118
		}
119
		DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
119
	}
120
	}
120
	
121
	
121
	/**
122
	/**
Lines 129-146 Link Here
129
	 * @see IMenuCreator#getMenu(Menu)
130
	 * @see IMenuCreator#getMenu(Menu)
130
	 */
131
	 */
131
	public Menu getMenu(Menu parent) {
132
	public Menu getMenu(Menu parent) {
132
		if (getCreatedMenu() != null) {
133
		if (fCreatedMenu != null) {
133
			 getCreatedMenu().dispose();
134
			fCreatedMenu.dispose();
134
		 }
135
		 }
135
		setCreatedMenu(new Menu(parent));
136
		fCreatedMenu = new Menu(parent);
136
		initMenu();
137
		initMenu();
137
		return getCreatedMenu();
138
		return fCreatedMenu;
138
	}
139
	}
139
	
140
	
140
	/**
141
	/**
142
	 * Returns an Evaluation context with default variable = selection
141
	 * @return an Evaluation context with default variable = selection
143
	 * @return an Evaluation context with default variable = selection
142
	 */
144
	 */
143
	private IEvaluationContext createContext() {
145
	protected IEvaluationContext createContext() {
144
	    List list = null;
146
	    List list = null;
145
		IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
147
		IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
146
		if (window != null) {
148
		if (window != null) {
Lines 176-187 Link Here
176
		return context;
178
		return context;
177
	}	
179
	}	
178
	
180
	
179
	private void fillMenu() {
181
	/**
182
	 * Fills the flyout menu of the action
183
	 */
184
	protected void fillMenu() {
180
		IEvaluationContext context = createContext();
185
		IEvaluationContext context = createContext();
181
		// gather all shortcuts and run their filters so that we only run the
186
		//Running filters can be expensive. Also, only *LOADED* plug-ins get their filters run.
182
		// filters one time for each shortcut. Running filters can be expensive.
187
		List allShortCuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts(fGroup.getCategory());
183
		// Also, only *LOADED* plug-ins get their filters run.
184
		List /* <LaunchShortcutExtension> */ allShortCuts = getLaunchConfigurationManager().getLaunchShortcuts(getLaunchGroup().getCategory());
185
		Iterator iter = allShortCuts.iterator();
188
		Iterator iter = allShortCuts.iterator();
186
		List filteredShortCuts = new ArrayList(10);
189
		List filteredShortCuts = new ArrayList(10);
187
		while (iter.hasNext()) {
190
		while (iter.hasNext()) {
Lines 218-225 Link Here
218
	
221
	
219
	/**
222
	/**
220
	 * Add the shortcut to the context menu's launch sub-menu.
223
	 * Add the shortcut to the context menu's launch sub-menu.
224
	 * @param mode
225
	 * @param ext
226
	 * @param menu
227
	 * @param accelerator
221
	 */
228
	 */
222
	private void populateMenuItem(String mode, LaunchShortcutExtension ext, Menu menu, int accelerator) {
229
	protected void populateMenuItem(String mode, LaunchShortcutExtension ext, Menu menu, int accelerator) {
223
		LaunchShortcutAction action = new LaunchShortcutAction(mode, ext);
230
		LaunchShortcutAction action = new LaunchShortcutAction(mode, ext);
224
		action.setActionDefinitionId(ext.getId() + "." + mode); //$NON-NLS-1$
231
		action.setActionDefinitionId(ext.getId() + "." + mode); //$NON-NLS-1$
225
		String helpContextId = ext.getHelpContextId();
232
		String helpContextId = ext.getHelpContextId();
Lines 237-253 Link Here
237
		// replace default action label with context label if specified.
244
		// replace default action label with context label if specified.
238
		label.append((contextLabel != null) ? contextLabel : action.getText());
245
		label.append((contextLabel != null) ? contextLabel : action.getText());
239
		action.setText(label.toString());
246
		action.setText(label.toString());
240
		ActionContributionItem item= new ActionContributionItem(action);
247
		ActionContributionItem item = new ActionContributionItem(action);
241
		item.fill(menu, -1);
248
		item.fill(menu, -1);
242
	}
249
	}
243
	
250
	
244
	/**
251
	/**
252
	 * Updates the state of the action i.e. text, image, etc
253
	 * @since 3.3
254
	 */
255
	protected void updateActionState() {
256
		ILaunchMode mode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(getMode());
257
		if(fAction != null) {
258
			//update the backing action, action delegate
259
			if(ContextRunner.isContextLaunchEnabled()) {
260
				fAction.setText(LaunchConfigurationPresentationManager.getDefault().getLaunchModeLabel(getMode()));
261
				fAction.setImageDescriptor(fGroup.getImageDescriptor());
262
				fAction.setMenuCreator(null);
263
			}
264
			else {
265
				fAction.setText(mode.getLaunchAsLabel());
266
				fAction.setImageDescriptor(null);
267
				fAction.setMenuCreator(this);
268
			}
269
			fAction.setEnabled(existsConfigTypesForMode());
270
		}
271
		else {
272
			//update this, could be a toolbar action
273
			if(ContextRunner.isContextLaunchEnabled()) {
274
				setText(LaunchConfigurationPresentationManager.getDefault().getLaunchModeLabel(getMode()));
275
				setImageDescriptor(fGroup.getImageDescriptor());
276
				setMenuCreator(null);
277
			}
278
			else {
279
				setText(mode.getLaunchAsLabel());
280
				setImageDescriptor(null);
281
				setMenuCreator(this);
282
			}
283
			setEnabled(existsConfigTypesForMode());
284
		}
285
	}
286
	
287
	/**
245
	 * Evaluate the enablement logic in the contextualLaunch
288
	 * Evaluate the enablement logic in the contextualLaunch
246
	 * element description. A true result means that we should
289
	 * element description. A true result means that we should
247
	 * include this shortcut in the context menu.
290
	 * include this shortcut in the context menu.
291
	 * @param ext
292
	 * @param context
248
	 * @return true iff shortcut should appear in context menu
293
	 * @return true iff shortcut should appear in context menu
294
	 * @throws CoreException
249
	 */
295
	 */
250
	private boolean isApplicable(LaunchShortcutExtension ext, IEvaluationContext context) throws CoreException {
296
	protected boolean isApplicable(LaunchShortcutExtension ext, IEvaluationContext context) throws CoreException {
251
		Expression expr = ext.getContextualLaunchEnablementExpression();
297
		Expression expr = ext.getContextualLaunchEnablementExpression();
252
		return ext.evalEnablementExpression(context, expr);
298
		return ext.evalEnablementExpression(context, expr);
253
	}
299
	}
Lines 255-263 Link Here
255
	/**
301
	/**
256
	 * Creates the menu for the action
302
	 * Creates the menu for the action
257
	 */
303
	 */
258
	private void initMenu() {
304
	protected void initMenu() {
259
		// Add listener to re-populate the menu each time
305
		// Add listener to re-populate the menu each time it is shown to reflect changes in selection or active perspective
260
		// it is shown to reflect changes in selection or active perspective
261
		fCreatedMenu.addMenuListener(new MenuAdapter() {
306
		fCreatedMenu.addMenuListener(new MenuAdapter() {
262
			public void menuShown(MenuEvent e) {
307
			public void menuShown(MenuEvent e) {
263
				Menu m = (Menu)e.widget;
308
				Menu m = (Menu)e.widget;
Lines 269-324 Link Here
269
			}
314
			}
270
		});
315
		});
271
	}
316
	}
272
		
273
	/**
274
	 * Returns the mode of this action - run or debug 
275
	 * 
276
	 * @return the mode of this action - run or debug
277
	 */
278
	private String getMode() {
279
		return getLaunchGroup().getMode();
280
	}
281
	
282
	private Menu getCreatedMenu() {
283
		return fCreatedMenu;
284
	}
285
	
286
	private void setCreatedMenu(Menu createdMenu) {
287
		fCreatedMenu = createdMenu;
288
	}
289
	
317
	
290
	/**
318
	/* (non-Javadoc)
291
	 * Returns the launch configuration manager.
319
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
292
	 *
293
	 * @return launch configuration manager
294
	 */
320
	 */
295
	private LaunchConfigurationManager getLaunchConfigurationManager() {
321
	public void init(IAction action) {
296
		return DebugUIPlugin.getDefault().getLaunchConfigurationManager();
322
		fAction = action;
297
	}	
323
		updateActionState();
324
	}
298
	
325
	
299
	/**
326
	/* (non-Javadoc)
300
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
327
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
301
	 */
328
	 */
302
	public void init(IWorkbenchWindow window) {
329
	public void init(IWorkbenchWindow window) {}
303
	}
304
305
	/**
306
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
307
	 */
308
	public void run(IAction action) {
309
		// do nothing - this is just a menu
310
	}
311
330
312
	/**
331
	/**
313
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
332
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
314
	 */
333
	 */
315
	public void selectionChanged(IAction action, ISelection selection) {
334
	public void selectionChanged(IAction action, ISelection selection) {}
316
	    if (!fInitialized) {
335
	
317
	        action.setEnabled(existsConfigTypesForMode());
318
	        fInitialized = true;
319
	    }
320
	}
321
322
	/**
336
	/**
323
	 * Return whether there are any registered launch configuration types for
337
	 * Return whether there are any registered launch configuration types for
324
	 * the mode of this action.
338
	 * the mode of this action.
Lines 326-332 Link Here
326
	 * @return whether there are any registered launch configuration types for
340
	 * @return whether there are any registered launch configuration types for
327
	 * the mode of this action
341
	 * the mode of this action
328
	 */
342
	 */
329
	private boolean existsConfigTypesForMode() {
343
	protected boolean existsConfigTypesForMode() {
330
		ILaunchConfigurationType[] configTypes = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
344
		ILaunchConfigurationType[] configTypes = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
331
		for (int i = 0; i < configTypes.length; i++) {
345
		for (int i = 0; i < configTypes.length; i++) {
332
			ILaunchConfigurationType configType = configTypes[i];
346
			ILaunchConfigurationType configType = configTypes[i];
Lines 336-340 Link Here
336
		}		
350
		}		
337
		return false;
351
		return false;
338
	}
352
	}
353
354
	/* (non-Javadoc)
355
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
356
	 */
357
	public void propertyChange(PropertyChangeEvent event) {
358
		if(event.getProperty().equals(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)) {
359
			updateActionState();
360
		}
361
	}
362
	
363
	/**
364
	 * Returns the mode of the associated launch group
365
	 * @return the mode of the associated launch group
366
	 */
367
	protected String getMode() {
368
		if(fGroup != null) {
369
			return fGroup.getMode();
370
		}
371
		return null;
372
	}
339
}
373
}
340
374
(-)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().launch(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 (-36 / +85 lines)
Lines 16-34 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;
21
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
19
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
23
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
21
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.jface.action.Action;
25
import org.eclipse.jface.action.Action;
23
import org.eclipse.jface.action.IAction;
26
import org.eclipse.jface.action.IAction;
27
import org.eclipse.jface.util.IPropertyChangeListener;
28
import org.eclipse.jface.util.PropertyChangeEvent;
24
import org.eclipse.jface.viewers.ISelection;
29
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.IStructuredSelection;
30
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.StructuredSelection;
31
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.jface.window.Window;
32
import org.eclipse.jface.window.Window;
33
import org.eclipse.swt.widgets.Event;
34
import org.eclipse.ui.IActionDelegate2;
28
import org.eclipse.ui.IWorkbenchWindow;
35
import org.eclipse.ui.IWorkbenchWindow;
29
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
36
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
30
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
31
38
39
import com.ibm.icu.text.MessageFormat;
40
32
/**
41
/**
33
 * Opens the launch configuration dialog in the context of a launch group.
42
 * Opens the launch configuration dialog in the context of a launch group.
34
 * <p>
43
 * <p>
Lines 37-43 Link Here
37
 * </p>
46
 * </p>
38
 * @since 2.1
47
 * @since 2.1
39
 */
48
 */
40
public class OpenLaunchDialogAction extends Action implements IWorkbenchWindowActionDelegate {
49
public class OpenLaunchDialogAction extends Action implements IPropertyChangeListener, IActionDelegate2, IWorkbenchWindowActionDelegate {
41
50
42
	/**
51
	/**
43
	 * Launch group identifier
52
	 * Launch group identifier
Lines 45-53 Link Here
45
	private String fIdentifier;
54
	private String fIdentifier;
46
	
55
	
47
	/**
56
	/**
48
	 * The action used to render this delegate.
57
	 * The underlying <code>IAction</code> for this delegate
49
	 */
58
	 */
50
	private IAction fAction;	
59
	private IAction fBackingAction = null;
51
	
60
	
52
	/**
61
	/**
53
	 * Constructs an action that opens the launch configuration dialog in
62
	 * Constructs an action that opens the launch configuration dialog in
Lines 57-70 Link Here
57
	 */
66
	 */
58
	public OpenLaunchDialogAction(String identifier) {
67
	public OpenLaunchDialogAction(String identifier) {
59
		fIdentifier = identifier;
68
		fIdentifier = identifier;
60
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
69
		updateActionState();
61
		if (extension != null) {
62
			setText(extension.getLabel() + "..."); //$NON-NLS-1$
63
			setImageDescriptor(extension.getImageDescriptor());
64
		}
65
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
66
	}
70
	}
67
71
	
68
	/**
72
	/**
69
	 * @see org.eclipse.jface.action.IAction#run()
73
	 * @see org.eclipse.jface.action.IAction#run()
70
	 */
74
	 */
Lines 80-123 Link Here
80
		int result = DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
84
		int result = DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
81
		notifyResult(result == Window.OK);
85
		notifyResult(result == Window.OK);
82
	}
86
	}
83
	/**
87
	
84
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
88
	/* (non-Javadoc)
85
	 */
89
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
86
	public void dispose() {
87
	}
88
89
	/**
90
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
91
	 */
90
	 */
92
	public void init(IWorkbenchWindow window) {
91
	public void runWithEvent(IAction action, Event event) {
92
		run();
93
	}
93
	}
94
94
	
95
	/**
95
	/* (non-Javadoc)
96
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
96
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
97
	 */
97
	 */
98
	public void run(IAction action) {
98
	public void run(IAction action) {
99
		run();
99
		run();
100
	}
100
	}
101
101
	
102
	/**
102
	/**
103
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
103
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
104
	 */
105
	public void dispose() {
106
		DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
107
	}
108
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
104
	 */
111
	 */
105
	public void selectionChanged(IAction action, ISelection selection) {
112
	public void init(IAction action) {
106
		if (fAction == null) {
113
		fBackingAction = action;
107
			initialize(action);
114
		DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
108
		} 		
115
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
116
		updateActionState();
109
	}
117
	}
110
	
118
	
111
	/**
119
	/**
112
	 * Set the enabled state of the underlying action based on whether there are any
120
	 * Updates the action state (label and image descriptor)
113
	 * registered launch configuration types that understand how to launch in the
121
	 * @since 3.3
114
	 * mode of this action.
122
	 * CONTEXTLAUNCHING
115
	 */
123
	 */
116
	private void initialize(IAction action) {
124
	protected void updateActionState() {
117
		fAction = action;
125
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(fIdentifier);
118
		action.setEnabled(existsConfigTypesForMode());	
126
		if(fBackingAction != null) {
119
	}	
127
			if(ContextRunner.isContextLaunchEnabled() && !"org.eclipse.ui.externaltools.launchGroup".equals(fIdentifier)) { //$NON-NLS-1$
120
128
				fBackingAction.setText(MessageFormat.format(ContextMessages.OpenLaunchDialogAction_0, new String[] {extension.getLabel()}));
129
				fBackingAction.setImageDescriptor(null);
130
			}
131
			else {
132
				fBackingAction.setText(extension.getLabel() + "..."); //$NON-NLS-1$
133
				fBackingAction.setImageDescriptor(extension.getImageDescriptor());
134
			}
135
			fBackingAction.setEnabled(existsConfigTypesForMode());
136
		}
137
		else {
138
			//there is no backing action, like a toolbar action delegate
139
			if(ContextRunner.isContextLaunchEnabled() && !"org.eclipse.ui.externaltools.launchGroup".equals(fIdentifier)) { //$NON-NLS-1$
140
				setText(MessageFormat.format(ContextMessages.OpenLaunchDialogAction_0, new String[] {extension.getLabel()}));
141
				setImageDescriptor(null);
142
			}
143
			else {
144
				setText(extension.getLabel() + "..."); //$NON-NLS-1$
145
				setImageDescriptor(extension.getImageDescriptor());
146
			}
147
			setEnabled(existsConfigTypesForMode());
148
		}
149
	}
150
	
121
	/**
151
	/**
122
	 * Return whether there are any registered launch configuration types for
152
	 * Return whether there are any registered launch configuration types for
123
	 * the mode of this action.
153
	 * the mode of this action.
Lines 136-141 Link Here
136
		return false;
166
		return false;
137
	}
167
	}
138
	
168
	
169
	/* (non-Javadoc)
170
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
171
	 */
172
	public void init(IWorkbenchWindow window) {}
173
	
174
	/* (non-Javadoc)
175
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
176
	 */
177
	public void propertyChange(PropertyChangeEvent event) {
178
		if (IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH.equals(event.getProperty())){
179
			updateActionState();
180
		}
181
	}
182
	
183
	/**
184
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
185
	 */
186
	public void selectionChanged(IAction action, ISelection selection) {}
187
	
139
	/**
188
	/**
140
	 * Returns the launch mode for this action.
189
	 * Returns the launch mode for this action.
141
	 * 
190
	 * 
(-)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/launchConfigurations/LaunchConfigurationsMessages.properties (+4 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 settings the default for [{0}]
108
LaunchShortcutSelectionDialog_3=Ma&ke generated settings the default for project [{0}]
105
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
109
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
106
110
107
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
111
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java (+8 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;
115
116
	public static String LaunchShortcutSelectionDialog_3;
109
	public static String PerspectiveManager_Error_1;
117
	public static String PerspectiveManager_Error_1;
110
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
118
	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;
119
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-3 / +13 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 1111-1117 Link Here
1111
	/**
1121
	/**
1112
	 * Determines if the currently showing launch configuration has multiple launch delegates for the same mode set, but does not care
1122
	 * Determines if the currently showing launch configuration has multiple launch delegates for the same mode set, but does not care
1113
	 * if there has been a default selected yet or not
1123
	 * if there has been a default selected yet or not
1114
	 * @return true if the current launch configuraiton has multiple launch delegates, false otherwise
1124
	 * @return true if the current launch configuration has multiple launch delegates, false otherwise
1115
	 */
1125
	 */
1116
	private boolean hasMultipleDelegates() {
1126
	private boolean hasMultipleDelegates() {
1117
		ILaunchConfiguration config = getWorkingCopy();
1127
		ILaunchConfiguration config = getWorkingCopy();
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/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/ClosedProjectFilter.java (-1 / +1 lines)
Lines 55-61 Link Here
55
					}
55
					}
56
					for(int i = 0; i < resources.length; i++) {
56
					for(int i = 0; i < resources.length; i++) {
57
						IProject project= resources[i].getProject();
57
						IProject project= resources[i].getProject();
58
						//we don't want overlap with the deleted projects filter, so we need to allow projects taht don't exist through
58
						//we don't want overlap with the deleted projects filter, so we need to allow projects that don't exist through
59
						if(project != null && (project.isOpen() || !project.exists())) {
59
						if(project != null && (project.isOpen() || !project.exists())) {
60
							return true;
60
							return true;
61
						}
61
						}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java (-3 / +50 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 216-222 Link Here
216
	/**
219
	/**
217
	 * Returns a listing of <code>IlaunchDeleagtes</code> that does not contain any delegates from disabled activities
220
	 * Returns a listing of <code>IlaunchDeleagtes</code> that does not contain any delegates from disabled activities
218
	 * @param delegates the raw listing of delegates to filter
221
	 * @param delegates the raw listing of delegates to filter
219
	 * @return the filtered listing of <code>ILaunchDelegate</code>s or an empty array, nevere <code>null</code>.
222
	 * @return the filtered listing of <code>ILaunchDelegate</code>s or an empty array, never <code>null</code>.
220
	 * @since 3.3
223
	 * @since 3.3
221
	 * 
224
	 * 
222
	 * EXPERIMENTAL
225
	 * EXPERIMENTAL
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
	 * EXPERIMENTAL
609
	 * CONTEXTLAUNCHING
610
	 */
611
	public List getApplicableConfigurationTypes(IResource resource) {
612
		List types = new ArrayList();
613
		try {
614
			List exts = getLaunchShortcuts();
615
			LaunchShortcutExtension ext = null;
616
			List list = new ArrayList();
617
			list.add(resource);
618
			IEvaluationContext context = new EvaluationContext(null, list);
619
			context.addVariable("selection", list); //$NON-NLS-1$
620
			HashSet set = new HashSet();
621
			for(Iterator iter = exts.iterator(); iter.hasNext();) {
622
				ext = (LaunchShortcutExtension) iter.next();
623
				if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
624
					set.addAll(ext.getAssociatedConfigurationTypes());
625
				}
626
			}
627
			LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
628
			ILaunchConfigurationType type = null;
629
			for(Iterator iter = set.iterator(); iter.hasNext();) {
630
				type = lm.getLaunchConfigurationType((String)iter.next());
631
				if(type != null) { 
632
					if(!types.contains(type) && type.isPublic() && !"org.eclipse.ui.externaltools.builder".equals(type.getCategory())) { //$NON-NLS-1$
633
						types.add(type);
634
					}
635
				}
636
			}
637
		}
638
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
639
		return types;
640
	}
597
	
641
	
598
	/**
642
	/**
599
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
643
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
600
	 * launch configuration type id.
644
	 * launch configuration type id.
601
	 * @param typeid the id of the launch configuraiton
645
	 * @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
646
	 * @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>
647
	 * type id or an empty list, never <code>null</code>
604
	 * 
648
	 * 
Lines 695-700 Link Here
695
	 * @since 3.3
739
	 * @since 3.3
696
	 * 
740
	 * 
697
	 * EXPERIMENTAL
741
	 * EXPERIMENTAL
742
	 * CONTEXTLAUNCHING
698
	 */
743
	 */
699
	public LaunchShortcutExtension getLaunchShortcut(String id) {
744
	public LaunchShortcutExtension getLaunchShortcut(String id) {
700
		loadLaunchShortcuts();
745
		loadLaunchShortcuts();
Lines 800-805 Link Here
800
	 * @since 3.3
845
	 * @since 3.3
801
	 * 
846
	 * 
802
	 * EXPERIMENTAL
847
	 * EXPERIMENTAL
848
	 * CONTEXTLAUNCHING
803
	 */
849
	 */
804
	public void setDefaultLaunchShortcut(IResource resource, LaunchShortcutExtension shortcut) throws CoreException {
850
	public void setDefaultLaunchShortcut(IResource resource, LaunchShortcutExtension shortcut) throws CoreException {
805
		IProject project = resource.getProject();
851
		IProject project = resource.getProject();
Lines 826-837 Link Here
826
	 * 
872
	 * 
827
	 * @see {@link ILaunchManager#getDefaultConfiguration(IResource)}
873
	 * @see {@link ILaunchManager#getDefaultConfiguration(IResource)}
828
	 * @param resource the resource
874
	 * @param resource the resource
829
	 * @return the corresponding <code>LaunchShortcutExtension</code> for the guven <code>IResource</code>,
875
	 * @return the corresponding <code>LaunchShortcutExtension</code> for the given <code>IResource</code>,
830
	 * or <code>null</code> if there is not one.
876
	 * or <code>null</code> if there is not one.
831
	 * 
877
	 * 
832
	 * @since 3.3
878
	 * @since 3.3
833
	 * 
879
	 * 
834
	 * EXPERIMENTAL
880
	 * EXPERIMENTAL
881
	 * CONTEXTLAUNCHING
835
	 */
882
	 */
836
	public LaunchShortcutExtension getDefaultLaunchShortcut(IResource resource) {
883
	public LaunchShortcutExtension getDefaultLaunchShortcut(IResource resource) {
837
		IProject project = resource.getProject();
884
		IProject project = resource.getProject();
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java (+17 lines)
Lines 349-353 Link Here
349
		Collections.sort(names);
349
		Collections.sort(names);
350
		return names;
350
		return names;
351
	}
351
	}
352
	
353
	/**
354
	 * Returns the label of the mode id with all accelerators removed
355
	 * @param modeid the id of the mode i.e. 'run'
356
	 * @return the formatted label of the specified mode id with all accelerators removed, or <code>null</code> if no label is available
357
	 * @since 3.3
358
	 */
359
	public String getLaunchModeLabel(String modeid) {
360
		String mode = null;
361
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
362
		ILaunchMode lmode = manager.getLaunchMode(modeid);
363
		if(lmode != null) {
364
			return lmode.getLabel();
365
		}
366
		return mode;
367
	}
368
	
352
}
369
}
353
370
(-)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/internal/ui/contextlaunching/ContextRunner.java (+365 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.IFile;
10
import org.eclipse.core.resources.IResource;
11
import org.eclipse.core.runtime.CoreException;
12
import org.eclipse.core.runtime.IAdaptable;
13
import org.eclipse.debug.core.DebugPlugin;
14
import org.eclipse.debug.core.ILaunch;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchListener;
17
import org.eclipse.debug.internal.core.LaunchManager;
18
import org.eclipse.debug.internal.ui.DebugUIPlugin;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
21
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutSelectionDialog;
22
import org.eclipse.debug.ui.DebugUITools;
23
import org.eclipse.debug.ui.IDebugUIConstants;
24
import org.eclipse.jface.text.ITextSelection;
25
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.ISelectionProvider;
27
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.jface.viewers.StructuredSelection;
29
import org.eclipse.jface.window.Window;
30
import org.eclipse.ui.IEditorPart;
31
import org.eclipse.ui.IFileEditorInput;
32
import org.eclipse.ui.IWorkbenchPage;
33
import org.eclipse.ui.IWorkbenchPart;
34
import org.eclipse.ui.IWorkbenchPartSite;
35
import org.eclipse.ui.IWorkbenchWindow;
36
37
/**
38
 * Static runner for context launching to provide the base capability of context 
39
 * launching to more than one form of action (drop down, toolbar, view, etc)
40
 * 
41
 * @see {@link ContextLaunchingAction}
42
 * @see {@link ContextLaunchingToolbarAction}
43
 * @see {@link ILaunchListener}
44
 * @see {@link org.eclipse.debug.core.ILaunchManager}
45
 * 
46
 *  @since 3.3
47
 *  EXPERIMENTAL
48
 *  CONTEXTLAUNCHING
49
 */
50
public class ContextRunner implements ILaunchListener {
51
	
52
	private static ContextRunner fgInstance = null;
53
	
54
	/**
55
	 * Returns the singleton instance of <code>ContextRunner</code>
56
	 * @return the singleton instance of <code>ContextRunner</code>
57
	 */
58
	public static ContextRunner getDefault() {
59
		if(fgInstance == null) {
60
			fgInstance = new ContextRunner();
61
		}
62
		return fgInstance;
63
	}
64
65
	/**
66
	 * The underlying resource that is derived from the object context of the 
67
	 * run(Object, String) method
68
	 */
69
	private IResource fBackingResource = null;
70
	private boolean fMakeResourceDefault = false;
71
	private boolean fMakeProjectDefault = false;
72
	
73
	/**
74
	 * Performs the context launching given the object context and the mode to launch in
75
	 * @param mode the mode to launch in
76
	 */
77
	public void launch(String mode) {
78
		try {
79
			Object context = getCurrentContext();
80
			boolean launched = false;
81
			ILaunchConfiguration config = isSharedConfig(context);
82
			if(config != null) { 
83
				DebugUITools.launch(config, mode);
84
				launched = true;
85
			}
86
			else {
87
				config = isSharedConfigEditorInput(context);
88
				if(config != null) {
89
					DebugUITools.launch(config, mode);
90
					launched = true;
91
				}
92
				else if(context instanceof IAdaptable) {
93
					IAdaptable adapt = (IAdaptable) context;
94
					//try to get the ILaunchConfiguration adapter first
95
					config = (ILaunchConfiguration) adapt.getAdapter(ILaunchConfiguration.class);
96
					if(config != null) {
97
						DebugUITools.launch(config, mode);
98
						launched = true;
99
					}
100
					else {
101
						//try to get the resource adapter from the context
102
						IResource resource = (IResource) adapt.getAdapter(IResource.class);
103
						if(resource != null) {
104
							fBackingResource = resource;
105
							config = getLaunchManager().getDefaultConfiguration(resource);
106
							if(config == null) {
107
								//ask the project
108
								config = getLaunchManager().getDefaultConfiguration(fBackingResource.getProject());
109
							}
110
							if(config != null) {
111
								if(config.exists()) {
112
									DebugUITools.launch(config, mode);
113
									launched = true;
114
								}
115
								else {
116
									getLaunchManager().setDefaultConfiguration(resource, null);
117
									selectAndLaunch(mode);
118
									launched = true;
119
								}
120
							}
121
							else {
122
								selectAndLaunch(mode);
123
								launched = true;
124
							}
125
						}
126
					}
127
				}
128
			}
129
			if(!launched) {
130
				DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP, null);
131
			}
132
		}
133
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
134
	}
135
	
136
	/**
137
	 * This method return if the editor input is from a shared java launch configuration file or not
138
	 * @param receiver the editor input to examine
139
	 * @return true if the editor input is from a shared launch configuration file, false otherwise.
140
	 */
141
	public ILaunchConfiguration isSharedConfigEditorInput(Object receiver) {
142
		if(receiver instanceof IFileEditorInput) {
143
			IFileEditorInput input = (IFileEditorInput) receiver;
144
			return isSharedConfig(input.getFile());
145
		}
146
		return null;
147
	}
148
	
149
	/**
150
	 * Returns the shared config from the selected resource or <code>null</code> if the selecetd resources is not a shared config
151
	 * @param receiver
152
	 * @return the shared config from the selected resource or <code>null</code> if the selecetd resources is not a shared config
153
	 */
154
	public ILaunchConfiguration isSharedConfig(Object receiver) {
155
		if(receiver instanceof IFile) {
156
			IFile file = (IFile) receiver;
157
			String ext = file.getFileExtension();
158
			if(ext == null) {
159
				return null;
160
			}
161
			if(ext.equals("launch")) { //$NON-NLS-1$
162
				ILaunchConfiguration config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(file);
163
				if(config != null && config.exists()) {
164
					return config;
165
				}
166
			}
167
		}
168
		return null;
169
	}
170
	
171
	/**
172
	 * Prompts the user to select a way of launching the current resource, where a 'way'
173
	 * is defined as a launch shortcut
174
	 * @param adapt the adaptable type the specified resource was derived from
175
	 * @param resource
176
	 * @return the 'way' to launch the selected resource
177
	 * @throws CoreException
178
	 */
179
	protected void selectAndLaunch(String mode) throws CoreException {
180
		IResource res = fBackingResource;
181
		if(getLaunchShortcuts(res).isEmpty()) {
182
			res = res.getProject();
183
			if(getLaunchShortcuts(res).isEmpty()) {
184
				//TODO prompt for what to do
185
				
186
			}
187
		}
188
		LaunchShortcutSelectionDialog dialog = new LaunchShortcutSelectionDialog(fBackingResource, mode);
189
		if (dialog.open() == Window.OK) {
190
			Object[] result = dialog.getResult();
191
			if(result.length > 0) {
192
				fMakeProjectDefault = dialog.makeProjectDefault();
193
				fMakeResourceDefault = dialog.makeDefault();
194
				if(fMakeProjectDefault || fMakeResourceDefault) {
195
					getLaunchManager().addLaunchListener(this);
196
				}
197
				LaunchShortcutExtension method = (LaunchShortcutExtension) result[0];
198
				if(method != null) {
199
					method.launch(new StructuredSelection(res), mode);
200
				}
201
			}
202
		}
203
	}
204
	
205
	/**
206
	 * Creates a listing of the launch shortcut extensions that are applicable to the underlying resource
207
	 * @param resource the underlying resource
208
	 * @return a listing of applicable launch shortcuts
209
	 * @throws CoreException
210
	 */
211
	public List getLaunchShortcuts(IResource resource) throws CoreException {
212
		List list = new ArrayList(); 
213
		List sc = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts();
214
		List ctxt = new ArrayList();
215
		ctxt.add(resource);
216
		IEvaluationContext context = new EvaluationContext(null, ctxt);
217
		context.addVariable("selection", ctxt); //$NON-NLS-1$
218
		LaunchShortcutExtension ext = null;
219
		for(Iterator iter = sc.iterator(); iter.hasNext();) {
220
			ext = (LaunchShortcutExtension) iter.next();
221
			if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
222
				if(!list.contains(ext)) {
223
					list.add(ext);
224
				}
225
			}
226
		}
227
		return list;
228
	}
229
	
230
	/**
231
	 * Returns the current context to be considered for launching. 
232
	 * The returned object will be one of:
233
	 * <ol>
234
	 * <li>{@link IEditorInput}</li>
235
	 * <li>{@link Object}, where <i>object</i> is the first element in the selection obtained from the 
236
	 * selection provider of the currently selected workbench part</li>
237
	 * </ol>
238
	 * @return the currently selected context to consider for launching, or <code>null</code>.
239
	 *
240
	 */
241
	public Object getCurrentContext() {
242
		IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
243
		if(window != null) {
244
			IWorkbenchPage page = window.getActivePage();
245
			if(page!= null) {
246
				IWorkbenchPart part = page.getActivePart();
247
				if(part != null) {
248
					if(part instanceof IEditorPart) {
249
						return ((IEditorPart)part).getEditorInput();
250
					}
251
					IWorkbenchPartSite site = part.getSite();
252
					if(site != null) {
253
						ISelectionProvider provider = site.getSelectionProvider();
254
						if(provider != null) {
255
							ISelection sel = provider.getSelection();
256
							if(sel instanceof IStructuredSelection) {
257
								StructuredSelection ss = (StructuredSelection) sel;
258
								if(ss.isEmpty()) {
259
									return part;
260
								}
261
								else {
262
									return ss.getFirstElement();
263
								}
264
							}
265
							else if(sel instanceof ITextSelection) {
266
								return part;
267
							}
268
							return sel;
269
						}
270
						else {
271
							//default to returning the part, which can be further queried for adapters
272
							return part;
273
						}
274
					}
275
				}
276
			}
277
			
278
		}
279
		return null;
280
	}
281
	
282
	/**
283
	 * Returns the name of the currently selected context, or the empty string.
284
	 * This method can return null in the event the contributor of the selected context returns <code>null</code>
285
	 * as the resource name.
286
	 * @return the name of the currently selected context or the empty string. 
287
	 */
288
	public String getContextName() {
289
		Object o = getCurrentContext();
290
		ILaunchConfiguration config = isSharedConfig(o);
291
		if(config != null) {
292
			return config.getName();
293
		}
294
		else {
295
			config = isSharedConfigEditorInput(o);
296
			if(config != null) {
297
				return config.getName();
298
			}
299
			else {
300
				if(o instanceof IAdaptable) {
301
					IAdaptable adapt = (IAdaptable) o;
302
					Object a = adapt.getAdapter(ILaunchConfiguration.class);
303
					if(a != null) {
304
						return ((ILaunchConfiguration) a).getName();
305
					}
306
					else {
307
						a = adapt.getAdapter(IResource.class);
308
						if(a != null) {
309
							IResource res = (IResource) a;
310
							return (res.isAccessible() ? res.getName() : ""); //$NON-NLS-1$
311
						}
312
					}
313
				}
314
			}
315
		}
316
		return ""; //$NON-NLS-1$
317
	}
318
	
319
	/**
320
	 * Returns if context launching is enabled
321
	 * @return if context launching is enabled
322
	 */
323
	public static boolean isContextLaunchEnabled() {
324
		return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
325
	}
326
	
327
	/**
328
	 * Returns the launch manager
329
	 * @return the launch manager
330
	 */
331
	protected LaunchManager getLaunchManager() {
332
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
333
	}
334
	
335
	/**
336
	 * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch)
337
	 */
338
	public void launchAdded(ILaunch launch) {
339
		if(fBackingResource != null) {
340
			try {
341
				if(fMakeResourceDefault) {
342
					getLaunchManager().setDefaultConfiguration(fBackingResource, launch.getLaunchConfiguration());
343
				}
344
				if(fMakeProjectDefault) {
345
					getLaunchManager().setDefaultConfiguration(fBackingResource.getProject(), launch.getLaunchConfiguration());
346
				}
347
				getLaunchManager().removeLaunchListener(this);
348
				fMakeProjectDefault = false;
349
				fMakeResourceDefault = false;
350
			}
351
			catch(CoreException ce) {DebugUIPlugin.log(ce);}
352
		}
353
	}
354
355
	/**
356
	 * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch)
357
	 */
358
	public void launchChanged(ILaunch launch) {}
359
360
	/**
361
	 * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
362
	 */
363
	public void launchRemoved(ILaunch launch) {}
364
	
365
}
(-)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/preferences/RunDebugPropertiesPage.java (+506 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
 * EXPERIMENTAL
71
 * CONTEXTLAUNCHING
72
 * 
73
 * @since 3.3
74
 */
75
public class RunDebugPropertiesPage extends PropertyPage {
76
	/**
77
	 * Set of configurations to be deleted
78
	 */
79
	private Set fDeletedConfigurations = new HashSet();
80
	
81
	/**
82
	 * Set of original default candidates for the resource
83
	 */
84
	private Set fOriginalCandidates;
85
	
86
	/**
87
	 * List of the applicable launch config types for the backing resource
88
	 */
89
	private List fTypeCandidates = null;
90
	
91
	//widgets
92
	private CheckboxTableViewer fViewer;
93
	private Button fNewButton = null;
94
	private Button fEditButton = null;
95
	private Button fDuplicateButton = null;
96
	private Button fDeleteButton = null;
97
	
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
100
	 */
101
	protected Control createContents(Composite parent) {
102
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE);
103
		collectConfigCandidates(getResource());
104
		Composite topComposite = SWTUtil.createComposite(parent, 2, 1, GridData.FILL_BOTH);
105
		
106
		SWTUtil.createWrapLabel(topComposite, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_0, 2, 300);
107
		SWTUtil.createVerticalSpacer(topComposite, 2);
108
		SWTUtil.createWrapLabel(topComposite, MessageFormat.format(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_1, new String[]{getResource().getName()}), 2, 300);
109
		fViewer = createViewer(topComposite);
110
		
111
		Composite buttonComp = SWTUtil.createComposite(topComposite, 1, 1, GridData.FILL_VERTICAL);
112
		GridLayout layout = (GridLayout) buttonComp.getLayout();
113
		layout.marginHeight = 0;
114
		fNewButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_2, null);
115
		fNewButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_3);
116
		fNewButton.addSelectionListener(new SelectionListener() {
117
			public void widgetDefaultSelected(SelectionEvent e) {}
118
			public void widgetSelected(SelectionEvent e) {
119
				handleNew();
120
			}
121
		});
122
		
123
		fDuplicateButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_4, null);
124
		fDuplicateButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_5);
125
		fDuplicateButton.setEnabled(false);
126
		fDuplicateButton.addSelectionListener(new SelectionListener() {
127
			public void widgetDefaultSelected(SelectionEvent e) {}
128
			public void widgetSelected(SelectionEvent e) {
129
				handleCopy();
130
			}
131
		});
132
		fEditButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_6, null);
133
		fEditButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_7);
134
		fEditButton.setEnabled(false);
135
		fEditButton.addSelectionListener(new SelectionListener() {
136
			public void widgetDefaultSelected(SelectionEvent e) {}
137
			public void widgetSelected(SelectionEvent e) {
138
				handleEdit();
139
			}
140
		});
141
		fDeleteButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_8, null);
142
		fDeleteButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_9);
143
		fDeleteButton.setEnabled(false);
144
		fDeleteButton.addSelectionListener(new SelectionListener() {
145
			public void widgetDefaultSelected(SelectionEvent e) {}
146
			public void widgetSelected(SelectionEvent e) {
147
				handleDelete();
148
			}
149
		});
150
		
151
		fViewer.setSelection(new StructuredSelection());
152
		applyDialogFont(topComposite);
153
		return topComposite;
154
	}
155
156
	/**
157
	 * Creates and returns the viewer that will display the possible default configurations.
158
	 * 
159
	 * @param parent parent composite to create the viewer in
160
	 * @return viewer viewer that will display possible default configurations
161
	 */
162
	protected CheckboxTableViewer createViewer(Composite parent){
163
		CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
164
		viewer.setLabelProvider(new DefaultLabelProvider());
165
		viewer.setContentProvider(new ArrayContentProvider());
166
		viewer.setComparator(new LaunchConfigurationComparator());
167
		viewer.addCheckStateListener(new ICheckStateListener() {
168
			public void checkStateChanged(CheckStateChangedEvent event) {
169
				if (event.getChecked()) {
170
					fViewer.setCheckedElements(new Object[] {event.getElement()});
171
				}
172
				else{
173
					fViewer.setCheckedElements(new Object[] {});
174
				}
175
			}
176
		});
177
		Table builderTable = viewer.getTable();
178
		GridData tableGridData = new GridData(GridData.FILL_BOTH);
179
		tableGridData.heightHint = 300;
180
		builderTable.setLayoutData(tableGridData);
181
		
182
		IResource resource = getResource();
183
		viewer.setInput(collectConfigCandidates(resource));
184
		try {
185
			ILaunchConfiguration configuration = getLaunchManager().getDefaultConfiguration(resource);
186
			if (configuration != null) {
187
				Iterator iterator = fOriginalCandidates.iterator();
188
				while (iterator.hasNext()) {
189
					ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
190
					if (configuration.equals(wc.getOriginal())) {
191
						viewer.setChecked(wc, true);
192
						break;
193
					}
194
				}
195
			}
196
		} catch (CoreException e) {setErrorMessage(e.getMessage());}
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
		return fTypeCandidates;
244
	}
245
	
246
	/**
247
	 * Returns a set of potential default configurations candidates for the given
248
	 * resource. The configurations are working copies.
249
	 *  
250
	 * @param resource resource
251
	 * @return list of default candidates
252
	 */
253
	protected Set collectConfigCandidates(IResource resource) {
254
		if(fOriginalCandidates == null) {
255
			fOriginalCandidates = new HashSet();
256
			IPath resourcePath = resource.getFullPath();
257
			try {
258
				List types = collectTypeCandidates();
259
				List configs = new ArrayList();
260
				ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations();
261
				for(int i = 0; i < configurations.length; i++) {
262
					if(types.contains(configurations[i].getType())) {
263
						if(configurations[i].isMigrationCandidate()) {
264
							configurations[i].migrate();
265
						}
266
						configs.add(configurations[i]);
267
					}
268
				}
269
				ILaunchConfiguration configuration = null;
270
				IResource[] resources = null;
271
				for (Iterator iter = configs.iterator(); iter.hasNext();) {
272
					configuration = (ILaunchConfiguration) iter.next();
273
					if(acceptConfiguration(configuration)) { 
274
						if(configuration.contentsEqual(getLaunchManager().getDefaultConfiguration(resource))) {
275
							fOriginalCandidates.add(configuration.getWorkingCopy());
276
						}
277
						else {
278
							resources = configuration.getMappedResources();
279
							if (resources != null) {
280
								for (int j = 0; j < resources.length; j++) {
281
									if (resource.equals(resources[j]) || resourcePath.isPrefixOf(resources[j].getFullPath())) {
282
										fOriginalCandidates.add(configuration.getWorkingCopy());
283
										break;
284
									}
285
								}
286
							}
287
							else {
288
								//in the event the config has no mapping
289
								fOriginalCandidates.add(configuration.getWorkingCopy());
290
							}
291
						}
292
					}
293
				}
294
			} catch (CoreException e) {
295
				fOriginalCandidates.clear();
296
				DebugPlugin.log(e);
297
			}
298
		}
299
		return fOriginalCandidates;
300
	}
301
	
302
	/**
303
	 * Returns if the specified configuration should be considered as a potential candidate
304
	 * @param config
305
	 * @return if the specified configuration should be considered as a potential candidate
306
	 * @throws CoreException
307
	 */
308
	private boolean acceptConfiguration(ILaunchConfiguration config) throws CoreException {
309
		if(config != null && !DebugUITools.isPrivate(config)) {
310
			if(!"org.eclipse.ui.externaltools".equals(config.getType().getCategory())) { //$NON-NLS-1$
311
				return true;
312
			}
313
			else {
314
				IResource[] res = config.getMappedResources();
315
				if(res != null) {
316
					return true;
317
				}
318
			}
319
		}
320
		return false;
321
	}
322
	
323
	/**
324
	 * Returns the resource this property page is open on.
325
	 * 
326
	 * @return resource
327
	 */
328
	protected IResource getResource() {
329
		Object element = getElement();
330
		IResource resource = null;
331
		if (element instanceof IResource) {
332
			resource = (IResource) element;
333
		} else if (element instanceof IAdaptable) {
334
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
335
		}
336
		return resource;
337
	}
338
339
	/* (non-Javadoc)
340
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
341
	 */
342
	public boolean performOk() {
343
		Object[] checked = fViewer.getCheckedElements();
344
		try {
345
			ILaunchConfiguration def = null;
346
			if (checked.length == 1) {
347
					def = (ILaunchConfiguration) checked[0];
348
					def = ((ILaunchConfigurationWorkingCopy)def).doSave();
349
			}
350
			DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
351
		} catch (CoreException e) {
352
			setErrorMessage(e.getMessage());
353
			return false;
354
		}
355
	//delete 
356
		Iterator iter = fDeletedConfigurations.iterator();
357
		while (iter.hasNext()) {
358
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
359
			try{			
360
				if (currentConfig.getOriginal() != null){
361
					currentConfig.getOriginal().delete();
362
				}
363
			} catch (CoreException e) {
364
				DebugPlugin.logMessage("Problem deleting configuration " + currentConfig.getName(), e); //$NON-NLS-1$
365
			}
366
		}
367
	//add
368
		iter = fOriginalCandidates.iterator();
369
		while (iter.hasNext()) {
370
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
371
			if (currentConfig.isDirty()){
372
				try{
373
					currentConfig.doSave();
374
				} catch (CoreException e) {
375
					DebugPlugin.logMessage("Problem saving changes to configuration " + currentConfig.getName(), e); //$NON-NLS-1$
376
				}
377
			}
378
		}
379
		
380
		return super.performOk();
381
	}
382
383
	/* (non-Javadoc)
384
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
385
	 */
386
	protected void performDefaults() {
387
		fViewer.setAllChecked(false);
388
		setErrorMessage(null);
389
		setValid(true);
390
		super.performDefaults();
391
	}
392
	
393
	/**
394
	 * Returns the names of the launch configurations passed in as original input to the tree viewer
395
	 * @return the names of the original launch configurations
396
	 */
397
	private Set getConfigurationNames() {
398
		Set names = new HashSet();
399
		Iterator iter = fOriginalCandidates.iterator();
400
		Object o = null;
401
		while (iter.hasNext()) {
402
			o = iter.next();
403
			if(o instanceof ILaunchConfiguration) {
404
				names.add(((ILaunchConfiguration)o).getName());
405
			}
406
		}
407
		return names;
408
	}
409
	
410
	/**
411
	 * Returns selected configurations.
412
	 * 
413
	 * @return selected configurations
414
	 */
415
	private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() {
416
		IStructuredSelection ss = (IStructuredSelection) fViewer.getSelection();
417
		return (ILaunchConfigurationWorkingCopy[]) ss.toList().toArray(new ILaunchConfigurationWorkingCopy[ss.size()]);
418
	}
419
420
	/**
421
	 * Copy the selection
422
	 */
423
	private void handleCopy() {
424
		ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0];
425
		try {
426
			ILaunchConfigurationWorkingCopy copy = configuration.copy(
427
					((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).generateUniqueLaunchConfigurationNameFrom(configuration.getName(), getConfigurationNames()));
428
			copy.setAttributes(configuration.getAttributes());
429
			fOriginalCandidates.add(copy);
430
			fViewer.refresh();
431
			fViewer.setSelection(new StructuredSelection(copy));
432
		} catch (CoreException e) {
433
			setErrorMessage(e.getMessage());
434
		}
435
	}
436
437
	/**
438
	 * Delete the selection
439
	 */
440
	private void handleDelete() {
441
		Table table = fViewer.getTable();
442
		int[] indices = table.getSelectionIndices();
443
		Arrays.sort(indices);
444
		ILaunchConfiguration[] configurations = getSelectedConfigurations();
445
		for (int i = 0; i < configurations.length; i++) {
446
			fDeletedConfigurations.add(configurations[i]);
447
			fOriginalCandidates.remove(configurations[i]);
448
		}
449
		fViewer.refresh();
450
		if (indices[0] < table.getItemCount()) {
451
			fViewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData()));
452
		} else if (table.getItemCount() > 0) {
453
			fViewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData()));
454
		}
455
	}
456
457
	/**
458
	 * Edit the selection
459
	 */
460
	private void handleEdit() {
461
		edit(getSelectedConfigurations()[0]);
462
		fViewer.refresh();
463
	}
464
465
	/**
466
	 * Edits the given configuration as a nested working copy.
467
	 * Returns the code from the dialog used to edit the configuration.
468
	 * 
469
	 * @param configuration
470
	 * @return dialog return code - OK or CANCEL
471
	 */
472
	private int edit(ILaunchConfigurationWorkingCopy configuration) {
473
		return DebugUIPlugin.openLaunchConfigurationPropertiesDialog(getShell(), configuration, IDebugUIConstants.ID_RUN_LAUNCH_GROUP, getConfigurationNames(), null);
474
	}
475
476
	/**
477
	 * Create a new configuration
478
	 */
479
	private void handleNew() {
480
		ListDialog dialog = new ListDialog(getShell());
481
		dialog.setTitle(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_11);
482
		dialog.setContentProvider(new ArrayContentProvider());
483
		dialog.setLabelProvider(new DefaultLabelProvider());
484
		dialog.setAddCancelButton(true);
485
		dialog.setMessage(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_12);
486
		dialog.setInput(collectTypeCandidates());
487
		if (dialog.open() == Window.OK) {
488
			Object[] result = dialog.getResult();
489
			if (result.length == 1) {
490
				ILaunchConfigurationType type = (ILaunchConfigurationType) result[0];
491
				try {
492
					ILaunchConfigurationWorkingCopy wc = type.newInstance(null, 
493
							((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).
494
							generateUniqueLaunchConfigurationNameFrom("New_configuration", getConfigurationNames())); //$NON-NLS-1$
495
					if (edit(wc) == Window.OK) {
496
						fOriginalCandidates.add(wc);
497
						fViewer.refresh();
498
						fViewer.setSelection(new StructuredSelection(wc));
499
					}
500
				} catch (CoreException e) {
501
					setErrorMessage(e.getMessage());
502
				}
503
			}
504
		}
505
	}	
506
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingAction.java (+76 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
 * CONTEXTLAUNCHING
32
 */
33
public class ContextLaunchingAction implements IActionDelegate2 {
34
35
	/**
36
	 * the mode the action is created on
37
	 */
38
	private String fMode = null;
39
	
40
	/**
41
	 * Constructor
42
	 * @param mode
43
	 */
44
	public ContextLaunchingAction(String mode) {
45
		fMode = mode;
46
	}
47
48
	/**
49
	 * @see org.eclipse.ui.IActionDelegate2#dispose()
50
	 */
51
	public void dispose() {}
52
53
	/**
54
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
55
	 */
56
	public void init(IAction action) {}
57
58
	/**
59
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
60
	 */
61
	public void runWithEvent(IAction action, Event event) {
62
		ContextRunner.getDefault().launch(fMode);
63
	}
64
	
65
	/**
66
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
67
	 */
68
	public void run(IAction action) {
69
		//not called
70
	}
71
72
	/**
73
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
74
	 */
75
	public void selectionChanged(IAction action, ISelection selection) {}
76
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingToolbarAction.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.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
 *  CONTEXTLAUNCHING
33
 */
34
public class ContextLaunchingToolbarAction extends Action implements IWorkbenchWindowActionDelegate {
35
36
	/**
37
	 * The mode this action applies to
38
	 */
39
	private String fMode = null;
40
	
41
	/**
42
	 * Constructor
43
	 * @param id
44
	 */
45
	public ContextLaunchingToolbarAction(String id) {
46
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(id);
47
		if (extension != null) {
48
			fMode = extension.getMode();
49
			setText(extension.getLabel());
50
			setImageDescriptor(extension.getImageDescriptor());
51
		}
52
	}
53
54
	/**
55
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
56
	 */
57
	public void dispose() {}
58
59
	/**
60
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
61
	 */
62
	public void init(IWorkbenchWindow window) {}
63
	
64
	/**
65
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
66
	 */
67
	public void selectionChanged(IAction action, ISelection selection) {}
68
69
	/**
70
	 * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
71
	 */
72
	public void runWithEvent(Event event) {
73
		ContextRunner.getDefault().launch(fMode);
74
	}
75
76
	/**
77
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
78
	 */
79
	public void run(IAction action) {
80
		//do nothing
81
	}
82
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ProfileContextLaunchingAction.java (+36 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
 * CONTEXTLAUNCHING
26
 */
27
public class ProfileContextLaunchingAction extends ContextLaunchingAction {
28
29
	/**
30
	 * Constructor
31
	 */
32
	public ProfileContextLaunchingAction() {
33
		super(ILaunchManager.PROFILE_MODE);
34
	}
35
36
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java (+156 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.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.DebugPlugin;
19
import org.eclipse.debug.core.ILaunchMode;
20
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
22
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
23
import org.eclipse.debug.internal.ui.SWTUtil;
24
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
25
import org.eclipse.debug.ui.IDebugUIConstants;
26
import org.eclipse.jface.dialogs.IDialogSettings;
27
import org.eclipse.jface.viewers.ArrayContentProvider;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.dialogs.ListDialog;
36
37
import com.ibm.icu.text.MessageFormat;
38
39
/**
40
 * Specialized dialog for showing/selecting a specific launch shortcut extension, and allowing it
41
 * to be marked to be set as the default
42
 * 
43
 * @see {@link org.eclipse.debug.internal.ui.actions.ContextLaunchingAction}
44
 * 
45
 * @since 3.3
46
 * EXPERIMENTAL
47
 * CONTEXTLAUNCHING
48
 */
49
public class LaunchShortcutSelectionDialog extends ListDialog {
50
51
	private static final String DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_SHORTCUT_DIALOG"; //$NON-NLS-1$;
52
	
53
	/**
54
	 * The list of input for the dialog
55
	 */
56
	private String fMode = null;
57
	private IResource fResource = null;
58
	private boolean fChecked = false;
59
	private boolean fProject = false;
60
	
61
	/**
62
	 * Constructor
63
	 * @param input
64
	 * @param resource
65
	 * @param mode
66
	 */
67
	public LaunchShortcutSelectionDialog(IResource resource, String mode) {
68
		super(DebugUIPlugin.getShell());
69
		setShellStyle(getShellStyle() | SWT.RESIZE);
70
		fResource = resource;
71
		fMode = mode;
72
		ILaunchMode lmode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fMode);
73
		String modename = fMode;
74
		if (lmode != null) {
75
			modename = DebugUIPlugin.removeAccelerators(lmode.getLabel());
76
		}
77
		setTitle(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_0, new String[] {modename}));
78
		setAddCancelButton(true);
79
		setMessage(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_1, new String[] {fMode, fResource.getName()}));
80
		setLabelProvider(new DefaultLabelProvider());
81
		setContentProvider(new ArrayContentProvider());
82
	}
83
84
	/**
85
	 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
86
	 */
87
	protected Control createContents(Composite parent) {
88
		Composite comp = (Composite) super.createContents(parent);
89
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_METHOD_DIALOG);
90
		return comp;
91
	}
92
93
	/**
94
	 * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
95
	 */
96
	protected IDialogSettings getDialogBoundsSettings() {
97
		IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
98
		IDialogSettings section = settings.getSection(DIALOG_SETTINGS);
99
		if (section == null) {
100
			section = settings.addNewSection(DIALOG_SETTINGS);
101
		} 
102
		return section;
103
	}
104
	
105
	/**
106
	 * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
107
	 */
108
	protected Control createDialogArea(Composite container) {
109
		Composite comp = (Composite) super.createDialogArea(container);
110
		try {
111
			List input = new ArrayList(ContextRunner.getDefault().getLaunchShortcuts(fResource));
112
			Button butt = null;
113
			if(!input.isEmpty()) {
114
				butt = SWTUtil.createCheckButton(comp, MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_2, new String[] {fResource.getName()}), null, fChecked);
115
				butt.addSelectionListener(new SelectionListener() {
116
					public void widgetDefaultSelected(SelectionEvent e) {}
117
					public void widgetSelected(SelectionEvent e) {
118
						fChecked = ((Button)e.getSource()).getSelection();
119
					}
120
				});
121
			}
122
			else {
123
				SWTUtil.createWrapLabel(comp, MessageFormat.format("Resource {0} cannot be launched, but you can choose a new way to run the associated project {1}.", new String[] {}), 1, 300);
124
				input = new ArrayList(ContextRunner.getDefault().getLaunchShortcuts(fResource.getProject()));
125
			}
126
			if(!input.isEmpty()) {
127
				butt = SWTUtil.createCheckButton(comp, MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_3, new String[] {fResource.getProject().getName()}), null, false);
128
				butt.addSelectionListener(new SelectionListener() {
129
					public void widgetDefaultSelected(SelectionEvent e) {}
130
					public void widgetSelected(SelectionEvent e) {
131
						fProject = ((Button)e.getSource()).getSelection();
132
					}
133
				});
134
			}
135
			getTableViewer().setInput(input);
136
		}
137
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
138
		return comp;
139
	}
140
 
141
	/**
142
	 * Returns if the launched config from the selected shortcut should be made the default for the underlying resource
143
	 * @return if the launched config should be made the default
144
	 */
145
	public boolean makeDefault() {
146
		return fChecked;
147
	}
148
	
149
	/**
150
	 * Returns if the launched config from the selected shortcut should be made the default for the enderlying resources' alssociated project
151
	 * @return if the launched config from the selected shortcut should be made the default for the enderlying resources' alssociated project
152
	 */
153
	public boolean makeProjectDefault() {
154
		return fProject;
155
	}
156
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/RunContextLaunchingAction.java (+36 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
 * CONTEXTLAUNCHING
26
 */
27
public class RunContextLaunchingAction extends ContextLaunchingAction {
28
29
	/**
30
	 * Constructor
31
	 */
32
	public RunContextLaunchingAction() {
33
		super(ILaunchManager.RUN_MODE);
34
	}
35
36
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java (+84 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
 * EXPERIMENTAL
32
 * CONTEXTLAUNCHING
33
 */
34
public class LaunchConfigurationComparator extends WorkbenchViewerComparator {
35
36
	/**
37
	 * the map of categories of <code>ILaunchConfigurationType</code>s to <code>Integer</code>s entries
38
	 */
39
	private static Map fgCategories;
40
	
41
	/**
42
	 * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
43
	 */
44
	public int category(Object element) {
45
		Map map = getCategories();
46
		if (element instanceof ILaunchConfiguration) {
47
			ILaunchConfiguration configuration = (ILaunchConfiguration) element;
48
			try {
49
				Integer i = (Integer) map.get(configuration.getType());
50
				if (i != null) {
51
					return i.intValue();
52
				}
53
			} catch (CoreException e) {
54
			}
55
		}
56
		return map.size();
57
	}
58
	
59
	/**
60
	 * Returns the map of categories
61
	 * @return the map of categories
62
	 */
63
	private Map getCategories() {
64
		if (fgCategories == null) {
65
			fgCategories = new HashMap();
66
			List types = Arrays.asList(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes());
67
			Collections.sort(types, new Comparator() {
68
				public int compare(Object o1, Object o2) {
69
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
70
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
71
					return t1.getName().compareTo(t2.getName());
72
				}
73
			
74
			});
75
			Iterator iterator = types.iterator();
76
			int i = 0;
77
			while (iterator.hasNext()) {
78
				fgCategories.put(iterator.next(), new Integer(i));
79
				i++;
80
			}
81
		}
82
		return fgCategories;
83
	}
84
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java (+22 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui.contextlaunching;
2
3
import org.eclipse.osgi.util.NLS;
4
5
/**
6
 * NLS'd messages for context launching artifacts
7
 * @since 3.3
8
 * EXPERIMENTAL
9
 * CONTEXTLAUNCHING
10
 */
11
public class ContextMessages extends NLS {
12
	private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.contextlaunching.ContextMessages"; //$NON-NLS-1$
13
	public static String ContextRunner_0;
14
	public static String OpenLaunchDialogAction_0;
15
	static {
16
		// initialize resource bundle
17
		NLS.initializeMessages(BUNDLE_NAME, ContextMessages.class);
18
	}
19
20
	private ContextMessages() {
21
	}
22
}
(-)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 {0} Dialog
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/DebugContextLaunchingAction.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 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
 * CONTEXTLAUNCHING
26
 */
27
public class DebugContextLaunchingAction extends ContextLaunchingAction {
28
	
29
	/**
30
	 * Constructor
31
	 */
32
	public DebugContextLaunchingAction() {
33
		super(ILaunchManager.DEBUG_MODE);
34
	}
35
}
(-)ui/org/eclipse/jdt/internal/debug/core/refactoring/LaunchConfigurationProjectMainTypeChange.java (-1 / +10 lines)
Lines 145-151 Link Here
145
		if (fNewProjectName != null) {
145
		if (fNewProjectName != null) {
146
			oldProjectName = fOldProjectName;
146
			oldProjectName = fOldProjectName;
147
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fNewProjectName);
147
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fNewProjectName);
148
			wc.setMappedResources(new IResource[] {ResourcesPlugin.getWorkspace().getRoot().getProject(fNewProjectName)});
148
			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(fNewProjectName);
149
			if(project != null) {
150
				IResource res = project.findMember(wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null));
151
				if(res != null) {
152
					wc.setMappedResources(new IResource[] {res});
153
				}
154
			}
155
			else {
156
				wc.setMappedResources(new IResource[] {});
157
			}
149
		} 
158
		} 
150
		else {
159
		else {
151
			oldProjectName = null;
160
			oldProjectName = null;
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/AbstractJavaMainTab.java (-5 / +12 lines)
Lines 19-24 Link Here
19
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
20
import org.eclipse.jdt.core.IJavaModel;
20
import org.eclipse.jdt.core.IJavaModel;
21
import org.eclipse.jdt.core.IJavaProject;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.IType;
22
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
25
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
Lines 208-219 Link Here
208
	 * @param config
209
	 * @param config
209
	 */
210
	 */
210
	protected void mapResources(ILaunchConfigurationWorkingCopy config)  {
211
	protected void mapResources(ILaunchConfigurationWorkingCopy config)  {
211
		IJavaProject javaProject = getJavaProject();
212
		try {
212
		IResource[] resources = null;
213
			IJavaProject javaProject = getJavaProject();
213
		if (javaProject != null) {
214
			IResource[] resources = null;
214
			resources = new IResource[]{javaProject.getProject()};
215
			if (javaProject != null) {
216
				IType type = javaProject.findType(config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null));
217
				if (type != null) {
218
					resources = new IResource[] {type.getUnderlyingResource()};
219
				}
220
			}
221
			config.setMappedResources(resources);
215
		}
222
		}
216
		config.setMappedResources(resources);
223
		catch(CoreException ce) {JDIDebugUIPlugin.log(ce);}
217
	}	
224
	}	
218
	
225
	
219
}
226
}
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java (-1 / +1 lines)
Lines 72-78 Link Here
72
			wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName()));
72
			wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName()));
73
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
73
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
74
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
74
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
75
			wc.setMappedResources(new IResource[] {type.getJavaProject().getProject()});
75
			wc.setMappedResources(new IResource[] {type.getUnderlyingResource()});
76
			config = wc.doSave();
76
			config = wc.doSave();
77
		} catch (CoreException exception) {
77
		} catch (CoreException exception) {
78
			reportErorr(exception);		
78
			reportErorr(exception);		
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java (-1 / +1 lines)
Lines 39-45 Link Here
39
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH);
39
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH);
40
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT);
40
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT);
41
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$
41
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$
42
			wc.setMappedResources(new IResource[] {type.getJavaProject().getProject()});
42
			wc.setMappedResources(new IResource[] {type.getUnderlyingResource()});
43
			config = wc.doSave();		
43
			config = wc.doSave();		
44
		} catch (CoreException ce) {
44
		} catch (CoreException ce) {
45
			reportErorr(ce);			
45
			reportErorr(ce);			

Return to bug 74480