本文整理汇总了Java中org.eclipse.core.runtime.Platform.getBundle方法的典型用法代码示例。如果您正苦于以下问题:Java Platform.getBundle方法的具体用法?Java Platform.getBundle怎么用?Java Platform.getBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.Platform
的用法示例。
在下文中一共展示了Platform.getBundle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIcon
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
protected Image getIcon(String fullPath) throws IOException {
if (fullPath==null) return defaultIcon;
if ("".equals(fullPath)) return defaultIcon;
try {
if (iconMap.containsKey(fullPath)) return iconMap.get(fullPath);
final String[] sa = fullPath.split("/");
final Bundle bundle = Platform.getBundle(sa[0]);
if (bundle==null) return defaultIcon;
if (bundle!=null) {
Image image = new Image(null, bundle.getResource(sa[1]+"/"+sa[2]).openStream());
iconMap.put(fullPath, image);
}
return iconMap.get(fullPath);
} catch (Exception ne) {
logger.debug("Cannot get icon for "+fullPath, ne);
return defaultIcon;
}
}
示例2: createIcons
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private void createIcons() {
icons = new HashMap<String, Image>(7);
final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.generator");
for (IConfigurationElement e : eles) {
final String identity = e.getAttribute("id");
final String icon = e.getAttribute("icon");
if (icon !=null) {
final String cont = e.getContributor().getName();
final Bundle bundle= Platform.getBundle(cont);
final URL entry = bundle.getEntry(icon);
final ImageDescriptor des = ImageDescriptor.createFromURL(entry);
icons.put(identity, des.createImage());
}
}
}
示例3: createImageDescriptor
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
public static ImageDescriptor createImageDescriptor(String path, String pluginId) {
if (path == null) {
/* fall back if path null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
if (pluginId == null) {
/* fall back if pluginId null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
Bundle bundle = Platform.getBundle(pluginId);
if (bundle == null) {
/*
* fall back if bundle not available, so avoid NPE in eclipse
* framework
*/
return ImageDescriptor.getMissingImageDescriptor();
}
URL url = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);
return imageDesc;
}
示例4: getEventValue
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
public String getEventValue() {
Bundle bundle = Platform.getBundle(PLUGIN_ID.THIS);
if (bundle == null) {
return NOT_INSTALLED;
}
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(PLUGIN_ID.THIS);
boolean showOnStartup = prefs.getBoolean(SHOW_BOX_ON_STARTUP, true);
if (showOnStartup) {
return TRUE;
}
return FALSE;
}
示例5: installBundle
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
* Installs the specified jar bundle and adds the Bundle instance to the local bundle vector {@link #getBundleVector()}.
* @param bundleJarFile the bundle jar file
*/
public void installBundle(File bundleJarFile) {
// --- Check the symbolic bundle name of the jar to load ----
String sbn = this.getBundleBuilder().getBundleJarsSymbolicBundleNames().get(bundleJarFile);
if (sbn!=null && sbn.isEmpty()==false) {
if (Platform.getBundle(sbn)!=null) {
System.out.println("[" + this.getClass().getSimpleName() + "] Bundle '" + sbn + "' is already installed, skip installation of jar file!");
return;
}
}
// --- INstall the local bundle -----------------------------
this.installBundle("reference:file:" + bundleJarFile.getAbsolutePath());
}
示例6: getVersion
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
* Loads the version information to this instance.
*/
public Version getVersion() {
if (version==null) {
Bundle bundle = Platform.getBundle(this.plugInID);
version = bundle.getVersion();
}
return version;
}
示例7: findBundle
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
* Return a bundle containing 'aspectClassName'.
*
* Return null if not found.
*/
private Bundle findBundle(final IExecutionContext executionContext, String aspectClassName) {
// Look using JavaWorkspaceScope as this is safer and will look in
// dependencies
IType mainIType = getITypeMainByWorkspaceScope(aspectClassName);
Bundle bundle = null;
String bundleName = null;
if (mainIType != null) {
IPackageFragmentRoot packageFragmentRoot = (IPackageFragmentRoot) mainIType.getPackageFragment()
.getParent();
bundleName = packageFragmentRoot.getPath().removeLastSegments(1).lastSegment().toString();
if (bundleName != null) {
// We try to look into an already loaded bundle
bundle = Platform.getBundle(bundleName);
}
} else {
// the main isn't visible directly from the workspace, try another
// method
bundle = _executionContext.getMelangeBundle();
}
return bundle;
}
示例8: launch
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private void launch(IResource file, int line, IType type, String agentArgs, IMethod mainMethod)
throws CoreException {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType confType = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
ILaunchConfigurationWorkingCopy wc = confType.newInstance(null, file.getName() + " (PandionJ)");
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, file.getProject().getName());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, false);
// if(breakPoint != null)
// breakPoint.delete();
// if(line != -1)
// breakPoint = JDIDebugModel.createLineBreakpoint(file, firstType.getFullyQualifiedName(), line, -1, -1, 0, true, null);
try {
Bundle bundle = Platform.getBundle(LaunchCommand.class.getPackage().getName());
URL find = FileLocator.find(bundle, new Path("lib/agent.jar"), null);
URL resolve = FileLocator.resolve(find);
if(!mainMethod.exists()) {
String path = resolve.getPath();
if(Platform.getOS().compareTo(Platform.OS_WIN32) == 0)
path = path.substring(1);
String args = "-javaagent:\"" + path + "=" + agentArgs + "\" -Djava.awt.headless=true";
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args);
}
} catch (IOException e1) {
e1.printStackTrace();
}
ILaunchConfiguration config = wc.doSave();
Activator.launch(config);
}
示例9: getImage
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
* Get image contained in the 'images' folder of the plugin
*/
static Image getImage(String name) {
Bundle bundle = Platform.getBundle(PandionJConstants.PLUGIN_ID);
URL imagePath = FileLocator.find(bundle, new Path(PandionJConstants.IMAGE_FOLDER + "/" + name), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(imagePath);
return imageDesc.createImage();
}
示例10: fillContextMenu
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
@Override
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
ActionContributionItem pasteContribution = getPasteContribution(menu.getItems());
menu.remove(pasteContribution);
IAction pasteAction = new Action(PASTE_ACTION_TEXT) {
@Override
public void run() {
IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
.getService(IHandlerService.class);
try {
JobCopyParticipant.setCopiedFileList(new ArrayList<>());
handlerService.executeCommand(PASTE_COMMAND_ID, null);
} catch (Exception exception) {
logger.warn("Error while pasting job files :: {}",exception.getMessage());
}
}
};
pasteAction.setAccelerator(SWT.MOD1 | 'v');
Bundle bundle = Platform.getBundle(MENU_PLUGIN_NAME);
URL imagePath = BundleUtility.find(bundle,ImagePathConstant.PASTE_IMAGE_PATH.getValue());
ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(imagePath);
pasteAction.setImageDescriptor(imageDescriptor);
menu.insertAfter(COPY_ACTION_ID, pasteAction);
}
示例11: getApplicationBundle
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
* Returns the bundle that launched the application that this class runs in.
*
* @return the defining bundle
*/
private Bundle getApplicationBundle() {
IProduct product = Platform.getProduct();
if (product != null) {
return product.getDefiningBundle();
} else {
return Platform.getBundle(ECLIPSE_RUNTIME_BULDEID);
}
}
示例12: getBundleLocation
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
* @param bundleName
* @return file this can return null if bundle is not found
* @throws IOException
*/
public static File getBundleLocation(final String bundleName) throws IOException {
final Bundle bundle = Platform.getBundle(bundleName);
if (bundle == null) {
return null;
}
return FileLocator.getBundleFile(bundle);
}
示例13: resolveFile
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private static File resolveFile(String pluginName, String path) {
Bundle bundle = Platform.getBundle(pluginName);
URL fileURL = bundle.getEntry(path);
try {
URL resolvedFileURL = FileLocator.toFileURL(fileURL);
URI resolvedURI = new URI(resolvedFileURL.getProtocol(), resolvedFileURL.getPath(), null);
return new File(resolvedURI);
} catch (URISyntaxException | IOException e) {
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
return null;
}
示例14: getBeanClass
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private Class<StatusBean> getBeanClass() {
String beanBundleName = getSecondaryIdAttribute("beanBundleName");
String beanClassName = getSecondaryIdAttribute("beanClassName");
try {
Bundle bundle = Platform.getBundle(beanBundleName);
return (Class<StatusBean>)bundle.loadClass(beanClassName);
} catch (Exception ne) {
logger.error("Cannot get class "+beanClassName+". Defaulting to StatusBean. This will probably not work though.", ne);
return StatusBean.class;
}
}
示例15: initializeDefaultPreferences
import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
@Override
public void initializeDefaultPreferences() {
boolean compilerInstalled = Platform.getBundle(COMPILER_PLUGIN) != null;
getPreferenceStore().setDefault(SolidityPreferences.COMPILER_ENABLED, compilerInstalled);
getPreferenceStore().setDefault(SolidityPreferences.COMPILER_OUTPUT_ABI, false);
getPreferenceStore().setDefault(SolidityPreferences.COMPILER_OUTPUT_AST, false);
getPreferenceStore().setDefault(SolidityPreferences.COMPILER_OUTPUT_BIN, true);
getPreferenceStore().setDefault(SolidityPreferences.COMPILER_OUTPUT_ASM, false);
getPreferenceStore().setDefault(SolidityPreferences.COMPILER_OUTPUT_PATH, DEFAULT_OUTPUT_PATH);
getPreferenceStore().setDefault(SolidityPreferences.FOLDING_COMMENT_AUTOFOLD, SolidityPreferences.FOLDING_COMMENT_AUTOFOLD_HEADER);
getPreferenceStore().setDefault(SolidityPreferences.FOLDING_COMMENT_LINECOUNT, 5);
}