1 11 package org.eclipse.debug.internal.ui.views.console; 12 13 import org.eclipse.debug.core.DebugPlugin; 14 import org.eclipse.debug.core.ILaunch; 15 import org.eclipse.debug.core.ILaunchesListener2; 16 import org.eclipse.debug.internal.ui.DebugPluginImages; 17 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 18 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 19 import org.eclipse.debug.internal.ui.actions.RemoveAllTerminatedAction; 20 import org.eclipse.debug.ui.IDebugUIConstants; 21 import org.eclipse.jface.action.Action; 22 import org.eclipse.ui.PlatformUI; 23 import org.eclipse.ui.texteditor.IUpdate; 24 25 28 public class ConsoleRemoveAllTerminatedAction extends Action implements IUpdate, ILaunchesListener2 { 29 30 public void dispose() { 31 DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); 32 } 33 34 37 public void update() { 38 ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); 39 for (int i = 0; i < launches.length; i++) { 40 ILaunch launch = launches[i]; 41 if (launch.isTerminated()) { 42 setEnabled(true); 43 return; 44 } 45 } 46 setEnabled(false); 47 48 } 49 50 53 public void run() { 54 ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); 55 RemoveAllTerminatedAction.removeTerminatedLaunches(launches); 56 } 57 58 public ConsoleRemoveAllTerminatedAction() { 59 super(ConsoleMessages.ConsoleRemoveAllTerminatedAction_0); 60 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CONSOLE_REMOVE_ALL_TERMINATED); 61 setToolTipText(ConsoleMessages.ConsoleRemoveAllTerminatedAction_1); 62 setImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE_ALL)); 63 setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_REMOVE_ALL)); 64 setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_REMOVE_ALL)); 65 DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); 66 update(); 67 } 68 69 72 public void launchesRemoved(ILaunch[] launches) { 73 if (isEnabled()) { 74 update(); 75 } 76 } 77 78 81 public void launchesAdded(ILaunch[] launches) { 82 } 83 84 87 public void launchesChanged(ILaunch[] launches) { 88 } 89 90 93 public void launchesTerminated(ILaunch[] launches) { 94 update(); 95 } 96 } 97 | Popular Tags |