Esempio n. 1
0
 private Console() {
   super("RCLog4j", null);
   activate();
   MessageConsole console = new MessageConsole("RCLog4j", null);
   ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
   ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {this});
 }
Esempio n. 2
0
  private static MessageConsoleStream createConsoleStream() {

    MessageConsole console = new MessageConsole("Annotations Search Results", null);
    console.activate();
    ConsolePlugin consolePlugin = ConsolePlugin.getDefault();
    consolePlugin.getConsoleManager().addConsoles(new IConsole[] {console});
    MessageConsoleStream messageStream = console.newMessageStream();
    return messageStream;
  }
Esempio n. 3
0
  private SimpleLogger() {
    MessageConsole console = new MessageConsole("System Output", null); // $NON-NLS-1$
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
    ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
    MessageConsoleStream stream = console.newMessageStream();

    System.setOut(new PrintStream(stream));
    System.setErr(new PrintStream(stream));
  }
  public void writeToShell(String serverId, String[] lines) {
    MessageConsole myConsole = findConsole(serverId);
    MessageConsoleStream out = myConsole.newMessageStream();
    for (int i = 0; i < lines.length; i++) out.println(lines[i]);

    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    conMan.showConsoleView(myConsole);
  }
  /*
   * Busca la consola de eclipse para poder escribir los log
   */
  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];

    MessageConsole myConsole = new MessageConsole(name, null);
    conMan.addConsoles(new IConsole[] {myConsole});
    return myConsole;
  }
 private static MessageConsole findConsole(String name) {
   ConsolePlugin conPlugin = ConsolePlugin.getDefault();
   IConsoleManager conManager = conPlugin.getConsoleManager();
   IConsole[] consAll = conManager.getConsoles();
   for (int i = 0; i < consAll.length; i++)
     if (name.equals(consAll[i].getName())) return (MessageConsole) consAll[i];
   // no console found, so we create a new one
   MessageConsole console = new MessageConsole(name, null);
   conManager.addConsoles(new IConsole[] {console});
   return console;
 }
