1 11 package org.eclipse.debug.internal.ui.actions; 12 13 14 import org.eclipse.debug.core.ILaunch; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.model.IDebugElement; 17 import org.eclipse.debug.core.model.IProcess; 18 import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; 19 import org.eclipse.debug.ui.DebugUITools; 20 21 public class RelaunchActionDelegate extends AbstractDebugActionDelegate { 22 23 26 protected void doAction(Object object) { 27 ILaunch launch= getLaunch(object); 28 if (launch != null) { 29 relaunch(launch.getLaunchConfiguration(), launch.getLaunchMode()); 30 } 31 } 32 33 public static ILaunch getLaunch(Object element) { 34 ILaunch launch= null; 35 if (element instanceof IDebugElement) { 36 launch= ((IDebugElement)element).getLaunch(); 37 } else if (element instanceof ILaunch) { 38 launch= ((ILaunch)element); 39 } else if (element instanceof IProcess) { 40 launch= ((IProcess)element).getLaunch(); 41 } 42 return launch; 43 } 44 45 48 public static void relaunch(ILaunchConfiguration config, String mode) { 49 DebugUITools.launch(config, mode); 50 } 51 52 55 protected boolean isEnabledFor(Object element) { 56 ILaunch launch= null; 57 if (element instanceof ILaunch) { 58 launch= (ILaunch)element; 59 } else if (element instanceof IDebugElement) { 60 launch= ((IDebugElement)element).getLaunch(); 61 } else if (element instanceof IProcess) { 62 launch= ((IProcess)element).getLaunch(); 63 } 64 65 return launch != null && launch.getLaunchConfiguration() != null && LaunchConfigurationManager.isVisible(launch.getLaunchConfiguration()); 66 } 67 68 71 protected String getErrorDialogMessage() { 72 return ActionMessages.RelaunchActionDelegate_Launch_Failed_1; 73 } 74 75 78 protected String getStatusMessage() { 79 return ActionMessages.RelaunchActionDelegate_An_exception_occurred_while_launching_2; 80 } 81 } 82 | Popular Tags |