Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Common Navigator Framework

Revision as of 12:09, 2 June 2008 by Francisu.ieee.org (Talk | contribs) (How to use the CNF with Resources in an RCP Application)

Template:Platform UI The Common Navigator Framework (CNF) is designed to help you integrate document models into a navigator experience, integrate content that isn't specific to the workbench, allow you to absorb other content seamlessly (in particular resource and Java(tm) models), and mitigate your expense in time and effort to absorb incremental enhancements from release to release from layers beneath you.

The CNF began as a product solution for a general problem in IBM Rational Application Developer v6.0, and has been contributed to the open source Eclipse Platform in 3.2 to allow the community to better integrate their navigational viewers and provide a more cohesive user experience across software layers and products.

To begin using the CNF, developers should consult the schema and API documentation in the Platform Help (Window > Help > Platform Developer's Guide > Reference > Schema + API).

Also have a look at the following resources for the CNF:

We are interested in your Common Navigator Framework Use Cases.


How to use the CNF with Resources in an RCP Application

If you are using resources (org.eclipse.core.resources), using the CNF is the preferred way to allow your clients to manipulate your resources. It's possible add the CNF to an RCP application in just a few minutes using these steps:

  1. Add the following as dependent plugins:
    • org.eclipse.ui.navigator
    • org.eclipse.ui.navigator.resources
    • org.eclipse.ui.ide
    • 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. See [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
    • To get the resource workspace as input, override this method:
      	public IAdaptable getDefaultPageInput() {
      		IWorkspace workspace = ResourcesPlugin.getWorkspace();
      		return workspace.getRoot();
      	}
      
  6. To get the correct adapters hooked up and to have the project icons available, add this code to the initialize() method:
    	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);
    	}
    

Back to the top