Java 类org.eclipse.ui.console.MessageConsoleStream 实例源码

项目:n4js    文件:ConsoleOutputStreamProvider.java   
@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;
}
项目:google-cloud-eclipse    文件:CloudSdkProcessWrapper.java   
/**
 * Sets up a {@link CloudSdk} to be used for App Engine deploy.
 */
public void setUpDeployCloudSdk(Path credentialFile, MessageConsoleStream normalOutputStream) {
  Preconditions.checkNotNull(credentialFile, "credential required for deploying");
  Preconditions.checkArgument(Files.exists(credentialFile), "non-existing credential file");
  Preconditions.checkState(cloudSdk == null, "CloudSdk already set up");

  // Structured deploy result (in JSON format) goes to stdout, so prepare to capture that.
  stdOutCaptor = new StringBuilderProcessOutputLineListener();
  // Structured gcloud logs (in JSON format) go to stderr, so prepare to capture them.
  gcloudErrorMessageCollector = new GcloudStructuredLogErrorMessageCollector();

  // Normal operation output goes to stderr.
  MessageConsoleStream stdErrOutputStream = normalOutputStream;
  CloudSdk.Builder cloudSdkBuilder = getBaseCloudSdkBuilder(stdErrOutputStream)
      .appCommandCredentialFile(credentialFile.toFile())
      .appCommandShowStructuredLogs("always")  // turns on gcloud structured log
      .addStdErrLineListener(gcloudErrorMessageCollector)
      .addStdOutLineListener(stdOutCaptor);
  cloudSdk = cloudSdkBuilder.build();
}
项目:google-cloud-eclipse    文件:FlexStagingDelegate.java   
@Override
public IStatus stage(IPath stagingDirectory, IPath safeWorkDirectory,
    MessageConsoleStream stdoutOutputStream, MessageConsoleStream stderrOutputStream,
    IProgressMonitor monitor) {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

  boolean result = stagingDirectory.toFile().mkdirs();
  if (!result) {
    return StatusUtil.error(this, "Could not create staging directory " + stagingDirectory);
  }

  try {
    IPath deployArtifact = getDeployArtifact(safeWorkDirectory, subMonitor.newChild(40));
    CloudSdkStagingHelper.stageFlexible(appEngineDirectory, deployArtifact, stagingDirectory,
        subMonitor.newChild(60));
    return Status.OK_STATUS;
  } catch (AppEngineException | CoreException ex) {
    return StatusUtil.error(this, Messages.getString("deploy.job.staging.failed"), ex);
  } finally {
    subMonitor.done();
  }
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerBehaviour.java   
private void initializeDevServer(MessageConsoleStream stdout, MessageConsoleStream stderr,
    Path javaHomePath) {
  MessageConsoleWriterOutputLineListener stdoutListener =
      new MessageConsoleWriterOutputLineListener(stdout);
  MessageConsoleWriterOutputLineListener stderrListener =
      new MessageConsoleWriterOutputLineListener(stderr);

  // dev_appserver output goes to stderr
  cloudSdk = new CloudSdk.Builder()
      .javaHome(javaHomePath)
      .addStdOutLineListener(stdoutListener).addStdErrLineListener(stderrListener)
      .addStdErrLineListener(serverOutputListener)
      .startListener(localAppEngineStartListener)
      .exitListener(localAppEngineExitListener)
      .async(true)
      .build();

  devServer = LocalAppEngineServerLaunchConfigurationDelegate.DEV_APPSERVER2
      ? new CloudSdkAppEngineDevServer2(cloudSdk)
      : new CloudSdkAppEngineDevServer1(cloudSdk);
  moduleToUrlMap.clear();
}
项目:ncl30-eclipse    文件:RemoteUtility.java   
public RemoteUtility(
        String hostName, 
        String userName, 
        String userPassword,
        MessageConsoleStream consoleStream) {

    // Setting attributes
    setHostName(hostName);
    setUserName(userName);
    setUserPassword(userPassword);
    setConsoleStream(consoleStream);

    setConnection(new Connection(getHostName()));

    setVerboseMode(false);
}
项目:caml2tosca    文件:C2TRunHandler.java   
@Override
public Object execute(ExecutionEvent event) {

    try {
        this.showConsole(event);
        this.clearConsole();

        IFile file = this.getSelectedFile(event);
        String umlModelPath = file.getLocation().toFile().getAbsolutePath();
        String toscaModelPath = file.getLocation().toFile().getAbsolutePath();
        toscaModelPath = toscaModelPath.replace(".uml", ".tosca");

        MessageConsoleStream outStream = console.newMessageStream();
        outStream.println("Translating " + umlModelPath + " into " + toscaModelPath);

        CAML2TOSCALauncher launcher = new CAML2TOSCALauncher();
        launcher.runCAML2TOSCATemplates(umlModelPath, toscaModelPath);

        outStream.println("Done ;)");
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    return null;
}
项目:RFRunnerPlugin    文件:StopTestAction.java   
public void run() {
    try {
        ISelection selection = treeViewer.getSelection();
        Object obj = ((IStructuredSelection) selection).getFirstElement();

        if (obj instanceof Test) {
            if (((Test) obj).getStatus().equals("Actual run")) {
                ((Test) obj).setStatus("Not run");
                treeViewer.refresh();
                treeViewer.expandAll();

                Runtime.getRuntime().exec("taskkill /F /IM python.exe");
                MessageConsoleStream out = ConsoleManager
                        .getMessageConsoleStream("Console");
                out.println("Test Stop");

                runTestAction.setEnabled(true);
                this.setEnabled(false);
            }
        }

    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:cppcheclipse    文件:Console.java   
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;
}
项目:EASyProducer    文件:EclipseConsole.java   
/**
 * Displays the specified text at the console, followed by a line
 * separator string.
 * 
 * @param text message to display
 * @param lineBreak <tt>true</tt> if a linebreak shall be inserted after the message.
 * @return <tt>true</tt> if the message was successfully displayed inside the console.
 */
public boolean writeToConsole(String text, boolean lineBreak) {
    boolean isWritten = false;
    if (this.msgConsole != null) {
        MessageConsoleStream out = this.msgConsole.newMessageStream();
        if (lineBreak) {
            out.println(text);
        } else {
            out.print(text);
        }
        try {
            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return isWritten;
}
项目:checker-framework    文件:JavacRunner.java   
/**
 * Runs the compiler on the selected files using the given processor
 * 
 * @param fileNames
 *            files that need to be type-checked
 * @param processors
 *            Type processors to run
 * @param classpath
 *            The classpath to reference in compilation
 */

public void run()
{
    Iterable<String> opts;

    opts = getOptions(processors, classpath);

    // The following code uses the compiler's internal APIs, which are
    // volatile. (see warning in JavacTool source)
    JavacTool tool = JavacTool.create();
    JavacFileManager manager = tool.getStandardFileManager(collector, null, null);

    Iterable<? extends JavaFileObject> fileObjs = manager.getJavaFileObjectsFromStrings(fileNames);

    CheckerPlugin.getDefault();
    MessageConsole console = CheckerPlugin.findConsole();
    MessageConsoleStream stream = console.newMessageStream();
    Writer writer = new OutputStreamWriter(stream);

    JavacTask task = tool.getTask(writer, manager, collector, opts, null, fileObjs);

    task.call();
    manager.close();
}
项目:vdt-plugin    文件:ConsoleView.java   
private MessageConsoleStream getNewMessageConsoleStream(int msgKind)
{     
    int swtColorId = SWT.COLOR_DARK_GREEN;

    switch (msgKind) {
        case MSG_INFORMATION:
            swtColorId = SWT.COLOR_BLACK;
            break;

        case MSG_ERROR:
            swtColorId = SWT.COLOR_RED;
            break;

        case MSG_WARNING:
            swtColorId = SWT.COLOR_DARK_BLUE;
            break;

        default:          
            swtColorId = SWT.COLOR_DARK_MAGENTA;
    }  

    MessageConsoleStream msgConsoleStream = getMessageConsole().newMessageStream();     
    msgConsoleStream.setColor(Display.getCurrent().getSystemColor(swtColorId));
    return msgConsoleStream;
}
项目:d-case_editor    文件:BasicNodeOpenEditPolicy.java   
/**
 * Checks Description string.
 * @param name the node name.
 * @param desc the description.
 */
private void checkDescParameters(String name, String desc) {
    Pattern p = Pattern.compile("\\{([^\\}]+)\\}"); //$NON-NLS-1$
    ArrayList<String> paramList = new ArrayList<String>();
    while (true) {
        Matcher m = p.matcher(desc);
        if (! m.find()) {
            break;
        }
        String parameter = m.group(1);
        paramList.add(parameter);
        desc = desc.replaceAll(String.format(PARAM_ITEM_REGEX_FORMAT, parameter), ""); //$NON-NLS-1$
    }
    // found unknown parameters.
    if (paramList.size() > 0) {
        MessageConsoleStream stream = DcaseNodeEditPart.getMessageConsoleStream();
        stream.print(name + ": cannot found "); //$NON-NLS-1$
        for (int i = 0; i < paramList.size(); i++) {
            stream.print(paramList.get(i) + ((i == paramList.size()-1) ? "":",")); //$NON-NLS-1$
        }
        stream.println();
    }
}
项目:n4js    文件:XpectConsole.java   
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;
}
项目:neoscada    文件:ConsoleContext.java   
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 ) );
}
项目:convertigo-eclipse    文件:ConvertigoPlugin.java   
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);
        }

    };
}
项目:jason-eclipse-plugin    文件:RunJasonFileEditor.java   
public RunJasonFileEditor() {
    super();

    MessageConsole console = findConsole("Console");
    MessageConsoleStream out = console.newMessageStream();

    System.setOut(new PrintStream(out));
    System.setErr(new PrintStream(out));
}
项目:jason-eclipse-plugin    文件:RunJasonApplication.java   
public RunJasonApplication() {
    super();

    MessageConsole console = findConsole("Console");
    MessageConsoleStream out = console.newMessageStream();

    System.setOut(new PrintStream(out));
    System.setErr(new PrintStream(out));
}
项目:jason-eclipse-plugin    文件:RunJasonFile.java   
public RunJasonFile() {
    super();

    MessageConsole console = findConsole("Console");
    MessageConsoleStream out = console.newMessageStream();

    System.setOut(new PrintStream(out));
    System.setErr(new PrintStream(out));
}
项目:eclipse    文件:CommandConsoleFactoryImpl.java   
@Override
public OutputStream createErrorStream() {
  // Get the error stream for the given console (a stream that print in red).
  final MessageConsoleStream errorStream = console.newMessageStream();
  Display display = Display.getCurrent();
  if (display == null) {
    display = Display.getDefault();
  }
  display.asyncExec(() -> errorStream.setColor(new Color(null, 255, 0, 0)));
  return errorStream;
}
项目:eclipse    文件:CommandConsoleFactoryImpl.java   
@Override
public CommandConsole get(String name, String title) throws IOException {
  MessageConsole console = findConsole(name);
  MessageConsoleStream stream = console.newMessageStream();
  stream.setActivateOnWrite(true);
  stream.write("*** " + title + " ***\n");
  return new CommandConsoleImpl(console);
}
项目:team-explorer-everywhere    文件:Console.java   
public void addStream(final String id, final Color color) {
    Check.notNull(id, "id"); //$NON-NLS-1$

    throwIfDisposed();

    final MessageConsoleStream messageConsoleStream;

    synchronized (streams) {
        if (streams.containsKey(id)) {
            final String messageFormat = "this console already contains a stream with id [{0}]"; //$NON-NLS-1$
            final String message = MessageFormat.format(messageFormat, id);
            throw new IllegalArgumentException(message);
        }

        /*
         * newMessageStream() can be called from any thread
         */
        messageConsoleStream = messageConsole.newMessageStream();
        final ConsoleStream stream = new ConsoleStream(id, Console.this, messageConsoleStream);
        streams.put(id, stream);
    }

    if (Display.getCurrent() != null) {
        Display.getCurrent().asyncExec(new Runnable() {
            @Override
            public void run() {
                messageConsoleStream.setColor(color);
            }
        });
    }
}
项目:google-cloud-eclipse    文件:DeployCommandHandler.java   
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();
}
项目:google-cloud-eclipse    文件:AppEngineProjectDeployer.java   
/**
 * @param optionalConfigurationFilesDirectory if not {@code null}, searches optional configuration
 * files (such as {@code cron.yaml}) in this directory and deploys them together
 */
