Jump to: navigation, search

Difference between revisions of "Common Navigator Framework"

(How to use the CNF with Resources in an RCP Application)
(added a link to CNF article 2)
 
(6 intermediate revisions by 3 users not shown)
Line 11: Line 11:
 
* [http://scribbledideas.blogspot.com/ Michael Elder's CNF Tutorials]
 
* [http://scribbledideas.blogspot.com/ Michael Elder's CNF Tutorials]
 
* [http://dev.eclipse.org/blogs/francis Francis Upton's CNF Blog]
 
* [http://dev.eclipse.org/blogs/francis Francis Upton's CNF Blog]
 +
* [http://www.techjava.de/topics/2009/04/eclipse-common-navigator-framework/ CNF introduction tutorial on TechJava by Simon Zambrovski]
 +
* [http://www.techjava.de/topics/2009/08/eclipse-common-navigator-framework-2/ CNF from multiple plug-ins on TechJava by Simon Zambrovski]
  
 
We are interested in your [[Common Navigator Framework Use Cases]].
 
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:
 
 
<ol>
 
<li>
 
Add the following as dependent plugins:
 
<ul>
 
<li>org.eclipse.ui.navigator
 
<li>org.eclipse.ui.navigator.resources
 
<li>org.eclipse.ui.ide
 
<li>org.eclipse.core.resources
 
</ul>
 
<li>Add a View extension (org.eclipse.ui.views) which uses the class org.eclipse.ui.navigator.CommonNavigator.
 
<pre>
 
  <extension
 
        point="org.eclipse.ui.views">
 
      <view
 
            name="View"
 
            class="org.eclipse.ui.navigator.CommonNavigator"
 
            id="example.view">
 
      </view>
 
  </extension>
 
</pre>
 
<li>Update your perspective factory (IPerspectiveFactory) code to show the new View (this is necessary when adding any View):
 
<pre>
 
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);
 
}
 
 
</pre>
 
<p>
 
Note that for the moment you need to specify "true" to show title, otherwise the viewer will not render correctly.  See
 
[[https://bugs.eclipse.org/bugs/show_bug.cgi?id=235171 bug 235171]].
 
<li>
 
Add a org.eclipse.ui.navigator.viewer extension that has:
 
<ul>
 
<li>viewerActionBinding, point this to your View Id above (example.view)
 
<ul>
 
<li>includes of org.eclipse.ui.navigator.resources
 
</ul>
 
<li>viewerContentBinding, point this to your View Id above (example.view)
 
<ul>
 
<li>includes of:
 
<ul>
 
<li>org.eclipse.ui.navigator.resources
 
<li>org.eclipse.ui.navigator.resourceContent
 
<li>org.eclipse.ui.navigator.resources.filters
 
<li>org.eclipse.ui.navigator.resources.linkHelper
 
<li>org.eclipse.ui.navigator.resources.workingSets"
 
</ul>
 
</ul>
 
</ul>
 
<pre>
 
  <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>
 
 
</pre>
 
<li>Add the following to your WorkbenchAdvisor
 
<ul>
 
<li>To get the resource workspace as input, override this method:
 
<pre>
 
public IAdaptable getDefaultPageInput() {
 
IWorkspace workspace = ResourcesPlugin.getWorkspace();
 
return workspace.getRoot();
 
}
 
</pre>
 
<li>To get the correct adapters hooked up and to have the project icons available,
 
add this code to the initialize() method:
 
<pre>
 
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);
 
}
 
</pre>
 
</ul>
 
  
  
  
 
[[Category:Platform UI]]
 
[[Category:Platform UI]]

Latest revision as of 01:09, 20 August 2009

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.