wiki:ModelNavigator

Version 8 (modified by anonymous, 17 years ago) (diff)

--

Create Model Navigator

<back

  1. Create new view with a normal TreeViewer? (for example)
  2. Use AdapterFactoryContentProvider as content provider and AdapterFactoryLabelProvider as label provider. It should be something like that:
    AdapterFactory adapterFactory = ExhibitionDiagramEditorPlugin
            .getInstance().getItemProvidersAdapterFactory();
    viewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    viewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
    
  3. Set the input of the viewer like that: (Maybe there is a better way, but I didn't found it yet...)
    IEditorPart edp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    viewer.setInput(((DiagramDocumentEditor)edp).getEditingDomain().getResourceSet());
    
  4. You can inherit from the content and label provider to customize them for your needs.
  5. Notice: the viewer will only update the objects that it contains. If you for example omit the top-level node, the viewer will not notice if you add or remove a childnode of the top-level node.

If you want the properties view to listen to selection changes of the viewer do the following:

  1. The view must implement ITabbedPropertySheetPageContributor
  2. The method getContributorId() must return the ID that is returned by getContributorId() of your XXXDiagramEditor class.
  3. Implement the method getAdapter similar to the following:
    public Object getAdapter(Class type) {
        if (type == IPropertySheetPage.class) {
           return new PropertiesBrowserPage(this);
        }
        return super.getAdapter(type);
    }
    
  4. In createPartControl add getSite().setSelectionProvider(viewer); where viewer is your TreeViewer?.
  5. Probably you have to add something like <input type="org.eclipse.emf.ecore.EObject"/> to the plugin.xml for the extension point org.eclipse.ui.views.properties.tabbed.propertySections.