private Map promptForOverwrite(List plugins, List locales) {
    Map overwrites = new HashMap();

    if (overwriteWithoutAsking) return overwrites;

    for (Iterator iter = plugins.iterator(); iter.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) iter.next();
      for (Iterator it = locales.iterator(); it.hasNext(); ) {
        Locale locale = (Locale) it.next();
        IProject project = getNLProject(plugin, locale);

        if (project.exists() && !overwrites.containsKey(project.getName())) {
          boolean overwrite =
              MessageDialog.openConfirm(
                  PDEPlugin.getActiveWorkbenchShell(),
                  PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteTitle,
                  NLS.bind(
                      PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteMessage,
                      pluginName(plugin, locale)));
          overwrites.put(project.getName(), overwrite ? OVERWRITE : null);
        }
      }
    }

    return overwrites;
  }
 private void handleNewIntro() {
   boolean needNewProduct = false;
   if (!productDefined()) {
     needNewProduct = true;
     MessageDialog mdiag =
         new MessageDialog(
             PDEPlugin.getActiveWorkbenchShell(),
             PDEUIMessages.IntroSection_undefinedProductId,
             null,
             PDEUIMessages.IntroSection_undefinedProductIdMessage,
             MessageDialog.QUESTION,
             new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
             0);
     if (mdiag.open() != Window.OK) return;
   }
   ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct);
   WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
   dialog.create();
   if (dialog.open() == Window.OK) {
     String id = wizard.getIntroId();
     fIntroCombo.add(id, 0);
     fIntroCombo.setText(id);
     getIntroInfo().setId(id);
     addDependenciesAndPlugins();
   }
 }
  /**
   * Runs the organize manifest operation for projects in the provided selection. Public to allow
   * editors to call this action
   *
   * <p>TODO This could be done better using the ICommandService
   *
   * @param selection selection to run organize manifest operation on
   */
  public void runOrganizeManfestsAction(ISelection selection) {
    if (!PlatformUI.getWorkbench().saveAllEditors(true)) return;

    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ssel = (IStructuredSelection) selection;
      Iterator<?> it = ssel.iterator();
      ArrayList<IProject> projects = new ArrayList<>();
      while (it.hasNext()) {
        Object element = it.next();
        IProject proj = null;
        if (element instanceof IFile) proj = ((IFile) element).getProject();
        else if (element instanceof IProject) proj = (IProject) element;
        else if (element instanceof IJavaProject) {
          proj = ((IJavaProject) element).getProject();
        }
        if (proj != null && PDEProject.getManifest(proj).exists()) projects.add(proj);
      }
      if (projects.size() > 0) {
        OrganizeManifestsProcessor processor = new OrganizeManifestsProcessor(projects);
        PDERefactor refactor = new PDERefactor(processor);
        OrganizeManifestsWizard wizard = new OrganizeManifestsWizard(refactor);
        RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);

        try {
          op.run(PDEPlugin.getActiveWorkbenchShell(), ""); // $NON-NLS-1$
        } catch (final InterruptedException irex) {
        }
      } else
        MessageDialog.openInformation(
            PDEPlugin.getActiveWorkbenchShell(),
            PDEUIMessages.OrganizeManifestsWizardPage_title,
            PDEUIMessages.OrganizeManifestsWizardPage_errorMsg);
    }
  }
