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; }
public boolean performFinish() { try { String perspId = selection.getAttribute("perspectiveId"); // $NON-NLS-1$ IWorkbenchPage page = PDEPlugin.getActivePage(); if (perspId != null && switchPerspective) { PlatformUI.getWorkbench().showPerspective(perspId, page.getWorkbenchWindow()); } SampleOperation op = new SampleOperation(selection, namesPage.getProjectNames(), new ImportOverwriteQuery()); getContainer().run(true, true, op); IFile sampleManifest = op.getSampleManifest(); if (selectRevealEnabled) { selectReveal(getShell()); } if (activitiesEnabled) enableActivities(); if (sampleEditorNeeded && sampleManifest != null) IDE.openEditor(page, sampleManifest, true); } catch (InvocationTargetException e) { PDEPlugin.logException(e); return false; } catch (InterruptedException e) { // PDEPlugin.logException(e); return false; } catch (CoreException e) { PDEPlugin.logException(e); return false; } catch (OperationCanceledException e) { return false; } return true; }
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(PDEPlugin.getDefault().getLabelProvider()); GridData gd = (GridData) tablePart.getControl().getLayoutData(); gd.heightHint = 300; gd.widthHint = 300; pluginListViewer.setInput(PDEPlugin.getDefault()); if (fSelected != null && fSelected.length > 0) { tablePart.setSelection(fSelected); } setControl(container); Dialog.applyDialogFont(container); PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.UPDATE_CLASSPATH); }
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(); } }
/** * 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); } }
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(); } }
private void executeChange( Object element, String propertyName, Object oldValue, Object newValue) { if (element instanceof PluginObject) { PluginObject pobj = (PluginObject) element; try { pobj.restoreProperty(propertyName, oldValue, newValue); } catch (CoreException e) { PDEPlugin.logException(e); } } else if (element instanceof BuildObject) { BuildObject bobj = (BuildObject) element; try { bobj.restoreProperty(propertyName, oldValue, newValue); } catch (CoreException e) { PDEPlugin.logException(e); } } else if (element instanceof PluginObjectNode) { PluginObjectNode node = (PluginObjectNode) element; String newString = newValue != null ? newValue.toString() : null; node.setXMLAttribute(propertyName, newString); } else if (element instanceof BundleObject) { if (element instanceof ImportPackageObject) { ImportPackageObject ipObj = (ImportPackageObject) element; ipObj.restoreProperty(propertyName, oldValue, newValue); } } }
/** * Creates a new BundleExplorerDialog. * * @param shell the parent shell for the dialog * @param multi <code>true</code> if multi selection is allowed */ public BundleExplorerDialog(Shell shell, boolean multi, IPluginModelBase[] models) { super(shell, multi); setTitle("Plug-in Selection"); setMessage("Select a Plug-in:"); fModels = models; PDEPlugin.getDefault().getLabelProvider().connect(this); setListLabelProvider(PDEPlugin.getDefault().getLabelProvider()); }
public void run() { try { IViewPart view = PDEPlugin.getActivePage().showView(IPDEUIConstants.DEPENDENCIES_VIEW_ID); ((DependenciesView) view).openCallersFor(fModel); } catch (PartInitException e) { PDEPlugin.logException(e); } }
public boolean openHyperLink() { String localiz = getLocalization(); if (localiz == null) { return false; } else if (fBase.getUnderlyingResource() == null) { return false; } else if (fElement.length() == 0 || fElement.charAt(0) != '%') { return false; } IProject proj = fBase.getUnderlyingResource().getProject(); IFile file = proj.getFile(localiz + ".properties"); // $NON-NLS-1$ if (!file.exists()) return false; try { IEditorPart editor = IDE.openEditor(PDEPlugin.getActivePage(), file); if (!(editor instanceof TextEditor)) return false; TextEditor tEditor = (TextEditor) editor; IDocument doc = tEditor.getDocumentProvider().getDocument(tEditor.getEditorInput()); if (doc == null) return false; try { String key = fElement.substring(1); int keyLen = key.length(); int length = doc.getLength(); int start = 0; IRegion region = null; FindReplaceDocumentAdapter docSearch = new FindReplaceDocumentAdapter(doc); while ((region = docSearch.find(start, key, true, false, false, false)) != null) { int offset = region.getOffset(); if (offset > 0) { // check for newline before char c = doc.getChar(offset - 1); if (c != '\n' && c != '\r') { start += keyLen; continue; } } if (offset + keyLen < length) { // check for whitespace / assign symbol after char c = doc.getChar(offset + keyLen); if (!Character.isWhitespace(c) && c != '=' && c != ':') { start += keyLen; continue; } } tEditor.selectAndReveal(offset, keyLen); break; } } catch (BadLocationException e) { PDEPlugin.log(e); } } catch (PartInitException e) { return false; } return true; }
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()); } }
public PluginWorkingSet() { super( "page1", PDEUIMessages.PluginWorkingSet_title, PDEPluginImages.DESC_DEFCON_WIZ); // $NON-NLS-1$ PDEPlugin.getDefault().getLabelProvider().connect(this); }
protected void addEditorPages() { try { addPage(new IUsPage(this)); } catch (PartInitException e) { PDEPlugin.logException(e); } }
protected void saveSettings(IDialogSettings settings) { ISecurePreferences preferences = getPreferences(settings.getName()); if (preferences == null) { // only in case it is not possible to create secured storage in // default location -> in that case do not persist settings return; } try { preferences.putBoolean(S_SIGN_JARS, fButton.getSelection(), true); preferences.put(S_KEYSTORE, fKeystoreText.getText().trim(), true); preferences.put(S_ALIAS, fAliasText.getText().trim(), true); preferences.put(S_PASSWORD, fPasswordText.getText().trim(), true); preferences.put(S_KEYPASS, fKeypassText.getText().trim(), true); // bug387565 - for keys which are starting with this bugfix to be // stored // in secured storage, replace value in settings with empty string // to avoid keeping sensitive info in plain text String[] obsoleted = new String[] {S_KEYSTORE, S_ALIAS, S_PASSWORD, S_KEYPASS}; for (String key : obsoleted) { if (settings.get(key) != null) { settings.put(key, ""); // $NON-NLS-1$ } } } catch (StorageException e) { PDEPlugin.log( "Failed to store JarSigning settings in secured preferences store"); //$NON-NLS-1$ } }
public boolean generate() { try { final Map overwrites = promptForOverwrite(plugins, locales); container.run( false, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { setProgressMonitor(monitor); try { internationalizePlugins(plugins, locales, overwrites); } catch (final Exception ex) { Display.getDefault() .syncExec( new Runnable() { public void run() { PDEPlugin.logException( ex, ex.getMessage(), PDEUIMessages .InternationalizeWizard_NLSFragmentGenerator_errorMessage); } }); } } }); } catch (Exception e) { PDEPlugin.logException(e); } return true; }
private void createContentSection( IManagedForm managedForm, Composite parent, FormToolkit toolkit) { String sectionTitle; // if (isFragment()) { // sectionTitle = PDEUIMessages.ManifestEditor_ContentSection_ftitle; // } else { // sectionTitle = PDEUIMessages.ManifestEditor_ContentSection_title; // } sectionTitle = PDEUIMessages.MonitorEditor_ContentSection_title; Section section = createStaticSection(toolkit, parent, sectionTitle); Composite container = createStaticSectionClient(toolkit, section); FormText text = createClient( container, isFragment() ? PDEUIMessages.OverviewPage_fContent : PDEUIMessages.OverviewPage_content, toolkit); PDELabelProvider lp = PDEPlugin.getDefault().getLabelProvider(); text.setImage( "page", lp.get(PDEPluginImages.DESC_PAGE_OBJ, SharedLabelProvider.F_EDIT)); // $NON-NLS-1$ if (!isBundle() && isEditable()) { String content; if (isFragment()) { content = PDEUIMessages.OverviewPage_fOsgi; } else { content = PDEUIMessages.OverviewPage_osgi; } text = createClient(container, content, toolkit); } section.setClient(container); }
/** * Gets a list of all the bundles that can be added as implicit dependencies * * @return list of possible dependencies */ protected BundleInfo[] getValidBundles() throws CoreException { NameVersionDescriptor[] current = getTargetDefinition().getImplicitDependencies(); Set<String> currentBundles = new HashSet<String>(); if (current != null) { for (int i = 0; i < current.length; i++) { if (!currentBundles.contains(current[i].getId())) { currentBundles.add(current[i].getId()); } } } List<BundleInfo> targetBundles = new ArrayList<BundleInfo>(); TargetBundle[] allTargetBundles = getTargetDefinition().getAllBundles(); if (allTargetBundles == null || allTargetBundles.length == 0) { throw new CoreException( new Status( IStatus.WARNING, PDEPlugin.getPluginId(), PDEUIMessages.ImplicitDependenciesSection_0)); } for (int i = 0; i < allTargetBundles.length; i++) { BundleInfo bundleInfo = allTargetBundles[i].getBundleInfo(); if (!currentBundles.contains(bundleInfo.getSymbolicName())) { currentBundles.add(bundleInfo.getSymbolicName()); // to avoid duplicate entries targetBundles.add(bundleInfo); } } return targetBundles.toArray(new BundleInfo[targetBundles.size()]); }
/** Constructor to create a new wizard */ public NewPluginProjectFromTemplateWizard() { setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWPPRJ_WIZ); setDialogSettings(PDEPlugin.getDefault().getDialogSettings()); setWindowTitle(PDEUIMessages.NewProjectWizard_title); setNeedsProgressMonitor(true); fPluginData = new PluginFieldData(); }
public ILaunchConfiguration getSelectedLaunchConfiguration() { if (!fLaunchConfigButton.getSelection()) return null; String configName = fLaunchConfigCombo.getText(); try { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(EclipseLaunchShortcut.CONFIGURATION_TYPE); ILaunchConfigurationType type2 = manager.getLaunchConfigurationType(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE); ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); ILaunchConfiguration[] configs2 = manager.getLaunchConfigurations(type2); ILaunchConfiguration[] configurations = new ILaunchConfiguration[configs.length + configs2.length]; System.arraycopy(configs, 0, configurations, 0, configs.length); System.arraycopy(configs2, 0, configurations, configs.length, configs2.length); for (int i = 0; i < configurations.length; i++) { if (configurations[i].getName().equals(configName) && !DebugUITools.isPrivate(configurations[i])) return configurations[i]; } } catch (CoreException e) { PDEPlugin.logException(e); } return null; }
/* * (non-Javadoc) * * @see org.eclipse.pde.internal.ui.wizards.NewWizard#performFinish() */ public boolean performFinish() { try { fProjectPage.updateData(); fContentPage.updateData(); IDialogSettings settings = getDialogSettings(); if (settings != null) { fProjectPage.saveSettings(settings); fContentPage.saveSettings(settings); } BasicNewProjectResourceWizard.updatePerspective(fConfig); getContainer() .run( false, true, new NewProjectCreationOperation(fPluginData, fProjectProvider, fTemplateWizard)); IWorkingSet[] workingSets = fProjectPage.getSelectedWorkingSets(); if (workingSets.length > 0) getWorkbench() .getWorkingSetManager() .addToWorkingSets(fProjectProvider.getProject(), workingSets); return true; } catch (InvocationTargetException e) { PDEPlugin.logException(e); } catch (InterruptedException e) { } return false; }
protected void createFormContent(IManagedForm managedForm) { super.createFormContent(managedForm); ScrolledForm form = managedForm.getForm(); FormToolkit toolkit = managedForm.getToolkit(); if (isFragment()) { form.setImage( PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_FRAGMENT_MF_OBJ)); } else { form.setImage( PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_MF_OBJ)); } form.setText(PDEUIMessages.MonitorEditor_OverviewPage_title); fillBody(managedForm, toolkit); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(form.getBody(), IHelpContextIds.MONITOR_PLUGIN_OVERVIEW); }
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()); } } }
/** * Returns an IPluginModelBase from the active ManifestEditor or null if no manifest editor is * open. * * @return the active IPluginModelBase */ public static IPluginModelBase getActivePluginModel() { IEditorPart editor = PDEPlugin.getActivePage().getActiveEditor(); if (editor instanceof ManifestEditor) { IBaseModel model = ((ManifestEditor) editor).getAggregateModel(); if (model instanceof IPluginModelBase) return (IPluginModelBase) model; } return null; }
protected void createSystemFileContexts(InputContextManager manager, FileStoreEditorInput input) { try { IFileStore store = EFS.getStore(input.getURI()); IEditorInput in = new FileStoreEditorInput(store); manager.putContext(in, new CategoryInputContext(this, in, true)); } catch (CoreException e) { PDEPlugin.logException(e); } }
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); } } }
private void handleGoToPackage(ISelection selection) { IPackageFragment frag = getPackageFragment(selection); if (frag != null) try { IViewPart part = PDEPlugin.getActivePage().showView(JavaUI.ID_PACKAGES); ShowInPackageViewAction action = new ShowInPackageViewAction(part.getSite()); action.run(frag); } catch (PartInitException e) { } }
private void createTabs() { for (int i = 0; i < TAB_LABELS.length; i++) { CTabItem item = new CTabItem(fTabFolder, SWT.NULL); item.setText(TAB_LABELS[i]); item.setImage( PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_OPERATING_SYSTEM_OBJ)); } fLastTab = 0; fTabFolder.setSelection(fLastTab); }
private void handleExistingProjects() { ArrayList<Object> result = new ArrayList<>(); for (int i = 0; i < fModels.length; i++) { String id = fModels[i].getPluginBase().getId(); IProject project = (IProject) PDEPlugin.getWorkspace().getRoot().findMember(id); if (project != null && project.isOpen() && WorkspaceModelManager.isPluginProject(project)) { result.add(fModels[i]); } } handleSetImportSelection(result); }
public NewLibraryPluginCreationUpdateRefPage( LibraryPluginFieldData data, Collection<?> initialJarPaths, Collection<?> selection) { super("UpdateReferences"); // $NON-NLS-1$ setTitle(PDEUIMessages.UpdateBuildpathWizard_title); setDescription(PDEUIMessages.UpdateBuildpathWizard_desc); computeUnmigrated(); computeSelected(selection); fData = data; tablePart = new TablePart(PDEUIMessages.UpdateBuildpathWizard_availablePlugins); PDEPlugin.getDefault().getLabelProvider().connect(this); }
/** The default constructor. */ public SampleWizard() { PDEPlugin.getDefault().getLabelProvider().connect(this); setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWEXP_WIZ); samples = Platform.getExtensionRegistry() .getConfigurationElementsFor("org.eclipse.pde.ui.samples"); // $NON-NLS-1$ namesPage = new ProjectNamesPage(this); lastPage = new ReviewPage(this); setNeedsProgressMonitor(true); setWindowTitle(PDEUIMessages.ShowSampleAction_title); }