Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 74480 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+7 lines)
Lines 1394-1399 Link Here
1394
            </or>
1394
            </or>
1395
         </enabledWhen>
1395
         </enabledWhen>
1396
      </page>
1396
      </page>
1397
      <page
1398
            adaptable="true"
1399
            class="org.eclipse.debug.internal.ui.launchConfigurations.properties.ExecutionPropertiesPage"
1400
            id="org.eclipse.debug.ui.properties.execution"
1401
            name="Execution"
1402
            objectClass="org.eclipse.core.resources.IResource">
1403
      </page>
1397
   </extension>
1404
   </extension>
1398
<!-- commands and their bindings
1405
<!-- commands and their bindings
1399
NOTE: 
1406
NOTE: 
(-)ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java (+1 lines)
Lines 115-120 Link Here
115
	// Property pages
115
	// Property pages
116
	public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
116
	public static final String PROCESS_PROPERTY_PAGE = PREFIX + "process_property_page_context"; //$NON-NLS-1$
117
	public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
117
	public static final String PROCESS_PAGE_RUN_AT = PREFIX + "process_page_run_at_time_widget"; //$NON-NLS-1$
118
	public static final String EXECUTION_PROPERTY_PAGE = PREFIX + "execution_property_page"; //$NON-NLS-1$
118
	
119
	
119
	// Launch configuration dialog pages
120
	// Launch configuration dialog pages
120
	public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$
