protected void perfValidate(String filename, int iterations) throws Exception {
    // read in the file
    InputStream in =
        FileLocator.openStream(
            Platform.getBundle(JSCorePlugin.PLUGIN_ID),
            Path.fromPortableString("performance/" + filename),
            false);
    IFile file = project.createFile(filename, IOUtil.read(in));
    RebuildIndexJob job = new RebuildIndexJob(project.getURI());
    job.run(null);

    // Ok now actually validate the thing, the real work
    for (int i = 0; i < iterations; i++) {
      EditorTestHelper.joinBackgroundActivities();

      BuildContext context = new BuildContext(file);
      // Don't measure reading in string...
      context.getContents();

      startMeasuring();
      validator.buildFile(context, null);
      stopMeasuring();
    }
    commitMeasurements();
    assertPerformance();
  }
예제 #2
0
 public static IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException {
   String jre =
       configuration.getAttribute(
           IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null);
   IVMInstall vm = null;
   if (jre == null) {
     String name = configuration.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null);
     if (name == null) {
       name = getDefaultVMInstallName(configuration);
     }
     vm = getVMInstall(name);
     if (vm == null) {
       throw new CoreException(
           LauncherUtils.createErrorStatus(
               NLS.bind(MDEMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
     }
   } else {
     IPath jrePath = Path.fromPortableString(jre);
     vm = JavaRuntime.getVMInstall(jrePath);
     if (vm == null) {
       String id = JavaRuntime.getExecutionEnvironmentId(jrePath);
       if (id == null) {
         String name = JavaRuntime.getVMInstallName(jrePath);
         throw new CoreException(
             LauncherUtils.createErrorStatus(
                 NLS.bind(MDEMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
       }
       throw new CoreException(
           LauncherUtils.createErrorStatus(NLS.bind(MDEMessages.VMHelper_cannotFindExecEnv, id)));
     }
   }
   return vm;
 }
예제 #3
0
  private static void loadFromStream(InputSource inputSource, Map<IPath, String> oldLocations)
      throws CoreException {
    Element cpElement;
    try {
      DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
      parser.setErrorHandler(new DefaultHandler());
      cpElement = parser.parse(inputSource).getDocumentElement();
    } catch (SAXException e) {
      throw createException(e, CorextMessages.JavaDocLocations_error_readXML);
    } catch (ParserConfigurationException e) {
      throw createException(e, CorextMessages.JavaDocLocations_error_readXML);
    } catch (IOException e) {
      throw createException(e, CorextMessages.JavaDocLocations_error_readXML);
    }

    if (cpElement == null) return;
    if (!cpElement.getNodeName().equalsIgnoreCase(NODE_ROOT)) {
      return;
    }
    NodeList list = cpElement.getChildNodes();
    int length = list.getLength();
    for (int i = 0; i < length; ++i) {
      Node node = list.item(i);
      short type = node.getNodeType();
      if (type == Node.ELEMENT_NODE) {
        Element element = (Element) node;
        if (element.getNodeName().equalsIgnoreCase(NODE_ENTRY)) {
          String varPath = element.getAttribute(NODE_PATH);
          String varURL = parseURL(element.getAttribute(NODE_URL)).toExternalForm();

          oldLocations.put(Path.fromPortableString(varPath), varURL);
        }
      }
    }
  }
  @Override
  protected void setUp() throws Exception {
    File baseTempFile = File.createTempFile("test", ".txt"); // $NON-NLS-1$ //$NON-NLS-2$
    baseTempFile.deleteOnExit();

    File baseDirectory = baseTempFile.getParentFile();

    LocalConnectionPoint lcp = new LocalConnectionPoint();
    lcp.setPath(new Path(baseDirectory.getAbsolutePath()));
    clientManager = lcp;

    SFTPConnectionPoint ftpcp = new SFTPConnectionPoint();
    ftpcp.setHost(getConfig().getProperty("sftp.host")); // $NON-NLS-1$
    ftpcp.setLogin(getConfig().getProperty("sftp.username")); // $NON-NLS-1$
    ftpcp.setPassword(getConfig().getProperty("sftp.password").toCharArray());
    ftpcp.setPort(
        Integer.valueOf(getConfig().getProperty("sftp.port", "22"))); // $NON-NLS-1$ //$NON-NLS-2$
    ftpcp.setPath(Path.fromPortableString(getConfig().getProperty("sftp.path"))); // $NON-NLS-1$
    serverManager = ftpcp;

    ConnectionContext context = new ConnectionContext();
    context.put(ConnectionContext.COMMAND_LOG, System.out);
    CoreIOPlugin.setConnectionContext(ftpcp, context);

    fileName = "file name.txt";
    folderName = "folder name";

    super.setUp();
  }
예제 #5
0
  public void testAsPortableString() throws Exception {
    ItemPointer pointer =
        new ItemPointer(
            Path.fromPortableString("c:/temp/a.py"), new Location(1, 2), new Location(3, 4));
    String asPortableString = pointer.asPortableString();
    assertEquals(pointer, ItemPointer.fromPortableString(asPortableString));

    pointer =
        new ItemPointer(
            Path.fromPortableString("c:/temp/a.py"),
            new Location(1, 2),
            new Location(3, 4),
            null,
            "zipLocation");
    asPortableString = pointer.asPortableString();
    assertEquals(pointer, ItemPointer.fromPortableString(asPortableString));
  }
 private static IPath decodePath(String str) {
   if ("#".equals(str)) { // $NON-NLS-1$
     return null;
   } else if ("&".equals(str)) { // $NON-NLS-1$
     return Path.EMPTY;
   } else {
     return Path.fromPortableString(decode(str));
   }
 }
예제 #7
0
 /* (non-Javadoc)
  * @see com.aptana.ide.core.io.ConnectionPoint#loadState(com.aptana.ide.core.io.epl.IMemento)
  */
 @Override
 protected void loadState(IMemento memento) {
   super.loadState(memento);
   IMemento child = memento.getChild(ELEMENT_HOST);
   if (child != null) {
     host = child.getTextData();
   }
   child = memento.getChild(ELEMENT_PORT);
   if (child != null) {
     try {
       port = Integer.parseInt(child.getTextData());
     } catch (NumberFormatException e) {
     }
   }
   child = memento.getChild(ELEMENT_PATH);
   if (child != null) {
     String text = child.getTextData();
     if (text != null) {
       path = Path.fromPortableString(text);
     }
   }
   child = memento.getChild(ELEMENT_LOGIN);
   if (child != null) {
     login = child.getTextData();
   }
   child = memento.getChild(ELEMENT_EXPLICIT);
   if (child != null) {
     explicit = Boolean.parseBoolean(child.getTextData());
   }
   child = memento.getChild(ELEMENT_VALIDATE_CERTIFICATE);
   if (child != null) {
     validateCertificate = Boolean.parseBoolean(child.getTextData());
   }
   child = memento.getChild(ELEMENT_NO_SSL_SESSION_RESUMPTION);
   if (child != null) {
     noSSLSessionResumption = Boolean.parseBoolean(child.getTextData());
   }
   child = memento.getChild(ELEMENT_PASSIVE);
   if (child != null) {
     passiveMode = Boolean.parseBoolean(child.getTextData());
   }
   child = memento.getChild(ELEMENT_TRANSFER_TYPE);
   if (child != null) {
     transferType = child.getTextData();
   }
   child = memento.getChild(ELEMENT_ENCODING);
   if (child != null) {
     encoding = child.getTextData();
   }
   child = memento.getChild(ELEMENT_TIMEZONE);
   if (child != null) {
     timezone = child.getTextData();
   }
 }
  protected static void ensureMetadataJSONExists(IFile moduleFile, IProgressMonitor monitor) {
    IFile mdjson = moduleFile.getParent().getFile(Path.fromPortableString(METADATA_JSON_NAME));
    if (mdjson.exists()) return;

    try {
      OpenBAStream oba = new OpenBAStream();
      PrintStream ps = new PrintStream(oba);
      ps.println("{}");
      ps.close();
      mdjson.create(oba.getInputStream(), IResource.DERIVED, monitor);
    } catch (CoreException e) {
    }
  }
예제 #9
0
 protected String getContent(String path) {
   try {
     InputStream stream =
         FileLocator.openStream(
             Platform.getBundle("com.aptana.xml.core.tests"),
             Path.fromPortableString(path),
             false);
     return IOUtil.read(stream);
   } catch (IOException e) {
     fail(e.getMessage());
     // never reached...
     return StringUtil.EMPTY;
   }
 }
예제 #10
0
 public static void addDialyzerWarningMarker(
     final IProject project, final String filename, final int line, final String message) {
   final IPath projectPath = project.getLocation();
   final String projectPathString = projectPath.toPortableString();
   IResource file;
   if (filename.startsWith(projectPathString)) {
     final String relFilename = filename.substring(projectPathString.length());
     final IPath relPath = Path.fromPortableString(relFilename);
     file = project.findMember(relPath);
   } else {
     file = null;
   }
   MarkerUtils.addDialyzerWarningMarker(file, filename, message, line, IMarker.SEVERITY_WARNING);
 }
예제 #11
0
 private void xmlReadManifest(JarPackageData jarPackage, Element element)
     throws java.io.IOException {
   if (element.getNodeName().equals("manifest")) { // $NON-NLS-1$
     jarPackage.setManifestVersion(element.getAttribute("manifestVersion")); // $NON-NLS-1$
     jarPackage.setUsesManifest(getBooleanAttribute(element, "usesManifest")); // $NON-NLS-1$
     jarPackage.setReuseManifest(getBooleanAttribute(element, "reuseManifest")); // $NON-NLS-1$
     jarPackage.setSaveManifest(getBooleanAttribute(element, "saveManifest")); // $NON-NLS-1$
     jarPackage.setGenerateManifest(
         getBooleanAttribute(element, "generateManifest")); // $NON-NLS-1$
     jarPackage.setManifestLocation(
         Path.fromPortableString(element.getAttribute("manifestLocation"))); // $NON-NLS-1$
     jarPackage.setManifestMainClass(getMainClass(element));
     xmlReadSealingInfo(jarPackage, element);
   }
 }
예제 #12
0
 private void fillTreeItemWithGitDirectory(
     RepositoryMapping m, TreeItem treeItem, boolean isAlternative) {
   if (m.getGitDir() == null)
     treeItem.setText(2, UIText.ExistingOrNewPage_SymbolicValueEmptyMapping);
   else {
     IPath relativePath = new Path(m.getGitDir());
     if (isAlternative) {
       IPath withoutLastSegment = relativePath.removeLastSegments(1);
       IPath path;
       if (withoutLastSegment.isEmpty()) path = Path.fromPortableString("."); // $NON-NLS-1$
       else path = withoutLastSegment;
       treeItem.setText(0, path.toString());
     }
     treeItem.setText(2, relativePath.toOSString());
     try {
       IProject project = m.getContainer().getProject();
       Repository repo =
           new RepositoryBuilder().setGitDir(m.getGitDirAbsolutePath().toFile()).build();
       File workTree = repo.getWorkTree();
       IPath workTreePath = Path.fromOSString(workTree.getAbsolutePath());
       if (workTreePath.isPrefixOf(project.getLocation())) {
         IPath makeRelativeTo = project.getLocation().makeRelativeTo(workTreePath);
         String repoRelativePath =
             makeRelativeTo.append("/.project").toPortableString(); // $NON-NLS-1$
         ObjectId headCommitId = repo.resolve(Constants.HEAD);
         if (headCommitId != null) {
           // Not an empty repo
           RevWalk revWalk = new RevWalk(repo);
           RevCommit headCommit = revWalk.parseCommit(headCommitId);
           RevTree headTree = headCommit.getTree();
           TreeWalk projectInRepo = TreeWalk.forPath(repo, repoRelativePath, headTree);
           if (projectInRepo != null) {
             // the .project file is tracked by this repo
             treeItem.setChecked(true);
           }
           revWalk.dispose();
         }
       }
       repo.close();
     } catch (IOException e1) {
       Activator.logError(UIText.ExistingOrNewPage_FailedToDetectRepositoryMessage, e1);
     }
   }
 }
예제 #13
0
 /*
  * (non-Javadoc)
  * @see com.aptana.ide.core.io.ConnectionPoint#loadState(com.aptana.ide.core.io.epl.IMemento)
  */
 @Override
 protected void loadState(IMemento memento) {
   super.loadState(memento);
   IMemento child = memento.getChild(ELEMENT_HOST);
   if (child != null) {
     host = child.getTextData();
   }
   child = memento.getChild(ELEMENT_PORT);
   if (child != null) {
     try {
       port = Integer.parseInt(child.getTextData());
     } catch (NumberFormatException e) {
     }
   }
   child = memento.getChild(ELEMENT_PATH);
   if (child != null) {
     String text = child.getTextData();
     if (text != null) {
       path = Path.fromPortableString(text);
     }
   }
   child = memento.getChild(ELEMENT_LOGIN);
   if (child != null) {
     login = child.getTextData();
   }
   child = memento.getChild(ELEMENT_PASSIVE);
   if (child != null) {
     passiveMode = Boolean.parseBoolean(child.getTextData());
   }
   child = memento.getChild(ELEMENT_TRANSFER_TYPE);
   if (child != null) {
     transferType = child.getTextData();
   }
   child = memento.getChild(ELEMENT_ENCODING);
   if (child != null) {
     encoding = child.getTextData();
   }
   child = memento.getChild(ELEMENT_TIMEZONE);
   if (child != null) {
     timezone = child.getTextData();
   }
 }
 protected static void createDescriptor() {
   try {
     InputStream descriptorStream =
         ExerciseCParseControllerGenerated.class.getResourceAsStream(DESCRIPTOR);
     InputStream table = ExerciseCParseControllerGenerated.class.getResourceAsStream(TABLE);
     boolean filesystem = false;
     if (descriptorStream == null && new File("./" + DESCRIPTOR).exists()) {
       descriptorStream = new FileInputStream("./" + DESCRIPTOR);
       filesystem = true;
     }
     if (table == null && new File("./" + TABLE).exists()) {
       table = new FileInputStream("./" + TABLE);
       filesystem = true;
     }
     if (descriptorStream == null)
       throw new BadDescriptorException(
           "Could not load descriptor file from "
               + DESCRIPTOR
               + " (not found in plugin: "
               + getPluginLocation()
               + ")");
     if (table == null)
       throw new BadDescriptorException(
           "Could not load parse table from "
               + TABLE
               + " (not found in plugin: "
               + getPluginLocation()
               + ")");
     descriptor =
         DescriptorFactory.load(
             descriptorStream, table, filesystem ? Path.fromPortableString("./") : null);
     descriptor.setAttachmentProvider(ExerciseCParseControllerGenerated.class);
   } catch (BadDescriptorException exc) {
     notLoadingCause = exc;
     Environment.logException("Bad descriptor for " + LANGUAGE + " plugin", exc);
     throw new RuntimeException("Bad descriptor for " + LANGUAGE + " plugin", exc);
   } catch (IOException exc) {
     notLoadingCause = exc;
     Environment.logException("I/O problem loading descriptor for " + LANGUAGE + " plugin", exc);
     throw new RuntimeException("I/O problem loading descriptor for " + LANGUAGE + " plugin", exc);
   }
 }
예제 #15
0
 private void xmlReadOptions(JarPackageData jarPackage, Element element)
     throws java.io.IOException {
   if (element.getNodeName().equals("options")) { // $NON-NLS-1$
     jarPackage.setOverwrite(getBooleanAttribute(element, "overwrite")); // $NON-NLS-1$
     jarPackage.setCompress(getBooleanAttribute(element, "compress")); // $NON-NLS-1$
     jarPackage.setExportErrors(getBooleanAttribute(element, "exportErrors")); // $NON-NLS-1$
     jarPackage.setExportWarnings(getBooleanAttribute(element, "exportWarnings")); // $NON-NLS-1$
     jarPackage.setSaveDescription(getBooleanAttribute(element, "saveDescription")); // $NON-NLS-1$
     jarPackage.setUseSourceFolderHierarchy(
         getBooleanAttribute(element, "useSourceFolders", false)); // $NON-NLS-1$
     jarPackage.setDescriptionLocation(
         Path.fromPortableString(element.getAttribute("descriptionLocation"))); // $NON-NLS-1$
     jarPackage.setBuildIfNeeded(
         getBooleanAttribute(
             element, "buildIfNeeded", jarPackage.isBuildingIfNeeded())); // $NON-NLS-1$
     jarPackage.setIncludeDirectoryEntries(
         getBooleanAttribute(element, "includeDirectoryEntries", false)); // $NON-NLS-1$
     jarPackage.setRefactoringAware(
         getBooleanAttribute(element, "storeRefactorings", false)); // $NON-NLS-1$
   }
 }
예제 #16
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  protected Control createDialogArea(Composite parent) {

    Composite result = (Composite) super.createDialogArea(parent);
    final Button button = new Button(result, SWT.CHECK);
    button.setText(fFilterMessage);
    button.setFont(parent.getFont());

    IDialogSettings settings = PhingUi.getDefault().getDialogSettings();
    fShowAll = settings.getBoolean(DIALOG_SETTING);

    String lastPath = settings.get(LAST_CONTAINER);
    if (lastPath != null) {
      IPath path = Path.fromPortableString(lastPath);
      IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
      setInitialSelection(resource);
    }

    fFilter.considerExtension(!fShowAll);
    getTreeViewer().addFilter(fFilter);
    if (!fShowAll) {
      button.setSelection(true);
    }

    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            if (button.getSelection()) {
              fShowAll = false;
            } else {
              fShowAll = true;
            }
            fFilter.considerExtension(!fShowAll);
            getTreeViewer().refresh();
          }
        });
    applyDialogFont(result);
    return result;
  }
예제 #17
0
  public void testLongOneLiner() throws Exception {
    // read in the file
    InputStream stream =
        FileLocator.openStream(
            Platform.getBundle("com.aptana.editor.json.tests"), // $NON-NLS-1$
            Path.fromPortableString("performance/api-aptana-format.json"),
            false); //$NON-NLS-1$
    String src = IOUtil.read(stream);
    IDocument document = new Document(src);

    // Ok now actually scan the thing, the real work
    for (int i = 0; i < 15; i++) {
      startMeasuring();
      fScanner.setRange(document, 0, src.length());
      while (fScanner.nextToken() != Token.EOF) {
        fScanner.getTokenOffset();
        fScanner.getTokenLength();
      }
      stopMeasuring();
    }
    commitMeasurements();
    assertPerformance();
  }
예제 #18
0
 protected void loadState(IMemento memento) {
   IMemento child = memento.getChild(ELEMENT_NAME);
   if (child != null) {
     name = child.getTextData();
   }
   child = memento.getChild(ELEMENT_SOURCE);
   if (child != null) {
     URI uri = URI.create(child.getTextData());
     sourceConnectionPoint = ConnectionPointUtils.findConnectionPoint(uri);
     if (sourceConnectionPoint == null) {
       IdeLog.logWarning(
           SyncingPlugin.getDefault(),
           "Failed to load source connection point from URI " + uri, // $NON-NLS-1$
           IDebugScopes.DEBUG);
     }
   }
   child = memento.getChild(ELEMENT_DESTINATION);
   if (child != null) {
     URI uri = URI.create(child.getTextData());
     destinationConnectionPoint = ConnectionPointUtils.findConnectionPoint(uri);
     if (destinationConnectionPoint == null) {
       IdeLog.logWarning(
           SyncingPlugin.getDefault(),
           "Failed to load destination connection point from URI " + uri, // $NON-NLS-1$
           IDebugScopes.DEBUG);
     }
   }
   child = memento.getChild(ELEMENT_EXCLUDES);
   if (child != null) {
     for (IMemento i : child.getChildren(ELEMENT_PATH)) {
       excludes.add(Path.fromPortableString(i.getTextData()));
     }
     for (IMemento i : child.getChildren(ELEMENT_WILDCARD)) {
       excludes.add(i.getTextData());
     }
   }
 }
  protected void perfValidate(String filename, int iterations) throws Exception {
    // read in the file
    URL url =
        FileLocator.find(
            Platform.getBundle(JSCorePlugin.PLUGIN_ID),
            Path.fromPortableString("performance/" + filename),
            null);
    File file = ResourceUtil.resourcePathToFile(url);
    IFileStore fileStore = EFS.getStore(file.toURI());

    // Ok now actually validate the thing, the real work
    for (int i = 0; i < iterations; i++) {
      EditorTestHelper.joinBackgroundActivities();

      // Force a re-parse every time so we're comparing apples to apples for JSLint
      BuildContext context =
          new FileStoreBuildContext(fileStore) {
            @Override
            protected ParseResult parse(
                String contentType, IParseState parseState, WorkingParseResult working)
                throws Exception {
              if (reparseEveryTime()) {
                return new JSParser().parse(parseState);
              }
              return super.parse(contentType, parseState, working);
            }
          };
      // Don't measure reading in string...
      context.getContents();

      startMeasuring();
      validator.buildFile(context, null);
      stopMeasuring();
    }
    commitMeasurements();
    assertPerformance();
  }
예제 #20
0
 /**
  * Get version for the specified Firefox extension ID
  *
  * @param extensionID
  * @param profileDir
  * @return
  */
 public static String getExtensionVersion(String extensionID, IPath profileDir) {
   try {
     IPath dir = profileDir.append("extensions").append(extensionID); // $NON-NLS-1$
     InputStream rdfInputStream = null;
     if (dir.toFile().isFile()) {
       dir = Path.fromOSString(IOUtil.read(new FileInputStream(dir.toFile())));
     }
     if (dir.toFile().isDirectory()) {
       File installRdf = dir.append("install.rdf").toFile(); // $NON-NLS-1$
       if (installRdf.exists()) {
         rdfInputStream = new FileInputStream(installRdf);
       }
     } else if (dir.addFileExtension("xpi").toFile().isFile()) // $NON-NLS-1$
     {
       rdfInputStream =
           ZipUtil.openEntry(
               dir.addFileExtension("xpi").toFile(), // $NON-NLS-1$
               Path.fromPortableString("install.rdf")); // $NON-NLS-1$
     }
     if (rdfInputStream != null) {
       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
       DocumentBuilder parser = factory.newDocumentBuilder();
       Document document = parser.parse(rdfInputStream);
       Node node = document.getDocumentElement().getFirstChild();
       while (node != null) {
         if ("description".equals(node.getNodeName().toLowerCase()) // $NON-NLS-1$
             || "rdf:description".equals(node.getNodeName().toLowerCase())) { // $NON-NLS-1$
           NamedNodeMap attrs = node.getAttributes();
           Node about = attrs.getNamedItem("about"); // $NON-NLS-1$
           if (about == null) {
             about = attrs.getNamedItem("RDF:about"); // $NON-NLS-1$
           }
           if (about != null) {
             if ("urn:mozilla:install-manifest".equals(about.getNodeValue())) { // $NON-NLS-1$
               break;
             }
           }
         }
         node = node.getNextSibling();
       }
       if (node != null) {
         NamedNodeMap attrs = node.getAttributes();
         Node version = attrs.getNamedItem("em:version"); // $NON-NLS-1$
         if (version != null) {
           return version.getNodeValue();
         }
         node = node.getFirstChild();
       }
       while (node != null) {
         if ("em:version".equals(node.getNodeName().toLowerCase())) { // $NON-NLS-1$
           break;
         }
         node = node.getNextSibling();
       }
       if (node != null) {
         return node.getTextContent();
       }
     }
   } catch (Exception e) {
     IdeLog.logError(CorePlugin.getDefault(), e.getMessage(), e);
   }
   return null;
 }
예제 #21
0
 private void xmlReadJarLocation(JarPackageData jarPackage, Element element) {
   if (element.getNodeName().equals(JarPackagerUtil.JAR_EXTENSION))
     jarPackage.setJarLocation(
         Path.fromPortableString(element.getAttribute("path"))); // $NON-NLS-1$
 }
  @Override
  protected void updateProject(IProgressMonitor monitor)
      throws CoreException, InterruptedException {

    IProject projectHandle = fFirstPage.getProjectHandle();
    IScriptProject create = DLTKCore.create(projectHandle);
    super.init(create, null, false);
    fCurrProjectLocation = getProjectLocationURI();

    boolean installSymfony = true;

    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    try {
      monitor.beginTask(NewWizardMessages.ScriptProjectWizardSecondPage_operation_initialize, 70);
      if (monitor.isCanceled()) {
        throw new OperationCanceledException();
      }

      URI realLocation = fCurrProjectLocation;
      if (fCurrProjectLocation == null) { // inside workspace
        try {
          URI rootLocation = ResourcesPlugin.getWorkspace().getRoot().getLocationURI();
          realLocation =
              new URI(
                  rootLocation.getScheme(),
                  null,
                  Path.fromPortableString(rootLocation.getPath())
                      .append(getProject().getName())
                      .toString(),
                  null);
        } catch (URISyntaxException e) {
          Assert.isTrue(false, "Can't happen"); // $NON-NLS-1$
        }
      }

      rememberExistingFiles(realLocation);

      createProject(getProject(), fCurrProjectLocation, new SubProgressMonitor(monitor, 20));

      IBuildpathEntry[] buildpathEntries = null;
      IncludePath[] includepathEntries = null;

      SymfonyProjectWizardFirstPage firstPage = (SymfonyProjectWizardFirstPage) fFirstPage;

      if (firstPage.getDetect()) {

        installSymfony = false;
        includepathEntries = setProjectBaseIncludepath();
        if (!getProject().getFile(FILENAME_BUILDPATH).exists()) {

          IDLTKLanguageToolkit toolkit = DLTKLanguageManager.getLanguageToolkit(getScriptNature());
          final BuildpathDetector detector = createBuildpathDetector(monitor, toolkit);
          buildpathEntries = detector.getBuildpath();

        } else {
          monitor.worked(20);
        }
      } else if (firstPage.hasSymfonyStandardEdition()) {

        // flat project layout
        IPath projectPath = getProject().getFullPath();
        List cpEntries = new ArrayList();
        cpEntries.add(DLTKCore.newSourceEntry(projectPath));

        //				buildpathEntries = (IBuildpathEntry[]) cpEntries
        //						.toArray(new IBuildpathEntry[cpEntries.size()]);
        //				includepathEntries = setProjectBaseIncludepath();

        buildpathEntries = new IBuildpathEntry[0];
        includepathEntries = new IncludePath[0];

        monitor.worked(20);

      } else {
        // flat project layout
        IPath projectPath = getProject().getFullPath();
        List cpEntries = new ArrayList();
        cpEntries.add(DLTKCore.newSourceEntry(projectPath));

        //				buildpathEntries = (IBuildpathEntry[]) cpEntries
        //						.toArray(new IBuildpathEntry[cpEntries.size()]);
        //				includepathEntries = setProjectBaseIncludepath();

        buildpathEntries = new IBuildpathEntry[0];
        includepathEntries = new IncludePath[0];

        monitor.worked(20);
      }
      if (monitor.isCanceled()) {
        throw new OperationCanceledException();
      }

      init(DLTKCore.create(getProject()), buildpathEntries, false);

      // setting PHP4/5 and ASP-Tags :
      setPhpLangOptions();

      configureScriptProject(new SubProgressMonitor(monitor, 30));

      SymfonyProjectWizardFirstPage p = (SymfonyProjectWizardFirstPage) getFirstPage();

      // checking and adding JS nature,libs, include path if needed
      if (p.shouldSupportJavaScript()) {
        addJavaScriptNature(monitor);
      }

      // adding build paths, and language-Container:
      getScriptProject().setRawBuildpath(buildpathEntries, new NullProgressMonitor());
      LanguageModelInitializer.enableLanguageModelFor(getScriptProject());

      // init, and adding include paths:
      getBuildPathsBlock().init(getScriptProject(), new IBuildpathEntry[] {});
      IncludePathManager.getInstance().setIncludePath(getProject(), includepathEntries);

      if (installSymfony) installSymfony(new SubProgressMonitor(monitor, 50));

    } finally {
      monitor.done();
    }
  }
예제 #23
0
  protected void initialiseStoriesfromConfiguration(ILaunchConfiguration config) {

    try {
      String containerHandle =
          config.getAttribute(ILaunchConstants.LAUNCH_ATTR_CONTAINER_HANDLE, "");

      if (!StringUtils.isBlank(containerHandle)) {
        container = JavaCore.create(containerHandle);
        txtMultiStories.setText(container.getElementName());
      }

    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set project,resource or package name for launch", ce);
      setErrorMessage("Unable to set project,folder or package for stories from configuration");
    }

    try {
      String storyProjectPath = config.getAttribute(ILaunchConstants.LAUNCH_ATTR_STORY_PATH, "");

      IPath path = null;
      if (!StringUtils.isBlank(storyProjectPath)) {
        path = Path.fromPortableString(storyProjectPath);
      }

      IJavaProject javaProject = getJavaProject();

      if (javaProject != null) {
        IProject project = javaProject.getProject();
        if (project.findMember(path) instanceof IFile) {
          storyFile = (IFile) project.findMember(path);
        } else {
          setErrorMessage("Unable to locate " + storyProjectPath + " in project");
        }
      } else {
        setErrorMessage("No project has been set for story");
      }

      if (storyFile != null) {
        txtStory.setText(storyFile.getName());
      } else if (!StringUtils.isBlank(storyProjectPath)) {
        txtStory.setText(storyProjectPath);
      }

    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set story for launch", ce);
      setErrorMessage("Unable to set story for launch");
    }

    try {
      boolean isSingleStory =
          config.getAttribute(ILaunchConstants.LAUNCH_ATTR_IS_SINGLE_STORY, true);
      setEnableSingleStory(isSingleStory);
      setEnableProject(isSingleStory);
      setEnableMultiStory(!isSingleStory);

      btnRadioSingleStory.setSelection(isSingleStory);
      btnRadioMultiStory.setSelection(!isSingleStory);

    } catch (CoreException ce) {
      EasybLaunchActivator.Log("Unable to set single or multi story radio buttons", ce);
      setErrorMessage("Unable to set single or multi story radio buttons");
    }
  }
예제 #24
0
파일: SDK.java 프로젝트: petrep/liferay-ide
 public void loadFromMemento(XMLMemento sdkElement) {
   setName(sdkElement.getString("name")); // $NON-NLS-1$
   setLocation(Path.fromPortableString(sdkElement.getString("location"))); // $NON-NLS-1$
   // setRuntime(sdkElement.getString("runtime"));
 }
 public static IPath convertCygpath(IPath path) {
   String pathStr = path.toPortableString();
   String newPathStr = Cygwin.cygwinToWindowsPath(pathStr);
   IPath newPath = Path.fromPortableString(newPathStr);
   return newPath;
 }
예제 #26
0
 /**
  * Returns the package fragment root corresponding to a given resource path.
  *
  * @param resourcePathString path of expected package fragment root.
  * @return the {@link IProjectFragment package fragment root} which path match the given one or
  *     <code>null</code> if none was found.
  */
 public IProjectFragment projectFragment(String resourcePathString) {
   int index = -1;
   int separatorIndex = resourcePathString.indexOf(FILE_ENTRY_SEPARATOR);
   boolean isZIPFile = separatorIndex != -1;
   boolean isSpecial = resourcePathString.startsWith(IBuildpathEntry.BUILDPATH_SPECIAL);
   if (isZIPFile) {
     // internal or external jar (case 3, 4, or 5)
     String zipPath = resourcePathString.substring(0, separatorIndex);
     String relativePath = resourcePathString.substring(separatorIndex + 1);
     index = indexOf(zipPath, relativePath);
   } else {
     // resource in workspace (case 1 or 2)
     index = indexOf(resourcePathString);
   }
   if (index >= 0) {
     int idx = projectIndexes[index];
     String projectPath = idx == -1 ? null : (String) this.projectPaths.get(idx);
     if (projectPath != null) {
       IScriptProject project =
           DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject(projectPath));
       if (isZIPFile) {
         return project.getProjectFragment(this.containerPaths[index]);
       }
       if (isSpecial) {
         return project.getProjectFragment(this.containerPaths[index]);
       }
       Object target =
           Model.getTarget(
               ResourcesPlugin.getWorkspace().getRoot(),
               Path.fromPortableString(
                   this.containerPaths[index] + '/' + this.relativePaths[index]),
               false);
       if (target instanceof IProject) {
         return project.getProjectFragment((IProject) target);
       }
       if (target instanceof IResource) {
         IModelElement element = DLTKCore.create((IResource) target);
         return (IProjectFragment) element.getAncestor(IModelElement.PROJECT_FRAGMENT);
       }
       if (target instanceof IFileHandle) {
         try {
           IProjectFragment[] fragments = project.getProjectFragments();
           IFileHandle t = (IFileHandle) target;
           IPath absPath = t.getFullPath();
           for (int i = 0; i < fragments.length; ++i) {
             IProjectFragment f = fragments[i];
             if (f.isExternal()) {
               IPath pPath = f.getPath();
               if (pPath.isPrefixOf(absPath) && !Util.isExcluded(absPath, f, t.isDirectory())) {
                 return f;
               }
             }
           }
         } catch (ModelException e) {
           e.printStackTrace();
           return null;
         }
       }
     }
   }
   return null;
 }
예제 #27
0
 private IPath getPath(Element element) throws IOException {
   String pathString = element.getAttribute("path"); // $NON-NLS-1$
   if (pathString.length() == 0)
     throw new IOException(JarPackagerMessages.JarPackageReader_error_tagPathNotFound);
   return Path.fromPortableString(element.getAttribute("path")); // $NON-NLS-1$
 }
예제 #28
0
/** @author Max Stepanov */
@SuppressWarnings("nls")
public class FTPSConnectionPointTest {

  private static final String name = "My FTPS Site";
  private static final String host = "127.0.0.1";
  private static final int port = 2222;
  private static final String login = "******";
  private static final char[] password = "******".toCharArray();
  private static final IPath path = Path.fromPortableString("/home/user");
  private static final String encoding = "UTF-8";
  private static final boolean passiveMode = true;
  private static final String timezone = "GMT";
  private static final String transferType = IFTPConstants.TRANSFER_TYPE_BINARY;
  private static final boolean explicit = false;
  private static final boolean noSSLSessionResumption = false;
  private static final boolean validateCertificate = false;

  @Test
  public void testPersistance() {
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        explicit,
        noSSLSessionResumption,
        validateCertificate);
  }

  @Test
  public void testPassiveMode() {
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        true,
        timezone,
        transferType,
        explicit,
        noSSLSessionResumption,
        validateCertificate);
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        false,
        timezone,
        transferType,
        explicit,
        noSSLSessionResumption,
        validateCertificate);
  }

  @Test
  public void testTransferTypes() {
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        IFTPConstants.TRANSFER_TYPE_ASCII,
        explicit,
        noSSLSessionResumption,
        validateCertificate);
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        IFTPConstants.TRANSFER_TYPE_BINARY,
        explicit,
        noSSLSessionResumption,
        validateCertificate);
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        IFTPConstants.TRANSFER_TYPE_AUTO,
        explicit,
        noSSLSessionResumption,
        validateCertificate);
  }

  @Test
  public void testExplicitMode() {
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        true,
        noSSLSessionResumption,
        validateCertificate);
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        false,
        noSSLSessionResumption,
        validateCertificate);
  }

  @Test
  public void testSSLSessionResumptionMode() {
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        explicit,
        true,
        validateCertificate);
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        explicit,
        false,
        validateCertificate);
  }

  @Test
  public void testValidateCertificateMode() {
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        explicit,
        noSSLSessionResumption,
        true);
    createAndTestConnectionPoint(
        name,
        host,
        port,
        login,
        password,
        path,
        encoding,
        passiveMode,
        timezone,
        transferType,
        explicit,
        noSSLSessionResumption,
        false);
  }

  @Test
  public void testExplicitModeDefaultPort() {
    FTPSConnectionPoint cp = new FTPSConnectionPoint();
    cp.setExplicit(true);
    assertEquals(
        "Default explicit port doesn't match", IFTPSConstants.FTP_PORT_DEFAULT, cp.getPort());
  }

  @Test
  public void testImplicitModeDefaultPort() {
    FTPSConnectionPoint cp = new FTPSConnectionPoint();
    cp.setExplicit(false);
    assertEquals(
        "Default implicit port doesn't match", IFTPSConstants.FTPS_IMPLICIT_PORT, cp.getPort());
  }

  private static void createAndTestConnectionPoint(
      String name,
      String host,
      int port,
      String login,
      char[] password,
      IPath path,
      String encoding,
      boolean passiveMode,
      String timezone,
      String transferType,
      boolean explicit,
      boolean noSSLSessionResumption,
      boolean validateCertificate) {
    FTPSConnectionPoint cp = new FTPSConnectionPoint();
    cp.setName(name);
    cp.setHost(host);
    cp.setPort(port);
    cp.setLogin(login);
    cp.setPassword(password);
    cp.setPassiveMode(passiveMode);
    cp.setPath(path);
    cp.setTimezone(timezone);
    cp.setTransferType(transferType);
    cp.setEncoding(encoding);
    cp.setExplicit(explicit);
    cp.setNoSSLSessionResumption(noSSLSessionResumption);
    cp.setValidateCertificate(validateCertificate);

    XMLMemento root = XMLMemento.createWriteRoot("root");
    IMemento memento = root.createChild("item");
    cp.saveState(memento);

    cp = new FTPSConnectionPoint();
    cp.loadState(memento);
    assertEquals("Name doesn't match", name, cp.getName());
    assertEquals("Host doesn't match", host, cp.getHost());
    assertEquals("Port doesn't match", port, cp.getPort());
    assertEquals("Login doesn't match", login, cp.getLogin());
    assertEquals("Password should not be persistent", null, cp.getPassword());
    assertEquals("Passive mode doesn't match", passiveMode, cp.isPassiveMode());
    assertEquals("Path doesn't match", path, cp.getPath());
    assertEquals("Timezone doesn't match", timezone, cp.getTimezone());
    assertEquals("Transfer type doesn't match", transferType, cp.getTransferType());
    assertEquals("Encoding doesn't match", encoding, cp.getEncoding());
    assertEquals("Explicit mode doesn't match", explicit, cp.isExplicit());
    assertEquals(
        "No SSL resumption mode doesn't match",
        noSSLSessionResumption,
        cp.isNoSSLSessionResumption());
    assertEquals(
        "Validate certificate mode doesn't match", validateCertificate, cp.isValidateCertificate());
  }
}
  /**
   * Creates a locale specific properties file within the fragment project based on the content of
   * the host plug-in's properties file.
   *
   * @param fragmentProject
   * @param locale
   * @throws CoreException
   * @throws IOException
   */
  private void createLocaleSpecificPropertiesFile(
      final IProject fragmentProject, IPluginModelBase plugin, final Locale locale)
      throws CoreException, IOException {
    final IFolder localeResourceFolder =
        fragmentProject.getFolder(RESOURCE_FOLDER_PARENT).getFolder(locale.toString());

    // Case 1: External plug-in
    if (plugin instanceof ExternalPluginModelBase) {
      final String installLocation = plugin.getInstallLocation();
      // Case 1a: External plug-in is a jar file
      if (new File(installLocation).isFile()) {
        ZipFile zf = new ZipFile(installLocation);
        for (Enumeration e = zf.entries(); e.hasMoreElements(); ) {
          worked();

          ZipEntry zfe = (ZipEntry) e.nextElement();
          String name = zfe.getName();

          String[] segments = name.split(SLASH);
          IPath path = Path.fromPortableString(join(SLASH, segments, 0, segments.length - 1));
          String resourceName = segments[segments.length - 1];
          String localizedResourceName = localeSpecificName(resourceName, locale);
          if (propertiesFilter.include(name)) {

            createParents(fragmentProject, path);
            IFile file = fragmentProject.getFile(path.append(localizedResourceName));
            InputStream is = zf.getInputStream(zfe);
            file.create(is, false, getProgressMonitor());
          } else if (resourceFilter.include(name)) {
            IPath target = localeResourceFolder.getFullPath().append(path).append(resourceName);
            createParents(fragmentProject, target.removeLastSegments(1).removeFirstSegments(1));
            IFile file = fragmentProject.getFile(target.removeFirstSegments(1));
            file.create(zf.getInputStream(zfe), false, getProgressMonitor());
          }
        }
      }
      // Case 1b: External plug-in has a folder structure
      else {
        Visitor visitor =
            new Visitor() {
              public void visit(File file) throws CoreException, FileNotFoundException {
                worked();

                String relativePath =
                    file.getAbsolutePath()
                        .substring(installLocation.length())
                        .replaceAll(File.separator, SLASH);
                String[] segments = relativePath.split(SLASH);
                IPath path = Path.fromPortableString(join(SLASH, segments, 0, segments.length - 1));
                String resourceName = segments[segments.length - 1];
                String localizedResourceName = localeSpecificName(resourceName, locale);

                if (propertiesFilter.include(
                    relativePath + (file.isDirectory() ? SLASH : EMPTY_STRING))) {
                  createParents(fragmentProject, path);
                  IFile iFile = fragmentProject.getFile(path.append(localizedResourceName));
                  iFile.create(new FileInputStream(file), false, getProgressMonitor());
                } else if (resourceFilter.include(
                    relativePath + (file.isDirectory() ? SLASH : EMPTY_STRING))) {
                  IPath target = localeResourceFolder.getFullPath().append(relativePath);
                  createParents(
                      fragmentProject, target.removeLastSegments(1).removeFirstSegments(1));
                  IFile iFile = fragmentProject.getFile(target.removeFirstSegments(1));
                  iFile.create(new FileInputStream(file), false, getProgressMonitor());
                }

                if (file.isDirectory()) {
                  File[] children = file.listFiles();
                  for (int i = 0; i < children.length; i++) {
                    visit(children[i]);
                  }
                }
              }
            };

        visitor.visit(new File(installLocation));
      }
    }
    // Case 2: Workspace plug-in
    else {
      final IProject project = plugin.getUnderlyingResource().getProject();

      project.accept(
          new IResourceVisitor() {
            public boolean visit(IResource resource) throws CoreException {
              worked();

              IPath parent = resource.getFullPath().removeLastSegments(1).removeFirstSegments(1);
              if (propertiesFilter.include(resource)) {
                String segment = localeSpecificName(resource.getFullPath().lastSegment(), locale);
                IPath fragmentResource =
                    fragmentProject.getFullPath().append(parent).append(segment);

                createParents(fragmentProject, parent);
                resource.copy(fragmentResource, true, getProgressMonitor());
              } else if (resourceFilter.include(resource)) {
                IPath target =
                    localeResourceFolder
                        .getFullPath()
                        .append(parent)
                        .append(resource.getFullPath().lastSegment());
                createParents(fragmentProject, target.removeLastSegments(1).removeFirstSegments(1));
                resource.copy(target, true, getProgressMonitor());
              }
              return true;
            }
          });
    }
  }
  @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);
    }
  }