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

Collapse All | Expand All

(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/LaunchConfigurationsPropertiesMessages.properties (+13 lines)
Added Link Here
1
ExecutionPropertiesPage_0=&Select default launch configuration for {0}:
2
ExecutionPropertiesPage_1=New launch configuration
3
ExecutionPropertiesPage_2=New...
4
ExecutionPropertiesPage_3=Duplicates the currently selected launch configuration
5
ExecutionPropertiesPage_4=Duplicate...
6
ExecutionPropertiesPage_5=Edit the currently selected launch configuration
7
ExecutionPropertiesPage_6=Edit...
8
ExecutionPropertiesPage_7=Delete selected launch configuration(s)
9
ExecutionPropertiesPage_8=Delete...
10
ExecutionPropertiesPage_11=Configuration must be located in project {0}
11
ExecutionPropertiesPage_12=Selection Configuration Type
12
ExecutionPropertiesPage_13=&Select the kind of configuration to create:
13
ExecutionPropertiesPage_14=New Configuration
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/properties/ExecutionPropertiesPage.java (+533 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.HashSet;
18
import java.util.Iterator;
19
import java.util.List;
20
import java.util.Set;
21
22
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IAdaptable;
25
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.core.ILaunchConfigurationType;
29
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.core.ILaunchManager;
31
import org.eclipse.debug.internal.core.LaunchManager;
32
import org.eclipse.debug.internal.ui.DebugUIPlugin;
33
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
34
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
35
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
36
import org.eclipse.debug.internal.ui.SWTUtil;
37
import org.eclipse.debug.ui.DebugUITools;
38
import org.eclipse.debug.ui.IDebugUIConstants;
39
import org.eclipse.debug.ui.ILaunchGroup;
40
import org.eclipse.jface.action.Action;
41
import org.eclipse.jface.action.IAction;
42
import org.eclipse.jface.action.ToolBarManager;
43
import org.eclipse.jface.viewers.ArrayContentProvider;
44
import org.eclipse.jface.viewers.CheckStateChangedEvent;
45
import org.eclipse.jface.viewers.CheckboxTableViewer;
46
import org.eclipse.jface.viewers.DoubleClickEvent;
47
import org.eclipse.jface.viewers.ICheckStateListener;
48
import org.eclipse.jface.viewers.IDoubleClickListener;
49
import org.eclipse.jface.viewers.ISelection;
50
import org.eclipse.jface.viewers.IStructuredSelection;
51
import org.eclipse.jface.viewers.StructuredSelection;
52
import org.eclipse.jface.window.Window;
53
import org.eclipse.swt.SWT;
54
import org.eclipse.swt.custom.ViewForm;
55
import org.eclipse.swt.layout.GridData;
56
import org.eclipse.swt.layout.GridLayout;
57
import org.eclipse.swt.widgets.Composite;
58
import org.eclipse.swt.widgets.Control;
59
import org.eclipse.swt.widgets.Table;
60
import org.eclipse.swt.widgets.ToolBar;
61
import org.eclipse.ui.PlatformUI;
62
import org.eclipse.ui.actions.SelectionProviderAction;
63
import org.eclipse.ui.dialogs.ListDialog;
64
import org.eclipse.ui.dialogs.PropertyPage;
65
66
import com.ibm.icu.text.MessageFormat;
67
68
/**
69
 * Displays execution settings for a resource - associated launch configurations.
70
 * 
71
 * @since 3.3
72
 */
73
public class ExecutionPropertiesPage extends PropertyPage implements ICheckStateListener,IDoubleClickListener {
74
	
75
	private ViewForm fViewForm;
76
	private CheckboxTableViewer fViewer;
77
78
	
79
	/**
80
	 * List of configurations to be deleted
81
	 */
82
	private Set fDeletedConfigurations = new HashSet();
83
	
84
	/**
85
	 * List of original default candidates for the resource
86
	 */
87
	private Set fOriginalCandidates;
88
89
	/* (non-Javadoc)
90
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
91
	 */
92
	protected Control createContents(Composite parent) {
93
		// TODO: add help to documentation
94
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.EXECUTION_PROPERTY_PAGE);
95
		
96
		Composite topComposite = new Composite(parent, SWT.NONE);
97
		topComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
98
		GridLayout layout = new GridLayout();
99
		layout.marginHeight = 0;
100
		layout.marginWidth = 0;
101
		topComposite.setLayout(layout);
102
		
103
		SWTUtil.createLabel(topComposite, MessageFormat.format(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_0, new String[]{getResource().getName()}), 2);
104
		
105
		fViewForm = new ViewForm(topComposite,SWT.BORDER | SWT.FLAT);
106
		GridData formGridData = new GridData(GridData.FILL_BOTH);
107
		fViewForm.setLayoutData(formGridData);
108
					
109
		fViewer = createViewer(fViewForm);		
110
		fViewForm.setContent(fViewer.getControl());
111
		
112
		ToolBar toolBar = new ToolBar(fViewForm,SWT.FLAT);
113
		toolBar.setBackground(parent.getBackground());
114
		ToolBarManager toolBarManager = new ToolBarManager(toolBar);
115
		fViewForm.setTopLeft(toolBar);
116
		createActions(toolBarManager);
117
		
118
		fViewer.setSelection(new StructuredSelection());
119
		applyDialogFont(topComposite);
120
		return topComposite;
121
	}
122
123
	/**
124
	 * Creates and returns the viewer that will display the possible default configurations.
125
	 * 
126
	 * @param parent parent composite to create the viewer in
127
	 * @return viewer viewer that will display possible default configurations
128
	 */
129
	protected CheckboxTableViewer createViewer(Composite parent){
130
		CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
131
		viewer.setLabelProvider(new DefaultLabelProvider());
132
		viewer.setContentProvider(new ArrayContentProvider());
133
		viewer.setComparator(new LaunchConfigurationComparator());
134
		viewer.addCheckStateListener(this);
135
		viewer.addDoubleClickListener(this);
136
		// Only filter private configurations and external tools to avoid filtering a default
137
		viewer.addFilter(new PrivateConfigurationFilter());
138
		viewer.addFilter(new CategoryFilter());
139
		Table builderTable= viewer.getTable();
140
		GridData tableGridData = new GridData(GridData.FILL_BOTH);
141
		tableGridData.heightHint = 300;
142
		builderTable.setLayoutData(tableGridData);
143
		
144
		IResource resource = getResource();
145
		fOriginalCandidates = getDefaultCandidates(resource);
146
		viewer.setInput(fOriginalCandidates);
147
		try {
148
			ILaunchConfiguration configuration = DebugPlugin.getDefault().getLaunchManager().getDefaultConfiguration(resource);
149
			if (configuration != null) {
150
				Iterator iterator = fOriginalCandidates.iterator();
151
				while (iterator.hasNext()) {
152
					ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next();
153
					if (configuration.equals(wc.getOriginal())) {
154
						viewer.setChecked(wc, true);
155
						break;
156
					}
157
				}
158
			}
159
		} catch (CoreException e) {
160
			setErrorMessage(e.getMessage());
161
		}
162
		
163
		return viewer;
164
	}
165
	
166
	/**
167
	 * Creates the actions for the property page and adds them to the 
168
	 * tool bar manager.  Called by <code>createContents()</code>.
169
	 * 
170
	 * @param tbm The tool bar manager for this property page
171
	 */
172
	protected void createActions(ToolBarManager tbm){	
173
		IAction action = new Action(){
174
			public void run() {
175
				handleNew();			
176
			}
177
		};
178
		action.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_NEW_CONFIG));
179
		action.setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG));
