Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IProjectDescription


        DerbyServerUtils.getDefault().stopDerbyServer(currentJavaProject.getProject());
      }
      IClasspathEntry[] rawClasspath = currentJavaProject.getRawClasspath();
      currentJavaProject.setRawClasspath(DerbyUtils.removeDerbyJars(rawClasspath), null);
     
      IProjectDescription description = currentJavaProject.getProject().getDescription();
      String[] natures = description.getNatureIds();

      description.setNatureIds(removeDerbyNature(natures));
      currentJavaProject.getProject().setDescription(description, null);
      // refresh project so user sees changes
      currentJavaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
      ((ApplicationWindow)window).setStatus(Messages.DERBY_NATURE_REMOVED);
    }catch (Exception e) {
View Full Code Here


            //new way
            if (currentJavaProject == null)
            {
                // if the java nature is not present
                // it must be added, along with the Derby nature
                IProjectDescription description = currentProject
                        .getDescription();
                String[] natureIds = description.getNatureIds();
                String[] newNatures = new String[natureIds.length + 2];
                System.arraycopy(natureIds, 0, newNatures, 0, natureIds.length);
                newNatures[newNatures.length - 2] = JavaCore.NATURE_ID;
                newNatures[newNatures.length - 1] = CommonNames.DERBY_NATURE;
                description.setNatureIds(newNatures);
                currentProject.setDescription(description, null);

                currentJavaProject = (IJavaProject) JavaCore
                        .create((IProject) currentProject);
            }
            else
            {
                //add the derby nature, the java nature is already present
                IProjectDescription description = currentJavaProject
                        .getProject().getDescription();
                String[] natures = description.getNatureIds();
                String[] newNatures = new String[natures.length + 1];
                System.arraycopy(natures, 0, newNatures, 0, natures.length);
                // must prefix with plugin id
                newNatures[natures.length] = CommonNames.DERBY_NATURE;
                description.setNatureIds(newNatures);
                currentJavaProject.getProject().setDescription(description,
                        null);
            }

            IClasspathEntry[] rawClasspath = currentJavaProject
View Full Code Here

    public static void addNature(final IProject project) {
        if (hasNature(project)) {
            return;
        }

        final IProjectDescription description;
        try {
            description = project.getDescription();
        } catch (CoreException e) {
            IvyPlugin.logError("Failed to add Ivy dependency management on " + project.getName(), e);
            return;
        }
        final String[] ids = description.getNatureIds();

        final String[] newIds = new String[ids == null ? 1 : ids.length + 1];
        if (ids != null) {
            System.arraycopy(ids, 0, newIds, 0, ids.length);
        }
        newIds[ids == null ? 0 : ids.length] = IVY_NATURE_ID;

        description.setNatureIds(newIds);
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                try {
                    project.setDescription(description, null);
                } catch (CoreException e) {
View Full Code Here

        try {
            if (!hasNature(project)) {
                return;
            }

            final IProjectDescription description = project.getDescription();
            final String[] ids = description.getNatureIds();
            if (ids == null || ids.length == 0) {
                // wtf ? it has the Ivy nature but there is none ?
                return;
            }

            int i;
            for (i = 0; i < ids.length; i++) {
                if (IVY_NATURE_ID.equals(ids[i])) {
                    break;
                }
            }
            if (i == ids.length) {
                // wtf ? it has the Ivy nature but we cannot find it ?
                return;
            }

            final String[] newIds = new String[ids.length - 1];
            if (i > 0) {
                System.arraycopy(ids, 0, newIds, 0, i);
            }
            if (i < ids.length - 1) {
                System.arraycopy(ids, i + 1, newIds, i, ids.length - i - 1);
            }

            description.setNatureIds(newIds);
            project.setDescription(description, null);
        } catch (Exception e) {
            IvyPlugin.logError(
                "Failed to remove Ivy dependency management on " + project.getName(), e);
        }
View Full Code Here

        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)
View Full Code Here

        IPath path = folder.getFullPath();
        project.setOutputLocation(path, null);
    }

    private void addJavaBuilder(IJavaProject project, IProgressMonitor monitor) throws CoreException {
        IProjectDescription description = project.getProject().getDescription();
        ICommand[] commands = description.getBuildSpec();
        ICommand[] newCommands = new ICommand[commands.length + 2];
        System.arraycopy(commands, 0, newCommands, 0, commands.length);

        ICommand javaCommand = description.newCommand();
        javaCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
        newCommands[commands.length] = javaCommand;
       
        ICommand droolsCommand = description.newCommand();
        droolsCommand.setBuilderName(DroolsBuilder.BUILDER_ID);
        newCommands[commands.length + 1] = droolsCommand;
       
        description.setBuildSpec(newCommands);
        project.getProject().setDescription(description, monitor);
    }
View Full Code Here

        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)
View Full Code Here

        IPath path = folder.getFullPath();
        project.setOutputLocation(path, null);
    }

    private void addJavaBuilder(IJavaProject project, IProgressMonitor monitor) throws CoreException {
        IProjectDescription description = project.getProject().getDescription();
        ICommand[] commands = description.getBuildSpec();
        ICommand[] newCommands = new ICommand[commands.length + 2];
        System.arraycopy(commands, 0, newCommands, 0, commands.length);

        ICommand javaCommand = description.newCommand();
        javaCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
        newCommands[commands.length] = javaCommand;
       
        ICommand droolsCommand = description.newCommand();
        droolsCommand.setBuilderName(DroolsBuilder.BUILDER_ID);
        newCommands[commands.length + 1] = droolsCommand;
       
        description.setBuildSpec(newCommands);
        project.getProject().setDescription(description, monitor);
    }
View Full Code Here

    /**
     *
     */
    private void addJavaNature() {
        try {
            IProjectDescription projectDescription = project.getDescription();
            String[] currentNatures = projectDescription.getNatureIds();
            List<String> newNatures = new ArrayList<String>();
            for (String nature : currentNatures) {
                newNatures.add(nature);
            }
            newNatures.add(JavaCore.NATURE_ID);
            projectDescription.setNatureIds(newNatures.toArray(new String[newNatures.size()]));
            project.setDescription(projectDescription, null);
        }
        catch (CoreException e) {
            e.printStackTrace();
        }
View Full Code Here

   * @param project
   *            to have sample nature added or removed
   */
  private void toggleNature(IProject project) {
    try {
      IProjectDescription description = project.getDescription();
      String[] natures = description.getNatureIds();

      for (int i = 0; i < natures.length; ++i) {
        if (SampleNature.NATURE_ID.equals(natures[i])) {
          // Remove the nature
          String[] newNatures = new String[natures.length - 1];
          System.arraycopy(natures, 0, newNatures, 0, i);
          System.arraycopy(natures, i + 1, newNatures, i,
              natures.length - i - 1);
          description.setNatureIds(newNatures);
          project.setDescription(description, null);
          return;
        }
      }

      // Add the nature
      String[] newNatures = new String[natures.length + 1];
      System.arraycopy(natures, 0, newNatures, 0, natures.length);
      newNatures[natures.length] = SampleNature.NATURE_ID;
      description.setNatureIds(newNatures);
      project.setDescription(description, null);
    } catch (CoreException e) {
    }
  }
View Full Code Here

TOP

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

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.