@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> required) { if (IShowInSource.class.equals(required)) { return (T) this; } if (IShowInTargetList.class.equals(required)) { return (T) this; } //CONTEXTLAUNCHING if(ILaunchConfiguration.class.equals(required)) { ILaunch launch = getProcess().getLaunch(); if(launch != null) { return (T) launch.getLaunchConfiguration(); } return null; } return 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(); }
@Override public Object execute(ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException { IStreamsProxy proxy = getProcess().getStreamsProxy(); if (proxy instanceof IStreamsProxy2) { IStreamsProxy2 proxy2 = (IStreamsProxy2) proxy; try { proxy2.closeInputStream(); } catch (IOException e1) { } } return null; }
@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 debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { if (fView != null && getProcess().equals(DebugUITools.getCurrentProcess())) { fView.display(fConsole); } } } }
@Override public ShowInContext getShowInContext() { IProcess process = getProcess(); if (process == null) { return null; } IDebugTarget target = process.getAdapter(IDebugTarget.class); ISelection selection = null; if (target == null) { selection = new TreeSelection(new TreePath(new Object[]{ DebugPlugin.getDefault().getLaunchManager(), process.getLaunch(), process})); } else { selection = new TreeSelection(new TreePath(new Object[]{ DebugPlugin.getDefault().getLaunchManager(), target.getLaunch(), target})); } return new ShowInContext(null, selection); }