Eclipse RCP:没有IDE插件的CNF是否需要自定义ContentProvider?
在 RCP 应用程序中,我想创建一个 Common Navigator Framework 视图,仅从本地文件系统上的资源开始。
我已经在一个包含 org.eclipse.ui.ide 插件的项目中完成了这一任务。但是,这会创建一个过于复杂且不适合此应用程序的 UI。 (例如,它添加了大约 20 个首选项面板,其中一些与构建和版本控制相关。)
所以现在我尝试在不使用 ~.ide 插件且不使用 org.eclipse.ui 的情况下完成此操作。 .navigator.resources 依赖它的插件。
在 RCP 应用程序中,我成功地使用下面的代码在带有 ~navigator.viewer 扩展的插件中创建了一个新的工作区项目(我认为),如下所示。但 CNF 视图中什么也没有出现。
问题:
- 由于我排除了 org.eclipse.ui.navigator.resources 插件,我是否需要定义自己的内容提供程序?
- org.eclipse.ui.navigator.resources插件中的类ResourceExtensionContentProvider是否用于实现内容绑定org.eclipse.ui.navigator.resourceContent?
plugin.xml 摘录
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerActionBinding
viewerId="com.mycompany.app.gen.workspace">
<includes>
<actionExtension pattern="org.eclipse.ui.navigator.resources.*" />
</includes>
</viewerActionBinding>
<viewerContentBinding
viewerId="com.dnastar.app.gen.workspace">
<includes>
<contentExtension pattern="org.eclipse.ui.navigator.resourceContent" />
<contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.workingSets"/>
</includes>
</viewerContentBinding>
</extension>
用于创建新项目的代码(为了完整性而包含在内):
Path path = new Path( sPath );
File filePath = new File( sPath );
String fileBaseName = filePath.getName();
String projectName = fileBaseName; // For now
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectDescription projDescr = workspace.newProjectDescription( projectName );
projDescr.setLocation( path );
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject( projectName );
try {
project.create( projDescr, null );
if ( ! project.isOpen() ) {
project.open( null );
}
} catch (CoreException e) {
MessageDialog.openError( Display.getCurrent().getActiveShell(),
"New Project Error", "Could not create new project." + "\n[" + e + "]");
}
In an RCP application, I'd like to create a Common Navigator Framework view, starting just with resources on the local file system.
I've done that in one project that includes the org.eclipse.ui.ide plug-in. However, that creates a UI that is over-complex and inappropriate for this application. (For example, it adds about 20 preferences panels, some associated with builds and version control.)
So now I'm trying to do it without the ~.ide plug-in -- and without the org.eclipse.ui.navigator.resources plug-in which depends on it.
In the RCP app, I've managed to create a new workspace project (I think) with the code below, in a plugin with the ~navigator.viewer extensions shown below. But nothing appears in the CNF view.
Questions:
- Since I am excluding the org.eclipse.ui.navigator.resources plug-in, do I need to define my own content provider?
- Is the class ResourceExtensionContentProvider in the org.eclipse.ui.navigator.resources plug-in used to implement the content binding org.eclipse.ui.navigator.resourceContent?
plugin.xml excerpt
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerActionBinding
viewerId="com.mycompany.app.gen.workspace">
<includes>
<actionExtension pattern="org.eclipse.ui.navigator.resources.*" />
</includes>
</viewerActionBinding>
<viewerContentBinding
viewerId="com.dnastar.app.gen.workspace">
<includes>
<contentExtension pattern="org.eclipse.ui.navigator.resourceContent" />
<contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.linkHelper"/>
<contentExtension pattern="org.eclipse.ui.navigator.resources.workingSets"/>
</includes>
</viewerContentBinding>
</extension>
Code used to create a new project (included for completeness):
Path path = new Path( sPath );
File filePath = new File( sPath );
String fileBaseName = filePath.getName();
String projectName = fileBaseName; // For now
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectDescription projDescr = workspace.newProjectDescription( projectName );
projDescr.setLocation( path );
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject( projectName );
try {
project.create( projDescr, null );
if ( ! project.isOpen() ) {
project.open( null );
}
} catch (CoreException e) {
MessageDialog.openError( Display.getCurrent().getActiveShell(),
"New Project Error", "Could not create new project." + "\n[" + e + "]");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要扩展它,然后重写 getInitialInput() 方法,而不是使用 CommonNavigator 类。还有返回IWorkspaceRoot
Instead of using the CommonNavigator class, you need to extend it and then override the getInitialInput() method. There return IWorkspaceRoot