Esempio n. 7
0
 public static PVSConsole getConsole() {
   ConsolePlugin plugin = ConsolePlugin.getDefault();
   IConsoleManager conMan = plugin.getConsoleManager();
   for (IConsole c : conMan.getConsoles()) {
     if (name.equals(c.getName())) {
       return (PVSConsole) c;
     }
   }
   PVSConsole console = new PVSConsole();
   conMan.addConsoles(new IConsole[] {console});
   conMan.showConsoleView(console);
   return console;
 }
  public static MessageConsole getConsole() {
    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    IConsole[] existing = conMan.getConsoles();
    for (int i = 0; i < existing.length; i++)
      if (ConsoleHelper.CONSOLE_ID.equals(existing[i].getName()))
        return (MessageConsole) existing[i];
    // no console found, so create a new one
    MessageConsole myConsole = ARESUI.getDefault().getConsole();

    conMan.addConsoles(new IConsole[] {myConsole});
    return myConsole;
  }
  /** Execution of the start ZAP job. */
  @Override
  protected IStatus run(IProgressMonitor monitor) {
    // Signal that the ZAP start action is starting.
    Job signalZAPStartJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Start...", ZAPEventType.SERVER_STARTED, eventHandler);
    signalZAPStartJob.setPriority(Job.INTERACTIVE);
    signalZAPStartJob.schedule();

    // Run the start ZAP job.
    Job startZAPJob = new StartZAPJob("Running ZAP Start Job...");
    startZAPJob.setPriority(Job.LONG);
    startZAPJob.schedule();
    while (startZAPJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    // Signal that the ZAp start action is complete.
    Job signalZAPStartCompleteJob =
        new SignalZAPEventJob(
            display, "ZAP Start Complete", ZAPEventType.SERVER_STARTUP_COMPLETE, eventHandler);
    signalZAPStartCompleteJob.setPriority(Job.INTERACTIVE);
    signalZAPStartCompleteJob.schedule();

    return Status.OK_STATUS;
  }
Esempio n. 10
0
 public void createConsoleStream() {
   // 出力コンソールの用意
   console = new MessageConsole("キーワードプログラミング", null);
   consoleManager = ConsolePlugin.getDefault().getConsoleManager();
   consoleManager.addConsoles(new IConsole[] {console});
   consoleStream = console.newMessageStream();
 }
Esempio n. 11
0
 private boolean checkRegistration() {
   IConsole[] consoleArray = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
   for (int i = 0; i < consoleArray.length; i++) {
     IConsole c = consoleArray[i];
     if (c == console) {
       return true;
     }
   }
   return false;
 }
Esempio n. 12
0
 @Override
 public void stop(BundleContext context) throws Exception {
   plugin = null;
   final IConsoleManager mgr = ConsolePlugin.getDefault().getConsoleManager();
   mgr.removeConsoles(new IConsole[] {console});
   console = null;
   destroyStream(ConsoleStream.DEFAULT);
   destroyStream(ConsoleStream.STDOUT);
   destroyStream(ConsoleStream.STDERR);
   super.stop(context);
 }
Esempio n. 13
0
 @Override
 public void start(BundleContext context) throws Exception {
   console = new MessageConsole("Terracotta build system", null);
   final Device device = console.getFont() != null ? console.getFont().getDevice() : null;
   initStream(ConsoleStream.DEFAULT, device, BLACK);
   initStream(ConsoleStream.STDOUT, device, BLUE);
   initStream(ConsoleStream.STDERR, device, RED);
   final IConsoleManager mgr = ConsolePlugin.getDefault().getConsoleManager();
   mgr.addConsoles(new IConsole[] {console});
   super.start(context);
 }
Esempio n. 14
0
 /**
  * Returns a reference to the console that is for the given {@link RPMProject}. If such a console
  * does not yet exist, it will be created.
  *
  * @param rpmProject The project this console will be for. Must not be <code>null</code>.
  * @return A console instance.
  */
 public static RpmConsole findConsole(RPMProject rpmProject) {
   RpmConsole ret = null;
   for (IConsole cons : ConsolePlugin.getDefault().getConsoleManager().getConsoles()) {
     if (cons instanceof RpmConsole
         && ((RpmConsole) cons)
             .rpmProject
             .getSpecFile()
             .getProject()
             .getName()
             .equals(rpmProject.getSpecFile().getProject().getName())) {
       ret = (RpmConsole) cons;
     }
   }
   // no existing console, create new one
   if (ret == null) {
     ret = new RpmConsole(rpmProject);
     ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {ret});
   }
   return ret;
 }
 /* (non-Javadoc)
  * @see org.apache.log4j.Appender#close()
  */
 public void close() {
   if (_consoleStream != null) {
     try {
       _consoleStream.flush();
       _consoleStream.close();
       IConsoleManager mgr = ConsolePlugin.getDefault().getConsoleManager();
       mgr.removeConsoles(new IConsole[] {_consoleStream.getConsole()});
     } catch (IOException ioe) {
       _consoleStream.println(Activator.getResourceString("MessageConsoleAppender.ErrorClosing"));
       ioe.printStackTrace(new PrintStream(_consoleStream));
     }
   }
 }
 public boolean isEnabled() {
   try {
     Expression enablementExpression = getEnablementExpression();
     if (enablementExpression == null) {
       return true;
     }
     EvaluationContext context = new EvaluationContext(null, this);
     EvaluationResult evaluationResult = enablementExpression.evaluate(context);
     return evaluationResult != EvaluationResult.FALSE;
   } catch (CoreException e) {
     ConsolePlugin.log(e);
     return false;
   }
 }
Esempio n. 17
0
  private static void basicOpenConsole() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      IWorkbenchPage page = window.getActivePage();
      if (page != null) {
        try {
          IConsole myConsole = findConsole(SQLPLUS_CONSOLE_VIEW);
          String id = IConsoleConstants.ID_CONSOLE_VIEW;
          IConsoleView view = (IConsoleView) page.showView(id);
          view.display(myConsole);

        } catch (PartInitException e) {
          ConsolePlugin.log(e);
        }
      }
    }
  }
