Java Code Examples for org.eclipse.ui.console.ConsolePlugin

The following are top voted examples for showing how to use org.eclipse.ui.console.ConsolePlugin. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: plugindependencies   File: PluginDependenciesConsole.java   Source Code and License 7 votes vote down vote up
public static PluginDependenciesConsole 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 PluginDependenciesConsole("Plug-in Dependencies", null, 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 2
Project: n4js   File: ConsoleOutputStreamProvider.java   Source Code and License 6 votes vote down vote up
@Override
public OutputStream getOutputStream(final OutputStreamType type, OutputRedirection redirect) {
	if (!PlatformUI.isWorkbenchRunning()) {
		return DEFAULT.getOutputStream(type, redirect);
	}
	final MessageConsole console = consoleSupplier.get();
	boolean silent = redirect == OutputRedirection.SUPPRESS;
	if (!silent) {
		console.activate();
	}
	ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
	final MessageConsoleStream stream = console.newMessageStream();
	getDisplay().asyncExec(() -> {
		stream.setColor(toColor(type));
		showConsoleView(silent);
	});
	return stream;
}
 
Example 3
Project: n4js   File: BuilderStateLogger.java   Source Code and License 6 votes vote down vote up
@Override
public void log(final Object o) {

	final IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
	final BuilderStateConsole console = from(asList(manager.getConsoles())).filter(BuilderStateConsole.class)
			.first()
			.orNull();

	if (console != null) {
		if (o instanceof Throwable) {
			console.println(getStackTraceAsString((Throwable) o));
		} else {
			console.println(String.valueOf(o));
		}
		manager.showConsoleView(console);
	}

}
 
Example 4
Project: neoscada   File: StartItemTrace.java   Source Code and License 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final List<IConsole> consoles = new ArrayList<IConsole> ();

    for ( final Item item : SelectionHelper.iterable ( getSelection (), Item.class ) )
    {
        final IConsole console = createConsole ( item ).getConsole ();
        if ( console != null )
        {
            consoles.add ( console );
        }
    }

    final IConsoleManager cm = ConsolePlugin.getDefault ().getConsoleManager ();
    if ( !consoles.isEmpty () )
    {
        cm.addConsoles ( consoles.toArray ( new IConsole[consoles.size ()] ) );
        cm.showConsoleView ( consoles.get ( 0 ) );
    }

    return null;
}
 
Example 5
Project: gemoc-studio   File: EclipseConsoleIOFactory.java   Source Code and License 6 votes vote down vote up
/**
  * retrieve or create a ConsoleIO with the given UId
  * the name is used only if the console is created
  * @param name
  * @return
  */
 public EclipseConsoleIO getConsoleIO(String uid, String name){    	
 	
 	EclipseConsoleIO consoleIo=consoleIOMap.get(uid);    	
 	if(consoleIo == null){
 		// create the eclipse console
 		IOConsole ioConsole = new IOConsole(name, null);
  	ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ ioConsole });
// ConsolePlugin.getDefault().getConsoleManager().showConsoleView(ioConsole);
// ioConsole.activate(); // console will be displayed on first use
 		// create the IO with this console
consoleIo = new EclipseConsoleIO(ioConsole);
  	consoleIOMap.put(uid, consoleIo);
 	}
 	return consoleIo;
 }
 
Example 6
Project: gemoc-studio   File: EclipseConsoleIO.java   Source Code and License 6 votes vote down vote up
public void println(final ConsoleMessage message) {
	// use normal print for the message itself
	print(message);
	// add the carriage return
	Runnable r = new Runnable() {
		public void run() {
			changeStyle(message.getColor(), message.getStyle());
			if(!((IOConsoleOutputStream)getOutputStream()).isClosed()){
				try {
					((IOConsoleOutputStream)getOutputStream()).write("\n");
				} catch (IOException e) {
				}
			}
		}
	};
	ConsolePlugin.getStandardDisplay().asyncExec(r);
}
 
