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/DebugUIPreferenceInitializer.java (-5 / +10 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
		prefs.setDefault(IInternalDebugUIConstants.PREF_ALWAYS_RUN_LAST_LAUNCH, MessageDialogWithToggle.PROMPT);
55
		prefs.setDefault(IInternalDebugUIConstants.PREF_ALWAYS_RUN_PROJECT_CONFIGURATION, MessageDialogWithToggle.PROMPT);
56
		
54
		//View Management preference page
57
		//View Management preference page
55
		prefs.setDefault(IDebugUIConstants.PREF_MANAGE_VIEW_PERSPECTIVES, IDebugUIConstants.ID_DEBUG_PERSPECTIVE);
58
		prefs.setDefault(IDebugUIConstants.PREF_MANAGE_VIEW_PERSPECTIVES, IDebugUIConstants.ID_DEBUG_PERSPECTIVE);
56
		prefs.setDefault(IInternalDebugUIConstants.PREF_TRACK_VIEWS, true);
59
		prefs.setDefault(IInternalDebugUIConstants.PREF_TRACK_VIEWS, true);
Lines 111-120 Link Here
111
		prefs.setDefault(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE, 
114
		prefs.setDefault(IDebugUIConstants.PREF_DEFAULT_EBCDIC_CODE_PAGE, 
112
				IDebugPreferenceConstants.DEFAULT_EBCDIC_CP);
115
				IDebugPreferenceConstants.DEFAULT_EBCDIC_CP);
113
		
116
		
114
		if (MemoryViewUtil.isLinuxGTK())
117
		if (MemoryViewUtil.isLinuxGTK()) {
115
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, false);
118
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, false);
116
		else
119
		}
120
		else {
117
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, true);
121
			prefs.setDefault(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, true);
122
		}
118
		
123
		
119
		prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
124
		prefs.setDefault(IDebugPreferenceConstants.PREF_TABLE_RENDERING_PAGE_SIZE, IDebugPreferenceConstants.DEFAULT_PAGE_SIZE);
120
		prefs.setDefault(IDebugPreferenceConstants.PREF_RESET_MEMORY_BLOCK, IDebugPreferenceConstants.RESET_VISIBLE);
125
		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 / +31 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
     * CONTEXTLAUNCHING
210
     */ 
211
    public static final String PREF_USE_CONTEXTUAL_LAUNCH= IDebugUIConstants.PLUGIN_ID + ".UseContextualLaunch"; //$NON-NLS-1$
212
    
213
    /**
214
     * always/never/prompt preference indicating the action for the event when there is no context to launch during context launching 
215
     * 
216
     * @since 3.3
217
     *  
218
     *  CONTEXTLAUNCHING
219
     */
220
    public static final String PREF_ALWAYS_RUN_LAST_LAUNCH = IDebugUIConstants.PLUGIN_ID + ".AlwaysRunLastLaunch"; //$NON-NLS-1$
221
    
222
    /**
223
     * always/never/prompt preference indicating the action to take when an un-runnable file is the context
224
     * 
225
     * @since 3.3
226
     * 
227
     * CONTEXTLAUNCHING
228
     */
229
    public static final String PREF_ALWAYS_RUN_PROJECT_CONFIGURATION = IDebugUIConstants.PLUGIN_ID + ".ALwaysRunProjectConfiguration"; //$NON-NLS-1$
230
    
231
    /**
205
     * String preference controlling whether editors are saved before launching.
232
     * String preference controlling whether editors are saved before launching.
206
     * Valid values are either "always", "never", or "prompt".
233
     * Valid values are either "always", "never", or "prompt".
207
     * If "always" or "never", launching will save editors (or not) automatically.
234
     * 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$
239
    public static final String PREF_SAVE_DIRTY_EDITORS_BEFORE_LAUNCH = IDebugUIConstants.PLUGIN_ID + ".save_dirty_editors_before_launch"; //$NON-NLS-1$
213
    
240
    
214
    /**
241
    /**
215
     * Preference specifiying that all launches should be DEBUG_MODE if breakpoints exist in the workspace
242
     * Preference specifying that all launches should be DEBUG_MODE if breakpoints exist in the workspace
216
     * @since 3.0
243
     * @since 3.0
217
     */
244
     */
218
    public static final String PREF_RELAUNCH_IN_DEBUG_MODE = IDebugUIConstants.PLUGIN_ID + ".relaunch_in_debug_mode"; //$NON-NLS-1$
245
    public static final String PREF_RELAUNCH_IN_DEBUG_MODE = IDebugUIConstants.PLUGIN_ID + ".relaunch_in_debug_mode"; //$NON-NLS-1$
(-)ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java (-1 / +7 lines)
Lines 39-44 Link Here
39
import org.eclipse.debug.core.model.IVariable;
39
import org.eclipse.debug.core.model.IVariable;
40
import org.eclipse.debug.core.model.IWatchExpression;
40
import org.eclipse.debug.core.model.IWatchExpression;
41
import org.eclipse.debug.core.model.IWatchpoint;
41
import org.eclipse.debug.core.model.IWatchpoint;
42
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
42
import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
43
import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
43
import org.eclipse.debug.ui.IDebugUIConstants;
44
import org.eclipse.debug.ui.IDebugUIConstants;
44
import org.eclipse.jface.resource.ImageDescriptor;
45
import org.eclipse.jface.resource.ImageDescriptor;
Lines 69-74 Link Here
69
			}
70
			}
70
			return null;
71
			return null;
71
		}
72
		}
73
		if(element instanceof LaunchShortcutExtension) {
74
			return ((LaunchShortcutExtension)element).getImageDescriptor().createImage();
75
		}
72
		return DebugPluginImages.getImage(key);
76
		return DebugPluginImages.getImage(key);
73
	}
77
	}
74
	
78
	
Lines 155-161 Link Here
155
					DebugUIPlugin.log(e);
159
					DebugUIPlugin.log(e);
156
					return null;
160
					return null;
157
				}
161
				}
158
			} 
162
			}
159
		}
163
		}
160
		return null;		
164
		return null;		
161
	}
165
	}
Lines 206-211 Link Here
206
						name = delegate.getContributorName();
210
						name = delegate.getContributorName();
207
					}
211
					}
208
					label.append(name);
212
					label.append(name);
213
				} else if(element instanceof LaunchShortcutExtension) {
214
					label.append(((LaunchShortcutExtension)element).getLabel());
209
				} else if (element instanceof String) {
215
				} else if (element instanceof String) {
210
					label.append(element);
216
					label.append(element);
211
				} else {
217
				} else {
(-)plugin.xml (-8 / +127 lines)
Lines 155-160 Link Here
155
               id="org.eclipse.debug.ui.launchDelegatesKeywords">
155
               id="org.eclipse.debug.ui.launchDelegatesKeywords">
156
         </keywordReference>
156
         </keywordReference>
157
      </page>
157
      </page>
158
      <page
159
            category="org.eclipse.debug.ui.DebugPreferencePage"
160
            class="org.eclipse.debug.internal.ui.preferences.ContextLaunchingPreferencePage"
161
            id="org.eclipse.debug.ui.contextualLaunchingPage"
162
            name="%ContextualLaunchingPrefPage.name">
163
         <keywordReference
164
               id="org.eclipse.debug.ui.contextLaunching">
165
         </keywordReference>
166
      </page>
158
   </extension>
167
   </extension>
159
   <extension point="org.eclipse.ui.actionSets">
168
   <extension point="org.eclipse.ui.actionSets">
160
   		<actionSet
169
   		<actionSet
Lines 382-393 Link Here
382
               menubarPath="org.eclipse.ui.run/runGroup">
391
               menubarPath="org.eclipse.ui.run/runGroup">
383
         </action>
392
         </action>
384
         <action
393
         <action
385
               label="%RunWithConfigurationAction.label"
386
               style="pulldown"
387
               helpContextId="run_with_configuration_action_context"
388
               class="org.eclipse.debug.internal.ui.actions.RunAsAction"
394
               class="org.eclipse.debug.internal.ui.actions.RunAsAction"
395
               helpContextId="run_with_configuration_action_context"
396
               id="org.eclipse.debug.internal.ui.actions.RunWithConfigurationAction"
397
               label="%RunWithConfigurationAction.label"
389
               menubarPath="org.eclipse.ui.run/runGroup"
398
               menubarPath="org.eclipse.ui.run/runGroup"
390
               id="org.eclipse.debug.internal.ui.actions.RunWithConfigurationAction">
399
               style="pulldown">
391
         </action>
400
         </action>
392
         <action
401
         <action
393
               label="%RunHistoryMenuAction.label"
402
               label="%RunHistoryMenuAction.label"
Lines 874-880 Link Here
874
               id="org.eclipse.debug.ui.contextualLaunch.profile.submenu">
883
               id="org.eclipse.debug.ui.contextualLaunch.profile.submenu">
875
        </action>    
884
        </action>    
876
        <enablement>
885
        <enablement>
877
         	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
886
          <and>
887
          	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
888
          	<not>
889
          		<test property="org.eclipse.debug.ui.contextlaunch" />
890
          	</not>
891
          </and>
878
        </enablement>        
892
        </enablement>        
879
      </objectContribution>
893
      </objectContribution>
880
      <objectContribution
894
      <objectContribution
Lines 889-895 Link Here
889
               id="org.eclipse.debug.ui.contextualLaunch.debug.submenu">
903
               id="org.eclipse.debug.ui.contextualLaunch.debug.submenu">
890
         </action>
904
         </action>
891
         <enablement>
905
         <enablement>
892
         	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
906
          <and>
907
          	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
908
          	<not>
909
          		<test property="org.eclipse.debug.ui.contextlaunch" />
910
          	</not>
911
          </and>
893
         </enablement>     
912
         </enablement>     
894
       </objectContribution>    
913
       </objectContribution>    
895
       <objectContribution
914
       <objectContribution
Lines 904-913 Link Here
904
               id="org.eclipse.debug.ui.contextualLaunch.run.submenu">
923
               id="org.eclipse.debug.ui.contextualLaunch.run.submenu">
905
         </action>                  
924
         </action>                  
906
         <enablement>
925
         <enablement>
907
         	<test property="org.eclipse.debug.ui.launchable" value="run"/>
926
          <and>
927
          	<test property="org.eclipse.debug.ui.launchable" value="run"/>
928
          	<not>
929
          		<test property="org.eclipse.debug.ui.contextlaunch" />
930
          	</not>
931
          </and>
908
         </enablement>
932
         </enablement>
909
      </objectContribution>
933
      </objectContribution>
934
       <objectContribution
935
             id="org.eclipse.debug.ui.contextlaunch.debugas"
936
             objectClass="org.eclipse.core.runtime.IAdaptable">
937
          <action
938
                class="org.eclipse.debug.internal.ui.contextlaunching.DebugContextLaunchingAction"
939
                enablesFor="1"
940
                icon="icons/full/etool16/debug_exc.gif"
941
                id="org.eclipse.debug.ui.contextlaunch.debugas"
942
                label="%ContextLaunchingDebugMenu.name"
943
                menubarPath="additions"
944
                tooltip="%ContextLaunchingDebugMenu.tooltip">
945
          </action>
946
          <enablement>
947
          <and>
948
            <test
949
                  property="org.eclipse.debug.ui.resource"
950
                  />
951
          	<test
952
                 property="org.eclipse.debug.ui.contextlaunch"
953
                 />
954
          	<test property="org.eclipse.debug.ui.launchable" value="debug"/>
955
          </and>
956
         </enablement>
957
       </objectContribution>
958
       <objectContribution
959
             id="org.eclipse.debug.ui.contextlaunch.profileas"
960
             objectClass="org.eclipse.core.runtime.IAdaptable">
961
          <action
962
                class="org.eclipse.debug.internal.ui.contextlaunching.ProfileContextLaunchingAction"
963
                enablesFor="1"
964
                icon="icons/full/etool16/profile_exc.gif"
965
                id="org.eclipse.debug.ui.contextlaunch.profileas"
966
                label="%ContextLaunchingProfileMenu.name"
967
                menubarPath="additions"
968
                tooltip="%ContextLaunchingProfileMenu.tooltip">
969
          </action>
970
          <enablement>
971
          <and>
972
            <test
973
                  property="org.eclipse.debug.ui.resource"
974
                  />
975
          	<test property="org.eclipse.debug.ui.contextlaunch" />
976
          	<test property="org.eclipse.debug.ui.launchable" value="profile"/>
977
          </and>
978
         </enablement> 
979
       </objectContribution>
910
   <!-- console additions -->
980
   <!-- console additions -->
981
      <objectContribution
982
            id="org.eclipse.debug.ui.contextlaunch.runas"
983
            objectClass="org.eclipse.core.runtime.IAdaptable">
984
         <action
985
               class="org.eclipse.debug.internal.ui.contextlaunching.RunContextLaunchingAction"
986
               enablesFor="1"
987
               icon="icons/full/etool16/run_exc.gif"
988
               id="org.eclipse.debug.ui.contextlaunch.runas"
989
               label="%ContextLaunchingRunMenu.name"
990
               menubarPath="additions"
991
               tooltip="%ContextLaunchingRunMenu.tooltip">
992
         </action>
993
         <enablement>
994
          <and>
995
          	<test property="org.eclipse.debug.ui.contextlaunch" />
996
          	<test
997
                 property="org.eclipse.debug.ui.resource"
998
                 />
999
          	<test property="org.eclipse.debug.ui.launchable" value="run"/>
1000
          </and>
1001
         </enablement> 
1002
      </objectContribution>
911
      <viewerContribution
1003
      <viewerContribution
912
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
1004
             targetID="org.eclipse.debug.ui.ProcessConsoleType.#ContextMenu"
913
             id="org.eclipse.debug.ui.processConsoleContextMenu">
1005
             id="org.eclipse.debug.ui.processConsoleContextMenu">
Lines 1394-1399 Link Here
1394
            </or>
1486
            </or>
1395
         </enabledWhen>
1487
         </enabledWhen>
1396
      </page>
1488
      </page>
1489
      <page
1490
            class="org.eclipse.debug.internal.ui.preferences.RunDebugPropertiesPage"
1491
            id="org.eclipse.debug.ui.properties.defaultLaunchConfigurations"
1492
            name="%DefaultLaunchConfigurationsPropPage.name"
1493
            >
1494
         <enabledWhen>
1495
            <and>
1496
               <adapt
1497
                     type="org.eclipse.core.resources.IResource">
1498
               </adapt>
1499
               <test
1500
                     property="org.eclipse.debug.ui.contextlaunch"
1501
                     />
1502
               <test
1503
                     property="org.eclipse.debug.ui.contextlaunchable"
1504
                     >
1505
               </test>
1506
               <test
1507
                     property="org.eclipse.debug.ui.resource">
1508
               </test>
1509
            </and>
1510
         </enabledWhen>
1511
      </page>
1397
   </extension>
1512
   </extension>
1398
<!-- commands and their bindings
1513
<!-- commands and their bindings
1399
NOTE: 
1514
NOTE: 
Lines 2032-2038 Link Here
2032
      </propertyTester>
2147
      </propertyTester>
2033
	  <propertyTester
2148
	  <propertyTester
2034
			namespace="org.eclipse.debug.ui"
2149
			namespace="org.eclipse.debug.ui"
2035
			properties="launchable"
2150
			properties="launchable, resource, contextlaunch, contextlaunchable"
2036
			type="java.lang.Object"
2151
			type="java.lang.Object"
2037
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2152
			class="org.eclipse.debug.internal.ui.actions.LaunchablePropertyTester"
2038
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
2153
			id="org.eclipse.debug.ui.propertyTesters.launchable">		
Lines 2240-2245 Link Here
2240
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2355
             id="org.eclipse.debug.ui.launchDelegatesKeywords"
2241
             label="%preferenceKeywords.launchDelegates">
2356
             label="%preferenceKeywords.launchDelegates">
2242
       </keyword>
2357
       </keyword>
2358
       <keyword
2359
             id="org.eclipse.debug.ui.contextLaunching"
2360
             label="%preferenceKeywords.contextLaunching">
2361
       </keyword>
2243
    </extension>
2362
    </extension>
2244
    <extension
2363
    <extension
2245
          point="org.eclipse.ui.importWizards">
2364
          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 330-335 Link Here
330
preferenceKeywords.perspective=perspectives switching assign automatic run debug
343
preferenceKeywords.perspective=perspectives switching assign automatic run debug
331
preferenceKeywords.launchConfigurations=filters launch migration configurations run debug
344
preferenceKeywords.launchConfigurations=filters launch migration configurations run debug
332
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
346
preferenceKeywords.contextLaunching=run debug profile launch contextual delegate configuration execute
333
347
334
exportBreakpoints.label=E&xport Breakpoints...
348
exportBreakpoints.label=E&xport Breakpoints...
335
importBreakpoints.label=I&mport Breakpoints...
349
importBreakpoints.label=I&mport Breakpoints...
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties (+4 lines)
Lines 102-107 Link Here
102
PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4=Unable to open perspectives as specified by launch: {0}
102
PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4=Unable to open perspectives as specified by launch: {0}
103
PerspectiveManager_Unable_to_switch_to_perspective___0__2=Unable to open perspective: {0}
103
PerspectiveManager_Unable_to_switch_to_perspective___0__2=Unable to open perspective: {0}
104
LaunchShortcutExtension_Error_4=Error
104
LaunchShortcutExtension_Error_4=Error
105
LaunchShortcutSelectionDialog_0={0} As...
106
LaunchShortcutSelectionDialog_1=&Select how to {0} {1}: 
107
LaunchShortcutSelectionDialog_2=&Make generated settings the default for [{0}]
108
LaunchShortcutSelectionDialog_3=Ma&ke generated settings the default for project [{0}]
105
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
109
LaunchShortcutExtension_Unable_to_use_launch_shortcut_5=Unable to use launch shortcut
106
110
107
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
111
LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1=Edit launch configuration properties
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java (+8 lines)
Lines 106-111 Link Here
106
	public static String LaunchConfigurationTabGroupViewer_13;
106
	public static String LaunchConfigurationTabGroupViewer_13;
107
107
108
	public static String LaunchConfigurationView_0;
108
	public static String LaunchConfigurationView_0;
109
110
	public static String LaunchShortcutSelectionDialog_0;
111
112
	public static String LaunchShortcutSelectionDialog_1;
113
114
	public static String LaunchShortcutSelectionDialog_2;
115
116
	public static String LaunchShortcutSelectionDialog_3;
109
	public static String PerspectiveManager_Error_1;
117
	public static String PerspectiveManager_Error_1;
110
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
118
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
111
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
119
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-3 / +13 lines)
Lines 360-366 Link Here
360
	
