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

(-)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 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.ui.actions;
11
package org.eclipse.debug.internal.ui.actions;
12
12
13
import org.eclipse.core.expressions.PropertyTester;
13
import org.eclipse.core.expressions.PropertyTester;
14
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IResource;
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;
16
import org.eclipse.debug.ui.actions.ILaunchable;
19
import org.eclipse.debug.ui.actions.ILaunchable;
Lines 20-35 Link Here
20
 */
23
 */
21
public class LaunchablePropertyTester extends PropertyTester {
24
public class LaunchablePropertyTester extends PropertyTester {
22
25
23
	/* (non-Javadoc)
26
	/**
24
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
27
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
25
	 */
28
	 */
26
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
29
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
27
		if (property.equals("launchable")) { //$NON-NLS-1$
30
		if ("launchable".equals(property)) { //$NON-NLS-1$
28
			if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
31
				if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
29
				return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
32
					return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
33
				}
34
		}
35
		else if("resource".equals(property)) { //$NON-NLS-1$
36
			IResource res = getResource(receiver);
37
			if(res != null) {
38
				if(res instanceof IProject) {
39
					return ((IProject)res).isOpen();
40
				}
30
			}
41
			}
31
		}
42
		}
32
		return false;
43
		return false;
33
	}
44
	}
34
45
46
	/**
47
	 * Returns the resource this property page is open on.
48
	 * 
49
	 * @return resource
50
	 */
51
	protected IResource getResource(Object element) {
52
		IResource resource = null;
53
		if (element instanceof IResource) {
54
			resource = (IResource) element;
55
		} else if (element instanceof IAdaptable) {
56
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
57
		}
58
		return resource;
59
	}
35
}
60
}
(-)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 / +120 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 property="org.eclipse.debug.ui.resource" />
949
          	<test property="org.eclipse.debug.ui.contextlaunch" />
950
          	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
951
          </and>
952
         </enablement>
953
       </objectContribution>
954
       <objectContribution
955
             id="org.eclipse.debug.ui.contextlaunch.profileas"
956
             objectClass="org.eclipse.core.runtime.IAdaptable">
957
          <action
958
                class="org.eclipse.debug.internal.ui.contextlaunching.ProfileContextLaunchingAction"
959
                enablesFor="1"
960
                icon="icons/full/etool16/profile_exc.gif"
961
                id="org.eclipse.debug.ui.contextlaunch.profileas"
962
                label="%ContextLaunchingProfileMenu.name"
963
                menubarPath="additions"
964
                tooltip="%ContextLaunchingProfileMenu.tooltip">
965
          </action>
966
          <enablement>
967
          <and>
968
            <test property="org.eclipse.debug.ui.resource" />
969
          	<test property="org.eclipse.debug.ui.contextlaunch" />
970
          	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
971
          </and>
972
         </enablement> 
973
       </objectContribution>
910
   <!-- console additions -->
974
   <!-- console additions -->
975
      <objectContribution
976
            id="org.eclipse.debug.ui.contextlaunch.runas"
977
            objectClass="org.eclipse.core.runtime.IAdaptable">
978
         <action
979
               class="org.eclipse.debug.internal.ui.contextlaunching.RunContextLaunchingAction"
980
               enablesFor="1"
981
               icon="icons/full/etool16/run_exc.gif"
982
               id="org.eclipse.debug.ui.contextlaunch.runas"
983
               label="%ContextLaunchingRunMenu.name"
984
               menubarPath="additions"
985
               tooltip="%ContextLaunchingRunMenu.tooltip">
986
         </action>
987
         <enablement>
988
          <and>
989
          	<test property="org.eclipse.debug.ui.contextlaunch" />
990
          	<test property="org.eclipse.debug.ui.resource" />
991
          	<test property="org.eclipse.debug.ui.launchable" value="run"/>
992
          </and>
993
         </enablement> 
994
      </objectContribution>
911
      <viewerContribution
995
      <viewerContribution
912
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
996
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
913
             id="org.eclipse.debug.ui.processConsoleContextMenu">
997
             id="org.eclipse.debug.ui.processConsoleContextMenu">
Lines 1394-1399 Link Here
1394
            </or>
1478
            </or>
1395
         </enabledWhen>
1479
         </enabledWhen>
1396
      </page>
1480
      </page>
1481
      <page
1482
            class="org.eclipse.debug.internal.ui.preferences.RunDebugPropertiesPage"
1483
            id="org.eclipse.debug.ui.properties.defaultLaunchConfigurations"
1484
            name="%DefaultLaunchConfigurationsPropPage.name"
1485
            >
1486
         <enabledWhen>
1487
            <and>
1488
               <adapt
1489
                     type="org.eclipse.core.resources.IResource">
1490
               </adapt>
1491
               <test property="org.eclipse.debug.ui.contextlaunch" />
1492
               <test
1493
                     property="org.eclipse.debug.ui.resource">
1494
               </test>
1495
            </and>
1496
         </enabledWhen>
1497
      </page>
1397
   </extension>
1498
   </extension>
1398
<!-- commands and their bindings
1499
<!-- commands and their bindings
1399
NOTE: 
1500
NOTE: 
Lines 2032-2038 Link Here
2032
      </propertyTester>
2133
      </propertyTester>
2033
	  <propertyTester
2134
	  <propertyTester
2034
			namespace="org.eclipse.debug.ui"
2135
			namespace="org.eclipse.debug.ui"
2035
			properties="launchable"
2136
			properties="launchable, resource"
2036
			type="java.lang.Object"
2137
			type="java.lang.Object"
2037
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2138
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2038
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
2139
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
Lines 2050-2055 Link Here
2050
            properties="getModelIdentifier,isTerminatedOrDisconnected"
2151
            properties="getModelIdentifier,isTerminatedOrDisconnected"
2051
            type="org.eclipse.core.runtime.IAdaptable">
2152
            type="org.eclipse.core.runtime.IAdaptable">
2052
      </propertyTester>
2153
      </propertyTester>
2154
      <propertyTester
2155
            class="org.eclipse.debug.internal.ui.preferences.ContextLaunchingPropertyTester"
2156
            id="org.eclipse.debug.ui.contextlaunching.IAdaptableTester"
2157
            namespace="org.eclipse.debug.ui"
2158
            properties="contextlaunch"
2159
            type="org.eclipse.core.runtime.IAdaptable">
2160
      </propertyTester>
2053
   </extension>
2161
   </extension>
2054
<!-- Context extensions -->
2162
<!-- Context extensions -->
2055
  <extension
2163
  <extension
Lines 2235-2240 Link Here
2235
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2343
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2236
             label="%preferenceKeywords.launchDelegates">
2344
             label="%preferenceKeywords.launchDelegates">
2237
       </keyword>
2345
       </keyword>
2346
       <keyword
2347
             id="org.eclipse.debug.ui.contextLaunching"
2348
             label="%preferenceKeywords.contextLaunching">
2349
       </keyword>
2238
    </extension>
2350
    </extension>
2239
    <extension
2351
    <extension
2240
          point="org.eclipse.ui.importWizards">
2352
          point="org.eclipse.ui.importWizards">
