1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import java.util.Iterator ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.debug.core.ILaunchConfiguration; 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.dialogs.MessageDialog; 22 import org.eclipse.jface.resource.ImageDescriptor; 23 import org.eclipse.jface.viewers.IStructuredSelection; 24 import org.eclipse.jface.viewers.Viewer; 25 26 29 public class DeleteLaunchConfigurationAction extends AbstractLaunchConfigurationAction { 30 31 34 public static final String ID_DELETE_ACTION = DebugUIPlugin.getUniqueIdentifier() + ".ID_DELETE_ACTION"; 36 39 public DeleteLaunchConfigurationAction(Viewer viewer, String mode) { 40 super(LaunchConfigurationsMessages.DeleteLaunchConfigurationAction_Dele_te_1, viewer, mode); 41 } 42 43 48 protected boolean shouldDelete() { 49 IStructuredSelection selection = getStructuredSelection(); 50 String dialogMessage = selection.size() > 1 ? LaunchConfigurationsMessages.LaunchConfigurationDialog_Do_you_wish_to_delete_the_selected_launch_configurations__1 : LaunchConfigurationsMessages.LaunchConfigurationDialog_Do_you_wish_to_delete_the_selected_launch_configuration__2; return MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.LaunchConfigurationDialog_Confirm_Launch_Configuration_Deletion_3, dialogMessage); 53 } 54 55 58 protected void performAction() { 59 if(!shouldDelete()) { 60 return; 61 } 62 IStructuredSelection selection = getStructuredSelection(); 63 64 getViewer().getControl().setRedraw(false); 65 Iterator iterator = selection.iterator(); 66 while (iterator.hasNext()) { 67 ILaunchConfiguration configuration = (ILaunchConfiguration)iterator.next(); 68 try { 69 configuration.delete(); 70 } catch (CoreException e) { 71 errorDialog(e); 72 } 73 } 74 getViewer().getControl().setRedraw(true); 75 } 76 77 80 protected boolean updateSelection(IStructuredSelection selection) { 81 if (selection.isEmpty()) { 82 return false; 83 } 84 Iterator items = selection.iterator(); 85 while (items.hasNext()) { 86 if (!(items.next() instanceof ILaunchConfiguration)) { 87 return false; 88 } 89 } 90 return true; 91 } 92 93 96 public ImageDescriptor getDisabledImageDescriptor() { 97 return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_DELETE_CONFIG); 98 } 99 100 103 public ImageDescriptor getImageDescriptor() { 104 return DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG); 105 } 106 107 110 public String getToolTipText() { 111 return LaunchConfigurationsMessages.LaunchConfigurationsDialog_1; 112 } 113 114 } 115 | Popular Tags |