121
	public static final String LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB = PREFIX + "launch_configuration_dialog_common_tab"; //$NON-NLS-1$
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/CategoryFilter.java (+39 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.properties;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.jface.viewers.ViewerFilter;
17
18
/**
19
 * Filters configurations in non-default launch categories.
20
 *
21
 * @since 3.3
22
 */
23
public class CategoryFilter extends ViewerFilter {
24
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
27
	 */
28
	public boolean select(Viewer viewer, Object parentElement, Object element) {
29
		if (element instanceof ILaunchConfiguration) {
30
			try {
31
				return ((ILaunchConfiguration)element).getType().getCategory() == null;
32
			} catch (CoreException e) {
33
				return false;
34
			}
35
		}
36
		return true;
37
	}
38
39
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/LaunchConfigurationComparator.java (+78 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.properties;
12
13
import java.util.ArrayList;
14
import java.util.Collections;
15
import java.util.Comparator;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.DebugPlugin;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.ILaunchConfigurationType;
25
import org.eclipse.ui.model.WorkbenchViewerComparator;
26
27
/**
28
 * Groups configurations by type.
29
 * 
30
 * @since 3.3
31
 */
32
public class LaunchConfigurationComparator extends WorkbenchViewerComparator {
33
34
	private static Map categories;
35
	
36
	public int category(Object element) {
37
		Map map = getCategories();
38
		if (element instanceof ILaunchConfiguration) {
39
			ILaunchConfiguration configuration = (ILaunchConfiguration) element;
40
			try {
41
				Integer i = (Integer) map.get(configuration.getType());
42
				if (i != null) {
43
					return i.intValue();
44
				}
45
			} catch (CoreException e) {
46
			}
47
		}
48
		return map.size();
49
	}
50
	
51
	private Map getCategories() {
52
		if (categories == null) {
53
			categories = new HashMap();
54
			ILaunchConfigurationType[] lcts = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
55
			List types = new ArrayList(lcts.length);
56
			for (int i = 0; i < lcts.length; i++) {
57
				types.add(lcts[i]);
58
			}
59
			Collections.sort(types, new Comparator() {
60
				public int compare(Object o1, Object o2) {
61
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
62
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
63
					return t1.getName().compareTo(t2.getName());
64
				}
65
			
66
			});
67
			Iterator iterator = types.iterator();
68
			int i = 0;
69
			while (iterator.hasNext()) {
70
				categories.put(iterator.next(), new Integer(i));
71
				i++;
72
			}
73
		}
74
		return categories;
75
	}
76
77
	
78
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/ExecutionPropertiesPage.java (+449 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.properties;
12
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Collections;
16
import java.util.Comparator;
17
import java.util.Iterator;
18
import java.util.List;
19
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IAdaptable;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.debug.core.DebugPlugin;
25
import org.eclipse.debug.core.ILaunchConfiguration;
26
import org.eclipse.debug.core.ILaunchConfigurationType;
27
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
28
import org.eclipse.debug.core.ILaunchManager;
29
import org.eclipse.debug.internal.ui.DebugUIPlugin;
30
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
31
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
32
import org.eclipse.debug.internal.ui.SWTUtil;
33
import org.eclipse.debug.ui.DebugUITools;
34
import org.eclipse.debug.ui.ILaunchGroup;
35
import org.eclipse.jface.viewers.ArrayContentProvider;
36
import org.eclipse.jface.viewers.CheckStateChangedEvent;
37
import org.eclipse.jface.viewers.CheckboxTableViewer;
38
import org.eclipse.jface.viewers.ICheckStateListener;
39
import org.eclipse.jface.viewers.ISelection;
40
import org.eclipse.jface.viewers.ISelectionChangedListener;
41
import org.eclipse.jface.viewers.IStructuredSelection;
42
import org.eclipse.jface.viewers.SelectionChangedEvent;
43
import org.eclipse.jface.viewers.StructuredSelection;
44
import org.eclipse.jface.window.Window;
45
import org.eclipse.swt.SWT;
46
import org.eclipse.swt.events.SelectionEvent;
47
import org.eclipse.swt.events.SelectionListener;
48
import org.eclipse.swt.layout.GridData;
49
import org.eclipse.swt.layout.GridLayout;
50
import org.eclipse.swt.widgets.Button;
51
import org.eclipse.swt.widgets.Composite;
52
import org.eclipse.swt.widgets.Control;
53
import org.eclipse.swt.widgets.Table;
54
import org.eclipse.ui.PlatformUI;
55
import org.eclipse.ui.dialogs.ListDialog;
56
import org.eclipse.ui.dialogs.PropertyPage;
57
58
import com.ibm.icu.text.MessageFormat;
59
60
/**
61
 * Displays execution settings for a resource - associated launch configurations.
62
 * 
63
 * @since 3.3
64
 */
65
public class ExecutionPropertiesPage extends PropertyPage implements ICheckStateListener, ISelectionChangedListener, SelectionListener {
66
	
67
	private CheckboxTableViewer viewer;
68
	private Button newButton;
69
	private Button copyButton;
70
	private Button editButton;
71
	private Button deleteButton;
72
	
73
	/**
74
	 * List of configurations to be deleted
75
	 */
76
	private List deletedConfigurations = new ArrayList();
77
	
78
	/**
79
	 * List of original default candidates for the resource
80
	 */
81
	private List originalCandidates;
82
	
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
85
	 */
86
	protected Control createContents(Composite parent) {
87
		// TODO: add help to documentation
88
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.EXECUTION_PROPERTY_PAGE);
89
		
90
		Composite composite = new Composite(parent, SWT.NONE);
91
		composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
92
		GridLayout layout = new GridLayout();
93
		layout.marginHeight = 0;
94
		layout.marginWidth = 0;
95
		composite.setLayout(layout);
96
		
97
		SWTUtil.createLabel(composite, MessageFormat.format("&Select default launch settings for {0}:", new String[]{getResource().getName()}), 2);
98
		
99
		Composite tableAndButtons = new Composite(composite, SWT.NONE);
100
		tableAndButtons.setLayoutData(new GridData(GridData.FILL_BOTH));
101
		layout = new GridLayout();
102
		layout.marginHeight = 0;
103
		layout.marginWidth = 0;
104
		layout.numColumns = 2;
105
		tableAndButtons.setLayout(layout);
106
		
107
		viewer= CheckboxTableViewer.newCheckList(tableAndButtons, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
108
		viewer.setLabelProvider(new DefaultLabelProvider());
109
		viewer.setContentProvider(new ArrayContentProvider());
110
		viewer.setComparator(new LaunchConfigurationComparator());
111
		viewer.addCheckStateListener(this);
112
		// Only filter private configurations and external tools to avoid filtering a default
113
		viewer.addFilter(new PrivateConfigurationFilter());
114
		viewer.addFilter(new CategoryFilter());
115
		Table builderTable= viewer.getTable();
116
		GridData gridData = new GridData(GridData.FILL_BOTH);
117
		gridData.heightHint = 300;
118
		builderTable.setLayoutData(gridData);
119
		
120
		IResource resource = getResource();
121
		originalCandidates = getDefaultCandidates(resource);
122
		viewer.setInput(originalCandidates);
123
		try {
124
			ILaunchConfiguration configuration = DebugPlugin.getDefault().getLaunchManager().getDefaultConfiguration(resource);
125
			if (configuration != null) {
126
				Iterator iterator = originalCandidates.iterator();
127
				while (iterator.hasNext()) {
128
					ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
129
					if (configuration.equals(wc.getOriginal())) {
130
						viewer.setChecked(wc, true);
131
						break;
132
					}
133
				}
134
			}
135
		} catch (CoreException e) {
136
			setErrorMessage(e.getMessage());
137
		}
138
		
139
		Composite buttonArea = new Composite(tableAndButtons, SWT.NONE);
140
		layout = new GridLayout();
141
		layout.marginHeight = 0;
142
		layout.marginWidth = 0;
143
		buttonArea.setLayout(layout);
144
		buttonArea.setLayoutData(new GridData(GridData.FILL_VERTICAL));
145
		newButton = SWTUtil.createPushButton(buttonArea, "New...", null);
146
		newButton.addSelectionListener(this);
147
		copyButton = SWTUtil.createPushButton(buttonArea, "Copy...", null);
148
		copyButton.addSelectionListener(this);
149
		editButton = SWTUtil.createPushButton(buttonArea, "Edit...", null);
150
		editButton.addSelectionListener(this);
151
		deleteButton = SWTUtil.createPushButton(buttonArea, "Delete", null);
152
		deleteButton.addSelectionListener(this);
153
		
154
		viewer.addSelectionChangedListener(this);
155
		applyDialogFont(composite);
156
		updateButtons(new StructuredSelection());
157
		return composite;
158
	}
159
160
	/**
161
	 * Returns the resource this property page is open on.
162
	 * 
163
	 * @return resource
164
	 */
165
	protected IResource getResource() {
166
		Object element = getElement();
167
		IResource resource = null;
168
		if (element instanceof IResource) {
169
			resource = (IResource) element;
170
		} else if (element instanceof IAdaptable) {
171
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
172
		}
173
		return resource;
174
	}
175
176
	/* (non-Javadoc)
177
	 * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
178
	 */
179
	public void checkStateChanged(CheckStateChangedEvent event) {
180
		ILaunchConfiguration configuration = (ILaunchConfiguration) event.getElement();
181
		// only allow one check
182
		viewer.setCheckedElements(new Object[]{configuration});
183
		// validate
184
		if (!configuration.isLocal()) {
185
			if (!getResource().getProject().equals(configuration.getFile().getProject())) {
186
				// a config must be stored in the same project that it is a default config for
187
				setErrorMessage(MessageFormat.format("Configuration must be located in project {0}", new String[]{getResource().getProject().getName()}));
188
				setValid(false);
189
				return;
190
			}
191
		}
192
		setErrorMessage(null);
193
		setValid(true);
194
	}
195
196
	/* (non-Javadoc)
197
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
198
	 */
199
	public boolean performOk() {
200
		Object[] checked = viewer.getCheckedElements();
201
		try {
202
			ILaunchConfiguration def = null;
203
			if (checked.length == 1) {
204
					def = (ILaunchConfiguration) checked[0];
205
			}
206
			DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
207
		} catch (CoreException e) {
208
			setErrorMessage(e.getMessage());
209
			return false;
210
		}
211
		return super.performOk();
212
	}
213
214
	/* (non-Javadoc)
215
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
216
	 */
217
	protected void performDefaults() {
218
		viewer.setAllChecked(false);
219
		setErrorMessage(null);
220
		setValid(true);
221
		super.performDefaults();
222
	}
223
224
	/* (non-Javadoc)
225
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
226
	 */
227
	public void selectionChanged(SelectionChangedEvent event) {
228
		ISelection s = event.getSelection();
229
		if (s instanceof IStructuredSelection) {
230
			updateButtons((IStructuredSelection) s);
231
		}
232
		
233
	}
234
235
	/**
236
	 * Update buttons based on the given selection.
237
	 * 
238
	 * @param selection
239
	 */
240
	private void updateButtons(IStructuredSelection selection) {
241
		if (selection.size() == 0) {
242
			editButton.setEnabled(false);
243
			copyButton.setEnabled(false);
244
			deleteButton.setEnabled(false);
245
		} else if (selection.size() == 1) {
246
			editButton.setEnabled(true);
247
			copyButton.setEnabled(true);
248
			deleteButton.setEnabled(true);
249
		} else {
250
			editButton.setEnabled(false);
251
			copyButton.setEnabled(false);
252
			deleteButton.setEnabled(true);
253
		}
254
	}
255
256
	/**
257
	 * Returns a list of potential default configurations candidates for the given
258
	 * resource. The configurations are working copies.
259
	 *  
260
	 * @param resource resource
261
	 * @return list of default candidates
262
	 */
263
	private List getDefaultCandidates(IResource resource) {
264
		IPath resourcePath = resource.getFullPath();
265
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
266
		List list = new ArrayList();
267
		try {
268
			ILaunchConfiguration[] configurations = manager.getLaunchConfigurations();
269
			for (int i = 0; i < configurations.length; i++) {
270
				ILaunchConfiguration configuration = configurations[i];
271
				IResource[] resources = configuration.getMappedResources();
272
				if (resources != null) {
273
					for (int j = 0; j < resources.length; j++) {
274
						IResource mappedResource = resources[j];
275
						if (resource.equals(mappedResource) || 
276
								resourcePath.isPrefixOf(mappedResource.getFullPath())) {
277
							list.add(configuration.getWorkingCopy());
278
							break;
279
						}
280
					}
281
				} else {
282
					// 1. similar to launch dialog - if no resource mapping, display the config
283
					// 2. only consider the default launch category (applications, *not* external tools)
284
					if (configuration.getType().getCategory() == null) {
285
						list.add(configuration.getWorkingCopy());
286
					}
287
				}
288
			}
289
		} catch (CoreException e) {
290
			list.clear();
291
			DebugUIPlugin.log(e);
292
		}
293
		return list;
294
	}
295
296
	/* (non-Javadoc)
297
	 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
298
	 */
299
	public void widgetDefaultSelected(SelectionEvent e) {
300
	}
301
302
	/* (non-Javadoc)
303
	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
304
	 */
305
	public void widgetSelected(SelectionEvent e) {
306
		if (e.widget == newButton) {
307
			handleNew();
308
		} else if (e.widget == copyButton) {
309
			handleCopy();
310
		} else if (e.widget == deleteButton) {
311
			handleDelete();
312
		} else if (e.widget == editButton) {
313
			handleEdit();
314
		}
315
	}
316
	
317
	/**
318
	 * Returns selected configurations.
319
	 * 
320
	 * @return selected configurations
321
	 */
322
	private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() {
323
		Object[] array = ((IStructuredSelection)viewer.getSelection()).toArray();
324
		ILaunchConfigurationWorkingCopy[] lcs = new ILaunchConfigurationWorkingCopy[array.length];
325
		System.arraycopy(array, 0, lcs, 0, array.length);
326
		return lcs;
327
	}
328
329
	/**
330
	 * Copy the selection
331
	 */
332
	private void handleCopy() {
333
		ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0];
334
		try {
335
			ILaunchConfigurationWorkingCopy copy = configuration.copy(
336
					DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configuration.getName()));
337
			copy.setAttributes(configuration.getAttributes());
338
			int code = edit(copy);
339
			if (code == Window.OK) {
340
				originalCandidates.add(copy);
341
				viewer.refresh();
342
				viewer.setSelection(new StructuredSelection(copy));
343
			}
344
		} catch (CoreException e) {
345
			setErrorMessage(e.getMessage());
346
		}
347
	}
348
349
	/**
350
	 * Delete the selection
351
	 */
352
	private void handleDelete() {
353
		Table table = viewer.getTable();
354
		int[] indices = table.getSelectionIndices();
355
		Arrays.sort(indices);
356
		ILaunchConfiguration[] configurations = getSelectedConfigurations();
357
		for (int i = 0; i < configurations.length; i++) {
358
			deletedConfigurations.add(configurations[i]);
359
			originalCandidates.remove(configurations[i]);
360
		}
361
		viewer.refresh();
362
		if (indices[0] < table.getItemCount()) {
363
			viewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData()));
364
		} else if (table.getItemCount() > 0) {
365
			viewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData()));
366
		}
367
	}
