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

The following examples show how to use org.eclipse.ui.console.IConsoleManager#addConsoles() . 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: TLAPMConsoleFactory.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Finds the console with a given name.
 * 
 * @param name, name of the console
 * @return
 */
private static MessageConsole findConsole(String name)
{
    if (name == null)
    {
        throw new IllegalArgumentException("Console name must be not null");
    }
    IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();

    IConsole[] existing = consoleManager.getConsoles();
    // try to find existing
    for (int i = 0; i < existing.length; i++)
    {
        if (name.equals(existing[i].getName()))
        {
            return (MessageConsole) existing[i];
        }
    }

    // no console found, create a new one
    MessageConsole myConsole = new MessageConsole(name, null);
    consoleManager.addConsoles(new IConsole[] { myConsole });
    return myConsole;
}
 
Example 2
Source File: YangToPNG.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
private static MessageConsole findConsole(String name) {//Find and return console, otherwise make one

		if (ConsolePlugin.getDefault() == null)
			return null;
		ConsolePlugin plugin = ConsolePlugin.getDefault();
		IConsoleManager YangConsole = plugin.getConsoleManager();
		IConsole[] existing = YangConsole.getConsoles();
		for (int i = 0; i < existing.length; i++)
			if (name.equals(existing[i].getName())) {
				YangConsole.showConsoleView(existing[i]);
				return (MessageConsole) existing[i];
			}
		MessageConsole myConsole = new MessageConsole(name, null);
		YangConsole.addConsoles(new IConsole[] { myConsole });
		return myConsole;
	}
 
Example 3
Source File: YangToDsdl.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
private static MessageConsole findConsole(String name) {//Find and return console, otherwise make one

   if (ConsolePlugin.getDefault() == null)
    	return null;
   ConsolePlugin plugin = ConsolePlugin.getDefault();
   IConsoleManager YangConsole = plugin.getConsoleManager();
   IConsole[] existing = YangConsole.getConsoles();
   for (int i = 0; i < existing.length; i++)
      if (name.equals(existing[i].getName())) {
      	YangConsole.showConsoleView(existing[i]);
      	return (MessageConsole) existing[i];
      }
   // no console found, so create a new one
   MessageConsole myConsole = new MessageConsole(name, null);
   YangConsole.addConsoles(new IConsole[] { myConsole });
   return myConsole;
}
 
Example 4
Source File: YangToSkelxml.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
private static MessageConsole findConsole(String name) {//Find and return console, otherwise make one

   if (ConsolePlugin.getDefault() == null)
    	return null;
   ConsolePlugin plugin = ConsolePlugin.getDefault();
   IConsoleManager YangConsole = plugin.getConsoleManager();
   IConsole[] existing = YangConsole.getConsoles();
   for (int i = 0; i < existing.length; i++)
      if (name.equals(existing[i].getName())) {
      	YangConsole.showConsoleView(existing[i]);
      	return (MessageConsole) existing[i];
      }
   MessageConsole myConsole = new MessageConsole(name, null);
   YangConsole.addConsoles(new IConsole[] { myConsole });
   return myConsole;
}
 
Example 5
Source File: CppStyle.java    From CppStyle with MIT License 6 votes vote down vote up
public static CppStyleMessageConsole buildConsole() {
	CppStyleMessageConsole console = null;
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();

	for (int i = 0; i < existing.length; i++) {
		if (CppStyleConstants.CONSOLE_NAME.equals(existing[i].getName())) {
			console = (CppStyleMessageConsole) existing[i];
		}
	}

	if (console == null) {
		// no console found, so create a new one
		CppStyleConsolePatternMatchListener listener = new CppStyleConsolePatternMatchListener();
		console = new CppStyleMessageConsole(listener);
		conMan.addConsoles(new IConsole[] { console });
	}

	console.clear();
	return console;
}
 
Example 6
Source File: YangToJSTREE.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
private static MessageConsole findConsole(String name) {//Find and return console, otherwise make one

   if (ConsolePlugin.getDefault() == null)
    	return null;
   ConsolePlugin plugin = ConsolePlugin.getDefault();
   IConsoleManager YangConsole = plugin.getConsoleManager();
   IConsole[] existing = YangConsole.getConsoles();
   for (int i = 0; i < existing.length; i++)
      if (name.equals(existing[i].getName())) {
      	YangConsole.showConsoleView(existing[i]);
      	return (MessageConsole) existing[i];
      }
   // no console found, so create a new one
   MessageConsole myConsole = new MessageConsole(name, null);
   YangConsole.addConsoles(new IConsole[] { myConsole });
   return myConsole;
}
 