360
	
361
	/**
361
	/**
362
	 * Creates some help text for the tab group launch types
362
	 * Creates some help text for the tab group launch types
363
	 * @param parent thep arent composite
363
	 * @param parent the parent composite
364
	 * @since 3.2
364
	 * @since 3.2
365
	 */
365
	 */
366
	private void createGettingStarted(Composite parent) {
366
	private void createGettingStarted(Composite parent) {
Lines 492-498 Link Here
492
		ILaunchConfigurationTab[] tabs = getTabs();
492
		ILaunchConfigurationTab[] tabs = getTabs();
493
		if (tabs != null) {
493
		if (tabs != null) {
494
			// update the working copy from the active tab
494
			// update the working copy from the active tab
495
			boolean newwc = !getWorkingCopy().isDirty();
495
			getActiveTab().performApply(getWorkingCopy());
496
			getActiveTab().performApply(getWorkingCopy());
497
			if(getOriginal() instanceof ILaunchConfigurationWorkingCopy && newwc) {
498
				try {
499
					getWorkingCopy().doSave();
500
				} 
501
				catch (CoreException e) {DebugUIPlugin.log(e);}
502
			}
496
			updateButtons();
503
			updateButtons();
497
			// update error ticks
504
			// update error ticks
498
			CTabItem item = null;
505
			CTabItem item = null;
Lines 948-953 Link Here
948
		if (workingCopy == null) {
955
		if (workingCopy == null) {
949
			return false;
956
			return false;
950
		}
957
		}
958
		if(workingCopy.getParent() != null) {
959
			return !workingCopy.getParent().contentsEqual(workingCopy);
960
		}
951
		// Working copy hasn't been saved
961
		// Working copy hasn't been saved
952
		if (workingCopy.getOriginal() == null) {
962
		if (workingCopy.getOriginal() == null) {
953
			return true;
963
			return true;
Lines 1111-1117 Link Here
1111
	/**
1121
	/**
1112
	 * Determines if the currently showing launch configuration has multiple launch delegates for the same mode set, but does not care
1122
	 * Determines if the currently showing launch configuration has multiple launch delegates for the same mode set, but does not care
1113
	 * if there has been a default selected yet or not
1123
	 * if there has been a default selected yet or not
1114
	 * @return true if the current launch configuraiton has multiple launch delegates, false otherwise
1124
	 * @return true if the current launch configuration has multiple launch delegates, false otherwise
1115
	 */
1125
	 */
1116
	private boolean hasMultipleDelegates() {
1126
	private boolean hasMultipleDelegates() {
1117
		ILaunchConfiguration config = getWorkingCopy();
1127
		ILaunchConfiguration config = getWorkingCopy();
Lines 1354-1361 Link Here
1354
		try {
1364
		try {
1355
			if(fTabGroup != null) {
1365
			if(fTabGroup != null) {
1356
				fTabGroup.initializeFrom(fOriginal);
1366
				fTabGroup.initializeFrom(fOriginal);
1357
				fWorkingCopy = fOriginal.getWorkingCopy();
1358
				fNameWidget.setText(fOriginal.getName());
1367
				fNameWidget.setText(fOriginal.getName());
1368
				fWorkingCopy = fOriginal.getWorkingCopy();
1359
				refreshStatus();
1369
				refreshStatus();
1360
			}
1370
			}
1361
		} 
1371
		} 
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java (-1 / +4 lines)
Lines 851-857 Link Here
851
	 * @return the shell title
851
	 * @return the shell title
852
	 */
852
	 */
853
	protected String getShellTitle() {
853
	protected String getShellTitle() {
854
		String title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel());
854
		String title = null;
855
		if(getLaunchGroup() != null) {
856
			 title = DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel());
857
		}
855
		if (title == null) {
858
		if (title == null) {
856
			title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; 
859
			title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; 
857
		}
860
		}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java (-4 / +52 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 311-317 Link Here
311
	 * @return the most recent, un-filtered launch
314
	 * @return the most recent, un-filtered launch
312
	 */
315
	 */
313
	public ILaunchConfiguration getFilteredLastLaunch(String groupId) {
316
	public ILaunchConfiguration getFilteredLastLaunch(String groupId) {
314
		LaunchHistory history = getLaunchHistory(groupId);if (history != null) {
317
		LaunchHistory history = getLaunchHistory(groupId);
318
		if (history != null) {
315
			ILaunchConfiguration[] filterConfigs = filterConfigs(history.getHistory());
319
			ILaunchConfiguration[] filterConfigs = filterConfigs(history.getHistory());
316
			if (filterConfigs.length > 0) {
320
			if (filterConfigs.length > 0) {
317
				return filterConfigs[0];
321
				return filterConfigs[0];
Lines 594-604 Link Here
594
		}
598
		}
595
		return fLaunchShortcuts;
599
		return fLaunchShortcuts;
596
	}
600
	}
601
602
	/**
603
	 * Returns a listing of all of the <code>ILaunchConfigurationType</code>s that apply to the currently
604
	 * specified <code>IResource</code>.
605
	 * 
606
	 * @param resource the resource context
607
	 * @return a listing of applicable <code>ILaunchConfigurationType</code>s, or an empty list, never <code>null</code>
608
	 * @since 3.3
609
	 * EXPERIMENTAL
610
	 * CONTEXTLAUNCHING
611
	 */
612
	public List getApplicableConfigurationTypes(IResource resource) {
613
		List types = new ArrayList();
614
		try {
615
			List exts = getLaunchShortcuts();
616
			LaunchShortcutExtension ext = null;
617
			List list = new ArrayList();
618
			list.add(resource);
619
			IEvaluationContext context = new EvaluationContext(null, list);
620
			context.addVariable("selection", list); //$NON-NLS-1$
621
			HashSet set = new HashSet();
622
			for(Iterator iter = exts.iterator(); iter.hasNext();) {
623
				ext = (LaunchShortcutExtension) iter.next();
624
				if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
625
					set.addAll(ext.getAssociatedConfigurationTypes());
626
				}
627
			}
628
			LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
629
			ILaunchConfigurationType type = null;
630
			for(Iterator iter = set.iterator(); iter.hasNext();) {
631
				type = lm.getLaunchConfigurationType((String)iter.next());
632
				if(type != null) { 
633
					if(!types.contains(type) && type.isPublic() && !"org.eclipse.ui.externaltools.builder".equals(type.getCategory())) { //$NON-NLS-1$
634
						types.add(type);
635
					}
636
				}
637
			}
638
		}
639
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
640
		return types;
641
	}
597
	
642
	
598
	/**
643
	/**
599
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
644
	 * Returns a listing of all applicable <code>LaunchShortcutExtension</code>s for the given
600
	 * launch configuration type id.
645
	 * launch configuration type id.
601
	 * @param typeid the id of the launch configuraiton
646
	 * @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
647
	 * @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>
648
	 * type id or an empty list, never <code>null</code>
604
	 * 
649
	 * 
Lines 695-700 Link Here
695
	 * @since 3.3
740
	 * @since 3.3
696
	 * 
741
	 * 
697
	 * EXPERIMENTAL
742
	 * EXPERIMENTAL
743
	 * CONTEXTLAUNCHING
698
	 */
744
	 */
699
	public LaunchShortcutExtension getLaunchShortcut(String id) {
745
	public LaunchShortcutExtension getLaunchShortcut(String id) {
700
		loadLaunchShortcuts();
746
		loadLaunchShortcuts();
Lines 800-805 Link Here
800
	 * @since 3.3
846
	 * @since 3.3
801
	 * 
847
	 * 
802
	 * EXPERIMENTAL
848
	 * EXPERIMENTAL
849
	 * CONTEXTLAUNCHING
803
	 */
850
	 */
804
	public void setDefaultLaunchShortcut(IResource resource, LaunchShortcutExtension shortcut) throws CoreException {
851
	public void setDefaultLaunchShortcut(IResource resource, LaunchShortcutExtension shortcut) throws CoreException {
805
		IProject project = resource.getProject();
852
		IProject project = resource.getProject();
Lines 826-837 Link Here
826
	 * 
873
	 * 
827
	 * @see {@link ILaunchManager#getDefaultConfiguration(IResource)}
874
	 * @see {@link ILaunchManager#getDefaultConfiguration(IResource)}
828
	 * @param resource the resource
875
	 * @param resource the resource
829
	 * @return the corresponding <code>LaunchShortcutExtension</code> for the guven <code>IResource</code>,
876
	 * @return the corresponding <code>LaunchShortcutExtension</code> for the given <code>IResource</code>,
830
	 * or <code>null</code> if there is not one.
877
	 * or <code>null</code> if there is not one.
831
	 * 
878
	 * 
832
	 * @since 3.3
879
	 * @since 3.3
833
	 * 
880
	 * 
834
	 * EXPERIMENTAL
881
	 * EXPERIMENTAL
882
	 * CONTEXTLAUNCHING
835
	 */
883
	 */
836
	public LaunchShortcutExtension getDefaultLaunchShortcut(IResource resource) {
884
	public LaunchShortcutExtension getDefaultLaunchShortcut(IResource resource) {
837
		IProject project = resource.getProject();
885
		IProject project = resource.getProject();
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java (+17 lines)
Lines 349-353 Link Here
349
		Collections.sort(names);
349
		Collections.sort(names);
350
		return names;
350
		return names;
351
	}
351
	}
352
	
353
	/**
354
	 * Returns the label of the mode id with all accelerators removed
355
	 * @param modeid the id of the mode i.e. 'run'
356
	 * @return the formatted label of the specified mode id with all accelerators removed, or <code>null</code> if no label is available
357
	 * @since 3.3
358
	 */
359
	public String getLaunchModeLabel(String modeid) {
360
		String mode = null;
361
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
362
		ILaunchMode lmode = manager.getLaunchMode(modeid);
363
		if(lmode != null) {
364
			return lmode.getLabel();
365
		}
366
		return mode;
367
	}
368
	
352
}
369
}
353
370
(-)ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties (+17 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.
21
ContextLaunchingPreferencePage_0=Launch previous when no context available
22
ContextLaunchingPreferencePage_1=Launch project of un-runnable context
19
ConsolePreferencePage_Console_width=&Maximum character width:
23
ConsolePreferencePage_Console_width=&Maximum character width:
20
ConsolePreferencePage_Limit_console_output_1=&Limit console output
24
ConsolePreferencePage_Limit_console_output_1=&Limit console output
21
ConsolePreferencePage_Console_buffer_size__characters___2=Console &buffer size (characters):
25
ConsolePreferencePage_Console_buffer_size__characters___2=Console &buffer size (characters):
Lines 127-129 Link Here
127
LaunchDelegatesPreferencePage_4=Launcher Description
131
LaunchDelegatesPreferencePage_4=Launcher Description
128
LaunchPerspectivePreferencePage_0=There is no perspective information available to change.
132
LaunchPerspectivePreferencePage_0=There is no perspective information available to change.
129
LaunchPerspectivePreferencePage_1=The selected types/launchers do not have any common mode sets.
133
LaunchPerspectivePreferencePage_1=The selected types/launchers do not have any common mode sets.
134
DefaultLaunchConfigurationsPropertiesPage_0=This page allows you to select a default way to launch the currently selected resource.
135
DefaultLaunchConfigurationsPropertiesPage_1=&Select default configuration for {0}:
136
DefaultLaunchConfigurationsPropertiesPage_2=&New...
137
DefaultLaunchConfigurationsPropertiesPage_3=Create new launch configuration
138
DefaultLaunchConfigurationsPropertiesPage_4=Du&plicate
139
DefaultLaunchConfigurationsPropertiesPage_5=Duplicate selected launch configuration
140
DefaultLaunchConfigurationsPropertiesPage_6=&Edit...
141
DefaultLaunchConfigurationsPropertiesPage_7=Edit selected launch configuration
142
DefaultLaunchConfigurationsPropertiesPage_8=De&lete
143
DefaultLaunchConfigurationsPropertiesPage_9=Delete selected launch configuration
144
DefaultLaunchConfigurationsPropertiesPage_10=Configuration must be located in project {0}
145
DefaultLaunchConfigurationsPropertiesPage_11=Select Configuration Type
146
DefaultLaunchConfigurationsPropertiesPage_12=&Select the configuration type to create:
(-)ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java (+34 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 ContextLaunchingPreferencePage_0;
36
37
	public static String ContextLaunchingPreferencePage_1;
38
39
	public static String ContextualLaunchPreferencePage_0;
40
41
	public static String ContextualLaunchPreferencePage_1;
42
35
	public static String DebugPreferencePage_1;
43
	public static String DebugPreferencePage_1;
36
	public static String DebugPreferencePage_2;
44
	public static String DebugPreferencePage_2;
37
45
Lines 51-56 Link Here
51
	public static String DebugPreferencePage_26;
59
	public static String DebugPreferencePage_26;
52
	public static String DebugPreferencePage_27;
60
	public static String DebugPreferencePage_27;
53
61
62
	public static String DefaultLaunchConfigurationsPropertiesPage_0;
63
64
	public static String DefaultLaunchConfigurationsPropertiesPage_1;
65
66
	public static String DefaultLaunchConfigurationsPropertiesPage_10;
67
68
	public static String DefaultLaunchConfigurationsPropertiesPage_11;
69
70
	public static String DefaultLaunchConfigurationsPropertiesPage_12;
71
72
	public static String DefaultLaunchConfigurationsPropertiesPage_2;
73
74
	public static String DefaultLaunchConfigurationsPropertiesPage_3;
75
76
	public static String DefaultLaunchConfigurationsPropertiesPage_4;
77
78
	public static String DefaultLaunchConfigurationsPropertiesPage_5;
79
80
	public static String DefaultLaunchConfigurationsPropertiesPage_6;
81
82
	public static String DefaultLaunchConfigurationsPropertiesPage_7;
83
84
	public static String DefaultLaunchConfigurationsPropertiesPage_8;
85
86
	public static String DefaultLaunchConfigurationsPropertiesPage_9;
87
54
	public static String LaunchDelegatesPreferencePage_0;
88
	public static String LaunchDelegatesPreferencePage_0;
55
89
56
	public static String LaunchDelegatesPreferencePage_1;
90
	public static String LaunchDelegatesPreferencePage_1;
(-)ui/org/eclipse/debug/ui/actions/AbstractLaunchToolbarAction.java (-8 / +21 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
16
import org.eclipse.debug.internal.ui.contextlaunching.ContextLaunchingToolbarAction;
17
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
16
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
18
import org.eclipse.debug.internal.ui.launchConfigurations.OrganizeFavoritesAction;
17
import org.eclipse.debug.ui.DebugUITools;
19
import org.eclipse.debug.ui.DebugUITools;
18
import org.eclipse.jface.action.IAction;
20
import org.eclipse.jface.action.IAction;
Lines 54-61 Link Here
54
		if (menu.getItemCount() > 0) {
56
		if (menu.getItemCount() > 0) {
55
			addSeparator(menu);
57
			addSeparator(menu);
56
		}
58
		}
57
59
		if(!getLaunchGroupIdentifier().equals("org.eclipse.ui.externaltools.launchGroup")) { //$NON-NLS-1$
58
		addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
60
			if(ContextRunner.isContextLaunchEnabled()) {
61
				addToMenu(menu, new ContextLaunchingToolbarAction(getLaunchGroupIdentifier()), -1);
62
			}
63
			else {
64
				addToMenu(menu, new LaunchShortcutsAction(getLaunchGroupIdentifier()), -1);
65
			}
66
		}
59
		addToMenu(menu, getOpenDialogAction(), -1);
67
		addToMenu(menu, getOpenDialogAction(), -1);
60
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
68
		addToMenu(menu, new OrganizeFavoritesAction(getLaunchGroupIdentifier()), -1);
61
	}
69
	}
Lines 67-84 Link Here
67
	protected IAction getOpenDialogAction() {
75
	protected IAction getOpenDialogAction() {
68
		return new OpenLaunchDialogAction(getLaunchGroupIdentifier());
76
		return new OpenLaunchDialogAction(getLaunchGroupIdentifier());
69
	}
77
	}
70
78
	
71
	/**
79
	/**
72
	 * Launch the last launch, or open the launch config dialog if none.
80
	 * Launch the last launch, or open the launch config dialog if none.
73
	 * 
81
	 * 
74
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
82
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
75
	 */
83
	 */
76
	public void run(IAction action) {
84
	public void run(IAction action) {
77
		ILaunchConfiguration configuration = getLastLaunch();
85
		if(ContextRunner.isContextLaunchEnabled()) {
78
		if (configuration == null) {
86
			ContextRunner.getDefault().launch(getMode());
79
			DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier());
87
		}
80
		} else {
88
		else {
81
			DebugUITools.launch(configuration, getMode());
89
			ILaunchConfiguration configuration = getLastLaunch();
90
			if (configuration == null) {
91
				DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(), getLaunchGroupIdentifier());
92
			} else {
93
				DebugUITools.launch(configuration, getMode());
94
			}
82
		}
95
		}
83
	}	
96
	}	
84
}
97
}
(-)ui/org/eclipse/debug/ui/actions/ContextualLaunchAction.java (-50 / +9 lines)
Lines 28-33 Link Here
28
import org.eclipse.debug.internal.ui.DebugUIPlugin;
28
import org.eclipse.debug.internal.ui.DebugUIPlugin;
29
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
29
import org.eclipse.debug.internal.ui.actions.LaunchShortcutAction;
30
import org.eclipse.debug.internal.ui.actions.SharedLaunchConfigAction;
30
import org.eclipse.debug.internal.ui.actions.SharedLaunchConfigAction;
31
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
31
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
32
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
32
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
33
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
33
import org.eclipse.debug.ui.DebugUITools;
34
import org.eclipse.debug.ui.DebugUITools;
Lines 53-59 Link Here
53
 * An action delegate that builds a context menu with applicable launch shortcuts
54
 * An action delegate that builds a context menu with applicable launch shortcuts
54
 * for a specific launch mode.
55
 * for a specific launch mode.
55
 * <p>
56
 * <p>
56
 * This class can be subclassed and contributed as an object contribution pop-up
57
 * 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
58
 * menu extension action. When invoked, it becomes a sub-menu that dynamically
58
 * builds a list of applicable launch shortcuts for the current selection.
59
 * 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.
60
 * Each launch shortcut may have optional information to support a context menu action.
Lines 167-215 Link Here
167
		}
168
		}
168
		action.setEnabled(false);
169
		action.setEnabled(false);
169
	}
170
	}
170
171
	/**
172
	 * This method is used to determine if the selected object is in fact a shared launch
173
	 * configuration that can be launched
174
	 * @return true if the item is a shared ocnfig , false otherwise
175
	 * @since 3.3
176
	 */
177
	private boolean isSharedConfig(Object receiver) {
178
		if(receiver instanceof IFile) {
179
			IFile file = (IFile) receiver;
180
			String ext = file.getFileExtension();
181
			if(ext == null) {
182
				return false;
183
			}
184
			if(ext.equals("launch")) { //$NON-NLS-1$
185
				ILaunchConfiguration config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(file);
186
				if(config != null && config.exists()) {
187
					return true;
188
				}
189
			}
190
		}
191
		return false;
192
	}
193
	
194
	/**
195
	 * This method return if the editor input is from a shared java launch configuration file or not
196
	 * @param receiver the editor input to examine
197
	 * @return true if the editor input is from a shared launch configuration file, false otherwise.
198
	 */
199
	private boolean isSharedConfigEditorInput(Object receiver) {
200
		if(receiver instanceof IFileEditorInput) {
201
			IFileEditorInput input = (IFileEditorInput) receiver;
202
			return isSharedConfig(input.getFile());
203
		}
204
		return false;
205
	}
206
	
171
	
207
	/**
172
	/**
208
	 * Returns the launch manager
173
	 * Returns the launch manager
209
	 * @return the launch manager
174
	 * @return the launch manager
210
	 * @since 3.3
175
	 * @since 3.3
211
	 */
176
	 */
212
	private ILaunchManager getLaunchManager() {
177
	protected ILaunchManager getLaunchManager() {
213
		return DebugPlugin.getDefault().getLaunchManager();
178
		return DebugPlugin.getDefault().getLaunchManager();
214
	}
179
	}
215
	
180
	
Lines 240-266 Link Here
240
		if (fSelection == null) {
205
		if (fSelection == null) {
241
			return;
206
			return;
242
		}
207
		}
243
		
244
		IEvaluationContext context = createContext();
208
		IEvaluationContext context = createContext();
245
		
246
		//add in any selected shared configs before the rest of the items to launch as
209
		//add in any selected shared configs before the rest of the items to launch as
247
		//feature fix for 
210
		//feature fix for 
211
		//CONTEXTLAUNCHING
248
		if(!fSelection.isEmpty()) {
212
		if(!fSelection.isEmpty()) {
249
			Object obj = fSelection.getFirstElement();
213
			Object obj = fSelection.getFirstElement();
250
			if(isSharedConfig(obj)) {
214
			if(ContextRunner.getDefault().isSharedConfig(obj) != null) {
251
				prepareSharedConfigAction((IFile)obj, menu);
215
				prepareSharedConfigAction((IFile)obj, menu);
252
				new MenuItem(menu, SWT.SEPARATOR);
216
				new MenuItem(menu, SWT.SEPARATOR);
253
			} 
217
			} 
254
			else if(isSharedConfigEditorInput(obj)) {
218
			else if(ContextRunner.getDefault().isSharedConfigEditorInput(obj) != null) {
255
				prepareSharedConfigAction(((IFileEditorInput) obj).getFile(), menu);
219
				prepareSharedConfigAction(((IFileEditorInput) obj).getFile(), menu);
256
				new MenuItem(menu, SWT.SEPARATOR);
220
				new MenuItem(menu, SWT.SEPARATOR);
257
			}
221
			}
258
		}
222
		}
259
		
223
		List allShortCuts = getLaunchConfigurationManager().getLaunchShortcuts();
260
		// gather all shortcuts and run their filters so that we only run the
261
		// filters one time for each shortcut. Running filters can be expensive.
262
		// Also, only *LOADED* plug-ins get their filters run.
263
		List /* <LaunchShortcutExtension> */ allShortCuts = getLaunchConfigurationManager().getLaunchShortcuts();
264
		Iterator iter = allShortCuts.iterator();
224
		Iterator iter = allShortCuts.iterator();
265
		List filteredShortCuts = new ArrayList(10);
225
		List filteredShortCuts = new ArrayList(10);
266
		while (iter.hasNext()) {
226
		while (iter.hasNext()) {
Lines 269-277 Link Here
269
				if (!WorkbenchActivityHelper.filterItem(ext) && isApplicable(ext, context)) {
229
				if (!WorkbenchActivityHelper.filterItem(ext) && isApplicable(ext, context)) {
270
					filteredShortCuts.add(ext);
230
					filteredShortCuts.add(ext);
271
				}
231
				}
272
			} catch (CoreException e) {
232
			} 
273
				// not supported
233
			catch (CoreException e) {DebugUIPlugin.log(e);}
274
			}
275
		}
234
		}
276
		iter = filteredShortCuts.iterator();
235
		iter = filteredShortCuts.iterator();
277
		int accelerator = 1;
236
		int accelerator = 1;
(-)ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java (-36 / +74 lines)
Lines 16-34 Link Here
16
import org.eclipse.debug.core.ILaunchConfigurationType;
16
import org.eclipse.debug.core.ILaunchConfigurationType;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
18
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.contextlaunching.ContextMessages;
21
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
19
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
20
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
23
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
21
import org.eclipse.debug.ui.DebugUITools;
24
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.jface.action.Action;
25
import org.eclipse.jface.action.Action;
23
import org.eclipse.jface.action.IAction;
26
import org.eclipse.jface.action.IAction;
27
import org.eclipse.jface.util.IPropertyChangeListener;
28
import org.eclipse.jface.util.PropertyChangeEvent;
24
import org.eclipse.jface.viewers.ISelection;
29
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.IStructuredSelection;
30
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.StructuredSelection;
31
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.jface.window.Window;
32
import org.eclipse.jface.window.Window;
33
import org.eclipse.swt.widgets.Event;
34
import org.eclipse.ui.IActionDelegate2;
28
import org.eclipse.ui.IWorkbenchWindow;
35
import org.eclipse.ui.IWorkbenchWindow;
29
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
36
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
30
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
31
38
39
import com.ibm.icu.text.MessageFormat;
40
32
/**
41
/**
33
 * Opens the launch configuration dialog in the context of a launch group.
42
 * Opens the launch configuration dialog in the context of a launch group.
34
 * <p>
43
 * <p>
Lines 37-43 Link Here
37
 * </p>
46
 * </p>
38
 * @since 2.1
47
 * @since 2.1
39
 */
48
 */
40
public class OpenLaunchDialogAction extends Action implements IWorkbenchWindowActionDelegate {
49
public class OpenLaunchDialogAction extends Action implements IPropertyChangeListener, IActionDelegate2, IWorkbenchWindowActionDelegate {
41
50
42
	/**
51
	/**
43
	 * Launch group identifier
52
	 * Launch group identifier
Lines 45-53 Link Here
45
	private String fIdentifier;
54
	private String fIdentifier;
46
	
55
	
47
	/**
56
	/**
48
	 * The action used to render this delegate.
57
	 * The underlying <code>IAction</code> for this delegate
49
	 */
58
	 */
50
	private IAction fAction;	
59
	private IAction fBackingAction = null;
51
	
60
	
52
	/**
61
	/**
53
	 * Constructs an action that opens the launch configuration dialog in
62
	 * Constructs an action that opens the launch configuration dialog in
Lines 57-70 Link Here
57
	 */
66
	 */
58
	public OpenLaunchDialogAction(String identifier) {
67
	public OpenLaunchDialogAction(String identifier) {
59
		fIdentifier = identifier;
68
		fIdentifier = identifier;
60
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(identifier);
69
		updateActionState();
61
		if (extension != null) {
62
			setText(extension.getLabel() + "..."); //$NON-NLS-1$
63
			setImageDescriptor(extension.getImageDescriptor());
64
		}
65
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
66
	}
70
	}
67
71
	
68
	/**
72
	/**
69
	 * @see org.eclipse.jface.action.IAction#run()
73
	 * @see org.eclipse.jface.action.IAction#run()
70
	 */
74
	 */
Lines 80-123 Link Here
80
		int result = DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
84
		int result = DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), selection, fIdentifier);
81
		notifyResult(result == Window.OK);
85
		notifyResult(result == Window.OK);
82
	}
86
	}
83
	/**
87
	
84
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
88
	/* (non-Javadoc)
85
	 */
89
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
86
	public void dispose() {
87
	}
88
89
	/**
90
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
91
	 */
90
	 */
92
	public void init(IWorkbenchWindow window) {
91
	public void runWithEvent(IAction action, Event event) {
92
		run();
93
	}
93
	}
94
94
	
95
	/**
95
	/* (non-Javadoc)
96
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
96
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
97
	 */
97
	 */
98
	public void run(IAction action) {
98
	public void run(IAction action) {
99
		run();
99
		run();
100
	}
100
	}
101
101
	
102
	/**
102
	/**
103
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
103
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
104
	 */
104
	 */
105
	public void selectionChanged(IAction action, ISelection selection) {
105
	public void dispose() {
106
		if (fAction == null) {
106
		DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
107
			initialize(action);
107
	}
108
		} 		
108
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
111
	 */
112
	public void init(IAction action) {
113
		fBackingAction = action;
114
		DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
115
		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION);
116
		updateActionState();
109
	}
117
	}
110
	
118
	
111
	/**
119
	/**
112
	 * Set the enabled state of the underlying action based on whether there are any
120
	 * Updates the action state (label and image descriptor)
113
	 * registered launch configuration types that understand how to launch in the
121
	 * @since 3.3
114
	 * mode of this action.
122
	 * CONTEXTLAUNCHING
115
	 */
123
	 */
116
	private void initialize(IAction action) {
124
	protected void updateActionState() {
117
		fAction = action;
125
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(fIdentifier);
118
		action.setEnabled(existsConfigTypesForMode());	
126
		if(fBackingAction == null) {
119
	}	
127
			//there is no backing action, like a toolbar action delegate
120
128
			if(ContextRunner.isContextLaunchEnabled() && !"org.eclipse.ui.externaltools.launchGroup".equals(fIdentifier)) { //$NON-NLS-1$
129
				setText(MessageFormat.format(ContextMessages.OpenLaunchDialogAction_0, new String[] {extension.getLabel()}));
130
				setImageDescriptor(null);
131
			}
132
			else {
133
				setText(extension.getLabel() + "..."); //$NON-NLS-1$
134
				setImageDescriptor(extension.getImageDescriptor());
135
			}
136
			setEnabled(existsConfigTypesForMode());
137
		}
138
	}
139
	
121
	/**
140
	/**
122
	 * Return whether there are any registered launch configuration types for
141
	 * Return whether there are any registered launch configuration types for
123
	 * the mode of this action.
142
	 * the mode of this action.
Lines 136-141 Link Here
136
		return false;
155
		return false;
137
	}
156
	}
138
	
157
	
158
	/* (non-Javadoc)
159
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
160
	 */
161
	public void init(IWorkbenchWindow window) {}
162
	
163
	/* (non-Javadoc)
164
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
165
	 */
166
	public void propertyChange(PropertyChangeEvent event) {
167
		if (IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH.equals(event.getProperty())){
168
			updateActionState();
169
		}
170
	}
171
	
172
	/**
173
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
174
	 */
175
	public void selectionChanged(IAction action, ISelection selection) {}
176
	
139
	/**
177
	/**
140
	 * Returns the launch mode for this action.
178
	 * Returns the launch mode for this action.
141
	 * 
179
	 * 
(-)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/actions/LaunchablePropertyTester.java (-5 / +39 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-18 Link Here
11
package org.eclipse.debug.internal.ui.actions;
11
package org.eclipse.debug.internal.ui.actions;
12
12
13
import org.eclipse.core.expressions.PropertyTester;
13
import org.eclipse.core.expressions.PropertyTester;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.debug.internal.ui.DebugUIPlugin;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
16
import org.eclipse.debug.ui.actions.ILaunchable;
21
import org.eclipse.debug.ui.actions.ILaunchable;
17
22
18
/**
23
/**
Lines 20-35 Link Here
20
 */
25
 */
21
public class LaunchablePropertyTester extends PropertyTester {
26
public class LaunchablePropertyTester extends PropertyTester {
22
27
23
	/* (non-Javadoc)
28
	/**
24
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
29
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
25
	 */
30
	 */
26
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
31
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
27
		if (property.equals("launchable")) { //$NON-NLS-1$
32
		if ("launchable".equals(property)) { //$NON-NLS-1$
28
			if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
33
				if (DebugUIPlugin.getDefault().getLaunchConfigurationManager().launchModeAvailable((String)expectedValue)) {
29
				return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
34
					return Platform.getAdapterManager().hasAdapter(receiver, ILaunchable.class.getName());
35
				}
36
		}
37
		if("resource".equals(property)) { //$NON-NLS-1$
38
			IResource res = getResource(receiver);
39
			if(res != null) {
40
				return res.isAccessible();
30
			}
41
			}
31
		}
42
		}
43
		if("contextlaunch".equals(property)) { //$NON-NLS-1$
44
			return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
45
		}
46
		if("contextlaunchable".equals(property)) { //$NON-NLS-1$
47
			try {
48
				return ContextRunner.getDefault().getLaunchShortcuts(getResource(receiver)).size() > 0 && ContextRunner.getDefault().isSharedConfig(receiver) == null;
49
			} 
50
			catch (CoreException e) {return false;}
51
		}
32
		return false;
52
		return false;
33
	}
53
	}
34
54
55
	/**
56
	 * Returns the resource this property page is open on.
57
	 * 
58
	 * @return resource
59
	 */
60
	protected IResource getResource(Object element) {
61
		IResource resource = null;
62
		if (element instanceof IResource) {
63
			resource = (IResource) element;
64
		} else if (element instanceof IAdaptable) {
65
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
66
		}
67
		return resource;
68
	}
35
}
69
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java (+487 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui.contextlaunching;
2
3
import java.util.ArrayList;
4
import java.util.Iterator;
5
import java.util.List;
6
7
import org.eclipse.core.expressions.EvaluationContext;
8
import org.eclipse.core.expressions.IEvaluationContext;
9
import org.eclipse.core.resources.IFile;
10
import org.eclipse.core.resources.IProject;
11
import org.eclipse.core.resources.IResource;
12
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.debug.core.DebugPlugin;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchListener;
18
import org.eclipse.debug.internal.core.LaunchManager;
19
import org.eclipse.debug.internal.ui.DebugUIPlugin;
20
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
21
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutExtension;
23
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchShortcutSelectionDialog;
24
import org.eclipse.debug.ui.DebugUITools;
25
import org.eclipse.debug.ui.ILaunchGroup;
26
import org.eclipse.jface.dialogs.IDialogConstants;
27
import org.eclipse.jface.dialogs.MessageDialog;
28
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
29
import org.eclipse.jface.text.ITextSelection;
30
import org.eclipse.jface.viewers.ISelection;
31
import org.eclipse.jface.viewers.ISelectionProvider;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.jface.viewers.StructuredSelection;
34
import org.eclipse.jface.window.Window;
35
import org.eclipse.ui.IEditorPart;
36
import org.eclipse.ui.IFileEditorInput;
37
import org.eclipse.ui.IWorkbenchPage;
38
import org.eclipse.ui.IWorkbenchPart;
39
import org.eclipse.ui.IWorkbenchPartSite;
40
import org.eclipse.ui.IWorkbenchWindow;
41
42
import com.ibm.icu.text.MessageFormat;
43
44
/**
45
 * Static runner for context launching to provide the base capability of context 
46
 * launching to more than one form of action (drop down, toolbar, view, etc)
47
 * 
48
 * @see {@link ContextLaunchingAction}
49
 * @see {@link ContextLaunchingToolbarAction}
50
 * @see {@link ILaunchListener}
51
 * @see {@link org.eclipse.debug.core.ILaunchManager}
52
 * 
53
 *  @since 3.3
54
 *  EXPERIMENTAL
55
 *  CONTEXTLAUNCHING
56
 */
57
public class ContextRunner implements ILaunchListener {
58
	
59
	private static ContextRunner fgInstance = null;
60
	
61
	/**
62
	 * Returns the singleton instance of <code>ContextRunner</code>
63
	 * @return the singleton instance of <code>ContextRunner</code>
64
	 */
65
	public static ContextRunner getDefault() {
66
		if(fgInstance == null) {
67
			fgInstance = new ContextRunner();
68
		}
69
		return fgInstance;
70
	}
71
72
	/**
73
	 * The underlying resource that is derived from the object context of the 
74
	 * run(Object, String) method
75
	 */
76
	private IResource fBackingResource = null;
77
	private boolean fMakeResourceDefault = false;
78
	private boolean fMakeProjectDefault = false;
79
	
80
	/**
81
	 * Performs the context launching given the object context and the mode to launch in.
82
	 * @param mode the mode to launch in
83
	 */
84
	public void launch(String mode) {
85
		try {
86
			Object context = getCurrentContext();
87
			ILaunchConfiguration config = isSharedConfig(context);
88
			if(config != null) { 
89
				DebugUITools.launch(config, mode);
90
				return;
91
			}
92
			config = isSharedConfigEditorInput(context);
93
			if(config != null) {
94
				DebugUITools.launch(config, mode);
95
				return;
96
			}
97
			if(context instanceof IAdaptable) {
98
				IAdaptable adapt = (IAdaptable) context;
99
				//try to get the ILaunchConfiguration adapter first
100
				config = (ILaunchConfiguration) adapt.getAdapter(ILaunchConfiguration.class);
101
				if(config != null) {
102
					DebugUITools.launch(config, mode);
103
					return;
104
				}
105
				else {
106
					//try to get the resource adapter from the context
107
					IResource resource = (IResource) adapt.getAdapter(IResource.class);
108
					if(resource != null) {
109
						fBackingResource = resource;
110
						config = getLaunchManager().getDefaultConfiguration(resource);
111
						if(config != null && config.exists()) {
112
							//the default config is available
113
							DebugUITools.launch(config, mode);
114
							return;
115
						}
116
						else {
117
							//there is no default config
118
							getLaunchManager().setDefaultConfiguration(resource, null);
119
							selectAndLaunch(fBackingResource, mode);
120
							return;
121
						}
122
					}
123
					else {
124
						handleUnknownContext(mode);
125
					}
126
				}
127
			}
128
			else {
129
				handleUnknownContext(mode);
130
			}
131
		}
132
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
133
	}
134
	
135
	/**
136
	 * Handles the case where the context is unknown: Meaning that nothing can be launched.
137
	 * @param mode the mode
138
	 */
139
	protected void handleUnknownContext(String mode) {
140
		String prompt = DebugUIPlugin.getDefault().getPreferenceStore().getString(IInternalDebugUIConstants.PREF_ALWAYS_RUN_LAST_LAUNCH);
141
		if(MessageDialogWithToggle.PROMPT.equals(prompt)) {
142
			MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoCancelQuestion(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0,
143
					ContextMessages.ContextRunner_1, ContextMessages.ContextRunner_2, 
144
					false, null, null);
145
			int ret = mdwt.getReturnCode();
146
			boolean checked = mdwt.getToggleState();
147
			if(ret == IDialogConstants.YES_ID) {
148
				//get launch history for the given mode and do it 
149
				launchLast(mode);
150
				if(checked) {
151
					DebugUIPlugin.getDefault().getPreferenceStore().putValue(IInternalDebugUIConstants.PREF_ALWAYS_RUN_LAST_LAUNCH, MessageDialogWithToggle.ALWAYS);
152
				}
153
			}
154
			else if(ret == IDialogConstants.NO_ID) {
155
				if(checked) {
156
					DebugUIPlugin.getDefault().getPreferenceStore().putValue(IInternalDebugUIConstants.PREF_ALWAYS_RUN_LAST_LAUNCH, MessageDialogWithToggle.NEVER);
157
				}
158
			}
159
		}
160
		else if(MessageDialogWithToggle.ALWAYS.equals(prompt)) {
161
			launchLast(mode);
162
		}
163
	}
164
	
165
	/**
166
	 * Launches the last launched item from the corresponding launch history
167
	 * @param mode the mode to launch in
168
	 * @return true if this method launched a config, false otherwise
169
	 */
170
	protected boolean launchLast(String mode) {
171
		ILaunchGroup group = resolveLaunchGroup(mode);
172
		ILaunchConfiguration config = null;
173
		if(group != null) {
174
			LaunchHistory history = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchHistory(group.getIdentifier());
175
			if(history != null) {
176
				config = history.getRecentLaunch();
177
				DebugUITools.launch(config, mode);
178
				return true;
179
			}
180
		}
181
		return false;
182
	}
183
	
184
	/**
185
	 * This method return if the editor input is from a shared java launch configuration file or not
186
	 * @param receiver the editor input to examine
187
	 * @return true if the editor input is from a shared launch configuration file, false otherwise.
188
	 */
189
	public ILaunchConfiguration isSharedConfigEditorInput(Object receiver) {
190
		if(receiver instanceof IFileEditorInput) {
191
			IFileEditorInput input = (IFileEditorInput) receiver;
192
			return isSharedConfig(input.getFile());
193
		}
194
		return null;
195
	}
196
	
197
	/**
198
	 * Returns the launch group that corresponds to the specified mode
199
	 * @param mode the mode to find the launch group
200
	 * @return the launch group that corresponds to the specified mode
201
	 */
202
	protected ILaunchGroup resolveLaunchGroup(String mode) {
203
		ILaunchGroup[] groups = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroups();
204
		for(int i = 0; i < groups.length; i++) {
205
			if(groups[i].getMode().equals(mode) && groups[i].getCategory() == null) {
206
				return groups[i];
207
			}
208
		}
209
		return null;
210
	}
211
	
212
	/**
213
	 * Returns the shared config from the selected resource or <code>null</code> if the selected resources is not a shared config
214
	 * @param receiver
215
	 * @return the shared config from the selected resource or <code>null</code> if the selected resources is not a shared config
216
	 */
217
	public ILaunchConfiguration isSharedConfig(Object receiver) {
218
		if(receiver instanceof IFile) {
219
			IFile file = (IFile) receiver;
220
			String ext = file.getFileExtension();
221
			if(ext == null) {
222
				return null;
223
			}
224
			if(ext.equals("launch")) { //$NON-NLS-1$
225
				ILaunchConfiguration config = DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(file);
226
				if(config != null && config.exists()) {
227
					return config;
228
				}
229
			}
230
		}
231
		return null;
232
	}
233
	
234
	/**
235
	 * Prompts the user to select a way of launching the current resource, where a 'way'
236
	 * is defined as a launch shortcut, and returns if a launch took place
237
	 * @param adapt the adaptable type the specified resource was derived from
238
	 * @param resource
239
	 * @return if the context was launched in the given mode or not
240
	 * @throws CoreException
241
	 */
242
	protected boolean selectAndLaunch(IResource resource, String mode) throws CoreException {
243
		boolean launched = false;
244
		if(launchDefault(resource, mode)) {
245
			return true;
246
		}
247
		List exts = getLaunchShortcuts(resource);
248
		if(exts.size() == 1) {
249
			//just launch it and set it as the default
250
			LaunchShortcutExtension ext = (LaunchShortcutExtension) exts.get(0);
251
			ext.launch(new StructuredSelection(resource), mode);
252
			return true;
253
		}
254
		else if(exts.size() < 1) {
255
			//prompt to try the parent containers
256
			String prompt = DebugUIPlugin.getDefault().getPreferenceStore().getString(IInternalDebugUIConstants.PREF_ALWAYS_RUN_PROJECT_CONFIGURATION);
257
			if(MessageDialogWithToggle.ALWAYS.equals(prompt)) {
258
				//go ahead and check
259
				selectAndLaunch(resource.getProject(), mode);
260
			}
261
			else if(MessageDialogWithToggle.PROMPT.equals(prompt)) {
262
				MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoCancelQuestion(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_3,
263
						MessageFormat.format(ContextMessages.ContextRunner_4, new String[] {fBackingResource.getName()}),
264
						ContextMessages.ContextRunner_2, false, null, null);
265
				int ret = mdwt.getReturnCode();
266
				boolean checked = mdwt.getToggleState();
267
				if(ret == IDialogConstants.YES_ID) {
268
					if(checked) {
269
						DebugUIPlugin.getDefault().getPreferenceStore().putValue(IInternalDebugUIConstants.PREF_ALWAYS_RUN_PROJECT_CONFIGURATION, MessageDialogWithToggle.ALWAYS);
270
					}
271
					selectAndLaunch(resource.getProject(), mode);
272
				}
273
				else if(ret == IDialogConstants.NO_ID) {
274
					if(checked) {
275
						DebugUIPlugin.getDefault().getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_ALWAYS_RUN_PROJECT_CONFIGURATION, MessageDialogWithToggle.NEVER);
276
						return false;
277
					}
278
				}
279
			}
280
			return false;
281
		}
282
		else {
283
			boolean project = resource instanceof IProject;
284
			if(exts.isEmpty()) {
285
				MessageDialog.openError(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_5, ContextMessages.ContextRunner_6);
286
			}
287
			else {
288
				LaunchShortcutSelectionDialog dialog = new LaunchShortcutSelectionDialog(resource, mode, !project, project);
289
				if (dialog.open() == Window.OK) {
290
					Object[] result = dialog.getResult();
291
					if(result.length > 0) {
292
						fMakeProjectDefault = dialog.makeProjectDefault();
293
						fMakeResourceDefault = dialog.makeDefault();
294
						if(fMakeProjectDefault || fMakeResourceDefault) {
295
							getLaunchManager().addLaunchListener(this);
296
						}
297
						LaunchShortcutExtension method = (LaunchShortcutExtension) result[0];
298
						if(method != null) {
299
							method.launch(new StructuredSelection(resource), mode);
300
						}
301
					}
302
				}
303
			}
304
		}
305
		return launched;
306
	}
307
	
308
	/**
309
	 * Creates a listing of the launch shortcut extensions that are applicable to the underlying resource
310
	 * @param resource the underlying resource
311
	 * @return a listing of applicable launch shortcuts
312
	 * @throws CoreException
313
	 */
314
	public List getLaunchShortcuts(IResource resource) throws CoreException {
315
		List list = new ArrayList(); 
316
		List sc = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchShortcuts();
317
		List ctxt = new ArrayList();
318
		ctxt.add(resource);
319
		IEvaluationContext context = new EvaluationContext(null, ctxt);
320
		context.addVariable("selection", ctxt); //$NON-NLS-1$
321
		LaunchShortcutExtension ext = null;
322
		for(Iterator iter = sc.iterator(); iter.hasNext();) {
323
			ext = (LaunchShortcutExtension) iter.next();
324
			if(ext.evalEnablementExpression(context, ext.getContextualLaunchEnablementExpression())) {
325
				if(!list.contains(ext)) {
326
					list.add(ext);
327
				}
328
			}
329
		}
330
		return list;
331
	}
332
	
333
	/**
334
	 * Returns the current context to be considered for launching. 
335
	 * The returned object will be one of:
336
	 * <ol>
337
	 * <li>{@link IEditorInput}</li>
338
	 * <li>{@link Object}, where <i>object</i> is the first element in the selection obtained from the 
339
	 * selection provider of the currently selected workbench part</li>
340
	 * </ol>
341
	 * @return the currently selected context to consider for launching, or <code>null</code>.
342
	 *
343
	 */
344
	public Object getCurrentContext() {
345
		IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
346
		if(window != null) {
347
			IWorkbenchPage page = window.getActivePage();
348
			if(page!= null) {
349
				IWorkbenchPart part = page.getActivePart();
350
				if(part != null) {
351
					if(part instanceof IEditorPart) {
352
						return ((IEditorPart)part).getEditorInput();
353
					}
354
					IWorkbenchPartSite site = part.getSite();
355
					if(site != null) {
356
						ISelectionProvider provider = site.getSelectionProvider();
357
						if(provider != null) {
358
							ISelection sel = provider.getSelection();
359
							if(sel instanceof IStructuredSelection) {
360
								StructuredSelection ss = (StructuredSelection) sel;
361
								if(ss.isEmpty()) {
362
									return part;
363
								}
364
								else {
365
									return ss.getFirstElement();
366
								}
367
							}
368
							else if(sel instanceof ITextSelection) {
369
								return part;
370
							}
371
							return sel;
372
						}
373
						else {
374
							//default to returning the part, which can be further queried for adapters
375
							return part;
376
						}
377
					}
378
				}
379
			}
380
			
381
		}
382
		return null;
383
	}
384
	
385
	/**
386
	 * Returns the name of the currently selected context, or the empty string.
387
	 * This method can return null in the event the contributor of the selected context returns <code>null</code>
388
	 * as the resource name.
389
	 * @return the name of the currently selected context or the empty string. 
390
	 */
391
	public String getContextName() {
392
		Object o = getCurrentContext();
393
		ILaunchConfiguration config = isSharedConfig(o);
394
		if(config != null) {
395
			return config.getName();
396
		}
397
		else {
398
			config = isSharedConfigEditorInput(o);
399
			if(config != null) {
400
				return config.getName();
401
			}
402
			else {
403
				if(o instanceof IAdaptable) {
404
					IAdaptable adapt = (IAdaptable) o;
405
					Object a = adapt.getAdapter(ILaunchConfiguration.class);
406
					if(a != null) {
407
						return ((ILaunchConfiguration) a).getName();
408
					}
409
					else {
410
						a = adapt.getAdapter(IResource.class);
411
						if(a != null) {
412
							IResource res = (IResource) a;
413
							return (res.isAccessible() ? res.getName() : ""); //$NON-NLS-1$
414
						}
415
					}
416
				}
417
			}
418
		}
419
		return ""; //$NON-NLS-1$
420
	}
421
	
422
	/**
423
	 * Returns if context launching is enabled
424
	 * @return if context launching is enabled
425
	 */
426
	public static boolean isContextLaunchEnabled() {
427
		return DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH);
428
	}
