Beispiel #1
0
 @Override
 public void rename(DBRProgressMonitor monitor, String newName) throws DBException {
   try {
     final IProjectDescription description = getProject().getDescription();
     description.setName(newName);
     getProject().move(description, true, monitor.getNestedMonitor());
   } catch (CoreException e) {
     throw new DBException("Can't rename project", e);
   }
 }
 private void setProjectNatures(IProject project, IFeatureModel model, IProgressMonitor monitor)
     throws CoreException {
   IProjectDescription desc = project.getDescription();
   if (needsJavaNature(model)) {
     desc.setNatureIds(new String[] {JavaCore.NATURE_ID, MDE.FEATURE_NATURE});
   } else {
     desc.setNatureIds(new String[] {MDE.FEATURE_NATURE});
   }
   project.setDescription(desc, new SubProgressMonitor(monitor, 1));
 }
  /** Test for Bug #5102. Never reproduced but interesting little test, worth keeping around */
  public void testPR() throws Exception {
    // create a project with a RefreshLocalJavaFileBuilder and a SortBuilder on the classpath
    IProject project = getWorkspace().getRoot().getProject("P1");
    project.create(null);
    project.open(null);
    IProjectDescription desc = project.getDescription();
    ICommand one = desc.newCommand();
    one.setBuilderName(RefreshLocalJavaFileBuilder.BUILDER_NAME);
    ICommand two = desc.newCommand();
    two.setBuilderName(SortBuilder.BUILDER_NAME);
    desc.setBuildSpec(new ICommand[] {one, two});
    project.setDescription(desc, null);

    // do a full build
    project.build(IncrementalProjectBuilder.FULL_BUILD, null);

    // do an incremental build by creating a file
    IFile file = project.getFile("Foo");
    file.create(getRandomContents(), true, getMonitor());
  }
Beispiel #4
0
 /** Goes over the given projects and converts them */
 private void processProjects(final IProject[] projects) throws CoreException, ModelException {
   ProjectsIterate:
   for (IProject project : projects) {
     // skip unaccessible projects
     if (!project.isAccessible()) {
       continue ProjectsIterate;
     }
     // verify that the project is a PHP project
     if (PHPToolkitUtil.isPhpProject(project)) {
       IProjectDescription projectDescription = project.getDescription();
       ICommand[] commands = projectDescription.getBuildSpec();
       // check if the Script Builder is installed
       for (int i = 0; i < commands.length; ++i) {
         if (commands[i].getBuilderName().equals(DLTKCore.BUILDER_ID)) {
           // when the builder exists - continue to the next
           // project
           continue ProjectsIterate;
         }
       }
       // perform modifications only if the builder is not installed
       modifyProject(project);
     }
   }
 }
