Eclipse RCP: Does CNF without IDE plug-in require custom ContentProvider?
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&g开发者_如何学编程t;
</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 + "]");
}
Instead of using the CommonNavigator class, you need to extend it and then override the getInitialInput() method. There return IWorkspaceRoot
精彩评论