Ejemplo n.º 4
0
 private void handleConvert() {
   try {
     // remove listeners of Info section before we convert.  If we don't
     // we may get a model changed event while disposing the page.  Bug 156414
     fInfoSection.removeListeners();
     PDEFormEditor editor = getPDEEditor();
     IPluginModelBase model = (IPluginModelBase) editor.getAggregateModel();
     IRunnableWithProgress op = new CreateManifestOperation(model);
     IProgressService service = PlatformUI.getWorkbench().getProgressService();
     editor.doSave(null);
     service.runInUI(service, op, PDEPlugin.getWorkspace().getRoot());
     updateBuildProperties();
     editor.doSave(null);
   } catch (InvocationTargetException e) {
     MessageDialog.openError(
         PDEPlugin.getActiveWorkbenchShell(),
         PDEUIMessages.OverviewPage_error,
         e.getCause().getMessage());
     // if convert failed and this OverviewPage hasn't been removed from the editor, reattach
     // listeners
     if (!fDisposed) fInfoSection.addListeners();
   } catch (InterruptedException e) {
     // if convert failed and this OverviewPage hasn't been removed from the editor, reattach
     // listeners
     if (!fDisposed) fInfoSection.addListeners();
   }
 }
 private void handleNewPlugin() {
   NewPluginProjectWizard wizard = new NewPluginProjectWizard();
   wizard.init(PDEPlugin.getActiveWorkbenchWindow().getWorkbench(), null);
   WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
   dialog.create();
   SWTUtil.setDialogSize(dialog, 400, 500);
   if (dialog.open() == Window.OK) {
     addPlugin(wizard.getPluginId(), wizard.getPluginVersion());
   }
 }
 private void handleProperties() {
   IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
   if (ssel.size() == 1) {
     IProductPlugin plugin = (IProductPlugin) ssel.toArray()[0];
     VersionDialog dialog =
         new VersionDialog(PDEPlugin.getActiveWorkbenchShell(), isEditable(), plugin.getVersion());
     dialog.create();
     SWTUtil.setDialogSize(dialog, 400, 200);
     if (dialog.open() == Window.OK) {
       plugin.setVersion(dialog.getVersion());
     }
   }
 }
 @Override
 public void run(String[] params, ICheatSheetManager manager) {
   Hashtable<String, String> defValues = new Hashtable<>();
   if (params.length > 0) defValues.put(NewSiteProjectWizard.DEF_PROJECT_NAME, params[0]);
   NewSiteProjectWizard wizard = new NewSiteProjectWizard();
   wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
   wizard.init(defValues);
   WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
   dialog.create();
   SWTUtil.setDialogSize(dialog, 500, 500);
   dialog.getShell().setText(wizard.getWindowTitle());
   int result = dialog.open();
   notifyResult(result == Window.OK);
 }
Ejemplo n.º 8
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.forms.events.HyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent)
  */
 public void linkActivated(HyperlinkEvent e) {
   String href = (String) e.getHref();
   // try page references
   if (href.equals("dependencies")) // $NON-NLS-1$
   getEditor().setActivePage(DependenciesPage.PAGE_ID);
   else if (href.equals("runtime")) // $NON-NLS-1$
   getEditor().setActivePage(RuntimePage.PAGE_ID);
   else if (href.equals("extensions")) { // $NON-NLS-1$
     if (getEditor().setActivePage(ExtensionsPage.PAGE_ID) == null)
       activateExtensionPages(ExtensionsPage.PAGE_ID);
   } else if (href.equals("ex-points")) { // $NON-NLS-1$
     if (getEditor().setActivePage(ExtensionPointsPage.PAGE_ID) == null)
       activateExtensionPages(ExtensionPointsPage.PAGE_ID);
   } else if (href.equals("build")) { // $NON-NLS-1$
     if (!getPDEEditor().hasInputContext(BuildInputContext.CONTEXT_ID)) {
       if (!MessageDialog.openQuestion(
           PDEPlugin.getActiveWorkbenchShell(),
           PDEUIMessages.OverviewPage_buildTitle,
           PDEUIMessages.OverviewPage_buildQuestion)) return;
       IFile file = PDEProject.getBuildProperties(getPDEEditor().getCommonProject());
       WorkspaceBuildModel model = new WorkspaceBuildModel(file);
       model.save();
       IEditorInput in = new FileEditorInput(file);
       getPDEEditor()
           .getContextManager()
           .putContext(in, new BuildInputContext(getPDEEditor(), in, false));
     }
     getEditor().setActivePage(BuildPage.PAGE_ID);
   } else if (href.equals("export")) { // $NON-NLS-1$
     getExportAction().run();
   } else if (href.equals("action.convert")) { // $NON-NLS-1$
     handleConvert();
   } else if (href.equals("organize")) { // $NON-NLS-1$
     getEditor().doSave(null);
     OrganizeManifestsAction organizeAction = new OrganizeManifestsAction();
     organizeAction.selectionChanged(
         null, new StructuredSelection(getPDEEditor().getCommonProject()));
     organizeAction.run(null);
   } else if (href.equals("externalize")) { // $NON-NLS-1$
     getEditor().doSave(null);
     GetNonExternalizedStringsAction externalizeAction = new GetNonExternalizedStringsAction();
     externalizeAction.selectionChanged(
         null, new StructuredSelection(getPDEEditor().getCommonProject()));
     externalizeAction.run(null);
   } else super.linkActivated(e);
 }
 private void handleAdd() {
   ElementListSelectionDialog dialog =
       new ElementListSelectionDialog(
           PDEPlugin.getActiveWorkbenchShell(), PDEPlugin.getDefault().getLabelProvider());
   dialog.setElements(getBundles());
   dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
   dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
   dialog.setMultipleSelection(true);
   if (dialog.open() == Window.OK) {
     Object[] bundles = dialog.getResult();
     for (int i = 0; i < bundles.length; i++) {
       BundleDescription desc = (BundleDescription) bundles[i];
       addPlugin(desc.getSymbolicName(), "0.0.0"); // $NON-NLS-1$
       // addPlugin(desc.getSymbolicName(), desc.getVersion().toString());
     }
   }
 }
  private void openPortabilityChoiceDialog(String property, FormEntry text, Choice[] choices) {
    String value = text.getValue();

    PortabilityChoicesDialog dialog =
        new PortabilityChoicesDialog(PDEPlugin.getActiveWorkbenchShell(), choices, value);
    dialog.create();
    dialog.getShell().setText(PDEUIMessages.SiteEditor_PortabilityChoicesDialog_title);

    int result = dialog.open();
    if (result == Window.OK) {
      value = dialog.getValue();
      text.setValue(value);
      try {
        applyValue(property, value);
      } catch (CoreException e) {
        PDEPlugin.logException(e);
      }
    }
  }
