本文介绍了为Eclipse插件导入org.eclipse.core包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个插件来模拟Eclipse打开的资源对话框(CTRL + SHIFT + R)。我学习了如何创建一个FilteredItemsSelectionDialog,遵循。但是,缺少的是如何使用工作空间资源填充对话框。我发现,我试图在我的插件中复制这个功能,所以我可以逐步了解它的工作原理。所以我复制源并重命名它以避免与真实的冲突。问题是我不能导入这些类:

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 OpenResourceHandler and 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:

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

我尝试编辑我的清单,但它不会让我导入org.eclipse.core(虽然我可以import org.eclipse.core.runtime)。那么,我在哪里可以找到这些类,如何导入?而且,更重要的是,一般来说,我如何找到一个给定类的bundle并导入它?

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.resources

一般来说,您可以打开插件视图(窗口 - >显示视图 - >其他 - >插件开发 - >插件)。然后,选择有趣的插件,然后右键单击 - >添加到Java搜索。然后,您可以使用打开类型(Ctrl + Shift + T)打开类。

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.

此外,在包资源管理器中,更改过滤器以不排除在图书馆工程。 链接到编辑器可以显示您刚才打开的课程包含什么。

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.

这篇关于为Eclipse插件导入org.eclipse.core包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 14:08