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

Collapse All | Expand All

(-)plugin.xml (-1 / +13 lines)
Lines 147-153 Link Here
147
      </page>
147
      </page>
148
      <page
148
      <page
149
            category="org.eclipse.debug.ui.LaunchingPreferencePage"
149
            category="org.eclipse.debug.ui.LaunchingPreferencePage"
150
            class="org.eclipse.debug.internal.ui.preferences.LaunchDelegatesPreferencePage"
150
            class="org.eclipse.debug.internal.ui.preferences.LaunchersPreferencePage"
151
            id="org.eclipse.debug.ui.LaunchDelegatesPreferencePage"
151
            id="org.eclipse.debug.ui.LaunchDelegatesPreferencePage"
152
            name="%LaunchDelegatesPreferencePage.name">
152
            name="%LaunchDelegatesPreferencePage.name">
153
         <keywordReference
153
         <keywordReference
Lines 1452-1457 Link Here
1452
            </or>
1452
            </or>
1453
         </enabledWhen>
1453
         </enabledWhen>
1454
      </page>
1454
      </page>
1455
      <page
1456
            class="org.eclipse.debug.internal.ui.launchConfigurations.PreferredLaunchersPropertyPage"
1457
            id="org.eclipse.debug.ui.launchConfigurationPropertyPage"
1458
            name="%preferredLaunchersPropertyPage.name">
1459
         <enabledWhen>
1460
            <and>
1461
               <instanceof
1462
                     value="org.eclipse.debug.core.ILaunchConfiguration">
1463
               </instanceof>
1464
            </and>
1465
         </enabledWhen>
1466
      </page>
1455
   </extension>
1467
   </extension>
1456
<!-- commands and their bindings
1468
<!-- commands and their bindings
1457
NOTE: 
1469
NOTE: 
(-)plugin.properties (+2 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
preferredLaunchersPropertyPage.name=Preferred Launchers
31
30
BreakpointActionSet.label=Breakpoints
32
BreakpointActionSet.label=Breakpoints
31
CollapseAll.label=Collapse All
33
CollapseAll.label=Collapse All
32
CollapseAll.tooltip= Collapse All
34
CollapseAll.tooltip= Collapse All
(-)ui/org/eclipse/debug/internal/ui/SWTUtil.java (+51 lines)
Lines 15-20 Link Here
15
import org.eclipse.jface.dialogs.IDialogConstants;
15
import org.eclipse.jface.dialogs.IDialogConstants;
16
import org.eclipse.jface.resource.JFaceResources;
16
import org.eclipse.jface.resource.JFaceResources;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.custom.CLabel;
18
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridData;
Lines 59-64 Link Here
59
		}
60
		}
60
	}		
61
	}		
61
	
62
	
63
	/**
64
	 * Creates a check box button using the parents' font
65
	 * @param parent the parent to add the button to
66
	 * @param label the label for the button
67
	 * @param image the image for the button 
68
	 * @param checked the initial checked state of the button
69
	 * @return a new checked button set to the initial checked state
70
	 * @since 3.3
71
	 */
72
	public static Button createCheckButton(Composite parent, String label, Image image, boolean checked) {
73
		Button button = new Button(parent, SWT.CHECK);
74
		button.setFont(parent.getFont());
75
		button.setSelection(checked);
76
		if(image != null) {
77
			button.setImage(image);
78
		}
79
		if(label != null) {
80
			button.setText(label);
81
		}
82
		GridData gd = new GridData();
83
		button.setLayoutData(gd);
84
		setButtonDimensionHint(button);
85
		return button;
86
	}
62
	
87
	
63
	/**
88
	/**
64
	 * Creates and returns a new push button with the given
89
	 * Creates and returns a new push button with the given
Lines 166-171 Link Here
166
	}
191
	}
167
	
192
	
168
	/**
193
	/**
194
	 * Creates a new <code>CLabel</code> that will wrap at the specified width and has the specified image
195
	 * @param parent the parent to add this label to
196
	 * @param text the text for the label
197
	 * @param image the image for the label
198
	 * @param hspan the h span to take up in the parent
199
	 * @param wrapwidth the with to wrap at
200
	 * @return a new <code>CLabel</code>
201
	 * @since 3.3
202
	 */
203
	public static CLabel createWrapCLabel(Composite parent, String text, Image image, int hspan, int wrapwidth) {
204
		CLabel label = new CLabel(parent, SWT.NONE | SWT.WRAP);
205
		label.setFont(parent.getFont());
206
		if(text != null) {
207
			label.setText(text);
208
		}
209
		if(image != null) {
210
			label.setImage(image);
211
		}
212
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
213
		gd.horizontalSpan = hspan;
214
		gd.widthHint = wrapwidth;
215
		label.setLayoutData(gd);
216
		return label;
217
	}
218
	
219
	/**
169
	 * Creates a wrapping label
220
	 * Creates a wrapping label
170
	 * @param parent the parent composite to add this label to
221
	 * @param parent the parent composite to add this label to
171
	 * @param text the text to be displayed in the label
222
	 * @param text the text to be displayed in the label
(-)ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java (+1 lines)
Lines 111-116 Link Here
111
	public static final String LAUNCH_CONFIGURATION_DIALOG_PERSPECTIVE_TAB = PREFIX + "launch_configuration_dialog_perspective_tab"; //$NON-NLS-1$	
111
	public static final String LAUNCH_CONFIGURATION_DIALOG_PERSPECTIVE_TAB = PREFIX + "launch_configuration_dialog_perspective_tab"; //$NON-NLS-1$	
112
	public static final String LAUNCH_CONFIGURATION_DIALOG_REFRESH_TAB = PREFIX + "launch_configuration_dialog refresh_tab"; //$NON-NLS-1$
112
	public static final String LAUNCH_CONFIGURATION_DIALOG_REFRESH_TAB = PREFIX + "launch_configuration_dialog refresh_tab"; //$NON-NLS-1$
113
	public static final String LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB = PREFIX +  "launch_configuration_dialog_environment_tab"; //$NON-NLS-1$
113
	public static final String LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB = PREFIX +  "launch_configuration_dialog_environment_tab"; //$NON-NLS-1$
114
	public static final String LAUNCH_CONFIGURATION_DIALOG_LAUNCHERS_TAB = PREFIX + "launch_configuration_dialog_launchers_tab"; //$NON-NLS-1$
114
	
115
	
115
	// Working set page
116
	// Working set page
116
	public static final String WORKING_SET_PAGE = PREFIX + "working_set_page_context"; //$NON-NLS-1$			
117
	public static final String WORKING_SET_PAGE = PREFIX + "working_set_page_context"; //$NON-NLS-1$			
(-)ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java (-15 / +7 lines)
Lines 137-142 Link Here
137
    public static final String PREF_LAUNCH_PERSPECTIVES = IDebugUIConstants.PLUGIN_ID + ".PREF_LAUNCH_PERSPECTIVES"; //$NON-NLS-1$
137
    public static final String PREF_LAUNCH_PERSPECTIVES = IDebugUIConstants.PLUGIN_ID + ".PREF_LAUNCH_PERSPECTIVES"; //$NON-NLS-1$
138
    
138
    
139
    /**
139
    /**
140
     * Represents the empty string
141
     * @since 3.3
142
     */
143
    public static final String EMPTY_STRING = ""; //$NON-NLS-1$
144
    
145
    /**
140
     * Preference for enabling/disabling launch configuration filtering based on project accessibilty status
146
     * Preference for enabling/disabling launch configuration filtering based on project accessibilty status
141
     * 
147
     * 
142
     * @since 3.2
148
     * @since 3.2
Lines 263-283 Link Here
263
	 * @since 3.1
269
	 * @since 3.1
264
	 */
270
	 */
265
	public static final String PREF_MAX_DETAIL_LENGTH = IDebugUIConstants.PLUGIN_ID + ".max_detail_length"; //$NON-NLS-1$
271
	public static final String PREF_MAX_DETAIL_LENGTH = IDebugUIConstants.PLUGIN_ID + ".max_detail_length"; //$NON-NLS-1$
266
	    
272
267
	/**
268
	 * Constant to describe the 'list' action for duplicate launch delegate resolution
269
	 * @since 3.3
270
	 * EXPERIMENTAL
271
	 */
272
	public static final String DELEGATE_ACTION_ID_LIST = "list"; //$NON-NLS-1$
273
	
274
	/**
275
	 * Constant to describe the 'dialog' action for duplicate delegate resolution 
276
	 * @since 3.3
277
	 * EXPERIMENTAL
278
	 */
279
	public static final String DELEGATE_ACTION_ID_DIALOG = "dialog"; //$NON-NLS-1$
280
	
281
	/**
273
	/**
282
	 * Font for Memory View
274
	 * Font for Memory View
283
	 * 
275
	 * 
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties (-3 / +11 lines)
Lines 34-39 Link Here
34
CommonTab_8=No file specified for process output
34
CommonTab_8=No file specified for process output
35
CommonTab_9=Variable&s...
35
CommonTab_9=Variable&s...
36
36
37
LaunchersTab_0=The settings on this tab all you to specify which launcher to use when multiple launchers are available for a configuration and launch mode.
38
LaunchersTab_1=Enable configuration specific settings
39
LaunchersTab_2=Launchers
40
LaunchersTab_3=<a>Change Workspace Settings...</a>
41
LaunchersTab_4=You must select a preferred launcher for 
42
LaunchersTab_6=You must select a workspace default or configuration specific preferred launcher
43
37
CompileErrorPromptStatusHandler_0=Errors in Project{0}
44
CompileErrorPromptStatusHandler_0=Errors in Project{0}
38
CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch?
45
CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch?
39
CompileErrorPromptStatusHandler_2=Errors exist in required project{0}: {1}.\nProceed with launch?
46
CompileErrorPromptStatusHandler_2=Errors exist in required project{0}: {1}.\nProceed with launch?
Lines 56-63 Link Here
56
LaunchConfigurationTabGroupViewer_9=The file associated with this launch configuration is read-only and cannot be modified.\n
63
LaunchConfigurationTabGroupViewer_9=The file associated with this launch configuration is read-only and cannot be modified.\n
57
LaunchConfigurationTabGroupViewer_13=Select a supported <a>launch mode</a>.
64
LaunchConfigurationTabGroupViewer_13=Select a supported <a>launch mode</a>.
58
LaunchConfigurationTabGroupViewer_14=Mixed launch mode not supported: {0}
65
LaunchConfigurationTabGroupViewer_14=Mixed launch mode not supported: {0}
59
LaunchConfigurationTabGroupViewer_15=Select preferred <a>launch tooling</a> for this type of configuration.
66
LaunchConfigurationTabGroupViewer_15=More than one launcher available - <a>Select other...</a>
60
LaunchConfigurationTabGroupViewer_16=There is duplicate launch tooling for the mixed mode: {0}
67
LaunchConfigurationTabGroupViewer_16=Using {0} - <a>Select other...</a>
68
LaunchConfigurationTabGroupViewer_17=Multiple launchers exist - <a>Choose one...</a>
61
69
62
LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations
70
LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations
63
LaunchConfigurationDialog_Dele_te_14=De&lete
71
LaunchConfigurationDialog_Dele_te_14=De&lete
Lines 70-76 Link Here
70
LaunchConfigurationDialog_Launch_Configuration_Error_46=Launch Configuration Error
78
LaunchConfigurationDialog_Launch_Configuration_Error_46=Launch Configuration Error
71
LaunchConfigurationDialog_Launch_Configurations_18=Launch Configurations
79
LaunchConfigurationDialog_Launch_Configurations_18=Launch Configurations
72
LaunchConfigurationDialog_Name_required_for_launch_configuration_11=Name required for launch configuration
80
LaunchConfigurationDialog_Name_required_for_launch_configuration_11=Name required for launch configuration
73
LaunchConfigurationDialog_Ne_w_13=Ne&w
81
LaunchConfigurationDialog_Ne_w_13=Ne&w\t\t
74
LaunchConfigurationDialog_No_33=No
82
LaunchConfigurationDialog_No_33=No
75
LaunchConfigurationEditDialog_0=Modify configuration and continue.
83
LaunchConfigurationEditDialog_0=Modify configuration and continue.
76
LaunchConfigurationEditDialog_1=Con&tinue
84
LaunchConfigurationEditDialog_1=Con&tinue
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupWrapper.java (-32 / +38 lines)
Lines 1-6 Link Here
1
package org.eclipse.debug.internal.ui.launchConfigurations;
1
package org.eclipse.debug.internal.ui.launchConfigurations;
2
2
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.Arrays;
4
import java.util.List;
5
import java.util.List;
5
6
6
import org.eclipse.core.runtime.CoreException;
7
import org.eclipse.core.runtime.CoreException;
Lines 30-35 Link Here
30
	
31
	
31
	private ILaunchConfigurationTabGroup fGroup = null;
32
	private ILaunchConfigurationTabGroup fGroup = null;
32
	private String fGroupId = null;
33
	private String fGroupId = null;
34
	/**
35
	 * listing of tab extensions that we have to create
36
	 */
33
	private List fTabs = null;
37
	private List fTabs = null;
34
	private String fMode = null;
38
	private String fMode = null;
35
	private ILaunchConfiguration fConfig = null;
39
	private ILaunchConfiguration fConfig = null;
Lines 38-43 Link Here
38
	 * Constructor
42
	 * Constructor
39
	 * @param group the existing group to wrapper
43
	 * @param group the existing group to wrapper
40
	 * @param groupId the string id of the associated tab group
44
	 * @param groupId the string id of the associated tab group
45
	 * @param config the launch configuration this tab group is opened on
41
	 */
46
	 */
