|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.debug.internal.ui.preferences; |
| 12 |
|
| 13 |
import java.util.ArrayList; |
| 14 |
import java.util.Arrays; |
| 15 |
import java.util.Collections; |
| 16 |
import java.util.Comparator; |
| 17 |
import java.util.HashSet; |
| 18 |
import java.util.Iterator; |
| 19 |
import java.util.List; |
| 20 |
import java.util.Set; |
| 21 |
|
| 22 |
import org.eclipse.core.resources.IResource; |
| 23 |
import org.eclipse.core.runtime.CoreException; |
| 24 |
import org.eclipse.core.runtime.IAdaptable; |
| 25 |
import org.eclipse.core.runtime.IPath; |
| 26 |
import org.eclipse.debug.core.DebugPlugin; |
| 27 |
import org.eclipse.debug.core.ILaunchConfiguration; |
| 28 |
import org.eclipse.debug.core.ILaunchConfigurationType; |
| 29 |
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 30 |
import org.eclipse.debug.internal.core.LaunchManager; |
| 31 |
import org.eclipse.debug.internal.ui.DebugUIPlugin; |
| 32 |
import org.eclipse.debug.internal.ui.DefaultLabelProvider; |
| 33 |
import org.eclipse.debug.internal.ui.IDebugHelpContextIds; |
| 34 |
import org.eclipse.debug.internal.ui.SWTUtil; |
| 35 |
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationComparator; |
| 36 |
import org.eclipse.debug.ui.DebugUITools; |
| 37 |
import org.eclipse.debug.ui.IDebugUIConstants; |
| 38 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
| 39 |
import org.eclipse.jface.viewers.CheckStateChangedEvent; |
| 40 |
import org.eclipse.jface.viewers.CheckboxTableViewer; |
| 41 |
import org.eclipse.jface.viewers.ICheckStateListener; |
| 42 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 43 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 44 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 45 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 46 |
import org.eclipse.jface.window.Window; |
| 47 |
import org.eclipse.swt.SWT; |
| 48 |
import org.eclipse.swt.events.SelectionEvent; |
| 49 |
import org.eclipse.swt.events.SelectionListener; |
| 50 |
import org.eclipse.swt.layout.GridData; |
| 51 |
import org.eclipse.swt.layout.GridLayout; |
| 52 |
import org.eclipse.swt.widgets.Button; |
| 53 |
import org.eclipse.swt.widgets.Composite; |
| 54 |
import org.eclipse.swt.widgets.Control; |
| 55 |
import org.eclipse.swt.widgets.Table; |
| 56 |
import org.eclipse.ui.PlatformUI; |
| 57 |
import org.eclipse.ui.dialogs.ListDialog; |
| 58 |
import org.eclipse.ui.dialogs.PropertyPage; |
| 59 |
|
| 60 |
import com.ibm.icu.text.MessageFormat; |
| 61 |
|
| 62 |
/** |
| 63 |
* Displays default launch configuration settings for a selected resource - associated launch configurations. |
| 64 |
* |
| 65 |
* @see {@link PropertyPage} |
| 66 |
* @see {@link ILaunchConfiguration} |
| 67 |
* @see {@link org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog} |
| 68 |
* @see {@link IDebugHelpContextIds#DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE} |
| 69 |
* |
| 70 |
* @since 3.3 |
| 71 |
*/ |
| 72 |
public class DefaultLaunchConfigurationsPropertiesPage extends PropertyPage { |
| 73 |
/** |
| 74 |
* Set of configurations to be deleted |
| 75 |
*/ |
| 76 |
private Set fDeletedConfigurations = new HashSet(); |
| 77 |
|
| 78 |
/** |
| 79 |
* Set of original default candidates for the resource |
| 80 |
*/ |
| 81 |
private Set fOriginalCandidates; |
| 82 |
|
| 83 |
/** |
| 84 |
* List of the applicable launch config types for the backing resource |
| 85 |
*/ |
| 86 |
private List fTypeCandidates = null; |
| 87 |
|
| 88 |
//widgets |
| 89 |
private CheckboxTableViewer fViewer; |
| 90 |
private Button fNewButton = null; |
| 91 |
private Button fEditButton = null; |
| 92 |
private Button fDuplicateButton = null; |
| 93 |
private Button fDeleteButton = null; |
| 94 |
|
| 95 |
/* (non-Javadoc) |
| 96 |
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) |
| 97 |
*/ |
| 98 |
protected Control createContents(Composite parent) { |
| 99 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE); |
| 100 |
|
| 101 |
Composite topComposite = SWTUtil.createComposite(parent, 2, 1, GridData.FILL_BOTH); |
| 102 |
|
| 103 |
SWTUtil.createWrapLabel(topComposite, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_0, 2, 300); |
| 104 |
SWTUtil.createVerticalSpacer(topComposite, 2); |
| 105 |
SWTUtil.createWrapLabel(topComposite, MessageFormat.format(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_1, new String[]{getResource().getName()}), 2, 300); |
| 106 |
|
| 107 |
fViewer = createViewer(topComposite); |
| 108 |
|
| 109 |
Composite buttonComp = SWTUtil.createComposite(topComposite, 1, 1, GridData.FILL_VERTICAL); |
| 110 |
GridLayout layout = (GridLayout) buttonComp.getLayout(); |
| 111 |
layout.marginHeight = 0; |
| 112 |
fNewButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_2, null); |
| 113 |
fNewButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_3); |
| 114 |
fNewButton.addSelectionListener(new SelectionListener() { |
| 115 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 116 |
public void widgetSelected(SelectionEvent e) { |
| 117 |
handleNew(); |
| 118 |
} |
| 119 |
}); |
| 120 |
|
| 121 |
fDuplicateButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_4, null); |
| 122 |
fDuplicateButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_5); |
| 123 |
fDuplicateButton.setEnabled(false); |
| 124 |
fDuplicateButton.addSelectionListener(new SelectionListener() { |
| 125 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 126 |
public void widgetSelected(SelectionEvent e) { |
| 127 |
handleCopy(); |
| 128 |
} |
| 129 |
}); |
| 130 |
fEditButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_6, null); |
| 131 |
fEditButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_7); |
| 132 |
fEditButton.setEnabled(false); |
| 133 |
fEditButton.addSelectionListener(new SelectionListener() { |
| 134 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 135 |
public void widgetSelected(SelectionEvent e) { |
| 136 |
handleEdit(); |
| 137 |
} |
| 138 |
}); |
| 139 |
fDeleteButton = SWTUtil.createPushButton(buttonComp, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_8, null); |
| 140 |
fDeleteButton.setToolTipText(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_9); |
| 141 |
fDeleteButton.setEnabled(false); |
| 142 |
fDeleteButton.addSelectionListener(new SelectionListener() { |
| 143 |
public void widgetDefaultSelected(SelectionEvent e) {} |
| 144 |
public void widgetSelected(SelectionEvent e) { |
| 145 |
handleDelete(); |
| 146 |
} |
| 147 |
}); |
| 148 |
|
| 149 |
fViewer.setSelection(new StructuredSelection()); |
| 150 |
applyDialogFont(topComposite); |
| 151 |
return topComposite; |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Creates and returns the viewer that will display the possible default configurations. |
| 156 |
* |
| 157 |
* @param parent parent composite to create the viewer in |
| 158 |
* @return viewer viewer that will display possible default configurations |
| 159 |
*/ |
| 160 |
protected CheckboxTableViewer createViewer(Composite parent){ |
| 161 |
CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); |
| 162 |
viewer.setLabelProvider(new DefaultLabelProvider()); |
| 163 |
viewer.setContentProvider(new ArrayContentProvider()); |
| 164 |
viewer.setComparator(new LaunchConfigurationComparator()); |
| 165 |
viewer.addCheckStateListener(new ICheckStateListener() { |
| 166 |
public void checkStateChanged(CheckStateChangedEvent event) { |
| 167 |
if (event.getChecked()) { |
| 168 |
fViewer.setCheckedElements(new Object[] {event.getElement()}); |
| 169 |
} |
| 170 |
else{ |
| 171 |
fViewer.setCheckedElements(new Object[] {}); |
| 172 |
} |
| 173 |
} |
| 174 |
}); |
| 175 |
Table builderTable = viewer.getTable(); |
| 176 |
GridData tableGridData = new GridData(GridData.FILL_BOTH); |
| 177 |
tableGridData.heightHint = 300; |
| 178 |
builderTable.setLayoutData(tableGridData); |
| 179 |
|
| 180 |
IResource resource = getResource(); |
| 181 |
viewer.setInput(collectConfigCandidates(resource)); |
| 182 |
try { |
| 183 |
ILaunchConfiguration configuration = getLaunchManager().getDefaultConfiguration(resource); |
| 184 |
if (configuration != null) { |
| 185 |
Iterator iterator = fOriginalCandidates.iterator(); |
| 186 |
while (iterator.hasNext()) { |
| 187 |
ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) iterator.next(); |
| 188 |
if (configuration.equals(wc.getOriginal())) { |
| 189 |
viewer.setChecked(wc, true); |
| 190 |
break; |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
} catch (CoreException e) { |
| 195 |
setErrorMessage(e.getMessage()); |
| 196 |
} |
| 197 |
viewer.addSelectionChangedListener(new ISelectionChangedListener() { |
| 198 |
public void selectionChanged(SelectionChangedEvent event) { |
| 199 |
boolean empty = event.getSelection().isEmpty(); |
| 200 |
fEditButton.setEnabled(!empty); |
| 201 |
fDuplicateButton.setEnabled(!empty); |
| 202 |
fDeleteButton.setEnabled(!empty); |
| 203 |
} |
| 204 |
}); |
| 205 |
|
| 206 |
return viewer; |
| 207 |
} |
| 208 |
|
| 209 |
/** |
| 210 |
* Returns the viewer displaying possible default configurations. |
| 211 |
* |
| 212 |
* @return viewer |
| 213 |
*/ |
| 214 |
protected CheckboxTableViewer getViewer() { |
| 215 |
return fViewer; |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* Returns the launch manager |
| 220 |
* @return the launch manager |
| 221 |
*/ |
| 222 |
protected LaunchManager getLaunchManager() { |
| 223 |
return (LaunchManager) DebugPlugin.getDefault().getLaunchManager(); |
| 224 |
} |
| 225 |
|
| 226 |
/** |
| 227 |
* Collects the applicable launch configuration types for the backing resource. |
| 228 |
* Default implementation uses the launch shortcut evaluation expressions and leverages the |
| 229 |
* mapping of launch shortcut to config type id to derive the applicable types. |
| 230 |
* @return the listing of applicable launch configuration types for the backing resource |
| 231 |
*/ |
| 232 |
protected List collectTypeCandidates() { |
| 233 |
if(fTypeCandidates == null) { |
| 234 |
fTypeCandidates = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getApplicableConfigurationTypes(getResource()); |
| 235 |
Collections.sort(fTypeCandidates, new Comparator() { |
| 236 |
public int compare(Object o1, Object o2) { |
| 237 |
ILaunchConfigurationType t1 = (ILaunchConfigurationType) o1; |
| 238 |
ILaunchConfigurationType t2 = (ILaunchConfigurationType) o2; |
| 239 |
return t1.getName().compareTo(t2.getName()); |
| 240 |
} |
| 241 |
|
| 242 |
}); |
| 243 |
} |
| 244 |
return fTypeCandidates; |
| 245 |
} |
| 246 |
|
| 247 |
/** |
| 248 |
* Returns a set of potential default configurations candidates for the given |
| 249 |
* resource. The configurations are working copies. |
| 250 |
* |
| 251 |
* @param resource resource |
| 252 |
* @return list of default candidates |
| 253 |
*/ |
| 254 |
protected Set collectConfigCandidates(IResource resource) { |
| 255 |
if(fOriginalCandidates == null) { |
| 256 |
fOriginalCandidates = new HashSet(); |
| 257 |
IPath resourcePath = resource.getFullPath(); |
| 258 |
try { |
| 259 |
List types = collectTypeCandidates(); |
| 260 |
List configs = new ArrayList(); |
| 261 |
ILaunchConfiguration[] configurations = getLaunchManager().getLaunchConfigurations(); |
| 262 |
for(int i = 0; i < configurations.length; i++) { |
| 263 |
if(types.contains(configurations[i].getType())) { |
| 264 |
configs.add(configurations[i]); |
| 265 |
} |
| 266 |
} |
| 267 |
ILaunchConfiguration configuration = null; |
| 268 |
IResource[] resources = null; |
| 269 |
for (Iterator iter = configs.iterator(); iter.hasNext();) { |
| 270 |
configuration = (ILaunchConfiguration) iter.next(); |
| 271 |
if(!DebugUITools.isPrivate(configuration) && !"org.eclipse.ui.externaltools".equals(configuration.getType().getCategory())) { //$NON-NLS-1$ |
| 272 |
if(configuration.contentsEqual(getLaunchManager().getDefaultConfiguration(resource))) { |
| 273 |
fOriginalCandidates.add(configuration.getWorkingCopy()); |
| 274 |
} |
| 275 |
else { |
| 276 |
resources = configuration.getMappedResources(); |
| 277 |
if (resources != null) { |
| 278 |
for (int j = 0; j < resources.length; j++) { |
| 279 |
if (resource.equals(resources[j]) || resourcePath.isPrefixOf(resources[j].getFullPath()) || |
| 280 |
resources[j].getFullPath().isPrefixOf(resourcePath)) { |
| 281 |
fOriginalCandidates.add(configuration.getWorkingCopy()); |
| 282 |
break; |
| 283 |
} |
| 284 |
} |
| 285 |
} |
| 286 |
} |
| 287 |
} |
| 288 |
} |
| 289 |
} catch (CoreException e) { |
| 290 |
fOriginalCandidates.clear(); |
| 291 |
DebugPlugin.log(e); |
| 292 |
} |
| 293 |
} |
| 294 |
return fOriginalCandidates; |
| 295 |
} |
| 296 |
|
| 297 |
/** |
| 298 |
* Returns the resource this property page is open on. |
| 299 |
* |
| 300 |
* @return resource |
| 301 |
*/ |
| 302 |
protected IResource getResource() { |
| 303 |
Object element = getElement(); |
| 304 |
IResource resource = null; |
| 305 |
if (element instanceof IResource) { |
| 306 |
resource = (IResource) element; |
| 307 |
} else if (element instanceof IAdaptable) { |
| 308 |
resource = (IResource) ((IAdaptable)element).getAdapter(IResource.class); |
| 309 |
} |
| 310 |
return resource; |
| 311 |
} |
| 312 |
|
| 313 |
/* (non-Javadoc) |
| 314 |
* @see org.eclipse.jface.preference.PreferencePage#performOk() |
| 315 |
*/ |
| 316 |
public boolean performOk() { |
| 317 |
Object[] checked = fViewer.getCheckedElements(); |
| 318 |
try { |
| 319 |
ILaunchConfiguration def = null; |
| 320 |
if (checked.length == 1) { |
| 321 |
def = (ILaunchConfiguration) checked[0]; |
| 322 |
def = ((ILaunchConfigurationWorkingCopy)def).doSave(); |
| 323 |
} |
| 324 |
DebugPlugin.getDefault().getLaunchManager().setDefaultConfiguration(getResource(), def); |
| 325 |
} catch (CoreException e) { |
| 326 |
setErrorMessage(e.getMessage()); |
| 327 |
return false; |
| 328 |
} |
| 329 |
//delete |
| 330 |
Iterator iter = fDeletedConfigurations.iterator(); |
| 331 |
while (iter.hasNext()) { |
| 332 |
ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next(); |
| 333 |
try{ |
| 334 |
if (currentConfig.getOriginal() != null){ |
| 335 |
currentConfig.getOriginal().delete(); |
| 336 |
} |
| 337 |
} catch (CoreException e) { |
| 338 |
DebugPlugin.logMessage("Problem deleting configuration " + currentConfig.getName(), e); //$NON-NLS-1$ |
| 339 |
} |
| 340 |
} |
| 341 |
//add |
| 342 |
iter = fOriginalCandidates.iterator(); |
| 343 |
while (iter.hasNext()) { |
| 344 |
ILaunchConfigurationWorkingCopy currentConfig = (ILaunchConfigurationWorkingCopy) iter.next(); |
| 345 |
if (currentConfig.isDirty()){ |
| 346 |
try{ |
| 347 |
currentConfig.doSave(); |
| 348 |
} catch (CoreException e) { |
| 349 |
DebugPlugin.logMessage("Problem saving changes to configuration " + currentConfig.getName(), e); //$NON-NLS-1$ |
| 350 |
} |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
return super.performOk(); |
| 355 |
} |
| 356 |
|
| 357 |
/* (non-Javadoc) |
| 358 |
* @see org.eclipse.jface.preference.PreferencePage#performDefaults() |
| 359 |
*/ |
| 360 |
protected void performDefaults() { |
| 361 |
fViewer.setAllChecked(false); |
| 362 |
setErrorMessage(null); |
| 363 |
setValid(true); |
| 364 |
super.performDefaults(); |
| 365 |
} |
| 366 |
|
| 367 |
/** |
| 368 |
* Returns the names of the launch configurations passed in as original input to the tree viewer |
| 369 |
* @return the names of the original launch configurations |
| 370 |
*/ |
| 371 |
private Set getConfigurationNames() { |
| 372 |
Set names = new HashSet(); |
| 373 |
Iterator iter = fOriginalCandidates.iterator(); |
| 374 |
Object o = null; |
| 375 |
while (iter.hasNext()) { |
| 376 |
o = iter.next(); |
| 377 |
if(o instanceof ILaunchConfiguration) { |
| 378 |
names.add(((ILaunchConfiguration)o).getName()); |
| 379 |
} |
| 380 |
} |
| 381 |
return names; |
| 382 |
} |
| 383 |
|
| 384 |
/** |
| 385 |
* Returns selected configurations. |
| 386 |
* |
| 387 |
* @return selected configurations |
| 388 |
*/ |
| 389 |
private ILaunchConfigurationWorkingCopy[] getSelectedConfigurations() { |
| 390 |
IStructuredSelection ss = (IStructuredSelection) fViewer.getSelection(); |
| 391 |
return (ILaunchConfigurationWorkingCopy[]) ss.toList().toArray(new ILaunchConfigurationWorkingCopy[ss.size()]); |
| 392 |
} |
| 393 |
|
| 394 |
/** |
| 395 |
* Copy the selection |
| 396 |
*/ |
| 397 |
private void handleCopy() { |
| 398 |
ILaunchConfigurationWorkingCopy configuration = getSelectedConfigurations()[0]; |
| 399 |
try { |
| 400 |
ILaunchConfigurationWorkingCopy copy = configuration.copy( |
| 401 |
((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).generateUniqueLaunchConfigurationNameFrom(configuration.getName(), getConfigurationNames())); |
| 402 |
copy.setAttributes(configuration.getAttributes()); |
| 403 |
fOriginalCandidates.add(copy); |
| 404 |
fViewer.refresh(); |
| 405 |
fViewer.setSelection(new StructuredSelection(copy)); |
| 406 |
} catch (CoreException e) { |
| 407 |
setErrorMessage(e.getMessage()); |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
/** |
| 412 |
* Delete the selection |
| 413 |
*/ |
| 414 |
private void handleDelete() { |
| 415 |
Table table = fViewer.getTable(); |
| 416 |
int[] indices = table.getSelectionIndices(); |
| 417 |
Arrays.sort(indices); |
| 418 |
ILaunchConfiguration[] configurations = getSelectedConfigurations(); |
| 419 |
for (int i = 0; i < configurations.length; i++) { |
| 420 |
fDeletedConfigurations.add(configurations[i]); |
| 421 |
fOriginalCandidates.remove(configurations[i]); |
| 422 |
} |
| 423 |
fViewer.refresh(); |
| 424 |
if (indices[0] < table.getItemCount()) { |
| 425 |
fViewer.setSelection(new StructuredSelection(table.getItem(indices[0]).getData())); |
| 426 |
} else if (table.getItemCount() > 0) { |
| 427 |
fViewer.setSelection(new StructuredSelection(table.getItem(table.getItemCount() - 1).getData())); |
| 428 |
} |
| 429 |
} |
| 430 |
|
| 431 |
/** |
| 432 |
* Edit the selection |
| 433 |
*/ |
| 434 |
private void handleEdit() { |
| 435 |
edit(getSelectedConfigurations()[0]); |
| 436 |
fViewer.refresh(); |
| 437 |
} |
| 438 |
|
| 439 |
/** |
| 440 |
* Edits the given configuration as a nested working copy. |
| 441 |
* Returns the code from the dialog used to edit the configuration. |
| 442 |
* |
| 443 |
* @param configuration |
| 444 |
* @return dialog return code - OK or CANCEL |
| 445 |
*/ |
| 446 |
private int edit(ILaunchConfigurationWorkingCopy configuration) { |
| 447 |
return DebugUIPlugin.openLaunchConfigurationPropertiesDialog(getShell(), configuration, IDebugUIConstants.ID_RUN_LAUNCH_GROUP, getConfigurationNames(), null); |
| 448 |
} |
| 449 |
|
| 450 |
/** |
| 451 |
* Create a new configuration |
| 452 |
*/ |
| 453 |
private void handleNew() { |
| 454 |
ListDialog dialog = new ListDialog(getShell()); |
| 455 |
dialog.setTitle(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_11); |
| 456 |
dialog.setContentProvider(new ArrayContentProvider()); |
| 457 |
dialog.setLabelProvider(new DefaultLabelProvider()); |
| 458 |
dialog.setAddCancelButton(true); |
| 459 |
dialog.setMessage(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_12); |
| 460 |
dialog.setInput(collectTypeCandidates()); |
| 461 |
if (dialog.open() == Window.OK) { |
| 462 |
Object[] result = dialog.getResult(); |
| 463 |
if (result.length == 1) { |
| 464 |
ILaunchConfigurationType type = (ILaunchConfigurationType) result[0]; |
| 465 |
try { |
| 466 |
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, |
| 467 |
((LaunchManager)DebugPlugin.getDefault().getLaunchManager()). |
| 468 |
generateUniqueLaunchConfigurationNameFrom("New_configuration", getConfigurationNames())); //$NON-NLS-1$ |
| 469 |
if (edit(wc) == Window.OK) { |
| 470 |
fOriginalCandidates.add(wc); |
| 471 |
fViewer.refresh(); |
| 472 |
fViewer.setSelection(new StructuredSelection(wc)); |
| 473 |
} |
| 474 |
} catch (CoreException e) { |
| 475 |
setErrorMessage(e.getMessage()); |
| 476 |
} |
| 477 |
} |
| 478 |
} |
| 479 |
} |
| 480 |
} |