(-)plugin.properties (+14 lines)
Lines 27-32 Link Here
27
BreakpointOrganizersName=Breakpoint Organizers
27
BreakpointOrganizersName=Breakpoint Organizers
28
VariableValueEditorsName=Variable Value Editors
28
VariableValueEditorsName=Variable Value Editors
29
29
30
ContextLaunchingRunMenu.name=&Run
31
ContextLaunchingRunMenu.tooltip=Run the selected item
32
33
ContextLaunchingDebugMenu.name=&Debug
34
ContextLaunchingDebugMenu.tooltip=Debug the selected item
35
36
ContextLaunchingProfileMenu.name=&Profile
37
ContextLaunchingProfileMenu.tooltip=Profile the selected item
38
39
ContextualLaunchingPrefPage.name=Contextual Launching
40
41
DefaultLaunchConfigurationsPropPage.name=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 (-24 / +87 lines)
Lines 25-32 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;
31
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
30
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
32
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
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;
Lines 34-47 Link Here
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 86-94 Link Here
86
	 */
92
	 */
87
	public LaunchShortcutsAction(String launchGroupIdentifier) {
93
	public LaunchShortcutsAction(String launchGroupIdentifier) {
88
		super();
94
		super();
95
		DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
89
		fGroup = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(launchGroupIdentifier);
96
		fGroup = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(launchGroupIdentifier);
90
		ILaunchMode mode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fGroup.getMode());
97
		if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)
91
		setText(mode.getLaunchAsLabel()); 
98
				&& !"org.eclipse.ui.externaltools.launchGroup".equals(fGroup.getIdentifier())){ //$NON-NLS-1$
99
			setText(fGroup.getLabel());
100
			setImageDescriptor(fGroup.getImageDescriptor());
101
		} else {
102
			ILaunchMode mode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fGroup.getMode());
103
			setText(mode.getLaunchAsLabel());
104
			setImageDescriptor(null);
105
		}
92
		setMenuCreator(this);
106
		setMenuCreator(this);
93
		setEnabled(existsConfigTypesForMode());
107
		setEnabled(existsConfigTypesForMode());
94
	}
108
	}
Lines 102-112 Link Here
102
		return fGroup;
116
		return fGroup;
103
	}
117
	}
104
118
105
	/**
119
	/* (non-Javadoc)
106
	 * @see IAction#run()
120
	 * @see org.eclipse.jface.action.Action#run()
107
	 */
121
	 */
108
	public void run() {
122
	public void run() {
109
		//do nothing, this action just creates a cascading menu.
123
		if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)){
124
			ContextRunner.getDefault().run(fGroup.getMode());
125
		}
126
	}
127
	
128
	/* (non-Javadoc)
129
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
130
	 */
131
	public void runWithEvent(IAction action, Event event) {
132
		run();
133
	}
134
	
135
	/* (non-Javadoc)
136
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
137
	 */
138
	public void run(IAction action) {
139
		run();
110
	}
140
	}
111
	
141
	
112
	/**
142
	/**
Lines 129-140 Link Here
129
	 * @see IMenuCreator#getMenu(Menu)
159
	 * @see IMenuCreator#getMenu(Menu)
130
	 */
160
	 */
131
	public Menu getMenu(Menu parent) {
161
	public Menu getMenu(Menu parent) {
132
		if (getCreatedMenu() != null) {
162
		if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)){
133
			 getCreatedMenu().dispose();
163
			if (getCreatedMenu() != null) {
134
		 }
164
				 getCreatedMenu().dispose();
135
		setCreatedMenu(new Menu(parent));
165
			 }
136
		initMenu();
166
			setCreatedMenu(null);
137
		return getCreatedMenu();
167
			return null;
168
		} else {	
169
			if (getCreatedMenu() != null) {
170
				 getCreatedMenu().dispose();
171
			 }
172
			setCreatedMenu(new Menu(parent));
173
			initMenu();
174
			return getCreatedMenu();
175
		}
138
	}
176
	}
139
	
177
	
140
	/**
178
	/**
Lines 296-324 Link Here
296
		return DebugUIPlugin.getDefault().getLaunchConfigurationManager();
334
		return DebugUIPlugin.getDefault().getLaunchConfigurationManager();
297
	}	
335
	}	
298
	
336
	
299
	/**
337
	/* (non-Javadoc)
338
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
339
	 */
340
	public void init(IAction action) {
341
		fAction = action;
342
		refresh();
343
	}
344
	
345
	/* (non-Javadoc)
300
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
346
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
301
	 */
347
	 */
302
	public void init(IWorkbenchWindow window) {
348
	public void init(IWorkbenchWindow window) {
303
	}
349
	}
304
350
	
305
	/**
351
	/**
306
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
352
	 * Refreshes the enablement, text and image of the proxy action to this delegate if one exists.
307
	 */
353
	 */
308
	public void run(IAction action) {
354
	private void refresh(){
309
		// do nothing - this is just a menu
355
		if (fAction != null){
356
			fAction.setEnabled(existsConfigTypesForMode());
357
			if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)
358
					&& !"org.eclipse.ui.externaltools.launchGroup".equals(fGroup.getIdentifier())){ //$NON-NLS-1$
359
				fAction.setText(fGroup.getLabel());
360
				fAction.setImageDescriptor(fGroup.getImageDescriptor());
361
			} else {
362
				ILaunchMode mode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fGroup.getMode());
363
				fAction.setText(mode.getLaunchAsLabel());
364
				fAction.setImageDescriptor(null);
365
			}
366
		}
310
	}
367
	}
311
368
312
	/**
369
	/**
313
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
370
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
314
	 */
371
	 */
315
	public void selectionChanged(IAction action, ISelection selection) {
372
	public void selectionChanged(IAction action, ISelection selection) {
316
	    if (!fInitialized) {
317
	        action.setEnabled(existsConfigTypesForMode());
318
	        fInitialized = true;
319
	    }
320
	}
373
	}
321
374
	
375
	/* (non-Javadoc)
376
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
377
	 */
378
	public void propertyChange(PropertyChangeEvent event) {
379
		if (IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH.equals(event.getProperty())){
380
			refresh();
381
		}
382
	}
383
	
322
	/**
384
	/**
323
	 * Return whether there are any registered launch configuration types for
385
	 * Return whether there are any registered launch configuration types for
324
	 * the mode of this action.
386
	 * the mode of this action.
Lines 336-340 Link Here
336
		}		
398
		}		
337
		return false;
399
		return false;
338
	}
400
	}
401
339
}
402
}
340
403
(-)ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java (-8 / +21 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
import org.eclipse.debug.internal.ui.contextlaunching.ContextLaunchingToolbarAction;
17
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
16
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
18
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
17
import org.eclipse.debug.ui.DebugUITools;
19
import org.eclipse.debug.ui.DebugUITools;
18
import org.eclipse.jface.action.IAction;
20
import org.eclipse.jface.action.IAction;
Lines 54-61 Link Here
54
		if (menu.getItemCount() > 0) {
56
		if (menu.getItemCount() > 0) {
55
			addSeparator(menu);
57
			addSeparator(menu);
56
		}
58
		}
57
59
		if(!getLaunchGroupIdentifier().equals("org.eclipse.ui.externaltools.launchGroup")) { //$NON-NLS-1$
58
		addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
60
			if(ContextRunner.isContextLaunchEnabled()) {
61
				addToMenu(menu, new ContextLaunchingToolbarAction(getLaunchGroupIdentifier()), -1);
62
			}
63
			else {
64
				addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
65
			}
66
		}
59
		addToMenu(menu, getOpenDialogAction(), -1);
67
		addToMenu(menu, getOpenDialogAction(), -1);
60
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
68
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
61
	}
69
	}
Lines 67-84 Link Here
67
	protected IAction getOpenDialogAction() {
75
	protected IAction getOpenDialogAction() {
68
		return new OpenLaunchDialogAction(getLaunchGroupIdentifier());
76
		return new OpenLaunchDialogAction(getLaunchGroupIdentifier());
69
	}
77
	}
70
78
	
71
	/**
79
	/**
72
	 * Launch the last launch, or open the launch config dialog if none.
80
	 * Launch the last launch, or open the launch config dialog if none.
73
	 * 
81
	 * 
74
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
82
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
75
	 */
