/** * Returns the dev.properties as a property store. * * @return properties */ protected static Properties getDevProperties() { if (fgIsDev) { if (fgDevProperties == null) { fgDevProperties = new Properties(); if (fgDevPropertiesURL != null) { try { URL url = new URL(fgDevPropertiesURL); String path = url.getFile(); if (path != null && path.length() > 0) { File file = new File(path); if (file.exists()) { BufferedInputStream stream = null; try { stream = new BufferedInputStream(new FileInputStream(file)); fgDevProperties.load(stream); } catch (FileNotFoundException e) { PDECore.log(e); } catch (IOException e) { PDECore.log(e); } finally { if (stream != null) stream.close(); } } } } catch (MalformedURLException e) { PDECore.log(e); } catch (IOException e) { PDECore.log(e); } } } return fgDevProperties; } return null; }
public void dispose() { super.dispose(); FeatureModelManager mng = PDECore.getDefault().getFeatureModelManager(); mng.removeFeatureModelListener(this); fModel.removeModelChangedListener(this); if (fSiteLabelProvider != null) fSiteLabelProvider.dispose(); }
/** * Tests reading a 3.0.2 install with a mix of classic and OSGi plug-ins. * * @throws Exception */ public void testClassicPlugins() throws Exception { // extract the 3.0.2 skeleton IPath location = extractClassicPlugins(); // the new way ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); definition.setTargetLocations(new ITargetLocation[] {container}); Set urls = getAllBundleURLs(definition); assertTrue("Must be bundles", urls.size() > 0); Preferences store = PDECore.getDefault().getPluginPreferences(); boolean restore = store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION); try { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, false); // the old way URL[] pluginPaths = PluginPathFinder.getPluginPaths(location.toOSString()); for (int i = 0; i < pluginPaths.length; i++) { URL url = pluginPaths[i]; if (!urls.contains(url)) { System.err.println(url.toString()); } } assertEquals("Wrong number of bundles", pluginPaths.length, urls.size()); } finally { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, restore); } }
/** * Finds a feature with the same id and version as a site feature. If feature is not found, but * feature with a M.m.s.qualifier exists it will be returned. * * @param siteFeature * @return IFeature or null */ public static IFeature findFeature(ISiteFeature siteFeature) { IFeatureModel model = PDECore.getDefault() .getFeatureModelManager() .findFeatureModelRelaxed(siteFeature.getId(), siteFeature.getVersion()); if (model != null) return model.getFeature(); return null; }
/** * Computes the set of implicit dependencies from the {@link PDEPreferencesManager} * * @return a set if bundle ids */ private static String[] getImplicitDependencies() { try { ITargetPlatformService service = (ITargetPlatformService) PDECore.getDefault().acquireService(ITargetPlatformService.class.getName()); if (service != null) { NameVersionDescriptor[] implicit = service.getWorkspaceTargetDefinition().getImplicitDependencies(); if (implicit != null) { String[] result = new String[implicit.length]; for (int i = 0; i < implicit.length; i++) { result[i] = implicit[i].getId(); } return result; } } } catch (CoreException e) { PDECore.log(e); } return new String[0]; }
private void validateFeatureID(Element element, Attr attr) { int severity = CompilerFlags.getFlag(fProject, CompilerFlags.F_UNRESOLVED_FEATURES); if (severity != CompilerFlags.IGNORE) { IFeatureModel[] models = PDECore.getDefault().getFeatureModelManager().findFeatureModels(attr.getValue()); if (models.length == 0) { report( NLS.bind(PDECoreMessages.Builders_Feature_freference, attr.getValue()), getLine(element, attr.getName()), severity, PDEMarkerFactory.CAT_OTHER); } } }
/** * Tests that a bundle directory container is equivalent to scanning locations when it uses a * variable to specify its location. * * @throws Exception */ public void testVariableDirectoryBundleContainer() throws Exception { // the new way ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService().newDirectoryLocation("${eclipse_home}/plugins"); definition.setTargetLocations(new ITargetLocation[] {container}); Set urls = getAllBundleURLs(definition); Preferences store = PDECore.getDefault().getPluginPreferences(); boolean restore = store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION); try { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, false); // the old way URL[] pluginPaths = PluginPathFinder.getPluginPaths(TargetPlatform.getDefaultLocation()); assertEquals("Should have same number of bundles", pluginPaths.length, urls.size()); for (int i = 0; i < pluginPaths.length; i++) { URL url = pluginPaths[i]; assertTrue("Missing plug-in " + url.toString(), urls.contains(url)); } } finally { store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, restore); } }
public void initialize() { refresh(); FeatureModelManager mng = PDECore.getDefault().getFeatureModelManager(); mng.addFeatureModelListener(this); }