180
		action.setToolTipText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_1);
181
		action.setText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_2);
182
		tbm.add(action);
183
		
184
		action = new SelectionProviderAction(getViewer(),null){
185
			public void run() {
186
				handleCopy();
187
			}
188
			public void selectionChanged(IStructuredSelection selection) {
189
				setEnabled(selection.size() == 1);
190
			}
191
		};
192
		action.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DUPLICATE_CONFIG));
193
		action.setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG));
194
		action.setToolTipText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_3);
195
		action.setText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_4);
196
		tbm.add(action);
197
		
198
		action = new SelectionProviderAction(getViewer(),null){
199
			public void run() {
200
				handleEdit();
201
			}
202
			public void selectionChanged(IStructuredSelection selection) {
203
				setEnabled(selection.size() == 1);
204
			}
205
		};
206
		// TODO: What icons to use
207
		action.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_MODIFICATION_WATCHPOINT_DISABLED));
208
		action.setImageDescriptor(DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_MODIFICATION_WATCHPOINT));
209
		action.setToolTipText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_5);
210
		action.setText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_6);
211
		tbm.add(action);
212
		
213
		action = new SelectionProviderAction(getViewer(),null){
214
			public void run() {
215
				handleDelete();
216
			}
217
			public void selectionChanged(IStructuredSelection selection) {
218
				setEnabled(selection.size() >= 1);
219
			}
220
		};
