コード例 #1
0
 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));
 }
コード例 #2
0
  private void setClasspath(IProject project, IFeatureModel model, IProgressMonitor monitor)
      throws JavaModelException {
    IJavaProject jProject = JavaCore.create(project);

    IClasspathEntry jreCPEntry =
        JavaCore.newContainerEntry(
            new Path("org.eclipse.jdt.launching.JRE_CONTAINER")); // $NON-NLS-1$

    String libName = model.getFeature().getInstallHandler().getLibrary();
    IClasspathEntry handlerCPEntry =
        JavaCore.newLibraryEntry(project.getFullPath().append(libName), null, null);

    jProject.setRawClasspath(new IClasspathEntry[] {jreCPEntry, handlerCPEntry}, monitor);
  }
コード例 #3
0
 private void createBuildProperties(IProject project) {
   IFile file = PDEProject.getBuildProperties(project);
   if (!file.exists()) {
     WorkspaceBuildModel model = new WorkspaceBuildModel(file);
     IBuildEntry ientry = model.getFactory().createEntry("bin.includes"); // $NON-NLS-1$
     try {
       IResource[] res = project.members();
       for (int i = 0; i < res.length; i++) {
         String path = res[i].getProjectRelativePath().toString();
         if (!path.equals(".project")) // $NON-NLS-1$
         ientry.addToken(path);
       }
       model.getBuild().add(ientry);
       model.save();
     } catch (CoreException e) {
     }
   }
 }
コード例 #4
0
  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();
    }
  }