@Override public void run() { IProcess process = fConsole.getProcess(); List<ITerminate> targets = collectTargets(process); targets.add(process); DebugCommandService service = DebugCommandService.getService(fWindow); service.executeCommand(ITerminateHandler.class, targets.toArray(), null); }
/** * Creates a terminate action for the console * @param window the window * @param console the console */ public ConsoleTerminateAction(IWorkbenchWindow window, ProcessConsole console) { super(ConsoleMessages.ConsoleTerminateAction_0); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CONSOLE_TERMINATE_ACTION); fConsole = console; fWindow = window; setToolTipText(ConsoleMessages.ConsoleTerminateAction_1); setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_TERMINATE)); setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE)); setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_TERMINATE)); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CONSOLE_TERMINATE_ACTION); update(); }
@Override public void update() { IProcess process = fConsole.getProcess(); setEnabled(process.canTerminate()); }
@Override public void handleDebugEvents(DebugEvent[] events) { for (int i = 0; i < events.length; i++) { DebugEvent event = events[i]; if (event.getSource().equals(getProcess())) { Runnable r = () -> { if (fTerminate != null) { fTerminate.update(); } }; DebugUIPlugin.getStandardDisplay().asyncExec(r); } } }
@Override public void dispose() { DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).removeDebugContextListener(this); DebugPlugin.getDefault().removeDebugEventListener(this); if (fRemoveTerminated != null) { fRemoveTerminated.dispose(); fRemoveTerminated = null; } if (fRemoveAllTerminated != null) { fRemoveAllTerminated.dispose(); fRemoveAllTerminated = null; } if (fTerminate != null) { fTerminate.dispose(); fTerminate = null; } if (fStdOut != null) { fStdOut.dispose(); fStdOut = null; } if (fStdErr != null) { fStdErr.dispose(); fStdErr = null; } fConsole = null; }
@Override public void init(IPageBookViewPage page, IConsole console) { fPage = page; fConsole = (ProcessConsole) console; fRemoveTerminated = new ConsoleRemoveLaunchAction(fConsole.getProcess().getLaunch()); fRemoveAllTerminated = new ConsoleRemoveAllTerminatedAction(); fTerminate = new ConsoleTerminateAction(page.getSite().getWorkbenchWindow(), fConsole); fStdOut = new ShowStandardOutAction(); fStdErr = new ShowStandardErrorAction(); fView = (IConsoleView) fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW); DebugPlugin.getDefault().addDebugEventListener(this); DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).addDebugContextListener(this); // contribute to toolbar IActionBars actionBars = fPage.getSite().getActionBars(); configureToolBar(actionBars.getToolBarManager()); // create handler and submissions for EOF fEOFHandler = new EOFHandler(); }