Java Code Examples for org.eclipse.ui.console.IConsoleManager#removeConsoles()

The following examples show how to use org.eclipse.ui.console.IConsoleManager#removeConsoles() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodewindConsoleFactory.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private static void onNewConsole(IOConsole console) {
	IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();

	// See if a console exists matching this one and remove it if it does,
	// so that we don't have multiple of the same console (they would be identical anyway)
	IConsole[] existingMCConsoles = consoleManager.getConsoles();
	for (IConsole existingConsole : existingMCConsoles) {
		if (existingConsole.getName().equals(console.getName())) {
			consoleManager.removeConsoles(new IConsole[] { existingConsole } );
			break;
		}
	}
		
	Logger.log(String.format("Creating new application console: %s of type %s", 				//$NON-NLS-1$
			console.getName(), console.getClass().getSimpleName()));

	consoleManager.addConsoles(new IConsole[] { console });
}
 
Example 2
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public synchronized void setEnabled(boolean enabled) {
	super.setEnabled(enabled);
	if (!enabled) {
		// Clean up the launch
		clearDebugger();
		
		// Clean up the consoles
		if (!activeConsoles.isEmpty()) {
			IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
			consoleManager.removeConsoles(activeConsoles.toArray(new IConsole[activeConsoles.size()]));
			activeConsoles.clear();
		}
	}
}
 
Example 3
Source File: HideAllLogsAction.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
  public void run() {
      if (app == null) {
      	// should not be possible
      	Logger.logError("HideAllLogsAction ran but no application was selected"); //$NON-NLS-1$
	return;
}
      
      if (app.getLogInfos() == null || app.getLogInfos().isEmpty()) {
      	Logger.logError("HideAllLogsAction ran but there are no logs for the selected application: " + app.name); //$NON-NLS-1$
      	return;
      }
      
      // Remove any existing consoles for this app
      Job job = new Job(NLS.bind(Messages.HideAllLogFilesJobLabel, app.name)) {
	@Override
	protected IStatus run(IProgressMonitor monitor) {
		try {
			for (ProjectLogInfo logInfo : app.getLogInfos()) {
				SocketConsole console = app.getConsole(logInfo);
				if (console != null) {
					IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
					consoleManager.removeConsoles(new IConsole[] { console });
					app.removeConsole(console);
				}
			}
			return Status.OK_STATUS;
		} catch (Exception e) {
			Logger.logError("An error occurred closing the log files for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
			return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.HideAllLogFilesError, app.name), e);
		}
	}
};
job.schedule();
  }
 
Example 4
Source File: TestDebugConfiguration.java    From corrosion with Eclipse Public License 2.0 5 votes vote down vote up
@After
@Before
public void stopLaunchesAndCloseConsoles() throws DebugException {
	for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
		launch.terminate();
	}
	IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
	consoleManager.removeConsoles(consoleManager.getConsoles());
	IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	for (IViewReference view : activePage.getViewReferences()) {
		if (IConsoleConstants.ID_CONSOLE_VIEW.equals(view.getId())) {
			activePage.hideView(view);
		}
	}
}
 
Example 5
Source File: FindBugsConsole.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void run() {
    IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
    if (console != null) {
        manager.removeConsoles(new IConsole[] { console });
        console = null;
    }
}
 
Example 6
Source File: TypeScriptConsoleHelper.java    From typescript.java with MIT License 5 votes vote down vote up
public static void closeConsole(IConsole console) {
	IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
	if (console != null) {
		manager.removeConsoles(new IConsole[] { console });
		// ConsolePlugin.getDefault().getConsoleManager()
		// .addConsoleListener(console.new MyLifecycle());
	}
}
 
Example 7
Source File: SVNOutputConsoleFactory.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static void closeConsole() {
	IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
	SVNOutputConsole console = SVNUIPlugin.getPlugin().getConsole();
	if (console != null) {
		manager.removeConsoles(new IConsole[] {console});
		ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(console.new MyLifecycle());
	}
}
 
Example 8
Source File: RuntimeConsoleUtil.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
public static void clearConsole() {
    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    IConsole[] existing = conMan.getConsoles();
    for (int i = 0; i < existing.length; i++) {
        if (KARAF_CONSOLE.equals(existing[i].getName())) {
            ((IOConsole) existing[i]).destroy();
            conMan.removeConsoles(new IConsole[] { existing[i] });
        }
    }
}
 
Example 9
Source File: Console.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public static void dispose() {
	if (instance == null)
		return;
	instance.close();
	IConsoleManager manager = ConsolePlugin.getDefault()
			.getConsoleManager();
	manager.removeConsoles(new IConsole[] { instance.console });
	instance.console.destroy();
	instance = null;
	System.setOut(System.out);
	System.setErr(System.err);
}
 
Example 10
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
private void removeConsole() {
  ConsolePlugin plugin = ConsolePlugin.getDefault();
  IConsoleManager manager = plugin.getConsoleManager();
  manager.removeConsoles(new IConsole[] {console});
  console.destroy();
}