Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.IPath


        IJavaProject project = getJavaProject();
        if (project == null) {
            return null;
        }
        IPath path = new Path(rootPath);
        if (path.isAbsolute()) {
            IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace()
                .getRoot();
            IResource resource = workspaceRoot.findMember(path);
            IPackageFragmentRoot root1;
            if (resource == null) {
View Full Code Here


                // set java nature
                addJavaNature(projectName);

                // create classpath entries
                IProject project = root.getProject(projectName);
                IPath projectPath = project.getFullPath();
                int sourceLength = sourceFolders.length;
                int libLength = libraries.length;

                IClasspathEntry[] entries = new IClasspathEntry[sourceLength
                    + libLength];
                for (int i = 0; i < sourceLength; i++) {
                    IPath sourcePath = new Path(sourceFolders[i]);
                    int segmentCount = sourcePath.segmentCount();
                    if (segmentCount > 0) {
                        // create folder and its parents
                        IContainer container = project;
                        for (int j = 0; j < segmentCount; j++) {
                            IFolder folder = container.getFolder(new Path(
                                sourcePath.segment(j)));
                            if (!folder.exists()) {
                                folder.create(true, true, null);
                            }
                            container = folder;
                        }
                    }

                    // create source entry
                    entries[i] = JavaCore.newSourceEntry(
                        projectPath.append(sourcePath), new IPath[0],
                        new IPath[0], null);
                }

                for (int i = 0; i < libLength; i++) {
                    String lib = libraries[i];
                    if (lib.startsWith("JCL")) {
                        // ensure JCL variables are set
                         try {
                            setUpJCLClasspathVariables(compliance);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }

                    if (lib.indexOf(File.separatorChar) == -1
                        && lib.charAt(0) != '/'
                        && lib.equals(lib.toUpperCase())) { // all upper case is a var
                        char[][] vars = CharOperation.splitOn(',', lib
                            .toCharArray());
                        entries[sourceLength + i] = JavaCore.newVariableEntry(
                            new Path(new String(vars[0])), vars.length > 1
                                ? new Path(new String(vars[1]))
                                : null, vars.length > 2
                                ? new Path(new String(vars[2]))
                                : null);
                    } else {
                        IPath libPath = new Path(lib);
                        if (!libPath.isAbsolute() && libPath.segmentCount() > 0
                            && libPath.getFileExtension() == null) {
                            project.getFolder(libPath).create(true, true, null);
                            libPath = projectPath.append(libPath);
                        }
                        entries[sourceLength + i] = JavaCore.newLibraryEntry(
                            libPath, null, null, ClasspathEntry.getAccessRules(
                                new IPath[0], new IPath[0]),
                            new IClasspathAttribute[0], false);
                    }
                }

                // create project's output folder
                IPath outputPath = new Path(projectOutput);
                if (outputPath.segmentCount() > 0) {
                    IFolder output = project.getFolder(outputPath);
                    if (!output.exists()) {
                        output.create(true, true, null);
                    }
                }
View Full Code Here

        options.put(CompilerOptions.OPTION_TargetPlatform, version);
        javaProject.setOptions(options);

        // replace JCL_LIB with JCL15_LIB, and JCL_SRC with JCL15_SRC
        IClasspathEntry[] classpath = javaProject.getRawClasspath();
        IPath jclLib = new Path(jclLibString);
        for (int i = 0, length = classpath.length; i < length; i++) {
            IClasspathEntry entry = classpath[i];
            if (entry.getPath().equals(jclLib)) {
                classpath[i] = JavaCore.newVariableEntry(
                    new Path(newJclLibString), null, entry
View Full Code Here

            return newProject;
        }
        final IProject newProjectHandle = mainPage.getProjectHandle();

        // get a project descriptor
        IPath newPath = null;
        if (!mainPage.useDefaults())
            newPath = mainPage.getLocationPath();

        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        final IProjectDescription description = workspace
View Full Code Here

   
    private void createOutputLocation(IJavaProject project)
            throws JavaModelException, CoreException {
        IFolder ifolder = project.getProject().getFolder("bin");
        createFolder(ifolder);
        IPath ipath = ifolder.getFullPath();
        project.setOutputLocation(ipath, null);
    }
View Full Code Here

                        URL url = getRawLocationURL(path.getPath());
                        pathElements.add(url);
                    }
                }
            }
            IPath location = getProjectLocation(project.getProject());
            IPath outputPath = location.append(project.getOutputLocation()
                    .removeFirstSegments(1));
            pathElements.add(outputPath.toFile().toURL());
           
            // also add classpath of required projects
            String[] names = project.getRequiredProjectNames();
            for ( int i = 0; i < names.length; i++ ) {
                String projectName = names[i];
View Full Code Here

   
      // filter out unmodified variables
      int discardCount = 0;
      for (int i = 0; i < varLength; i++){
        String variableName = this.variableNames[i];
        IPath oldPath = manager.variableGet(variableName); // if reentering will provide previous session value
        if (oldPath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS) {
          oldPath = null//33695 - cannot filter out restored variable, must update affected project to reset cached CP
        }
        if (oldPath != null && oldPath.equals(this.variablePaths[i])){
          this.variableNames[i] = null;
          discardCount++;
        }
      }
      if (discardCount > 0){
        if (discardCount == varLength) return;
        int changedLength = varLength - discardCount;
        String[] changedVariableNames = new String[changedLength];
        IPath[] changedVariablePaths = new IPath[changedLength];
        for (int i = 0, index = 0; i < varLength; i++){
          if (this.variableNames[i] != null){
            changedVariableNames[index] = this.variableNames[i];
            changedVariablePaths[index] = this.variablePaths[i];
            index++;
          }
        }
        this.variableNames = changedVariableNames;
        this.variablePaths = changedVariablePaths;
        varLength = changedLength;
      }
     
      if (isCanceled())
        return;
 
      IJavaProject[] projects = model.getJavaProjects();
      nextProject : for (int i = 0, projectLength = projects.length; i < projectLength; i++){
        JavaProject project = (JavaProject) projects[i];
           
        // check to see if any of the modified variables is present on the classpath
        IClasspathEntry[] classpath = project.getRawClasspath();
        for (int j = 0, cpLength = classpath.length; j < cpLength; j++){
         
          IClasspathEntry entry = classpath[j];
          for (int k = 0; k < varLength; k++){
 
            String variableName = this.variableNames[k];           
            if (entry.getEntryKind() ==  IClasspathEntry.CPE_VARIABLE){
 
              if (variableName.equals(entry.getPath().segment(0))){
                affectedProjectClasspaths.put(project, project.getResolvedClasspath());
                continue nextProject;
              }
              IPath sourcePath, sourceRootPath;
              if (((sourcePath = entry.getSourceAttachmentPath()) != null  && variableName.equals(sourcePath.segment(0)))
                || ((sourceRootPath = entry.getSourceAttachmentRootPath()) != null  && variableName.equals(sourceRootPath.segment(0)))) {
 
                affectedProjectClasspaths.put(project, project.getResolvedClasspath());
                continue nextProject;
              }
View Full Code Here

      ArrayList collector) {
    for (int i = 0, max = nonJavaResources.length; i < max; i++) {
      Object nonJavaResource = nonJavaResources[i];
      if (nonJavaResource instanceof IFile) {
        IFile file = (IFile) nonJavaResource;
        IPath path = file.getFullPath().removeFirstSegments(rootPathSegmentCounts);
        IResource member = container.findMember(path);
        if (member != null && member.exists()) {
          collector.add(member);
        }
      } else if (nonJavaResource instanceof IFolder) {
View Full Code Here

   * @see #setClasspathVariable(String, IPath)
   */
  public static IPath getClasspathVariable(final String variableName) {

      JavaModelManager manager = JavaModelManager.getJavaModelManager();
    IPath variablePath = manager.variableGet(variableName);
    if (variablePath == JavaModelManager.VARIABLE_INITIALIZATION_IN_PROGRESS){
        return manager.getPreviousSessionVariable(variableName);
    }

    if (variablePath != null) {
View Full Code Here

        for (int j = 0, max2 = res.length; j < max2; j++) {
          collector.add(res[j]);
        }
        continue;
      }
      IPath outputLocation = null;
      try {
        outputLocation = javaProject.getOutputLocation();
      } catch (JavaModelException e) {
        // ignore
      }
      IJavaElement root = element;
      while (root != null && root.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
        root = root.getParent();
      }
      if (root == null) continue;
      IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) root;
      int rootPathSegmentCounts = packageFragmentRoot.getPath().segmentCount();
      try {
        IClasspathEntry entry = packageFragmentRoot.getRawClasspathEntry();
        IPath entryOutputLocation = entry.getOutputLocation();
        if (entryOutputLocation != null) {
          outputLocation = entryOutputLocation;
        }
      } catch (JavaModelException e) {
        e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.IPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.