/*
  * @see IWorkspaceRunnable#run(IProgressMonitor)
  */
 public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
   if (monitor == null) {
     monitor = new NullProgressMonitor();
   }
   monitor.beginTask(MDEUIMessages.FeatureImportWizard_operation_creating, fModels.length);
   try {
     MultiStatus multiStatus =
         new MultiStatus(
             MDEPlugin.getPluginId(),
             IStatus.OK,
             MDEUIMessages.FeatureImportWizard_operation_multiProblem,
             null);
     for (int i = 0; i < fModels.length; i++) {
       try {
         createProject(fModels[i], new SubProgressMonitor(monitor, 1));
       } catch (CoreException e) {
         multiStatus.merge(e.getStatus());
       }
       if (monitor.isCanceled()) {
         throw new OperationCanceledException();
       }
     }
     if (!multiStatus.isOK()) {
       throw new CoreException(multiStatus);
     }
   } finally {
     monitor.done();
   }
 }
Beispiel #2
0
 public void execute(IProgressMonitor monitor) {
   IPluginModelBase[] plugins = PluginJavaSearchUtil.getPluginImports(fImportID);
   monitor.beginTask(
       PDEUIMessages.DependencyExtentOperation_searching + " " + fImportID + "...",
       10); //$NON-NLS-1$//$NON-NLS-2$
   checkForJavaDependencies(plugins, new SubProgressMonitor(monitor, 9));
   for (int i = 0; i < plugins.length; i++) {
     checkForExtensionPointsUsed(plugins[i]);
   }
   monitor.done();
 }
Beispiel #3
0
  private void checkForJavaDependencies(IPluginModelBase[] models, IProgressMonitor monitor) {
    try {
      if (!fProject.hasNature(JavaCore.NATURE_ID)) return;

      IJavaProject jProject = JavaCore.create(fProject);
      IPackageFragment[] packageFragments =
          PluginJavaSearchUtil.collectPackageFragments(models, jProject, true);
      monitor.beginTask("", packageFragments.length); // $NON-NLS-1$
      SearchEngine engine = new SearchEngine();
      for (int i = 0; i < packageFragments.length; i++) {
        if (monitor.isCanceled()) break;
        IPackageFragment pkgFragment = packageFragments[i];
        monitor.subTask(
            PDEUIMessages.DependencyExtentOperation_inspecting
                + " "
                + pkgFragment.getElementName()); // $NON-NLS-1$
        if (pkgFragment.hasChildren()) {
          IJavaElement[] children = pkgFragment.getChildren();
          for (int j = 0; j < children.length; j++) {
            if (monitor.isCanceled()) break;
            IJavaElement child = children[j];
            IType[] types = new IType[0];
            if (child instanceof IClassFile) {
              types = new IType[] {((IClassFile) child).getType()};
            } else if (child instanceof ICompilationUnit) {
              types = ((ICompilationUnit) child).getTypes();
            }
            if (types.length > 0)
              searchForTypesUsed(
                  engine, child, types, PluginJavaSearchUtil.createSeachScope(jProject));
          }
        }
        monitor.worked(1);
      }
    } catch (CoreException e) {
    } finally {
      monitor.done();
    }
  }
  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();
    }
  }