1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.DebugPlugin; 16 import org.eclipse.debug.core.ILaunchConfiguration; 17 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 18 import org.eclipse.debug.internal.ui.DebugUIPlugin; 19 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 20 import org.eclipse.debug.ui.DebugUITools; 21 import org.eclipse.jface.resource.ImageDescriptor; 22 import org.eclipse.jface.viewers.IStructuredSelection; 23 import org.eclipse.jface.viewers.Viewer; 24 25 28 public class DuplicateLaunchConfigurationAction extends AbstractLaunchConfigurationAction { 29 30 33 public static final String ID_DUPLICATE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_DUPLICATE_ACTION"; 35 38 public DuplicateLaunchConfigurationAction(Viewer viewer, String mode) { 39 super(LaunchConfigurationsMessages.DuplicateLaunchConfigurationAction__Duplicate_1, viewer, mode); 40 } 41 42 45 protected void performAction() { 46 ILaunchConfiguration original = (ILaunchConfiguration)getStructuredSelection().getFirstElement(); 47 String newName = DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(original.getName()); 48 try { 49 ILaunchConfigurationWorkingCopy newWorkingCopy = original.copy(newName); 50 newWorkingCopy.doSave(); 51 } catch (CoreException e) { 52 errorDialog(e); 53 } 54 } 55 56 59 protected boolean updateSelection(IStructuredSelection selection) { 60 return selection.size() == 1 && selection.getFirstElement() instanceof ILaunchConfiguration; 61 } 62 63 66 public ImageDescriptor getDisabledImageDescriptor() { 67 return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DUPLICATE_CONFIG); 68 } 69 70 73 public ImageDescriptor getImageDescriptor() { 74 return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG); 75 } 76 77 80 public String getToolTipText() { 81 return LaunchConfigurationsMessages.LaunchConfigurationsDialog_5; 82 } 83 84 } 85 | Popular Tags |