String contributorPluginId = e.getContributor() .getName(); Bundle bundle = Platform.getBundle(contributorPluginId); InputStream input = (InputStream) bundle.getResource( xml).getContent();
private void readStockThemes(Map<String, ColorTheme> themes) { IConfigurationElement[] config = Platform.getExtensionRegistry() .getConfigurationElementsFor( Activator.EXTENSION_POINT_ID_THEME); try { for (IConfigurationElement e : config) { String xml = e.getAttribute("file"); String contributorPluginId = e.getContributor().getName(); Bundle bundle = Platform.getBundle(contributorPluginId); InputStream input = (InputStream) bundle.getResource(xml) .getContent(); ParsedTheme theme = parseTheme(input, false); amendThemeEntries(theme.getTheme().getEntries()); themes.put(theme.getTheme().getName(), theme.getTheme()); } } catch (Exception e) { e.printStackTrace(); } }
/** * Returns whether creating executable extensions is acceptable * at this point in time. In particular, returns <code>false</code> * when the system bundle is shutting down, which only occurs * when the entire framework is exiting. */ private boolean canCreateExtensions() { return Platform.getBundle("org.eclipse.osgi").getState() != Bundle.STOPPING; //$NON-NLS-1$ }
@Override protected Transport getTransportService() throws Exception { try { Bundle bundle = Platform.getBundle(P2_REPOSITORY_BUNDLE); Class<?> clazz = bundle.loadClass(REPOSITORY_TRANSPORT_CLASS); Method method = clazz.getDeclaredMethod(GET_INSTANCE_METHOD); Object transportInstance = method.invoke(null); return (Transport) transportInstance; } catch (Exception e) { return null; } }
public static void log(IStatus status) { final Bundle bundle = Platform.getBundle(ResourcesPlugin.PI_RESOURCES); if (bundle == null) return; Platform.getLog(bundle).log(status); }
/** * Returns the plugin's path. * * @return The plugin's path. */ protected IPath getPluginPath(){ if (pluginPath == null){ Bundle bundle = Platform.getBundle(getPluginID()); pluginPath = new Path(bundle.getLocation()); } return pluginPath; }
private URL getResourceURL(String bundleID, String resourcePath) { try { Bundle bundle = Platform.getBundle(bundleID); if (bundle != null) { URL entry = bundle.getEntry(resourcePath); if (entry != null) return FileLocator.toFileURL(entry); } } catch (IOException e) { } return null; }
/** * Returns the page's image * @return ImageDescriptor of the image or null if creating failed */ public ImageDescriptor getImage() { String imageName= fElement.getAttribute(ICON_ATTRIBUTE); if (imageName == null) return null; Bundle bundle = Platform.getBundle(getPluginId()); return SearchPluginImages.createImageDescriptor(bundle, new Path(imageName), true); }
@Override public void handleException(Throwable exception) { String message= JFaceTextMessages.getString(fMessageKey); IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, message, exception); Platform.getLog(Platform.getBundle(PLUGIN_ID)).log(status); fLastErrorMessage= message; } }
public ImageDescriptor getImageDescriptor(String name) { try { URL url = new URL(Platform.getBundle("org.eclipse.wst.xml.ui").getEntry("/"), name); //$NON-NLS-1$ //$NON-NLS-2$ return ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { return ImageDescriptor.getMissingImageDescriptor(); } } }
@Override public boolean isDeclaringPluginActive() { Bundle fBundle= Platform.getBundle(fConfigElement.getContributor().getName()); return fBundle.getState() == Bundle.ACTIVE; }
public EjbEmitter(IConfigurationElement emitterConfig) throws ClassNotFoundException, InstantiationException, IllegalAccessException, CoreException { this.emitterConfig = emitterConfig; String pluginDescriptor = emitterConfig.getDeclaringExtension().getContributor().getName(); org.osgi.framework.Bundle bundle = Platform.getBundle(pluginDescriptor); Class c = bundle.loadClass(emitterConfig.getAttribute(CLASSPATHPROVIDER)); classpathProvider = (IEmitterClasspathProvider) c.newInstance(); base = bundle.getEntry("/").toString(); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(EJBEMITTERPROJECT); IProgressMonitor monitor = new NullProgressMonitor(); project.delete(true, true, monitor); }
private void processIconAttr() { String iconAttr = mElement.getAttribute(ATTR_ICON); if (iconAttr != null && iconAttr.trim().length() > 0) { URL url = Platform.getBundle( mElement.getContributor().getName()).getEntry( iconAttr); mIcon = ImageDescriptor.createFromURL(url); } else { mIcon = ImageDescriptor.getMissingImageDescriptor(); } }
@Override public void run() throws Exception { String pluginId = fElement.getContributor().getName(); boolean isPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE; if (isPlugInActivated || canActivatePlugIn()) result[0]= (IHyperlinkDetector)fElement.createExecutableExtension(CLASS_ATTRIBUTE); } @Override
public void run() throws Exception { String pluginId = fElement.getContributor().getName(); boolean isPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE; if (isPlugInActivated || canActivatePlugIn()) result[0]= (AbstractHyperlinkDetector)fElement.createExecutableExtension(CLASS_ATTRIBUTE); } /*
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof IBuild) { IBuild build = (IBuild) receiver; if ("hasConsole".equals(property)) { return CoreUtil.propertyEquals(Platform.getBundle("org.eclipse.ui.console") != null, expectedValue); } if ("hasTests".equals(property)) { return CoreUtil.propertyEquals(build.getTestResult() != null, expectedValue); } } return false; }
@Override public void walkTree(IResourceVisitor visitor) throws IOException { if (!exists() || symname == null) { throw new IOException(getURI().toString()); } Bundle bundle = Platform.getBundle(symname); recurse(bundle, getURI().getPath(), visitor, ""); //$NON-NLS-1$ }
private Bundle getBundle() { String namespace= fElement.getDeclaringExtension().getContributor().getName(); Bundle bundle= Platform.getBundle(namespace); return bundle; }
private Bundle getBundle() { String namespace= fElement.getDeclaringExtension().getContributor().getName(); Bundle bundle= Platform.getBundle(namespace); return bundle; } }
protected AbstractCatalogSource computeDiscoverySource(IContributor contributor) { Policy policy = new Policy(true); BundleDiscoverySource bundleDiscoverySource = new BundleDiscoverySource(Platform.getBundle(contributor.getName())); bundleDiscoverySource.setPolicy(policy); return bundleDiscoverySource; }