Esempio n. 18
0
  @Override
  public void run() {
    LogEventBean event = view.getSelectedEvent();
    if (event == null) {
      return;
    }
    StringBuffer buf = new StringBuffer();
    String[] lines = Logs.getThrowableRep(event);
    if (lines != null && lines.length > 0) {
      for (int i = 0; i < lines.length; i++) {
        buf.append(lines[i]).append(NEW_LINE);
      }
    } else {
      // lets use the location of the
      String className = event.getClassName();
      String methodName = event.getMethodName();
      String fileName = event.getFileName();
      String lineNumber = event.getLineNumber();
      if (Strings.isBlank(className)
          || Strings.isBlank(methodName)
          || Strings.isBlank(fileName)
          || Strings.isBlank(lineNumber)) {
        return;
      }
      buf.append(event.getMessage()).append(NEW_LINE);
      buf.append("\tat " + className + "." + methodName + "(" + fileName + ":" + lineNumber + ")")
          .append(NEW_LINE);
      ;
    }

    // check that the user did not remove our console from the ConsoleView
    boolean stillRegistered = checkRegistration();
    if (!stillRegistered) {
      registerConsole();
    }

    console.clearConsole();
    console.getDocument().set(buf.toString());
    ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
  }
  // print to stream, lazily instantiating and opening console if necessary
  private void print(final LoggingEvent event) {
    // ensure in UI thread
    assert Display.getCurrent() != null;

    // ensure console view is open
    if (WorkbenchUtil.getView(IConsoleConstants.ID_CONSOLE_VIEW) == null) {
      try {
        IWorkbenchPage activePage = WorkbenchUtil.getActivePage();
        if (activePage != null) {
          activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW);
        }
      } catch (PartInitException pie) {
        // ignore for now
      }
    }

    // lazily instantiate console if necessary
    if (_consoleStream == null) {
      IConsoleManager mgr = ConsolePlugin.getDefault().getConsoleManager();
      MessageConsole logConsole =
          new MessageConsole(
              Activator.getResourceString("MessageConsoleAppender.Log"), // $NON-NLS-1$
              null);
      mgr.addConsoles(new IConsole[] {logConsole});
      mgr.showConsoleView(logConsole);
      _consoleStream = logConsole.newMessageStream();
    }

    // print message
    _consoleStream.print(getLayout().format(event));
    if (getLayout().ignoresThrowable()) {
      String[] lines = event.getThrowableStrRep();
      if (lines != null) {
        for (String line : lines) {
          _consoleStream.println(line);
        }
      }
    }
  }
Esempio n. 20
0
  @Override
  public void performFullBuild(IFile config) {
    if (!isPluginInstalled(PLUGIN_ID_XTEXT)) {
      generateWarning(PLUGIN_WARNING_XTEXT);
      return;
    }
    if (!isPluginInstalled(PLUGIN_ID_XTYPES)) {
      generateWarning(PLUGIN_WARNING_XTYPES);
      return;
    }
    // init console
    MessageConsole console = new MessageConsole("DeltaJ Error Log", null);
    console.activate();
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {(IConsole) console});
    consoleMessageStream = console.newMessageStream();

    // initialization
    this.errors = 0;
    this.errorReport = "";
    boolean ioError = false;
    this.outputPath = this.featureProject.getBuildPath().replace('\\', '/') + "/";
    this.configName = config.getName().split("\\.")[0];
    this.spl = new DeltajSPLDefinition();
    IFolder sourceFolder = featureProject.getSourceFolder();
    this.featureModel = featureProject.getFeatureModel();
    this.spl.setName(this.featureModel.getRoot().getName());

    // get all features
    this.spl.addAllFeatures(this.featureModel.getConcreteFeatures());

    // get deltas specification
    this.spl.setDeltas(parseApplicationRules());

    // get current configuration
    Configuration configuration = new Configuration(this.featureModel);
    ConfigurationReader reader = new ConfigurationReader(configuration);
    try {
      reader.readFromFile(config);
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    } catch (IOException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }

    // collect all deltaj files of selected features
    String composedDeltas = "";
    deltajFiles = new ArrayList<DeltajFile>();
    composedDeltas += composeAllFileContents(sourceFolder);
    composedDeltas += this.spl.toString();
    composedDeltas += this.createProductDefinition(configuration);

    IFile tmpFile =
        featureProject
            .getProject()
            .getFile(featureProject.getBuildFolder().getName() + "/tmp" + DeltajComposer.FILE_EXT);
    InputStream in = new ByteArrayInputStream(composedDeltas.getBytes());
    try {
      tmpFile.create(in, false, null);
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }

    // compile
    compileResource(tmpFile.getFullPath().toString());

    // cleanup
    try {
      tmpFile.delete(false, null);
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }

    // print errors

    if (!issueList.isEmpty()) {
      for (Issue issue : issueList) {
        printError(issue);
      }
    }
    consoleMessageStream.print(
        "DeltaJ Files compiled with " + this.errors + (this.errors == 1 ? " error" : " errors"));
    if (this.errors != 0 || ioError) {
      this.errorReport += "\n" + this.errors + " compile errors";
      System.out.println(this.errorReport);
    }
  }
