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

(-)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
(-)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 / +8 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 preferred launcher or use the workspace default
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.
60
LaunchConfigurationTabGroupViewer_16=There is duplicate launch tooling for the mixed mode: {0}
61
66
62
LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations
67
LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations
63
LaunchConfigurationDialog_Dele_te_14=De&lete
68
LaunchConfigurationDialog_Dele_te_14=De&lete
Lines 70-76 Link Here
70
LaunchConfigurationDialog_Launch_Configuration_Error_46=Launch Configuration Error
75
LaunchConfigurationDialog_Launch_Configuration_Error_46=Launch Configuration Error
71
LaunchConfigurationDialog_Launch_Configurations_18=Launch Configurations
76
LaunchConfigurationDialog_Launch_Configurations_18=Launch Configurations
72
LaunchConfigurationDialog_Name_required_for_launch_configuration_11=Name required for launch configuration
77
LaunchConfigurationDialog_Name_required_for_launch_configuration_11=Name required for launch configuration
73
LaunchConfigurationDialog_Ne_w_13=Ne&w
78
LaunchConfigurationDialog_Ne_w_13=Ne&w\t\t
74
LaunchConfigurationDialog_No_33=No
79
LaunchConfigurationDialog_No_33=No
75
LaunchConfigurationEditDialog_0=Modify configuration and continue.
80
LaunchConfigurationEditDialog_0=Modify configuration and continue.
76
LaunchConfigurationEditDialog_1=Con&tinue
81
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/LaunchConfigurationsMessages.java (-5 / +8 lines)
Lines 94-106 Link Here
94
	public static String LaunchConfigurationPresentationManager_No_tab_group_defined_for_launch_configuration_type__0__3;
94
	public static String LaunchConfigurationPresentationManager_No_tab_group_defined_for_launch_configuration_type__0__3;
95
95
96
	public static String LaunchConfigurationTabGroupViewer_14;
96
	public static String LaunchConfigurationTabGroupViewer_14;
97
98
	public static String LaunchConfigurationTabGroupViewer_15;
99
100
	public static String LaunchConfigurationTabGroupViewer_16;
101
102
	public static String LaunchConfigurationTabGroupViewer_9;
97
	public static String LaunchConfigurationTabGroupViewer_9;
103
	public static String LaunchConfigurationTabGroupViewer_13;
98
	public static String LaunchConfigurationTabGroupViewer_13;
99
100
	public static String LaunchersTab_3;
101
	public static String LaunchersTab_4;
102
	public static String LaunchersTab_6;
104
	public static String PerspectiveManager_Error_1;
103
	public static String PerspectiveManager_Error_1;
105
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
104
	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;
105
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
Lines 215-219 Link Here
215
	public static String SelectLaunchOptionsDialog_2;
214
	public static String SelectLaunchOptionsDialog_2;
216
	public static String SelectLaunchOptionsDialog_3;
215
	public static String SelectLaunchOptionsDialog_3;
217
	public static String SelectLaunchOptionsDialog_4;
216
	public static String SelectLaunchOptionsDialog_4;
217
	
218
	public static String LaunchersTab_0;
219
	public static String LaunchersTab_1;
220
	public static String LaunchersTab_2;
218
221
219
}
222
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-159 / +63 lines)
Lines 11-17 Link Here
11
package org.eclipse.debug.internal.ui.launchConfigurations;
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
12
13
13
14
import java.util.HashSet;
15
import java.util.List;
14
import java.util.List;
16
import java.util.Set;
15
import java.util.Set;
17
16
Lines 37-48 Link Here
37
import org.eclipse.jface.dialogs.IDialogConstants;
36
import org.eclipse.jface.dialogs.IDialogConstants;
38
import org.eclipse.jface.viewers.ISelection;
37
import org.eclipse.jface.viewers.ISelection;
39
import org.eclipse.jface.viewers.IStructuredSelection;
38
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.viewers.SelectionChangedEvent;
41
import org.eclipse.jface.viewers.StructuredSelection;
39
import org.eclipse.jface.viewers.StructuredSelection;
42
import org.eclipse.jface.viewers.Viewer;
40
import org.eclipse.jface.viewers.Viewer;
43
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.SWT;
44
import org.eclipse.swt.custom.BusyIndicator;
42
import org.eclipse.swt.custom.BusyIndicator;
45
import org.eclipse.swt.custom.CLabel;
46
import org.eclipse.swt.custom.CTabFolder;
43
import org.eclipse.swt.custom.CTabFolder;
47
import org.eclipse.swt.custom.CTabItem;
44
import org.eclipse.swt.custom.CTabItem;
48
import org.eclipse.swt.custom.StackLayout;
45
import org.eclipse.swt.custom.StackLayout;
Lines 294-299 Link Here
294
		fOptionsLink.setFont(linkComp.getFont());
