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));
 }
Ejemplo n.º 2
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);
     }
   }
 }
Ejemplo n.º 3
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();
    }
  }