Example 7
Project: Hydrograph   File: HydrographConsole.java   Source Code and License 6 votes vote down vote up
@Override
	public void partOpened(IWorkbenchPart part) {
		super.partOpened(part);

		if (getComponentCanvas() != null) {
			ConsolePlugin plugin = ConsolePlugin.getDefault();
			IConsoleManager conMan = plugin.getConsoleManager();

			String consoleName = getComponentCanvas().getActiveProject() + "." + getComponentCanvas().getJobName();

			IConsole consoleToShow = getConsole(consoleName, conMan);

			if (consoleToShow != null) {
//				Fix for : Console window is getting displayed if user maximize canvas window and then try to create new job (Ctrl+J)
//				conMan.showConsoleView(consoleToShow);
			} else {
				addDummyConsole();
			}
		}
	}
 
Example 8
Project: andmore2   File: AndroidConsole.java   Source Code and License 6 votes vote down vote up
public AndroidConsole() {
	console = new MessageConsole("Android", null);
	ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
	out = console.newMessageStream();
	err = console.newMessageStream();

	// set the colors
	final Display display = Display.getDefault();
	display.syncExec(new Runnable() {
		@Override
		public void run() {
			out.setColor(display.getSystemColor(SWT.COLOR_BLACK));
			err.setColor(display.getSystemColor(SWT.COLOR_RED));
		}
	});
}
 
Example 9
Project: turnus   File: EclipseUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Get the console with the given name. If the console does not exist, then
 * a new one is created.
 * 
 * @param name
 * @return
 */
public static MessageConsole getConsole(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 console = new MessageConsole(name, null);
	conMan.addConsoles(new IConsole[] { console });

	// create a new logger handler
	Logger.addHandler(new EclipseConsoleHandler(console));

	return console;
}
 
Example 10
Project: CodeCheckerEclipsePlugin   File: ConsoleFactory.java   Source Code and License 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
Project: tlaplus   File: ConsoleFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Fins 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 12
Project: tlaplus   File: TLAPMConsoleFactory.java   Source Code and 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 13
Project: typescript.java   File: TypeScriptConsoleHelper.java   Source Code and License 6 votes vote down vote up
public static void showConsole(IConsole console) {
	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 14
Project: yang-design-studio   File: YangToJSTREE.java   Source Code and License 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 15
Project: caml2tosca   File: C2TRunHandler.java   Source Code and License 6 votes vote down vote up
private MessageConsole findConsole(String name) {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	
	// search existing consoles
	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});
	conMan.showConsoleView(myConsole);
	return myConsole;
}
 
Example 16
Project: yang-design-studio   File: YangToUML.java   Source Code and License 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 17
Project: LogViewer   File: LogFileTypeDialog.java   Source Code and License 6 votes vote down vote up
protected Control createDialogArea(Composite parent) {
   	String fileTypeName = "File";
	// create composite
	Composite composite = (Composite) super.createDialogArea(parent);
	// create combo
	typeCombo = new Combo(composite,SWT.LEFT);
	GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
	typeCombo.setLayoutData(data);
	// fill
   	IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
   	typeCombo.add(fileTypeName);
   	value = fileTypeName;    	
   	for (int i=0;i<consoles.length;i++) {
   		typeCombo.add("Console: " + consoles[i].getName());
   	}
	applyDialogFont(composite);
	return composite;
}
 
Example 18
Project: VariantSync   File: ConsoleFactory.java   Source Code and License 6 votes vote down vote up
private void showConsole() {
	ChangeOutPutConsole console = VariantSyncPlugin.getDefault().getConsole();
	if (console != null) {
		IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
		IConsole[] existing = manager.getConsoles();
		boolean exist = false;
		for (int i = 0; i < existing.length; i++) {
			if (console == existing[i]) {
				exist = true;
			}
		}
		if (!exist) {
			manager.addConsoles(new IConsole[] { console });
		}
		manager.showConsoleView(console);
	}

}
 
Example 19
Project: yang-design-studio   File: YangToXslt.java   Source Code and License 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 20
Project: yang-design-studio   File: YangToXSD.java   Source Code and License 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 21
Project: yang-design-studio   File: YangToYin.java   Source Code and License 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 22
Project: SecurityTesting   File: ZAPConfigureCSRFSettingsDialog.java   Source Code and License 6 votes vote down vote up
/**
 * When a new anti-CSRF token has been added or removed from the list or
 * when the view page is first being loaded, display the list.
 */
