To add the Common Navigator to an RCP application and have it manipulate the workspace resources, do the following:
<extension
point="org.eclipse.ui.views">
<view
name="View"
class="org.eclipse.ui.navigator.CommonNavigator"
id="example.view">
</view>
</extension>
public void createInitialLayout(IPageLayout layout) {
String editorArea = layout.getEditorArea();
layout.setEditorAreaVisible(false);
layout.setFixed(true);
layout.addStandaloneView("example.view", true /* show title */, IPageLayout.LEFT, 1.0f, editorArea);
}
Note that for the moment you need to specify "true" to show title, otherwise the viewer will not render correctly (bug 235171).
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerActionBinding
viewerId="example.view">
<includes>
<actionExtension pattern="org.eclipse.ui.navigator.resources.*" />
</includes>
</viewerActionBinding>
<viewerContentBinding
viewerId="example.view">
<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>
public IAdaptable getDefaultPageInput() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
return workspace.getRoot();
}
public void initialize(IWorkbenchConfigurer configurer) {
WorkbenchAdapterBuilder.registerAdapters();
final String ICONS_PATH = "icons/full/";
final String PATH_OBJECT = ICONS_PATH + "obj16/";
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
declareWorkbenchImage(configurer, ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif",
true);
declareWorkbenchImage(configurer, ideBundle,
IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
+ "cprj_obj.gif", true);
}
private void declareWorkbenchImage(IWorkbenchConfigurer configurer_p,
Bundle ideBundle, String symbolicName, String path, boolean shared) {
URL url = ideBundle.getEntry(path);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
configurer_p.declareImage(symbolicName, desc, shared);
}
Warning: the WorkbenchAdapterBuilder.registerAdapters() is an internal method and not part of the Eclipse API and is therefore subject to change in a subsequent release. There is an open work item to replace this with similar capability that is part of the API.