/** * 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(); }
/** * 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); }
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); } }
/** @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(); }
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()); } } } }
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 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; }
private static BundleDescription getActiveGroovyBundleDescription() { BundleDescription[] active = getAllGroovyBundleDescriptions(); if (active == null || active.length == 0) { return null; } // go through each bundle in versioned order and see if it is disabled // The highest bundle that is not disabled is the active bundle BundleDescription[] disabled = Platform.getPlatformAdmin().getState(false).getDisabledBundles(); for (BundleDescription bundle : active) { boolean isAvailable = true; for (BundleDescription d : disabled) { if (d.getVersion().equals(bundle.getVersion()) && d.getSymbolicName().equals(bundle.getSymbolicName())) { isAvailable = false; break; } } if (isAvailable) { return bundle; } } return null; }
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)); }
/** * 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 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()); } } }
/** * Return the identifier for this node. It is the unique plug-in identifier for this object's * plug-in descriptor. * * @return the plug-in id */ public String getId() { return descriptor.getSymbolicName(); }
public String deriveArtifactId(@NotNull BundleDescription bundle) { return deriveArtifactId(bundle.getSymbolicName()); }