Example 7
Source File: YangToTree.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
private static MessageConsole findConsole(String name) {//Find and return console, otherwise make one

          			if (ConsolePlugin.getDefault() == null)
          				return null;
          			ConsolePlugin plugin = ConsolePlugin.getDefault();
          			IConsoleManager YangConsole = plugin.getConsoleManager();
          			IConsole[] existing = YangConsole.getConsoles();
          			for (int i = 0; i < existing.length; i++)
          				if (name.equals(existing[i].getName())) {
          					YangConsole.showConsoleView(existing[i]);
          					return (MessageConsole) existing[i];
          				}
          			MessageConsole myConsole = new MessageConsole(name, null);
          			YangConsole.addConsoles(new IConsole[] { myConsole });
          			return myConsole;
          		}
 
Example 8
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 9
Source File: ConsoleFactory.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Fins the console with a given name
 * @param name, name of the console
 * @return
 */
private static IOConsole findConsole(String name)
{
    if (name == null)
    {
        throw new IllegalArgumentException("Console name must be not null");
    }
    IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();

    IConsole[] existing = consoleManager.getConsoles();
    // try to find existing
    for (int i = 0; i < existing.length; i++)
    {
        if (name.equals(existing[i].getName()))
        {
            return (IOConsole) existing[i];
        }
    }

    // no console found, create a new one
    IOConsole myConsole = new IOConsole(name, null);
    consoleManager.addConsoles(new IConsole[] { myConsole });
    return myConsole;
}
 
Example 10
Source File: ConsoleFactory.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void openConsole() {
    console = getConsole();
    if (console != null) {
        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
        IConsole[] existing = manager.getConsoles();
        boolean exists = false;
        for (int i = 0; i < existing.length; i++) {
            if(console == existing[i])
                exists = true;
        }
        if(!exists)
            manager.addConsoles(new IConsole[] {console});
        manager.showConsoleView(console);
    }
}
 
Example 11
Source File: FindBugsConsole.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static FindBugsConsole showConsole() {
    IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
    boolean exists = false;
    if (console != null) {
        IConsole[] existing = manager.getConsoles();
        for (int i = 0; i < existing.length; i++) {
            if (console == existing[i]) {
                exists = true;
            }
        }
    } else {
        console = new FindBugsConsole("SpotBugs",
                FindbugsPlugin.getDefault().getImageDescriptor(AbstractFindbugsView.PERSPECTIVE_IMG), true);
    }
    if (!exists) {
        manager.addConsoles(new IConsole[] { console });
    }
    ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
    theme.addPropertyChangeListener(console);
    console.setConsoleFont();
    manager.showConsoleView(console);
    return console;
}
 
Example 12
Source File: YangToXSD.java    From yang-design-studio with Eclipse Public License 1.0 6 votes vote down vote up
private static MessageConsole findConsole(String name) {//Find and return console, otherwise make one

   if (ConsolePlugin.getDefault() == null)
    	return null;
   ConsolePlugin plugin = ConsolePlugin.getDefault();
   IConsoleManager YangConsole = plugin.getConsoleManager();
   IConsole[] existing = YangConsole.getConsoles();
   for (int i = 0; i < existing.length; i++)
      if (name.equals(existing[i].getName())) {
      	YangConsole.showConsoleView(existing[i]);
      	return (MessageConsole) existing[i];
      }
   MessageConsole myConsole = new MessageConsole(name, null);
   YangConsole.addConsoles(new IConsole[] { myConsole });
   return myConsole;
}
 
Example 13
Source File: SootPlugin.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private MessageConsole findConsole(String name) {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	for (int i = 0; i < existing.length; i++)
		if (name.equals(existing[i].getName()))
			return (MessageConsole) existing[i];
	// no console found, so create a new one
	MessageConsole myConsole = new MessageConsole(name, null);
	conMan.addConsoles(new IConsole[] { myConsole });
	return myConsole;
}
 