221
		action.setDisabledImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DELETE_CONFIG));
222
		action.setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG));
223
		action.setToolTipText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_7);
224
		action.setText(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_8);
225
		tbm.add(action);
226
		
227
		tbm.update(true);
228
		
229
	}
230
	
231
	/**
232
	 * Returns the viewer displaying possible default configurations.
233
	 * 
234
	 * @return viewer
235
	 */
236
	protected CheckboxTableViewer getViewer(){
237
		return fViewer;
238
	}
239
		
240
	/**
241
	 * Returns the resource this property page is open on.
242
	 * 
243
	 * @return resource
244
	 */
245
	protected IResource getResource() {
246
		Object element = getElement();
247
		IResource resource = null;
248
		if (element instanceof IResource) {
249
			resource = (IResource) element;
250
		} else if (element instanceof IAdaptable) {
251
			resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class);
252
		}
253
		return resource;
254
	}
255
256
	/* (non-Javadoc)
257
	 * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
258
	 */
259
	public void checkStateChanged(CheckStateChangedEvent event) {
260
		if (event.getChecked()){
261
			ILaunchConfiguration configuration = (ILaunchConfiguration) event.getElement();
262
			changeCurrentDefault(configuration);
263
		}
264
		else{
265
			changeCurrentDefault(null);
266
		}
267
	}
268
	
269
	/* (non-Javadoc)
270
	 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
271
	 */
272
	public void doubleClick(DoubleClickEvent event) {
273
		ISelection selection = event.getSelection();
274
		if (!selection.isEmpty() && selection instanceof IStructuredSelection){
275
			// Switch checked state, setting default to null if config is unchecked
276
			ILaunchConfiguration configuration = (ILaunchConfiguration)((IStructuredSelection)selection).getFirstElement();
277
			changeCurrentDefault(fViewer.getChecked(configuration) ? null : configuration);
278
		}	
279
	}
280
	
281
	/* (non-Javadoc)
282
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
283
	 */
284
	public boolean performOk() {
285
		Object[] checked = fViewer.getCheckedElements();
286
		try {
287
			ILaunchConfiguration def = null;
288
			if (checked.length == 1) {
289
					def = (ILaunchConfiguration) checked[0];
290
					def = ((ILaunchConfigurationWorkingCopy)def).doSave();
291
			}
292
			DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def);
293
		} catch (CoreException e) {
294
			setErrorMessage(e.getMessage());
295
			return false;
296
		}
297
		
298
		Iterator deletedIter = fDeletedConfigurations.iterator();
299
		while (deletedIter.hasNext()) {
300
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) deletedIter.next();
301
			try{			
302
				if (currentConfig.getOriginal() != null){
303
					currentConfig.getOriginal().delete();
304
				}
305
			} catch (CoreException e) {
306
				DebugPlugin.logMessage("Problem deleting configuration " + currentConfig.getName(), e); //$NON-NLS-1$
307
			}
308
		}
309
		
310
		Iterator originalIter = fOriginalCandidates.iterator();
311
		while (originalIter.hasNext()) {
312
			ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) originalIter.next();
313
			if (currentConfig.isDirty()){
314
				try{
315
					currentConfig.doSave();
316
				} catch (CoreException e) {
317
					DebugPlugin.logMessage("Problem saving changes to configuration " + currentConfig.getName(), e); //$NON-NLS-1$
318
				}
319
			}
320
		}
321
		
322
		return super.performOk();
323
	}
324
325
	/* (non-Javadoc)
326
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
327
	 */
328
	protected void performDefaults() {
329
		fViewer.setAllChecked(false);
330
		setErrorMessage(null);
331
		setValid(true);
332
		super.performDefaults();
333
	}
334
	
335
	/**
336
	 * Sets the default configuration for the working set.  This setting is only applied
337
	 * when <code>performOK</code> is pressed.  Pass <code>null</code> as an argument to 
338
	 * clear the default.
339
	 * 
340
	 * @param configuration configuration to use as default or <code>null</code>
341
	 */