private void updateCsrfTokenList() {
	csrfTokens.removeAll();

	try {
		ApiResponseElement response = (ApiResponseElement) ZAPHelper.getInstance().getZAPClient().acsrf
				.optionTokensNames();
		// The ZAP API returns the CSRF tokens as a string with the format
		// "[token1, token2, token3, ... tokenN]"
		// so the extra characters need to be parsed out.
		String[] csrfTokenValues = response.getValue().replace("[", "").replace("]", "").replace(" ", "")
				.split(",");
		for (String csrfTokenEntry : csrfTokenValues) {
			csrfTokens.add(csrfTokenEntry);
		}

	} catch (ClientApiException e) {
		ConsolePlugin.log(e);
	}
}
 
Example 23
Project: SecurityTesting   File: CancelZAPScanJob.java   Source Code and License 6 votes vote down vote up
/**
 * Execution of the call to ZAP to stop the current scan.
 */
@Override
protected IStatus run(IProgressMonitor monitor) {
	try {
		ClientApi zapAPI = ZAPHelper.getInstance().getZAPClient();

		/*
		 * TODO [On Hold] There is a defect in ZAP 2.4.1 where calling
		 * stopAllScans on the spider process locks up ZAP if there is an
		 * active spider. Disable this feature until this is resolved.
		 */
		// zapAPI.spider.stopAllScans(ZAPHelper.getInstance().getZapApiKey());

		zapAPI.ascan.stopAllScans(ZAPHelper.getInstance().getZapApiKey());
		Thread.sleep(5000); // give the scans time to stop
	} catch (ClientApiException | InterruptedException e) {
		ConsolePlugin.log(e);
	}

	return Status.OK_STATUS;
}
 
Example 24
Project: SecurityTesting   File: StopZAPJob.java   Source Code and License 6 votes vote down vote up
/**
 * Execution of the call to ZAP to stop the running server.
 */
@Override
protected IStatus run(IProgressMonitor monitor) {
	if (ZAPHelper.getInstance().isZapRunning()) {
		try {
			ZAPHelper.getInstance().getZAPClient().core.shutdown(ZAPHelper.getInstance().getZapApiKey());
			while (ZAPHelper.getInstance().isZapRunning()) {
				Thread.sleep(1000); // give server time to stop
			}
		} catch (Exception e) {
			ConsolePlugin.log(e);
		}
	} else {
		CreatePopupMessageJob job = new CreatePopupMessageJob(MessageDialog.ERROR,
				"The ZAP Server is not running.");
		job.setPriority(Job.INTERACTIVE);
		job.schedule();
	}

	return Status.OK_STATUS;
}
 
Example 25
Project: SecurityTesting   File: ZAPSetZAPLevelsJob.java   Source Code and License 6 votes vote down vote up
/**
 * Excution of the update for the ZAP scan policies based on the user input
 * from the ZAP view.
 */
@Override
protected IStatus run(IProgressMonitor monitor) {

	try {
		ClientApi zapAPI = ZAPHelper.getInstance().getZAPClient();
		for (ZAPPolicyInfo policyItem : zapPolicyList) {
			zapAPI.ascan.setPolicyAttackStrength(ZAPHelper.getInstance().getZapApiKey(), policyItem.getId(),
					policyItem.getAttackStrength(), "");
			zapAPI.ascan.setPolicyAlertThreshold(ZAPHelper.getInstance().getZapApiKey(), policyItem.getId(),
					policyItem.getAlertThreshold(), "");
		}

	} catch (ClientApiException e) {
		ConsolePlugin.log(e);
	}

	return Status.OK_STATUS;
}
 
Example 26
Project: SecurityTesting   File: StartZAPJob.java   Source Code and License 6 votes vote down vote up
/**
 * Create a reader for grabbing all process output data from the ZAP
 * executable and log it to the ZAP Console view.
 * 
 * @param stream
 *            The input stream of the process log.
 */
private void pipeToConsole(final InputStream stream) {
	new Thread(new Runnable() {

		@Override
		public void run() {
			BufferedInputStream bis = new BufferedInputStream(stream);
			InputStreamReader inread = new InputStreamReader(bis);
			BufferedReader bufferedReader = new BufferedReader(inread);
			String line;
			try {
				while ((line = bufferedReader.readLine()) != null) {
					ZAPHelper.getInstance().logConsoleMessage(line);
				}
			} catch (IOException e) {
				ConsolePlugin.log(e);
			}
		}
	}).start();
}
 