83
	 */
76
	public void run(IAction action) {
84
	public void run(IAction action) {
77
		ILaunchConfiguration configuration = getLastLaunch();
85
		if(ContextRunner.isContextLaunchEnabled()) {
78
		if (configuration == null) {
86
			ContextRunner.getDefault().run(getMode());
79
			DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier());
87
		}
80
		} else {
88
		else {
81
			DebugUITools.launch(configuration, getMode());
89
			ILaunchConfiguration configuration = getLastLaunch();
90
			if (configuration == null) {
91
				DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier());
92
			} else {
93
				DebugUITools.launch(configuration, getMode());
94
			}
82
		}
95
		}
83
	}	
96
	}	
84
}
97
}
(-)ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java (-2 / +2 lines)
Lines 53-59 Link Here
53
 * An action delegate that builds a context menu with applicable launch shortcuts
53
 * An action delegate that builds a context menu with applicable launch shortcuts
54
 * for a specific launch mode.
54
 * for a specific launch mode.
55
 * <p>
55
 * <p>
56
 * This class can be subclassed and contributed as an object contribution pop-up
56
 * This class can be sub-classed and contributed as an object contribution pop-up
57
 * menu extension action. When invoked, it becomes a sub-menu that dynamically
57
 * menu extension action. When invoked, it becomes a sub-menu that dynamically
58
 * builds a list of applicable launch shortcuts for the current selection.
58
 * builds a list of applicable launch shortcuts for the current selection.
59
 * Each launch shortcut may have optional information to support a context menu action.
59
 * Each launch shortcut may have optional information to support a context menu action.
Lines 171-177 Link Here
171
	/**
171
	/**
172
	 * This method is used to determine if the selected object is in fact a shared launch
172
	 * This method is used to determine if the selected object is in fact a shared launch
173
	 * configuration that can be launched
173
	 * configuration that can be launched
174
	 * @return true if the item is a shared ocnfig , false otherwise
174
	 * @return true if the item is a shared config , false otherwise
175
	 * @since 3.3
175
	 * @since 3.3
176
	 */
176
	 */
177
	private boolean isSharedConfig(Object receiver) {
177
	private boolean isSharedConfig(Object receiver) {
(-)ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java (-22 / +67 lines)
Lines 16-30 Link Here
16
import org.eclipse.debug.core.ILaunchConfigurationType;
16
import org.eclipse.debug.core.ILaunchConfigurationType;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
18
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.contextlaunching.ContextMessages;
19
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
21
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
21
import org.eclipse.debug.ui.DebugUITools;
23
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.jface.action.Action;
24
import org.eclipse.jface.action.Action;
23
import org.eclipse.jface.action.IAction;
25
import org.eclipse.jface.action.IAction;
26
import org.eclipse.jface.util.IPropertyChangeListener;
27
import org.eclipse.jface.util.PropertyChangeEvent;
24
import org.eclipse.jface.viewers.ISelection;
28
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.IStructuredSelection;
29
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.StructuredSelection;
30
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.jface.window.Window;
31
import org.eclipse.jface.window.Window;
32
import org.eclipse.swt.widgets.Event;
33
import org.eclipse.ui.IActionDelegate2;
28
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.IWorkbenchWindow;
29
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
35
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
30
import org.eclipse.ui.PlatformUI;
36
import org.eclipse.ui.PlatformUI;
Lines 37-43 Link Here
37
 * </p>
43
 * </p>
38
 * @since 2.1
44
 * @since 2.1
39
 */
45
 */
40
public class OpenLaunchDialogAction extends Action implements IWorkbenchWindowActionDelegate {
46
public class OpenLaunchDialogAction extends Action implements IPropertyChangeListener, IActionDelegate2, IWorkbenchWindowActionDelegate {
41
47
42
	/**
48
	/**
43
	 * Launch group identifier
49
	 * Launch group identifier
Lines 57-66 Link Here
57
	 */
63
	 */
58
	public OpenLaunchDialogAction(String identifier) {
64
	public OpenLaunchDialogAction(String identifier) {
59
		fIdentifier = identifier;
65
		fIdentifier = identifier;
66
		DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
60
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
67
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
61
		if (extension != null) {
68
		if (extension != null) {
62
			setText(extension.getLabel() + "..."); //$NON-NLS-1$
69
			if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)
63
			setImageDescriptor(extension.getImageDescriptor());
70
					&& !"org.eclipse.ui.externaltools.launchGroup".equals(identifier)) { //$NON-NLS-1$
71
				setText(ContextMessages.OpenLaunchDialogAction_0);
72
				setImageDescriptor(extension.getImageDescriptor());
73
			}
74
			else {
75
				setText(extension.getLabel() + "..."); //$NON-NLS-1$
76
				setImageDescriptor(extension.getImageDescriptor());
77
			}
64
		}
78
		}
65
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
79
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
66
	}
80
	}
Lines 80-124 Link Here
80
		int result = DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
94
		int result = DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
81
		notifyResult(result == Window.OK);
95
		notifyResult(result == Window.OK);
82
	}
96
	}
97
	
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
100
	 */
101
	public void runWithEvent(IAction action, Event event) {
102
		run();
103
	}
104
	
105
	/* (non-Javadoc)
106
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
107
	 */
108
	public void run(IAction action) {
109
		run();
110
	}
111
	
83
	/**
112
	/**
84
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
113
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
85
	 */
114
	 */
86
	public void dispose() {
115
	public void dispose() {
87
	}
116
	}
88
117
89
	/**
118
	/* (non-Javadoc)
119
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
120
	 */
121
	public void init(IAction action) {
122
		fAction = action;
123
		refresh();
124
	}
125
	
126
	/* (non-Javadoc)
90
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
127
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
91
	 */
128
	 */
92
	public void init(IWorkbenchWindow window) {
129
	public void init(IWorkbenchWindow window) {
93
	}
130
	}
94
131
	
95
	/**
132
	/**
96
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
133
	 * Refreshes the enablement, text and image of the proxy action to this delegate if one exists.
97
	 */
134
	 */
98
	public void run(IAction action) {
135
	private void refresh(){
99
		run();
136
		if (fAction != null){
137
			fAction.setEnabled(existsConfigTypesForMode());
138
			LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(fIdentifier);
139
			if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH)
140
					&& !"org.eclipse.ui.externaltools.launchGroup".equals(fIdentifier)) { //$NON-NLS-1$
141
				fAction.setText(ContextMessages.OpenLaunchDialogAction_0);
142
				fAction.setImageDescriptor(extension.getImageDescriptor());
143
			}
144
			else {
145
				fAction.setText(extension.getLabel() + "..."); //$NON-NLS-1$
146
				fAction.setImageDescriptor(extension.getImageDescriptor());
147
			}
148
		}
149
	}	
150
	
151
	/* (non-Javadoc)
152
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
153
	 */