public IStatus deploy(IPath stagingDirectory, Path credentialFile,
    DeployPreferences deployPreferences, IPath optionalConfigurationFilesDirectory,
    MessageConsoleStream stdoutOutputStream, IProgressMonitor monitor) {
  if (monitor.isCanceled()) {
    throw new OperationCanceledException();
  }

  cloudSdkProcessWrapper.setUpDeployCloudSdk(credentialFile, stdoutOutputStream);
  CloudSdk cloudSdk = cloudSdkProcessWrapper.getCloudSdk();

  SubMonitor progress = SubMonitor.convert(monitor, 1);
  progress.setTaskName(Messages.getString("task.name.deploy.project")); //$NON-NLS-1$
  try {
    List<File> deployables =
        computeDeployables(stagingDirectory, optionalConfigurationFilesDirectory);

    DefaultDeployConfiguration configuration =
        DeployPreferencesConverter.toDeployConfiguration(deployPreferences);
    configuration.setDeployables(deployables);
    CloudSdkAppEngineDeployment deployment = new CloudSdkAppEngineDeployment(cloudSdk);
    try { 
      deployment.deploy(configuration);
    } catch (AppEngineException ex) {
      return StatusUtil.error(this, "Error deploying project: " + ex.getMessage(), ex);
    }
    return cloudSdkProcessWrapper.getExitStatus();
  } finally {
    progress.worked(1);
  }
}
项目:google-cloud-eclipse    文件:CloudSdkProcessWrapper.java   
/**
 * Sets up a {@link CloudSdk} to be used for App Engine standard staging.
 *
 * @param javaHome JDK/JRE to 1) run {@code com.google.appengine.tools.admin.AppCfg} from
 *     {@code appengine-tools-api.jar}; and 2) compile JSPs during staging
 */