42
	public LaunchConfigurationTabGroupWrapper(ILaunchConfigurationTabGroup group, String groupId, ILaunchConfiguration config) {
47
	public LaunchConfigurationTabGroupWrapper(ILaunchConfigurationTabGroup group, String groupId, ILaunchConfiguration config) {
43
		fGroup = group;
48
		fGroup = group;
Lines 60-68 Link Here
60
	 */
65
	 */
61
	public void dispose() {
66
	public void dispose() {
62
		if(fTabs != null) {
67
		if(fTabs != null) {
63
			ILaunchConfigurationTab[] tabs = getTabs();
68
			for(int i = 0; i < fTabs.size(); i++) {
64
			for(int i = 0; i < tabs.length; i++) {
69
				((ILaunchConfigurationTab)fTabs.get(i)).dispose();
65
				tabs[i].dispose();
66
			}
70
			}
67
			fTabs = null;
71
			fTabs = null;
68
		}
72
		}
Lines 75-115 Link Here
75
		if(fTabs == null) {
79
		if(fTabs == null) {
76
			try {
80
			try {
77
				fTabs = new ArrayList();
81
				fTabs = new ArrayList();
78
				ILaunchConfigurationTab[] tmp = fGroup.getTabs();
82
			//add the tab groups' tabs first (defaults)
79
				for(int i = 0; i < tmp.length; i++) {
83
				fTabs.addAll(Arrays.asList(fGroup.getTabs()));
80
					fTabs.add(tmp[i]);
84
			//last, add the extensions (if any)
81
				}
82
				LaunchConfigurationTabExtension[] ext = LaunchConfigurationPresentationManager.getDefault().getTabExtensions(fGroupId, fConfig, fMode);
85
				LaunchConfigurationTabExtension[] ext = LaunchConfigurationPresentationManager.getDefault().getTabExtensions(fGroupId, fConfig, fMode);
83
				//copy contributed into correct position or end if no id or id is not found
86
				//copy contributed into correct position or end if no id or id is not found
84
				AbstractLaunchConfigurationTab alct = null;
85
				String id = null;
87
				String id = null;
86
				List item = null;
87
				for(int i = 0; i < ext.length; i++) {
88
				for(int i = 0; i < ext.length; i++) {
88
					id = ext[i].getRelativeTabId();
89
					id = ext[i].getRelativeTabId();
89
					if(id != null) {
90
					if(id != null) {
90
						//position specified, try to find it
91
						int idx = indexofTab(id);
91
						boolean found = false;
92
						if(idx  > -1) {
92
						for(int j = 0; j < tmp.length; j++) {
93
							fTabs.add(idx+1, ext[i].getTab());
93
							if(tmp[j] instanceof AbstractLaunchConfigurationTab) {
94
								alct = (AbstractLaunchConfigurationTab) tmp[j];
95
								if(id.equals(alct.getId())) {
96
									if(j != tmp.length-1) {
97
										item = new ArrayList();
98
										item.add(ext[i].getTab());
99
										fTabs.addAll(j+1, item);
100
										found = true;
101
										break;
102
									}
103
								}
104
							}
105
						}
94
						}
106
						if(!found) {
95
						else {
107
							//id did not match any tabs, add it to the end
108
							fTabs.add(ext[i].getTab());
96
							fTabs.add(ext[i].getTab());
109
						}
97
						}
110
					}
98
					}
111
					else {
99
					else {
112
						//no position specified, add it to the end
113
						fTabs.add(ext[i].getTab());
100
						fTabs.add(ext[i].getTab());
114
					}
101
					}
115
				}
102
				}
Lines 120-133 Link Here
120
	}
107
	}
121
	
108
	
122
	/**
109
	/**
110
	 * Returns the index of the tab matching the specified id
111
	 * @param id the id of the tab to find the index for
112
	 * @return the index of the tab specified by the id or -1 if not found
113
	 */
114
	private int indexofTab(String id) {
115
		if(id != null) { 
116
			Object o = null;
117
			for(int i = 0; i < fTabs.size(); i++) {
118
				o = fTabs.get(i);
119
				if(o instanceof AbstractLaunchConfigurationTab) {
120
					if(id.equals(((AbstractLaunchConfigurationTab)o).getId())) {
121
						return i;
122
					}
123
				}
124
			}
125
		}
126
		return -1;
127
	}
128
	
129
	/**
123
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
130
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
124
	 */
131
	 */
125
	public void initializeFrom(ILaunchConfiguration configuration) {
132
	public void initializeFrom(ILaunchConfiguration configuration) {
126
		if(fTabs == null) {
133
		if(fTabs != null) {
127
			getTabs();
134
			for(int i = 0; i < fTabs.size(); i++) {
128
		}
135
				((ILaunchConfigurationTab)fTabs.get(i)).initializeFrom(configuration);
129
		for(int i = 0; i < fTabs.size(); i++) {
136
			}
130
			((ILaunchConfigurationTab)fTabs.get(i)).initializeFrom(configuration);
131
		}
137
		}
132
	}
138
	}
133
139
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-187 / +158 lines)
Lines 37-48 Link Here
37
import org.eclipse.jface.dialogs.IDialogConstants;
37
import org.eclipse.jface.dialogs.IDialogConstants;
38
import org.eclipse.jface.viewers.ISelection;
38
import org.eclipse.jface.viewers.ISelection;
39
import org.eclipse.jface.viewers.IStructuredSelection;
39
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.viewers.SelectionChangedEvent;
41
import org.eclipse.jface.viewers.StructuredSelection;
40
import org.eclipse.jface.viewers.StructuredSelection;
42
import org.eclipse.jface.viewers.Viewer;
41
import org.eclipse.jface.viewers.Viewer;
43
import org.eclipse.swt.SWT;
42
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.custom.BusyIndicator;
43
import org.eclipse.swt.custom.BusyIndicator;
45
import org.eclipse.swt.custom.CLabel;
46
import org.eclipse.swt.custom.CTabFolder;
44
import org.eclipse.swt.custom.CTabFolder;
47
import org.eclipse.swt.custom.CTabItem;
45
import org.eclipse.swt.custom.CTabItem;
48
import org.eclipse.swt.custom.StackLayout;
46
import org.eclipse.swt.custom.StackLayout;
Lines 67-73 Link Here
67
import org.eclipse.swt.widgets.Text;
65
import org.eclipse.swt.widgets.Text;
68
import org.eclipse.ui.IWorkbenchPreferenceConstants;
66
import org.eclipse.ui.IWorkbenchPreferenceConstants;
69
import org.eclipse.ui.PlatformUI;
67
import org.eclipse.ui.PlatformUI;
70
import org.eclipse.ui.activities.WorkbenchActivityHelper;
71
68
72
import com.ibm.icu.text.MessageFormat;
69
import com.ibm.icu.text.MessageFormat;
73
70
Lines 309-332 Link Here
309
								modes.remove(getLaunchConfigurationDialog().getMode());
306
								modes.remove(getLaunchConfigurationDialog().getMode());
310
								ILaunchConfigurationWorkingCopy wc = getWorkingCopy();
307
								ILaunchConfigurationWorkingCopy wc = getWorkingCopy();
311
								wc.setModes(modes);
308
								wc.setModes(modes);
312
								refresh();
313
								refreshStatus();
309
								refreshStatus();
314
							}
310
							}
315
						}
311
						}
316
					}
312
					}
317
					else if(hasDuplicateDelegates()) {
313
					else if(hasMultipleDelegates()) {
318
						Set modes = new HashSet();
314
						((LaunchConfigurationsDialog)getLaunchConfigurationDialog()).getPropertiesAction().run();
319
						modes.add(getLaunchConfigurationDialog().getMode());
320
						modes.addAll(getWorkingCopy().getModes());
321
						SelectLaunchDelegatesDialog sld = new SelectLaunchDelegatesDialog(getShell(), fTabType.getDelegates(modes));
322
						if(sld.open() == IDialogConstants.OK_ID) {
323
							Object[] res = sld.getResult();
324
							if(res != null) {
325
								fTabType.setPreferredDelegate(modes, (ILaunchDelegate) res[0]);
326
								disposeExistingTabs();
327
								displayInstanceTabs();
328
							}
329
						}
330
					}
315
					}
331
				} catch (CoreException ex) {}
316
				} catch (CoreException ex) {}
332
			}
317
			}
Lines 366-385 Link Here
366
	}
351
	}
367
	
352
	
368
	/**
353
	/**
369
	 * Simple method to create a spacer in the page
370
	 * 
371
	 * @param composite the composite to add the spacer to
372
	 * @param columnSpan the amount of space for the spacer
373
	 * @since 3.2
374
	 */
375
	protected void createSpacer(Composite composite, int columnSpan) {
376
		Label label = new Label(composite, SWT.NONE);
377
		GridData gd = new GridData();
378
		gd.horizontalSpan = columnSpan;
379
		label.setLayoutData(gd);
380
	}
381
	
382
	/**
383
	 * Creates some help text for the tab group launch types
354
	 * Creates some help text for the tab group launch types
384
	 * @param parent thep arent composite
355
	 * @param parent thep arent composite
385
	 * @since 3.2
356
	 * @since 3.2
Lines 387-410 Link Here
387
	private void createGettingStarted(Composite parent) {
358
	private void createGettingStarted(Composite parent) {
388
		Font font = parent.getFont();
359
		Font font = parent.getFont();
389
		GridData gd = null;
360
		GridData gd = null;
390
		createWrapLabel(parent, null, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1);
361
		int width = parent.getBounds().width - 30;
391
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 
362
		SWTUtil.createWrapLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1, 1, width);
392
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2);
363
		SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 1, width);
393
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG),
364
		SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), 1, width);
394
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6);
365
		SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), 1, width);
395
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), 
366
        SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width);
396
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4);
367
        SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 1, width);
397
        createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS),
398
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8);
399
        createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 
400
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3);
401
        
368
        
402
		createSpacer(parent, 2);
369
		SWTUtil.createHorizontalSpacer(parent, 2);
403
		Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
370
		Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
404
		link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5);
371
		link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5);
405
		link.setFont(font);
372
		link.setFont(font);
406
		gd = new GridData(GridData.FILL_HORIZONTAL);
373
		gd = new GridData(GridData.FILL_HORIZONTAL);
407
		gd.widthHint = parent.getBounds().width - 30;
374
		gd.widthHint = width;
408
		link.setLayoutData(gd);
375
		link.setLayoutData(gd);
409
		link.addSelectionListener(new SelectionListener() {
376
		link.addSelectionListener(new SelectionListener() {
410
			public void widgetSelected(SelectionEvent e) {
377
			public void widgetSelected(SelectionEvent e) {
Lines 413-434 Link Here
413
			public void widgetDefaultSelected(SelectionEvent e) {}
380
			public void widgetDefaultSelected(SelectionEvent e) {}
414
		});
381
		});
415
	}
382
	}
416
417
    /**
418
     * Create a label on the given parent that wraps text.
419
     * 
420
     * @param parent
421
     * @param text
422
     */
423
    private void createWrapLabel(Composite parent, Image image, String text) {
424
    	CLabel lbl = new CLabel(parent, SWT.NONE | SWT.WRAP);
425
    	lbl.setImage(image);
426
        lbl.setFont(parent.getFont());
427
        lbl.setText(text);
428
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
429
        gd.widthHint = parent.getBounds().width - 30;
430
        lbl.setLayoutData(gd);
431
    }
432
	
383
	
433
	/**
384
	/**
434
	 * Creates the tab folder for displaying config instances
385
	 * Creates the tab folder for displaying config instances
Lines 519-528 Link Here
519
	 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
470
	 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
520
	 */
471
	 */
521
	public ISelection getSelection() {
472
	public ISelection getSelection() {
522
		if (getActiveTab() == null) {
473
		return new StructuredSelection(fWorkingCopy);
523
			return new StructuredSelection();
524
		} 
525
		return new StructuredSelection(getActiveTab());
526
	}
474
	}
527
475
528
	/**
476
	/**
Lines 540-562 Link Here
540
			// update error ticks
488
			// update error ticks
541
			CTabItem item = null;
489
			CTabItem item = null;
542
			boolean error = false;
490
			boolean error = false;
491
			Image image = null;
543
			for (int i = 0; i < tabs.length; i++) {
492
			for (int i = 0; i < tabs.length; i++) {
544
				tabs[i].isValid(getWorkingCopy());
493
				error = tabs[i].getErrorMessage() != null && !tabs[i].isValid(getWorkingCopy());
545
				error = tabs[i].getErrorMessage() != null;
494
				image = tabs[i].getImage();
546
				item = fTabFolder.getItem(i);
495
				item = fTabFolder.getItem(i);
547
				setTabIcon(item, error, tabs[i]);
496
				if(error) {
497
					item.setImage(DebugUIPlugin.getDefault().getLaunchConfigurationManager().getErrorTabImage(tabs[i]));
498
				}
499
				else {
500
					item.setImage(image);
501
				}
548
			}
502
			}
549
			if(!canLaunchWithModes()) {
503
			showLink();
550
				fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13);
504
		}
505
	}
506
507
	/**
508
	 * Shows the link for either multiple launch delegates or bad launch mode combinations
509
	 * 
510
	 * @since 3.3
511
	 * 
512
	 * EXPERIMENTAL
513
	 */
514
	private void showLink() {
515
		String text = null;
516
		if(!canLaunchWithModes()) {
517
			text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13;
518
		}
519
		else if(hasMultipleDelegates()) {
520
			ILaunchDelegate delegate = getPreferredDelegate();
521
			if(delegate != null) {
522
				String name = delegate.getName();
523
				if(name == null) {
524
					text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_15;
525
				}
526
				else {
527
					text = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_16, new String[] {name});
528
				}
551
			}
529
			}
552
			else if(hasDuplicateDelegates()) {
530
			else {
553
				fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_15);
531
				text = LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_17;
554
			}
532
			}
555
			fOptionsLink.setVisible(!canLaunchWithModes() || hasDuplicateDelegates());
556
			fOptionsLink.getParent().layout();
557
		}
533
		}
534
		if(text != null) {
535
			fOptionsLink.setText(text);
536
		}
537
		fOptionsLink.setVisible(!canLaunchWithModes() || hasMultipleDelegates());
538
		fOptionsLink.getParent().layout();
558
	}
539
	}
559
540
	
541
	/**
542
	 * Returns the preferred launch delegate for the current launch configuration and mode set
543
	 * @return the preferred launch delegate
544
	 * 
545
	 * @since 3.3
546
	 * 
547
	 * EXPERIMENTAL
548
	 */