154
	public void propertyChange(PropertyChangeEvent event) {
155
		if (IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH.equals(event.getProperty())){
156
			refresh();
157
		}
100
	}
158
	}
101
159
	
102
	/**
160
	/**
103
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
161
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
104
	 */
162
	 */
105
	public void selectionChanged(IAction action, ISelection selection) {
163
	public void selectionChanged(IAction action, ISelection selection) {
106
		if (fAction == null) {
107
			initialize(action);
108
		} 		
109
	}
164
	}
110
	
165
	
111
	/**
166
	/**
112
	 * Set the enabled state of the underlying action based on whether there are any
113
	 * registered launch configuration types that understand how to launch in the
114
	 * mode of this action.
115
	 */
116
	private void initialize(IAction action) {
117
		fAction = action;
118
		action.setEnabled(existsConfigTypesForMode());	
119
	}	
120
121
	/**
122
	 * Return whether there are any registered launch configuration types for
167
	 * Return whether there are any registered launch configuration types for
123
	 * the mode of this action.
168
	 * the mode of this action.
124
	 * 
169
	 * 
(-)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 (+3 lines)
Lines 102-107 Link Here
102
PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4=Unable to open perspectives as specified by launch: {0}
102
PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4=Unable to open perspectives as specified by launch: {0}
103
PerspectiveManager_Unable_to_switch_to_perspective___0__2=Unable to open perspective: {0}
103
PerspectiveManager_Unable_to_switch_to_perspective___0__2=Unable to open perspective: {0}
104
LaunchShortcutExtension_Error_4=Error
104
LaunchShortcutExtension_Error_4=Error
105
LaunchShortcutSelectionDialog_0={0} As...
106
LaunchShortcutSelectionDialog_1=&Select how to {0} {1}: 
107
LaunchShortcutSelectionDialog_2=&Make generated launch configuration the default for [{0}]
105
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
108
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
106
109
107
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
110
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-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/LaunchConfigurationsMessages.java (+6 lines)
Lines 106-111 Link Here
106
	public static String LaunchConfigurationTabGroupViewer_13;
106
	public static String LaunchConfigurationTabGroupViewer_13;
107
107
108
	public static String LaunchConfigurationView_0;
108
	public static String LaunchConfigurationView_0;
109
110
	public static String LaunchShortcutSelectionDialog_0;
111
112
	public static String LaunchShortcutSelectionDialog_1;
113
114
	public static String LaunchShortcutSelectionDialog_2;
109
	public static String PerspectiveManager_Error_1;
115
	public static String PerspectiveManager_Error_1;
110
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
116
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
111
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
117
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java (-1 / +4 lines)
Lines 851-857 Link Here
851
	 * @return the shell title
851
	 * @return the shell title
852
	 */
852
	 */
853
	protected String getShellTitle() {
853
	protected String getShellTitle() {
854
		String title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel());
854
		String title = null;
855
		if(getLaunchGroup() != null) {
856
			 title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel());
857
		}
855
		if (title == null) {
858
		if (title == null) {
856
			title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; 
859
			title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; 
857
		}
860
		}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/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 / +46 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
	 */
609
	public List getApplicableConfigurationTypes(IResource resource) {
610
		List types = new ArrayList();
611
		try {
612
			List exts = getLaunchShortcuts();
613
			LaunchShortcutExtension ext = null;
614
			List list = new ArrayList();
615
			list.add(resource);
616
			IEvaluationContext context = new EvaluationContext(null, list);
617
			context.addVariable("selection", list); //$NON-NLS-1$
618
			HashSet set = new HashSet();
619
			for(Iterator iter = exts.iterator(); iter.hasNext();) {
620
				ext = (LaunchShortcutExtension) iter.next();
621
				if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
622
					set.addAll(ext.getAssociatedConfigurationTypes());
623
				}
624
			}
625
			LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
626
			ILaunchConfigurationType type = null;
627
			for(Iterator iter = set.iterator(); iter.hasNext();) {
628
				type = lm.getLaunchConfigurationType((String)iter.next());
629
				if(type != null && !"org.eclipse.ui.externaltools".equals(type.getCategory()) && !types.contains(type)) { //$NON-NLS-1$
630
					types.add(type);
631
				}
632
			}
633
		}
634
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
635
		return types;
636
	}
597
	
637
	
598
	/**
638
	/**
599
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
639
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
600
	 * launch configuration type id.
640
	 * launch configuration type id.
601
	 * @param typeid the id of the launch configuraiton
641
	 * @param typeid the id of the launch configuration
602
	 * @return a listing of <code>LaunchShortcutExtension</code>s that are associated with the specified launch configuration
642
	 * @return a listing of <code>LaunchShortcutExtension</code>s that are associated with the specified launch configuration
603
	 * type id or an empty list, never <code>null</code>
643
	 * type id or an empty list, never <code>null</code>
604
	 * 
644
	 * 
Lines 695-700 Link Here
695
	 * @since 3.3
735
	 * @since 3.3
696
	 * 
736
	 * 
697
	 * EXPERIMENTAL
737
	 * EXPERIMENTAL
738
	 * CONTEXTLAUNCHING
698
	 */
739
	 */