Ejemplo n.º 11
0
 private void activateExtensionPages(String activePageId) {
   MessageDialog mdiag =
       new MessageDialog(
           PDEPlugin.getActiveWorkbenchShell(),
           PDEUIMessages.OverviewPage_extensionPageMessageTitle,
           null,
           PDEUIMessages.OverviewPage_extensionPageMessageBody,
           MessageDialog.QUESTION,
           new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
           0);
   if (mdiag.open() != Window.OK) return;
   try {
     MonitorEditor manifestEditor = (MonitorEditor) getEditor();
     manifestEditor.addExtensionTabs();
     manifestEditor.setShowExtensions(true);
     manifestEditor.setActivePage(activePageId);
   } catch (PartInitException e) {
   } catch (BackingStoreException e) {
   }
 }
 private void handleAddWorkingSet() {
   IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
   IWorkingSetSelectionDialog dialog =
       manager.createWorkingSetSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), true);
   if (dialog.open() == Window.OK) {
     IWorkingSet[] workingSets = dialog.getSelection();
     IProduct product = getProduct();
     IProductModelFactory factory = product.getModel().getFactory();
     ArrayList<IProductPlugin> pluginList = new ArrayList<IProductPlugin>();
     for (int i = 0; i < workingSets.length; i++) {
       IAdaptable[] elements = workingSets[i].getElements();
       for (int j = 0; j < elements.length; j++) {
         IPluginModelBase model = findModel(elements[j]);
         if (model != null) {
           IProductPlugin plugin = factory.createPlugin();
           IPluginBase base = model.getPluginBase();
           plugin.setId(base.getId());
           pluginList.add(plugin);
         }
       }
     }
     product.addPlugins(pluginList.toArray(new IProductPlugin[pluginList.size()]));
   }
 }
 private void handleAdd() {
   IPluginModelBase model = (IPluginModelBase) getPage().getModel();
   final IProject project = model.getUnderlyingResource().getProject();
   try {
     if (project.hasNature(JavaCore.NATURE_ID)) {
       ILabelProvider labelProvider = new JavaElementLabelProvider();
       final ConditionalListSelectionDialog dialog =
           new ConditionalListSelectionDialog(
               PDEPlugin.getActiveWorkbenchShell(),
               labelProvider,
               PDEUIMessages.ExportPackageSection_dialogButtonLabel);
       final Collection<?> pckgs = fHeader == null ? new Vector<>() : fHeader.getPackageNames();
       final boolean allowJava =
           "true".equals(getBundle().getHeader(ICoreConstants.ECLIPSE_JREBUNDLE)); // $NON-NLS-1$
       Runnable runnable =
           new Runnable() {
             @Override
             public void run() {
               ArrayList<IPackageFragment> elements = new ArrayList<>();
               ArrayList<IPackageFragment> conditional = new ArrayList<>();
               IPackageFragment[] fragments =
                   PDEJavaHelper.getPackageFragments(JavaCore.create(project), pckgs, allowJava);
               for (IPackageFragment fragment : fragments) {
                 try {
                   if (fragment.containsJavaResources()) {
                     elements.add(fragment);
                   } else {
                     conditional.add(fragment);
                   }
                 } catch (JavaModelException e) {
                 }
               }
               dialog.setElements(elements.toArray());
               dialog.setConditionalElements(conditional.toArray());
               dialog.setMultipleSelection(true);
               dialog.setMessage(PDEUIMessages.PackageSelectionDialog_label);
               dialog.setTitle(PDEUIMessages.ExportPackageSection_title);
               dialog.create();
               PlatformUI.getWorkbench()
                   .getHelpSystem()
                   .setHelp(dialog.getShell(), IHelpContextIds.EXPORT_PACKAGES);
               SWTUtil.setDialogSize(dialog, 400, 500);
             }
           };
       BusyIndicator.showWhile(Display.getCurrent(), runnable);
       if (dialog.open() == Window.OK) {
         Object[] selected = dialog.getResult();
         if (fHeader != null) {
           for (Object selectedObject : selected) {
             IPackageFragment candidate = (IPackageFragment) selectedObject;
             fHeader.addPackage(
                 new ExportPackageObject(fHeader, candidate, getVersionAttribute()));
           }
         } else {
           getBundle().setHeader(getExportedPackageHeader(), getValue(selected));
           // the way events get triggered, updateButtons isn't called
           if (selected.length > 0) getTablePart().setButtonEnabled(CALCULATE_USE_INDEX, true);
         }
       }
       labelProvider.dispose();
     }
   } catch (CoreException e) {
   }
 }
  /* (non-Javadoc)
   * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection ssel = (IStructuredSelection) selection;
      Iterator it = ssel.iterator();
      final HashSet projects = new HashSet();
      while (it.hasNext()) {
        Object element = it.next();
        IProject proj = null;
        if (element instanceof IFile) proj = ((IFile) element).getProject();
        if ((proj == null) && (element instanceof IProject)) proj = (IProject) element;
        if ((proj == null) && (element instanceof IAdaptable)) {
          IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
          if (resource != null) {
            proj = resource.getProject();
          }
          if (proj == null) {
            IWorkbenchAdapter workbenchAdapter =
                (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class);
            if (workbenchAdapter != null) {
              Object o = workbenchAdapter.getParent(element);
              if (o instanceof IAdaptable) {
                resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
                if (resource != null) {
                  proj = resource.getProject();
                }
              }
            }
          }
        }

        if (proj != null && WorkspaceModelManager.isPluginProject(proj)) projects.add(proj);
      }
      if (projects.size() > 0) {
        BusyIndicator.showWhile(
            PDEPlugin.getActiveWorkbenchShell().getDisplay(),
            new Runnable() {
              public void run() {
                Iterator it = projects.iterator();
                while (it.hasNext()) {
                  IProject project = (IProject) it.next();
                  IFile file = PDEProject.getManifest(project);
                  if (file == null || !file.exists()) file = PDEProject.getPluginXml(project);
                  if (file == null || !file.exists()) file = PDEProject.getFragmentXml(project);
                  if (file == null || !file.exists())
                    MessageDialog.openError(
                        PDEPlugin.getActiveWorkbenchShell(),
                        PDEUIMessages.OpenManifestsAction_title,
                        NLS.bind(PDEUIMessages.OpenManifestsAction_cannotFind, project.getName()));
                  else
                    try {
                      IDE.openEditor(
                          PDEPlugin.getActivePage(), file, IPDEUIConstants.MANIFEST_EDITOR_ID);
                    } catch (PartInitException e) {
                      MessageDialog.openError(
                          PDEPlugin.getActiveWorkbenchShell(),
                          PDEUIMessages.OpenManifestsAction_title,
                          NLS.bind(
                              PDEUIMessages.OpenManifestsAction_cannotOpen, project.getName()));
                    }
                }
              }
            });
      } else
        MessageDialog.openInformation(
            PDEPlugin.getActiveWorkbenchShell(),
            PDEUIMessages.OpenManifestsAction_title,
            PDEUIMessages.OpenManifestAction_noManifest);
    }
    return null;
  }