549
	protected ILaunchDelegate getPreferredDelegate() {
550
		ILaunchDelegate preferred = null;
551
		ILaunchConfigurationWorkingCopy config = getWorkingCopy();
552
		if(config != null) {
553
			try {
554
				Set modes = getCurrentModeSet();
555
				preferred = config.getPreferredDelegate(modes);
556
				if(preferred == null) {
557
					preferred = config.getType().getPreferredDelegate(modes);
558
				}
559
			}
560
			catch(CoreException ce) {DebugUIPlugin.log(ce);}
561
		}
562
		return preferred;
563
	}
564
	
565
	/**
566
	 * Returns the listing of modes for the current config
567
	 * @return the listing of modes for the current config
568
	 * @since 3.3
569
	 * 
570
	 * EXPERIMENTAL
571
	 */
572
	private Set getCurrentModeSet() {
573
		Set set = new HashSet();
574
		ILaunchConfigurationWorkingCopy config = getWorkingCopy();
575
		if(config != null) {
576
			try {
577
				set.addAll(config.getModes());
578
				set.add(getLaunchConfigurationDialog().getMode());
579
			}
580
			catch(CoreException ce) {DebugUIPlugin.log(ce);}
581
		}
582
		return set;
583
	}
584
	
560
	/**
585
	/**
561
	 * updates the button states
586
	 * updates the button states
562
	 */
587
	 */
Lines 565-584 Link Here
565
		fApplyButton.setEnabled(dirty && canSave());
590
		fApplyButton.setEnabled(dirty && canSave());
566
		fRevertButton.setEnabled(dirty);
591
		fRevertButton.setEnabled(dirty);
567
	}
592
	}
568
	
569
	/**
570
	 * Set the specified tab item's icon to an error icon if <code>error</code> is true,
571
	 * or a transparent icon of the same size otherwise.
572
	 */
573
	private void setTabIcon(CTabItem tabItem, boolean error, ILaunchConfigurationTab tab) {
574
		Image image = null;
575
		if (error) {
576
			image = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getErrorTabImage(tab);
577
		} else {
578
			image = tab.getImage();
579
		}
580
		tabItem.setImage(image);
581
	}	
582
593
583
	/* (non-Javadoc)
594
	/* (non-Javadoc)
584
	 * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object)
595
	 * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object)
Lines 673-679 Link Here
673
     */
684
     */
674
    protected void setFocusOnName() {
685
    protected void setFocusOnName() {
675
        fNameWidget.setFocus();
686
        fNameWidget.setFocus();
676
        
677
    }
687
    }
678
    
688
    
679
	/**
689
	/**
Lines 730-768 Link Here
730
	 * launch configuration type.
740
	 * launch configuration type.
731
	 */
741
	 */
732
	private void showInstanceTabsFor(ILaunchConfigurationType configType) {
742
	private void showInstanceTabsFor(ILaunchConfigurationType configType) {
733
734
		// Don't do any work if the current tabs are for the current config type
735
		if (fTabType != null && fTabType.equals(configType)) { 
736
			return;
737
		}
738
		
739
		// try to keep on same tab
743
		// try to keep on same tab
740
		Class tabKind = null;
744
		Class tabKind = null;
741
		if (getActiveTab() != null) {
745
		if (getActiveTab() != null) {
742
			tabKind = getActiveTab().getClass();
746
			tabKind = getActiveTab().getClass();
743
		}
747
		}
744
		
745
		// Build the new tabs
748
		// Build the new tabs
746
		ILaunchConfigurationTabGroup group = null;
749
		ILaunchConfigurationTabGroup group = null;
747
		try {
750
		try {
748
			group = createGroup(configType);
751
			group = createGroup();
749
		} catch (CoreException ce) {
752
		} catch (CoreException ce) {
750
			DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_Exception_occurred_creating_launch_configuration_tabs_27,ce); // 
753
			DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_Exception_occurred_creating_launch_configuration_tabs_27,ce); // 
751
			return;
754
			return;
752
		}
755
		}
753
756
		disposeExistingTabs();
754
		showTabsFor(group);
755
		fTabGroup = group;
757
		fTabGroup = group;
756
		fTabType = configType;
758
		fTabType = configType;
757
		
758
		// select same tab as before, if possible
759
		ILaunchConfigurationTab[] tabs = getTabs();
759
		ILaunchConfigurationTab[] tabs = getTabs();
760
		CTabItem tab = null;
761
		String name = EMPTY_STRING;
762
		Control control = null;
763
		for (int i = 0; i < tabs.length; i++) {
764
			tab = new CTabItem(fTabFolder, SWT.BORDER);
765
			name = tabs[i].getName();
766
			if (name == null) {
767
				name = LaunchConfigurationsMessages.LaunchConfigurationDialog_unspecified_28; 
768
			}
769
			tab.setText(name);
770
			tab.setImage(tabs[i].getImage());
771
			tabs[i].createControl(tab.getParent());
772
			control = tabs[i].getControl();
773
			if (control != null) {
774
				tab.setControl(control);
775
			}
776
		}
760
		//set the default tab as the first one
777
		//set the default tab as the first one
761
		setActiveTab(tabs[0]);
778
		setActiveTab(tabs[0]);
779
		// select same tab as before, if possible
762
		for (int i = 0; i < tabs.length; i++) {
780
		for (int i = 0; i < tabs.length; i++) {
763
			ILaunchConfigurationTab tab = tabs[i];
781
			if (tabs[i].getClass().equals(tabKind)) {
764
			if (tab.getClass().equals(tabKind)) {
782
				setActiveTab(tabs[i]);
765
				setActiveTab(tab);
766
				break;
783
				break;
767
			}
784
			}
768
		}
785
		}
Lines 782-830 Link Here
782
			String mode = fDialog.getMode();
799
			String mode = fDialog.getMode();
783
			description = LaunchConfigurationPresentationManager.getDefault().getDescription(configType, mode);
800
			description = LaunchConfigurationPresentationManager.getDefault().getDescription(configType, mode);
784
		}	
801
		}	
785
		if (description == null)
802
		if (description == null) {
786
			description = EMPTY_STRING;
803
			description = EMPTY_STRING;
804
		}
787
		return description;
805
		return description;
788
	}
806
	}
789
	
807
	
790
	/**
808
	/**
791
	 * Create the tabs in the configuration edit area for the given tab group.
792
	 */
793
	private void showTabsFor(ILaunchConfigurationTabGroup tabGroup) {
794
		// Dispose the current tabs
795
		disposeExistingTabs();
796
797
		fTabGroup = tabGroup;
798
799
		// Create the Control for each tab
800
		ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
801
		CTabItem tab = null;
802
		String name = EMPTY_STRING;
803
		Control control = null;
804
		for (int i = 0; i < tabs.length; i++) {
805
			tab = new CTabItem(fTabFolder, SWT.BORDER);
806
			name = tabs[i].getName();
807
			if (name == null) {
808
				name = LaunchConfigurationsMessages.LaunchConfigurationDialog_unspecified_28; 
809
			}
810
			tab.setText(name);
811
			tab.setImage(tabs[i].getImage());
812
			tabs[i].createControl(tab.getParent());
813
			control = tabs[i].getControl();
814
			if (control != null) {
815
				tab.setControl(control);
816
			}
817
		}
818
819
	}	
820
	
821
	/**
822
	 * Returns tab group for the given type of launch configuration.
809
	 * Returns tab group for the given type of launch configuration.
823
	 * Tabs are initialized to be contained in this dialog.
810
	 * Tabs are initialized to be contained in this dialog.
824
	 *
811
	 *
825
	 * @exception CoreException if unable to instantiate a tab group
812
	 * @exception CoreException if unable to instantiate a tab group
826
	 */
813
	 */
827
	protected ILaunchConfigurationTabGroup createGroup(final ILaunchConfigurationType configType) throws CoreException {
814
	protected ILaunchConfigurationTabGroup createGroup() throws CoreException {
828
		// Use a final Object array to store the tab group and any exception that
815
		// Use a final Object array to store the tab group and any exception that
829
		// results from the Runnable
816
		// results from the Runnable
830
		final Object[] finalArray = new Object[2];
817
		final Object[] finalArray = new Object[2];
Lines 869-876 Link Here
869
				if (object instanceof ILaunchConfigurationTab) {
856
				if (object instanceof ILaunchConfigurationTab) {
870
					ILaunchConfigurationTab[] tabs = getTabs();
857
					ILaunchConfigurationTab[] tabs = getTabs();
871
					for (int i = 0; i < tabs.length; i++) {
858
					for (int i = 0; i < tabs.length; i++) {
872
						ILaunchConfigurationTab tab = tabs[i];
859
						if (tabs[i].equals(object)) {
873
						if (tab.equals(object)) {
874
							fCurrentTabIndex = i;
860
							fCurrentTabIndex = i;
875
							fTabFolder.setSelection(i);
861
							fTabFolder.setSelection(i);
876
						}
862
						}
Lines 1029-1035 Link Here
1029
				return false;
1015
				return false;
1030
			}
1016
			}
1031
		}
1017
		}
1032
		
1033
		return true;
1018
		return true;
1034
	}	
1019
	}	
1035
	
1020
	
Lines 1053-1061 Link Here
1053
		try {
1038
		try {
1054
			ILaunchConfigurationWorkingCopy wc = getWorkingCopy();
1039
			ILaunchConfigurationWorkingCopy wc = getWorkingCopy();
1055
			if(wc != null) {
1040
			if(wc != null) {
1056
				Set modes = wc.getModes();
1041
				return wc.getType().supportsModeCombination(getCurrentModeSet());
1057
				modes.add(getLaunchConfigurationDialog().getMode());
1058
				return wc.getType().supportsModeCombination(modes);
1059
			}
1042
			}
1060
		}  catch (CoreException e) {
1043
		}  catch (CoreException e) {
1061
		}
1044
		}
Lines 1077-1100 Link Here
1077
		if(fInitializingTabs) {
1060
		if(fInitializingTabs) {
1078
			return false;
1061
			return false;
1079
		}
1062
		}
1080
		try {
1063
		ILaunchConfiguration config = getWorkingCopy();
1081
			ILaunchConfiguration config = getWorkingCopy();
1064
		if(config != null) {
1082
			if(config != null) {
1065
			if(hasMultipleDelegates()) {
1083
				Set modes = config.getModes();
1066
				return getPreferredDelegate() == null;
1084
				modes.add(getLaunchConfigurationDialog().getMode());
1067
			}
1068
		}
1069
		return false;
1070
	}
1071
	
1072
	/**
1073
	 * Determines if the currently showing launch configuration has multiple launch delegates for the same mode set, but does not care
1074
	 * if there has been a default selected yet or not
1075
	 * @return true if the current launch configuraiton has multiple launch delegates, false otherwise
1076
	 */
1077
	private boolean hasMultipleDelegates() {
1078
		ILaunchConfiguration config = getWorkingCopy();
1079
		if(config != null) {
1080
			try {
1081
				Set modes = getCurrentModeSet();
1085
				ILaunchDelegate[] delegates = LaunchConfigurationManager.filterLaunchDelegates(fTabType, modes);
1082
				ILaunchDelegate[] delegates = LaunchConfigurationManager.filterLaunchDelegates(fTabType, modes);
1086
				if(delegates.length > 1) {
1083
				return delegates.length > 1;
1087
					ILaunchDelegate preferred = fTabType.getPreferredDelegate(modes);
1088
					if(preferred == null) {
1089
						return true;
1090
					}
1091
					else if(WorkbenchActivityHelper.filterItem(new LaunchDelegateContribution(preferred))) {
1092
						return true;
1093
					}
1094
				}
1095
			}
1084
			}
1085
			catch (CoreException ce) {DebugUIPlugin.log(ce);}
1096
		}
1086
		}
1097
		catch(CoreException ce) {DebugUIPlugin.log(ce);}
1098
		return false;
1087
		return false;
1099
	}
1088
	}
1100
	
1089
	
Lines 1141-1170 Link Here
1141
				return temp.toString();
1130
				return temp.toString();
1142
			}
1131
			}
1143
		}
1132
		}
1144
		if(getWorkingCopy() != null) {
1133
		if(getWorkingCopy().isReadOnly()) {
1145
			if(getWorkingCopy().isReadOnly()) {
1134
			return LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9;
1146
				return LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9;
1147
			}
1148
		}
1135
		}
1149
		//EXPERIMENTAL
1136
		//EXPERIMENTAL
1150
		if(!canLaunchWithModes()) {
1137
		if(!canLaunchWithModes()) {
1151
			try {
1138
			Set modes = getCurrentModeSet();
1152
				Set modes = getWorkingCopy().getModes();
1139
			List names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes);
1153
				modes.add(getLaunchConfigurationDialog().getMode());
1140
			return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_14, new String[]{names.toString()});
1154
				List names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes);
1155
				return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_14, new String[]{names.toString()});
1156
			} catch (CoreException e) {
1157
				return e.getMessage();
1158
			}
1159
		}
1160
		if(hasDuplicateDelegates()) {
1161
			try {
1162
				Set modes = getWorkingCopy().getModes();
1163
				modes.add(getLaunchConfigurationDialog().getMode());
1164
				List names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes);
1165
				return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_16, new String[] {names.toString()});
1166
			}
1167
			catch (CoreException e) {DebugUIPlugin.log(e);}
1168
		}
1141
		}
1169
		return null;
1142
		return null;
1170
	}	
1143
	}	
Lines 1293-1300 Link Here
1293
			}
1266
			}
1294
		}
1267
		}
1295
		fCurrentTabIndex = fTabFolder.getSelectionIndex();
1268
		fCurrentTabIndex = fTabFolder.getSelectionIndex();
1296
		SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
1297
		fireSelectionChanged(event);
1298
	}
1269
	}
1299
	
1270
	
1300
	/**
1271
	/**
Lines 1342-1348 Link Here
1342
			if(fTabGroup != null) {
1313
			if(fTabGroup != null) {
1343
				fTabGroup.initializeFrom(fOriginal);
1314
				fTabGroup.initializeFrom(fOriginal);
1344
				fWorkingCopy = fOriginal.getWorkingCopy();
1315
				fWorkingCopy = fOriginal.getWorkingCopy();
1345
				refresh();
1346
				refreshStatus();
1316
				refreshStatus();
1347
			}
1317
			}
1348
		} 
1318
		} 
Lines 1366-1376 Link Here
1366
	 */
