# Using the Common Navigator in an RCP Application

To add the Common Navigator to an RCP application and have it manipulate the workspace resources, do the following:

1. Add the following as dependent plug-ins:
   1. org.eclipse.ui.navigator
   2. org.eclipse.ui.navigator.resources
   3. org.eclipse.ui.ide
   4. org.eclipse.core.resources
2. Add a View extension (org.eclipse.ui.views) which uses the class org.eclipse.ui.navigator.CommonNavigator.

          <extension
                point="org.eclipse.ui.views">
             <view
                   name="View"
                   class="org.eclipse.ui.navigator.CommonNavigator"
                   id="example.view">
             </view>
          </extension>

3. Update your perspective factory (IPerspectiveFactory) code to show the new View (this is necessary when adding any View):

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

4. Add a org.eclipse.ui.navigator.viewer extension that has:
   - viewerActionBinding, point this to your View Id above (example.view)
     - includes of org.eclipse.ui.navigator.resources
   - viewerContentBinding, point this to your View Id above (example.view)
     - includes of:
       - org.eclipse.ui.navigator.resources
       - org.eclipse.ui.navigator.resourceContent
       - org.eclipse.ui.navigator.resources.filters
       - org.eclipse.ui.navigator.resources.linkHelper
       - org.eclipse.ui.navigator.resources.workingSets

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

5. Add the following to your WorkbenchAdvisor
   1. To get the resource workspace as input, override this method:

          	public IAdaptable getDefaultPageInput() {
          		IWorkspace workspace = ResourcesPlugin.getWorkspace();
          		return workspace.getRoot();
          	}

   2. To get the correct adapters hooked up add this code to the initialize() method:

          	public void initialize(IWorkbenchConfigurer configurer) {
          		WorkbenchAdapterBuilder.registerAdapters();
          	}

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