429
	
430
	/**
431
	 * Returns the launch manager
432
	 * @return the launch manager
433
	 */
434
	protected LaunchManager getLaunchManager() {
435
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
436
	}
437
	
438
	/**
439
	 * @see org.eclipse.debug.core.ILaunchListener#launchAdded(org.eclipse.debug.core.ILaunch)
440
	 */
441
	public void launchAdded(ILaunch launch) {
442
		if(fBackingResource != null) {
443
			try {
444
				if(fMakeResourceDefault) {
445
					getLaunchManager().setDefaultConfiguration(fBackingResource, launch.getLaunchConfiguration());
446
				}
447
				if(fMakeProjectDefault) {
448
					getLaunchManager().setDefaultConfiguration(fBackingResource.getProject(), launch.getLaunchConfiguration());
449
				}
450
				getLaunchManager().removeLaunchListener(this);
451
				fMakeProjectDefault = false;
452
				fMakeResourceDefault = false;
453
			}
454
			catch(CoreException ce) {DebugUIPlugin.log(ce);}
455
		}
456
	}
457
458
	/**
459
	 * Handles launching the default launch configuration for the specified resource, if there is no default
460
	 * this method delegates to the <code>handleUnknownContext</code> method to figure out what to do
461
	 * @param res the resource to find the default configuration for
462
	 * @param mode the mode to launch it in
463
	 * @return true if the method launched something false otherwise
464
	 * @throws CoreException
465
	 */