Esempio n. 21
0
 private void initConsole() {
   console = new JavaStackTraceConsole();
   ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
 }
Esempio n. 22
0
 public ConsoleFactory() {
   this(ConsolePlugin.getDefault().getConsoleManager());
 }
 /** Static instanciation block */
 static {
   console = new MessageConsole(Messages.CONSOLE_NAME.message(), null);
   ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
   console.activate();
 }
Esempio n. 24
0
 private void registerConsole() {
   ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.console.IConsoleFactory#openConsole()
  */
 public void openConsole() {
   IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
   final TangoSpecConsole console = createConsole();
   manager.addConsoles(new IConsole[] {console});
   manager.showConsoleView(console);
 }
 private static void removeAllConsoles() {
   IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
   consoleManager.removeConsoles(consoleManager.getConsoles());
 }
 public ZephyrConsolePlugin() {
   ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {systemConsole});
 }
  /** Execution of the run ZAP scan job. */
  @Override
  protected IStatus run(IProgressMonitor monitor) {

    ScanProgress scanProgress = new ScanProgress();

    // Make sure that all of the necessary scan parameters have been
    // entered.
    if (StringUtils.isBlank(target.getTargetUrl())
        || StringUtils.isBlank(target.getFileName())
        || StringUtils.isBlank(target.getReportFormat())) {
      CreatePopupMessageJob incompleteParamsWarningJob =
          new CreatePopupMessageJob(
              MessageDialog.WARNING,
              "The Scan Target URL, Scan Result File, and Report Format fields are required to run a scan.");
      incompleteParamsWarningJob.setPriority(Job.INTERACTIVE);
      incompleteParamsWarningJob.schedule();
      return Status.CANCEL_STATUS;
    }

    // Give the user a warning if the scan will overwrite an existing scan
    // file.
    try {
      if (ZAPScanHelper.scanFilesExist(target.getFileName())) {
        CreatePopupMessageJob fileOverwriteWarning =
            new CreatePopupMessageJob(
                MessageDialog.CONFIRM,
                "The specified Scan Result File matches an existing scan file in the ZAPScanResults folder.  Executing the scan may overwrite existing scan results data.  Do you wish to proceed?");
        fileOverwriteWarning.setPriority(Job.INTERACTIVE);
        fileOverwriteWarning.schedule();
        while (fileOverwriteWarning.getResult() == null) {
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {
            ConsolePlugin.log(e);
          }
        }

        if (fileOverwriteWarning.getResult() == Status.CANCEL_STATUS) {
          return Status.CANCEL_STATUS;
        }
      }
    } catch (CoreException e1) {
      ConsolePlugin.log(e1);
    }

    // Signal that the spider has started.
    Job signalZAPSpiderJob =
        new SignalZAPEventJob(
            display,
            "Signal ZAP Spider Started...",
            ZAPEventType.SCAN_SPIDER_STARTED,
            eventHandler);
    signalZAPSpiderJob.setPriority(Job.INTERACTIVE);
    signalZAPSpiderJob.schedule();

    // Set the attack levels.
    Job attackLevelJob =
        new ZAPSetZAPLevelsJob("Setting ZAP Attack Levels..", target.getZapPolicyList());
    attackLevelJob.setPriority(LONG);
    attackLevelJob.schedule();

    // Perform a spider of the target URL.
    spiderJob =
        new ZAPSpiderJob(
            "Running Zed Attack Proxy Spider...",
            target,
            display,
            scanProgress,
            eventHandler,
            scanStatus);
    spiderJob.setPriority(LONG);
    spiderJob.schedule();
    while (spiderJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    if (scanStatus.isScanCancelled()) {
      return Status.CANCEL_STATUS;
    }

    // Signal that the spider has started.
    Job signalZAPAscanJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Ascan Started...", ZAPEventType.SCAN_ASCAN_STARTED, eventHandler);
    signalZAPAscanJob.setPriority(Job.INTERACTIVE);
    signalZAPAscanJob.schedule();

    // Perform an ascan on the target URL.
    ascanJob =
        new ZAPAscanJob(
            "Running Zed Attack Proxy Ascan...",
            target,
            display,
            scanProgress,
            eventHandler,
            scanStatus);
    ascanJob.setPriority(LONG);
    ascanJob.schedule();
    while (ascanJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    if (scanStatus.isScanCancelled()) {
      return Status.CANCEL_STATUS;
    }

    // Clear out scan data after run is complete.
    Job clearZapJob = new ClearZAPJob("Clearing Zed Attack Proxy Run Data...");
    clearZapJob.setPriority(LONG);
    clearZapJob.schedule();
    while (clearZapJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    // Signal that the scan is complete.
    Job signalZAPScanCompleteJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Scan Complete", ZAPEventType.SCAN_COMPLETE, eventHandler);
    signalZAPScanCompleteJob.setPriority(Job.INTERACTIVE);
    signalZAPScanCompleteJob.schedule();

    return Status.OK_STATUS;
  }
  @Override
  public void launch(
      ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor)
      throws CoreException {
    try {
      ConfigUtils configUtils = new ConfigUtils(config);
      project = configUtils.getProject();
      // check if Perf exists in $PATH
      if (!PerfCore.checkPerfInPath(project)) {
        IStatus status =
            new Status(
                IStatus.ERROR,
                PerfPlugin.PLUGIN_ID,
                "Error: Perf was not found on PATH"); //$NON-NLS-1$
        throw new CoreException(status);
      }
      URI binURI = new URI(configUtils.getExecutablePath());
      binPath = Path.fromPortableString(binURI.toString());
      workingDirPath =
          Path.fromPortableString(
              Path.fromPortableString(binURI.toString()).removeLastSegments(2).toPortableString());
      PerfPlugin.getDefault().setWorkingDir(workingDirPath);
      if (config.getAttribute(PerfPlugin.ATTR_ShowStat, PerfPlugin.ATTR_ShowStat_default)) {
        showStat(config, launch);
      } else {
        URI exeURI = new URI(configUtils.getExecutablePath());
        String configWorkingDir = configUtils.getWorkingDirectory() + IPath.SEPARATOR;
        RemoteConnection exeRC = new RemoteConnection(exeURI);
        String perfPathString =
            RuntimeProcessFactory.getFactory().whichCommand(PerfPlugin.PERF_COMMAND, project);
        boolean copyExecutable = configUtils.getCopyExecutable();
        if (copyExecutable) {
          URI copyExeURI = new URI(configUtils.getCopyFromExecutablePath());
          RemoteConnection copyExeRC = new RemoteConnection(copyExeURI);
          IRemoteFileProxy copyExeRFP = copyExeRC.getRmtFileProxy();
          IFileStore copyExeFS = copyExeRFP.getResource(copyExeURI.getPath());
          IRemoteFileProxy exeRFP = exeRC.getRmtFileProxy();
          IFileStore exeFS = exeRFP.getResource(exeURI.getPath());
          IFileInfo exeFI = exeFS.fetchInfo();
          if (exeFI.isDirectory()) {
            // Assume the user wants to copy the file to the given directory, using
            // the same filename as the "copy from" executable.
            IPath copyExePath = Path.fromOSString(copyExeURI.getPath());
            IPath newExePath =
                Path.fromOSString(exeURI.getPath()).append(copyExePath.lastSegment());
            // update the exeURI with the new path.
            exeURI =
                new URI(
                    exeURI.getScheme(),
                    exeURI.getAuthority(),
                    newExePath.toString(),
                    exeURI.getQuery(),
                    exeURI.getFragment());
            exeFS = exeRFP.getResource(exeURI.getPath());
          }
          copyExeFS.copy(exeFS, EFS.OVERWRITE | EFS.SHALLOW, new SubProgressMonitor(monitor, 1));
          // Note: assume that we don't need to create a new exeRC since the
          // scheme and authority remain the same between the original exeURI and the new one.
        }
        IPath remoteBinFile = Path.fromOSString(exeURI.getPath());
        IFileStore workingDir;
        URI workingDirURI =
            new URI(RemoteProxyManager.getInstance().getRemoteProjectLocation(project));
        RemoteConnection workingDirRC = new RemoteConnection(workingDirURI);
        IRemoteFileProxy workingDirRFP = workingDirRC.getRmtFileProxy();
        workingDir = workingDirRFP.getResource(workingDirURI.getPath());
        // Build the commandline string to run perf recording the given project
        String arguments[] = getProgramArgumentsArray(config); // Program args from launch config.
        ArrayList<String> command = new ArrayList<>(4 + arguments.length);
        Version perfVersion = PerfCore.getPerfVersion(config);
        command.addAll(
            Arrays.asList(
                PerfCore.getRecordString(
                    config,
                    perfVersion))); // Get the base commandline string (with flags/options based on
                                    // config)
        command.add(remoteBinFile.toOSString()); // Add the path to the executable
        command.set(0, perfPathString);
        command.add(2, OUTPUT_STR + configWorkingDir + PerfPlugin.PERF_DEFAULT_DATA);
        // Compile string
        command.addAll(Arrays.asList(arguments));

        // Spawn the process
        String[] commandArray = command.toArray(new String[command.size()]);
        Process pProxy =
            RuntimeProcessFactory.getFactory()
                .exec(commandArray, getEnvironment(config), workingDir, project);
        MessageConsole console = new MessageConsole("Perf Console", null); // $NON-NLS-1$
        console.activate();
        ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
        MessageConsoleStream stream = console.newMessageStream();

        if (pProxy != null) {
          try (BufferedReader error =
              new BufferedReader(new InputStreamReader(pProxy.getErrorStream()))) {
            String err = error.readLine();
            while (err != null) {
              stream.println(err);
              err = error.readLine();
            }
          }
        }

        /* This commented part is the basic method to run perf record without integrating into eclipse.
        String binCall = exePath.toOSString();
        for(String arg : arguments) {
            binCall.concat(" " + arg);
        }
        PerfCore.Run(binCall);*/

        pProxy.destroy();
        PrintStream print = null;
        if (config.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true)) {
          // Get the console to output to.
          // This may not be the best way to accomplish this but it shall do for now.
          ConsolePlugin plugin = ConsolePlugin.getDefault();
          IConsoleManager conMan = plugin.getConsoleManager();
          IConsole[] existing = conMan.getConsoles();
          IOConsole binaryOutCons = null;

          // Find the console
          for (IConsole x : existing) {
            if (x.getName().contains(renderProcessLabel(commandArray[0]))) {
              binaryOutCons = (IOConsole) x;
            }
          }
          if ((binaryOutCons == null)
              && (existing.length
                  != 0)) { // if can't be found get the most recent opened, this should probably
                           // never happen.
            if (existing[existing.length - 1] instanceof IOConsole)
              binaryOutCons = (IOConsole) existing[existing.length - 1];
          }

          // Get the printstream via the outputstream.
          // Get ouput stream
          OutputStream outputTo;
          if (binaryOutCons != null) {
            outputTo = binaryOutCons.newOutputStream();
            // Get the printstream for that console
            print = new PrintStream(outputTo);
          }

          for (int i = 0; i < command.size(); i++) {
            print.print(command.get(i) + " "); // $NON-NLS-1$
          }

          // Print Message
          print.println();
          print.println("Analysing recorded perf.data, please wait..."); // $NON-NLS-1$
          // Possibly should pass this (the console reference) on to PerfCore.Report if theres
          // anything we ever want to spit out to user.
        }
        PerfCore.report(
            config,
            getEnvironment(config),
            Path.fromOSString(configWorkingDir),
            monitor,
            null,
            print);

        URI perfDataURI = null;
        IRemoteFileProxy proxy = null;
        perfDataURI =
            new URI(
                RemoteProxyManager.getInstance().getRemoteProjectLocation(project)
                    + PerfPlugin.PERF_DEFAULT_DATA);
        proxy = RemoteProxyManager.getInstance().getFileProxy(perfDataURI);
        IFileStore perfDataFileStore = proxy.getResource(perfDataURI.getPath());
        IFileInfo info = perfDataFileStore.fetchInfo();
        info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
        perfDataFileStore.putInfo(info, EFS.SET_ATTRIBUTES, null);

        PerfCore.refreshView(renderProcessLabel(exeURI.getPath()));
        if (config.getAttribute(
            PerfPlugin.ATTR_ShowSourceDisassembly, PerfPlugin.ATTR_ShowSourceDisassembly_default)) {
          showSourceDisassembly(
              Path.fromPortableString(workingDirURI.toString() + IPath.SEPARATOR));
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
      abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    } catch (RemoteConnectionException e) {
      e.printStackTrace();
      abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    } catch (URISyntaxException e) {
      e.printStackTrace();
      abort(e.getLocalizedMessage(), null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
    }
  }