291
		fOptionsLink.setFont(linkComp.getFont());
295
		gd = new GridData(GridData.BEGINNING);
292
		gd = new GridData(GridData.BEGINNING);
296
		fOptionsLink.setLayoutData(gd);
293
		fOptionsLink.setLayoutData(gd);
294
		fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13);
297
		fOptionsLink.addSelectionListener(new SelectionListener() {
295
		fOptionsLink.addSelectionListener(new SelectionListener() {
298
			public void widgetSelected(SelectionEvent e) {
296
			public void widgetSelected(SelectionEvent e) {
299
				//collect the options available
297
				//collect the options available
Lines 309-333 Link Here
309
								modes.remove(getLaunchConfigurationDialog().getMode());
307
								modes.remove(getLaunchConfigurationDialog().getMode());
310
								ILaunchConfigurationWorkingCopy wc = getWorkingCopy();
308
								ILaunchConfigurationWorkingCopy wc = getWorkingCopy();
311
								wc.setModes(modes);
309
								wc.setModes(modes);
312
								refresh();
313
								refreshStatus();
310
								refreshStatus();
314
							}
311
							}
315
						}
312
						}
316
					}
313
					}
317
					else if(hasDuplicateDelegates()) {
318
						Set modes = new HashSet();
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
					}
331
				} catch (CoreException ex) {}
314
				} catch (CoreException ex) {}
332
			}
315
			}
333
			public void widgetDefaultSelected(SelectionEvent e) {}
316
			public void widgetDefaultSelected(SelectionEvent e) {}
Lines 366-385 Link Here
366
	}
349
	}
367
	
350
	
368
	/**
351
	/**
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
352
	 * Creates some help text for the tab group launch types
384
	 * @param parent thep arent composite
353
	 * @param parent thep arent composite
385
	 * @since 3.2
354
	 * @since 3.2
Lines 387-410 Link Here
387
	private void createGettingStarted(Composite parent) {
356
	private void createGettingStarted(Composite parent) {
388
		Font font = parent.getFont();
357
		Font font = parent.getFont();
389
		GridData gd = null;
358
		GridData gd = null;
390
		createWrapLabel(parent, null, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1);
359
		int width = parent.getBounds().width - 30;
391
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 
360
		SWTUtil.createWrapLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1, 1, width);
392
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2);
361
		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),
362
		SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), 1, width);
394
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6);
363
		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), 
364
        SWTUtil.createWrapCLabel(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS), 1, width);
396
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4);
365
        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
        
366
        
402
		createSpacer(parent, 2);
367
		SWTUtil.createHorizontalSpacer(parent, 2);
403
		Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
368
		Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
404
		link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5);
369
		link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5);
405
		link.setFont(font);
370
		link.setFont(font);
406
		gd = new GridData(GridData.FILL_HORIZONTAL);
371
		gd = new GridData(GridData.FILL_HORIZONTAL);
407
		gd.widthHint = parent.getBounds().width - 30;
372
		gd.widthHint = width;
408
		link.setLayoutData(gd);
373
		link.setLayoutData(gd);
409
		link.addSelectionListener(new SelectionListener() {
374
		link.addSelectionListener(new SelectionListener() {
410
			public void widgetSelected(SelectionEvent e) {
375
			public void widgetSelected(SelectionEvent e) {
Lines 413-434 Link Here
413
			public void widgetDefaultSelected(SelectionEvent e) {}
378
			public void widgetDefaultSelected(SelectionEvent e) {}
414
		});
379
		});
415
	}
380
	}
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
	
381
	
433
	/**
382
	/**
434
	 * Creates the tab folder for displaying config instances
383
	 * Creates the tab folder for displaying config instances
Lines 519-528 Link Here
519
	 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
468
	 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
520
	 */
469
	 */
