java 为 Eclipse 插件导入 org.eclipse.core 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3086859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 00:17:41  来源:igfitidea点击:

importing org.eclipse.core packages for Eclipse plug-in

javaeclipse-pluginosgi

提问by harschware

I'm trying to create a plug-in to mimic the Eclipse open resource dialog (CTRL+SHIFT+R). I've learned how to create a FilteredItemsSelectionDialog by following the example. But the missing piece is how to fill the dialog with the workspace resources. I found OpenResourceHandlerand am trying to duplicate this functionality in my plug-in, so I can step through and see how it works. So I copy the source and rename it to avoid colliding with the real one. The problem is that I cannot import these classes:

我正在尝试创建一个插件来模拟 Eclipse 打开资源对话框 (CTRL+SHIFT+R)。我已经按照示例学习了如何创建 FilteredItemsSelectionDialog 。但缺少的部分是如何用工作区资源填充对话框。我找到了OpenResourceHandler并试图在我的插件中复制这个功能,这样我就可以逐步了解它是如何工作的。所以我复制源并重命名它以避免与真实的冲突。问题是我无法导入这些类:

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;

I tried editing my Manifest but it will not let me import org.eclipse.core (although I can import org.eclipse.core.runtime). So, where do I find these classes and how can import them? And, more importantly, in general how would I find the bundle a given class exists in and import it?

我尝试编辑我的清单,但它不会让我导入 org.eclipse.core(虽然我可以导入 org.eclipse.core.runtime)。那么,我在哪里可以找到这些类以及如何导入它们?而且,更重要的是,通常我如何找到给定类存在的包并导入它?

回答by Andrew Niefer

You need to import org.eclipse.core.resources.

您需要导入org.eclipse.core.resources.

In general, you can open the "Plug-ins" view (Window -> Show View -> Other -> Plug-in Development -> Plug-ins). Then, select interesting plug-ins and right click -> Add to Java Search. Then you can use Open Type (Ctrl + Shift + T) to open the class.

一般情况下,可以打开“插件”视图(Window -> Show View -> Other -> Plug-in Development -> Plug-ins)。然后,选择有趣的插件并右键单击 -> 添加到 Java 搜索。然后您可以使用 Open Type (Ctrl + Shift + T) 打开类。

Also, in the package explorer, change the Filters to not exclude "External plug-in libraries project". "Link with Editor" can then show you what bundle contains the class you just opened.

此外,在包资源管理器中,将过滤器更改为不排除“外部插件库项目”。“Link with Editor”然后可以显示包含您刚刚打开的类的包。