699
	public LaunchShortcutExtension getLaunchShortcut(String id) {
740
	public LaunchShortcutExtension getLaunchShortcut(String id) {
700
		loadLaunchShortcuts();
741
		loadLaunchShortcuts();
Lines 800-805 Link Here
800
	 * @since 3.3
841
	 * @since 3.3
801
	 * 
842
	 * 
802
	 * EXPERIMENTAL
843
	 * EXPERIMENTAL
844
	 * CONTEXTLAUNCHING
803
	 */
845
	 */
804
	public void setDefaultLaunchShortcut(IResource resource, LaunchShortcutExtension shortcut) throws CoreException {
846
	public void setDefaultLaunchShortcut(IResource resource, LaunchShortcutExtension shortcut) throws CoreException {
805
		IProject project = resource.getProject();
847
		IProject project = resource.getProject();
Lines 826-837 Link Here
826
	 * 
868
	 * 
827
	 * @see {@link ILaunchManager#getDefaultConfiguration(IResource)}
869
	 * @see {@link ILaunchManager#getDefaultConfiguration(IResource)}
828
	 * @param resource the resource
870
	 * @param resource the resource
829
	 * @return the corresponding <code>LaunchShortcutExtension</code> for the guven <code>IResource</code>,
871
	 * @return the corresponding <code>LaunchShortcutExtension</code> for the given <code>IResource</code>,
830
	 * or <code>null</code> if there is not one.
872
	 * or <code>null</code> if there is not one.
831
	 * 
873
	 * 
832
	 * @since 3.3
874
	 * @since 3.3
833
	 * 
875
	 * 
834
	 * EXPERIMENTAL
876
	 * EXPERIMENTAL
877
	 * CONTEXTLAUNCHING
835
	 */
878
	 */
836
	public LaunchShortcutExtension getDefaultLaunchShortcut(IResource resource) {
879
	public LaunchShortcutExtension getDefaultLaunchShortcut(IResource resource) {
837
		IProject project = resource.getProject();
880
		IProject project = resource.getProject();
(-)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/preferences/ContextLaunchingPropertyTester.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.preferences;
12
13
import org.eclipse.core.expressions.PropertyTester;
14
import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
17
/**
18
 * Tests properties for enabling/disabling popup menu object contributions
19
 * @since 3.3
20
 * 
21
 * EXPERIMENTAL
22
 */
23
public class ContextLaunchingPropertyTester extends PropertyTester {
24
25
	/**
26
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
27
	 */
28
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
29
		if("contextlaunch".equals(property)) { //$NON-NLS-1$
30
			return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
31
		}
32
		return false;
33
	}
34
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingAction.java (+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().run(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/preferences/RunDebugPropertiesPage.java (+489 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
		
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
		
110
		fViewer = createViewer(topComposite);
111
		
112
		Composite buttonComp = SWTUtil.createComposite(topComposite, 1, 1, GridData.FILL_VERTICAL);
113
		GridLayout layout = (GridLayout) buttonComp.getLayout();
114
		layout.marginHeight = 0;
115
		fNewButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_2, null);
116
		fNewButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_3);
117
		fNewButton.addSelectionListener(new SelectionListener() {
118
			public void widgetDefaultSelected(SelectionEvent e) {}
119
			public void widgetSelected(SelectionEvent e) {
120
				handleNew();
121
			}
122
		});
123
		
124
		fDuplicateButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_4, null);
125
		fDuplicateButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_5);
126
		fDuplicateButton.setEnabled(false);
127
		fDuplicateButton.addSelectionListener(new SelectionListener() {
128
			public void widgetDefaultSelected(SelectionEvent e) {}
129
			public void widgetSelected(SelectionEvent e) {
130
				handleCopy();
131
			}
132
		});
133
		fEditButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_6, null);
134
		fEditButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_7);
135
		fEditButton.setEnabled(false);
136
		fEditButton.addSelectionListener(new SelectionListener() {
137
			public void widgetDefaultSelected(SelectionEvent e) {}
138
			public void widgetSelected(SelectionEvent e) {
139
				handleEdit();
140
			}
141
		});
142
		fDeleteButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_8, null);
143
		fDeleteButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_9);
144
		fDeleteButton.setEnabled(false);
145
		fDeleteButton.addSelectionListener(new SelectionListener() {
146
			public void widgetDefaultSelected(SelectionEvent e) {}
147
			public void widgetSelected(SelectionEvent e) {
148
				handleDelete();
149
			}
150
		});
151
		
152
		fViewer.setSelection(new StructuredSelection());
153
		applyDialogFont(topComposite);
154
		return topComposite;
155
	}
156
157
	/**
158
	 * Creates and returns the viewer that will display the possible default configurations.
159
	 * 
160
	 * @param parent parent composite to create the viewer in
161
	 * @return viewer viewer that will display possible default configurations
162
	 */
163
	protected CheckboxTableViewer createViewer(Composite parent){
164
		CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
165
		viewer.setLabelProvider(new DefaultLabelProvider());
166
		viewer.setContentProvider(new ArrayContentProvider());
167
		viewer.setComparator(new LaunchConfigurationComparator());
168
		viewer.addCheckStateListener(new ICheckStateListener() {
169
			public void checkStateChanged(CheckStateChangedEvent event) {
170
				if (event.getChecked()) {
171
					fViewer.setCheckedElements(new Object[] {event.getElement()});
172
				}
173
				else{
174
					fViewer.setCheckedElements(new Object[] {});
175
				}
176
			}
177
		});
178
		Table builderTable = viewer.getTable();
179
		GridData tableGridData = new GridData(GridData.FILL_BOTH);
180
		tableGridData.heightHint = 300;
181
		builderTable.setLayoutData(tableGridData);
182
		
183
		IResource resource = getResource();
184
		viewer.setInput(collectConfigCandidates(resource));
185
		try {
186
			ILaunchConfiguration configuration = getLaunchManager().getDefaultConfiguration(resource);
187
			if (configuration != null) {
188
				Iterator iterator = fOriginalCandidates.iterator();
189
				while (iterator.hasNext()) {
190
					ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
191
					if (configuration.equals(wc.getOriginal())) {
192
						viewer.setChecked(wc, true);
193
						break;
194
					}
195
				}
196
			}
197
		} catch (CoreException e) {
198
			setErrorMessage(e.getMessage());
199
		}
200
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
201
			public void selectionChanged(SelectionChangedEvent event) {
202
				boolean empty = event.getSelection().isEmpty();
203
				fEditButton.setEnabled(!empty);
204
				fDuplicateButton.setEnabled(!empty);
205
				fDeleteButton.setEnabled(!empty);
206
			}
207
		});
208
		
209
		return viewer;
210
	}
211
212
	/**
213
	 * Returns the viewer displaying possible default configurations.
214
	 * 
215
	 * @return viewer
216
	 */
217
	protected CheckboxTableViewer getViewer() {
218
		return fViewer;
219
	}
220
		
221
	/**
222
	 * Returns the launch manager
223
	 * @return the launch manager
224
	 */
225
	protected LaunchManager getLaunchManager() {
226
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
227
	}
228
	
229
	/**
230
	 * Collects the applicable launch configuration types for the backing resource.
231
	 * Default implementation uses the launch shortcut evaluation expressions and leverages the 
232
	 * mapping of launch shortcut to config type id to derive the applicable types.
233
	 * @return the listing of applicable launch configuration types for the backing resource
234
	 */
235
	protected List collectTypeCandidates() {
236
		if(fTypeCandidates == null) {
237
			fTypeCandidates = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getApplicableConfigurationTypes(getResource());
238
			Collections.sort(fTypeCandidates, new Comparator() {
239
				public int compare(Object o1, Object o2) {
240
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
241
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
242
					return t1.getName().compareTo(t2.getName());
243
				}
244
			
245
			});
246
		}
247
		return fTypeCandidates;
248
	}
249
	
250
	/**
251
	 * Returns a set of potential default configurations candidates for the given
252
	 * resource. The configurations are working copies.
253
	 *  
254
	 * @param resource resource
255
	 * @return list of default candidates
256
	 */
257
	protected Set collectConfigCandidates(IResource resource) {
258
		if(fOriginalCandidates == null) {
259
			fOriginalCandidates = new HashSet();
260
			IPath resourcePath = resource.getFullPath();
261
			try {
262
				List types = collectTypeCandidates();
263
				List configs = new ArrayList();
264
				ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations();
265
				for(int i = 0; i < configurations.length; i++) {
266
					if(types.contains(configurations[i].getType())) {
267
						if(configurations[i].isMigrationCandidate()) {
268
							configurations[i].migrate();
269
						}
270
						configs.add(configurations[i]);
271
					}
272
				}
273
				ILaunchConfiguration configuration = null;
274
				IResource[] resources = null;
275
				for (Iterator iter = configs.iterator(); iter.hasNext();) {
276
					configuration = (ILaunchConfiguration) iter.next();
277
					if(!DebugUITools.isPrivate(configuration) && !"org.eclipse.ui.externaltools".equals(configuration.getType().getCategory())) { //$NON-NLS-1$
278
						if(configuration.contentsEqual(getLaunchManager().getDefaultConfiguration(resource))) {
279
							fOriginalCandidates.add(configuration.getWorkingCopy());
280
						}
281
						else {
282
							resources = configuration.getMappedResources();
283
							if (resources != null) {
284
								for (int j = 0; j < resources.length; j++) {
285
									if (resource.equals(resources[j]) || resourcePath.isPrefixOf(resources[j].getFullPath())) {
286
										fOriginalCandidates.add(configuration.getWorkingCopy());
287
										break;
288
									}
289
								}
290
							}
291
							else {
292
								//in the event the config has no mapping
293
								fOriginalCandidates.add(configuration.getWorkingCopy());
294
							}
295
						}
296
					}
297
				}
298
			} catch (CoreException e) {
299
				fOriginalCandidates.clear();
300
				DebugPlugin.log(e);
301
			}
302
		}
303
		return fOriginalCandidates;
304
	}