521
	public ISelection getSelection() {
470
	public ISelection getSelection() {
522
		if (getActiveTab() == null) {
471
		/*if (getActiveTab() == null) {
523
			return new StructuredSelection();
472
			return new StructuredSelection();
524
		} 
473
		} */
525
		return new StructuredSelection(getActiveTab());
474
		return new StructuredSelection(fWorkingCopy/*getActiveTab()*/);
526
	}
475
	}
527
476
528
	/**
477
	/**
Lines 540-558 Link Here
540
			// update error ticks
489
			// update error ticks
541
			CTabItem item = null;
490
			CTabItem item = null;
542
			boolean error = false;
491
			boolean error = false;
492
			Image image = null;
543
			for (int i = 0; i < tabs.length; i++) {
493
			for (int i = 0; i < tabs.length; i++) {
544
				tabs[i].isValid(getWorkingCopy());
494
				error = tabs[i].getErrorMessage() != null && !tabs[i].isValid(getWorkingCopy());
545
				error = tabs[i].getErrorMessage() != null;
495
				image = tabs[i].getImage();
546
				item = fTabFolder.getItem(i);
496
				item = fTabFolder.getItem(i);
547
				setTabIcon(item, error, tabs[i]);
497
				if(error) {
548
			}
498
					item.setImage(DebugUIPlugin.getDefault().getLaunchConfigurationManager().getErrorTabImage(tabs[i]));
549
			if(!canLaunchWithModes()) {
499
				}
550
				fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_13);
500
				else {
551
			}
501
					item.setImage(image);
552
			else if(hasDuplicateDelegates()) {
502
				}
553
				fOptionsLink.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_15);
554
			}
503
			}
555
			fOptionsLink.setVisible(!canLaunchWithModes() || hasDuplicateDelegates());
504
			fOptionsLink.setVisible(!canLaunchWithModes());
556
			fOptionsLink.getParent().layout();
505
			fOptionsLink.getParent().layout();
557
		}
506
		}
558
	}
507
	}
Lines 565-584 Link Here
565
		fApplyButton.setEnabled(dirty && canSave());
514
		fApplyButton.setEnabled(dirty && canSave());
566
		fRevertButton.setEnabled(dirty);
515
		fRevertButton.setEnabled(dirty);
567
	}
516
	}
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
517
583
	/* (non-Javadoc)
518
	/* (non-Javadoc)
584
	 * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object)
519
	 * @see org.eclipse.jface.viewers.Viewer#setInput(java.lang.Object)
Lines 673-679 Link Here
673
     */
608
     */
674
    protected void setFocusOnName() {
609
    protected void setFocusOnName() {
675
        fNameWidget.setFocus();
610
        fNameWidget.setFocus();
676
        
677
    }
611
    }
678
    
612
    
679
	/**
613
	/**
Lines 730-768 Link Here
730
	 * launch configuration type.
664
	 * launch configuration type.
731
	 */
665
	 */
732
	private void showInstanceTabsFor(ILaunchConfigurationType configType) {
666
	private void showInstanceTabsFor(ILaunchConfigurationType configType) {
733
734
		// Don't do any work if the current tabs are for the current config type
667
		// Don't do any work if the current tabs are for the current config type
735
		if (fTabType != null && fTabType.equals(configType)) { 
668
/*if (fTabType != null && fTabType.equals(configType)) { 
736
			return;
669
	return;
737
		}
670
}*/
738
		
739
		// try to keep on same tab
671
		// try to keep on same tab
740
		Class tabKind = null;
672
		Class tabKind = null;
741
		if (getActiveTab() != null) {
673
		if (getActiveTab() != null) {
742
			tabKind = getActiveTab().getClass();
674
			tabKind = getActiveTab().getClass();
743
		}
675
		}
744
		
745
		// Build the new tabs
676
		// Build the new tabs
746
		ILaunchConfigurationTabGroup group = null;
677
		ILaunchConfigurationTabGroup group = null;
747
		try {
678
		try {
748
			group = createGroup(configType);
679
			group = createGroup();
749
		} catch (CoreException ce) {
680
		} catch (CoreException ce) {
750
			DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_Exception_occurred_creating_launch_configuration_tabs_27,ce); // 
681
			DebugUIPlugin.errorDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Error_19, LaunchConfigurationsMessages.LaunchConfigurationDialog_Exception_occurred_creating_launch_configuration_tabs_27,ce); // 
751
			return;
682
			return;
752
		}
683
		}
753
684
		disposeExistingTabs();
754
		showTabsFor(group);
755
		fTabGroup = group;
685
		fTabGroup = group;
756
		fTabType = configType;
686
		fTabType = configType;
757
		
758
		// select same tab as before, if possible
759
		ILaunchConfigurationTab[] tabs = getTabs();
687
		ILaunchConfigurationTab[] tabs = getTabs();
688
		CTabItem tab = null;
689
		String name = EMPTY_STRING;
690
		Control control = null;
691
		for (int i = 0; i < tabs.length; i++) {
692
			tab = new CTabItem(fTabFolder, SWT.BORDER);
693
			name = tabs[i].getName();
694
			if (name == null) {
695
				name = LaunchConfigurationsMessages.LaunchConfigurationDialog_unspecified_28; 
696
			}
697
			tab.setText(name);
698
			tab.setImage(tabs[i].getImage());
699
			tabs[i].createControl(tab.getParent());
700
			control = tabs[i].getControl();
701
			if (control != null) {
702
				tab.setControl(control);
703
			}
704
		}
760
		//set the default tab as the first one
705
		//set the default tab as the first one
761
		setActiveTab(tabs[0]);
706
		setActiveTab(tabs[0]);
707
		// select same tab as before, if possible
762
		for (int i = 0; i < tabs.length; i++) {
708
		for (int i = 0; i < tabs.length; i++) {
763
			ILaunchConfigurationTab tab = tabs[i];
709
			if (tabs[i].getClass().equals(tabKind)) {
764
			if (tab.getClass().equals(tabKind)) {
710
				setActiveTab(tabs[i]);
765
				setActiveTab(tab);
766
				break;
711
				break;
767
			}
712
			}
768
		}
713
		}
Lines 782-830 Link Here
782
			String mode = fDialog.getMode();
727
			String mode = fDialog.getMode();
783
			description = LaunchConfigurationPresentationManager.getDefault().getDescription(configType, mode);
728
			description = LaunchConfigurationPresentationManager.getDefault().getDescription(configType, mode);
784
		}	
729
		}	