public void setUpStandardStagingCloudSdk(Path javaHome,
    MessageConsoleStream stdoutOutputStream, MessageConsoleStream stderrOutputStream) {
  Preconditions.checkState(cloudSdk == null, "CloudSdk already set up");

  CloudSdk.Builder cloudSdkBuilder = getBaseCloudSdkBuilder(stderrOutputStream)
      .addStdOutLineListener(new MessageConsoleWriterOutputLineListener(stdoutOutputStream));
  if (javaHome != null) {
    cloudSdkBuilder.javaHome(javaHome);
  }
  cloudSdk = cloudSdkBuilder.build();
}
项目:google-cloud-eclipse    文件:CloudSdkProcessWrapper.java   
private CloudSdk.Builder getBaseCloudSdkBuilder(MessageConsoleStream stdErrStream) {
  return new CloudSdk.Builder()
      .addStdErrLineListener(new MessageConsoleWriterOutputLineListener(stdErrStream))
      .startListener(new StoreProcessObjectListener())
      .exitListener(new ProcessExitRecorder())
      .appCommandMetricsEnvironment(CloudToolsInfo.METRICS_NAME)
      .appCommandMetricsEnvironmentVersion(CloudToolsInfo.getToolsVersion())
      .appCommandOutputFormat("json");  // Deploy result will be in JSON.
}
项目:google-cloud-eclipse    文件:DeployJob.java   
/**
 * @param workDirectory temporary work directory the job can safely use (e.g., for creating and
 *     copying various files to stage and deploy)
 */