342
	private void changeCurrentDefault(ILaunchConfiguration configuration){
343
		if (configuration != null){
344
			// only allow one check
345
			fViewer.setCheckedElements(new Object[]{configuration});
346
			// validate
347
			if (!configuration.isLocal()) {
348
				if (!getResource().getProject().equals(configuration.getFile().getProject())) {
349
					// a config must be stored in the same project that it is a default config for
350
					setErrorMessage(MessageFormat.format(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_11, new String[]{getResource().getProject().getName()}));
351
					setValid(false);
352
					return;
353
				}
354
			}
355
		} else {
356
			fViewer.setCheckedElements(new Object[]{});
357
		}
358
		setErrorMessage(null);
359
		setValid(true);
360
	}
361
362
	/**
363
	 * Returns a list of potential default configurations candidates for the given
364
	 * resource. The configurations are working copies.
365
	 *  
366
	 * @param resource resource
367
	 * @return list of default candidates
368
	 */
369
	private Set getDefaultCandidates(IResource resource) {
370
		IPath resourcePath = resource.getFullPath();
371
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
372
		Set set = new HashSet();
373
		try {
374
			ILaunchConfiguration[] configurations = manager.getLaunchConfigurations();
375
			for (int i = 0; i < configurations.length; i++) {
376
				ILaunchConfiguration configuration = configurations[i];
377
				IResource[] resources = configuration.getMappedResources();
378
				if (resources != null) {
379
					for (int j = 0; j < resources.length; j++) {
380
						IResource mappedResource = resources[j];
381
						if (resource.equals(mappedResource) || 
382
								resourcePath.isPrefixOf(mappedResource.getFullPath())) {
383
							set.add(configuration.getWorkingCopy());
384
							break;
385
						}
386
					}
387
				} else {
388
					// 1. similar to launch dialog - if no resource mapping, display the config
389
					// 2. only consider the default launch category (applications, *not* external tools)
390
					if (configuration.getType().getCategory() == null) {
391
						set.add(configuration.getWorkingCopy());
392
					}
393
				}
394
			}
395
		} catch (CoreException e) {
396
			set.clear();
397
			DebugUIPlugin.log(e);
398
		}
399
		return set;
400
	}
401
	
402
	private Set getConfigurationNames(){
403
		Set names = new HashSet();
404
		Iterator iter = fOriginalCandidates.iterator();
405
		while (iter.hasNext()) {
406
			ILaunchConfiguration currentConfiguration = (ILaunchConfiguration) iter.next();
407
			names.add(currentConfiguration.getName());
408
		}
409
		return names;
410
	}
411
	
412
	/**
413
	 * Returns selected configurations.
414
	 * 
415
	 * @return selected configurations
416
	 */
417
	private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() {
418
		Object[] array = ((IStructuredSelection)fViewer.getSelection()).toArray();
419
		ILaunchConfigurationWorkingCopy[] lcs = new ILaunchConfigurationWorkingCopy[array.length];
420
		System.arraycopy(array, 0, lcs, 0, array.length);
421
		return lcs;
422
	}
423
424
	/**
425
	 * Copy the selection
426
	 */
427
	private void handleCopy() {
428
		ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0];
429
		try {
430
			ILaunchConfigurationWorkingCopy copy = configuration.copy(
431
					((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).generateUniqueLaunchConfigurationNameFrom(configuration.getName(), getConfigurationNames()));
432
			copy.setAttributes(configuration.getAttributes());
433
			fOriginalCandidates.add(copy);
434
			fViewer.refresh();
435
			fViewer.setSelection(new StructuredSelection(copy));
436
		} catch (CoreException e) {
437
			setErrorMessage(e.getMessage());
438
		}
439
	}
440
441
	/**
442
	 * Delete the selection
443
	 */
444
	private void handleDelete() {
445
		Table table = fViewer.getTable();
446
		int[] indices = table.getSelectionIndices();
447
		Arrays.sort(indices);
448
		ILaunchConfiguration[] configurations = getSelectedConfigurations();
449
		for (int i = 0; i < configurations.length; i++) {
450
			fDeletedConfigurations.add(configurations[i]);
451
			fOriginalCandidates.remove(configurations[i]);
452
		}
453
		fViewer.refresh();
454
		if (indices[0] < table.getItemCount()) {
455
			fViewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData()));
