Java Code Examples for org.eclipse.ui.console.ConsolePlugin#getDefault()

The following examples show how to use org.eclipse.ui.console.ConsolePlugin#getDefault() . 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: RunSelectedSequenceDiagramHandler.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Searches for a console with the name "Sequence Diagram Console" and
 * returns it if it was found. If the console was not found creates a new
 * one and returns it.
 */
private MessageConsole findConsole() {
	final String seqDiagConsoleName = "Sequence Diagram Console";
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	Optional<IConsole> seqConsole = Stream.of(existing)
			.filter(console -> console.getName().equals(seqDiagConsoleName)).findFirst();

	if (seqConsole.isPresent()) {
		return (MessageConsole) seqConsole.get();
	} else {
		MessageConsole newSeqConsole = new MessageConsole(seqDiagConsoleName, null);
		conMan.addConsoles(new IConsole[] { newSeqConsole });
		return newSeqConsole;
	}
}
 
Example 2
Source File: ConsoleTail.java    From LogViewer with Eclipse Public License 2.0 6 votes vote down vote up
private IConsole findConsole() throws FileNotFoundException {
	ConsolePlugin conPlugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = conPlugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	int nameFoundIndex = -1;
	for (int i = 0; i < existing.length; i++) {
	    // check full name first
		if (getConsolePath(existing[i]).equals(getPath())) {
			return existing[i];
		}
		// check short name if not already found
        int flags = 0;
           flags = java.util.regex.Pattern.CASE_INSENSITIVE | java.util.regex.Pattern.UNICODE_CASE;
        regexp = Pattern.compile(getNamePattern(), flags);
           if ((nameFoundIndex == -1) && regexp.matcher(existing[i].getName()).matches()) {
               nameFoundIndex = i;
           }
	}
	if (nameFoundIndex != -1) {
	    return existing[nameFoundIndex];
	}
	throw new FileNotFoundException("no console found");
}
 
Example 3
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 4
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 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: 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 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: 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 9
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 10
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 11
Source File: RuntimeConsoleUtil.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
public static IOConsole findConsole() {
    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()))
            return (IOConsole) existing[i];
    }
    // no console found, so create a new one
    IOConsole myConsole = new IOConsole(KARAF_CONSOLE, null);
    conMan.addConsoles(new IConsole[] { myConsole });
    return myConsole;
}
 
Example 12
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 13
Source File: ApplicationPlugin.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void init(final BundleContext context) throws CoreException {
    if (getDialogSettings().get(BAR_DEFAULT_PATH) == null) {
        getDialogSettings().put(BAR_DEFAULT_PATH, System.getProperty("user.home"));
    }
    try {
        ValidationPlugin.getDefault().getBundle().start();
        if (ConsolePlugin.getDefault() == null) {
            new ConsolePlugin();
        }
    } catch (final BundleException e) {
        BonitaStudioLog.error(e);
    }
}
 
Example 14
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 15
Source File: Console.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
private static MessageConsole findMessageConsole(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 16
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 17
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 18
Source File: EclipseConsoleLogger.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected IConsoleManager getConsoleManager() {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager consoleManager = plugin.getConsoleManager();
	return consoleManager;
}
 
Example 19
Source File: SootPlugin.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
public void showConsole() {
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager conMan = plugin.getConsoleManager();
conMan.showConsoleView(getConsole());
  }
 
Example 20
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();
}