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()); } } }
/* * (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 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) { } }