public DeployJob(DeployPreferences deployPreferences, Credential credential, IPath workDirectory,
    MessageConsoleStream stdoutOutputStream, MessageConsoleStream stderrOutputStream,
    StagingDelegate stager) {
  super(Messages.getString("deploy.job.name")); //$NON-NLS-1$
  Preconditions.checkNotNull(deployPreferences.getProjectId());
  Preconditions.checkArgument(!deployPreferences.getProjectId().isEmpty());
  this.deployPreferences = deployPreferences;
  this.credential = credential;
  this.workDirectory = workDirectory;
  this.stdoutOutputStream = stdoutOutputStream;
  this.stderrOutputStream = stderrOutputStream;
  this.stager = stager;
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerBehaviour.java   
/**
 * Starts the development server.
 *
 * @param mode the launch mode (see ILaunchManager.*_MODE constants)
 */
void startDevServer(String mode, DefaultRunConfiguration devServerRunConfiguration,
    Path javaHomePath, MessageConsoleStream outputStream, MessageConsoleStream errorStream)
    throws CoreException {

  PortChecker portInUse = new PortChecker() {
    @Override
    public boolean isInUse(InetAddress addr, int port) {
      Preconditions.checkArgument(port >= 0, "invalid port");
      return SocketUtil.isPortInUse(addr, port);
    }
  };

  checkPorts(devServerRunConfiguration, portInUse);

  setServerState(IServer.STATE_STARTING);
  setMode(mode);

  // TODO(chanseok): remove once Bug 68205805 is fixed. This is a temporary workaround for
  // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/2531.
  putAppEngineApiSdkJarIntoApps(devServerRunConfiguration.getServices(), repositoryService);

  // Create dev app server instance
  initializeDevServer(outputStream, errorStream, javaHomePath);

  // Run server
  try {
    devServer.run(devServerRunConfiguration);
  } catch (AppEngineException ex) {
    Activator.logError("Error starting server: " + ex.getMessage()); //$NON-NLS-1$
    stop(true);
  }
}
项目:google-cloud-eclipse    文件:StandardStagingDelegateTest.java   
@Test
public void testSetJavaHome() {
  Path javaHome = Paths.get("/some/path");
  StagingDelegate delegate = new StandardStagingDelegate(project, javaHome, cloudSdkWrapper);
  delegate.stage(stagingDirectory, safeWorkDirectory, null, null,
      new NullProgressMonitor());

  verify(cloudSdkWrapper).setUpStandardStagingCloudSdk(
      eq(javaHome), any(MessageConsoleStream.class), any(MessageConsoleStream.class));
}
项目:texlipse    文件:BuilderRegistry.java   
/**
 * Return the console output stream. Instantiate if necessary.
 * @return the output stream to console
 */
private MessageConsoleStream getConsoleStream() {
    if (consoleStream == null) {
        consoleStream = getConsole().newMessageStream();
    }
    return consoleStream;
}
项目:hybris-commerce-eclipse-plugin    文件:ConsoleUtils.java   
/**
 * 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);
}
项目:xstreamer    文件:Perspective.java   
@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
}
项目:xstreamer    文件:Perspective.java   
@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
}
项目:ncl30-eclipse    文件:GingaVMRemoteUtility.java   
public GingaVMRemoteUtility(
        String hostName, 
        String userName,
        String userPassword,
        MessageConsoleStream consoleStream) {

    super(hostName, userName, userPassword, consoleStream);
}
项目:ncl30-eclipse    文件:GingaVMRemoteUtility.java   
public GingaVMRemoteUtility(
        String hostName, 
        String userName,
        String userPassword,
        MessageConsoleStream consoleStream,
        String remoteLauncher,
        String remoteWorkspace,
        String remoSettingsIni) {

    super(hostName, userName, userPassword, consoleStream);

    setRemoteLauncher(remoteLauncher);
    setRemoteWorkspace(remoteWorkspace);
    setRemoteSettingsIni(remoSettingsIni);
}
项目:RFRunnerPlugin    文件:StreamWrapper.java   
public void run() {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(
                inputStream));
        String line = null;
        MessageConsoleStream out = ConsoleManager
                .getMessageConsoleStream("Console");
        while ((line = br.readLine()) != null) {
            out.println(line);
            actualRunTest.setEndTime(System.currentTimeMillis());

            if (line.contains("PASS") || (line.contains("FAIL"))) {
                if (line.contains("PASS")) {
                    actualRunTest.setStatus("Passed");
                } else if (line.contains("FAIL")) {
                    actualRunTest.setStatus("Failed");
                }

                treeContentProvider.updateTest(actualRunTest);
                runTestAction.setEnabled(true);
                stopTestAction.setEnabled(false);
                refresh();
            }
        }
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
项目:RFRunnerPlugin    文件:RunTestAction.java   
public void run() {
    loadPluginSettings();

    MessageConsoleStream out = ConsoleManager
            .getMessageConsoleStream("Console");
    out.println("");

    ISelection selection = treeViewer.getSelection();
    Object obj = ((IStructuredSelection) selection)
            .getFirstElement();

    if (obj instanceof Test) {
        Runtime rt = Runtime.getRuntime();
        StreamWrapper output;

        try {
            Test selectedTest = (Test) obj;
            String testName = selectedTest.getTestName();
            String filePath = selectedTest.getFile().getPath();
            String pybotCommand = new StringBuilder(pybotPath)
                    .append(" --test ").append('"')
                    .append(testName).append('"').append(' ')
                    .append(filePath).toString();
            Process proc = rt.exec(pybotCommand);
            output = new StreamWrapper(proc.getInputStream(),
                    (Test) obj, treeViewer, treeContentProvider, this, stopTestAction);
            selectedTest.setStatus("Actual run");
            selectedTest.setStartTime(System.currentTimeMillis());
            output.start();

            treeViewer.refresh();
            treeViewer.expandAll();
        } catch (IOException e) {
            e.printStackTrace();
        }

        this.setEnabled(false);
        stopTestAction.setEnabled(true);
    }
}
项目:dockerfoundry    文件:ViewHelper.java   
public static void showConsole(String consoleName, String content) throws IOException, PartInitException{
    IWorkbenchPage page = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage();
    MessageConsole console = ConsoleHelper
            .findConsole(consoleName);
    MessageConsoleStream out = console.newMessageStream();
    out.println(content);
    out.setActivateOnWrite(true);
    out.setColor(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
    out.close();

    IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
    view.display(console);
}
项目:PDFReporter-Studio    文件:JaspersoftStudioPlugin.java   
/**
 * Creates an additional Console for the Console view.
 * Once installed, all the messages printed on the System.out and System.err streams
 * will be redirected here.
 */
public static void installJSSConsole() {
    try {
        MessageConsole jssConsole = new MessageConsole(Messages.JaspersoftStudioPlugin_JSSConsoleTitle, null);
        ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{jssConsole});
        MessageConsoleStream consoleStream = jssConsole.newMessageStream();
        PrintStream pstream = new PrintStream(consoleStream);
        System.setOut(pstream);
        System.setErr(pstream);
    } catch (SecurityException e) {
        // something went wrong while trying to 
        // re-assign the standard output and error streams.
        e.printStackTrace();
    }   
}
项目:PDFReporter-Studio    文件:Console.java   
public void addError(final Throwable e, final JasperDesign design) {
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            MessageConsoleStream out = console.newMessageStream();
            Color color = out.getColor();
            out.setColor(color);
            out.println(ErrorUtil.getStackTrace(e) + "\n\r");
            out.setColor(REDCOLOR);
            for (VErrorPreview vep : ePreviews)
                vep.addError(e, design);
        }
    });
}
项目:PDFReporter-Studio    文件:Console.java   
public void addMessage(final String message) {
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            MessageConsoleStream out = console.newMessageStream();
            out.println(message);
            for (VErrorPreview vep : ePreviews)
                vep.addMessage(message);
        }
    });
}