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); } }
/** * Return a string representation of this object. It should be nicely formated and include the * list of children and ancestor nodes. */ public String toDeepString() { StringBuffer buffer = new StringBuffer(); // write ID writeln(buffer, 0, NLS.bind(Messages.stats_pluginid, descriptor.getSymbolicName())); // write ancestors if (ancestors.size() == 0) { writeln(buffer, 1, Messages.depend_noParentPlugins); } else { writeln(buffer, 1, Messages.depend_requiredBy); for (Iterator i = ancestors.iterator(); i.hasNext(); ) { PluginDependencyGraphNode ancestor = (PluginDependencyGraphNode) i.next(); writeln(buffer, 2, ancestor.getId()); } } // write children if (children.size() == 0) { writeln(buffer, 1, Messages.depend_noChildrenPlugins); } else { writeln(buffer, 1, Messages.depend_requires); for (Iterator i = children.iterator(); i.hasNext(); ) { PluginDependencyGraphNode child = (PluginDependencyGraphNode) i.next(); writeln(buffer, 2, child.getId()); } } return buffer.toString(); }
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); } }
public static boolean matchesCurrentEnvironment(IMonitorModelBase model) { BundleContext context = MDECore.getDefault().getBundleContext(); Dictionary environment = getTargetEnvironment(); BundleDescription bundle = model.getBundleDescription(); String filterSpec = bundle != null ? bundle.getPlatformFilter() : null; try { return filterSpec == null || context.createFilter(filterSpec).match(environment); } catch (InvalidSyntaxException e) { return false; } }
private static BundleDescription getDisabledBundleDescription(SpecifiedVersion version) { BundleDescription[] bundles = Platform.getPlatformAdmin().getState(false).getDisabledBundles(); for (BundleDescription bundle : bundles) { if (bundle.getSymbolicName().equals("org.codehaus.groovy") && bundle.getVersion().getMajor() == version.majorVersion && bundle.getVersion().getMinor() == version.minorVersion) { return bundle; } } return null; }
public static void closeBundleLoader(BundleLoaderProxy proxy) { if (proxy == null) return; // First close the BundleLoader BundleLoader loader = proxy.getBasicBundleLoader(); if (loader != null) loader.close(); proxy.setStale(); // if proxy is not null then make sure to unset user object // associated with the proxy in the state BundleDescription description = proxy.getBundleDescription(); description.setUserObject(null); }
/* * get the loader proxy for a bundle description */ public final BundleLoaderProxy getLoaderProxy(BundleDescription source) { BundleLoaderProxy sourceProxy = (BundleLoaderProxy) source.getUserObject(); if (sourceProxy == null) { // may need to force the proxy to be created long exportingID = source.getBundleId(); BundleHost exportingBundle = (BundleHost) bundle.getFramework().getBundle(exportingID); if (exportingBundle == null) return null; sourceProxy = exportingBundle.getLoaderProxy(); } return sourceProxy; }
// 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; }
public static Bundle getActiveGroovyBundle() { BundleDescription bundleDesc = getActiveGroovyBundleDescription(); if (bundleDesc == null) { return null; } Bundle[] allBundles = Platform.getBundles("org.codehaus.groovy", bundleDesc.getVersion().toString()); if (allBundles == null || allBundles.length == 0) { return null; } return allBundles[0]; }
public static BundleDescription getBundleDescription(SpecifiedVersion version) { BundleDescription[] active = getAllGroovyBundleDescriptions(); // return highest bundle version that matches the major.minor specified // version for (BundleDescription bundle : active) { if (bundle.getVersion().getMajor() == version.majorVersion && bundle.getVersion().getMinor() == version.minorVersion) { return bundle; } } return null; }
private void addSWTJars(List rtes) { if (fgSWTEntries == null) { fgSWTEntries = new ArrayList(); Bundle bundle = Platform.getBundle("org.eclipse.swt"); // $NON-NLS-1$ BundleDescription description = Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()); BundleDescription[] fragments = description.getFragments(); for (int i = 0; i < fragments.length; i++) { Bundle fragmentBundle = Platform.getBundle(fragments[i].getName()); URL bundleURL; try { bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); // $NON-NLS-1$ } catch (IOException e) { AntLaunching.log(e); continue; } String urlFileName = bundleURL.getFile(); if (urlFileName.startsWith("file:")) { // $NON-NLS-1$ try { urlFileName = new URL(urlFileName).getFile(); if (urlFileName.endsWith("!/")) { // $NON-NLS-1$ urlFileName = urlFileName.substring(0, urlFileName.length() - 2); } } catch (MalformedURLException e) { AntLaunching.log(e); continue; } } IPath fragmentPath = new Path(urlFileName); if (fragmentPath.getFileExtension() != null) { // JAR file fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath)); } else { // folder File bundleFolder = fragmentPath.toFile(); if (!bundleFolder.isDirectory()) { continue; } String[] names = bundleFolder.list( new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); // $NON-NLS-1$ } }); for (int j = 0; j < names.length; j++) { String jarName = names[j]; fgSWTEntries.add( JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName))); } } } } rtes.addAll(fgSWTEntries); }
/* * (non-Javadoc) * @see * org.eclipse.pde.api.tools.internal.search.AbstractProblemDetector#isProblem * (org.eclipse.pde.api.tools.internal.provisional.model.IReference) */ @Override protected boolean isProblem(IReference reference) { // the reference must be in the system library try { IApiMember member = reference.getMember(); IApiComponent apiComponent = member.getApiComponent(); String[] lowestEEs = apiComponent.getLowestEEs(); if (lowestEEs == null) { // this should not be true for Eclipse bundle as they should // always have a EE set return false; } loop: for (int i = 0, max = lowestEEs.length; i < max; i++) { String lowestEE = lowestEEs[i]; int eeValue = ProfileModifiers.getValue(lowestEE); if (eeValue == ProfileModifiers.NO_PROFILE_VALUE) { return false; } if (!((Reference) reference).resolve(eeValue)) { /* * Make sure that the resolved reference doesn't below to * one of the imported package of the current component */ if (apiComponent instanceof BundleComponent) { BundleDescription bundle = ((BundleComponent) apiComponent).getBundleDescription(); ImportPackageSpecification[] importPackages = bundle.getImportPackages(); String referencedTypeName = reference.getReferencedTypeName(); int index = referencedTypeName.lastIndexOf('.'); String packageName = referencedTypeName.substring(0, index); for (int j = 0, max2 = importPackages.length; j < max2; j++) { ImportPackageSpecification importPackageSpecification = importPackages[j]; // get the IPackageDescriptor for the element // descriptor String importPackageName = importPackageSpecification.getName(); if (importPackageName.equals(packageName)) { continue loop; } } } if (this.referenceEEs == null) { this.referenceEEs = new HashMap<IReference, Integer>(3); } this.referenceEEs.put(reference, new Integer(eeValue)); return true; } } } catch (CoreException e) { ApiPlugin.log(e); } return false; }
// Once we have resolved bundles, we need to make sure that exports // from these are ahead of those from unresolved bundles void reorder() { Iterator it = internal.values().iterator(); while (it.hasNext()) { ArrayList toBeReordered = new ArrayList(); VersionSupplier[] existing = (VersionSupplier[]) it.next(); if (existing == null || existing.length <= 1) continue; // Find any VersionSuppliers that need to be reordered VersionSupplier vs1 = (VersionSupplier) existing[0]; for (int i = 1; i < existing.length; i++) { VersionSupplier vs2 = (VersionSupplier) existing[i]; BundleDescription b1 = vs1.getBundle(); BundleDescription b2 = vs2.getBundle(); if (b2.isResolved() && !b1.isResolved()) { toBeReordered.add(vs2); } else if (b2.isResolved() == b1.isResolved()) { int versionDiff = vs2.getVersion().compareTo(vs1.getVersion()); if (versionDiff > 0 || (b2.getBundleId() < b1.getBundleId() && versionDiff == 0)) { toBeReordered.add(vs2); } } vs1 = vs2; } // Reorder them for (int i = 0; i < toBeReordered.size(); i++) { VersionSupplier vs = (VersionSupplier) toBeReordered.get(i); remove(vs); put(vs); } } }
/** * 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; } } } }
public void testExecuteUndo() throws Exception { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); IProfile profile = createProfile("test", profileProperties); IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData( "1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.source_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); File osgiTarget = new File(targetPlugins, "org.eclipse.osgi.source_3.4.2.R34x_v20080826-1230.jar"); copy("2.0", osgiSource, osgiTarget); BundleDescription bundleDescription = BundlesAction.createBundleDescription(osgiTarget); IArtifactKey key = BundlesAction.createBundleArtifactKey( bundleDescription.getSymbolicName(), bundleDescription.getVersion().toString()); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, osgiTarget); IInstallableUnit iu = createBundleIU(bundleDescription, osgiTarget.isDirectory(), key); bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); InstallableUnitOperand operand = new InstallableUnitOperand(null, iu); parameters.put("iu", operand.second()); touchpoint.initializeOperand(profile, parameters); parameters.put(ActionConstants.PARM_BUNDLE, key.toString()); parameters = Collections.unmodifiableMap(parameters); SourceManipulator manipulator = (SourceManipulator) parameters.get(EclipseTouchpoint.PARM_SOURCE_BUNDLES); assertNotNull(manipulator); assertFalse(inBundles(manipulator, osgiTarget)); AddSourceBundleAction action = new AddSourceBundleAction(); action.execute(parameters); assertTrue(inBundles(manipulator, osgiTarget)); action.undo(parameters); assertFalse(inBundles(manipulator, osgiTarget)); }
public static Map getPatchMap(MDEState state) { HashMap properties = new HashMap(); IMonitorModelBase[] models = MonitorRegistry.getActiveModels(); for (int i = 0; i < models.length; i++) { BundleDescription desc = models[i].getBundleDescription(); if (desc == null) continue; Long id = new Long(desc.getBundleId()); if (ClasspathUtilCore.hasExtensibleAPI(models[i])) { properties.put(id, ICoreConstants.EXTENSIBLE_API + ": true"); // $NON-NLS-1$ } else if (ClasspathUtilCore.isPatchFragment(models[i])) { properties.put(id, ICoreConstants.PATCH_FRAGMENT + ": true"); // $NON-NLS-1$ } } return properties; }
/** * Returns an IU corresponding to the given artifact key and bundle, or <code>null</code> if an IU * could not be created. */ public static IInstallableUnit createBundleIU(IArtifactKey artifactKey, File bundleFile) { BundleDescription bundleDescription = BundlesAction.createBundleDescription(bundleFile); if (bundleDescription == null) return null; PublisherInfo info = new PublisherInfo(); Version version = Version.create(bundleDescription.getVersion().toString()); AdviceFileAdvice advice = new AdviceFileAdvice( bundleDescription.getSymbolicName(), version, new Path(bundleFile.getAbsolutePath()), AdviceFileAdvice.BUNDLE_ADVICE_FILE); if (advice.containsAdvice()) info.addAdvice(advice); String shape = bundleFile.isDirectory() ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR; info.addAdvice(new BundleShapeAdvice(bundleDescription.getSymbolicName(), version, shape)); return BundlesAction.createBundleIU(bundleDescription, artifactKey, info); }
private boolean isAffected(BundleDescription desc, BundleDescription dependent) { ImportPackageSpecification[] imports = dependent.getImportPackages(); Iterator iter = fElements.keySet().iterator(); while (iter.hasNext()) { String name = ((IJavaElement) iter.next()).getElementName(); for (int i = 0; i < imports.length; i++) { if (name.equals(imports[i].getName())) { BaseDescription supplier = imports[i].getSupplier(); if (supplier instanceof ExportPackageDescription) { if (desc.equals(((ExportPackageDescription) supplier).getExporter())) return true; } } } } return false; }
public synchronized KeyedHashSet getImportedSources(KeyedHashSet visited) { if ((loaderFlags & FLAG_IMPORTSINIT) != 0) return importedSources; BundleDescription bundleDesc = proxy.getBundleDescription(); ExportPackageDescription[] packages = bundleDesc.getResolvedImports(); if (packages != null && packages.length > 0) { if (importedSources == null) importedSources = new KeyedHashSet(packages.length, false); for (int i = 0; i < packages.length; i++) { if (packages[i].getExporter() == bundleDesc) continue; // ignore imports resolved to this bundle PackageSource source = createExportPackageSource(packages[i], visited); if (source != null) importedSources.add(source); } } loaderFlags |= FLAG_IMPORTSINIT; return importedSources; }
/** * Recursively adds the given {@link BundleDescription} and its dependents to the given {@link * Set} * * @param desc the {@link BundleDescription} to compute dependencies for * @param set the {@link Set} to collect results in * @param includeOptional if optional dependencies should be included * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from * the dependency resolution */ private static void addBundleAndDependencies( BundleDescription desc, Set<String> set, boolean includeOptional, Set<String> excludeFragments) { if (desc != null && set.add(desc.getSymbolicName())) { BundleSpecification[] required = desc.getRequiredBundles(); for (int i = 0; i < required.length; i++) { if (includeOptional || !required[i].isOptional()) { addBundleAndDependencies( (BundleDescription) required[i].getSupplier(), set, includeOptional, excludeFragments); } } ImportPackageSpecification[] importedPkgs = desc.getImportPackages(); for (int i = 0; i < importedPkgs.length; i++) { ExportPackageDescription exporter = (ExportPackageDescription) importedPkgs[i].getSupplier(); // Continue if the Imported Package is unresolved of the package is optional and don't want // optional packages if (exporter == null || (!includeOptional && Constants.RESOLUTION_OPTIONAL.equals( importedPkgs[i].getDirective(Constants.RESOLUTION_DIRECTIVE)))) { continue; } addBundleAndDependencies(exporter.getExporter(), set, includeOptional, excludeFragments); } BundleDescription[] fragments = desc.getFragments(); for (int i = 0; i < fragments.length; i++) { if (!fragments[i].isResolved()) { continue; } String id = fragments[i].getSymbolicName(); if (!excludeFragments.contains(id)) { addBundleAndDependencies(fragments[i], set, includeOptional, excludeFragments); } } HostSpecification host = desc.getHost(); if (host != null) { addBundleAndDependencies( (BundleDescription) host.getSupplier(), set, includeOptional, excludeFragments); } } }
private Object[] getDependencies(BundleDescription desc) { // use map to store dependencies so if Import-Package is supplied by same BundleDescription as // supplier of Require-Bundle, it only shows up once // Also, have to use BundleSpecficiation instead of BundleDescroption to show re-exported icon // on re-exported Required-Bundles // Have to use ImportPackageSpecification to determine if an import is optional and should be // filtered. HashMap<Object, Object> dependencies = new HashMap<Object, Object>(); BundleSpecification[] requiredBundles = desc.getRequiredBundles(); for (int i = 0; i < requiredBundles.length; i++) { BaseDescription bd = requiredBundles[i].getSupplier(); if (bd != null) dependencies.put(bd, requiredBundles[i]); else dependencies.put(requiredBundles[i], requiredBundles[i]); } ImportPackageSpecification[] importedPkgs = desc.getImportPackages(); for (int i = 0; i < importedPkgs.length; i++) { BaseDescription bd = importedPkgs[i].getSupplier(); if (bd != null && bd instanceof ExportPackageDescription) { BundleDescription exporter = ((ExportPackageDescription) bd).getExporter(); if (exporter != null) { Object obj = dependencies.get(exporter); if (obj == null) { dependencies.put(exporter, importedPkgs[i]); } else if (!Constants.RESOLUTION_OPTIONAL.equals( importedPkgs[i].getDirective(Constants.RESOLUTION_DIRECTIVE)) && obj instanceof ImportPackageSpecification && Constants.RESOLUTION_OPTIONAL.equals( ((ImportPackageSpecification) obj) .getDirective(Constants.RESOLUTION_DIRECTIVE))) { // if we have a non-optional Import-Package dependency on a bundle which we already // depend on, check to make sure our // current dependency is not optional. If it is, replace the optional dependency with // the non-optional one dependencies.put(exporter, importedPkgs[i]); } } } // ignore unresolved packages } // include fragments which are "linked" to this bundle BundleDescription frags[] = desc.getFragments(); for (int i = 0; i < frags.length; i++) { if (!frags[i].equals(fFragmentDescription)) dependencies.put(frags[i], frags[i]); } return dependencies.values().toArray(); }
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()); } } }
/** @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("PluginDependencyGraphNode("); // $NON-NLS-1$ buffer.append(descriptor.getSymbolicName()); buffer.append(')'); return buffer.toString(); }
/** * Swtiches to or from groovy version 1.6.x depending on the boolean passed in A restart is * required immediately after or else many exceptions will be thrown. * * @param toVersion16 * @return {@link Status.OK_STATUS} if successful or error status that contains the exception * thrown otherwise */ public static IStatus switchVersions(SpecifiedVersion fromVersion, SpecifiedVersion toVersion) { try { State state = ((StateManager) Platform.getPlatformAdmin()).getSystemState(); BundleDescription toBundle = getBundleDescription(toVersion); BundleDescription[] allBundles = getAllGroovyBundleDescriptions(); if (toBundle == null) { throw new Exception("Could not find any " + toVersion + " groovy version to enable"); } // go through all bundles and ensure disabled for (BundleDescription bundle : allBundles) { DisabledInfo info = createDisabledInfo(state, bundle.getBundleId()); if (bundle.equals(toBundle)) { // ensure enabled Platform.getPlatformAdmin().removeDisabledInfo(info); } else { // don't actually stop // switch (bundle.getState()) { // case Bundle.ACTIVE: // case Bundle.INSTALLED: // case Bundle.STARTING: // case Bundle.RESOLVED: // bundle.stop(); // } // ensure disabled Platform.getPlatformAdmin().addDisabledInfo(info); } } CompilerLevelUtils.writeConfigurationVersion( toVersion, // need to get the system bundle GroovyCoreActivator.getDefault() .getBundle() .getBundleContext() .getBundle(0) .getBundleContext()); return Status.OK_STATUS; } catch (Exception e) { GroovyCore.logException(e.getMessage(), e); return new Status( IStatus.ERROR, GroovyCoreActivator.PLUGIN_ID, e.getMessage() + "\n\nSee the error log for more information.", e); } }
/** * Provides UI for switching compiler between versions * * @param toVersion */ private static void switchVersion( final SpecifiedVersion toVersion, final Composite compilerPage) { final BundleDescription toBundle = CompilerUtils.getBundleDescription(toVersion); if (toBundle == null) { // this version is not installed return; } Button switchTo = new Button(compilerPage, SWT.PUSH); switchTo.setText("Switch to " + toBundle.getVersion()); switchTo.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { Shell shell = compilerPage.getShell(); boolean result = MessageDialog.openQuestion( shell, "Change compiler and restart?", "Do you want to change the compiler?\n\nIf you select \"Yes\"," + " the compiler will be changed and Eclipse will be restarted.\n\n" + "Make sure all your work is saved before clicking \"Yes\"."); if (result) { // change compiler SpecifiedVersion activeGroovyVersion = CompilerUtils.getActiveGroovyVersion(); IStatus status = CompilerUtils.switchVersions(activeGroovyVersion, toVersion); if (status == Status.OK_STATUS) { restart(shell); } else { ErrorDialog error = new ErrorDialog( shell, "Error occurred", "Error occurred when trying to enable Groovy " + toBundle.getVersion(), status, IStatus.ERROR); error.open(); } } } public void widgetDefaultSelected(SelectionEvent e) {} }); }
private void fillWithDependent(LinkedList<BundleDescription> bundleDescriptions) { HashSet<String> added = new HashSet<String>(); for (BundleDescription bundleDescription : new LinkedList<BundleDescription>(bundleDescriptions)) { // BundleSpecification[] deps = bundleDescription.getRequiredBundles(); // for (BundleSpecification depSpec : deps) { // if ( depDescription.getSymbolicName().contains("commons.logging") ) // break; // BundleDescription depDescription = depSpec.getBundle(); BundleDescription deps[] = bundleDescription.getResolvedRequires(); for (BundleDescription depDescription : deps) { if (!added.contains(depDescription.getSymbolicName())) { bundleDescriptions.add(depDescription); added.add(depDescription.getSymbolicName()); } } } }
/** * 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 addBundleManifestChange(CompositeChange result, IProgressMonitor pm) throws CoreException { super.addBundleManifestChange(result, pm); IMonitorModelBase model = MonitorRegistry.findModel(fProject); if (model != null) { BundleDescription desc = model.getBundleDescription(); if (desc != null) { BundleDescription[] dependents = desc.getDependents(); for (int i = 0; i < dependents.length; i++) { if (isAffected(desc, dependents[i])) { IMonitorModelBase candidate = MonitorRegistry.findModel(dependents[i]); if (candidate instanceof IBundlePluginModelBase) { IFile file = (IFile) candidate.getUnderlyingResource(); addBundleManifestChange(file, result, pm); } } } } } }
public String deriveGroupId(@NotNull BundleDescription bundle) { final String symbolicName = bundle.getSymbolicName(); String groupId = applyGroupIdMapping(symbolicName); if (groupId == null) { groupId = deriveGroupId(symbolicName); } if (groupIdPrefix != null) { groupId = groupIdPrefix + groupId; } return groupId; }
public void checkBundlesResolved_a() { assertTrue("unexpected bundle resolution state", bundle_1.isResolved()); assertTrue("unexpected bundle resolution state", !bundle_2.isResolved()); assertTrue("unexpected bundle resolution state", bundle_3.isResolved()); assertTrue("unexpected bundle resolution state", bundle_4.isResolved()); assertTrue("unexpected bundle resolution state", bundle_5.isResolved()); assertTrue("unexpected bundle resolution state", bundle_6.isResolved()); } // end method