Examples of IProject


Examples of org.eclipse.core.resources.IProject

                // 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

Examples of org.eclipse.core.resources.IProject

        return result[0];
    }

    protected IProject createProject(final String projectName)
        throws CoreException {
        final IProject project1 = root.getProject(projectName);

        deleteProject(project1);

        IWorkspaceRunnable create = new IWorkspaceRunnable() {

            public void run(IProgressMonitor monitor) throws CoreException {
                project1.create(null);
                project1.open(null);
            }
        };
        workspace.run(create, null);
        return project1;
    }
View Full Code Here

Examples of org.eclipse.core.resources.IProject

        workspace.run(create, null);
        return project1;
    }

    protected void addJavaNature(String projectName) throws CoreException {
        IProject project1 = root.getProject(projectName);
        IProjectDescription description = project1.getDescription();
        description.setNatureIds(new String[]{JavaCore.NATURE_ID});
        project1.setDescription(description, null);
    }
View Full Code Here

Examples of org.eclipse.core.resources.IProject

   
    private IProject createNewProject() {
        if (newProject != null) {
            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
                .newProjectDescription(newProjectHandle.getName());
        description.setLocation(newPath);
        addNatures(description);

        // create the new project operation
        WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
            protected void execute(IProgressMonitor monitor)
                    throws CoreException {
                createProject(description, newProjectHandle, monitor);
            }
        };

        // run the new project creation operation
        try {
            getContainer().run(true, true, op);
        } catch (InterruptedException e) {
            return null;
        } catch (InvocationTargetException e) {
            Throwable t = e.getTargetException();
            if (t instanceof CoreException) {
                if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
                    MessageDialog.openError(getShell(),
                        "NewProject.errorMessage",
                        "NewProject.caseVariantExistsError"
                                + newProjectHandle.getName());
                } else {
                    ErrorDialog.openError(getShell(),
                        "NewProject.errorMessage", null, // no special message
                        ((CoreException) t).getStatus());
                }
View Full Code Here

Examples of org.eclipse.core.resources.IProject

           
            // also add classpath of required projects
            String[] names = project.getRequiredProjectNames();
            for ( int i = 0; i < names.length; i++ ) {
                String projectName = names[i];
                IProject reqProject = project.getProject().getWorkspace()
                    .getRoot().getProject(projectName);
                if (reqProject != null) {
                    IJavaProject reqJavaProject = JavaCore.create(reqProject);
                    pathElements.addAll(getProjectClassPathURLs(reqJavaProject));
                }
View Full Code Here

Examples of org.eclipse.core.resources.IProject

    public static final String BUILDER_ID = "org.drools.ide.droolsbuilder";

    protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
            throws CoreException {
        IProject currentProject = getProject();
        if (currentProject == null || !currentProject.isAccessible()) {
            return new IProject[0];
        }
        try {
            if (monitor != null && monitor.isCanceled())
                throw new OperationCanceledException();

            if (kind == IncrementalProjectBuilder.FULL_BUILD) {
                fullBuild(monitor);
            } else {
                IResourceDelta delta = getDelta(getProject());
                if (delta == null) {
                    fullBuild(monitor);
                } else {
                    incrementalBuild(delta, monitor);
                }
            }
        } catch (CoreException e) {
            IMarker marker = currentProject.createMarker(IDroolsModelMarker.DROOLS_MODEL_PROBLEM_MARKER);
            marker.setAttribute(IMarker.MESSAGE, "Error when trying to build Drools project: " + e.getLocalizedMessage());
            marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
        }
        return null;
    }
View Full Code Here

Examples of org.eclipse.core.resources.IProject

   
    String[] oldRequired = this.oldResolvedClasspath == null ? CharOperation.NO_STRINGS : this.project.projectPrerequisites(this.oldResolvedClasspath);
    IClasspathEntry[] newResolvedClasspath = this.project.getResolvedClasspath();
    String[] newRequired = this.project.projectPrerequisites(newResolvedClasspath);
    try {
      IProject projectResource = this.project.getProject();
      IProjectDescription description = projectResource.getDescription();
      
      IProject[] projectReferences = description.getDynamicReferences();
     
      HashSet oldReferences = new HashSet(projectReferences.length);
      for (int i = 0; i < projectReferences.length; i++){
        String projectName = projectReferences[i].getName();
        oldReferences.add(projectName);
      }
      HashSet newReferences = (HashSet)oldReferences.clone();
 
      for (int i = 0; i < oldRequired.length; i++){
        String projectName = oldRequired[i];
        newReferences.remove(projectName);
      }
      for (int i = 0; i < newRequired.length; i++){
        String projectName = newRequired[i];
        newReferences.add(projectName);
      }
 
      Iterator iter;
      int newSize = newReferences.size();
     
      checkIdentity: {
        if (oldReferences.size() == newSize){
          iter = newReferences.iterator();
          while (iter.hasNext()){
            if (!oldReferences.contains(iter.next())){
              break checkIdentity;
            }
          }
          return;
        }
      }
      String[] requiredProjectNames = new String[newSize];
      int index = 0;
      iter = newReferences.iterator();
      while (iter.hasNext()){
        requiredProjectNames[index++] = (String)iter.next();
      }
      Util.sort(requiredProjectNames); // ensure that if changed, the order is consistent
     
      IProject[] requiredProjectArray = new IProject[newSize];
      IWorkspaceRoot wksRoot = projectResource.getWorkspace().getRoot();
      for (int i = 0; i < newSize; i++){
        requiredProjectArray[i] = wksRoot.getProject(requiredProjectNames[i]);
      }
      description.setDynamicReferences(requiredProjectArray);
      projectResource.setDescription(description, null);
 
    } catch(CoreException e){
      if (!ExternalJavaProject.EXTERNAL_PROJECT_NAME.equals(this.project.getElementName()))
        throw new JavaModelException(e);
    }
View Full Code Here

Examples of org.eclipse.core.resources.IProject

    ArrayList collector = new ArrayList();
    for (int i = 0, max = elements.length; i < max; i++) {
      // collect all the java project
      IJavaElement element = elements[i];
      IJavaProject javaProject = element.getJavaProject();
      IProject project = javaProject.getProject();
      State state = null;
      State currentState = (State) projectsStates.get(project);
      if (currentState != null) {
        state = currentState;
      } else {
        state = (State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, null);
        if (state != null) {
          projectsStates.put(project, state);
        }
      }
      if (state == null) continue;
      if (element.getElementType() == IJavaElement.JAVA_PROJECT) {
        IPackageFragmentRoot[] roots = null;
        try {
          roots = javaProject.getPackageFragmentRoots();
        } catch (JavaModelException e) {
          // ignore
        }
        if (roots == null) continue;
        IRegion region2 = JavaCore.newRegion();
        for (int j = 0; j < roots.length; j++) {
          region2.add(roots[j]);
        }
        IResource[] res = getGeneratedResources(region2, includesNonJavaResources);
        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();
      }
      if (outputLocation == null) continue;
      IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation);
      switch(element.getElementType()) {
        case IJavaElement.COMPILATION_UNIT :
          // get the .class files generated when this element was built
          ICompilationUnit unit = (ICompilationUnit) element;
          getGeneratedResource(unit, container, state, rootPathSegmentCounts, collector);
View Full Code Here

Examples of org.eclipse.core.resources.IProject

       
        // recurse in project to get all its indirect exports (only consider exported entries from there on)       
        if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
          IResource member = workspaceRoot.findMember(entry.getPath());
          if (member != null && member.getType() == IResource.PROJECT){ // double check if bound to project (23977)
            IProject projRsc = (IProject) member;
            if (JavaProject.hasJavaNature(projRsc)) {
              JavaProject javaProject = (JavaProject) JavaCore.create(projRsc);
              javaProject.computeExpandedClasspath(
                combinedEntry,
                rootIDs,
View Full Code Here

Examples of org.eclipse.core.resources.IProject

        if (!retrieveExportedRoots) return;
        if (referringEntry != null && !resolvedEntry.isExported()) return;

        IResource member = workspaceRoot.findMember(entryPath);
        if (member != null && member.getType() == IResource.PROJECT){// double check if bound to project (23977)
          IProject requiredProjectRsc = (IProject) member;
          if (JavaProject.hasJavaNature(requiredProjectRsc)){ // special builder binary output
            rootIDs.add(rootID);
            JavaProject requiredProject = (JavaProject)JavaCore.create(requiredProjectRsc);
            requiredProject.computePackageFragmentRoots(
              requiredProject.getResolvedClasspath(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.