785
		if (description == null)
730
		if (description == null) {
786
			description = EMPTY_STRING;
731
			description = EMPTY_STRING;
732
		}
787
		return description;
733
		return description;
788
	}
734
	}
789
	
735
	
790
	/**
736
	/**
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.
737
	 * Returns tab group for the given type of launch configuration.
823
	 * Tabs are initialized to be contained in this dialog.
738
	 * Tabs are initialized to be contained in this dialog.
824
	 *
739
	 *
825
	 * @exception CoreException if unable to instantiate a tab group
740
	 * @exception CoreException if unable to instantiate a tab group
826
	 */
741
	 */
827
	protected ILaunchConfigurationTabGroup createGroup(final ILaunchConfigurationType configType) throws CoreException {
742
	protected ILaunchConfigurationTabGroup createGroup() throws CoreException {
828
		// Use a final Object array to store the tab group and any exception that
743
		// Use a final Object array to store the tab group and any exception that
829
		// results from the Runnable
744
		// results from the Runnable
830
		final Object[] finalArray = new Object[2];
745
		final Object[] finalArray = new Object[2];
Lines 1029-1035 Link Here
1029
				return false;
944
				return false;
1030
			}
945
			}
1031
		}
946
		}
1032
		
1033
		return true;
947
		return true;
1034
	}	
948
	}	
1035
	
949
	
Lines 1084-1090 Link Here
1084
				modes.add(getLaunchConfigurationDialog().getMode());
998
				modes.add(getLaunchConfigurationDialog().getMode());
1085
				ILaunchDelegate[] delegates = LaunchConfigurationManager.filterLaunchDelegates(fTabType, modes);
999
				ILaunchDelegate[] delegates = LaunchConfigurationManager.filterLaunchDelegates(fTabType, modes);
1086
				if(delegates.length > 1) {
1000
				if(delegates.length > 1) {
1087
					ILaunchDelegate preferred = fTabType.getPreferredDelegate(modes);
1001
					ILaunchDelegate preferred = config.getPreferredDelegate(modes);
1002
					if(preferred == null) {
1003
						preferred = fTabType.getPreferredDelegate(modes);
1004
					}
1088
					if(preferred == null) {
1005
					if(preferred == null) {
1089
						return true;
1006
						return true;
1090
					}
1007
					}
Lines 1141-1150 Link Here
1141
				return temp.toString();
1058
				return temp.toString();
1142
			}
1059
			}