Example 27
Project: yang-design-studio   File: YangToDsdl.java   Source Code and License 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 28
Project: eclox   File: Console.java   Source Code and License 6 votes vote down vote up
/**
 * Shows a console for the given job.
 *
 * @param	job	a build that needs a console to be shown
 */
static public void show(BuildJob job) {
    // Retrieves the active workbench window and console manager.
    IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
    Console console = null;

    if (consoles.containsKey(job)) {
        console = (Console) consoles.get(job);
    } else {
        console = new Console(job);
        consoleManager.addConsoles(new IConsole[] { console });
    }

    // anb0s: refresh the name
    console.setName(job.getName());

    // Shows the console view.
    console.activate();
}
 
Example 29
Project: gwt-eclipse-plugin   File: MessageConsoleUtilities.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a {@link CustomMessageConsole} with the given
 * <code>consoleName</code>. If no console by that name exists then one is
 * created. The returned console is cleared; callers of this method can decide
 * when to activate it.
 *
 * @param consoleName name of the console
 * @param imageDescriptor image descriptor to use
 * @return {@link CustomMessageConsole} with the given
 *         <code>consoleName</code>
 */
public static CustomMessageConsole getMessageConsole(String consoleName,
    ImageDescriptor imageDescriptor) {
  CustomMessageConsole messageConsole = null;
  IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
  for (IConsole console : consoleManager.getConsoles()) {
    if (console.getName().equals(consoleName)
        && console instanceof CustomMessageConsole) {
      messageConsole = (CustomMessageConsole) console;
      break;
    }
  }

  if (messageConsole == null) {
    messageConsole = new CustomMessageConsole(consoleName, imageDescriptor);
    consoleManager.addConsoles(new IConsole[] {messageConsole});
  } else {
    messageConsole.clearConsole();
  }

  return messageConsole;
}
 
Example 30
Project: gwt-eclipse-plugin   File: MessageConsoleUtilities.java   Source Code and License 6 votes vote down vote up
public static CustomMessageConsole getMessageConsoleKeepLog(String consoleName,
    ImageDescriptor imageDescriptor) {
  CustomMessageConsole messageConsole = null;
  IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
  for (IConsole console : consoleManager.getConsoles()) {
    if (console.getName().equals(consoleName)
        && console instanceof CustomMessageConsole) {
      messageConsole = (CustomMessageConsole) console;
      break;
    }
  }

  if (messageConsole == null) {
    messageConsole = new CustomMessageConsole(consoleName, imageDescriptor);
    consoleManager.addConsoles(new IConsole[] {messageConsole});
  } else {
    //messageConsole.clearConsole();
  }

  return messageConsole;
}
 
Example 31
Project: jdepend4eclipse   File: JDependConsole.java   Source Code and License 6 votes vote down vote up
public static JDependConsole 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 JDependConsole("JDepend", null, true);
    }
    if (!exists) {
        manager.addConsoles(new IConsole[] { console });
    }
    manager.showConsoleView(console);
    return console;
}
 
Example 32
Project: HMM   File: AbstractConsole.java   Source Code and License 6 votes vote down vote up
protected void createConsole() {
  	Display.getDefault().syncExec(new Runnable() {
	public void run() {
    	IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
    	console = new MessageConsole(consoleName, null);
    	manager.addConsoles(new IConsole[] { console });
        try {
        	Font font = new Font(Display.getCurrent(), "simsun", 9, SWT.NORMAL);
        	console.setFont(font);
        } catch (SWTError error) {
			error.printStackTrace();
		}
        mcs = console.newMessageStream();
        black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
        red = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
        mcs.setColor(black);
		manager.showConsoleView(console);
	}
});
  }
 
Example 33
Project: yang-design-studio   File: YangToPNG.java   Source Code and License 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 34
Project: yang-design-studio   File: YangToSkelxml.java   Source Code and License 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 35
Project: n4js   File: ConsoleDisplayMgr.java   Source Code and License 5 votes vote down vote up
private static MessageConsole findMessageConsole(String title) {
	IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
	for (IConsole iConsole : consoles) {
		if (iConsole.getName().equals(title)) {
			return (MessageConsole) iConsole;
		}
	}
	return null;
}
 
