/** * Returns the process console manager. The manager will be created lazily on * the first access. * * @return ProcessConsoleManager */ public ProcessConsoleManager getProcessConsoleManager() { if (fProcessConsoleManager == null) { fProcessConsoleManager = new ProcessConsoleManager(); } return fProcessConsoleManager; }
/** * Returns the document for the process, or <code>null</code> * if none. */ public IDocument getConsoleDocument(IProcess process) { ProcessConsole console = (ProcessConsole) getConsole(process); return (console != null ? console.getDocument() : null); }
/** * @see ILaunchListener#launchAdded(ILaunch) */ @Override public void launchAdded(ILaunch launch) { launchChanged(launch); }
/** * @see ILaunchListener#launchChanged(ILaunch) */ @Override public void launchChanged(final ILaunch launch) { IProcess[] processes= launch.getProcesses(); for (IProcess process : processes) { if (process.getStreamsProxy() == null) { continue; } if (getConsoleDocument(process) == null) { // create a new console in a separated thread, see bug 355011. Job job = new ConsoleCreation(launch, process); job.schedule(); } } List<IProcess> removed = getRemovedProcesses(launch); if (removed != null) { for (IProcess p : removed) { removeProcess(p); } } }
@Override protected IStatus run(IProgressMonitor monitor) { if (monitor.isCanceled() || getConsoleDocument(process) != null) { return Status.CANCEL_STATUS; } IConsoleColorProvider colorProvider = getColorProvider(process.getAttribute(IProcess.ATTR_PROCESS_TYPE)); String encoding = launch.getAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING); ProcessConsole pc = new ProcessConsole(process, colorProvider, encoding); pc.setAttribute(IDebugUIConstants.ATTR_CONSOLE_PROCESS, process); // add new console to console manager. ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { pc }); return Status.OK_STATUS; }
/** * @see ILaunchListener#launchRemoved(ILaunch) */ @Override public void launchRemoved(ILaunch launch) { removeLaunch(launch); }
@Override public void connect(TextConsole console) { if (console instanceof ProcessConsole) { fConsole = (ProcessConsole)console; IConsoleLineTracker[] lineTrackers = DebugUIPlugin.getDefault().getProcessConsoleManager().getLineTrackers(fConsole.getProcess()); for (int i = 0; i < lineTrackers.length; i++) { lineTrackers[i].init(fConsole); addConsoleListener(lineTrackers[i]); } fConsole.addPropertyChangeListener(this); } }
/** * Returns the processes that have been removed from the given * launch, or <code>null</code> if none. * * @param launch launch that has changed * @return removed processes or <code>null</code> */ private List<IProcess> getRemovedProcesses(ILaunch launch) { List<IProcess> removed = null; if (fProcesses == null) { fProcesses = new HashMap<>(); } IProcess[] old = fProcesses.get(launch); IProcess[] curr = launch.getProcesses(); if (old != null) { for (int i = 0; i < old.length; i++) { IProcess process = old[i]; if (!contains(curr, process)) { if (removed == null) { removed = new ArrayList<>(); } removed.add(process); } } } // update cache with current processes fProcesses.put(launch, curr); return removed; }
/** * Called by the debug ui plug-in on startup. * The console document manager starts listening for * launches to be registered and initializes if any launches * already exist. */ public void startup() { ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager(); launchManager.addLaunchListener(this); //set up the docs for launches already registered ILaunch[] launches= launchManager.getLaunches(); for (int i = 0; i < launches.length; i++) { launchAdded(launches[i]); } }
/** * Called by the debug ui plug-in on shutdown. * The console document manager de-registers as a * launch listener and kills all existing console documents. */ public void shutdown() { Job.getJobManager().cancel(ProcessConsoleManager.class); ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager(); ILaunch[] launches = launchManager.getLaunches(); for (int i = 0; i < launches.length; i++) { ILaunch launch = launches[i]; removeLaunch(launch); } launchManager.removeLaunchListener(this); if (fProcesses != null) { fProcesses.clear(); } }
IConsoleLineTracker[] lineTrackers = DebugUIPlugin.getDefault().getProcessConsoleManager().getLineTrackers(process); if (lineTrackers.length > 0) { addPatternMatchListener(new ConsoleLineNotifier());
/** * Returns the console associated with the given process, or * <code>null</code> if none. * * @param process a process * @return console associated with the given process, or * <code>null</code> if none * @since 3.0 */ public static IConsole getConsole(IProcess process) { return DebugUIPlugin.getDefault().getProcessConsoleManager().getConsole(process); }
/** * Removes the console and document associated with the given process. * * @param iProcess process to clean up */ private void removeProcess(IProcess iProcess) { IConsole console = getConsole(iProcess); if (console != null) { IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); manager.removeConsoles(new IConsole[]{console}); } }