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; }
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); } } }
protected void addEditorPages() { try { addPage(new IUsPage(this)); } catch (PartInitException e) { PDEPlugin.logException(e); } }
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; }
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; }
/* * (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; }
public void run() { try { IViewPart view = PDEPlugin.getActivePage().showView(IPDEUIConstants.DEPENDENCIES_VIEW_ID); ((DependenciesView) view).openCallersFor(fModel); } catch (PartInitException e) { PDEPlugin.logException(e); } }
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 executeAttributeChange(AttributeChangedEvent e, boolean undo) { PluginElement element = (PluginElement) e.getChangedObjects()[0]; PluginAttribute att = (PluginAttribute) e.getChangedAttribute(); Object oldValue = e.getOldValue(); Object newValue = e.getNewValue(); try { if (undo) element.setAttribute(att.getName(), oldValue.toString()); else element.setAttribute(att.getName(), newValue.toString()); } catch (CoreException ex) { PDEPlugin.logException(ex); } }
public boolean performFinish() { boolean result = true; try { getContainer().run(false, true, getOperation()); } catch (final InvocationTargetException e) { PDEPlugin.logException(e); result = false; } catch (final InterruptedException e) { result = false; } return result; }
private void computeUnmigrated() { IPluginModelBase[] models = PluginRegistry.getWorkspaceModels(); ArrayList<IPluginModelBase> modelArray = new ArrayList<IPluginModelBase>(); 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) { PDEPlugin.logException(e); } fUnmigrated = modelArray.toArray(new IPluginModelBase[modelArray.size()]); }
private void writeFile(IFile file, StringWriter swriter) { try { ByteArrayInputStream stream = new ByteArrayInputStream(swriter.toString().getBytes("UTF8")); // $NON-NLS-1$ if (file.exists()) { file.setContents(stream, false, false, null); } else { file.create(stream, false, null); } stream.close(); swriter.close(); } catch (Exception e) { PDEPlugin.logException(e); } }
/** * Implements the interface method by looping through template sections and executing them * sequentially. * * @param project the project * @param model the plug-in model * @param monitor the progress monitor to track the execution progress as part of the overall new * project creation operation * @return <code>true</code> if the wizard completed the operation with success, <code>false * </code> otherwise. */ public boolean performFinish(IProject project, IPluginModelBase model, IProgressMonitor monitor) { try { ITemplateSection[] sections = getTemplateSections(); monitor.beginTask("", sections.length); // $NON-NLS-1$ for (int i = 0; i < sections.length; i++) { sections[i].execute(project, model, new SubProgressMonitor(monitor, 1)); } // No reason to do this any more with the new editors // saveTemplateFile(project, null); } catch (CoreException e) { PDEPlugin.logException(e); return false; } finally { monitor.done(); } return true; }
@Override public boolean performFinish() { try { BasicNewProjectResourceWizard.updatePerspective(fConfig); final IProject project = fMainPage.getProjectHandle(); final IPath location = fMainPage.getLocationPath(); final String webLocation = fMainPage.getWebLocation(); IRunnableWithProgress op = new NewSiteProjectCreationOperation( getShell().getDisplay(), project, location, webLocation); getContainer().run(false, true, op); } catch (InvocationTargetException e) { PDEPlugin.logException(e); return false; } catch (InterruptedException e) { return false; } return true; }
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 String[] getLaunchConfigurations() { ArrayList list = new ArrayList(); try { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(EclipseLaunchShortcut.CONFIGURATION_TYPE); ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); for (int i = 0; i < configs.length; i++) { if (!DebugUITools.isPrivate(configs[i])) list.add(configs[i].getName()); } // add osgi launch configs to the list type = manager.getLaunchConfigurationType(IPDELauncherConstants.OSGI_CONFIGURATION_TYPE); configs = manager.getLaunchConfigurations(type); for (int i = 0; i < configs.length; i++) { if (!DebugUITools.isPrivate(configs[i])) list.add(configs[i].getName()); } } catch (CoreException e) { PDEPlugin.logException(e); } return (String[]) list.toArray(new String[list.size()]); }
private void handleAddCategoryDefinition() { String name = NLS.bind( PDEUIMessages.CategorySection_newCategoryName, Integer.toString(++newCategoryCounter)); while (categoryExists(name)) { name = NLS.bind( PDEUIMessages.CategorySection_newCategoryName, Integer.toString(++newCategoryCounter)); } String label = NLS.bind( PDEUIMessages.CategorySection_newCategoryLabel, Integer.toString(newCategoryCounter)); ISiteCategoryDefinition categoryDef = fModel.getFactory().createCategoryDefinition(); try { categoryDef.setName(name); categoryDef.setLabel(label); fModel.getSite().addCategoryDefinitions(new ISiteCategoryDefinition[] {categoryDef}); } catch (CoreException e) { PDEPlugin.logException(e); } fCategoryViewer.setSelection(new StructuredSelection(categoryDef), true); }
private void executeRemove(IModelChangeProvider model, Object[] elements) { IPluginBase pluginBase = null; IBuild build = null; IBundleModel bundleModel = null; if (model instanceof IPluginModelBase) { pluginBase = ((IPluginModelBase) model).getPluginBase(); } else if (model instanceof IBuildModel) { build = ((IBuildModel) model).getBuild(); } else if (model instanceof IBundleModel) { bundleModel = (IBundleModel) model; } try { for (Object element : elements) { if (element instanceof IPluginImport) { pluginBase.remove((IPluginImport) element); } else if (element instanceof IPluginLibrary) { pluginBase.remove((IPluginLibrary) element); } else if (element instanceof IPluginExtensionPoint) { pluginBase.remove((IPluginExtensionPoint) element); } else if (element instanceof IPluginExtension) { pluginBase.remove((IPluginExtension) element); } else if (element instanceof IPluginElement) { IPluginElement e = (IPluginElement) element; Object parent = e.getParent(); if (parent instanceof PluginLibraryNode && e instanceof PluginElementNode) { ((PluginLibraryNode) parent).removeContentFilter((PluginElementNode) e); } else if (parent instanceof IPluginParent) { ((IPluginParent) parent).remove(e); } } else if (element instanceof IBuildEntry) { IBuildEntry e = (IBuildEntry) element; build.remove(e); } else if (element instanceof BundleObject) { if (element instanceof ImportPackageObject) { IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.IMPORT_PACKAGE); if (header != null && header instanceof ImportPackageHeader) { ((ImportPackageHeader) header).removePackage((PackageObject) element); } } if (element instanceof RequireBundleObject) { IBaseModel aggModel = getEditor().getAggregateModel(); if (aggModel instanceof BundlePluginModel) { BundlePluginModel mod = (BundlePluginModel) aggModel; pluginBase = mod.getPluginBase(); IPluginImport[] imports = pluginBase.getImports(); IPluginImport currentImport = null; for (IPluginImport pluginImport : imports) { String elementValue = ((RequireBundleObject) element).getValue(); if (pluginImport.getId().equals(elementValue)) { currentImport = pluginImport; break; } } IPluginImport[] plugins = {currentImport}; if (pluginBase instanceof BundlePluginBase && currentImport != null) ((BundlePluginBase) pluginBase).remove(plugins); } } if (element instanceof ExportPackageObject) { IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.EXPORT_PACKAGE); if (header != null && header instanceof ExportPackageHeader) { ((ExportPackageHeader) header).removePackage((PackageObject) element); } } } } } catch (CoreException e) { PDEPlugin.logException(e); } }
private void executeAdd(IModelChangeProvider model, Object[] elements) { IPluginBase pluginBase = null; IBuild build = null; IBundleModel bundleModel = null; if (model instanceof IPluginModelBase) { pluginBase = ((IPluginModelBase) model).getPluginBase(); } else if (model instanceof IBuildModel) { build = ((IBuildModel) model).getBuild(); } else if (model instanceof IBundleModel) { bundleModel = (IBundleModel) model; } try { for (Object element : elements) { if (element instanceof IPluginImport) { pluginBase.add((IPluginImport) element); } else if (element instanceof IPluginLibrary) { pluginBase.add((IPluginLibrary) element); } else if (element instanceof IPluginExtensionPoint) { pluginBase.add((IPluginExtensionPoint) element); } else if (element instanceof IPluginExtension) { pluginBase.add((IPluginExtension) element); } else if (element instanceof IPluginElement) { IPluginElement e = (IPluginElement) element; Object parent = e.getParent(); if (parent instanceof PluginLibraryNode && e instanceof PluginElementNode) { ((PluginLibraryNode) parent).addContentFilter((PluginElementNode) e); } else if (parent instanceof IPluginParent) { ((IPluginParent) parent).add(e); } } else if (element instanceof IBuildEntry) { IBuildEntry e = (IBuildEntry) element; build.add(e); } else if (element instanceof BundleObject) { if (element instanceof ImportPackageObject) { IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.IMPORT_PACKAGE); if (header != null && header instanceof ImportPackageHeader) { ((ImportPackageHeader) header).addPackage((PackageObject) element); } } if (element instanceof RequireBundleObject) { IBaseModel aggModel = getEditor().getAggregateModel(); if (aggModel instanceof BundlePluginModel) { BundlePluginModel pluginModel = (BundlePluginModel) aggModel; RequireBundleObject requireBundle = (RequireBundleObject) element; pluginBase = pluginModel.getPluginBase(); String elementValue = requireBundle.getValue(); IPluginImport importNode = null; if (pluginModel.getPluginFactory() instanceof BundlePluginModelBase) importNode = ((BundlePluginModelBase) pluginModel.getPluginFactory()) .createImport(elementValue); String version = ((RequireBundleObject) element).getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE); IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.REQUIRE_BUNDLE); int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion( ((RequireBundleHeader) header).getBundle()); boolean option = (bundleManifestVersion > 1) ? Constants.RESOLUTION_OPTIONAL.equals( requireBundle.getDirective(Constants.RESOLUTION_DIRECTIVE)) : "true" .equals( requireBundle.getAttribute( ICoreConstants.OPTIONAL_ATTRIBUTE)); // $NON-NLS-1$; boolean exported = (bundleManifestVersion > 1) ? Constants.VISIBILITY_REEXPORT.equals( requireBundle.getDirective(Constants.VISIBILITY_DIRECTIVE)) : "true" .equals( requireBundle.getAttribute( ICoreConstants.REPROVIDE_ATTRIBUTE)); // $NON-NLS-1$; if (importNode != null) { importNode.setVersion(version); importNode.setOptional(option); importNode.setReexported(exported); } if (pluginBase instanceof BundlePluginBase && importNode != null) ((BundlePluginBase) pluginBase).add(importNode); } } if (element instanceof ExportPackageObject) { IManifestHeader header = bundleModel.getBundle().getManifestHeader(Constants.EXPORT_PACKAGE); if (header != null && header instanceof ExportPackageHeader) { ((ExportPackageHeader) header).addPackage((PackageObject) element); } } } } } catch (CoreException e) { PDEPlugin.logException(e); } }
public static void logException(Throwable e) { logException(e, null, null); }