466
	protected boolean launchDefault(IResource res, String mode) throws CoreException {
467
		ILaunchConfiguration config = getLaunchManager().getDefaultConfiguration(res);
468
		if(config != null && config.exists()) {
469
			DebugUITools.launch(config, mode);
470
			return true;
471
		}
472
		else {
473
			return false;
474
		}
475
	}
476
	
477
	/**
478
	 * @see org.eclipse.debug.core.ILaunchListener#launchChanged(org.eclipse.debug.core.ILaunch)
479
	 */
480
	public void launchChanged(ILaunch launch) {}
481
482
	/**
483
	 * @see org.eclipse.debug.core.ILaunchListener#launchRemoved(org.eclipse.debug.core.ILaunch)
484
	 */
485
	public void launchRemoved(ILaunch launch) {}
486
	
487
}
(-)ui/org/eclipse/debug/internal/ui/preferences/ContextLaunchingPreferencePage.java (+118 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.dialogs.MessageDialogWithToggle;
21
import org.eclipse.jface.preference.BooleanFieldEditor;
22
import org.eclipse.jface.preference.FieldEditor;
23
import org.eclipse.jface.preference.PreferencePage;
24
import org.eclipse.jface.preference.RadioGroupFieldEditor;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.ui.IWorkbench;
29
import org.eclipse.ui.IWorkbenchPreferencePage;
30
import org.eclipse.ui.PlatformUI;
31
32
/**
33
 * A preference page for configuring launching preferences.
34
 * 
35
 * @since 3.3
36
 */
37
public class ContextLaunchingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
38
	
39
	/**
40
	 * a list of the field editors
41
	 */
42
	private List fFieldEditors;
43
	
44
	/**
45
	 * The default constructor
46
	 */
47
	public ContextLaunchingPreferencePage() {
48
		super();
49
		setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
50
	}
51
	
52
	/**
53
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
54
	 */
55
	public void createControl(Composite parent) {
56
		super.createControl(parent);
57
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.CONTEXTUAL_LAUNCHING_PREFERENCE_PAGE);
58
	}
