org.eclipse.pde.core.plugin.IPluginModelBase Java Examples
The following examples show how to use
org.eclipse.pde.core.plugin.IPluginModelBase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientTemplate.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public void execute ( final IProject project, final IPluginModelBase model, final IProgressMonitor monitor ) throws CoreException { monitor.beginTask ( "Creating client", 5 ); super.execute ( project, model, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 final Map<String, String> properties = new HashMap<> (); properties.put ( "pluginId", this.pluginId ); //$NON-NLS-1$ properties.put ( "version", this.version ); //$NON-NLS-1$ properties.put ( "mavenVersion", this.version.replaceFirst ( "\\.qualifier$", "-SNAPSHOT" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ createParentProject ( project, properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 createProductProject ( project, properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 createFeatureProject ( project, properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 addFilteredResource ( project, "pom.xml", getResource ( "app-pom.xml" ), "UTF-8", properties, new SubProgressMonitor ( monitor, 1 ) ); // COUNT:1 }
Example #2
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Finds extensions of given {@link ExtensionType extension type} in given {@link IPluginModelBase plugin model}. * If {@code type} is {@link ExtensionType#ALL}, all extensions which may be mapped to {@link ExtensionType} are * returned. (They must have an ID pattern as defined in {@link #getExtensionId(CheckCatalog, ExtensionType)}). * * @param pluginModel * the plugin in which to find the extensions * @param catalogName * qualified catalog name * @param type * the extension type to be looked up * @return a collection of extensions in the plugin.xml that match given extension type */ private Collection<IPluginExtension> findExtensions(final IPluginModelBase pluginModel, final QualifiedName catalogName, final ExtensionType type) { IPluginExtension[] pluginExtensions = pluginModel.getPluginBase().getExtensions(); final String extensionId = getExtensionId(catalogName, type); final String point = getExtensionHelper(type) == null ? null : getExtensionHelper(type).getExtensionPointId(); return Collections2.filter(Arrays.asList(pluginExtensions), new Predicate<IPluginExtension>() { @Override public boolean apply(final IPluginExtension extension) { final String currentExtensionId = extension.getId(); if (type == ExtensionType.ALL) { if (currentExtensionId == null) { return getAllExtensionPointIds().contains(extension.getPoint()); } else { final int pos = currentExtensionId.lastIndexOf('.'); return pos != -1 && getAllExtensionPointIds().contains(extension.getPoint()) && Strings.equal(currentExtensionId.substring(0, pos), extensionId); } } else { return Strings.equal(currentExtensionId, extensionId) && Strings.equal(extension.getPoint(), point); } } }); }
Example #3
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Add check catalog extensions if not already existing. * * @param catalog * the catalog * @param pluginModel * the plugin model * @param monitor * the monitor * @throws CoreException * the core exception */ public void addExtensions(final CheckCatalog catalog, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException { QualifiedName catalogName = nameProvider.apply(catalog); Collection<IPluginExtension> catalogExtensions = findExtensions(pluginModel, catalogName, ExtensionType.ALL); Iterable<ExtensionType> registeredExtensionTypes = findExtensionTypes(catalogExtensions); for (ExtensionType type : ExtensionType.values()) { ICheckExtensionHelper helper = getExtensionHelper(type); if (helper == null) { continue; } if (!Iterables.contains(registeredExtensionTypes, type)) { helper.addExtensionToPluginBase(pluginModel, catalog, type, getExtensionId(nameProvider.apply(catalog), type)); } } }
Example #4
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Sorts the plug-in extensions alphabetically by extension point ID and then by extension ID (and name in case the IDs are equal or null). * * @param pluginModel * the plugin model * @param monitor * the monitor * @throws CoreException * the core exception */ public void sortAllExtensions(final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException { Ordering<IPluginExtension> ordering = Ordering.from((a, b) -> ComparisonChain.start().compare(a.getPoint(), b.getPoint()).compare(a.getId(), b.getId(), Ordering.natural().nullsLast()).compare(a.getName(), b.getName(), Ordering.natural().nullsLast()).result()); List<IPluginExtension> catalogExtensions = Lists.newArrayList(findAllExtensions(pluginModel)); List<IPluginExtension> orderedExtensions = ordering.sortedCopy(catalogExtensions); if (catalogExtensions.equals(orderedExtensions)) { return; } for (int i = 0; i < orderedExtensions.size(); i++) { IPluginExtension expected = orderedExtensions.get(i); IPluginExtension actual = catalogExtensions.get(i); if (!Objects.equals(actual, expected)) { // IExtensions#swap() doesn't work; see https://bugs.eclipse.org/bugs/show_bug.cgi?id=506831 // pluginModel.getExtensions().swap(expected, actual); for (int j = i; j < catalogExtensions.size(); j++) { pluginModel.getExtensions().remove(catalogExtensions.get(j)); } for (int j = i; j < orderedExtensions.size(); j++) { pluginModel.getExtensions().add(orderedExtensions.get(j)); } break; } } }
Example #5
Source File: AbstractCheckExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Creates the extension. Note that the <code>id</code> attribute is optional and thus not created. * * @param catalog * the catalog for which to crate the extension content. * @param extensionId * the extension id, may be <code>null</code> * @param pluginModel * the model * @return the plugin extension * @throws CoreException * a core exception */ protected IPluginExtension createExtension(final CheckCatalog catalog, final String extensionId, final IPluginModelBase pluginModel) throws CoreException { IPluginExtension newExtension = pluginModel.getFactory().createExtension(); newExtension.setPoint(getExtensionPointId()); if (extensionId != null) { newExtension.setId(extensionId); } if (getExtensionPointName(catalog) != null) { newExtension.setName(getExtensionPointName(catalog)); } // Add contents to the extension for (final IPluginObject p : getElements(catalog, newExtension)) { newExtension.add(p); } return newExtension; }
Example #6
Source File: ReportLauncherUtils.java From birt with Eclipse Public License 1.0 | 6 votes |
private static String getOSGiPath( ) { ModelEntry entry = PDECore.getDefault( ) .getModelManager( ) .findEntry( "org.eclipse.osgi" ); //$NON-NLS-1$ if ( entry != null && entry.getActiveModels( ).length > 0 ) { IPluginModelBase model = entry.getActiveModels( )[0]; if ( model.getUnderlyingResource( ) != null ) { return model.getUnderlyingResource( ) .getLocation( ) .removeLastSegments( 2 ) .toOSString( ); } return model.getInstallLocation( ); } return null; }
Example #7
Source File: LaunchShortcut.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private void split ( final Map<String, Bundle> all, final Set<Bundle> targetResult, final Set<Bundle> workspaceResult ) { final Set<IPluginModelBase> workspaceSet = new HashSet<> ( Arrays.asList ( PluginRegistry.getWorkspaceModels () ) ); for ( final Bundle b : all.values () ) { final IPluginModelBase model = PluginRegistry.findModel ( b.name ); if ( workspaceSet.contains ( model ) ) { workspaceResult.add ( b ); } else { targetResult.add ( b ); } } }
Example #8
Source File: ScriptDebugUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @param model * @param libraryName * @return */ public static IPath getPath( IPluginModelBase model, String libraryName ) { IResource resource = model.getUnderlyingResource( ); if ( resource != null ) { IResource jarFile = resource.getProject( ).findMember( libraryName ); return ( jarFile != null ) ? jarFile.getFullPath( ) : null; } File file = new File( model.getInstallLocation( ), libraryName ); return file.exists( ) ? new Path( file.getAbsolutePath( ) ) : null; }
Example #9
Source File: CheckExtensionGenerator.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Returns the plugin model associated to the given file. * * @param file * a plugin.xml file * @return a plugin model */ protected IPluginModelBase getModel(final IFile file) { if (STANDARD_FRAGMENT_FILENAME.equals(file.getName())) { return new WorkspaceFragmentModel(file, false); } else { return new WorkspacePluginModel(file, false); } }
Example #10
Source File: AbstractCheckDocumentationExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected boolean isExtensionEnabled(final IPluginModelBase base, final CheckCatalog catalog, final ExtensionType type, final String extensionId) { if (!super.isExtensionEnabled(base, catalog, type, extensionId)) { return false; } // Do not generate plugin.xml extensions for docu in a non SCA-plugin CheckGeneratorConfig config = generatorConfigProvider.get(catalog.eResource().getURI()); return !config.isGenerateLanguageInternalChecks(); }
Example #11
Source File: CheckMarkerHelpExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Gets the plugin id of the project. * * @param extension * the extension * @return the plugin id */ private String getPluginId(final IPluginExtension extension) { // TODO if marker help extensions used the ID attribute, it would be possible to find the extension // contributor using Platform.getExtensionRegistry.findExtension(extension.getId()).getContributor().getName() // or similar; that would be more elegant. PluginRegistry#findModel(IProject) is expensive! IResource file = extension.getModel().getUnderlyingResource(); if (file.getProject() == null) { return null; } IPluginModelBase pluginModel = PluginRegistry.findModel(file.getProject()); return pluginModel != null ? pluginModel.getPluginBase().getId() : null; }
Example #12
Source File: CheckMarkerHelpExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final CheckCatalog catalog, final ExtensionType type) throws CoreException { final IQualifiedNameProvider nameProvider = getFromServiceProvider(IQualifiedNameProvider.class, catalog); if (extension.getChildCount() == Iterables.size(getElements(nameProvider.apply(catalog), catalog.eResource().getURI(), extension))) { // remove whole extension, all existing marker elements belong to this catalog base.getPluginBase().remove(extension); } else { // only remove elements of this catalog, other catalogs have marker elements for (IPluginElement e : getElements(nameProvider.apply(catalog), catalog.eResource().getURI(), extension)) { extension.remove(e); } } }
Example #13
Source File: CheckMarkerHelpExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final IEObjectDescription obj, final ExtensionType type) throws CoreException { if (extension.getChildCount() == Iterables.size(getElements(obj.getName(), obj.getEObjectURI(), extension))) { // remove whole extension, all existing marker elements belong to this catalog base.getPluginBase().remove(extension); } else { // only remove elements of this catalog, other catalogs have marker elements for (IPluginElement e : getElements(obj.getName(), obj.getEObjectURI(), extension)) { extension.remove(e); } } }
Example #14
Source File: AbstractCheckExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override public IPluginExtension addExtensionToPluginBase(final IPluginModelBase base, final CheckCatalog catalog, final ExtensionType type, final String extensionId) throws CoreException { if (isExtensionEnabled(base, catalog, type, extensionId)) { IPluginExtension newExtension = createExtension(catalog, extensionId, base); base.getPluginBase().add(newExtension); return newExtension; } return null; }
Example #15
Source File: PDEClassPathGenerator.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private static Collection<String> createPluginClassPath(IJavaProject javaProject, Set<IProject> projectOnCp) throws CoreException { Set<String> javaClassPath = createJavaClasspath(javaProject, projectOnCp); IPluginModelBase model = PluginRegistry.findModel(javaProject.getProject()); if (model == null || model.getPluginBase().getId() == null) { return javaClassPath; } ArrayList<String> pdeClassPath = new ArrayList<>(); pdeClassPath.addAll(javaClassPath); BundleDescription target = model.getBundleDescription(); Set<BundleDescription> bundles = new HashSet<>(); // target is null if plugin uses non OSGI format if (target != null) { addDependentBundles(target, bundles); } // convert default location (relative to wsp) to absolute path IPath defaultOutputLocation = ResourceUtils.relativeToAbsolute(javaProject.getOutputLocation()); for (BundleDescription bd : bundles) { appendBundleToClasspath(bd, pdeClassPath, defaultOutputLocation); } if (defaultOutputLocation != null) { String defaultOutput = defaultOutputLocation.toOSString(); if (pdeClassPath.indexOf(defaultOutput) > 0) { pdeClassPath.remove(defaultOutput); pdeClassPath.add(0, defaultOutput); } } return pdeClassPath; }
Example #16
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Returns all Check extensions in the given plug-in model. * * @param pluginModel * plug-in model, must not be {@code null} * @return all Check extensions * @see #getAllExtensionPointIds() */ private Collection<IPluginExtension> findAllExtensions(final IPluginModelBase pluginModel) { Set<String> allExtensionPointIds = getAllExtensionPointIds(); IPluginExtension[] pluginExtensions = pluginModel.getPluginBase().getExtensions(); return Collections2.filter(Arrays.asList(pluginExtensions), new Predicate<IPluginExtension>() { @Override public boolean apply(final IPluginExtension extension) { return allExtensionPointIds.contains(extension.getPoint()); } }); }
Example #17
Source File: ReportAdvancedLauncherTab.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @param model * @param checked */ // should update later private void handleCheckStateChanged( IPluginModelBase model, boolean checked ) { if ( model.getUnderlyingResource( ) == null ) { if ( checked ) { fNumExternalChecked += 1; } else { fNumExternalChecked -= 1; } } else { if ( model instanceof IProject ) { try { if ( ( (IProject) model ).hasNature( REPORTPROJECTKID ) ) { fNumWorkspaceBIRTChecked += checked ? 1 : -1; } else if ( ( (IProject) model ).hasNature( JavaCore.NATURE_ID ) ) { fNumWorkspaceJavaChecked += checked ? 1 : -1; } } catch ( CoreException e ) { logger.log( Level.SEVERE, e.getMessage( ), e ); } fNumWorkspaceChecked = fNumWorkspaceBIRTChecked + fNumWorkspaceJavaChecked; } } adjustGroupState( ); }
Example #18
Source File: CheckTocExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final IEObjectDescription obj, final ExtensionType type) throws CoreException { // do nothing, the extension must not be removed }
Example #19
Source File: CheckTocExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final CheckCatalog catalog, final ExtensionType type) throws CoreException { // do nothing, the extension must not be removed }
Example #20
Source File: CheckQuickfixExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override protected boolean isExtensionEnabled(final IPluginModelBase base, final CheckCatalog catalog, final ExtensionType type, final String extensionId) { IProject project = base.getUnderlyingResource().getProject(); return super.isExtensionEnabled(base, catalog, type, extensionId) && projectHelper.isJavaFilePresent(project, getTargetClassName(catalog)); }
Example #21
Source File: BaseTemplate.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public void initializeFields ( final IPluginModelBase model ) { this.pluginId = model.getPluginBase ().getId (); this.version = model.getPluginBase ().getVersion (); }
Example #22
Source File: AbstractCheckExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final IEObjectDescription obj, final ExtensionType type) throws CoreException { base.getPluginBase().remove(extension); // remove the extension }
Example #23
Source File: AbstractCheckExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final CheckCatalog catalog, final ExtensionType type) throws CoreException { base.getPluginBase().remove(extension); // remove the extension }
Example #24
Source File: CheckContextsExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final IEObjectDescription obj, final ExtensionType type) throws CoreException { // do nothing, the extension must not be removed }
Example #25
Source File: CheckContextsExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override public void removeExtensionFromPluginBase(final IPluginModelBase base, final IPluginExtension extension, final CheckCatalog catalog, final ExtensionType type) throws CoreException { // do nothing, the extension must not be removed }
Example #26
Source File: PDEClassPathGenerator.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
private static void appendBundleToClasspath(BundleDescription bd, List<String> pdeClassPath, IPath defaultOutputLocation) { IPluginModelBase model = PluginRegistry.findModel(bd); if (model == null) { return; } ArrayList<IClasspathEntry> classpathEntries = new ArrayList<>(); ClasspathUtilCore.addLibraries(model, classpathEntries); for (IClasspathEntry cpe : classpathEntries) { IPath location; if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) { location = ResourceUtils.getOutputLocation(cpe, defaultOutputLocation); } else { location = cpe.getPath(); } if (location == null) { continue; } String locationStr = location.toOSString(); if (pdeClassPath.contains(locationStr)) { continue; } // extra cleanup for some directories on classpath String bundleLocation = bd.getLocation(); if (bundleLocation != null && !"jar".equals(location.getFileExtension()) && new File(bundleLocation).isDirectory()) { if (bd.getSymbolicName().equals(location.lastSegment())) { // ignore badly resolved plugin directories inside workspace // ("." as classpath is resolved as plugin root directory) // which is, if under workspace, NOT a part of the classpath continue; } } if (!location.isAbsolute()) { location = ResourceUtils.relativeToAbsolute(location); } if (!isValidPath(location)) { continue; } locationStr = location.toOSString(); if (!pdeClassPath.contains(locationStr)) { pdeClassPath.add(locationStr); } } }
Example #27
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Update check catalog extensions if necessary. * * @param catalog * the catalog * @param pluginModel * the plugin model * @param monitor * the monitor * @throws CoreException * the core exception */ public void updateExtensions(final CheckCatalog catalog, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException { QualifiedName catalogName = nameProvider.apply(catalog); Collection<IPluginExtension> catalogExtensions = findExtensions(pluginModel, catalogName, ExtensionType.ALL); // Update extensions as appropriate for (IPluginExtension extension : catalogExtensions) { for (ICheckExtensionHelper helper : getExtensionHelpers()) { // TODO getExtensionHelper using extension.getPoint() would make this more efficient helper.updateExtension(catalog, extension); } } }
Example #28
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Remove check catalog extensions as a catalog is removed. * * @param obj * the catalog * @param pluginModel * the plugin model * @param monitor * the monitor * @throws CoreException * the core exception */ public void removeExtensions(final IEObjectDescription obj, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException { for (IPluginExtension extension : findExtensions(pluginModel, obj.getName(), ExtensionType.ALL)) { final ExtensionType extensionType = getExtensionType(extension); getExtensionHelper(extensionType).removeExtensionFromPluginBase(pluginModel, extension, obj, extensionType); } }
Example #29
Source File: CheckExtensionHelperManager.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Removes the extensions. Is called when the catalog still exists (it has not been deleted) and plugin extensions which no longer correspond * to the model exist. This is the case if the model becomes invalid. Extensions are then removed from the plugin model. * * @param catalog * the catalog * @param pluginModel * the plugin model * @param monitor * the monitor * @throws CoreException * the core exception */ public void removeExtensions(final CheckCatalog catalog, final IPluginModelBase pluginModel, final IProgressMonitor monitor) throws CoreException { QualifiedName name = nameConverter.toQualifiedName(projectUtil.getCatalogQualifiedName(catalog)); for (IPluginExtension extension : findExtensions(pluginModel, name, ExtensionType.ALL)) { final ExtensionType extensionType = getExtensionType(extension); getExtensionHelper(extensionType).removeExtensionFromPluginBase(pluginModel, extension, catalog, extensionType); } }
Example #30
Source File: AbstractCheckExtensionHelper.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Determines if the extension point should be enabled. * * @param base * the base * @param catalog * the catalog * @param type * the type * @param extensionId * the extension id * @return true, if the extension should be enabled */ protected boolean isExtensionEnabled(final IPluginModelBase base, final CheckCatalog catalog, final ExtensionType type, final String extensionId) { if (type == ExtensionType.MARKERHELP) { return false; // disabled until https://bugs.eclipse.org/bugs/show_bug.cgi?id=369534 is fixed } String projectSetting = projectHelper.getProjectPreference(base.getUnderlyingResource().getProject(), getExtensionEnablementPreferenceName()); return projectSetting == null || Boolean.valueOf(projectSetting); }