1143
		}
1060
		}
1144
		if(getWorkingCopy() != null) {
1061
		if(getWorkingCopy().isReadOnly()) {
1145
			if(getWorkingCopy().isReadOnly()) {
1062
			return LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9;
1146
				return LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9;
1147
			}
1148
		}
1063
		}
1149
		//EXPERIMENTAL
1064
		//EXPERIMENTAL
1150
		if(!canLaunchWithModes()) {
1065
		if(!canLaunchWithModes()) {
Lines 1157-1171 Link Here
1157
				return e.getMessage();
1072
				return e.getMessage();
1158
			}
1073
			}
1159
		}
1074
		}
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
		}
1169
		return null;
1075
		return null;
1170
	}	
1076
	}	
1171
	
1077
	
Lines 1293-1300 Link Here
1293
			}
1199
			}
1294
		}
1200
		}
1295
		fCurrentTabIndex = fTabFolder.getSelectionIndex();
1201
		fCurrentTabIndex = fTabFolder.getSelectionIndex();
1296
		SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
1297
		fireSelectionChanged(event);
1298
	}
1202
	}
1299
	
1203
	
1300
	/**
1204
	/**
Lines 1342-1348 Link Here
1342
			if(fTabGroup != null) {
1246
			if(fTabGroup != null) {
1343
				fTabGroup.initializeFrom(fOriginal);
1247
				fTabGroup.initializeFrom(fOriginal);
1344
				fWorkingCopy = fOriginal.getWorkingCopy();
1248
				fWorkingCopy = fOriginal.getWorkingCopy();
1345
				refresh();
1346
				refreshStatus();
1249
				refreshStatus();
1347
			}
1250
			}
1348
		} 
1251
		} 
Lines 1366-1376 Link Here
1366
	 */
1269
	 */
1367
	public void setActiveTab(ILaunchConfigurationTab tab) {
1270
	public void setActiveTab(ILaunchConfigurationTab tab) {
1368
		ILaunchConfigurationTab[] tabs = getTabs();
1271
		ILaunchConfigurationTab[] tabs = getTabs();
1369
		for (int i = 0; i < tabs.length; i++) {
1272
		if(tabs != null) {
1370
			ILaunchConfigurationTab configurationTab = tabs[i];
1273
			for (int i = 0; i < tabs.length; i++) {
1371
			if (configurationTab.equals(tab)) {
1274
				if (tabs[i].getClass().equals(tab.getClass())) {
1372
				setActiveTab(i);
1275
					setActiveTab(i);
1373
				return;
1276
					return;
1277
				}
1374
			}
1278
			}
1375
		}
1279
		}
1376
	}
1280
	}
(-)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 (-21 / +6 lines)
Lines 157-181 Link Here
157
	}
157
	}
158
	
158
	
159
	/**
159
	/**
160
	 * Returns the tab group for the given launch configuration type and mode.
160
	 * Returns the tab group for the given launch configutation and the mode the dialog opened in
161
	 * 
162
	 * @param type launch configuration type
163
	 * @param mode launch mode
164
	 * @return the tab group for the given type of launch configuration, or <code>null</code> if none
165
	 * @exception CoreException if an exception occurs creating the group
166
	 */
167
	public ILaunchConfigurationTabGroup getTabGroup(ILaunchConfigurationType type, String mode) throws CoreException {
168
		LaunchConfigurationTabGroupExtension ext = getExtension(type.getIdentifier(), mode);
169
		if (ext == null) {
170
			IStatus status = new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.INTERNAL_ERROR,
171
			 MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationPresentationManager_No_tab_group_defined_for_launch_configuration_type__0__3, (new String[] {type.getIdentifier()})), null);  
172
			 throw new CoreException(status);
173
		} 
174
		return new LaunchConfigurationTabGroupWrapper(ext.newTabGroup(), ext.getIdentifier(), null);		
175
	}
176
	