1336
	 */
1367
	public void setActiveTab(ILaunchConfigurationTab tab) {
1337
	public void setActiveTab(ILaunchConfigurationTab tab) {
1368
		ILaunchConfigurationTab[] tabs = getTabs();
1338
		ILaunchConfigurationTab[] tabs = getTabs();
1369
		for (int i = 0; i < tabs.length; i++) {
1339
		if(tabs != null) {
1370
			ILaunchConfigurationTab configurationTab = tabs[i];
1340
			for (int i = 0; i < tabs.length; i++) {
1371
			if (configurationTab.equals(tab)) {
1341
				if (tabs[i].getClass().equals(tab.getClass())) {
1372
				setActiveTab(i);
1342
					setActiveTab(i);
1373
				return;
1343
					return;
1344
				}
1374
			}
1345
			}
1375
		}
1346
		}
1376
	}
1347
	}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java (+9 lines)
Lines 99-106 Link Here
99
99
100
	public static String LaunchConfigurationTabGroupViewer_16;
100
	public static String LaunchConfigurationTabGroupViewer_16;
101
101
102
	public static String LaunchConfigurationTabGroupViewer_17;
102
	public static String LaunchConfigurationTabGroupViewer_9;
103
	public static String LaunchConfigurationTabGroupViewer_9;
103
	public static String LaunchConfigurationTabGroupViewer_13;
104
	public static String LaunchConfigurationTabGroupViewer_13;
105
106
	public static String LaunchersTab_3;
107
	public static String LaunchersTab_4;
108
	public static String LaunchersTab_6;
104
	public static String PerspectiveManager_Error_1;
109
	public static String PerspectiveManager_Error_1;
105
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
110
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
106
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
111
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
Lines 215-219 Link Here
215
	public static String SelectLaunchOptionsDialog_2;
220
	public static String SelectLaunchOptionsDialog_2;
216
	public static String SelectLaunchOptionsDialog_3;
221
	public static String SelectLaunchOptionsDialog_3;
217
	public static String SelectLaunchOptionsDialog_4;
222
	public static String SelectLaunchOptionsDialog_4;
223
	
224
	public static String LaunchersTab_0;
225
	public static String LaunchersTab_1;
226
	public static String LaunchersTab_2;
218
227
219
}
228
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java (+11 lines)
Lines 731-736 Link Here
731
		return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DuplicateLaunchConfigurationAction.ID_DUPLICATE_ACTION);
731
		return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DuplicateLaunchConfigurationAction.ID_DUPLICATE_ACTION);
732
	}
732
	}
733
  	
733
  	
734
  	/**
735
  	 * returns the properties action 
736
  	 * @return the 'Properties' action from the context menu of the launch view
737
  	 * 
738
  	 * @since 3.3
739
  	 * EXPERIMENTAL
740
  	 */
741
  	protected IAction getPropertiesAction() {
742
  		return fLaunchConfigurationView.getAction(LaunchConfigurationPropertiesAction.ID_PROPERTIES_ACTION);
743
  	}
744
  	
734
	/**
745
	/**
735
	 * Gets the help context id
746
	 * Gets the help context id
736
	 * 
747
	 * 
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchDelegatesDialog.java (-67 / +11 lines)
Lines 1-34 Link Here
1
package org.eclipse.debug.internal.ui.launchConfigurations;
1
package org.eclipse.debug.internal.ui.launchConfigurations;
2
2
3
import java.util.Arrays;
3
import java.util.ArrayList;
4
4
5
import org.eclipse.debug.core.ILaunchDelegate;
5
import org.eclipse.debug.core.ILaunchDelegate;
6
import org.eclipse.debug.internal.ui.DebugUIPlugin;
6
import org.eclipse.debug.internal.ui.DebugUIPlugin;
7
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
7
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
8
import org.eclipse.debug.internal.ui.SWTUtil;
9
import org.eclipse.debug.ui.IDebugUIConstants;
8
import org.eclipse.debug.ui.IDebugUIConstants;
10
import org.eclipse.jface.dialogs.Dialog;
9
import org.eclipse.jface.dialogs.Dialog;
11
import org.eclipse.jface.dialogs.IDialogConstants;
10
import org.eclipse.jface.dialogs.IDialogConstants;
12
import org.eclipse.jface.dialogs.IDialogSettings;
11
import org.eclipse.jface.dialogs.IDialogSettings;
13
import org.eclipse.jface.viewers.ArrayContentProvider;
14
import org.eclipse.jface.viewers.CheckStateChangedEvent;
12
import org.eclipse.jface.viewers.CheckStateChangedEvent;
15
import org.eclipse.jface.viewers.CheckboxTableViewer;
13
import org.eclipse.jface.viewers.CheckboxTableViewer;
16
import org.eclipse.jface.viewers.ICheckStateListener;
14
import org.eclipse.jface.viewers.ICheckStateListener;
17
import org.eclipse.jface.viewers.ILabelProvider;
18
import org.eclipse.jface.viewers.ILabelProviderListener;
19
import org.eclipse.jface.viewers.ISelectionChangedListener;
20
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.viewers.SelectionChangedEvent;
22
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.graphics.Image;
24
import org.eclipse.swt.graphics.Point;
16
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Group;
29
import org.eclipse.swt.widgets.Shell;
19
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Table;
31
import org.eclipse.swt.widgets.Text;
32
import org.eclipse.ui.PlatformUI;
20
import org.eclipse.ui.PlatformUI;
33
import org.eclipse.ui.dialogs.SelectionDialog;
21
import org.eclipse.ui.dialogs.SelectionDialog;
34
22
Lines 43-79 Link Here
43
 * EXPERIMENTAL
31
 * EXPERIMENTAL
44
 */
32
 */