59
	
60
	/**
61
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
62
	 */
63
	protected Control createContents(Composite parent) {
64
		fFieldEditors = new ArrayList();
65
		Composite comp = SWTUtil.createComposite(parent, 1, 1, GridData.FILL_BOTH);
66
		
67
		SWTUtil.createWrapLabel(comp, DebugPreferencesMessages.ContextualLaunchPreferencePage_0, 1, 300);
68
		SWTUtil.createVerticalSpacer(comp, 2);
69
	//use contextual launch
70
		FieldEditor edit = new BooleanFieldEditor(IInternalDebugUIConstants.PREF_USE_CONTEXTUAL_LAUNCH, DebugPreferencesMessages.ContextualLaunchPreferencePage_1, comp);	
71
		fFieldEditors.add(edit);
72
			
73
		edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_ALWAYS_RUN_LAST_LAUNCH, DebugPreferencesMessages.ContextLaunchingPreferencePage_0, 3, 
74
				new String[][] {{DebugPreferencesMessages.LaunchingPreferencePage_3, MessageDialogWithToggle.ALWAYS}, 
75
				 {DebugPreferencesMessages.LaunchingPreferencePage_4, MessageDialogWithToggle.NEVER},
76
				 {DebugPreferencesMessages.LaunchingPreferencePage_5, MessageDialogWithToggle.PROMPT}},
77
				 comp, true);	