Example 14
Source File: CommandConsoleFactoryImpl.java    From eclipse with Apache License 2.0 5 votes vote down vote up
private static MessageConsole findConsole(String name) {
  ConsolePlugin plugin = ConsolePlugin.getDefault();
  IConsoleManager conMan = plugin.getConsoleManager();
  IConsole[] existing = conMan.getConsoles();
  for (int i = 0; i < existing.length; i++) {
    if (name.equals(existing[i].getName())) {
      return (MessageConsole) existing[i];
    }
  }
  // no console found, so create a new one
  MessageConsole myConsole = new MessageConsole(name, null);
  conMan.addConsoles(new IConsole[] {myConsole});
  return myConsole;
}
 
Example 15
Source File: FormulaConsoleAction.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private IOConsole findOrCreateConsole(String name) {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	for (int i = 0; i < existing.length; i++)
		if (name.equals(existing[i].getName()))
			return (IOConsole) existing[i];
	IOConsole console = new IOConsole(name, null);
	conMan.addConsoles(new IConsole[] { console });
	return console;
}
 
Example 16
Source File: SymbolController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private ConsoleContext createOrGetConsole ()
{
    if ( this.parentController != null && this.parentController.getConsole () != null )
    {
        return this.parentController.getConsole ();
    }

    final IConsoleManager manager = ConsolePlugin.getDefault ().getConsoleManager ();
    final MessageConsole messageConsole = new MessageConsole ( String.format ( "Symbol Debug Console: %s", this.symbolInfoName ), null, null, true );
    manager.addConsoles ( new IConsole[] { messageConsole } );
    this.createdConsole = messageConsole;
    return new ConsoleContext ( messageConsole );
}
 
Example 17
Source File: Console.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private MessageConsole findOrCreate(String name) {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	for (int i = 0; i < existing.length; i++)
		if (name.equals(existing[i].getName()))
			return (MessageConsole) existing[i];
	MessageConsole console = new MessageConsole(name, null);
	// set the buffer size of the console
	console.setWaterMarks(1000, 25000);
	conMan.addConsoles(new IConsole[] { console });
	return console;
}
 
Example 18
Source File: SVNOutputConsole.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void bringConsoleToFront() {
    IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
    if(! visible) {
        manager.addConsoles(new IConsole[] {this});
    }
    manager.showConsoleView(this);
}
 
Example 19
Source File: DockerClientMessageConsole.java    From doclipser with Eclipse Public License 1.0 4 votes vote down vote up
public DockerClientMessageConsole(String name) {
            ConsolePlugin plugin = ConsolePlugin.getDefault();
            IConsoleManager conMan = plugin.getConsoleManager();
            IConsole[] existing = conMan.getConsoles();
            for (int i = 0; i < existing.length; i++) {
                if (name.equals(existing[i].getName())) {
                    dockerMessageConsole = (MessageConsole) existing[i];
                    dockerConsoleOut = dockerMessageConsole.newMessageStream();
                    return;
                }
            }
            
            // no console found, so create a new one
            Bundle bundle = Platform.getBundle("com.zenika.doclipser.api");
            ImageDescriptor imageDcr = ImageDescriptor.createFromURL(
                  FileLocator.find(bundle,
                                   new Path("icons/docker-solo.gif"),
                                            null));
            MessageConsole dockerConsole = new MessageConsole(name, imageDcr);
            conMan.addConsoles(new IConsole[] { dockerConsole });
            
            dockerMessageConsole = dockerConsole;
            dockerConsoleOut = dockerMessageConsole.newMessageStream();

//          Currently does not work: win is always null 
//          (I guess because we are not in the main UI Thread)
//          
//          // get current active page
//          IWorkbench wb = PlatformUI.getWorkbench();
//          IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
//          
//          // on new versions it may need to be changed to:
//          IWorkbenchPage page = win.getActivePage();
//
//          // Reveal the console view
//          String id = IConsoleConstants.ID_CONSOLE_VIEW;
//          IConsoleView view;
//          try {
//              view = (IConsoleView) page.showView(id);
//              view.display(dockerConsole);
//          } catch (PartInitException e) {
//              // TODO Auto-generated catch block
//              e.printStackTrace();
//          }
        }
 
Example 20
Source File: BuilderStateLogger.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void openConsole() {
	final IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
	manager.addConsoles(new IConsole[] { new BuilderStateConsole() });
}