Beispiel #5
0
  /**
   * The worker method. It will create a new project, then create the appropriate Soar heirarchy and
   * files.
   */
  private void doFinish(String projectName, IProgressMonitor monitor) throws CoreException {

    monitor.beginTask("Creating " + projectName, 7);

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject newProject = root.getProject(projectName);

    // creation of the project
    if (newProject.exists()) {
      throwCoreException("Project \"" + projectName + "\" already exists");
    } else {

      newProject.create(monitor);
      newProject.open(monitor);

      try {

        IProjectDescription description = newProject.getDescription();
        String[] natures = description.getNatureIds();
        String[] newNatures = new String[natures.length + 1];
        System.arraycopy(natures, 0, newNatures, 0, natures.length);
        newNatures[natures.length] = SoarProjectNature.NATURE_ID;
        description.setNatureIds(newNatures);

        newProject.setDescription(description, IResource.FORCE, monitor);

        newProject.setPersistentProperty(DataMap.VERTEX_ID, "0");

      } catch (CoreException e) {
        e.printStackTrace();
      } // catch
    } // else

    monitor.worked(2);

    // Create the contents of the project's root directory
    IFolder folderAll = newProject.getFolder("all");
    if (!folderAll.exists()) {
      folderAll.create(true, true, monitor);
    } // if
    FileMarker.markResource(folderAll, "file");

    IFolder folderElaborations = newProject.getFolder("elaborations");
    if (!folderElaborations.exists()) {
      folderElaborations.create(true, true, monitor);
    } // if
    FileMarker.markResource(folderElaborations, "file");

    IFile file_firstload = newProject.getFile("_firstload.soar");
    if (!file_firstload.exists()) {
      file_firstload.create(
          Utility.getFileTemplate(file_firstload, "_firstload.soar"), true, monitor);
    } // if
    FileMarker.markResource(file_firstload, "file");

    IFile filedatamap = newProject.getFile("datamap.xdm");
    if (!filedatamap.exists()) {
      filedatamap.create(Utility.getFileTemplate(filedatamap, "datamap.xdm"), true, monitor);
    } // if

    monitor.worked(3);

    // Create the contents of the elaborations folder
    IFile file_all = folderElaborations.getFile("_all.soar");
    if (!file_all.exists()) {
      file_all.create(Utility.getFileTemplate(file_all, "_all.soar"), true, monitor);
    } // if
    FileMarker.markResource(file_all, "file");

    IFile filetopstate = folderElaborations.getFile("top-state.soar");
    if (!filetopstate.exists()) {
      filetopstate.create(Utility.getFileTemplate(filetopstate, "top-state.soar"), true, monitor);
    } // if
    FileMarker.markResource(filetopstate, "file");

    SourcingFile.createSourcingFile(newProject, monitor);

    newProject.close(monitor);
    newProject.open(monitor);

    monitor.worked(2);
    monitor.done();
  } // void doFinish(...)
  private void createProject(IFeatureModel model, IProgressMonitor monitor) throws CoreException {
    String name = model.getFeature().getId();

    IFeaturePlugin[] plugins = model.getFeature().getPlugins();
    for (int i = 0; i < plugins.length; i++) {
      if (name.equals(plugins[i].getId())) {
        name += "-feature"; // $NON-NLS-1$
        break;
      }
    }

    String task = NLS.bind(MDEUIMessages.FeatureImportWizard_operation_creating2, name);
    monitor.beginTask(task, 9);
    try {
      IProject project = fRoot.getProject(name);

      if (project.exists() || new File(project.getParent().getLocation().toFile(), name).exists()) {
        if (queryReplace(project)) {
          if (!project.exists()) project.create(new SubProgressMonitor(monitor, 1));
          project.delete(true, true, new SubProgressMonitor(monitor, 1));
          try {
            RepositoryProvider.unmap(project);
          } catch (TeamException e) {
          }
        } else {
          return;
        }
      } else {
        monitor.worked(1);
      }

      IProjectDescription description = MDEPlugin.getWorkspace().newProjectDescription(name);
      if (fTargetPath != null) description.setLocation(fTargetPath.append(name));

      project.create(description, new SubProgressMonitor(monitor, 1));
      if (!project.isOpen()) {
        project.open(null);
      }
      File featureDir = new File(model.getInstallLocation());

      importContent(
          featureDir,
          project.getFullPath(),
          FileSystemStructureProvider.INSTANCE,
          null,
          new SubProgressMonitor(monitor, 1));
      IFolder folder = project.getFolder("META-INF"); // $NON-NLS-1$
      if (folder.exists()) {
        folder.delete(true, null);
      }
      if (fBinary) {
        // Mark this project so that we can show image overlay
        // using the label decorator
        project.setPersistentProperty(
            MDECore.EXTERNAL_PROJECT_PROPERTY, MDECore.BINARY_PROJECT_VALUE);
      }
      createBuildProperties(project);
      setProjectNatures(project, model, monitor);
      if (project.hasNature(JavaCore.NATURE_ID)) setClasspath(project, model, monitor);

    } finally {
      monitor.done();
    }
  }