305
	
306
	/**
307
	 * Returns the resource this property page is open on.
308
	 * 
309
	 * @return resource
310
	 */
311
	protected IResource getResource() {
312
		Object element = getElement();
313
		IResource resource = null;
314
		if (element instanceof IResource) {
315
			resource = (IResource) element;
316
		} else if (element instanceof IAdaptable) {
317
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
318
		}
319
		return resource;
320
	}
321
322
	/* (non-Javadoc)
323
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
324
	 */
325
	public boolean performOk() {
326
		Object[] checked = fViewer.getCheckedElements();
327
		try {
328
			ILaunchConfiguration def = null;
329
			if (checked.length == 1) {
330
					def = (ILaunchConfiguration) checked[0];
331
					def = ((ILaunchConfigurationWorkingCopy)def).doSave();
332
			}
333
			DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
334
		} catch (CoreException e) {
335
			setErrorMessage(e.getMessage());
336
			return false;
337
		}
338
	//delete 
339
		Iterator iter = fDeletedConfigurations.iterator();
340
		while (iter.hasNext()) {
341
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
342
			try{			
343
				if (currentConfig.getOriginal() != null){
344
					currentConfig.getOriginal().delete();
345
				}
346
			} catch (CoreException e) {
347
				DebugPlugin.logMessage("Problem deleting configuration " + currentConfig.getName(), e); //$NON-NLS-1$
348
			}
349
		}
350
	//add
351
		iter = fOriginalCandidates.iterator();
352
		while (iter.hasNext()) {
353
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
354
			if (currentConfig.isDirty()){
355
				try{
356
					currentConfig.doSave();
357
				} catch (CoreException e) {
358
					DebugPlugin.logMessage("Problem saving changes to configuration " + currentConfig.getName(), e); //$NON-NLS-1$
359
				}
360
			}
361
		}
362
		
363
		return super.performOk();
364
	}
365
366
	/* (non-Javadoc)
367
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
368
	 */
369
	protected void performDefaults() {
370
		fViewer.setAllChecked(false);
371
		setErrorMessage(null);
372
		setValid(true);
373
		super.performDefaults();
374
	}
375
	
376
	/**
377
	 * Returns the names of the launch configurations passed in as original input to the tree viewer
378
	 * @return the names of the original launch configurations
379
	 */
380
	private Set getConfigurationNames() {
381
		Set names = new HashSet();
382
		Iterator iter = fOriginalCandidates.iterator();
383
		Object o = null;
384
		while (iter.hasNext()) {
385
			o = iter.next();
386
			if(o instanceof ILaunchConfiguration) {
387
				names.add(((ILaunchConfiguration)o).getName());
388
			}
389
		}
390
		return names;
391
	}
392
	
393
	/**
394
	 * Returns selected configurations.
395
	 * 
396
	 * @return selected configurations
397
	 */
398
	private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() {
399
		IStructuredSelection ss = (IStructuredSelection) fViewer.getSelection();
400
		return (ILaunchConfigurationWorkingCopy[]) ss.toList().toArray(new ILaunchConfigurationWorkingCopy[ss.size()]);
401
	}
402
403
	/**
404
	 * Copy the selection
405
	 */
406
	private void handleCopy() {
407
		ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0];
408
		try {
409
			ILaunchConfigurationWorkingCopy copy = configuration.copy(
410
					((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).generateUniqueLaunchConfigurationNameFrom(configuration.getName(), getConfigurationNames()));
411
			copy.setAttributes(configuration.getAttributes());
412
			fOriginalCandidates.add(copy);
413
			fViewer.refresh();
414
			fViewer.setSelection(new StructuredSelection(copy));
415
		} catch (CoreException e) {
416
			setErrorMessage(e.getMessage());
417
		}
418
	}
419
420
	/**
421
	 * Delete the selection
422
	 */
423
	private void handleDelete() {
424
		Table table = fViewer.getTable();
425
		int[] indices = table.getSelectionIndices();
426
		Arrays.sort(indices);
427
		ILaunchConfiguration[] configurations = getSelectedConfigurations();
428
		for (int i = 0; i < configurations.length; i++) {
429
			fDeletedConfigurations.add(configurations[i]);
430
			fOriginalCandidates.remove(configurations[i]);
431
		}
432
		fViewer.refresh();
433
		if (indices[0] < table.getItemCount()) {
434
			fViewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData()));
435
		} else if (table.getItemCount() > 0) {
436
			fViewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData()));
437
		}
438
	}
439
440
	/**
441
	 * Edit the selection
442
	 */
443
	private void handleEdit() {
444
		edit(getSelectedConfigurations()[0]);
445
		fViewer.refresh();
446
	}
447
448
	/**
449
	 * Edits the given configuration as a nested working copy.
450
	 * Returns the code from the dialog used to edit the configuration.
451
	 * 
452
	 * @param configuration
453
	 * @return dialog return code - OK or CANCEL
454
	 */
455
	private int edit(ILaunchConfigurationWorkingCopy configuration) {
456
		return DebugUIPlugin.openLaunchConfigurationPropertiesDialog(getShell(), configuration, IDebugUIConstants.ID_RUN_LAUNCH_GROUP, getConfigurationNames(), null);
457
	}
458
459
	/**
460
	 * Create a new configuration
461
	 */
462
	private void handleNew() {
463
		ListDialog dialog = new ListDialog(getShell());
464
		dialog.setTitle(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_11);
465
		dialog.setContentProvider(new ArrayContentProvider());
466
		dialog.setLabelProvider(new DefaultLabelProvider());
467
		dialog.setAddCancelButton(true);
468
		dialog.setMessage(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_12);
469
		dialog.setInput(collectTypeCandidates());
470
		if (dialog.open() == Window.OK) {
471
			Object[] result = dialog.getResult();
472
			if (result.length == 1) {
473
				ILaunchConfigurationType type = (ILaunchConfigurationType) result[0];
474
				try {
475
					ILaunchConfigurationWorkingCopy wc = type.newInstance(null, 
476
							((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).
477
							generateUniqueLaunchConfigurationNameFrom("New_configuration", getConfigurationNames())); //$NON-NLS-1$
478
					if (edit(wc) == Window.OK) {
479
						fOriginalCandidates.add(wc);
480
						fViewer.refresh();
481
						fViewer.setSelection(new StructuredSelection(wc));
482
					}
483
				} catch (CoreException e) {
484
					setErrorMessage(e.getMessage());
485
				}
486
			}
487
		}
488
	}	
489
}
(-)ui/org/eclipse/debug/internal/ui/preferences/ContextLaunchingPreferencePage.java (+104 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.preferences;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.debug.internal.ui.DebugUIPlugin;
17
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
18
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19
import org.eclipse.debug.internal.ui.SWTUtil;
20
import org.eclipse.jface.preference.BooleanFieldEditor;
21
import org.eclipse.jface.preference.FieldEditor;
22
import org.eclipse.jface.preference.PreferencePage;
23
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.ui.IWorkbench;
27
import org.eclipse.ui.IWorkbenchPreferencePage;
28
import org.eclipse.ui.PlatformUI;
29
30
/**
31
 * A preference page for configuring launching preferences.
32
 * 
33
 * @since 3.3
34
 */
35
public class ContextLaunchingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
36
	
37
	/**
38
	 * a list of the field editors
39
	 */
40
	private List fFieldEditors;
41
	
42
	/**
43
	 * The default constructor
44
	 */
45
	public ContextLaunchingPreferencePage() {
46
		super();
47
		setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
48
	}
49
	
50
	/**
51
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
52
	 */
53
	public void createControl(Composite parent) {
54
		super.createControl(parent);
55
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.CONTEXTUAL_LAUNCHING_PREFERENCE_PAGE);
56
	}