177
	/**
178
	 * Returns the tab group for the given launch configutation, its type and the mode the dialog opened in
179
	 * @param type the type of the configuration
161
	 * @param type the type of the configuration
180
	 * @param config
162
	 * @param config
181
	 * @param mode
163
	 * @param mode
Lines 195-201 Link Here
195
	/**
177
	/**
196
	 * Returns the proxy elements for all contributed tabs for the specified tab group id
178
	 * Returns the proxy elements for all contributed tabs for the specified tab group id
197
	 * @param groupid the id of the tab group
179
	 * @param groupid the id of the tab group
198
	 * @param type the type the tab group is opened on
180
	 * @param config the config the tab group is opened on
199
	 * @param mode the mode the associated launch dialog is opened on
181
	 * @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>
182
	 * @return the listing of all of the tab extensions or an empty array, never <code>null</code>
201
	 * 
183
	 * 
Lines 241-247 Link Here
241
			//filter to preferred delegate (if there is one)
223
			//filter to preferred delegate (if there is one)
242
				HashSet modes = (HashSet) config.getModes();
224
				HashSet modes = (HashSet) config.getModes();
243
				modes.add(mode);
225
				modes.add(mode);
244
				ILaunchDelegate delegate = config.getType().getPreferredDelegate(modes);
226
				ILaunchDelegate delegate = config.getPreferredDelegate(modes);
227
				if(delegate == null) {
228
					delegate = config.getType().getPreferredDelegate(modes);
229
				}
245
				if(delegate != null) {
230
				if(delegate != null) {
246
					if(tabs[i].getDelegateSet().contains(delegate.getId())) {
231
					if(tabs[i].getDelegateSet().contains(delegate.getId())) {
247
						set.add(tabs[i]);
232
						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 (+217 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.IStructuredSelection;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.events.SelectionListener;
28
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Control;
32
import org.eclipse.swt.widgets.Link;
33
import org.eclipse.ui.IWorkbenchPropertyPage;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.dialogs.PropertyPage;
36
37
/**
38
 * This class provides a property page for editing the properties of a launch configuration in the launch dialog
39
 * 
40
 *  @since 3.3
41
 *  EXPERIMENTAL
42
 */
43
public class PreferredLaunchersPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
44
45
	private Button fUseSystemLauncher = null;
46
	private SelectLaunchDelegatePanel fPanel = null;
47
	
48
	/**
49
	 * Constructor
50
	 */
51
	public PreferredLaunchersPropertyPage() {}
52
53
	/**
54
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
55
	 */
56
	protected Control createContents(Composite parent) {
57
		Composite comp = SWTUtil.createComposite(parent, 1, 1, GridData.FILL_BOTH);
58
		SWTUtil.createWrapLabel(comp, LaunchConfigurationsMessages.LaunchersTab_0, 1);
59
		SWTUtil.createVerticalSpacer(comp, 1);
60
		Composite c2 = SWTUtil.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL);
61
		fUseSystemLauncher = SWTUtil.createCheckButton(c2, LaunchConfigurationsMessages.LaunchersTab_1, null, true);
62
		Link link = new Link(c2, SWT.NONE);
63
		link.setText(LaunchConfigurationsMessages.LaunchersTab_3);
64
		link.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true, 1, 1));
65
		
66
		SWTUtil.createVerticalSpacer(comp, 1);
67
		fPanel = new SelectLaunchDelegatePanel(comp);
68
		
69
		initialize();
70
		
71
	//add selection listeners after so we can access the panel
72
		fUseSystemLauncher.addSelectionListener(new SelectionListener() {
73
			public void widgetDefaultSelected(SelectionEvent e) {}
74
			public void widgetSelected(SelectionEvent e) {
75
				boolean checked = ((Button)e.widget).getSelection();
76
				fPanel.setEnabled(checked);
77
				resetDelegate();
78
			}
79
		});
80
		link.addSelectionListener(new SelectionListener() {
81
			public void widgetDefaultSelected(SelectionEvent e) {}
82
			public void widgetSelected(SelectionEvent e) {
83
				SWTUtil.showPreferencePage("org.eclipse.debug.ui.LaunchDelegatesPreferencePage"); //$NON-NLS-1$
84
				if(!fUseSystemLauncher.getSelection()) {
85
					resetDelegate();
86
				}
87
			}
88
		});
89
		PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_LAUNCHERS_TAB);
90
		return comp;
91
	}
92
93
	/**
94
	 * Resets the selected and checked delegate in the preferred launcher view part to be the one from the workspace
95
	 */