Example 36
Project: EclipseMinifyBuilder   File: MinifyBuilder.java   Source Code and License 5 votes vote down vote up
public MessageConsole minifierConsole() {
	IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	for (int i = 0; i < existing.length; i++)
		if ("Minifier".equals(existing[i].getName()))
			return (MessageConsole) existing[i];
	//no console found, so create a new one
	MessageConsole myConsole = new MessageConsole("Minifier", null);
	conMan.addConsoles(new IConsole[] { myConsole });
	return myConsole;
}
 
Example 37
Project: neoscada   File: DataItemConsole.java   Source Code and License 5 votes vote down vote up
protected void dispose ()
{
    stop ();

    if ( this.processor != null )
    {
        this.processor.dispose ();
        this.processor = null;
    }

    if ( this.connectionPrintStream != null )
    {
        this.connectionPrintStream.close ();
        this.connectionStream = null;
        this.connectionPrintStream = null;
    }
    if ( this.dataPrintStream != null )
    {
        this.dataPrintStream.close ();
        this.dataStream = null;
        this.dataPrintStream = null;
    }

    if ( this.running )
    {
        this.running = false;
        ConsolePlugin.getDefault ().getConsoleManager ().removeConsoleListener ( this.consoleListener );
    }
}
 
Example 38
Project: neoscada   File: SymbolController.java   Source Code and License 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 39
Project: neoscada   File: OscarValidatorHandler.java   Source Code and License 5 votes vote down vote up
@Override
protected void runFile ( final IFile file, final IProgressMonitor monitor ) throws Exception
{

    final MessageConsole mc = new MessageConsole ( String.format ( "OSCAR Validation: %s", file ), "org.eclipse.scada.configuration.oscar.validation", null, true );

    ConsolePlugin.getDefault ().getConsoleManager ().addConsoles ( new IConsole[] { mc } );
    mc.activate ();

    final File dataFile = file.getLocation ().toFile ();

    Map<String, Map<String, Map<String, String>>> data;

    if ( OscarLoader.isOscar ( dataFile ) )
    {
        data = new OscarLoader ( dataFile ).getData ();
    }
    else
    {
        try (FileInputStream stream = new FileInputStream ( dataFile ))
        {
            data = OscarLoader.loadJsonData ( stream );
        }
    }

    final PrintStream consoleStream = new PrintStream ( mc.newOutputStream () );
    try
    {
        new LoopValidator ( data, consoleStream ).validate ();
    }
    finally
    {
        consoleStream.close ();
    }
}
 
Example 40
Project: convertigo-eclipse   File: ConvertigoPlugin.java   Source Code and License 5 votes vote down vote up
private void createConsoles() {
	ConsolePlugin consolePlugin = ConsolePlugin.getDefault();
	IConsoleManager consoleManager = consolePlugin.getConsoleManager();
	
	stdoutConsole = new MessageConsole("Stdout", ImageDescriptor.createFromFile(getClass(), "/consoles/stdout.gif"));
	stdoutConsole.setTabWidth(TAB_WIDTH);
	stdoutConsoleStream = stdoutConsole.newMessageStream();
	stderrConsoleStream = stdoutConsole.newMessageStream();
	stderrConsoleStream.setColor(stderrConsoleStreamColor);
	
	engineConsole = new MessageConsole("Engine", ImageDescriptor.createFromFile(getClass(), "/consoles/engine.gif"));
	engineConsole.setTabWidth(TAB_WIDTH);
	engineConsoleStream = engineConsole.newMessageStream();

	consoleManager.addConsoles(new IConsole[] {
		engineConsole,
		stdoutConsole
	});
	
	consolePipes = new ConsolePipes();
	
	debugConsoleStream = new MessageConsoleStream(engineConsole) {

		@Override
		public void write(String str) throws IOException {
			if (str.endsWith("\n")) {
				str = str.substring(0, str.length() - 1);
			}
			Engine.logStudio.info("[debug] " + str);
		}
		
	};
}
 