78
		fFieldEditors.add(edit);
79
		edit = new RadioGroupFieldEditor(IInternalDebugUIConstants.PREF_ALWAYS_RUN_PROJECT_CONFIGURATION, DebugPreferencesMessages.ContextLaunchingPreferencePage_1, 3, 
80
				new String[][] {{DebugPreferencesMessages.LaunchingPreferencePage_3, MessageDialogWithToggle.ALWAYS}, 
81
				 {DebugPreferencesMessages.LaunchingPreferencePage_4, MessageDialogWithToggle.NEVER},
82
				 {DebugPreferencesMessages.LaunchingPreferencePage_5, MessageDialogWithToggle.PROMPT}},
83
				 comp, true);	
84
		fFieldEditors.add(edit);
85
	//init the field editors
86
		FieldEditor editor;
87
		for(int i = 0; i < fFieldEditors.size(); i++) {
88
			editor = (FieldEditor)fFieldEditors.get(i);
89
			editor.setPreferenceStore(getPreferenceStore());
90
			editor.load();
91
		}
92
		return comp;
93
	}
94
	
95
	/**
96
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
97
	 */
98
	public void init(IWorkbench workbench) {}
99
	
100
	/**
101
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
102
	 */
103
	protected void performDefaults() {
104
		for(int i = 0; i < fFieldEditors.size(); i++) {
105
			((FieldEditor)fFieldEditors.get(i)).loadDefault();
106
		}
107
	}
108
	
109
	/**
110
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
111
	 */
112
	public boolean performOk() {
113
		for(int i = 0; i < fFieldEditors.size(); i++) {
114
			((FieldEditor)fFieldEditors.get(i)).store();
115
		}
116
		return super.performOk();
117
	}
118
}
(-)ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java (+506 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.preferences;
12
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.Comparator;
17
import java.util.HashSet;
18
import java.util.Iterator;
19
import java.util.List;
20
import java.util.Set;
21
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IAdaptable;
25
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.core.ILaunchConfigurationType;
29
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.internal.core.LaunchManager;
31
import org.eclipse.debug.internal.ui.DebugUIPlugin;
32
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
33
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
34
import org.eclipse.debug.internal.ui.SWTUtil;
35
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationComparator;
36
import org.eclipse.debug.ui.DebugUITools;
37
import org.eclipse.debug.ui.IDebugUIConstants;
38
import org.eclipse.jface.viewers.ArrayContentProvider;
39
import org.eclipse.jface.viewers.CheckStateChangedEvent;
40
import org.eclipse.jface.viewers.CheckboxTableViewer;
41
import org.eclipse.jface.viewers.ICheckStateListener;
42
import org.eclipse.jface.viewers.ISelectionChangedListener;
43
import org.eclipse.jface.viewers.IStructuredSelection;
44
import org.eclipse.jface.viewers.SelectionChangedEvent;
45
import org.eclipse.jface.viewers.StructuredSelection;
46
import org.eclipse.jface.window.Window;
47
import org.eclipse.swt.SWT;
48
import org.eclipse.swt.events.SelectionEvent;
49
import org.eclipse.swt.events.SelectionListener;
50
import org.eclipse.swt.layout.GridData;
51
import org.eclipse.swt.layout.GridLayout;
52
import org.eclipse.swt.widgets.Button;
53
import org.eclipse.swt.widgets.Composite;
54
import org.eclipse.swt.widgets.Control;
55
import org.eclipse.swt.widgets.Table;
56
import org.eclipse.ui.PlatformUI;
57
import org.eclipse.ui.dialogs.ListDialog;
58
import org.eclipse.ui.dialogs.PropertyPage;
59
60
import com.ibm.icu.text.MessageFormat;
61
62
/**
63
 * Displays default launch configuration settings for a selected resource - associated launch configurations.
64
 * 
65
 * @see {@link PropertyPage}
66
 * @see {@link ILaunchConfiguration}
67
 * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog}
68
 * @see {@link IDebugHelpContextIds#DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE}
69
 * 
70
 * EXPERIMENTAL
71
 * CONTEXTLAUNCHING
72
 * 
73
 * @since 3.3
74
 */
75
public class RunDebugPropertiesPage extends PropertyPage {
76
	/**
77
	 * Set of configurations to be deleted
78
	 */
79
	private Set fDeletedConfigurations = new HashSet();
80
	
81
	/**
82
	 * Set of original default candidates for the resource
83
	 */
84
	private Set fOriginalCandidates;
85
	
86
	/**
87
	 * List of the applicable launch config types for the backing resource
88
	 */
89
	private List fTypeCandidates = null;
90
	
91
	//widgets
92
	private CheckboxTableViewer fViewer;
93
	private Button fNewButton = null;
94
	private Button fEditButton = null;
95
	private Button fDuplicateButton = null;
96
	private Button fDeleteButton = null;
97
	
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
100
	 */
101
	protected Control createContents(Composite parent) {
102
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE);
103
		collectConfigCandidates(getResource());
104
		Composite topComposite = SWTUtil.createComposite(parent, 2, 1, GridData.FILL_BOTH);
105
		
106
		SWTUtil.createWrapLabel(topComposite, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_0, 2, 300);
107
		SWTUtil.createVerticalSpacer(topComposite, 2);
108
		SWTUtil.createWrapLabel(topComposite, MessageFormat.format(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_1, new String[]{getResource().getName()}), 2, 300);
109
		fViewer = createViewer(topComposite);
110
		
111
		Composite buttonComp = SWTUtil.createComposite(topComposite, 1, 1, GridData.FILL_VERTICAL);
112
		GridLayout layout = (GridLayout) buttonComp.getLayout();
113
		layout.marginHeight = 0;
114
		fNewButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_2, null);
115
		fNewButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_3);
116
		fNewButton.addSelectionListener(new SelectionListener() {
117
			public void widgetDefaultSelected(SelectionEvent e) {}
118
			public void widgetSelected(SelectionEvent e) {
119
				handleNew();
120
			}
121
		});
122
		
123
		fDuplicateButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_4, null);
124
		fDuplicateButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_5);
125
		fDuplicateButton.setEnabled(false);
126
		fDuplicateButton.addSelectionListener(new SelectionListener() {
127
			public void widgetDefaultSelected(SelectionEvent e) {}
128
			public void widgetSelected(SelectionEvent e) {
129
				handleCopy();
130
			}
131
		});
132
		fEditButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_6, null);
133
		fEditButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_7);
134
		fEditButton.setEnabled(false);
135
		fEditButton.addSelectionListener(new SelectionListener() {
136
			public void widgetDefaultSelected(SelectionEvent e) {}
137
			public void widgetSelected(SelectionEvent e) {
138
				handleEdit();
139
			}
140
		});
141
		fDeleteButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_8, null);
142
		fDeleteButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_9);
143
		fDeleteButton.setEnabled(false);
144
		fDeleteButton.addSelectionListener(new SelectionListener() {
145
			public void widgetDefaultSelected(SelectionEvent e) {}
146
			public void widgetSelected(SelectionEvent e) {
147
				handleDelete();
148
			}
149
		});
150
		
151
		fViewer.setSelection(new StructuredSelection());
152
		applyDialogFont(topComposite);
153
		return topComposite;
154
	}
155
156
	/**
157
	 * Creates and returns the viewer that will display the possible default configurations.
158
	 * 
159
	 * @param parent parent composite to create the viewer in
160
	 * @return viewer viewer that will display possible default configurations
161
	 */
162
	protected CheckboxTableViewer createViewer(Composite parent){
163
		CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
164
		viewer.setLabelProvider(new DefaultLabelProvider());
165
		viewer.setContentProvider(new ArrayContentProvider());
166
		viewer.setComparator(new LaunchConfigurationComparator());
167
		viewer.addCheckStateListener(new ICheckStateListener() {
168
			public void checkStateChanged(CheckStateChangedEvent event) {
169
				if (event.getChecked()) {
170
					fViewer.setCheckedElements(new Object[] {event.getElement()});
171
				}
172
				else{
173
					fViewer.setCheckedElements(new Object[] {});
174
				}
175
			}
176
		});
177
		Table builderTable = viewer.getTable();
178
		GridData tableGridData = new GridData(GridData.FILL_BOTH);
179
		tableGridData.heightHint = 300;
180
		builderTable.setLayoutData(tableGridData);
181
		
182
		IResource resource = getResource();
183
		viewer.setInput(collectConfigCandidates(resource));
184
		try {
185
			ILaunchConfiguration configuration = getLaunchManager().getDefaultConfiguration(resource);
186
			if (configuration != null) {
187
				Iterator iterator = fOriginalCandidates.iterator();
188
				while (iterator.hasNext()) {
189
					ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
190
					if (configuration.equals(wc.getOriginal())) {
191
						viewer.setChecked(wc, true);
192
						break;
193
					}
194
				}
195
			}
196
		} catch (CoreException e) {setErrorMessage(e.getMessage());}
197
		viewer.addSelectionChangedListener(new ISelectionChangedListener() {
198
			public void selectionChanged(SelectionChangedEvent event) {
199
				boolean empty = event.getSelection().isEmpty();
200
				fEditButton.setEnabled(!empty);
201
				fDuplicateButton.setEnabled(!empty);
202
				fDeleteButton.setEnabled(!empty);
203
			}
204
		});
205
		
206
		return viewer;
207
	}
208
209
	/**
210
	 * Returns the viewer displaying possible default configurations.
211
	 * 
212
	 * @return viewer
213
	 */
214
	protected CheckboxTableViewer getViewer() {
215
		return fViewer;
216
	}
217
		
218
	/**
219
	 * Returns the launch manager
220
	 * @return the launch manager
221
	 */