456
		} else if (table.getItemCount() > 0) {
457
			fViewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData()));
458
		}
459
	}
460
461
	/**
462
	 * Edit the selection
463
	 */
464
	private void handleEdit() {
465
		edit(getSelectedConfigurations()[0]);
466
		fViewer.refresh();
467
	}
468
469
	/**
470
	 * Edits the given configuration as a nested working copy.
471
	 * Returns the code from the dialog used to edit the configuration.
472
	 * 
473
	 * @param configuration
474
	 * @return dialog return code - OK or CANCEL
475
	 */
476
	private int edit(ILaunchConfigurationWorkingCopy configuration) {
477
		// TODO: This will result in an NPE in non-standard groups
478
		ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE);
479
		if (group == null) {
480
			group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.DEBUG_MODE);
481
		}
482
		return DebugUIPlugin.openLaunchConfigurationPropertiesDialog(getShell(), configuration, group.getIdentifier(), getConfigurationNames(), null);
483
	}
484
485
	/**
486
	 * Create a new configuration
487
	 */
488
	private void handleNew() {
489
		ILaunchConfigurationType[] types = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationTypes();
490
		List avail = new ArrayList(types.length); 
491
		for (int i = 0; i < types.length; i++) {
492
			ILaunchConfigurationType type = types[i];
493
			if (type.getCategory() == null) {
494
				// TODO: external tools?
495
				avail.add(type);
496
			}
497
		}
498
		Collections.sort(avail, new Comparator() {
499
				public int compare(Object o1, Object o2) {
500
					ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1;
501
					ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2;
502
					return t1.getName().compareTo(t2.getName());
503
				}
504
			
505
			});
506
		ListDialog dialog = new ListDialog(getShell());
507
		dialog.setTitle(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_12);
508
		dialog.setContentProvider(new ArrayContentProvider());
509
		dialog.setLabelProvider(new DefaultLabelProvider());
510
		dialog.setAddCancelButton(true);
511
		dialog.setMessage(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_13);
512
		dialog.setInput(avail);
513
		if (dialog.open() == Window.OK) {
514
			Object[] result = dialog.getResult();
515
			if (result.length == 1) {
516
				ILaunchConfigurationType type = (ILaunchConfigurationType) result[0];
517
				try {
518
					ILaunchConfigurationWorkingCopy wc = type.newInstance(null, 
519
							((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).
520
							generateUniqueLaunchConfigurationNameFrom(LaunchConfigurationsPropertiesMessages.ExecutionPropertiesPage_14,getConfigurationNames()));
521
					if (edit(wc) == Window.OK) {
522
						fOriginalCandidates.add(wc);
523
						fViewer.refresh();
524
						fViewer.setSelection(new StructuredSelection(wc));
525
					}
526
				} catch (CoreException e) {
527
					setErrorMessage(e.getMessage());
528
				}
529
			}
530
		}
531
	}
532
	
533
}
(-)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
}
(-)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/LaunchConfigurationsPropertiesMessages.java (+28 lines)
Added Link Here
1
package org.eclipse.debug.internal.ui.launchConfigurations.properties;
2
3
import org.eclipse.osgi.util.NLS;
4
5
public class LaunchConfigurationsPropertiesMessages extends NLS {
6
	private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.launchConfigurations.properties.LaunchConfigurationsPropertiesMessages"; //$NON-NLS-1$
7
	public static String ExecutionPropertiesPage_0;
8
	public static String ExecutionPropertiesPage_1;
9
	public static String ExecutionPropertiesPage_11;
10
	public static String ExecutionPropertiesPage_12;
11
	public static String ExecutionPropertiesPage_13;
12
	public static String ExecutionPropertiesPage_14;
13
	public static String ExecutionPropertiesPage_2;
14
	public static String ExecutionPropertiesPage_3;
15
	public static String ExecutionPropertiesPage_4;
16
	public static String ExecutionPropertiesPage_5;
17
	public static String ExecutionPropertiesPage_6;
18
	public static String ExecutionPropertiesPage_7;
19
	public static String ExecutionPropertiesPage_8;
20
	static {
21
		// initialize resource bundle
22
		NLS.initializeMessages(BUNDLE_NAME,
23
				LaunchConfigurationsPropertiesMessages.class);
24
	}
25
26
	private LaunchConfigurationsPropertiesMessages() {
27
	}
28
}

Return to bug 74480