96
	private void resetDelegate() {
97
		ILaunchConfiguration config = getLaunchConfiguration();
98
		if(!fUseSystemLauncher.getSelection()) {
99
			try {
100
				ILaunchDelegate preferred = config.getType().getPreferredDelegate(getModes());
101
				if(preferred != null) {
102
					fPanel.setSelection(preferred);
103
				}
104
			}
105
			catch (CoreException ce) {DebugUIPlugin.log(ce);}
106
		}
107
	}
108
	
109
	/**
110
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
111
	 */
112
	protected void performDefaults() {
113
		if(fUseSystemLauncher != null) {
114
			fUseSystemLauncher.setSelection(false);
115
		}
116
		super.performDefaults();
117
	}
118
119
	/**
120
	 * Initializes the page
121
	 */
122
	private void initialize() {
123
		try {
124
			fPanel.initialize(getLaunchConfiguration().getType().getDelegates(getModes()));
125
			ILaunchConfigurationWorkingCopy config = getLaunchConfiguration();
126
			Set modes = getModes();
127
			ILaunchDelegate delegate = config.getPreferredDelegate(modes);
128
			boolean custom = delegate != null;
129
			fUseSystemLauncher.setSelection(custom);
130
			fPanel.setEnabled(custom);
131
			//load the pref settings
132
			fPanel.initialize(config.getType().getDelegates(modes));
133
			if(delegate == null) {
134
				delegate = config.getType().getPreferredDelegate(modes);
135
			}
136
			fPanel.setSelection(delegate);
137
		} 
138
		catch (CoreException e1) {DebugUIPlugin.log(e1);}
139
	}
140
	
141
	/**
142
	 * @return the launch configuration backing this property page
143
	 */
144
	private ILaunchConfigurationWorkingCopy getLaunchConfiguration() {
145
		LaunchConfigurationsDialog dialog = (LaunchConfigurationsDialog) LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
146
		return (ILaunchConfigurationWorkingCopy) ((IStructuredSelection)dialog.getTabViewer().getSelection()).getFirstElement();
147
	}
148
	
149
	/**
150
	 * @see org.eclipse.jface.preference.PreferencePage#isValid()
151
	 */
152
	public boolean isValid() {
153
		setErrorMessage(null);
154
		if(fPanel.getSelectedDelegate() == null) {
155
			ILaunchConfigurationWorkingCopy config = getLaunchConfiguration();
156
			if(fUseSystemLauncher.getSelection()) {
157
				setErrorMessage(LaunchConfigurationsMessages.LaunchersTab_4+config.getName());
158
				return false;
159
			}
160
			else {
161
				setErrorMessage(LaunchConfigurationsMessages.LaunchersTab_6);
162
				return false;
163
			}
164
		}
165
		return super.isValid();
166
	}
167
168
	/**
169
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
170
	 */
171
	public boolean performOk() {
172
		ILaunchConfigurationWorkingCopy config = getLaunchConfiguration();
173
		Set modes = getModes();
174
		ILaunchDelegate delegate = null;
175
		if(fUseSystemLauncher.getSelection()) {
176
			delegate = fPanel.getSelectedDelegate();	
177
			if(delegate != null) {
178
				config.setPreferredLaunchDelegate(modes, delegate.getId());
179
			}
180
		}
181
		else {
182
			config.setPreferredLaunchDelegate(modes, null);
183
		}
184
		if(config.isDirty()) {
185
			try {
186
				config.doSave();
187
			} 
188
			catch (CoreException e) {DebugUIPlugin.log(e);}
189
		}
190
		updateLaunchDialog();
191
		return super.performOk();
192
	}
193
	
194
	/**
195
	 * @return the complete set of modes that the associated launch configuration is concerned with
196
	 */
197
	private Set getModes() {
198
		Set modes = new HashSet();
199
		try {
200
			ILaunchConfigurationWorkingCopy config = getLaunchConfiguration().getWorkingCopy();
201
			modes = config.getModes();
202
			modes.add(LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog().getMode());
203
		}
204
		catch (CoreException ce) {DebugUIPlugin.log(ce);}
205
		return modes;
206
	}
207
	
208
	/**
209
	 * updates the currently visible launch dialog
210
	 */
211
	private void updateLaunchDialog() {
212
		ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog();
213
		dialog.updateButtons();
214
		dialog.updateMessage();
215
	}
216
	
217
}
(-)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

Return to bug 157059