public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 5;
    container.setLayout(layout);

    tablePart.createControl(container);

    pluginListViewer = tablePart.getTableViewer();
    pluginListViewer.setContentProvider(new BuildpathContentProvider());
    pluginListViewer.setLabelProvider(MDEPlugin.getDefault().getLabelProvider());

    GridData gd = (GridData) tablePart.getControl().getLayoutData();
    gd.heightHint = 300;
    gd.widthHint = 300;

    pluginListViewer.setInput(MDEPlugin.getDefault());
    if (fSelected != null && fSelected.length > 0) {
      tablePart.setSelection(fSelected);
    }
    setControl(container);
    Dialog.applyDialogFont(container);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.UPDATE_CLASSPATH);
  }
 /*
  * @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();
   }
 }
  private void importContent(
      Object source,
      IPath destPath,
      IImportStructureProvider provider,
      List filesToImport,
      IProgressMonitor monitor)
      throws CoreException {
    IOverwriteQuery query =
        new IOverwriteQuery() {
          public String queryOverwrite(String file) {
            return ALL;
          }
        };
    ImportOperation op = new ImportOperation(destPath, source, provider, query);
    op.setCreateContainerStructure(false);
    if (filesToImport != null) {
      op.setFilesToImport(filesToImport);
    }

    try {
      op.run(monitor);
    } catch (InvocationTargetException e) {
      Throwable th = e.getTargetException();
      if (th instanceof CoreException) {
        throw (CoreException) th;
      }
      IStatus status =
          new Status(IStatus.ERROR, MDEPlugin.getPluginId(), IStatus.ERROR, e.getMessage(), e);
      throw new CoreException(status);
    } catch (InterruptedException e) {
      throw new OperationCanceledException(e.getMessage());
    }
  }
Beispiel #4
0
 /** @param elementInfo */
 public static int getCounterValue(ISchemaElement elementInfo) {
   Hashtable counters = MDEPlugin.getDefault().getDefaultNameCounters();
   String counterKey = getCounterKey(elementInfo);
   Integer counter = (Integer) counters.get(counterKey);
   if (counter == null) {
     counter = new Integer(1);
   } else counter = new Integer(counter.intValue() + 1);
   counters.put(counterKey, counter);
   return counter.intValue();
 }
 public NewLibraryPluginCreationUpdateRefPage(
     LibraryPluginFieldData data, Collection initialJarPaths, Collection selection) {
   super("UpdateReferences"); // $NON-NLS-1$
   setTitle(MDEUIMessages.UpdateBuildpathWizard_title);
   setDescription(MDEUIMessages.UpdateBuildpathWizard_desc);
   computeUnmigrated();
   computeSelected(selection);
   fData = data;
   tablePart = new TablePart(MDEUIMessages.UpdateBuildpathWizard_availablePlugins);
   MDEPlugin.getDefault().getLabelProvider().connect(this);
 }
 protected void createChange(IBaseModel model) {
   IEditorPart part = MDEPlugin.getActivePage().getActiveEditor();
   if (part instanceof ManifestEditor) {
     ManifestEditor editor = (ManifestEditor) part;
     IBaseModel base = editor.getAggregateModel();
     if (base instanceof IBundlePluginModelBase) {
       IBundlePluginModelBase pluginModel = (IBundlePluginModelBase) base;
       NewExtensionPointWizard wizard =
           new NewExtensionPointWizard(
               pluginModel.getUnderlyingResource().getProject(), pluginModel, editor) {
             public boolean performFinish() {
               return super.performFinish();
             }
           };
       WizardDialog dialog = new WizardDialog(MDEPlugin.getActiveWorkbenchShell(), wizard);
       dialog.create();
       SWTUtil.setDialogSize(dialog, 400, 450);
       dialog.open();
     }
   }
 }
 private void computeUnmigrated() {
   IMonitorModelBase[] models = MonitorRegistry.getWorkspaceModels();
   ArrayList modelArray = new ArrayList();
   try {
     for (int i = 0; i < models.length; i++) {
       if (models[i].getUnderlyingResource().getProject().hasNature(JavaCore.NATURE_ID))
         modelArray.add(models[i]);
     }
   } catch (CoreException e) {
     MDEPlugin.logException(e);
   }
   fUnmigrated =
       (IMonitorModelBase[]) modelArray.toArray(new IMonitorModelBase[modelArray.size()]);
 }
  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();
    }
  }