368
369
	/**
370
	 * Edit the selection
371
	 */
372
	private void handleEdit() {
373
		edit(getSelectedConfigurations()[0]);
374
		viewer.refresh();
375
	}
376
377
	/**
378
	 * Edits the given configuration as a nested working copy.
379
	 * Returns the code from the dialog used to edit the configuration.
380
	 * 
381
	 * @param configuration
382
	 * @return dialog return code - OK or CANCEL
383
	 */
384
	private int edit(ILaunchConfigurationWorkingCopy configuration) {
385
		try {
386
			ILaunchConfigurationWorkingCopy copy = configuration.getNestedWorkingCopy();
387
			ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE);
388
			if (group == null) {
389
				group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.DEBUG_MODE);
390
			}
391
			int code = DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(), copy, group.getIdentifier());
392
			if (code == Window.OK) {
393
				copy.doSave();
394
			}
395
			return code;
396
		} catch (CoreException e) {
397
			setErrorMessage(e.getMessage());
398
		}
399
		return Window.CANCEL;
400
	}
401
402
	/**
403
	 * Create a new configuration
404
	 */
405
	private void handleNew() {
406
		ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
407
		List avail = new ArrayList(types.length); 
408
		for (int i = 0; i < types.length; i++) {
409
			ILaunchConfigurationType type = types[i];
410
			if (type.getCategory() == null) {
411
				// TODO: external tools?
412
				avail.add(type);
413
			}
414
		}
415
		Collections.sort(avail, new Comparator() {
416
				public int compare(Object o1, Object o2) {
417
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
418
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
419
					return t1.getName().compareTo(t2.getName());
420
				}
421
			
422
			});
423
		ListDialog dialog = new ListDialog(getShell());
424
		dialog.setTitle("Selection Configuration Type");
425
		dialog.setContentProvider(new ArrayContentProvider());
426
		dialog.setLabelProvider(new DefaultLabelProvider());
427
		dialog.setAddCancelButton(true);
428
		dialog.setMessage("&Select the kind of configuration to create:");
429
		dialog.setInput(avail);
430
		if (dialog.open() == Window.OK) {
431
			Object[] result = dialog.getResult();
432
			if (result.length == 1) {
433
				ILaunchConfigurationType type = (ILaunchConfigurationType) result[0];
434
				try {
435
					ILaunchConfigurationWorkingCopy wc = type.newInstance(null, DebugPlugin.getDefault().getLaunchManager().
436
							generateUniqueLaunchConfigurationNameFrom("New Configuration"));
437
					if (edit(wc) == Window.OK) {
438
						originalCandidates.add(wc);
439
						viewer.refresh();
440
						viewer.setSelection(new StructuredSelection(wc));
441
					}
442
				} catch (CoreException e) {
443
					setErrorMessage(e.getMessage());
444
				}
445
			}
446
		}
447
	}
448
	
449
}
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/PrivateConfigurationFilter.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.launchConfigurations.properties;
12
13
import org.eclipse.debug.core.ILaunchConfiguration;
14
import org.eclipse.debug.ui.DebugUITools;
15
import org.eclipse.jface.viewers.Viewer;
16
import org.eclipse.jface.viewers.ViewerFilter;
17
18
/**
19
 * Filters private configurations.
20
 *
21
 * @since 3.3
22
 */
23
public class PrivateConfigurationFilter extends ViewerFilter {
24
25
	/* (non-Javadoc)
26
	 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
27
	 */
28
	public boolean select(Viewer viewer, Object parentElement, Object element) {
29
		if (element instanceof ILaunchConfiguration) {
30
			return !DebugUITools.isPrivate((ILaunchConfiguration) element);
31
		}
32
		return true;
33
	}
34
35
}

Return to bug 74480