public void computeImports() throws CoreException { // some existing imports may valid and can be preserved Vector preservedImports = new Vector(fImports.size()); // new imports ArrayList newImports = new ArrayList(); IPluginModelBase model = null; for (int i = 0; i < fPlugins.size(); i++) { IFeaturePlugin fp = (IFeaturePlugin) fPlugins.get(i); ModelEntry entry = PluginRegistry.findEntry(fp.getId()); if (entry == null) continue; IPluginModelBase[] models = entry.getActiveModels(); for (int j = 0; j < models.length; j++) { IPluginModelBase m = models[j]; if (fp.getVersion().equals(m.getPluginBase().getVersion()) || fp.getVersion().equals("0.0.0")) // $NON-NLS-1$ model = m; } if (model != null) { addPluginImports(preservedImports, newImports, model.getPluginBase()); if (model.isFragmentModel()) { BundleDescription desc = model.getBundleDescription(); if (desc == null) continue; HostSpecification hostSpec = desc.getHost(); String id = hostSpec.getName(); String version = null; int match = IMatchRules.NONE; VersionRange versionRange = hostSpec.getVersionRange(); if (!(versionRange == null || VersionRange.emptyRange.equals(versionRange))) { version = versionRange.getMinimum() != null ? versionRange.getMinimum().toString() : null; match = PluginBase.getMatchRule(versionRange); } addNewDependency(id, version, match, preservedImports, newImports); } } } // preserve imports of features for (int i = 0; i < fImports.size(); i++) { IFeatureImport iimport = (IFeatureImport) fImports.get(i); if (iimport.getType() == IFeatureImport.FEATURE) preservedImports.add(iimport); } // removed = old - preserved Vector removedImports = ((Vector) fImports.clone()); removedImports.removeAll(preservedImports); // perform remove fImports = preservedImports; if (removedImports.size() > 0) { fireStructureChanged( (IFeatureImport[]) removedImports.toArray(new IFeatureImport[removedImports.size()]), IModelChangedEvent.REMOVE); } // perform add if (newImports.size() > 0) { fImports.addAll(newImports); fireStructureChanged( (IFeatureImport[]) newImports.toArray(new IFeatureImport[newImports.size()]), IModelChangedEvent.INSERT); } }
/** * The fields are populated based on the plug-in attributes. Some fields are set to their default * values. */ private FragmentFieldData populateFieldData(IPluginModelBase plugin, Locale locale) { FragmentFieldData fragmentData = new FragmentFieldData(); fragmentData.setId(pluginName(plugin, locale)); fragmentData.setVersion(DEFAULT_VERSION); fragmentData.setMatch(0); fragmentData.setPluginId(plugin.getPluginBase().getId()); fragmentData.setPluginVersion(incrementRelease(plugin.getPluginBase().getVersion())); fragmentData.setName(pluginName(plugin, locale) + " Fragment"); // $NON-NLS-1$ fragmentData.setProvider(EMPTY_STRING); fragmentData.setSimple(true); if (!(plugin instanceof ExternalPluginModelBase)) { fragmentData.setSourceFolderName("src"); // $NON-NLS-1$ fragmentData.setOutputFolderName("bin"); // $NON-NLS-1$ } fragmentData.setLegacy(false); fragmentData.setTargetVersion( Double.toString(ensureTargetVersionCompatibility(TargetPlatformHelper.getTargetVersion()))); fragmentData.setHasBundleStructure(true); fragmentData.setOSGiFramework(null); fragmentData.setWorkingSets(null); return fragmentData; }
private void initializeState() { fLaunchConfigCombo.setEnabled(false); if (fLaunchConfigCombo.getItemCount() > 0) fLaunchConfigCombo.setText(fLaunchConfigCombo.getItem(0)); if (fModel != null && fModel.getPluginBase().getId() != null) { IPluginExtension[] extensions = fModel.getPluginBase().getExtensions(); for (int i = 0; i < extensions.length; i++) { String point = extensions[i].getPoint(); if ("org.eclipse.core.runtime.products".equals(point)) { // $NON-NLS-1$ String id = extensions[i].getId(); if (id != null) { String full = fModel.getPluginBase().getId() + "." + id; // $NON-NLS-1$ if (fProductCombo.indexOf(full) != -1) { fProductCombo.setText(full); fProductButton.setSelection(true); return; } } } } } fBasicButton.setSelection(true); fProductCombo.setEnabled(false); if (fProductCombo.getItemCount() > 0) fProductCombo.setText(fProductCombo.getItem(0)); }
/** * Validates that the version of the given plug-in is available in the registry. Adds a warning if * the plug-in could not be found. * * @param plugin xml element describing the plug-in to look for in the registry * @param attr set of element attributes */ private void validateVersion(Element plugin, Attr attr) { String id = plugin.getAttribute("id"); // $NON-NLS-1$ String version = plugin.getAttribute("version"); // $NON-NLS-1$ if (id.trim().length() == 0 || version.trim().length() == 0 || version.equals("0.0.0")) // $NON-NLS-1$ return; ModelEntry entry = PluginRegistry.findEntry(id); if (entry != null) { IPluginModelBase[] allModels = entry.getActiveModels(); for (int i = 0; i < allModels.length; i++) { IPluginModelBase availablePlugin = allModels[i]; if (id.equals(availablePlugin.getPluginBase().getId())) { if (version.equals(availablePlugin.getPluginBase().getVersion())) { return; } } } } report( NLS.bind( PDECoreMessages.Builders_Feature_mismatchPluginVersion, new String[] {version, id}), getLine(plugin, attr.getName()), CompilerFlags.WARNING, PDEMarkerFactory.CAT_OTHER); }
private void loadManifestAndIntroIds(boolean onlyLoadManifest) { TreeSet<String> result = new TreeSet<String>(); String introId; IExtension[] extensions = PDECore.getDefault() .getExtensionsRegistry() .findExtensions("org.eclipse.ui.intro", true); // $NON-NLS-1$ for (int i = 0; i < extensions.length; i++) { IConfigurationElement[] children = extensions[i].getConfigurationElements(); for (int j = 0; j < children.length; j++) { if ("introProductBinding".equals(children[j].getName())) { // $NON-NLS-1$ String attribute = children[j].getAttribute("productId"); // $NON-NLS-1$ if (attribute != null && attribute.equals(getProduct().getProductId())) { if (fManifest == null) { IPluginModelBase base = PluginRegistry.findModel(extensions[i].getContributor().getName()); if (base == null) continue; fManifest = (IFile) base.getUnderlyingResource(); } if (onlyLoadManifest) return; introId = children[j].getAttribute("introId"); // $NON-NLS-1$ if (introId != null) result.add(introId); } } } } fAvailableIntroIds = result.toArray(new String[result.size()]); }
protected void collectSuites(IPluginModelBase model, Set<String> visited) { if (!model.isEnabled()) return; BundleDescription description = model.getBundleDescription(); if (!visited.add(description.getSymbolicName())) return; model.addModelChangedListener(this); listentingTo.add(model); for (IPluginExtension ext : model.getExtensions(true).getExtensions()) if ("org.xpect.testSuite".equals(ext.getPoint())) { for (IPluginObject child : ext.getChildren()) { if (child instanceof IPluginElement) { IPluginElement pluginElement = (IPluginElement) child; IPluginAttribute clazz = pluginElement.getAttribute("class"); IPluginAttribute fileExtension = pluginElement.getAttribute("fileExtension"); if (clazz != null && fileExtension != null) { LazyClass<Object> lazyClass = LazyClass.create( Object.class, clazz.getValue(), (Function<String, Class<?>>) null); TestSuiteInfo info = new TestSuiteInfo(lazyClass, Collections.singleton(fileExtension.getValue())); this.extToInfo.put(fileExtension.getValue(), info); } } } } for (BundleDescription desc : description.getDependents()) { collectSuites(PluginRegistry.findModel(desc), visited); } }
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { IPluginModelBase plugin = (IPluginModelBase) element; Version hVersion = versions.get(plugin.getBundleDescription().getSymbolicName()); if (hVersion == null) return true; return hVersion.equals(plugin.getBundleDescription().getVersion()); }
private boolean canAddExportedPackages() { // Ensure model is editable if (isEditable() == false) { return false; } // Get the model IPluginModelBase model = getModel(); // Ensure model is defined if (model == null) { return false; } // Get the underlying resource IResource resource = model.getUnderlyingResource(); // Ensure resource is defined if (resource == null) { return false; } // Get the project IProject project = resource.getProject(); // Ensure the project is defined if (project == null) { return false; } // Ensure the project is a Java project try { if (project.hasNature(JavaCore.NATURE_ID) == false) { return false; } } catch (CoreException e) { return false; } return true; }
/** * This will search through the workspace for a plugin defined with the given symbolic name and * return it if any. * * @param bundleName Symbolic name of the plugin we're searching a workspace project for. * @return The workspace project of the given symbolic name, <code>null</code> if none could be * found. */ public static IProject getProject(String bundleName) { for (IPluginModelBase model : PluginRegistry.getWorkspaceModels()) { if (model.getBundleDescription().getSymbolicName().equals(bundleName)) { return model.getUnderlyingResource().getProject(); } } return null; }
/** @{inheritDoc */ @Override public String getElementName(Object item) { if (item instanceof IPluginModelBase) { IPluginModelBase model = (IPluginModelBase) item; return model.getPluginBase().getId(); } return null; }
private int compareSimilarObjects(Object o1, Object o2) { if (o1 instanceof IPluginModelBase && o2 instanceof IPluginModelBase) { IPluginModelBase ipmb1 = (IPluginModelBase) o1; IPluginModelBase ipmb2 = (IPluginModelBase) o2; return comparePlugins(ipmb1.getPluginBase(), ipmb2.getPluginBase()); } return 0; }
// Copied from PDEClasspathContainer#getPath protected 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; }
/** * This will refresh the workspace contributions if needed, then search through the workspace * loaded bundles for a class corresponding to <code>qualifiedName</code>. * * @param qualifiedName The qualified name of the class we seek to load. * @param honorOSGiVisibility If <code>true</code>, this will only search through exported * packages for the class <code>qualifiedName</code>. Otherwise we'll search through all * bundles by simply trying to load the class and catching the {@link ClassNotFoundException} * if it isn't loadable. * @return The class <code>qualifiedName</code> if it could be found in the workspace bundles, * <code>null</code> otherwise. */ public synchronized Class<?> getClass(String qualifiedName, boolean honorOSGiVisibility) { if (changedContributions.size() > 0) { refreshContributions(); } // Has an instance of this class already been loaded? Class<?> clazz = null; final WorkspaceClassInstance workspaceInstance = workspaceLoadedClasses.get(qualifiedName); if (workspaceInstance != null) { if (workspaceInstance.isStale()) { for (Map.Entry<IPluginModelBase, Bundle> entry : workspaceInstalledBundles.entrySet()) { final IPluginModelBase model = entry.getKey(); if (workspaceInstance .getBundle() .equals(model.getBundleDescription().getSymbolicName())) { clazz = internalLoadClass(entry.getValue(), qualifiedName); workspaceInstance.setStale(false); workspaceInstance.setClass(clazz); break; } } } else { clazz = workspaceInstance.getInstance().getClass(); } } if (clazz != null) { return clazz; } // The class hasn't been instantiated yet ; search for the class without instantiating it Iterator<Map.Entry<IPluginModelBase, Bundle>> iterator = workspaceInstalledBundles.entrySet().iterator(); while (clazz == null && iterator.hasNext()) { Map.Entry<IPluginModelBase, Bundle> entry = iterator.next(); /* * If we're asked to honor OSGi package visibility, we'll first check the "Export-Package" header * of this bundle's MANIFEST. */ if (!honorOSGiVisibility || hasCorrespondingExportPackage(entry.getKey(), qualifiedName)) { try { clazz = entry.getValue().loadClass(qualifiedName); } catch (ClassNotFoundException e) { // Swallow this ; we'll log the issue later on if we cannot find the class at all } } } if (clazz == null) { AcceleoCommonPlugin.log( AcceleoCommonMessages.getString( "BundleClassLookupFailure", //$NON-NLS-1$ qualifiedName), false); } return clazz; }
@Override public boolean matchItem(Object item) { String id = null; if (item instanceof IPluginModelBase) { IPluginModelBase model = (IPluginModelBase) item; id = model.getPluginBase().getId(); } return (matches(id)); }
/** * This will check through the dependencies of <code>model</code> and install the necessary * workspace plugins if they are required. * * @param model The model of which we wish the dependencies checked. */ private void checkRequireBundleDependencies(IPluginModelBase model) { final BundleDescription desc = model.getBundleDescription(); if (desc == null) { return; } for (BundleSpecification requiredBundle : desc.getRequiredBundles()) { for (IPluginModelBase workspaceModel : PluginRegistry.getWorkspaceModels()) { if (requiredBundle.isSatisfiedBy(workspaceModel.getBundleDescription())) { installBundle(workspaceModel); break; } } } }
private HashMap<?, ?> createCurrentExportPackageMap() { // Dummy hash map created in order to return a defined but empty map HashMap<?, ?> packageFragments = new HashMap<>(0); // Get the model IPluginModelBase model = getModel(); // Ensure model is defined if (model == null) { return packageFragments; } // Get the underlying resource IResource resource = model.getUnderlyingResource(); // Ensure resource is defined if (resource == null) { return packageFragments; } // Get the project IProject project = resource.getProject(); // Ensure the project is defined if (project == null) { return packageFragments; } // Ensure the project is a Java project try { if (project.hasNature(JavaCore.NATURE_ID) == false) { return packageFragments; } } catch (CoreException e) { return packageFragments; } // Get the Java project IJavaProject javaProject = JavaCore.create(project); // Ensure the Java project is defined if (javaProject == null) { return packageFragments; } // Get the current packages associated with the export package header Vector<?> currentExportPackages = null; if (fHeader == null) { currentExportPackages = new Vector<>(); } else { currentExportPackages = fHeader.getPackageNames(); } // Get a hashtable of all the package fragments that are allowed to // be added to the current export package header // Generally, all package fragments contained in the same Java project // as the plugin manifest file // No duplicates are allowed and all current packages are excluded return PDEJavaHelper.getPackageFragmentsHash( javaProject, currentExportPackages, allowJavaPackages()); }
private void validateUnpack(Element parent) { int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_PLUGINS); if (severity == CompilerFlags.IGNORE) { return; } if (severity == CompilerFlags.ERROR) { // this might not be an error, so max the flag at WARNING level. severity = CompilerFlags.WARNING; } String unpack = parent.getAttribute("unpack"); // $NON-NLS-1$ IPluginModelBase pModel = PluginRegistry.findModel(parent.getAttribute("id")); // $NON-NLS-1$ if (pModel == null) { return; } if (pModel instanceof IBundlePluginModel) { IBundlePluginModel bModel = (IBundlePluginModel) pModel; IManifestHeader header = bModel .getBundleModel() .getBundle() .getManifestHeader(ICoreConstants.ECLIPSE_BUNDLE_SHAPE); if (header != null) { String value = header.getValue(); String unpackValue = "true".equals(unpack) ? "jar" : "dir"; // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (value != null && !value.equalsIgnoreCase(unpackValue)) { String message = NLS.bind( PDECoreMessages.Builders_Feature_mismatchUnpackBundleShape, (new String[] { "unpack=" + unpack, parent.getAttribute("id"), "Eclipse-BundleShape: " + value })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ report(message, getLine(parent), severity, PDEMarkerFactory.CAT_OTHER); } } } if ("true".equals(unpack) && !CoreUtility.guessUnpack(pModel.getBundleDescription())) { // $NON-NLS-1$ String message = NLS.bind( PDECoreMessages.Builders_Feature_missingUnpackFalse, (new String[] { parent.getAttribute("id"), "unpack=\"false\"" })); //$NON-NLS-1$ //$NON-NLS-2$ report(message, getLine(parent), severity, PDEMarkerFactory.CAT_OTHER); } }
private static String getServletBridgeAbsolutePath() { String result = null; ModelEntry entry = PluginRegistry.findEntry(Validator.SERVLET_BRIDGE_ID); if (entry != null) { IPluginModelBase[] targetModels = entry.getExternalModels(); for (int i = 0; i < targetModels.length && result == null; i++) { IPluginModelBase bridgeModel = targetModels[i]; String libLocation = bridgeModel.getInstallLocation(); if (libLocation != null && libLocation.toLowerCase().indexOf(".jar") != -1) // $NON-NLS-1$ { result = libLocation; } } } return result; }
/** * Returns a {@link Set} of bundle ids for the dependents of the given objects from the given * {@link State}. The set additionally only includes the given set of implicit dependencies. * * @param selected selected the group of objects to compute dependencies for. Any items in this * array that are not {@link IPluginModelBase}s are ignored. * @param implicit the array of additional implicit dependencies to add to the {@link Set} * @param state the {@link State} to compute the dependencies in * @param removeSelf if the id of one of the bundles were are computing dependencies for should be * included in the result {@link Set} or not * @param includeOptional if optional bundle ids should be included * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from * the dependency resolution * @return a set of bundle IDs */ private static Set<String> getDependencies( Object[] selected, String[] implicit, State state, boolean removeSelf, boolean includeOptional, Set<String> excludeFragments) { Set<String> set = new TreeSet<>(); for (int i = 0; i < selected.length; i++) { if (!(selected[i] instanceof IPluginModelBase)) continue; IPluginModelBase model = (IPluginModelBase) selected[i]; addBundleAndDependencies( model.getBundleDescription(), set, includeOptional, excludeFragments); IPluginExtension[] extensions = model.getPluginBase().getExtensions(); for (int j = 0; j < extensions.length; j++) { String point = extensions[j].getPoint(); if (point != null) { int dot = point.lastIndexOf('.'); if (dot != -1) { String id = point.substring(0, dot); addBundleAndDependencies( state.getBundle(id, null), set, includeOptional, excludeFragments); } } } } for (int i = 0; i < implicit.length; i++) { addBundleAndDependencies( state.getBundle(implicit[i], null), set, includeOptional, excludeFragments); } if (removeSelf) { for (int i = 0; i < selected.length; i++) { if (!(selected[i] instanceof IPluginModelBase)) { continue; } IPluginModelBase model = (IPluginModelBase) selected[i]; set.remove(model.getPluginBase().getId()); } } return set; }
/** * This will check the indirect dependencies of <code>model</code> and install the necessary * workspace plugins if we need to import some of their packages. * * @param model The model of which we wish the dependencies checked. */ private void checkImportPackagesDependencies(IPluginModelBase model) { final BundleDescription desc = model.getBundleDescription(); if (desc == null) { return; } for (ImportPackageSpecification importPackage : desc.getImportPackages()) { for (IPluginModelBase workspaceModel : PluginRegistry.getWorkspaceModels()) { if (workspaceModel != null && workspaceModel.getBundleDescription() != null) { for (ExportPackageDescription export : workspaceModel.getBundleDescription().getExportPackages()) { if (importPackage.isSatisfiedBy(export)) { installBundle(workspaceModel); break; } } } } } }
protected void validatePluginIDRef(Element element, Attr attr) { if (!validatePluginID(element, attr)) { return; } int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNRESOLVED_IMPORTS); if ("true".equals(element.getAttribute("optional")) && severity == CompilerFlags.ERROR) // $NON-NLS-1$ //$NON-NLS-2$ severity = CompilerFlags.WARNING; if (severity != CompilerFlags.IGNORE) { IPluginModelBase model = PluginRegistry.findModel(attr.getValue()); if (model == null || !model.isEnabled()) { report( NLS.bind(PDECoreMessages.Builders_Manifest_dependency, attr.getValue()), getLine(element, attr.getName()), severity, PDEMarkerFactory.CAT_FATAL); } } }
private void handleAddRequiredPlugins() { TableItem[] items = fImportListViewer.getTable().getItems(); if (items.length == 0) return; if (items.length == 1) { IPluginModelBase model = (IPluginModelBase) items[0].getData(); if (model.getPluginBase().getId().equals("org.eclipse.core.boot")) { // $NON-NLS-1$ return; } } ArrayList<IPluginModelBase> result = new ArrayList<>(); for (int i = 0; i < items.length; i++) { addPluginAndDependencies( (IPluginModelBase) items[i].getData(), result, fAddFragmentsButton.getSelection()); } ArrayList<Object> resultObject = new ArrayList<>(result.size()); resultObject.addAll(result); handleSetImportSelection(resultObject); }
/** * If a source annotation is pointing to a host project that is being wove, returns an empty * string so that the source annotation is the root of the project. Otherwise returns the given * library name. * * @param model plug-in we are attaching source for * @param libraryName the standard library name * @return empty string or the standard library name */ public static String getWeavedSourceLibraryName(IPluginModelBase model, String libraryName) { // Note that if the host project has binary-linked libraries, these libraries appear in the // dev.properties file with full path names, // and the library name must be returned as-is. if (fgIsDev && !new File(libraryName).isAbsolute()) { Properties properties = getDevProperties(); String id = null; if (model.getBundleDescription() != null) { id = model.getBundleDescription().getSymbolicName(); } if (id != null) { String property = properties.getProperty(id, null); if (property != null) { return ""; //$NON-NLS-1$ } } } return libraryName; }
private void validatePluginID(Element element, Attr attr, boolean isFragment) { String id = attr.getValue(); if (!validatePluginID(element, attr)) { return; } int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_PLUGINS); if (severity != CompilerFlags.IGNORE) { IPluginModelBase model = PluginRegistry.findModel(id); if (model == null || !model.isEnabled() || (isFragment && !model.isFragmentModel()) || (!isFragment && model.isFragmentModel())) { report( NLS.bind(PDECoreMessages.Builders_Feature_reference, id), getLine(element, attr.getName()), severity, PDEMarkerFactory.CAT_OTHER); } } }
// Copied from PDEClasspathContainer#resolveLibraryInFragments protected static IPluginModelBase resolveLibraryInFragments( IPluginModelBase model, String libraryName) { BundleDescription desc = model.getBundleDescription(); if (desc != null) { BundleDescription[] fragments = desc.getFragments(); for (int i = 0; i < fragments.length; i++) { if (new File(fragments[i].getLocation(), libraryName).exists()) return PluginRegistry.findModel(fragments[i]); } } return null; }
protected void doIncludeVersions(NameVersionDescriptor[] descriptions) throws Exception { String bsn = MULTI_VERSION_LOW_DESCRIPTION.getId(); IPath extras = extractMultiVersionPlugins(); ITargetDefinition target = getNewTarget(); ITargetLocation container = getTargetService().newDirectoryLocation(extras.toOSString()); target.setTargetLocations(new ITargetLocation[] {container}); target.setIncluded(descriptions); try { getTargetService().saveTargetDefinition(target); setTargetPlatform(target); IPluginModelBase[] models = PluginRegistry.getExternalModels(); Set enabled = new HashSet(); for (int i = 0; i < models.length; i++) { IPluginModelBase pm = models[i]; if (pm.getBundleDescription().getSymbolicName().equals(bsn)) { NameVersionDescriptor desc = new NameVersionDescriptor( pm.getPluginBase().getId(), pm.getPluginBase().getVersion()); if (pm.isEnabled()) { enabled.add(desc); } } } if (descriptions == null) { } else { assertEquals("Wrong number of enabled bundles", descriptions.length, enabled.size()); for (int i = 0; i < descriptions.length; i++) { assertTrue("Missing bundle", enabled.contains(descriptions[i])); } } } finally { getTargetService().deleteTarget(target.getHandle()); resetTargetPlatform(); } }
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 findMatches(IPluginExtensionPoint point) { String fullID = point.getFullId(); if (fullID == null) return; IPluginExtension[] extensions = fModel.getPluginBase().getExtensions(); for (int i = 0; i < extensions.length; i++) { if (fullID.equals(extensions[i].getPoint())) { int line = ((ISourceObject) extensions[i]).getStartLine() - 1; if (line >= 0) { fSearchResult.addMatch(new Match(point, Match.UNIT_LINE, line, 1)); break; } } } }
/** * Retrieves the singleton instance of the given service class after refreshing it if needed. * * @param serviceClass The service class we need an instance of. * @return The singleton instance of the given service class if any. */ public synchronized Object getServiceInstance(Class<?> serviceClass) { String qualifiedName = serviceClass.getName(); for (Map.Entry<String, WorkspaceClassInstance> workspaceClass : workspaceLoadedClasses.entrySet()) { if (workspaceClass.getKey().equals(qualifiedName)) { WorkspaceClassInstance workspaceInstance = workspaceClass.getValue(); if (workspaceInstance.isStale()) { for (Map.Entry<IPluginModelBase, Bundle> entry : workspaceInstalledBundles.entrySet()) { final IPluginModelBase model = entry.getKey(); if (workspaceInstance .getBundle() .equals(model.getBundleDescription().getSymbolicName())) { Class<?> clazz = internalLoadClass(entry.getValue(), qualifiedName); workspaceInstance.setStale(false); workspaceInstance.setClass(clazz); break; } } } return workspaceInstance.getInstance(); } } return null; }
/** * This will iterate over the "Export-Package" manifest header of the given bundle and search a * bundle corresponding to the given qualified class name. * * <p>For example, if the qualified name we're given is "org.eclipse.acceleo.sample.Test", we'll * search for a bundle exporting the package "org.eclipse.acceleo.sample". * * @param model The bundle model that is to be checked. * @param qualifiedName Qualified name of the class we search the exported package of. * @return <code>true</code> iff <code>model</code> has an entry for a package corresponding to * <code>qualifiedName</code>. */ private static boolean hasCorrespondingExportPackage( IPluginModelBase model, String qualifiedName) { String packageName = ""; // $NON-NLS-1$ final int end = qualifiedName.lastIndexOf('.'); if (end != -1) { packageName = qualifiedName.substring(0, end); } for (ExportPackageDescription exported : model.getBundleDescription().getExportPackages()) { if (packageName.startsWith(exported.getName())) { return true; } } return false; }