222
	protected LaunchManager getLaunchManager() {
223
		return (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
224
	}
225
	
226
	/**
227
	 * Collects the applicable launch configuration types for the backing resource.
228
	 * Default implementation uses the launch shortcut evaluation expressions and leverages the 
229
	 * mapping of launch shortcut to config type id to derive the applicable types.
230
	 * @return the listing of applicable launch configuration types for the backing resource
231
	 */
232
	protected List collectTypeCandidates() {
233
		if(fTypeCandidates == null) {
234
			fTypeCandidates = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getApplicableConfigurationTypes(getResource());
235
			Collections.sort(fTypeCandidates, new Comparator() {
236
				public int compare(Object o1, Object o2) {
237
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
238
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
239
					return t1.getName().compareTo(t2.getName());
240
				}
241
			});
242
		}
243
		return fTypeCandidates;
244
	}
245
	
246
	/**
247
	 * Returns a set of potential default configurations candidates for the given
248
	 * resource. The configurations are working copies.
249
	 *  
250
	 * @param resource resource
251
	 * @return list of default candidates
252
	 */
253
	protected Set collectConfigCandidates(IResource resource) {
254
		if(fOriginalCandidates == null) {
255
			fOriginalCandidates = new HashSet();
256
			IPath resourcePath = resource.getFullPath();
257
			try {
258
				List types = collectTypeCandidates();
259
				List configs = new ArrayList();
260
				ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations();
261
				for(int i = 0; i < configurations.length; i++) {
262
					if(types.contains(configurations[i].getType())) {
263
						if(configurations[i].isMigrationCandidate()) {
264
							configurations[i].migrate();
265
						}
266
						configs.add(configurations[i]);
267
					}
268
				}
269
				ILaunchConfiguration configuration = null;
270
				IResource[] resources = null;
271
				for (Iterator iter = configs.iterator(); iter.hasNext();) {
272
					configuration = (ILaunchConfiguration) iter.next();
273
					if(acceptConfiguration(configuration)) { 
274
						if(configuration.contentsEqual(getLaunchManager().getDefaultConfiguration(resource))) {
275
							fOriginalCandidates.add(configuration.getWorkingCopy());
276
						}
277
						else {
278
							resources = configuration.getMappedResources();
279
							if (resources != null) {
280
								for (int j = 0; j < resources.length; j++) {
281
									if (resource.equals(resources[j]) || resourcePath.isPrefixOf(resources[j].getFullPath())) {
282
										fOriginalCandidates.add(configuration.getWorkingCopy());
283
										break;
284
									}
285
								}
286
							}
287
							else {
288
								//in the event the config has no mapping
289
								fOriginalCandidates.add(configuration.getWorkingCopy());
290
							}
291
						}
292
					}
293
				}
294
			} catch (CoreException e) {
295
				fOriginalCandidates.clear();
296
				DebugPlugin.log(e);
297
			}
298
		}
299
		return fOriginalCandidates;
300
	}
301
	
302
	/**
303
	 * Returns if the specified configuration should be considered as a potential candidate
304
	 * @param config
305
	 * @return if the specified configuration should be considered as a potential candidate
306
	 * @throws CoreException
307
	 */
308
	private boolean acceptConfiguration(ILaunchConfiguration config) throws CoreException {
309
		if(config != null && !DebugUITools.isPrivate(config)) {
310
			if(!"org.eclipse.ui.externaltools".equals(config.getType().getCategory())) { //$NON-NLS-1$
311
				return true;
312
			}
313
			else {
314
				IResource[] res = config.getMappedResources();
315
				if(res != null) {
316
					return true;
317
				}
318
			}
319
		}
320
		return false;
321
	}
322
	
323
	/**
324
	 * Returns the resource this property page is open on.
325
	 * 
326
	 * @return resource
327
	 */
328
	protected IResource getResource() {
329
		Object element = getElement();
330
		IResource resource = null;
331
		if (element instanceof IResource) {
332
			resource = (IResource) element;
333
		} else if (element instanceof IAdaptable) {
334
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
335
		}
336
		return resource;
337
	}
338
339
	/* (non-Javadoc)
340
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
341
	 */
342
	public boolean performOk() {
343
		Object[] checked = fViewer.getCheckedElements();
344
		try {
345
			ILaunchConfiguration def = null;
346
			if (checked.length == 1) {
347
					def = (ILaunchConfiguration) checked[0];
348
					def = ((ILaunchConfigurationWorkingCopy)def).doSave();
349
			}
350
			DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
351
		} catch (CoreException e) {
352
			setErrorMessage(e.getMessage());
353
			return false;
354
		}
355
	//delete 
356
		Iterator iter = fDeletedConfigurations.iterator();
357
		while (iter.hasNext()) {
358
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
359
			try{			
360
				if (currentConfig.getOriginal() != null){
361
					currentConfig.getOriginal().delete();
362
				}
363
			} catch (CoreException e) {
364
				DebugPlugin.logMessage("Problem deleting configuration " + currentConfig.getName(), e); //$NON-NLS-1$
365
			}
366
		}
367
	//add
368
		iter = fOriginalCandidates.iterator();
369
		while (iter.hasNext()) {
370
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next();
371
			if (currentConfig.isDirty()){
372
				try{
373
					currentConfig.doSave();
374
				} catch (CoreException e) {
375
					DebugPlugin.logMessage("Problem saving changes to configuration " + currentConfig.getName(), e); //$NON-NLS-1$
376
				}
377
			}
378
		}
379
		
380
		return super.performOk();
381
	}
382
383
	/* (non-Javadoc)
384
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
385
	 */
386
	protected void performDefaults() {
387
		fViewer.setAllChecked(false);
388
		setErrorMessage(null);
389
		setValid(true);
390
		super.performDefaults();
391
	}
392
	
393
	/**
394
	 * Returns the names of the launch configurations passed in as original input to the tree viewer
395
	 * @return the names of the original launch configurations
396
	 */
397
	private Set getConfigurationNames() {
398
		Set names = new HashSet();
399
		Iterator iter = fOriginalCandidates.iterator();
400
		Object o = null;
401
		while (iter.hasNext()) {
402
			o = iter.next();
403
			if(o instanceof ILaunchConfiguration) {
404
				names.add(((ILaunchConfiguration)o).getName());
405
			}
406
		}
407
		return names;
408
	}
409
	
410
	/**
411
	 * Returns selected configurations.
412
	 * 
413
	 * @return selected configurations
414
	 */
415
	private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() {
416
		IStructuredSelection ss = (IStructuredSelection) fViewer.getSelection();
417
		return (ILaunchConfigurationWorkingCopy[]) ss.toList().toArray(new ILaunchConfigurationWorkingCopy[ss.size()]);
418
	}
419
420
	/**
421
	 * Copy the selection
422
	 */
423
	private void handleCopy() {
424
		ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0];
425
		try {
426
			ILaunchConfigurationWorkingCopy copy = configuration.copy(
427
					((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).generateUniqueLaunchConfigurationNameFrom(configuration.getName(), getConfigurationNames()));
428
			copy.setAttributes(configuration.getAttributes());
429
			fOriginalCandidates.add(copy);
430
			fViewer.refresh();
431
			fViewer.setSelection(new StructuredSelection(copy));
432
		} catch (CoreException e) {
433
			setErrorMessage(e.getMessage());
434
		}
435
	}
436
437
	/**
438
	 * Delete the selection
439
	 */
440
	private void handleDelete() {
441
		Table table = fViewer.getTable();
442
		int[] indices = table.getSelectionIndices();
443
		Arrays.sort(indices);
444
		ILaunchConfiguration[] configurations = getSelectedConfigurations();
445
		for (int i = 0; i < configurations.length; i++) {
446
			fDeletedConfigurations.add(configurations[i]);
447
			fOriginalCandidates.remove(configurations[i]);
448
		}
449
		fViewer.refresh();
450
		if (indices[0] < table.getItemCount()) {
451
			fViewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData()));
452
		} else if (table.getItemCount() > 0) {
453
			fViewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData()));
454
		}
455
	}
456
457
	/**
458
	 * Edit the selection
459
	 */
460
	private void handleEdit() {
461
		edit(getSelectedConfigurations()[0]);
462
		fViewer.refresh();
463
	}
464
465
	/**
466
	 * Edits the given configuration as a nested working copy.
467
	 * Returns the code from the dialog used to edit the configuration.
468
	 * 
469
	 * @param configuration
470
	 * @return dialog return code - OK or CANCEL
471
	 */
472
	private int edit(ILaunchConfigurationWorkingCopy configuration) {
473
		return DebugUIPlugin.openLaunchConfigurationPropertiesDialog(getShell(), configuration, IDebugUIConstants.ID_RUN_LAUNCH_GROUP, getConfigurationNames(), null);
474
	}
475
476
	/**
477
	 * Create a new configuration
478
	 */