45
public class SelectLaunchDelegatesDialog extends SelectionDialog {
33
public class SelectLaunchDelegatesDialog extends SelectionDialog {
46
47
	/**
48
	 * Builds labels for list control
49
	 */
50
	class DelegatesLabelProvider implements ILabelProvider {
51
		public Image getImage(Object element) {return null;}
52
		public String getText(Object element) {
53
			if(element instanceof ILaunchDelegate) {
54
				ILaunchDelegate ldp = (ILaunchDelegate) element;
55
				String name = ldp.getName();
56
				if(name == null) {
57
					name = ldp.getContributorName();
58
				}
59
				return name;
60
			}
61
			return element.toString();
62
		}
63
		public void addListener(ILabelProviderListener listener) {}
64
		public void dispose() {}
65
		public boolean isLabelProperty(Object element, String property) {return false;}
66
		public void removeListener(ILabelProviderListener listener) {}
67
	}
68
	
34
	
69
	private static final String SETTINGS_ID = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_DELEGATES_DIALOG"; //$NON-NLS-1$
35
	private static final String SETTINGS_ID = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_DELEGATES_DIALOG"; //$NON-NLS-1$
70
	
36
	
71
	private CheckboxTableViewer fTableViewer = null;
37
	private SelectLaunchDelegatePanel fPanel = null;
72
	private Table fTable  = null;
73
	private ILaunchDelegate[] fDelegates = null;
38
	private ILaunchDelegate[] fDelegates = null;
74
	private Text fDescriptionText = null;
75
	private final String EMPTY_STRING = ""; //$NON-NLS-1$
76
	
77
	/**
39
	/**
78
	 * Constructor
40
	 * Constructor
79
	 * @param parentShell the parent shell
41
	 * @param parentShell the parent shell
Lines 95-128 Link Here
95
	protected Control createDialogArea(Composite parent) {
57
	protected Control createDialogArea(Composite parent) {
96
		initializeDialogUnits(parent);
58
		initializeDialogUnits(parent);
97
		Composite comp = (Composite) super.createDialogArea(parent);
59
		Composite comp = (Composite) super.createDialogArea(parent);
98
		SWTUtil.createLabel(comp, LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_2, 1);
60
		fPanel = new SelectLaunchDelegatePanel(comp);
99
		fTable = new Table(comp, SWT.BORDER | SWT.SINGLE | SWT.CHECK);
61
		fPanel.initialize(fDelegates);
100
		fTable.setLayoutData(new GridData(GridData.FILL_BOTH));
62
		CheckboxTableViewer viewer = fPanel.getTableViewer();
101
		fTableViewer = new CheckboxTableViewer(fTable);
63
		viewer.addCheckStateListener(new ICheckStateListener() {
102
		fTableViewer.setLabelProvider(new DelegatesLabelProvider());
103
		fTableViewer.setContentProvider(new ArrayContentProvider());
104
		fTableViewer.setInput(fDelegates);
105
		fTableViewer.addCheckStateListener(new ICheckStateListener() {
106
			public void checkStateChanged(CheckStateChangedEvent event) {
64
			public void checkStateChanged(CheckStateChangedEvent event) {
107
				fTableViewer.setAllChecked(false);
108
				fTableViewer.setChecked(event.getElement(), true);
109
				getButton(IDialogConstants.OK_ID).setEnabled(true);
65
				getButton(IDialogConstants.OK_ID).setEnabled(true);
110
			}
66
			}
111
		});
67
		});
112
		fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
113
			public void selectionChanged(SelectionChangedEvent event) {
114
				IStructuredSelection ss = (IStructuredSelection) event.getSelection();
115
				if(ss != null && !ss.isEmpty()) {
116
					fDescriptionText.setText(((ILaunchDelegate)ss.getFirstElement()).getDescription());
117
				}
118
				else {
119
					fDescriptionText.setText(EMPTY_STRING);
120
				}
121
			}
122
		});
123
		Group group = SWTUtil.createGroup(comp, LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_3, 1, 1, GridData.FILL_BOTH);
124
		fDescriptionText = SWTUtil.createText(group, SWT.WRAP | SWT.READ_ONLY, 1, GridData.FILL_BOTH);
125
		fDescriptionText.setBackground(group.getBackground());
126
		Dialog.applyDialogFont(comp);		
68
		Dialog.applyDialogFont(comp);		
127
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_DELEGATES_DIALOG);
69
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_DELEGATES_DIALOG);
128
		return comp;
70
		return comp;
Lines 140-148 Link Here
140
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
82
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
141
	 */
83
	 */
142
	protected void okPressed() {
84
	protected void okPressed() {
143
		Object[] o =  fTableViewer.getCheckedElements();
85
		Object delegate = fPanel.getSelectedDelegate();
144
		if(o.length > 0) {
86
		if(delegate != null) {
145
			setResult(Arrays.asList(o));
87
			ArrayList list = new ArrayList();
88
			list.add(delegate);
89
			setResult(list);
146
		}
90
		}
147
		super.okPressed();
91
		super.okPressed();
148
	}
92
	}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java (-2 / +13 lines)
Lines 75-80 Link Here
75
	private DeleteLaunchConfigurationAction fDeleteAction;
75
	private DeleteLaunchConfigurationAction fDeleteAction;
76
	private DuplicateLaunchConfigurationAction fDuplicateAction;
76
	private DuplicateLaunchConfigurationAction fDuplicateAction;
77
	private CollapseAllLaunchConfigurationAction fCollapseAllAction;
77
	private CollapseAllLaunchConfigurationAction fCollapseAllAction;
78
	private LaunchConfigurationPropertiesAction fPropertiesAction;
78
	
79
	
79
	/**
80
	/**
80
	 * Action for providing filtering to the Launch Configuraiton Dialog
81
	 * Action for providing filtering to the Launch Configuraiton Dialog
Lines 101-106 Link Here
101
		fLaunchGroup = launchGroup;
102
		fLaunchGroup = launchGroup;
102
	}
103
	}
103
	
104
	
105
	/**
106
	 * Constructor
107
	 * @param launchGroup
108
	 * @param filters
109
	 */
104
	public LaunchConfigurationView(LaunchGroupExtension launchGroup, ViewerFilter[] filters) {
110
	public LaunchConfigurationView(LaunchGroupExtension launchGroup, ViewerFilter[] filters) {
105
		super();
111
		super();
106
		fLaunchGroup = launchGroup;
112
		fLaunchGroup = launchGroup;
Lines 181-186 Link Here
181
		
187
		
182
		fFilterAction = new FilterLaunchConfigurationAction();
188
		fFilterAction = new FilterLaunchConfigurationAction();
183
		setAction(FilterLaunchConfigurationAction.ID_FILTER_ACTION, fFilterAction);
189
		setAction(FilterLaunchConfigurationAction.ID_FILTER_ACTION, fFilterAction);
190
		
191
		fPropertiesAction = new LaunchConfigurationPropertiesAction((LaunchConfigurationsDialog) LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog(), getViewer());
192
		setAction(LaunchConfigurationPropertiesAction.ID_PROPERTIES_ACTION, fPropertiesAction);
193
		
184
	}
194
	}
185
195
186
	/**
196
	/**
Lines 198-203 Link Here
198
		menu.add(fDuplicateAction);
208
		menu.add(fDuplicateAction);
199
		menu.add(fDeleteAction);
209
		menu.add(fDeleteAction);
200
		menu.add(new Separator());
210
		menu.add(new Separator());
211
		menu.add(fPropertiesAction);
201
	}
212
	}
202
213
203
	/**
214
	/**
Lines 223-228 Link Here
223
		fDuplicateAction.dispose();
234
		fDuplicateAction.dispose();
224
		fFilterAction = null;
235
		fFilterAction = null;
225
		fCollapseAllAction = null;
236
		fCollapseAllAction = null;
237
		fPropertiesAction.dispose();
226
		getLaunchManager().removeLaunchConfigurationListener(this);
238
		getLaunchManager().removeLaunchConfigurationListener(this);
227
	}
239
	}
228
240
Lines 277-284 Link Here
277
	/**
289
	/**
278
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
290
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationChanged(org.eclipse.debug.core.ILaunchConfiguration)
279
	 */
291
	 */
280
	public void launchConfigurationChanged(ILaunchConfiguration configuration) {
292
	public void launchConfigurationChanged(ILaunchConfiguration configuration) {}
281
	}
282
293
283
	/**
294
	/**
284
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
295
	 * @see org.eclipse.debug.core.ILaunchConfigurationListener#launchConfigurationRemoved(org.eclipse.debug.core.ILaunchConfiguration)
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java (-3 / +6 lines)
Lines 175-181 Link Here
175
	}
175
	}
176
	
176
	
177
	/**
177
	/**
178
	 * Returns the tab group for the given launch configutation, its type and the mode the dialog opened in
178
	 * Returns the tab group for the given launch configutation and the mode the dialog opened in
179
	 * @param type the type of the configuration
179
	 * @param type the type of the configuration
180
	 * @param config
180
	 * @param config
181
	 * @param mode
181
	 * @param mode
Lines 195-201 Link Here
195
	/**
195
	/**
196
	 * Returns the proxy elements for all contributed tabs for the specified tab group id
196
	 * Returns the proxy elements for all contributed tabs for the specified tab group id
197
	 * @param groupid the id of the tab group
197
	 * @param groupid the id of the tab group
198
	 * @param type the type the tab group is opened on
198
	 * @param config the config the tab group is opened on
199
	 * @param mode the mode the associated launch dialog is opened on
199
	 * @param mode the mode the associated launch dialog is opened on
200
	 * @return the listing of all of the tab extensions or an empty array, never <code>null</code>
200
	 * @return the listing of all of the tab extensions or an empty array, never <code>null</code>
201
	 * 
201
	 * 
Lines 241-247 Link Here
241
			//filter to preferred delegate (if there is one)
241
			//filter to preferred delegate (if there is one)
242
				HashSet modes = (HashSet) config.getModes();
242
				HashSet modes = (HashSet) config.getModes();
243
				modes.add(mode);
243
				modes.add(mode);
244
				ILaunchDelegate delegate = config.getType().getPreferredDelegate(modes);
244
				ILaunchDelegate delegate = config.getPreferredDelegate(modes);
245
				if(delegate == null) {
246
					delegate = config.getType().getPreferredDelegate(modes);
247
				}
245
				if(delegate != null) {
248
				if(delegate != null) {
246
					if(tabs[i].getDelegateSet().contains(delegate.getId())) {
249
					if(tabs[i].getDelegateSet().contains(delegate.getId())) {
247
						set.add(tabs[i]);
250
						set.add(tabs[i]);
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java (-2 / +1 lines)
Lines 72-79 Link Here
72
				tabGroup.createTabs(dialog, dialog.getMode());
72
				tabGroup.createTabs(dialog, dialog.getMode());
73
				ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
73
				ILaunchConfigurationTab[] tabs = tabGroup.getTabs();
74
				for (int i = 0; i < tabs.length; i++) {
74
				for (int i = 0; i < tabs.length; i++) {
75
					ILaunchConfigurationTab tab = tabs[i];
75
					tabs[i].setLaunchConfigurationDialog(dialog);
76
					tab.setLaunchConfigurationDialog(dialog);
77
				}
76
				}
78
				tabGroup.setDefaults(wc);
77
				tabGroup.setDefaults(wc);
79
				tabGroup.dispose();
78
				tabGroup.dispose();
(-)ui/org/eclipse/debug/internal/ui/preferences/LaunchDelegatesPreferencePage.java (-312 lines)
Removed 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.HashMap;
14
import java.util.HashSet;
15
import java.util.Iterator;
16
import java.util.Map;
17
import java.util.Set;
18
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.ILaunchConfigurationType;
22
import org.eclipse.debug.core.ILaunchDelegate;
23
import org.eclipse.debug.internal.core.LaunchManager;
24
import org.eclipse.debug.internal.ui.DebugUIPlugin;
25
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
26
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
27
import org.eclipse.debug.internal.ui.SWTUtil;
28
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager;
29
import org.eclipse.jface.preference.PreferencePage;
30
import org.eclipse.jface.viewers.ArrayContentProvider;
31
import org.eclipse.jface.viewers.CheckStateChangedEvent;
32
import org.eclipse.jface.viewers.CheckboxTableViewer;
33
import org.eclipse.jface.viewers.ICheckStateListener;
34
import org.eclipse.jface.viewers.ISelectionChangedListener;
35
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jface.viewers.ITreeContentProvider;
37
import org.eclipse.jface.viewers.SelectionChangedEvent;
38
import org.eclipse.jface.viewers.TreeViewer;
39
import org.eclipse.jface.viewers.Viewer;
40
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.layout.GridData;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Control;
44
import org.eclipse.swt.widgets.Group;
45
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.swt.widgets.Text;
47
import org.eclipse.swt.widgets.Tree;
48
import org.eclipse.ui.IWorkbench;
49
import org.eclipse.ui.IWorkbenchPreferencePage;
50
import org.eclipse.ui.PlatformUI;
51
import org.eclipse.ui.model.WorkbenchViewerComparator;
52
53
/**
54
 * This class provides a preference page for selecting and changing preferred launch delegates for those of them
55
 * that have conflicting delegates.
56
 * 
57
 * Delegates are considered to be conflicting if they are for the same launc configuraiton type, and apply to the same 
58
 * mode sets.
59
 * 
60
 * @since 3.3
61
 * 
62
 * TODO create a help topic for this page....it needs a good description
63
 * 
64
 * EXPERIMENTAL
65
 */
66
public class LaunchDelegatesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
67
68
	/**
69
	 * Class to collect and persist attributes to sufficiently describe a dupicate launch delegate
70
	 */
71
	class DuplicateDelegate {
72
		private ILaunchConfigurationType fType = null;
73
		private ILaunchDelegate[] fDelegates = null;
74
		private Set fModes = null;
75
		
76
		public DuplicateDelegate(ILaunchConfigurationType type, ILaunchDelegate[] delegates, Set modes) {
77
			fModes = modes;
78
			fType = type;
79
			fDelegates = delegates;
80
		}
81
		
82
		public ILaunchConfigurationType getType() {
83
			return fType;
84
		}
85
		public ILaunchDelegate[] getDelegates() {
86
			return fDelegates;
87
		}
88
		public Set getModeSet() {
89
			return fModes;
90
		}
91
	}
92
	
93
	/**
94
	 * label provider to extend the default one, provides labels to both the tree and table of this page
95
	 */
96
	class LabelProvider extends DefaultLabelProvider {
97
		public String getText(Object element) {
98
			if(element instanceof ILaunchConfigurationType) {
99
				return super.getText(element);
100
			}
101
			else if(element instanceof DuplicateDelegate) {
102
				DuplicateDelegate dd = (DuplicateDelegate) element;
103
				return LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(dd.getModeSet()).toString();
104
			}
105
			else if(element instanceof ILaunchDelegate){
106
				return ((ILaunchDelegate) element).getName();
107
			}
108
			return element.toString();
109
		}
110
	}
111
	
112
	/**
113
	 * This class is used to provide content to the tree
114
	 */
115
	class TreeProvider implements ITreeContentProvider {
116
		public Object[] getChildren(Object parentElement) {
117
			if(parentElement instanceof ILaunchConfigurationType) {
118
				ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement;
119
				Set dupes = (Set) fDuplicates.get(type);
120
				if(dupes != null) {
121
					return dupes.toArray();
122
				}
123
				return null;
124
			}
125
			return null;
126
		}
127
		public boolean hasChildren(Object element) {
128
			return element instanceof ILaunchConfigurationType;
129
		}
130
		public Object[] getElements(Object inputElement) {
131
			if(inputElement instanceof Map) {
132
				return ((Map)inputElement).keySet().toArray();
133
			}
134
			return null;
135
		}
136
		public Object getParent(Object element) {return null;}
137
		public void dispose() {}
138
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
139
	}
140
	
141
	private TreeViewer fTreeViewer = null;
142
	private CheckboxTableViewer fTableViewer = null;
143
	private Map fDuplicates = null;
144
	private Map fDupeSelections = null;
145
	private boolean fDirty = false;
146
	private Text fDescription = null;
147
	
148
	/**
149
	 * Constructor
150
	 */
151
	public LaunchDelegatesPreferencePage() {
152
		setTitle(DebugPreferencesMessages.LaunchDelegatesPreferencePage_0);
153
	}
154
155
	/**
156
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
157
	 */
158
	public void createControl(Composite parent) {
159
		super.createControl(parent);
160
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCH_DELEGATES_PREFERENCE_PAGE);
161
	}
162
163
	/**
164
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
165
	 */
166
	protected Control createContents(Composite parent) {
167
		Composite comp = SWTUtil.createComposite(parent, 2, 1, GridData.FILL_BOTH);
168
		SWTUtil.createWrapLabel(comp, DebugPreferencesMessages.LaunchDelegatesPreferencePage_1, 2, 300);
169
		
170
		SWTUtil.createVerticalSpacer(comp, 1);
171
	//tree
172
		Composite comp1 = SWTUtil.createComposite(comp, 1, 1, GridData.FILL_VERTICAL);
173
		SWTUtil.createLabel(comp1, DebugPreferencesMessages.LaunchDelegatesPreferencePage_2, 1);
174
		Tree tree = new Tree(comp1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE);
175
		GridData gd = new GridData(GridData.FILL_BOTH);
176
		gd.grabExcessHorizontalSpace = false;
177
		tree.setLayoutData(gd);
178
		fTreeViewer = new TreeViewer(tree);
179
		fTreeViewer.setComparator(new WorkbenchViewerComparator());
180
		fTreeViewer.setContentProvider(new TreeProvider());
181
		fTreeViewer.setLabelProvider(new LabelProvider());
182
		fTreeViewer.setInput(fDuplicates);
183
		fTreeViewer.expandToLevel(2);
184
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
185
			public void selectionChanged(SelectionChangedEvent event) {
186
				Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
187
				if(obj instanceof DuplicateDelegate) {
188
					fTableViewer.setAllChecked(false);
189
					DuplicateDelegate dd = (DuplicateDelegate) obj;
190
					fTableViewer.setInput(dd.getDelegates());
191
					obj = fDupeSelections.get(dd);
192
					if(obj != null) {
193
						fTableViewer.setChecked(obj, true);
194
					}
195
				}
196
				else {
197
					fTableViewer.setInput(null);
198
				}
199
			}
200
		});
201
		
202
	//table
203
		Composite comp2 = SWTUtil.createComposite(comp, comp.getFont(), 1, 1, GridData.FILL_BOTH);
204
		SWTUtil.createLabel(comp2, DebugPreferencesMessages.LaunchDelegatesPreferencePage_3, 1);
205
		Table table = new Table(comp2, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.SINGLE);
206
		table.setLayoutData(new GridData(GridData.FILL_BOTH));
207
		fTableViewer = new CheckboxTableViewer(table);
208
		fTableViewer.setComparator(new WorkbenchViewerComparator());
209
		fTableViewer.setLabelProvider(new LabelProvider());
210
		fTableViewer.setContentProvider(new ArrayContentProvider());
211
		fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
212
			public void selectionChanged(SelectionChangedEvent event) {
213
				IStructuredSelection ss = (IStructuredSelection) event.getSelection();
214
				if(ss != null && !ss.isEmpty()) {
215
					fDescription.setText(((ILaunchDelegate)ss.getFirstElement()).getDescription());
216
				}
217
				else {
218
					fDescription.setText(""); //$NON-NLS-1$
219
				}
220
			}
221
		});
222
		fTableViewer.addCheckStateListener(new ICheckStateListener() {
223
			public void checkStateChanged(CheckStateChangedEvent event) {
224
				fDirty = true;
225
				Object element = event.getElement();
226
				boolean checked = event.getChecked();
227
				fTableViewer.setAllChecked(false);
228
				//always set checked, this way users cannot 'undo' a change to selecting a preferred delegate
229
				//The story for this is that on startup if there are dupes, the user is prompted to pick a delegate, after that they cannot 
230
				//return to a state of not being able to launch something, but can pick a different delegate
231
				fTableViewer.setChecked(element, true);
232
				//persist the selection
233
				Object obj = ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
234
				if(obj instanceof DuplicateDelegate) {
235
					fDupeSelections.remove(obj);
236
					if(checked) {
237
						fDupeSelections.put(obj, element);
238
					}
239
				}
240
			}
241
		});
242
		Group group = SWTUtil.createGroup(comp, DebugPreferencesMessages.LaunchDelegatesPreferencePage_4, 1, 2, GridData.FILL_BOTH);
243
		fDescription = SWTUtil.createText(group, SWT.WRAP | SWT.READ_ONLY, 1, GridData.FILL_BOTH);
244
		fDescription.setBackground(group.getBackground());
245
		return comp;
246
	}
247
248
	/**
249
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
250
	 */
251
	public boolean performOk() {
252
		if(fDirty && fDupeSelections != null && fDupeSelections.size() > 0) {
253
			fDirty = false;
254
			DuplicateDelegate dd = null;
255
			ILaunchDelegate delegate = null;
256
			for(Iterator iter = fDupeSelections.keySet().iterator(); iter.hasNext();) {
257
				dd = (DuplicateDelegate) iter.next();
258
				delegate = (ILaunchDelegate) fDupeSelections.get(dd);
259
				try {
260
					dd.getType().setPreferredDelegate(dd.getModeSet(), delegate);
261
				} 
262
				catch (CoreException e) {DebugUIPlugin.log(e);}
263
			}
264
		}
265
		if(getPreferenceStore().needsSaving()) {
266
			DebugUIPlugin.getDefault().savePluginPreferences();
267
		}
268
		return super.performOk();
269
	}
270
271
	/**
272
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
273
	 */
