Examples of IProjectDescription


Examples of org.eclipse.core.resources.IProjectDescription

              if (attribs != null && attribs.isReadOnly()) {
                attribs.setReadOnly(false);
                fProject.setResourceAttributes(attribs);
              }
             
              IProjectDescription desc = fProject.getDescription();
              ICommand[] commands = desc.getBuildSpec();           
              for (int i = 0; i < commands.length; ++i) {
                 if (commands[i].getBuilderName().equals(fId))
                    return;
              }
              //add builder to project
              ICommand command = desc.newCommand();
              command.setBuilderName(fId);
              ICommand[] nc = new ICommand[commands.length + 1];
              // Add it after all other builders.
              System.arraycopy(commands, 0, nc, 0, commands.length);
              nc[commands.length] = command;
              desc.setBuildSpec(nc);
              fProject.setDescription(desc, null);
             
            }
          }
       };
View Full Code Here

Examples of org.eclipse.core.resources.IProjectDescription

              ResourceAttributes attribs = fProject.getResourceAttributes();
              if (attribs != null && attribs.isReadOnly()) {
                attribs.setReadOnly(false);
                fProject.setResourceAttributes(attribs);
              }
              IProjectDescription desc = fProject.getDescription();
              ICommand[] commands = desc.getBuildSpec();
              List<ICommand> newCommands = new ArrayList<ICommand>();
              for (int i = 0; i < commands.length; ++i) {                 
                 if (!commands[i].getBuilderName().equals(fId)) {
                   newCommands.add(commands[i]);
                 }
              }
              desc.setBuildSpec(newCommands.toArray(new ICommand[0]));
              fProject.setDescription(desc, null);             
            }
          }
       };
       ResourcesPlugin.getWorkspace().run(operation, null);
View Full Code Here

Examples of org.eclipse.core.resources.IProjectDescription

import org.eclipse.core.runtime.CoreException;

public class JDTUtils {
 
  public static void addNature(IProject project, String natureId) throws CoreException {
    IProjectDescription description = project.getDescription();
    String[] natures = description.getNatureIds();
      String[] newNatures = new String[natures.length + 1];
      System.arraycopy(natures, 0, newNatures, 0, natures.length);
      newNatures[natures.length] = natureId;
      description.setNatureIds(newNatures);
    project.setDescription(description, null);
  }
View Full Code Here

Examples of org.eclipse.core.resources.IProjectDescription

        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.IProjectDescription

        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

Examples of org.eclipse.core.resources.IProjectDescription

        IPath ipath = ifolder.getFullPath();
        project.setOutputLocation(ipath, null);
    }

    private void addJavaBuilder(IJavaProject project) 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, null);
    }
View Full Code Here

Examples of org.eclipse.core.resources.IProjectDescription

    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.IProjectDescription

  /**
   * Adds a builder to the build spec for the given project.
   */
  protected void addToBuildSpec(String builderID) throws CoreException {

    IProjectDescription description = this.project.getDescription();
    int javaCommandIndex = getJavaCommandIndex(description.getBuildSpec());

    if (javaCommandIndex == -1) {

      // Add a Java command to the build spec
      ICommand command = description.newCommand();
      command.setBuilderName(builderID);
      setJavaCommand(description, command);
    }
  }
View Full Code Here

Examples of org.eclipse.core.resources.IProjectDescription

  /**
   * Removes the given builder from the build spec for the given project.
   */
  protected void removeFromBuildSpec(String builderID) throws CoreException {

    IProjectDescription description = this.project.getDescription();
    ICommand[] commands = description.getBuildSpec();
    for (int i = 0; i < commands.length; ++i) {
      if (commands[i].getBuilderName().equals(builderID)) {
        ICommand[] newCommands = new ICommand[commands.length - 1];
        System.arraycopy(commands, 0, newCommands, 0, i);
        System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
        description.setBuildSpec(newCommands);
        this.project.setDescription(description, null);
        return;
      }
    }
  }
View Full Code Here

Examples of org.eclipse.core.resources.IProjectDescription

    protected void importCnf(IProgressMonitor monitor) throws CoreException {
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IPath location = operation.getLocation();
        IContainer container = workspace.getRoot().getContainerForLocation(location);
        if (container == null) {
            IProjectDescription projDesc = workspace.loadProjectDescription(location.append(IProjectDescription.DESCRIPTION_FILE_NAME));
            IProject project = workspace.getRoot().getProject(Workspace.CNFDIR);
            project.create(projDesc, monitor);
            project.open(monitor);
        } else if (container.getType() == IResource.PROJECT) {
            IProject project = (IProject) container;
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.