Java Code Examples for org.eclipse.ui.console.MessageConsoleStream#setColor()

The following examples show how to use org.eclipse.ui.console.MessageConsoleStream#setColor() . 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: Console.java    From cppcheclipse with Apache License 2.0 6 votes vote down vote up
public OutputStream getConsoleOutputStream(boolean isError) {
	final MessageConsoleStream output = messageConsole.newMessageStream();
	output.setActivateOnWrite(false);
	
	final int colorId;
	if (!isError) {
		colorId = SWT.COLOR_BLACK;
	} else {
		colorId = SWT.COLOR_RED;
	}
	
	/* we must set the color in the UI thread */
	Runnable runnable = new Runnable() {
		public void run() {
			org.eclipse.swt.graphics.Color color = Display.getCurrent()
					.getSystemColor(colorId);
			output.setColor(color);
		}
	};
	Display.getDefault().syncExec(runnable);
	
	return output;
}
 
Example 2
Source File: XpectConsole.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private MessageConsoleStream getNewMessageConsoleStream(int msgKind) {
	int swtColorId = SWT.COLOR_BLACK;

	switch (msgKind) {
	case MSG_LOG:
		swtColorId = SWT.COLOR_BLACK;
		break;
	case MSG_INFORMATION:
		swtColorId = SWT.COLOR_DARK_GRAY;
		break;
	case MSG_ERROR:
		swtColorId = SWT.COLOR_DARK_MAGENTA;
		break;
	case MSG_WARNING:
		swtColorId = SWT.COLOR_DARK_YELLOW;
		break;
	case MSG_SUCCESS:
		swtColorId = SWT.COLOR_DARK_GREEN;
		break;
	default:
		swtColorId = SWT.COLOR_BLACK;
		break;
	}

	MessageConsoleStream msgConsoleStream = messageConsole.newMessageStream();
	msgConsoleStream.setColor(Display.getCurrent().getSystemColor(swtColorId));

	return msgConsoleStream;
}
 
Example 3
Source File: ConsoleContext.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public ConsoleContext ( final MessageConsole messageConsole )
{
    this.writerStream = messageConsole.newMessageStream ();

    final MessageConsoleStream errorStream = messageConsole.newMessageStream ();
    errorStream.setColor ( Display.getDefault ().getSystemColor ( SWT.COLOR_RED ) );
    this.errorPrintWriter = new PrintWriter ( new OutputStreamWriter ( errorStream ) );

    this.logStream = messageConsole.newMessageStream ();
    this.logStream.setColor ( Display.getDefault ().getSystemColor ( SWT.COLOR_GRAY ) );
}
 
Example 4
Source File: DeployCommandHandler.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void launchDeployJob(IProject project, Credential credential)
    throws IOException, CoreException {
  sendAnalyticsPing(AnalyticsEvents.APP_ENGINE_DEPLOY);

  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()) {
        sendAnalyticsPing(AnalyticsEvents.APP_ENGINE_DEPLOY_SUCCESS);
      }
      launchCleanupJob();
    }
  });
  deploy.schedule();
}
 
Example 5
Source File: ConsoleUtils.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Prints error message to the console.
 * 
 * @param message error message to print
 */
public static void printError(final String message) {
	final Display display = PlatformUI.getWorkbench().getDisplay();
	final MessageConsoleStream consoleStream = getConsoleStream();
	final Color color = new Color(display, new RGB(255, 0, 0));
	
	consoleStream.setColor(color);
	consoleStream.println(message);
}