57
	
58
	/**
59
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
60
	 */
61
	protected Control createContents(Composite parent) {
62
		fFieldEditors = new ArrayList();
63
		Composite comp = SWTUtil.createComposite(parent, 1, 1, GridData.FILL_BOTH);
64
		
65
		SWTUtil.createWrapLabel(comp, DebugPreferencesMessages.ContextualLaunchPreferencePage_0, 1, 300);
66
		SWTUtil.createVerticalSpacer(comp, 2);
67
		//use contextual launch
68
		FieldEditor edit = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, DebugPreferencesMessages.ContextualLaunchPreferencePage_1, comp);	
69
		fFieldEditors.add(edit);
70
			
71
		//init the field editors
72
		FieldEditor editor;
73
		for(int i = 0; i < fFieldEditors.size(); i++) {
74
			editor = (FieldEditor)fFieldEditors.get(i);
75
			editor.setPreferenceStore(getPreferenceStore());
76
			editor.load();
77
		}
78
		return comp;
79
	}
80
	
81
	/**
82
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
83
	 */
84
	public void init(IWorkbench workbench) {}
85
	
86
	/**
87
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
88
	 */
89
	protected void performDefaults() {
90
		for(int i = 0; i < fFieldEditors.size(); i++) {
91
			((FieldEditor)fFieldEditors.get(i)).loadDefault();
92
		}
93
	}
94
	
95
	/**
96
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
97
	 */
98
	public boolean performOk() {
99
		for(int i = 0; i < fFieldEditors.size(); i++) {
100
			((FieldEditor)fFieldEditors.get(i)).store();
101
		}
102
		return super.performOk();
103
	}
104
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java (+260 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui.contextlaunching;
2
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6
7
import org.eclipse.core.expressions.EvaluationContext;
8
import org.eclipse.core.expressions.IEvaluationContext;
9
import org.eclipse.core.resources.IResource;
10
import org.eclipse.core.runtime.CoreException;
11
import org.eclipse.core.runtime.IAdaptable;
12
import org.eclipse.debug.core.DebugPlugin;
13
import org.eclipse.debug.core.ILaunch;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchListener;
16
import org.eclipse.debug.internal.core.LaunchManager;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutSelectionDialog;
21
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.ISelectionProvider;
25
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.jface.window.Window;
28
import org.eclipse.ui.IEditorInput;
29
import org.eclipse.ui.IEditorPart;
30
import org.eclipse.ui.IWorkbenchPage;
31
import org.eclipse.ui.IWorkbenchPart;
32
import org.eclipse.ui.IWorkbenchPartSite;
33
import org.eclipse.ui.IWorkbenchWindow;
34
35
/**
36
 * Static runner for context launching to provide the base capability of context 
37
 * launching to more than one form of action (drop down, toolbar, view, etc)
38
 * 
39
 * @see {@link ContextLaunchingAction}
40
 * @see {@link ContextLaunchingToolbarAction}
41
 * @see {@link ILaunchListener}
42
 * @see {@link org.eclipse.debug.core.ILaunchManager}
43
 * 
44
 *  @since 3.3
45
 *  EXPERIMENTAL
46
 *  CONTEXTLAUNCHING
47
 */
48
public class ContextRunner implements ILaunchListener {
49
	
50
	private static ContextRunner fgInstance = null;
51
	
52
	/**
53
	 * Returns the singleton instance of <code>ContextRunner</code>
54
	 * @return the singleton instance of <code>ContextRunner</code>
55
	 */
56
	public static ContextRunner getDefault() {
57
		if(fgInstance == null) {
58
			fgInstance = new ContextRunner();
59
		}
60
		return fgInstance;
61
	}
62
63
	/**
64
	 * The underlying resource that is derived from the object context of the 
65
	 * run(Object, String) method
66
	 */
67
	private IResource fBackingResource = null;
68
	
69
	/**
70
	 * Performs the context launching given the object context and the mode to launch in
71
	 * @param mode the mode to launch in
72
	 */
73
	public void run(String mode) {
74
		try {
75
			Object context = getCurrentContext();
76
			boolean launched = false;
77
			if(context instanceof IAdaptable) {
78
				IAdaptable adapt = (IAdaptable) context;
79
				IResource resource = (IResource) adapt.getAdapter(IResource.class);
80
				if(resource != null) {
81
					fBackingResource = resource;
82
					ILaunchConfiguration config = getLaunchManager().getDefaultConfiguration(resource);
83
					if(config != null) {
84
						if(config.exists()) {
85
							DebugUITools.launch(config, mode);
86
							launched = true;
87
						}
88
						else {
89
							getLaunchManager().setDefaultConfiguration(resource, null);
90
							selectAndLaunch(adapt, mode);
91
							launched = true;
92
						}
93
					}
94
					else {
95
						selectAndLaunch(adapt, mode);
96
						launched = true;
97
					}
98
				}
99
			}
100
			if(!launched) {
101
				DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP, null);
102
			}
103
		}
104
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
105
	}
106
	
107
	/**
108
	 * Prompts the user to select a way of launching the current resource, where a 'way'
109
	 * is defined as a launch shortcut
110
	 * @param adapt the adaptable type the specified resource was derived from
111
	 * @param resource
112
	 * @return the 'way' to launch the selected resource
113
	 * @throws CoreException
114
	 */
115
	protected void selectAndLaunch(IAdaptable adapt, String mode) throws CoreException {
116
		LaunchShortcutSelectionDialog dialog = new LaunchShortcutSelectionDialog(getLaunchShortcuts(fBackingResource), fBackingResource, mode);
117
		if (dialog.open() == Window.OK) {
118
			Object[] result = dialog.getResult();
119
			if(result.length > 0) {
120
				if(dialog.makeDefault()) {
121
					getLaunchManager().addLaunchListener(this);
122
				}
123
				LaunchShortcutExtension method = (LaunchShortcutExtension) result[0];
124
				if(method != null) {
125
					if(adapt instanceof IEditorInput) {
126
						IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
127
						if(window != null) {
128
							IEditorPart epart = window.getActivePage().getActiveEditor();
129
							method.launch(epart, mode);
130
						}
131
					}
132
					else {
133
						method.launch(new StructuredSelection(adapt), mode);
134
					}
135
				}
136
			}
137
		}
138
	}
139
	
140
	/**
141
	 * Creates a listing of the launch shortcut extensions that are applicable to the underlying resource
142
	 * @param resource the underlying resource
143
	 * @return a listing of applicable launch shortcuts
144
	 * @throws CoreException
145
	 */
146
	protected List getLaunchShortcuts(IResource resource) throws CoreException {
147
		List list = new ArrayList(); 
148
		List sc = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts();
149
		List ctxt = new ArrayList();
150
		ctxt.add(resource);
151
		IEvaluationContext context = new EvaluationContext(null, ctxt);
152
		context.addVariable("selection", ctxt); //$NON-NLS-1$
153
		LaunchShortcutExtension ext = null;
154
		for(Iterator iter = sc.iterator(); iter.hasNext();) {
155
			ext = (LaunchShortcutExtension) iter.next();
156
			if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
157
				if(!list.contains(ext)) {
158
					list.add(ext);
159
				}
160
			}
161
		}
162
		return list;
163
	}
