capint
1/10/2016 - 5:00 PM

Eclipse >> Common Navigator Framework

Eclipse >> Common Navigator Framework

>> Source: http://www.modumind.com/2007/04/25/common-navigator-tutorial-1-hello-world/
        https://github.com/capint/codesnippet.eclipsercp >> com.rcpquickstart.cnftutorial
>> Step 1: Set up the view
  *** <extension
         point="org.eclipse.ui.views">
      <view
            class="com.rcpquickstart.cnftutorial.view.TutorialNavigator"
            id="com.rcpquickstart.cnftutorial.view.navigator"
  *** public class TutorialNavigator extends CommonNavigator {
	@Override
	protected IAdaptable getInitialInput() {
		this.getCommonViewer().refresh();
		return new NavigatorRoot();
	}
}

>> Step 2: Prepare the model
  *** public class NavigatorRoot extends PlatformObject {
  	public List<ParentBean> getParentBeans() {
  		List<ParentBean> parents = new LinkedList<ParentBean>();
      ...
  		return parents;
  	}
  }
  
>> Step 3: Prepare the content and label providers
<extension
      point="org.eclipse.ui.navigator.navigatorContent">
   <navigatorContent
         contentProvider="com.rcpquickstart.cnftutorial.view.ParentBeanContentProvider"
         id="com.rcpquickstart.cnftutorial.parentBeanContent"
         labelProvider="com.rcpquickstart.cnftutorial.view.ParentBeanLabelProvider"
         name="Parent Bean Content">
      <!--Trigger points specify what will cause our content to appear -->
      <triggerPoints>
         <instanceof value="com.rcpquickstart.cnftutorial.model.NavigatorRoot"/>
      </triggerPoints>
   </navigatorContent>
</extension>

>> Step 4: Bind the content to the navigator
<extension
         point="org.eclipse.ui.navigator.viewer">
      <viewer viewerId="com.rcpquickstart.cnftutorial.view.navigator"/>
      <viewerContentBinding viewerId="com.rcpquickstart.cnftutorial.view.navigator">
         <includes>
         <!-- Point to the content provider -->
            <contentExtension pattern="com.rcpquickstart.cnftutorial.parentBeanContent"/>
         </includes>
      </viewerContentBinding>
   </extension>