274
	public void init(IWorkbench workbench) {
275
		//init a listing of duplicate delegates arranged by type
276
		try {
277
			setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
278
			LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
279
			ILaunchConfigurationType[] types = lm.getLaunchConfigurationTypes();
280
			fDuplicates = new HashMap();
281
			fDupeSelections = new HashMap();
282
			Set modes = null;
283
			ILaunchDelegate[] delegates = null;
284
			Set modeset = null;
285
			Set tmp = null;
286
			ILaunchDelegate prefdelegate = null;
287
			DuplicateDelegate dd = null;
288
			for(int i = 0; i < types.length; i++) {
289
				modes = types[i].getSupportedModeCombinations();
290
				for(Iterator iter = modes.iterator(); iter.hasNext();) {
291
					modeset = (Set) iter.next();
292
					delegates = types[i].getDelegates(modeset);
293
					if(delegates.length > 1) {
294
						tmp = (Set) fDuplicates.get(types[i]);
295
						if(tmp == null) {
296
							tmp = new HashSet();
297
						}
298
						dd = new DuplicateDelegate(types[i], delegates, modeset);
299
						tmp.add(dd);
300
						fDuplicates.put(types[i], tmp);
301
						prefdelegate = types[i].getPreferredDelegate(modeset);
302
						if(prefdelegate != null) {
303
							fDupeSelections.put(dd, prefdelegate);
304
						}
305
					}
306
				}
307
			}
308
		}
309
		catch(CoreException e) {DebugUIPlugin.log(e);}
310
	}
311
312
}
(-)schema/launchConfigurationTabs.exsd (-1 / +1 lines)
Lines 66-72 Link Here
66
         <attribute name="class" type="string" use="required">
66
         <attribute name="class" type="string" use="required">
67
            <annotation>
67
            <annotation>
68
               <documentation>
68
               <documentation>
69
                  fully qualified name of the java class that implemnents &lt;code&gt;ILaunchConfigurationTab&lt;/code&gt;.
69
                  fully qualified name of the java class that implements &lt;code&gt;ILaunchConfigurationTab&lt;/code&gt;.
70
               </documentation>
70
               </documentation>
71
               <appInfo>
71
               <appInfo>
72
                  <meta.attribute kind="java" basedOn="org.eclipse.debug.ui.ILaunchConfigurationTab"/>
72
                  <meta.attribute kind="java" basedOn="org.eclipse.debug.ui.ILaunchConfigurationTab"/>
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectLaunchDelegatePanel.java (+164 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 org.eclipse.debug.core.ILaunchDelegate;
14
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.SWTUtil;
16
import org.eclipse.jface.viewers.ArrayContentProvider;
17
import org.eclipse.jface.viewers.CheckStateChangedEvent;
18
import org.eclipse.jface.viewers.CheckboxTableViewer;
19
import org.eclipse.jface.viewers.ICheckStateListener;
20
import org.eclipse.jface.viewers.ILabelProvider;
21
import org.eclipse.jface.viewers.ILabelProviderListener;
22
import org.eclipse.jface.viewers.ISelectionChangedListener;
23
import org.eclipse.jface.viewers.IStructuredSelection;
24
import org.eclipse.jface.viewers.SelectionChangedEvent;
25
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.graphics.Image;
28
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Group;
31
import org.eclipse.swt.widgets.Table;
32
import org.eclipse.swt.widgets.Text;
33
import org.eclipse.ui.model.WorkbenchViewerComparator;
34
35
/**
36
 * This class provides a reusable panel for the present a listing of <code>ILaunchDelegate</code>s to a user 
37
 * with a description field
38
 * 
39
 * EXPERIMENTAL
40
 * @since 3.3
41
 */
42
public class SelectLaunchDelegatePanel {
43
44
	/**
45
	 * Builds labels for table control
46
	 */
47
	class DelegatesLabelProvider implements ILabelProvider {
48
		public Image getImage(Object element) {return null;}
49
		public String getText(Object element) {
50
			if(element instanceof ILaunchDelegate) {
51
				ILaunchDelegate ldp = (ILaunchDelegate) element;
52
				String name = ldp.getName();
53
				if(name == null) {
54
					name = ldp.getContributorName();
55
				}
56
				return name;
57
			}
58
			return element.toString();
59
		}
60
		public void addListener(ILabelProviderListener listener) {}
61
		public void dispose() {}
62
		public boolean isLabelProperty(Object element, String property) {return false;}
63
		public void removeListener(ILabelProviderListener listener) {}
64
	}
65
	
66
	private Table fTable = null;
67
	private CheckboxTableViewer fTableViewer = null;
68
	private Text fDescriptionText = null;
69
	
70
	/**
71
	 * Constructor
72
	 * @param parent
73
	 * @param initialSelection
74
	 */
75
	public SelectLaunchDelegatePanel(Composite parent) {
76
		createControl(parent);
77
	}
78
	
79
	/**
80
	 * Creates the selection control on the specified parent composite
81
	 * @param parent the parent to add this control to
82
	 */
83
	protected void createControl(Composite parent) {
84
		Composite comp  = SWTUtil.createComposite(parent, 1, 1, GridData.FILL_BOTH);
85
		SWTUtil.createLabel(comp, LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_2, 1);
86
		fTable = new Table(comp, SWT.BORDER | SWT.SINGLE | SWT.CHECK);
87
		fTable.setLayoutData(new GridData(GridData.FILL_BOTH));
88
		fTableViewer = new CheckboxTableViewer(fTable);
89
		fTableViewer.setLabelProvider(new DelegatesLabelProvider());
90
		fTableViewer.setContentProvider(new ArrayContentProvider());
91
		fTableViewer.setComparator(new WorkbenchViewerComparator());
92
		fTableViewer.addCheckStateListener(new ICheckStateListener() {
93
			public void checkStateChanged(CheckStateChangedEvent event) {
94
				fTableViewer.setCheckedElements(new Object[] {event.getElement()});
95
			}
96
		});
97
		fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
98
			public void selectionChanged(SelectionChangedEvent event) {
99
				IStructuredSelection ss = (IStructuredSelection) event.getSelection();
100
				if(ss != null && !ss.isEmpty()) {
101
					fDescriptionText.setText(((ILaunchDelegate)ss.getFirstElement()).getDescription());
102
				}
103
				else {
104
					fDescriptionText.setText(IInternalDebugUIConstants.EMPTY_STRING);
105
				}
106
			}
107
		});
108
		Group group = SWTUtil.createGroup(comp, LaunchConfigurationsMessages.SelectLaunchDelegatesDialog_3, 1, 1, GridData.FILL_BOTH);
109
		fDescriptionText = SWTUtil.createText(group, SWT.WRAP | SWT.READ_ONLY, 1, GridData.FILL_BOTH);
110
		fDescriptionText.setBackground(group.getBackground());
111
	}
112
	
113
	/**
114
	 * This method initializes the input to the launch delegates viewer, and should be called before trying to set the selection 
115
	 * @param delegates the listing of delegates to set as input for this viewer
116
	 */
117
	public void initialize(ILaunchDelegate[] delegates) {
118
		fTableViewer.setInput(delegates);
119
	}
120
	
121
	/**
122
	 * Returns the currently checked launch delegate
123
	 * @return the currently selected launch delegate or <code>null</code> if none are checked
124
	 */
125
	public ILaunchDelegate getSelectedDelegate() {
126
		Object[] checked = fTableViewer.getCheckedElements();
127
		if(checked.length > 0) {
128
			return (ILaunchDelegate) checked[0];
129
		}
130
		return null;
131
	}
132
	
133
	/**
134
	 * Sets the enabled state of the panels' usable controls
135
	 * @param enabled the enabled state desired for the panels' usable controls
136
	 */
137
	public void setEnabled(boolean enabled) {
138
		fTable.setEnabled(enabled);
139
	}
140
	
141
	/**
142
	 * This method will both select and set as checked the specified delegate, if found in the table viewer
143
	 * @param delegate the delegate to set as selected AND checked in the table view
144
	 */
145
	public void setSelection(ILaunchDelegate delegate) {
146
		if(delegate != null) {
147
			fTableViewer.setSelection(new StructuredSelection(delegate));
148
			fTableViewer.setCheckedElements(new Object[] {delegate});
149
		}
150
		else {
151
			fTableViewer.setSelection(new StructuredSelection());
152
			fTableViewer.setAllChecked(false);
153
		}
154
	}
155
	
156
	/**
157
	 * Returns the check table viewer so subclasses can work directly with it
158
	 * @return the check box table viewer from this control
159
	 */
160
	protected CheckboxTableViewer getTableViewer() {
161
		return fTableViewer;
162
	}