479
	private void handleNew() {
480
		ListDialog dialog = new ListDialog(getShell());
481
		dialog.setTitle(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_11);
482
		dialog.setContentProvider(new ArrayContentProvider());
483
		dialog.setLabelProvider(new DefaultLabelProvider());
484
		dialog.setAddCancelButton(true);
485
		dialog.setMessage(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_12);
486
		dialog.setInput(collectTypeCandidates());
487
		if (dialog.open() == Window.OK) {
488
			Object[] result = dialog.getResult();
489
			if (result.length == 1) {
490
				ILaunchConfigurationType type = (ILaunchConfigurationType) result[0];
491
				try {
492
					ILaunchConfigurationWorkingCopy wc = type.newInstance(null, 
493
							((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).
494
							generateUniqueLaunchConfigurationNameFrom("New_configuration", getConfigurationNames())); //$NON-NLS-1$
495
					if (edit(wc) == Window.OK) {
496
						fOriginalCandidates.add(wc);
497
						fViewer.refresh();
498
						fViewer.setSelection(new StructuredSelection(wc));
499
					}
500
				} catch (CoreException e) {
501
					setErrorMessage(e.getMessage());
502
				}
503
			}
504
		}
505
	}	
506
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingAction.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.contextlaunching;
12
13
import org.eclipse.jface.action.IAction;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.swt.widgets.Event;
16
import org.eclipse.ui.IActionDelegate2;
17
18
/**
19
 * A universal context launching action for popup menus. 
20
 * This action gets its immediate context from what was right-clicked
21
 * on to present the action.
22
 * 
23
 * @see {@link ContextRunner}
24
 * @see {@link IActionDelegate2}
25
 * @see {@link RunContextLaunchingAction}
26
 * @see {@link DebugContextLaunchingAction}
27
 * @see {@link ProfileContextLaunchingAction}
28
 * 
29
 * @since 3.3
30
 * EXPERIMENTAL
31
 * CONTEXTLAUNCHING
32
 */
33
public class ContextLaunchingAction implements IActionDelegate2 {
34
35
	/**
36
	 * the mode the action is created on
37
	 */
38
	private String fMode = null;
39
	
40
	/**
41
	 * Constructor
42
	 * @param mode
43
	 */
44
	public ContextLaunchingAction(String mode) {
45
		fMode = mode;
46
	}
47
48
	/**
49
	 * @see org.eclipse.ui.IActionDelegate2#dispose()
50
	 */
51
	public void dispose() {}
52
53
	/**
54
	 * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
55
	 */
56
	public void init(IAction action) {}
57
58
	/**
59
	 * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
60
	 */
61
	public void runWithEvent(IAction action, Event event) {
62
		ContextRunner.getDefault().launch(fMode);
63
	}
64
	
65
	/**
66
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
67
	 */
68
	public void run(IAction action) {
69
		//not called
70
	}
71
72
	/**
73
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
74
	 */
75
	public void selectionChanged(IAction action, ISelection selection) {}
76
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextLaunchingToolbarAction.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.internal.ui.DebugUIPlugin;
14
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
15
import org.eclipse.jface.action.Action;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.swt.widgets.Event;
19
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
21
22
/**
23
 * A wrapper class for a context launching toolbar action
24
 * 
25
 * @see {@link ContextRunner}
26
 * @see {@link ContextLaunchingAction}
27
 * @see {@link Action}
28
 * @see {@link IWorkbenchWindowActionDelegate}
29
 * 
30
 *  @since 3.3
31
 *  EXPERIMENTAL
32
 *  CONTEXTLAUNCHING
33
 */
34
public class ContextLaunchingToolbarAction extends Action implements IWorkbenchWindowActionDelegate {
35
36
	/**
37
	 * The mode this action applies to
38
	 */
39
	private String fMode = null;
40
	
41
	/**
42
	 * Constructor
43
	 * @param id
44
	 */
45
	public ContextLaunchingToolbarAction(String id) {
46
		LaunchGroupExtension extension = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(id);
47
		if (extension != null) {
48
			fMode = extension.getMode();
49
			setText(extension.getLabel());
50
			setImageDescriptor(extension.getImageDescriptor());
51
		}
52
	}
53
54
	/**
55
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
56
	 */
57
	public void dispose() {}
58
59
	/**
60
	 * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
61
	 */
62
	public void init(IWorkbenchWindow window) {}
63
	
64
	/**
65
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
66
	 */
67
	public void selectionChanged(IAction action, ISelection selection) {}
68
69
	/**
70
	 * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
71
	 */
72
	public void runWithEvent(Event event) {
73
		ContextRunner.getDefault().launch(fMode);
74
	}
75
76
	/**
77
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
78
	 */
79
	public void run(IAction action) {
80
		//do nothing
81
	}
82
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ProfileContextLaunchingAction.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.core.ILaunchManager;
14
15
/**
16
 * Specialization of <code>ContextLaunchingAction</code> for profile mode
17
 * 
18
 * @see {@link ContextLaunchingAction}
19
 * @see {@link ILaunchManager}
20
 * @see {@link RunContextLaunchingAction}
21
 * @see {@link DebugContextLaunchingAction}
22
 * 
23
 * @since 3.3
24
 * EXPERIMENTAL
25
 * CONTEXTLAUNCHING
26
 */
27
public class ProfileContextLaunchingAction extends ContextLaunchingAction {
28
29
	/**
30
	 * Constructor
31
	 */
32
	public ProfileContextLaunchingAction() {
33
		super(ILaunchManager.PROFILE_MODE);
34
	}
35
36
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java (+158 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.DebugPlugin;
19
import org.eclipse.debug.core.ILaunchMode;
20
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
22
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
23
import org.eclipse.debug.internal.ui.SWTUtil;
24
import org.eclipse.debug.internal.ui.contextlaunching.ContextRunner;
25
import org.eclipse.debug.ui.IDebugUIConstants;
26
import org.eclipse.jface.dialogs.IDialogSettings;
27
import org.eclipse.jface.viewers.ArrayContentProvider;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.dialogs.ListDialog;
36
37
import com.ibm.icu.text.MessageFormat;
38
39
/**
40
 * Specialized dialog for showing/selecting a specific launch shortcut extension, and allowing it
41
 * to be marked to be set as the default
42
 * 
43
 * @see {@link org.eclipse.debug.internal.ui.actions.ContextLaunchingAction}
44
 * 
45
 * @since 3.3
46
 * EXPERIMENTAL
47
 * CONTEXTLAUNCHING
48
 */
49
public class LaunchShortcutSelectionDialog extends ListDialog {
50
51
	private static final String DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_SHORTCUT_DIALOG"; //$NON-NLS-1$;
52
	
53
	/**
54
	 * The list of input for the dialog
55
	 */
56
	private String fMode = null;
57
	private IResource fResource = null;
58
	private boolean fChecked = false;
59
	private boolean fProject = false;
60
	private boolean fShowProject = false;
61
	private boolean fShowResource = false;
62
	
63
	/**
64
	 * Constructor
65
	 * @param input
66
	 * @param resource
67
	 * @param mode
68
	 */
69
	public LaunchShortcutSelectionDialog(IResource resource, String mode, boolean showresource, boolean showproject) {
70
		super(DebugUIPlugin.getShell());
71
		setShellStyle(getShellStyle() | SWT.RESIZE);
72
		fResource = resource;
73
		fMode = mode;
74
		fShowProject = showproject;
75
		fShowResource = showresource;
76
		ILaunchMode lmode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(fMode);
77
		String modename = fMode;
78
		if (lmode != null) {
79
			modename = DebugUIPlugin.removeAccelerators(lmode.getLabel());
80
		}
81
		setTitle(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_0, new String[] {modename}));
82
		setAddCancelButton(true);
83
		setMessage(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_1, new String[] {fMode, fResource.getName()}));
84
		setLabelProvider(new DefaultLabelProvider());
85
		setContentProvider(new ArrayContentProvider());
86
	}
87
88
	/**
89
	 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
90
	 */
91
	protected Control createContents(Composite parent) {
92
		Composite comp = (Composite) super.createContents(parent);
93
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_METHOD_DIALOG);
94
		return comp;
95
	}
96
97
	/**
98
	 * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
99
	 */
100
	protected IDialogSettings getDialogBoundsSettings() {
101
		IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
102
		IDialogSettings section = settings.getSection(DIALOG_SETTINGS);
103
		if (section == null) {
104
			section = settings.addNewSection(DIALOG_SETTINGS);
105
		} 
106
		return section;
107
	}
108
	
109
	/**
110
	 * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
111
	 */
112
	protected Control createDialogArea(Composite container) {
113
		Composite comp = (Composite) super.createDialogArea(container);
114
		try {
115
			List input = new ArrayList(ContextRunner.getDefault().getLaunchShortcuts(fResource));
116
			Button butt = null;
117
			if(!input.isEmpty()) {
118
				if(fShowResource) {
119
					butt = SWTUtil.createCheckButton(comp, MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_2, new String[] {fResource.getName()}), null, fChecked);
120
					butt.addSelectionListener(new SelectionListener() {
121
						public void widgetDefaultSelected(SelectionEvent e) {}
122
						public void widgetSelected(SelectionEvent e) {
123
							fChecked = ((Button)e.getSource()).getSelection();
124
						}
125
					});
126
				}
127
				if(fShowProject) {
128
					butt = SWTUtil.createCheckButton(comp, MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_3, new String[] {fResource.getProject().getName()}), null, false);
129
					butt.addSelectionListener(new SelectionListener() {
130
						public void widgetDefaultSelected(SelectionEvent e) {}
131
						public void widgetSelected(SelectionEvent e) {
132
							fProject = ((Button)e.getSource()).getSelection();
133
						}
134
					});
135
				}
136
			}
137
			getTableViewer().setInput(input);
138
		}
139
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
140
		return comp;
141
	}
142
 
143
	/**
144
	 * Returns if the launched config from the selected shortcut should be made the default for the underlying resource
145
	 * @return if the launched config should be made the default
146
	 */
147
	public boolean makeDefault() {
148
		return fChecked;
149
	}
150
	
151
	/**
152
	 * Returns if the launched config from the selected shortcut should be made the default for the underlying resources' associated project
153
	 * @return if the launched config from the selected shortcut should be made the default for the underlying resources' associated project
154
	 */
155
	public boolean makeProjectDefault() {
156
		return fProject;
157
	}
158
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/RunContextLaunchingAction.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.core.ILaunchManager;
14
15
/**
16
 * Specialization of <code>ContextLaunchingAction</code> for run mode
17
 * 
18
 * @see {@link ContextLaunchingAction}
19
 * @see {@link ILaunchManager}
20
 * @see {@link DebugContextLaunchingAction}
21
 * @see {@link ProfileContextLaunchingAction}
22
 * 
23
 * @since 3.3
24
 * EXPERIMENTAL
25
 * CONTEXTLAUNCHING
26
 */
27
public class RunContextLaunchingAction extends ContextLaunchingAction {
28
29
	/**
30
	 * Constructor
31
	 */
32
	public RunContextLaunchingAction() {
33
		super(ILaunchManager.RUN_MODE);
34
	}
35
36
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java (+84 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
13
import java.util.Arrays;
14
import java.util.Collections;
15
import java.util.Comparator;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.DebugPlugin;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.ILaunchConfigurationType;
25
import org.eclipse.ui.model.WorkbenchViewerComparator;
26
27
/**
28
 * Groups configurations by type.
29
 * 
30
 * @since 3.3
31
 * EXPERIMENTAL
32
 * CONTEXTLAUNCHING
33
 */
34
public class LaunchConfigurationComparator extends WorkbenchViewerComparator {
35
36
	/**
37
	 * the map of categories of <code>ILaunchConfigurationType</code>s to <code>Integer</code>s entries
38
	 */
39
	private static Map fgCategories;
40
	
41
	/**
42
	 * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
43
	 */
44
	public int category(Object element) {
45
		Map map = getCategories();
46
		if (element instanceof ILaunchConfiguration) {
47
			ILaunchConfiguration configuration = (ILaunchConfiguration) element;
48
			try {
49
				Integer i = (Integer) map.get(configuration.getType());
50
				if (i != null) {
51
					return i.intValue();
52
				}
53
			} catch (CoreException e) {
54
			}
55
		}
56
		return map.size();
57
	}
58
	
59
	/**
60
	 * Returns the map of categories
61
	 * @return the map of categories
62
	 */
63
	private Map getCategories() {
64
		if (fgCategories == null) {
65
			fgCategories = new HashMap();
66
			List types = Arrays.asList(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes());
67
			Collections.sort(types, new Comparator() {
68
				public int compare(Object o1, Object o2) {
69
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
70
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
71
					return t1.getName().compareTo(t2.getName());
72
				}
73
			
74
			});
75
			Iterator iterator = types.iterator();
76
			int i = 0;
77
			while (iterator.hasNext()) {
78
				fgCategories.put(iterator.next(), new Integer(i));
79
				i++;
80
			}
81
		}
82
		return fgCategories;
83
	}
84
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.java (+29 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
	
14
	public static String ContextRunner_0;
15
	public static String ContextRunner_1;
16
	public static String ContextRunner_2;
17
	public static String ContextRunner_3;
18
	public static String ContextRunner_4;
19
	public static String ContextRunner_5;
20
	public static String ContextRunner_6;
21
	public static String OpenLaunchDialogAction_0;
22
	static {
23
		// initialize resource bundle
24
		NLS.initializeMessages(BUNDLE_NAME, ContextMessages.class);
25
	}
26
27
	private ContextMessages() {
28
	}
29
}
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/ContextMessages.properties (+8 lines)
Added Link Here
1
ContextRunner_0=Unable To Launch
2
ContextRunner_1=There is no way to launch the currently selected context, would you like to run the last thing you launched (pressing Cancel will end the attempt to launch)?
3
ContextRunner_2=Always perform this action
4
ContextRunner_3=Not Runnable
5
ContextRunner_4={0} is not runnable, would you like to check its'' parent project for a way to run it? (pressing Cancel will end the attempt to launch)?
6
ContextRunner_5=Cannot Launch
7
ContextRunner_6=Neither the selected resource or its'' associated project are launchable.
8
OpenLaunchDialogAction_0=Open {0} Dialog
(-)ui/org/eclipse/debug/internal/ui/contextlaunching/DebugContextLaunchingAction.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.contextlaunching;
12
13
import org.eclipse.debug.core.ILaunchManager;
14
15
/**
16
 * Specialization of <code>ContextLaunchingAction</code> for debug mode
17
 * 
18
 * @see {@link ContextLaunchingAction}
19
 * @see {@link ILaunchManager}
20
 * @see {@link RunContextLaunchingAction}
21
 * @see {@link ProfileContextLaunchingAction}
22
 * 
23
 * @since 3.3
24
 * EXPERIMENTAL
25
 * CONTEXTLAUNCHING
26
 */
27
public class DebugContextLaunchingAction extends ContextLaunchingAction {
28
	
29
	/**
30
	 * Constructor
31
	 */
32
	public DebugContextLaunchingAction() {
33
		super(ILaunchManager.DEBUG_MODE);
34
	}
35
}
(-)ui/org/eclipse/jdt/internal/debug/core/refactoring/LaunchConfigurationProjectMainTypeChange.java (-1 / +10 lines)
Lines 145-151 Link Here
145
		if (fNewProjectName != null) {
145
		if (fNewProjectName != null) {
146
			oldProjectName = fOldProjectName;
146
			oldProjectName = fOldProjectName;
147
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fNewProjectName);
147
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fNewProjectName);
148
			wc.setMappedResources(new IResource[] {ResourcesPlugin.getWorkspace().getRoot().getProject(fNewProjectName)});
148
			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(fNewProjectName);
149
			if(project != null) {
150
				IResource res = project.findMember(wc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null));
151
				if(res != null) {
152
					wc.setMappedResources(new IResource[] {res});
153
				}
154
			}
155
			else {
156
				wc.setMappedResources(new IResource[] {});
157
			}
149
		} 
158
		} 
150
		else {
159
		else {
151
			oldProjectName = null;
160
			oldProjectName = null;
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/AbstractJavaMainTab.java (-5 / +12 lines)
Lines 19-24 Link Here
19
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
20
import org.eclipse.jdt.core.IJavaModel;
20
import org.eclipse.jdt.core.IJavaModel;
21
import org.eclipse.jdt.core.IJavaProject;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.IType;
22
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
25
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
Lines 208-219 Link Here
208
	 * @param config
209
	 * @param config
209
	 */
210
	 */
210
	protected void mapResources(ILaunchConfigurationWorkingCopy config)  {
211
	protected void mapResources(ILaunchConfigurationWorkingCopy config)  {
211
		IJavaProject javaProject = getJavaProject();
212
		try {
212
		IResource[] resources = null;
213
			IJavaProject javaProject = getJavaProject();
213
		if (javaProject != null) {
214
			IResource[] resources = null;
214
			resources = new IResource[]{javaProject.getProject()};
215
			if (javaProject != null) {
216
				IType type = javaProject.findType(config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null));
217
				if (type != null) {
218
					resources = new IResource[] {type.getUnderlyingResource()};
219
				}
220
			}
221
			config.setMappedResources(resources);
215
		}
222
		}
216
		config.setMappedResources(resources);
223
		catch(CoreException ce) {JDIDebugUIPlugin.log(ce);}
217
	}	
224
	}	
218
	
225
	
219
}
226
}
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaApplicationLaunchShortcut.java (-1 / +1 lines)
Lines 72-78 Link Here
72
			wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName()));
72
			wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName()));
73
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
73
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
74
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
74
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
75
			wc.setMappedResources(new IResource[] {type.getJavaProject().getProject()});
75
			wc.setMappedResources(new IResource[] {type.getUnderlyingResource()});
76
			config = wc.doSave();
76
			config = wc.doSave();
77
		} catch (CoreException exception) {
77
		} catch (CoreException exception) {
78
			reportErorr(exception);		
78
			reportErorr(exception);		
(-)ui/org/eclipse/jdt/internal/debug/ui/launcher/JavaAppletLaunchShortcut.java (-1 / +1 lines)
Lines 39-45 Link Here
39
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH);
39
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH);
40
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT);
40
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT);
41
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$
41
			wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$
42
			wc.setMappedResources(new IResource[] {type.getJavaProject().getProject()});
42
			wc.setMappedResources(new IResource[] {type.getUnderlyingResource()});
43
			config = wc.doSave();		
43
			config = wc.doSave();		
44
		} catch (CoreException ce) {
44
		} catch (CoreException ce) {
45
			reportErorr(ce);			
45
			reportErorr(ce);			
(-)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