164
	
165
	/**
166
	 * Returns the current context to be considered for launching. 
167
	 * The returned object will be one of:
168
	 * <ol>
169
	 * <li>{@link IEditorInput}<li>
170
	 * <li>{@link Object}, where <i>object</i> is the first element in the selection obtained from the 
171
	 * selection provider of the currently selected workbench part</li>
172
	 * </ol>
173
	 * @return the currently selected context to consider for launching, or <code>null</code>.
174
	 *
175
	 */
176
	public Object getCurrentContext() {
177
		IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
178
		if(window != null) {
179
			IWorkbenchPage page = window.getActivePage();
180
			if(page!= null) {
181
				IWorkbenchPart part = page.getActivePart();
182
				if(part != null) {
183
					if(part instanceof IEditorPart) {
184
						return ((IEditorPart)part).getEditorInput();
185
					}
186
					IWorkbenchPartSite site = part.getSite();
187
					if(site != null) {
188
						ISelectionProvider provider = site.getSelectionProvider();
189
						if(provider != null) {
190
							ISelection sel = provider.getSelection();
191
							if(sel instanceof IStructuredSelection) {
192
								return ((IStructuredSelection)sel).getFirstElement();
193
							}
194
							return sel;
195
						}
196
					}
197
				}
198
			}
199
			
200
		}
201
		return null;
202
	}
203
	
204
	/**
205
	 * Returns the name of the currently selected context, or the empty string.
206
	 * This method can return null in the event the contributor of the selected context returns <code>null</code>
207
	 * as the resource name.
208
	 * @return the name of the currently selected context or the empty string. 
209
	 */
210
	public String getContextName() {
211
		Object o = getCurrentContext();
212
		if(o instanceof IAdaptable) {
213
			IResource resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
214
			if(resource != null) {
215
				return resource.getName();
216
			}
217
		}
218
		return ""; //$NON-NLS-1$
219
	}
220
	
221
	/**
222
	 * Returns if context launching is enabled
223
	 * @return if context launching is enabled
224
	 */
225
	public static boolean isContextLaunchEnabled() {
226
		return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
227
	}
228
	
229
	/**
230
	 * Returns the launch manager
231
	 * @return the launch manager
232
	 */
233
	protected LaunchManager getLaunchManager() {
234
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
235
	}
236
	
237
	/**
238
	 * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch)
239
	 */
240
	public void launchAdded(ILaunch launch) {
241
		if(fBackingResource != null) {
242
			try {
243
				getLaunchManager().setDefaultConfiguration(fBackingResource, launch.getLaunchConfiguration());
244
				getLaunchManager().removeLaunchListener(this);
245
			}
246
			catch(CoreException ce) {DebugUIPlugin.log(ce);}
247
		}
248
	}
249
250
	/**
251
	 * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch)
252
	 */
253
	public void launchChanged(ILaunch launch) {}
254
255
	/**
256
	 * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
257
	 */
258
	public void launchRemoved(ILaunch launch) {}
259
	
260
}
(-)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/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/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/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().run(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/launchConfigurations/LaunchShortcutSelectionDialog.java (+124 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
13
import java.util.List;
14
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.debug.core.DebugPlugin;
17
import org.eclipse.debug.core.ILaunchMode;
18
import org.eclipse.debug.internal.ui.DebugUIPlugin;
19
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
20
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
21
import org.eclipse.debug.internal.ui.SWTUtil;
22
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.jface.dialogs.IDialogSettings;
24
import org.eclipse.jface.viewers.ArrayContentProvider;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.events.SelectionListener;
28
import org.eclipse.swt.widgets.Button;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.dialogs.ListDialog;
33
34
import com.ibm.icu.text.MessageFormat;
35
36
/**
37
 * Specialized dialog for showing/selecting a specific launch shortcut extension, and allowing it
38
 * to be marked to be set as the default
39
 * 
40
 * @see {@link org.eclipse.debug.internal.ui.actions.ContextLaunchingAction}
41
 * 
42
 * @since 3.3
43
 * EXPERIMENTAL
44
 * CONTEXTLAUNCHING
45
 */
46
public class LaunchShortcutSelectionDialog extends ListDialog {
47
48
	private static final String DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_SHORTCUT_DIALOG"; //$NON-NLS-1$;
49
	
50
	/**
51
	 * The list of input for the dialog
52
	 */
53
	private String fMode = null;
54
	private IResource fResource = null;
55
	private boolean fChecked = false;
56
	
57
	/**
58
	 * Constructor
59
	 * @param input
60
	 * @param resource
61
	 * @param mode
62
	 */
63
	public LaunchShortcutSelectionDialog(List input, IResource resource, String mode) {
64
		super(DebugUIPlugin.getShell());
65
		setShellStyle(getShellStyle() | SWT.RESIZE);
66
		fResource = resource;
67
		fMode = mode;
68
		ILaunchMode lmode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fMode);
69
		String modename = fMode;
70
		if (lmode != null) {
71
			modename = DebugUIPlugin.removeAccelerators(lmode.getLabel());
72
		}
73
		setTitle(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_0, new String[] {modename}));
74
		setAddCancelButton(true);
75
		setMessage(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_1, new String[] {fMode, fResource.getName()}));
76
		setLabelProvider(new DefaultLabelProvider());
77
		setContentProvider(new ArrayContentProvider());
78
		setInput(input);
79
	}
80
81
	/**
82
	 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
83
	 */
84
	protected Control createContents(Composite parent) {
85
		Composite comp = (Composite) super.createContents(parent);
86
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_METHOD_DIALOG);
87
		return comp;
88
	}
89
90
	/**
91
	 * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
92
	 */
93
	protected IDialogSettings getDialogBoundsSettings() {
94
		IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
95
		IDialogSettings section = settings.getSection(DIALOG_SETTINGS);
96
		if (section == null) {
97
			section = settings.addNewSection(DIALOG_SETTINGS);
98
		} 
99
		return section;
100
	}
101
	
102
	/**
103
	 * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
104
	 */
105
	protected Control createDialogArea(Composite container) {
106
		Composite comp = (Composite) super.createDialogArea(container);
107
		Button butt = SWTUtil.createCheckButton(comp, MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_2, new String[] {fResource.getName()}), null, fChecked);
108
		butt.addSelectionListener(new SelectionListener() {
109
			public void widgetDefaultSelected(SelectionEvent e) {}
110
			public void widgetSelected(SelectionEvent e) {
111
				fChecked = ((Button)e.getSource()).getSelection();
112
			}
113
		});
114
		return comp;
115
	}
116
 
117
	/**
118
	 * Returns if the launched config from the selected shortcut should be made the default for the underlying resource
119
	 * @return if the launched config should be made the default
120
	 */
121
	public boolean makeDefault() {
122
		return fChecked;
123
	}
124
}
(-)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.properties (+2 lines)
Added Link Here
1
ContextRunner_0=The selected context could not be launched
2
OpenLaunchDialogAction_0=&Open Launch Dialog
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/DebugContextLaunchingAction.java (+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
}
(-)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

Return to bug 74480