Example 41
Project: pgcodekeeper   File: ConsoleFactory.java   Source Code and License 5 votes vote down vote up
private static CodekeeperConsole findConsole() {
   CodekeeperConsole myConsole = null;
   IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager();
   for (IConsole c : conMan.getConsoles()) {
       if (c instanceof CodekeeperConsole) {
           myConsole = (CodekeeperConsole) c;
       }
   }
   if (myConsole == null) {
       myConsole = new CodekeeperConsole();
   }
   conMan.addConsoles(new IConsole[] { myConsole });
   return myConsole;
}
 
Example 42
Project: Hydrograph   File: ConsoleLogger.java   Source Code and License 5 votes vote down vote up
/**
 * 
 *  get default console manager
 * 
 * @return ConsoleManager
 */
private IConsoleManager getConsoleManager() {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	logger.debug("Retrieved Console plugin object");
	IConsoleManager conMan = plugin.getConsoleManager();
	logger.debug("Retrieved Console manager");
	return conMan;
}
 
Example 43
Project: Hydrograph   File: HydrographConsole.java   Source Code and License 5 votes vote down vote up
private void addDummyConsole() {
		ConsolePlugin plugin = ConsolePlugin.getDefault();
		IConsoleManager conMan = plugin.getConsoleManager();

		IConsole consoleToShow = getConsole(DEFAULT_CONSOLE, conMan);

		if (consoleToShow == null) {
			consoleToShow = createNewMessageConsole(DEFAULT_CONSOLE, conMan);
		}
//		Fix for : Console window is getting displayed if user maximize canvas window and then try to create new job (Ctrl+J)
//		conMan.showConsoleView(consoleToShow);
	}
 
Example 44
Project: Hydrograph   File: ELTGraphicalEditor.java   Source Code and License 5 votes vote down vote up
private void addDummyConsole(){
		ConsolePlugin plugin = ConsolePlugin.getDefault();
		IConsoleManager consoleManager = plugin.getConsoleManager();

		IConsole consoleToShow = getConsole(DEFAULT_CONSOLE, consoleManager);	

		if(consoleToShow == null){
			consoleToShow = createNewMessageConsole(DEFAULT_CONSOLE,consoleManager);
		}
//		Fix for : Console window is getting displayed if user maximize canvas window and then try to create new job (Ctrl+J) 
//		consoleManager.showConsoleView(consoleToShow);
	}
 
Example 45
Project: Tarski   File: LaunchModel.java   Source Code and License 5 votes vote down vote up
private MessageConsole findConsole(final String name) {
  final ConsolePlugin plugin = ConsolePlugin.getDefault();
  final IConsoleManager conMan = plugin.getConsoleManager();
  final 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
  final MessageConsole myConsole = new MessageConsole(name, null);
  conMan.addConsoles(new IConsole[] {myConsole});
  return myConsole;
}
 
Example 46
Project: Tarski   File: RunModel.java   Source Code and License 5 votes vote down vote up
private MessageConsole findConsole(final String name) {
  final ConsolePlugin plugin = ConsolePlugin.getDefault();
  final IConsoleManager conMan = plugin.getConsoleManager();
  final 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
  final MessageConsole myConsole = new MessageConsole(name, null);
  conMan.addConsoles(new IConsole[] {myConsole});
  return myConsole;
}
 
Example 47
Project: jason-eclipse-plugin   File: RunJasonFileEditor.java   Source Code and License 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 48
Project: jason-eclipse-plugin   File: RunJasonApplication.java   Source Code and License 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 49
Project: jason-eclipse-plugin   File: RunJasonFile.java   Source Code and License 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 50
Project: egradle   File: EGradleSystemConsoleFactory.java   Source Code and License 5 votes vote down vote up
private EGradleSystemConsole 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 (EGradleSystemConsole) existing[i];
		}

	}
	// no console found, so create a new one
	EGradleSystemConsole myConsole = createConsole(name, conMan);
	return myConsole;
}
 