163
164
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesAction.java (+72 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.Set;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.internal.ui.DebugUIPlugin;
18
import org.eclipse.jface.viewers.ISelectionProvider;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.jface.window.IShellProvider;
21
import org.eclipse.ui.dialogs.PropertyDialogAction;
22
23
/**
24
 * Subclass to allow access the the run method of rht eproperrty dialog action
25
 * 
26
 * @since 3.3
27
 * EXPERIMENTAL
28
 */
29
public class LaunchConfigurationPropertiesAction extends PropertyDialogAction {
30
31
	/**
32
	 * Action identifier for IDebugView#getAction(String)
33
	 */
34
	public static final String ID_PROPERTIES_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_PROPERTIES_ACTION"; //$NON-NLS-1$
35
	
36
	/**
37
	 * Constructor
38
	 * @param shell
39
	 * @param provider
40
	 */
41
	public LaunchConfigurationPropertiesAction(IShellProvider shell, ISelectionProvider provider) {
42
		super(shell, provider);
43
	}
44
45
	/**
46
	 * @see org.eclipse.ui.dialogs.PropertyDialogAction#run()
47
	 */
48
	public void run() {
49
		super.run();
50
		((LaunchConfigurationsDialog)LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog()).getTabViewer().displayInstanceTabs();
51
	}
52
53
	/**
54
	 * @see org.eclipse.ui.dialogs.PropertyDialogAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
55
	 */
56
	public void selectionChanged(IStructuredSelection selection) {
57
		if(selection != null && !selection.isEmpty()) {
58
			Object o = selection.getFirstElement();
59
			if(o instanceof ILaunchConfiguration) {
60
				try {
61
					ILaunchConfiguration config = (ILaunchConfiguration) o;
62
					Set modes = config.getModes();
63
					modes.add(LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog().getMode());
64
					setEnabled(config.getType().getDelegates(modes).length > 1);
65
					return;
66
				}
67
				catch(CoreException ce) {DebugUIPlugin.log(ce);}
68
			}
69
		}
70
		setEnabled(false);
71
	}
72
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/PreferredLaunchersPropertyPage.java (+231 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.HashSet;
14
import java.util.Set;
15
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.ILaunchConfiguration;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.debug.core.ILaunchDelegate;
20
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
22
import org.eclipse.debug.internal.ui.SWTUtil;
23
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
24
import org.eclipse.jface.viewers.CheckStateChangedEvent;
25
import org.eclipse.jface.viewers.ICheckStateListener;
26
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.SelectionEvent;
29
import org.eclipse.swt.events.SelectionListener;
30
import org.eclipse.swt.layout.GridData;
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.swt.widgets.Label;
35
import org.eclipse.swt.widgets.Link;
36
import org.eclipse.ui.IWorkbenchPropertyPage;
37
import org.eclipse.ui.PlatformUI;
38
import org.eclipse.ui.dialogs.PropertyPage;
39
40
/**
41
 * This class provides a property page for editing the properties of a launch configuration in the launch dialog
42
 * 
43
 *  @since 3.3
44
 *  EXPERIMENTAL
45
 */
46
public class PreferredLaunchersPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
47
48
	private Button fUseSystemLauncher = null;
49
	private SelectLaunchDelegatePanel fPanel = null;
50
	
51
	/**
52
	 * Constructor
53
	 */
54
	public PreferredLaunchersPropertyPage() {}
55
56
	/**
57
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
58
	 */
59
	protected Control createContents(Composite parent) {
60
		Composite comp = SWTUtil.createComposite(parent, 1, 1, GridData.FILL_BOTH);
61
		Label label = SWTUtil.createWrapLabel(comp, LaunchConfigurationsMessages.LaunchersTab_0, 1);
62
		((GridData)label.getLayoutData()).widthHint = 40;
63
		SWTUtil.createVerticalSpacer(comp, 1);
64
		Composite c2 = SWTUtil.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL);
65
		fUseSystemLauncher = SWTUtil.createCheckButton(c2, LaunchConfigurationsMessages.LaunchersTab_1, null, true);
66
		Link link = new Link(c2, SWT.NONE);
67
		link.setText(LaunchConfigurationsMessages.LaunchersTab_3);
68
		link.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
69
		
70
		SWTUtil.createVerticalSpacer(comp, 1);
71
		fPanel = new SelectLaunchDelegatePanel(comp);
72
		fPanel.getTableViewer().addCheckStateListener(new ICheckStateListener() {
73
			public void checkStateChanged(CheckStateChangedEvent event) {
74
				setValid(isValid());
75
				
76
			}
77
		});
78
		
79
		initialize();
80
		
81
	//add selection listeners after so we can access the panel
82
		fUseSystemLauncher.addSelectionListener(new SelectionListener() {
83
			public void widgetDefaultSelected(SelectionEvent e) {}
84
			public void widgetSelected(SelectionEvent e) {
85
				boolean checked = ((Button)e.widget).getSelection();
86
				fPanel.setEnabled(checked);
87
				resetDelegate();
88
				setValid(isValid());
89
			}
90
		});
91
		link.addSelectionListener(new SelectionListener() {
92
			public void widgetDefaultSelected(SelectionEvent e) {}
93
			public void widgetSelected(SelectionEvent e) {
94
				SWTUtil.showPreferencePage("org.eclipse.debug.ui.LaunchDelegatesPreferencePage"); //$NON-NLS-1$
95
				if(!fUseSystemLauncher.getSelection()) {
96
					resetDelegate();
97
					setValid(isValid());
98
				}
99
			}
100
		});
101
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_LAUNCHERS_TAB);
102
		return comp;
103
	}
104
105
	/**
106
	 * Resets the selected and checked delegate in the preferred launcher view part to be the one from the workspace
107
	 */
108
	private void resetDelegate() {
109
		ILaunchConfiguration config = getLaunchConfiguration();
110
		if(!fUseSystemLauncher.getSelection()) {
111
			try {
112
				ILaunchDelegate preferred = config.getType().getPreferredDelegate(getModes());
113
				if(preferred != null) {
114
					fPanel.setSelection(preferred);
115
				}
116
			}
117
			catch (CoreException ce) {DebugUIPlugin.log(ce);}
118
		}
119
	}
120
	
121
	/**
122
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
123
	 */
124
	protected void performDefaults() {
125
		if(fUseSystemLauncher != null) {
126
			fUseSystemLauncher.setSelection(false);
127
			resetDelegate();
128
			fPanel.setEnabled(false);
129
		}
130
		super.performDefaults();
131
	}
132
133
	/**
134
	 * Initializes the page
135
	 */
136
	private void initialize() {
137
		try {
138
			fPanel.initialize(getLaunchConfiguration().getType().getDelegates(getModes()));
139
			ILaunchConfigurationWorkingCopy config = getLaunchConfiguration();
140
			Set modes = getModes();
141
			ILaunchDelegate delegate = config.getPreferredDelegate(modes);
142
			boolean custom = delegate != null;
143
			fUseSystemLauncher.setSelection(custom);
144
			fPanel.setEnabled(custom);
145
			//load the pref settings
146
			fPanel.initialize(config.getType().getDelegates(modes));
147
			if(delegate == null) {
148
				delegate = config.getType().getPreferredDelegate(modes);
149
			}
150
			fPanel.setSelection(delegate);
151
		} 
152
		catch (CoreException e1) {DebugUIPlugin.log(e1);}
153
	}
154
	
155
	/**
156
	 * @return the launch configuration backing this property page
157
	 */
158
	private ILaunchConfigurationWorkingCopy getLaunchConfiguration() {
159
		LaunchConfigurationsDialog dialog = (LaunchConfigurationsDialog) LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
160
		return (ILaunchConfigurationWorkingCopy) ((IStructuredSelection)dialog.getTabViewer().getSelection()).getFirstElement();
161
	}
162
	
163
	/**
164
	 * @see org.eclipse.jface.preference.PreferencePage#isValid()
165
	 */
166
	public boolean isValid() {
167
		setErrorMessage(null);
168
		if(fPanel.getSelectedDelegate() == null) {
169
			if(fUseSystemLauncher.getSelection()) {
170
				ILaunchConfigurationWorkingCopy config = getLaunchConfiguration();
171
				setErrorMessage(LaunchConfigurationsMessages.LaunchersTab_4+config.getName());
172
				return false;
173
			}
174
			else {
175
				setErrorMessage(LaunchConfigurationsMessages.LaunchersTab_6);
176
				return false;
177
			}
178
		}
179
		return true;
180
	}
181
182
	/**
183
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
184
	 */
185
	public boolean performOk() {
186
		ILaunchConfigurationWorkingCopy config = getLaunchConfiguration();
187
		Set modes = getModes();
188
		ILaunchDelegate delegate = null;
189
		if(fUseSystemLauncher.getSelection()) {
190
			delegate = fPanel.getSelectedDelegate();	
191
			if(delegate != null) {
192
				config.setPreferredLaunchDelegate(modes, delegate.getId());
193
			}
194
		}
195
		else {
196
			config.setPreferredLaunchDelegate(modes, null);
197
		}
198
		if(config.isDirty()) {
199
			try {
200
				config.doSave();
201
			} 
202
			catch (CoreException e) {DebugUIPlugin.log(e);}
203
		}
204
		updateLaunchDialog();
205
		return super.performOk();
206
	}
207
	
208
	/**
209
	 * @return the complete set of modes that the associated launch configuration is concerned with
210
	 */
211
	private Set getModes() {
212
		Set modes = new HashSet();
213
		try {
214
			ILaunchConfigurationWorkingCopy config = getLaunchConfiguration().getWorkingCopy();
215
			modes = config.getModes();
216
			modes.add(LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog().getMode());
217
		}
218
		catch (CoreException ce) {DebugUIPlugin.log(ce);}
219
		return modes;
220
	}
221
	
222
	/**
223
	 * updates the currently visible launch dialog
224
	 */
225
	private void updateLaunchDialog() {
226
		ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
227
		dialog.updateButtons();
228
		dialog.updateMessage();
229
	}
230
	
231
}
(-)ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java (+312 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.HashMap;
14
import java.util.HashSet;
15
import java.util.Iterator;
16
import java.util.Map;
17
import java.util.Set;
18
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.ILaunchConfigurationType;
22
import org.eclipse.debug.core.ILaunchDelegate;
23
import org.eclipse.debug.internal.core.LaunchManager;
24
import org.eclipse.debug.internal.ui.DebugUIPlugin;
25
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
26
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
27
import org.eclipse.debug.internal.ui.SWTUtil;
28
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPresentationManager;
29
import org.eclipse.jface.preference.PreferencePage;
30
import org.eclipse.jface.viewers.ArrayContentProvider;
31
import org.eclipse.jface.viewers.CheckStateChangedEvent;
32
import org.eclipse.jface.viewers.CheckboxTableViewer;
33
import org.eclipse.jface.viewers.ICheckStateListener;
34
import org.eclipse.jface.viewers.ISelectionChangedListener;
35
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jface.viewers.ITreeContentProvider;
37
import org.eclipse.jface.viewers.SelectionChangedEvent;
38
import org.eclipse.jface.viewers.TreeViewer;
39
import org.eclipse.jface.viewers.Viewer;
40
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.layout.GridData;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Control;
44
import org.eclipse.swt.widgets.Group;
45
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.swt.widgets.Text;
47
import org.eclipse.swt.widgets.Tree;
48
import org.eclipse.ui.IWorkbench;
49
import org.eclipse.ui.IWorkbenchPreferencePage;
50
import org.eclipse.ui.PlatformUI;
51
import org.eclipse.ui.model.WorkbenchViewerComparator;
52
53
/**
54
 * This class provides a preference page for selecting and changing preferred launch delegates for those of them
55
 * that have conflicting delegates.
56
 * 
57
 * Delegates are considered to be conflicting if they are for the same launc configuraiton type, and apply to the same 
58
 * mode sets.
59
 * 
60
 * @since 3.3
61
 * 
62
 * TODO create a help topic for this page....it needs a good description
63
 * 
64
 * EXPERIMENTAL
65
 */
66
public class LaunchersPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
67
68
	/**
69
	 * Class to collect and persist attributes to sufficiently describe a dupicate launch delegate
70
	 */
71
	class DuplicateDelegate {
72
		private ILaunchConfigurationType fType = null;
73
		private ILaunchDelegate[] fDelegates = null;
74
		private Set fModes = null;
75
		
76
		public DuplicateDelegate(ILaunchConfigurationType type, ILaunchDelegate[] delegates, Set modes) {
77
			fModes = modes;
78
			fType = type;
79
			fDelegates = delegates;
80
		}
81
		
82
		public ILaunchConfigurationType getType() {
83
			return fType;
84
		}
85
		public ILaunchDelegate[] getDelegates() {
86
			return fDelegates;
87
		}
88
		public Set getModeSet() {
89
			return fModes;
90
		}
91
	}
92
	
93
	/**
94
	 * label provider to extend the default one, provides labels to both the tree and table of this page
95
	 */
96
	class LabelProvider extends DefaultLabelProvider {
97
		public String getText(Object element) {
98
			if(element instanceof ILaunchConfigurationType) {
99
				return super.getText(element);
100
			}
101
			else if(element instanceof DuplicateDelegate) {
102
				DuplicateDelegate dd = (DuplicateDelegate) element;
103
				return LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(dd.getModeSet()).toString();
104
			}
105
			else if(element instanceof ILaunchDelegate){
106
				return ((ILaunchDelegate) element).getName();
107
			}
108
			return element.toString();
109
		}
110
	}
111
	
112
	/**
113
	 * This class is used to provide content to the tree
114
	 */
115
	class TreeProvider implements ITreeContentProvider {
116
		public Object[] getChildren(Object parentElement) {
117
			if(parentElement instanceof ILaunchConfigurationType) {
118
				ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement;
119
				Set dupes = (Set) fDuplicates.get(type);
120
				if(dupes != null) {
121
					return dupes.toArray();
122
				}
123
				return null;
124
			}
125
			return null;
126
		}
127
		public boolean hasChildren(Object element) {
128
			return element instanceof ILaunchConfigurationType;
129
		}
130
		public Object[] getElements(Object inputElement) {
131
			if(inputElement instanceof Map) {
132
				return ((Map)inputElement).keySet().toArray();
133
			}
134
			return null;
135
		}
136
		public Object getParent(Object element) {return null;}
137
		public void dispose() {}
138
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
139
	}
140
	
141
	private TreeViewer fTreeViewer = null;
142
	private CheckboxTableViewer fTableViewer = null;
143
	private Map fDuplicates = null;
144
	private Map fDupeSelections = null;
145
	private boolean fDirty = false;
146
	private Text fDescription = null;
147
	
148
	/**
149
	 * Constructor
150
	 */
151
	public LaunchersPreferencePage() {
152
		setTitle(DebugPreferencesMessages.LaunchDelegatesPreferencePage_0);
153
	}
154
155
	/**
156
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
157
	 */
158
	public void createControl(Composite parent) {
159
		super.createControl(parent);
160
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCH_DELEGATES_PREFERENCE_PAGE);
161
	}
162
163
	/**
164
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
165
	 */
166
	protected Control createContents(Composite parent) {
167
		Composite comp = SWTUtil.createComposite(parent, 2, 1, GridData.FILL_BOTH);
168
		SWTUtil.createWrapLabel(comp, DebugPreferencesMessages.LaunchDelegatesPreferencePage_1, 2, 300);
169
		
170
		SWTUtil.createVerticalSpacer(comp, 1);
171
	//tree
172
		Composite comp1 = SWTUtil.createComposite(comp, 1, 1, GridData.FILL_VERTICAL);
173
		SWTUtil.createLabel(comp1, DebugPreferencesMessages.LaunchDelegatesPreferencePage_2, 1);
174
		Tree tree = new Tree(comp1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE);
175
		GridData gd = new GridData(GridData.FILL_BOTH);
176
		gd.grabExcessHorizontalSpace = false;
177
		tree.setLayoutData(gd);
178
		fTreeViewer = new TreeViewer(tree);
179
		fTreeViewer.setComparator(new WorkbenchViewerComparator());
180
		fTreeViewer.setContentProvider(new TreeProvider());
181
		fTreeViewer.setLabelProvider(new LabelProvider());
182
		fTreeViewer.setInput(fDuplicates);
183
		fTreeViewer.expandToLevel(2);
184
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
185
			public void selectionChanged(SelectionChangedEvent event) {
186
				Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
187
				if(obj instanceof DuplicateDelegate) {
188
					fTableViewer.setAllChecked(false);
189
					DuplicateDelegate dd = (DuplicateDelegate) obj;
190
					fTableViewer.setInput(dd.getDelegates());
191
					obj = fDupeSelections.get(dd);
192
					if(obj != null) {
193
						fTableViewer.setChecked(obj, true);
194
					}
195
				}
196
				else {
197
					fTableViewer.setInput(null);
198
				}
199
			}
200
		});
201
		
202
	//table
203
		Composite comp2 = SWTUtil.createComposite(comp, comp.getFont(), 1, 1, GridData.FILL_BOTH);
204
		SWTUtil.createLabel(comp2, DebugPreferencesMessages.LaunchDelegatesPreferencePage_3, 1);
205
		Table table = new Table(comp2, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.SINGLE);
206
		table.setLayoutData(new GridData(GridData.FILL_BOTH));
207
		fTableViewer = new CheckboxTableViewer(table);
208
		fTableViewer.setComparator(new WorkbenchViewerComparator());
209
		fTableViewer.setLabelProvider(new LabelProvider());
210
		fTableViewer.setContentProvider(new ArrayContentProvider());
211
		fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
212
			public void selectionChanged(SelectionChangedEvent event) {
213
				IStructuredSelection ss = (IStructuredSelection) event.getSelection();
214
				if(ss != null && !ss.isEmpty()) {
215
					fDescription.setText(((ILaunchDelegate)ss.getFirstElement()).getDescription());
216
				}
217
				else {
218
					fDescription.setText(""); //$NON-NLS-1$
219
				}
220
			}
221
		});
222
		fTableViewer.addCheckStateListener(new ICheckStateListener() {
223
			public void checkStateChanged(CheckStateChangedEvent event) {
224
				fDirty = true;
225
				Object element = event.getElement();
226
				boolean checked = event.getChecked();
227
				fTableViewer.setAllChecked(false);
228
				//always set checked, this way users cannot 'undo' a change to selecting a preferred delegate
229
				//The story for this is that on startup if there are dupes, the user is prompted to pick a delegate, after that they cannot 
230
				//return to a state of not being able to launch something, but can pick a different delegate
231
				fTableViewer.setChecked(element, true);
232
				//persist the selection
233
				Object obj = ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
234
				if(obj instanceof DuplicateDelegate) {
235
					fDupeSelections.remove(obj);
236
					if(checked) {
237
						fDupeSelections.put(obj, element);
238
					}
239
				}
240
			}
241
		});
242
		Group group = SWTUtil.createGroup(comp, DebugPreferencesMessages.LaunchDelegatesPreferencePage_4, 1, 2, GridData.FILL_BOTH);
243
		fDescription = SWTUtil.createText(group, SWT.WRAP | SWT.READ_ONLY, 1, GridData.FILL_BOTH);
244
		fDescription.setBackground(group.getBackground());
245
		return comp;
246
	}
247
248
	/**
249
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
250
	 */
251
	public boolean performOk() {
252
		if(fDirty && fDupeSelections != null && fDupeSelections.size() > 0) {
253
			fDirty = false;
254
			DuplicateDelegate dd = null;
255
			ILaunchDelegate delegate = null;
256
			for(Iterator iter = fDupeSelections.keySet().iterator(); iter.hasNext();) {
257
				dd = (DuplicateDelegate) iter.next();
258
				delegate = (ILaunchDelegate) fDupeSelections.get(dd);
259
				try {
260
					dd.getType().setPreferredDelegate(dd.getModeSet(), delegate);
261
				} 
262
				catch (CoreException e) {DebugUIPlugin.log(e);}
263
			}
264
		}
265
		if(getPreferenceStore().needsSaving()) {
266
			DebugUIPlugin.getDefault().savePluginPreferences();
267
		}
268
		return super.performOk();
269
	}
