本文整理了Java中org.eclipse.core.runtime.Platform.getBundle()
方法的一些代码示例,展示了Platform.getBundle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Platform.getBundle()
方法的具体详情如下:
包路径:org.eclipse.core.runtime.Platform
类名称:Platform
方法名:getBundle
[英]Returns the resolved bundle with the specified symbolic name that has the highest version. If no resolved bundles are installed that have the specified symbolic name then null is returned.
Clients are also able to acquire the PackageAdmin service and query it for the bundle with the specified symbolic name. Clients can ask the service for all bundles with that particular name and then determine the one with the highest version. Note that clients may want to filter the results based on the state of the bundles.
[中]返回具有最高版本的指定符号名的已解析捆绑包。如果未安装具有指定符号名的已解析捆绑包,则返回null。
客户端还可以获取PackageAdmin服务,并使用指定的符号名查询包。客户可以要求服务提供具有该特定名称的所有捆绑包,然后确定具有最高版本的捆绑包。请注意,客户机可能希望根据捆绑包的状态筛选结果。
代码示例来源:origin: eclipse-color-theme/eclipse-color-theme
String contributorPluginId = e.getContributor()
.getName();
Bundle bundle = Platform.getBundle(contributorPluginId);
InputStream input = (InputStream) bundle.getResource(
xml).getContent();
代码示例来源:origin: eclipse-color-theme/eclipse-color-theme
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();
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.resources
/**
* 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$
}
代码示例来源:origin: org.eclipse.epp.mpc/core
@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;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.core.resources
public static void log(IStatus status) {
final Bundle bundle = Platform.getBundle(ResourcesPlugin.PI_RESOURCES);
if (bundle == null)
return;
Platform.getLog(bundle).log(status);
}
代码示例来源:origin: org.eclipse/org.eclipse.jst.jsf.core
/**
* 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;
}
代码示例来源:origin: org.eclipse/org.eclipse.pde.core
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;
}
代码示例来源:origin: org.eclipse/org.eclipse.search
/**
* 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);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
@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;
}
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xml.ui
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();
}
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.expressions
@Override
public boolean isDeclaringPluginActive() {
Bundle fBundle= Platform.getBundle(fConfigElement.getContributor().getName());
return fBundle.getState() == Bundle.ACTIVE;
}
代码示例来源:origin: org.eclipse/org.eclipse.jst.j2ee.ejb.annotations.emitter
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);
}
代码示例来源:origin: org.eclipse/org.eclipse.datatools.connectivity.ui
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();
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor
@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
代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor
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);
}
/*
代码示例来源:origin: org.eclipse.mylyn.builds/ui
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;
}
代码示例来源:origin: com.ibm.jaggr/jaggr-service
@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$
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private Bundle getBundle() {
String namespace= fElement.getDeclaringExtension().getContributor().getName();
Bundle bundle= Platform.getBundle(namespace);
return bundle;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor
private Bundle getBundle() {
String namespace= fElement.getDeclaringExtension().getContributor().getName();
Bundle bundle= Platform.getBundle(namespace);
return bundle;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.p2.discovery.compatibility
protected AbstractCatalogSource computeDiscoverySource(IContributor contributor) {
Policy policy = new Policy(true);
BundleDiscoverySource bundleDiscoverySource = new BundleDiscoverySource(Platform.getBundle(contributor.getName()));
bundleDiscoverySource.setPolicy(policy);
return bundleDiscoverySource;
}
内容来源于网络,如有侵权,请联系作者删除!