Example 51
Project: eclipse   File: CommandConsoleFactoryImpl.java   Source Code and License 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 52
Project: subclipse   File: SVNOutputConsoleFactory.java   Source Code and License 5 votes vote down vote up
public static void showConsole() {
	SVNOutputConsole console = SVNUIPlugin.getPlugin().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 53
Project: subclipse   File: SVNOutputConsoleFactory.java   Source Code and License 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 54
Project: subclipse   File: SVNOutputConsole.java   Source Code and License 5 votes vote down vote up
public void consolesRemoved(IConsole[] consoles) {
    for (int i = 0; i < consoles.length; i++) {
        IConsole console = consoles[i];
        if (console == SVNOutputConsole.this) {
            ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this);
            dispose();
        }
    }
}
 
Example 55
Project: subclipse   File: SVNOutputConsole.java   Source Code and License 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 56
Project: google-cloud-eclipse   File: DeployCommandHandler.java   Source Code and License 5 votes vote down vote up
private void launchDeployJob(IProject project, Credential credential)
    throws IOException, CoreException {
  AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.APP_ENGINE_DEPLOY,
      analyticsDeployEventMetadataKey);

  IPath workDirectory = createWorkDirectory();
  DeployPreferences deployPreferences = getDeployPreferences(project);

  DeployConsole messageConsole =
      MessageConsoleUtilities.createConsole(getConsoleName(deployPreferences.getProjectId()),
                                            new DeployConsole.Factory());
  IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
  consoleManager.showConsoleView(messageConsole);
  ConsoleColorProvider colorProvider = new ConsoleColorProvider();
  MessageConsoleStream outputStream = messageConsole.newMessageStream();
  MessageConsoleStream errorStream = messageConsole.newMessageStream();
  outputStream.setActivateOnWrite(true);
  errorStream.setActivateOnWrite(true);
  outputStream.setColor(colorProvider.getColor(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM));
  errorStream.setColor(colorProvider.getColor(IDebugUIConstants.ID_STANDARD_ERROR_STREAM));

  StagingDelegate stagingDelegate = getStagingDelegate(project);

  DeployJob deploy = new DeployJob(deployPreferences, credential, workDirectory,
      outputStream, errorStream, stagingDelegate);
  messageConsole.setJob(deploy);
  deploy.addJobChangeListener(new JobChangeAdapter() {

    @Override
    public void done(IJobChangeEvent event) {
      if (event.getResult().isOK()) {
        AnalyticsPingManager.getInstance().sendPing(AnalyticsEvents.APP_ENGINE_DEPLOY_SUCCESS,
            analyticsDeployEventMetadataKey);
      }
      launchCleanupJob();
    }
  });
  deploy.schedule();
}
 
Example 57
Project: google-cloud-eclipse   File: DeployConsolePageParticipant.java   Source Code and License 5 votes vote down vote up
private Action createCloseAction() {
  Action close = new Action(Messages.getString("action.remove")) {
    @Override
    public void run() {
      ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[] { console });
    }
  };
  close.setToolTipText(Messages.getString("action.remove"));
  close.setImageDescriptor(getSharedImage(ISharedImages.IMG_ELCL_REMOVE));
  close.setHoverImageDescriptor(getSharedImage(ISharedImages.IMG_ELCL_REMOVE));
  close.setDisabledImageDescriptor(getSharedImage(ISharedImages.IMG_ELCL_REMOVE_DISABLED));
  return close;
}
 
Example 58
Project: google-cloud-eclipse   File: MessageConsoleUtilities.java   Source Code and License 5 votes vote down vote up
public static <C extends MessageConsole> C createConsole(String name, ConsoleFactory<C> factory) {
  ConsolePlugin plugin = ConsolePlugin.getDefault();
  IConsoleManager manager = plugin.getConsoleManager();
  C console = factory.createConsole(name);
  manager.addConsoles(new IConsole[]{console});
  return console;
}
 
Example 59
Project: JAADAS   File: SootPlugin.java   Source Code and License 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 60
Project: xstreamer   File: Perspective.java   Source Code and License 5 votes vote down vote up
@Override
public void createInitialLayout(IPageLayout layout) {
	layout.setEditorAreaVisible(false);
	layout.setFixed(true);

	MessageConsole myConsole = new MessageConsole("Console", null); 
	ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { myConsole });

	MessageConsoleStream stream = myConsole.newMessageStream();

	PrintStream myS = new PrintStream(stream);
	System.setOut(myS); // link standard output stream to the console
	System.setErr(myS); // link error output stream to the console
}