Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IProject


    }
 
 
  public static WGARuntime getRuntime(String name){
   
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
    try {
      if(project.isAccessible() && project.hasNature(NATURE_WGA_RUNTIME)){
        return (WGARuntime) project.getNature(NATURE_WGA_RUNTIME);
      }else {
        return null;
      }
    } catch (CoreException e) {
      return null;
View Full Code Here


   * @return
   */
  public static Map<String, WGADesign> getAllDesigns() {

    Map<String, WGADesign> allWGADesigns = new HashMap<String, WGADesign>();
    IProject tmp[] = null;
    tmp = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < tmp.length; i++) {
      try {
        if (tmp[i].hasNature(NATURE_WGA_DESIGN)) {
          allWGADesigns.put(tmp[i].getName(), (WGADesign) tmp[i].getNature(NATURE_WGA_DESIGN));
View Full Code Here

    List<IJavaProject> javaProjectList = new ArrayList<IJavaProject>();
    StringBuffer traceBuffer = new StringBuffer();   
    traceBuffer.append("Projects in source path :\n");
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i=0; i < projects.length; i++) {
      IProject project = projects[i];
      if ((project.isOpen()) && project.hasNature(JavaCore.NATURE_ID)) {
        javaProjectList.add((IJavaProject)project.getNature(JavaCore.NATURE_ID));
      }
    }

    List<ISourceContainer> sourceContainers = new ArrayList<ISourceContainer>();

    if (!javaProjectList.isEmpty()) {
      IJavaProject[] javaProjects = javaProjectList.toArray(new IJavaProject[0]);
        //    sourceLocator = new JavaSourceLocator(javaProjects, true);

     
      // Eclipse stops looking for source if it finds a jar containing the source code
      // despite this jar as no attached source (the user will have to use 'Attach source' button).
      // So we have to enforce that sources in project are searched before jar files,
      // To do so we add source containers in this orders :
      // - First project source containers.
      // - second packageFragmentRoot container (jar files in projects build path will be added to source path)
      // - third DefaultSourceContainer (jar files added to classpath will be added to source path)

 
      // First add all projects source containers
      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject project = javaProjects[i];
        traceBuffer.append("  -> Add JavaProjectSourceContainer for " + project.getProject().getName() + "\n");
        sourceContainers.add(new JavaProjectSourceContainer(project));
      }

      // Adding packageFragmentRoot source containers, so classes in jar files associated to a project will be seen
      Set<IPath> external = new HashSet<IPath>();

      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject project = javaProjects[i];
        traceBuffer.append("  -> Compute SourceContainers for " + project.getProject().getName() + " :\n");

        IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
        for (int ri = 0; ri < roots.length; ri++) {
          IPackageFragmentRoot root = roots[ri];         
          if (root.isExternal()) {
            IPath location = root.getPath();
            if (external.contains(location)) {
View Full Code Here

  public void resourceChanged(IResourceChangeEvent event) {
    if (event.getType() == IResourceChangeEvent.PRE_BUILD) {
      IResourceDelta[] projectDeltas = event.getDelta().getAffectedChildren();
      for (IResourceDelta projectDelta : projectDeltas) {
        IProject project = (IProject) projectDelta.getResource();
        if (isWGAPublisherProject(project)) {
          try {
            WorkbenchUtils.addBuilder(project, WGADesignerPlugin.BUILDER_WGA_DEPLOYMENTS);
          } catch (Exception e) {
            WGADesignerPlugin.getDefault().getLog().log(new Status(Status.ERROR, WGADesignerPlugin.PLUGIN_ID, "Unable to add wga deployment builder to project '" + project.getName() + "'.", e));
          }       
        }
      }
    } else if (event.getType() == IResourceChangeEvent.PRE_DELETE) {
      IProject project = (IProject) event.getResource();
      if (isWGAPublisherProject(project)) {
        final WGADeployment deployment = getDeployment(project.getName());
        if (deployment != null) {
          Job job = new Job("Removing WGA Deployment '" + deployment.getName() + "'.") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
View Full Code Here

   * checks if this deployment represents a lokal (cvs checkedout( WGAPublisher project
   * @param deployment
   * @return
   */
  public boolean isProjectDeployment(WGADeployment deployment) {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(deployment.getName());
    if (project != null && isWGAPublisherProject(project)) {
      return true;
    } else {
      return false;
    }
View Full Code Here

   
      _selectedProject = selection;
      _designResources = WGADesignStructureHelper.retrieveDesignResources(new ResourceFilter() {

        public boolean accept(IResource resource) {
          IProject project = resource.getProject();
          if (project != null) {
            if (!project.isAccessible()) {
              return false;
            } else if (project.equals(_selectedProject)) {
              return false;
            }else if(!(resource instanceof IContainer)){
              return false;
            }else if(!WGADesignStructureHelper.isDesignFolder((IContainer)resource)){
              return false;
View Full Code Here

        String name = fProjText.getText().trim();
        if (name.length() > 0) {
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IStatus status = workspace.validateName(name, IResource.PROJECT);
            if (status.isOK()) {
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
                if (!project.exists()) {
                    setErrorMessage(MessageFormat.format("Project {0} does not exist", new String[] { name}));
                    return false;
                }
                if (!project.isOpen()) {
                    setErrorMessage(MessageFormat.format("Project {0} is closed", new String[] { name}));
                    return false;
                }
            } else {
                setErrorMessage(MessageFormat.format("Illegal project name: {0}", new String[] { status.getMessage()}));
View Full Code Here

        }
        return cl;
    }

    private static void getClassURLs(IJavaProject javaProject, List urls) {
        IProject project = javaProject.getProject();
        IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot();

        IClasspathEntry[] paths = null;
        IPath defaultOutputLocation = null;
        try {
            paths = javaProject.getResolvedClasspath(true);
            defaultOutputLocation = javaProject.getOutputLocation();
        } catch (JavaModelException e) {
            // don't show message to user neither log it
            // BytecodeOutlinePlugin.log(e, IStatus.ERROR);
        }
        if (paths != null) {
            IPath projectPath = javaProject.getProject().getLocation();
            for (int i = 0; i < paths.length; ++i) {
                IClasspathEntry cpEntry = paths[i];
                IPath p = null;
                if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    // filter out source container - there are unused for class
                    // search - add bytecode output location instead
                    p = cpEntry.getOutputLocation();
                    if (p == null) {
                        // default output used:
                        p = defaultOutputLocation;
                    }
                } else if (cpEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
                    String projName = cpEntry.getPath().toPortableString()
                        .substring(1);
                    IProject proj = workspaceRoot.getProject(projName);
                    IJavaProject projj = JavaCore.create(proj);
                    getClassURLs(projj, urls);
                    continue;
                } else {
                    p = cpEntry.getPath();
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

        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

TOP

Related Classes of org.eclipse.core.resources.IProject

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.