270
271
	/**
272
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
273
	 */
274
	public void init(IWorkbench workbench) {
275
		//init a listing of duplicate delegates arranged by type
276
		try {
277
			setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
278
			LaunchManager lm = (LaunchManager) DebugPlugin.getDefault().getLaunchManager();
279
			ILaunchConfigurationType[] types = lm.getLaunchConfigurationTypes();
280
			fDuplicates = new HashMap();
281
			fDupeSelections = new HashMap();
282
			Set modes = null;
283
			ILaunchDelegate[] delegates = null;
284
			Set modeset = null;
285
			Set tmp = null;
286
			ILaunchDelegate prefdelegate = null;
287
			DuplicateDelegate dd = null;
288
			for(int i = 0; i < types.length; i++) {
289
				modes = types[i].getSupportedModeCombinations();
290
				for(Iterator iter = modes.iterator(); iter.hasNext();) {
291
					modeset = (Set) iter.next();
292
					delegates = types[i].getDelegates(modeset);
293
					if(delegates.length > 1) {
294
						tmp = (Set) fDuplicates.get(types[i]);
295
						if(tmp == null) {
296
							tmp = new HashSet();
297
						}
298
						dd = new DuplicateDelegate(types[i], delegates, modeset);
299
						tmp.add(dd);
300
						fDuplicates.put(types[i], tmp);
301
						prefdelegate = types[i].getPreferredDelegate(modeset);
302
						if(prefdelegate != null) {
303
							fDupeSelections.put(dd, prefdelegate);
304
						}
305
					}
306
				}
307
			}
308
		}
309
		catch(CoreException e) {DebugUIPlugin.log(e);}
310
	}
311
312
}
(-)core/org/eclipse/debug/core/ILaunchConfiguration.java (+25 lines)
Lines 89-94 Link Here
89
	public static final String ATTR_SOURCE_LOCATOR_MEMENTO = DebugPlugin.getUniqueIdentifier() + ".source_locator_memento"; //$NON-NLS-1$
89
	public static final String ATTR_SOURCE_LOCATOR_MEMENTO = DebugPlugin.getUniqueIdentifier() + ".source_locator_memento"; //$NON-NLS-1$
90
	
90
	
91
	/**
91
	/**
92
	 * Launch configuration attribute storing a list 
93
	 * of preferred launchers for associated mode sets.
94
	 * This attribute is a list of launchers stored by mode set
95
	 * and relating to the id of the preferred launcher, which happens to be an <code>ILaunchDelegate</code>
96
	 * 
97
	 * @since 3.3
98
	 */
99
	public static final String ATTR_PREFERRED_LAUNCHERS = DebugPlugin.getUniqueIdentifier() + ".preferred_launchers"; //$NON-NLS-1$
100
	
101
	/**
92
	 * Returns whether the contents of this launch configuration are 
102
	 * Returns whether the contents of this launch configuration are 
93
	 * equal to the contents of the given launch configuration.
103
	 * equal to the contents of the given launch configuration.
94
	 * 
104
	 * 
Lines 345-350 Link Here
345
	public Set getModes() throws CoreException;
355
	public Set getModes() throws CoreException;
346
	
356
	
347
	/**
357
	/**
358
	 * Returns the preferred launch delegate that has been set on this configuration.
359
	 * @return this configuration's preferred launch delegate for the specified mode set, or 
360
	 * <code>null</code> if one is not specified
361
	 * 
362
	 * <p>
363
	 * <strong>EXPERIMENTAL</strong>. This method has been added as
364
	 * part of a work in progress. There is no guarantee that this API will
365
	 * remain unchanged during the 3.3 release cycle. Please do not use this API
366
	 * without consulting with the Platform/Debug team.
367
	 * </p>
368
	 * @since 3.3
369
	 */
370
	public ILaunchDelegate getPreferredDelegate(Set modes) throws CoreException;
371
	
372
	/**
348
	 * Returns the type of this launch configuration. This is a
373
	 * Returns the type of this launch configuration. This is a
349
	 * handle-only method.
374
	 * handle-only method.
350
	 * 
375
	 * 
(-)core/org/eclipse/debug/core/ILaunchConfigurationWorkingCopy.java (+16 lines)
Lines 195-200 Link Here
195
	public void setModes(Set modes);
195
	public void setModes(Set modes);
196
	
196
	
197
	/**
197
	/**
198
	 * Set the preferred launch delegates' id for the given mode set. Passing in <code>null</code> as a delegate
199
	 * id will cause the mapping for the specified mode set (if any) to be removed
200
	 * @param modes the set of modes to set this delegate id for
201
	 * @param delegateId the id of the delegate to associate as preferred for the specified mode set
202
	 * 
203
	 * <p>
204
	 * <strong>EXPERIMENTAL</strong>. This method has been added as
205
	 * part of a work in progress. There is no guarantee that this API will
206
	 * remain unchanged during the 3.3 release cycle. Please do not use this API
207
	 * without consulting with the Platform/Debug team.
208
	 * </p>
209
	 * @since 3.3
210
	 */
211
	public void setPreferredLaunchDelegate(Set modes, String delegateId);
212
	
213
	/**
198
	 * Adds the specified launch modes to this configuration's settings.
214
	 * Adds the specified launch modes to this configuration's settings.
199
	 * <p>
215
	 * <p>
200
	 * Setting launch modes on a configuration allows the configuration to
216
	 * Setting launch modes on a configuration allows the configuration to
(-)core/org/eclipse/debug/internal/core/LaunchManager.java (-12 / +34 lines)
Lines 1390-1399 Link Here
1390
	 * without consulting with the Platform/Debug team.
1390
	 * without consulting with the Platform/Debug team.
1391
	 * </p>
1391
	 * </p>
1392
	 */
1392
	 */
1393
	public LaunchDelegate[] getLaunchDelegates() {
1393
	public ILaunchDelegate[] getLaunchDelegates() {
1394
		initializeLaunchDelegates();
1394
		initializeLaunchDelegates();
1395
		Collection col = fLaunchDelegates.values();
1395
		Collection col = fLaunchDelegates.values();
1396
		return (LaunchDelegate[]) col.toArray(new LaunchDelegate[col.size()]);
1396
		return (ILaunchDelegate[]) col.toArray(new ILaunchDelegate[col.size()]);
1397
	}
1397
	}
1398
	
1398
	
1399
	/**
1399
	/**
Lines 1421-1426 Link Here
1421
	}
1421
	}
1422
	
1422
	
1423
	/**
1423
	/**
1424
	 * This method returns the <code>ILaunchDelegate</code> instance corresponding to the id 
1425
	 * of the launch delegate specified
1426
	 * @param id the id of the <code>ILaunchDelegate</code> to find 
1427
	 * @return the <code>ILaunchDelegate</code> or <code>null</code> if not found
1428
	 * @since 3.3
1429
	 * EXPERIMENTAL
1430
	 */
1431
	public ILaunchDelegate getLaunchDelegate(String id) {
1432
		if(id != null) {
1433
			ILaunchDelegate[] delegates = getLaunchDelegates();
1434
			for(int i = 0; i < delegates.length; i++) {
1435
				if(id.equals(delegates[i].getId())) {
1436
					return delegates[i];
1437
				}
1438
			}
1439
		}
1440
		return null;
1441
	}
1442
	
1443
	/**
1424
	 * Initializes the listing of delegates available to the launching framework
1444
	 * Initializes the listing of delegates available to the launching framework
1425
	 * 
1445
	 * 
1426
	 * <p>
1446
	 * <p>
Lines 2197-2214 Link Here
2197
					for(Iterator iter = preferred.keySet().iterator(); iter.hasNext();) {
2217
					for(Iterator iter = preferred.keySet().iterator(); iter.hasNext();) {
2198
						modes = (Set) iter.next();
2218
						modes = (Set) iter.next();
2199
						delegate = (ILaunchDelegate) preferred.get(modes);
2219
						delegate = (ILaunchDelegate) preferred.get(modes);
2200
						child = doc.createElement(DELEGATE);
2220
						if(delegate != null) {
2201
						child.setAttribute(ID, delegate.getId());
2221
							child = doc.createElement(DELEGATE);
2202
						child.setAttribute(TYPEID, types[i].getIdentifier());
2222
							child.setAttribute(ID, delegate.getId());
2203
						for(Iterator iter2 = modes.iterator(); iter2.hasNext();) {
2223
							child.setAttribute(TYPEID, types[i].getIdentifier());
2204
							modestr += iter2.next();
2224
							for(Iterator iter2 = modes.iterator(); iter2.hasNext();) {
2205
							if(iter2.hasNext()) {
2225
								modestr += iter2.next();
2206
								modestr += ","; //$NON-NLS-1$
2226
								if(iter2.hasNext()) {
2227
									modestr += ","; //$NON-NLS-1$
2228
								}
2207
							}
2229
							}
2230
							child.setAttribute(MODES, modestr);
2231
							modestr = EMPTY_STRING;
2232
							root.appendChild(child);
2208
						}
2233
						}
2209
						child.setAttribute(MODES, modestr);
2210
						modestr = EMPTY_STRING;
2211
						root.appendChild(child);
2212
					}
2234
					}
2213
				}
2235
				}
2214
			}
2236
			}
(-)core/org/eclipse/debug/internal/core/LaunchConfiguration.java (-1 / +18 lines)
Lines 624-630 Link Here
624
    		IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "No launch delegate found, canceling launch and returning", null); //$NON-NLS-1$
624
    		IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, "No launch delegate found, canceling launch and returning", null); //$NON-NLS-1$
625
    		throw new CoreException(status);
625
    		throw new CoreException(status);
626
    	} else {
626
    	} else {
627
    		ILaunchDelegate del = getType().getPreferredDelegate(modes);
627
    		ILaunchDelegate del = getPreferredDelegate(modes);
628
    		if(del == null) {
629
    			del = getType().getPreferredDelegate(modes);
630
    		}
628
    		if(del == null) {
631
    		if(del == null) {
629
    			IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus);
632
    			IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus);
630
    			IStatus status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode});
633
    			IStatus status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode});
Lines 777-782 Link Here
777
		}
780
		}
778
		return false;
781
		return false;
779
	}
782
	}
783
784
	/**
785
	 * @see org.eclipse.debug.core.ILaunchConfiguration#getPreferredDelegate(java.util.Set)
786
	 */
787
	public ILaunchDelegate getPreferredDelegate(Set modes) throws CoreException {
788
		Map delegates = getAttribute(ILaunchConfiguration.ATTR_PREFERRED_LAUNCHERS, (Map)null);
789
		if(delegates != null) {
790
			String id = (String) delegates.get(modes.toString());
791
			if(id != null) {
792
				return getLaunchManager().getLaunchDelegate(id);
793
			}
794
		}
795
		return null;
796
	}
780
	
797
	
781
}
798
}
782
799
(-)core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java (-4 / +29 lines)
Lines 17-22 Link Here
17
import java.io.IOException;
17
import java.io.IOException;
18
import java.io.UnsupportedEncodingException;
18
import java.io.UnsupportedEncodingException;
19
import java.util.ArrayList;
19
import java.util.ArrayList;
20
import java.util.HashMap;
20
import java.util.List;
21
import java.util.List;
21
import java.util.Map;
22
import java.util.Map;
22
import java.util.Set;
23
import java.util.Set;
Lines 408-425 Link Here
408
	/**
409
	/**
409
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setModes(java.util.Set)
410
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setModes(java.util.Set)
410
	 */
411
	 */
411
	public void setModes(Set options) {
412
	public void setModes(Set modes) {
412
		getInfo().setAttribute(ATTR_LAUNCH_MODES, (options.size() > 0 ? options : null));
413
		getInfo().setAttribute(ATTR_LAUNCH_MODES, (modes.size() > 0 ? modes : null));
413
		setDirty();
414
		setDirty();
414
	}
415
	}
415
416
416
	/**
417
	/**
417
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#addModes(java.util.Set)
418
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#addModes(java.util.Set)
418
	 */
419
	 */
419
	public void addModes(Set options) {
420
	public void addModes(Set modes) {
420
		try {
421
		try {
421
			Set opts = getModes();
422
			Set opts = getModes();
422
			if(opts.addAll(options)) {
423
			if(opts.addAll(modes)) {
423
				getInfo().setAttribute(ATTR_LAUNCH_MODES, opts);
424
				getInfo().setAttribute(ATTR_LAUNCH_MODES, opts);
424
				setDirty();
425
				setDirty();
425
			}
426
			}
Lines 611-615 Link Here
611
		setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types);
612
		setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, types);
612
	}
613
	}
613
614
615
	/**
616
	 * @see org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setPreferredLaunchDelegate(java.util.Set, java.lang.String)
617
	 */
618
	public void setPreferredLaunchDelegate(Set modes, String delegateId) {
619
		if(modes != null) {
620
			try {
621
				Map delegates = getAttribute(ILaunchConfiguration.ATTR_PREFERRED_LAUNCHERS, (Map)null);
622
					//copy map to avoid pointer issues
623
					Map map = new HashMap();
624
					if(delegates != null) {
625
						map.putAll(delegates);
626
					}
627
					if(delegateId == null) {
628
						map.remove(modes.toString());
629
					}
630
					else {
631
						map.put(modes.toString(), delegateId);
632
					}
633
					setAttribute(ILaunchConfiguration.ATTR_PREFERRED_LAUNCHERS, map);
634
			}
635
			catch (CoreException ce) {DebugPlugin.log(ce);}
636
		}
637
	}
638
614
}
639
}
615
640
(-)contexts_Debugger.xml (+4 lines)
Lines 595-600 Link Here
595
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
595
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
596
		<topic label="Source Attachments" href="reference/ref-124.htm"/>
596
		<topic label="Source Attachments" href="reference/ref-124.htm"/>
597
	</context>
597
	</context>
598
	<context  id="launch_configuration_dialog_launchers_tab" >
599
		<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>
600
		<topic label="Java application launch configuration" href=" tasks\tasks-java-local-configuration.htm"/>
601
	</context>
598
602
599
<!--
603
<!--
600
	Memory View
604
	Memory View

Return to bug 157059