Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2002-2006 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM - Initial API and implementation
  
  package org.eclipse.emf.java.presentation;
  
  
  
  import java.net.URL;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import  org.eclipse.swt.SWT;
  import  org.eclipse.swt.custom.CTabFolder;
  import  org.eclipse.swt.dnd.DND;
  import  org.eclipse.swt.dnd.Transfer;
  import  org.eclipse.swt.graphics.Point;
  import  org.eclipse.swt.layout.FillLayout;
  import  org.eclipse.swt.widgets.Composite;
  import  org.eclipse.swt.widgets.Menu;
  import  org.eclipse.swt.widgets.Table;
  import  org.eclipse.swt.widgets.TableColumn;
  import  org.eclipse.swt.widgets.Tree;
  import  org.eclipse.swt.widgets.TreeColumn;
 
 
 
 import  org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
 import  org.eclipse.emf.edit.domain.EditingDomain;
 import  org.eclipse.emf.edit.domain.IEditingDomainProvider;
 import  org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
 import  org.eclipse.emf.edit.provider.ComposedAdapterFactory;
 import  org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
 import  org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
 import  org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
 import  org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
 import  org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
 import  org.eclipse.emf.edit.ui.dnd.LocalTransfer;
 import  org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
 import  org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
 import  org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
 import  org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
 import  org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
 
 import  org.eclipse.emf.edit.ui.util.EditUIUtil;
 import  org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
 
 
 //import org.eclipse.swt.events.ControlAdapter;
 //import org.eclipse.swt.events.ControlEvent;
 

This is an example of a Java model editor.

Generated:
 
 public class JavaEditor 
   extends MultiPageEditorPart
   implements IEditingDomainProvider, ISelectionProviderIMenuListenerIViewerProviderIGotoMarker
 {
  
This keeps track of the editing domain that is used to track all changes to the model.

Generated:
 
   protected AdapterFactoryEditingDomain editingDomain;

  
This is the one adapter factory used for providing views of the model.

Generated:
 
   protected ComposedAdapterFactory adapterFactory;

  
This is the content outline page.

Generated:
 
This is a kludge...

Generated:
 
This is the content outline page's viewer.

Generated:
 
   protected TreeViewer contentOutlineViewer;

  
This is the property sheet page.

Generated:
 
This is the viewer that shadows the selection in the content outline. The parent relation must be correctly defined for this to work.

Generated:
 
   protected TreeViewer selectionViewer;

  
This inverts the roll of parent and child in the content provider and show parents as a tree.

Generated:
 
   protected TreeViewer parentViewer;

  
This shows how a tree view works.

Generated:
 
   protected TreeViewer treeViewer;

  
This shows how a list view works. A list viewer doesn't support icons.

Generated:
 
   protected ListViewer listViewer;

  
This shows how a table view works. A table can be used as a list with icons.

Generated:
 
   protected TableViewer tableViewer;

  
This shows how a tree view with columns works.

Generated:
 
   protected TreeViewer treeViewerWithColumns;

  
This keeps track of the active viewer pane, in the book.

Generated:
 
   protected ViewerPane currentViewerPane;

  
This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.

Generated:
 
   protected Viewer currentViewer;

  
This listens to which ever viewer is active.

Generated:
 
This keeps track of all the org.eclipse.jface.viewers.ISelectionChangedListeners that are listening to this editor.

Generated:
 
This keeps track of the selection of the editor as a whole.

Generated:
 
The MarkerHelper is responsible for creating workspace resource markers presented in Eclipse's Problems View.

Generated:
 
   protected MarkerHelper markerHelper = new EditUIMarkerHelper();

  
This listens for when the outline becomes active

Generated:
 
   protected IPartListener partListener =
     new IPartListener()
     {
       public void partActivated(IWorkbenchPart p)
       {
         if (p instanceof ContentOutline)
         {
           if (((ContentOutline)p).getCurrentPage() == )
           {
             getActionBarContributor().setActiveEditor(JavaEditor.this);
 
             setCurrentViewer();
           }
         }
         else if (p instanceof PropertySheet)
         {
           if (((PropertySheet)p).getCurrentPage() == )
           {
             getActionBarContributor().setActiveEditor(JavaEditor.this);
             handleActivate();
           }
         }
         else if (p == JavaEditor.this)
         {
           handleActivate();
         }
       }
       public void partBroughtToTop(IWorkbenchPart p)
       {
         // Ignore.
       }
       public void partClosed(IWorkbenchPart p)
       {
         // Ignore.
       }
       public void partDeactivated(IWorkbenchPart p)
       {
         // Ignore.
       }
       public void partOpened(IWorkbenchPart p)
       {
         // Ignore.
       }
     };

  
Resources that have been removed since last activation.

Generated:
 
   protected Collection<ResourceremovedResources = new ArrayList<Resource>();

  
Resources that have been changed since last activation.

Generated:
 
   protected Collection<ResourcechangedResources = new ArrayList<Resource>();

  
Resources that have been saved.

Generated:
 
   protected Collection<ResourcesavedResources = new ArrayList<Resource>();

  
Map to store the diagnostic associated with a resource.

Generated:
 
Controls whether the problem indication should be updated.

Generated:
 
   protected boolean updateProblemIndication = true;

  
Adapter used to update the problem indication when resources are demanded loaded.

Generated:
 
     new EContentAdapter()
     {
       @Override
       public void notifyChanged(Notification notification)
       {
         if (notification.getNotifier() instanceof Resource)
         {
           switch (notification.getFeatureID(Resource.class))
           {
             case .:
             case .:
             case .:
             {
               Resource resource = (Resource)notification.getNotifier();
               Diagnostic diagnostic = analyzeResourceProblems(resourcenull);
               if (diagnostic.getSeverity() != .)
               {
                 .put(resourcediagnostic);
               }
               else
               {
                 .remove(resource);
               }
 
               if ()
               {
                 getSite().getShell().getDisplay().asyncExec
                   (new Runnable()
                    {
                      public void run()
                      {
                        updateProblemIndication();
                      }
                    });
               }
               break;
             }
           }
         }
         else
         {
           super.notifyChanged(notification);
         }
       }
 
       @Override
       protected void setTarget(Resource target)
       {
         basicSetTarget(target);
       }
 
       @Override
       protected void unsetTarget(Resource target)
       {
         basicUnsetTarget(target);
       }
     };

  
This listens for workspace changes.

Generated:
 
     {
       public void resourceChanged(IResourceChangeEvent event)
       {
         IResourceDelta delta = event.getDelta();
         try
         {
           class ResourceDeltaVisitor implements IResourceDeltaVisitor
           {
             protected ResourceSet resourceSet = .getResourceSet();
             protected Collection<ResourcechangedResources = new ArrayList<Resource>();
             protected Collection<ResourceremovedResources = new ArrayList<Resource>();
 
             public boolean visit(IResourceDelta delta)
             {
               if (delta.getResource().getType() == .)
               {
                 if (delta.getKind() == . ||
                     delta.getKind() == . && delta.getFlags() != .)
                 {
                   Resource resource = .getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false);
                   if (resource != null)
                   {
                     if (delta.getKind() == .)
                     {
                       .add(resource);
                     }
                     else if (!.remove(resource))
                     {
                       .add(resource);
                     }
                   }
                 }
               }
 
               return true;
             }
 
             public Collection<ResourcegetChangedResources()
             {
               return ;
             }
 
             public Collection<ResourcegetRemovedResources()
             {
               return ;
             }
           }
 
           final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
           delta.accept(visitor);
 
           if (!visitor.getRemovedResources().isEmpty())
           {
             getSite().getShell().getDisplay().asyncExec
               (new Runnable()
                {
                  public void run()
                  {
                    .addAll(visitor.getRemovedResources());
                    if (!isDirty())
                    {
                      getSite().getPage().closeEditor(JavaEditor.thisfalse);
                    }
                  }
                });
           }
 
           if (!visitor.getChangedResources().isEmpty())
           {
             getSite().getShell().getDisplay().asyncExec
               (new Runnable()
                {
                  public void run()
                  {
                    .addAll(visitor.getChangedResources());
                    if (getSite().getPage().getActiveEditor() == JavaEditor.this)
                    {
                      handleActivate();
                    }
                  }
                });
           }
         }
         catch (CoreException exception)
         {
           ..log(exception);
         }
       }
     };


  
Handles activation of the editor or it's associated views.

Generated:
 
   protected void handleActivate()
   {
     // Recompute the read only state.
     //
     if (.getResourceToReadOnlyMap() != null)
     {
       .getResourceToReadOnlyMap().clear();
 
       // Refresh any actions that may become enabled or disabled.
       //
       setSelection(getSelection());
     }
 
     if (!.isEmpty())
     {
       if (handleDirtyConflict())
       {
         getSite().getPage().closeEditor(JavaEditor.thisfalse);
       }
       else
       {
         .clear();
         .clear();
         .clear();
       }
     }
     else if (!.isEmpty())
     {
       handleChangedResources();
       .clear();
       .clear();
     }
   }

  
Handles what to do with changed resources on activation.

Generated:
 
   protected void handleChangedResources()
   {
     if (!.isEmpty() && (!isDirty() || handleDirtyConflict()))
     {
       if (isDirty())
       {
         .addAll(.getResourceSet().getResources());
       }
       .getCommandStack().flush();
 
        = false;
       for (Resource resource : )
       {
         if (resource.isLoaded())
         {
           resource.unload();
           try
           {
             resource.load(.);
           }
           catch (IOException exception)
           {
             if (!.containsKey(resource))
             {
               .put(resourceanalyzeResourceProblems(resourceexception));
             }
           }
         }
       }
 
       if (AdapterFactoryEditingDomain.isStale())
       {
       }
 
        = true;
     }
   }
  
  
Updates the problems indication with the information described in the specified diagnostic.

Generated:
 
   protected void updateProblemIndication()
   {
     {
       BasicDiagnostic diagnostic =
         new BasicDiagnostic
           (.,
            "org.eclipse.emf.java.editor",
            0,
            null,
            new Object [] { .getResourceSet() });
       for (Diagnostic childDiagnostic : .values())
       {
         if (childDiagnostic.getSeverity() != .)
         {
           diagnostic.add(childDiagnostic);
         }
       }
 
       int lastEditorPage = getPageCount() - 1;
       if (lastEditorPage >= 0 && getEditor(lastEditorPageinstanceof ProblemEditorPart)
       {
         ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
         if (diagnostic.getSeverity() != .)
         {
           setActivePage(lastEditorPage);
         }
       }
       else if (diagnostic.getSeverity() != .)
       {
         ProblemEditorPart problemEditorPart = new ProblemEditorPart();
         problemEditorPart.setDiagnostic(diagnostic);
         problemEditorPart.setMarkerHelper();
         try
         {
           addPage(++lastEditorPageproblemEditorPartgetEditorInput());
           setPageText(lastEditorPageproblemEditorPart.getPartName());
           setActivePage(lastEditorPage);
           showTabs();
         }
         catch (PartInitException exception)
         {
           ..log(exception);
         }
       }
 
       if (.hasMarkers(.getResourceSet()))
       {
         .deleteMarkers(.getResourceSet());
         if (diagnostic.getSeverity() != .)
         {
           try
           {
             .createMarkers(diagnostic);
           }
           catch (CoreException exception)
           {
             ..log(exception);
           }
         }
       }
     }
   }

  
Shows a dialog that asks if conflicting changes should be discarded.

Generated:
 
   protected boolean handleDirtyConflict()
   {
     return
       MessageDialog.openQuestion
         (getSite().getShell(),
          getString("_UI_FileConflict_label"),
          getString("_WARN_FileConflict"));
   }

  
This creates a model editor.

Generated:
 
   public JavaEditor()
   {
     super();
   }

  
This sets up the editing domain for the model editor.

Generated:
 
   protected void initializeEditingDomain()
   {
     // Create an adapter factory that yields item providers.
     //
      = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
 
     .addAdapterFactory(new ResourceItemProviderAdapterFactory());
     .addAdapterFactory(new JavaItemProviderAdapterFactory());
     .addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
 
     // Create the command stack that will notify this editor as commands are executed.
     //
     BasicCommandStack commandStack = new BasicCommandStack();
 
     // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
     //
     commandStack.addCommandStackListener
       (new CommandStackListener()
        {
          public void commandStackChanged(final EventObject event)
          {
            getContainer().getDisplay().asyncExec
              (new Runnable()
               {
                 public void run()
                 {
                   firePropertyChange(.);
 
                   // Try to select the affected objects.
                   //
                   Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
                   if (mostRecentCommand != null)
                   {
                     setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                   }
                   if ( != null && !.getControl().isDisposed())
                   {
                     .refresh();
                   }
                 }
               });
          }
        });
 
     // Create the editing domain with a special command stack.
     //
      = new AdapterFactoryEditingDomain(commandStacknew HashMap<ResourceBoolean>());
   }

  
This is here for the listener to be able to call it.

Generated:
 
   protected void firePropertyChange(int action)
   {
     super.firePropertyChange(action);
   }

  
This sets the selection into whichever viewer is active.

Generated:
 
   public void setSelectionToViewer(Collection<?> collection)
   {
     final Collection<?> theSelection = collection;
     // Make sure it's okay.
     //
     if (theSelection != null && !theSelection.isEmpty())
     {
       Runnable runnable =
         new Runnable()
         {
           public void run()
           {
             // Try to select the items in the current content viewer of the editor.
             //
             if ( != null)
             {
               .setSelection(new StructuredSelection(theSelection.toArray()), true);
             }
           }
         };
       getSite().getShell().getDisplay().asyncExec(runnable);
     }
   }

  
This returns the editing domain as required by the IEditingDomainProvider interface. This is important for implementing the static methods of AdapterFactoryEditingDomain and for supporting org.eclipse.emf.edit.ui.action.CommandAction.

Generated:
 
   public EditingDomain getEditingDomain()
   {
     return ;
   }

  

Generated:
 
   public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider
   {
    

Generated:
 
     public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory)
     {
       super(adapterFactory);
     }

    

Generated:
 
     @Override
     public Object [] getElements(Object object)
     {
       Object parent = super.getParent(object);
       return (parent == null ? . : Collections.singleton(parent)).toArray();
     }

    

Generated:
 
     @Override
     public Object [] getChildren(Object object)
     {
       Object parent = super.getParent(object);
       return (parent == null ? . : Collections.singleton(parent)).toArray();
     }

    

Generated:
 
     @Override
     public boolean hasChildren(Object object)
     {
       Object parent = super.getParent(object);
       return parent != null;
     }

    

Generated:
 
     @Override
     public Object getParent(Object object)
     {
       return null;
     }
   }

  

Generated:
 
   public void setCurrentViewerPane(ViewerPane viewerPane)
   {
     if ( != viewerPane)
     {
       if ( != null)
       {
         .showFocus(false);
       }
        = viewerPane;
     }
   }

  
This makes sure that one content viewer, either for the current page or the outline view, if it has focus, is the current one.

Generated:
 
   public void setCurrentViewer(Viewer viewer)
   {
     // If it is changing...
     //
     if ( != viewer)
     {
       if ( == null)
       {
         // Create the listener on demand.
         //
          =
           new ISelectionChangedListener()
           {
             // This just notifies those things that are affected by the section.
             //
             public void selectionChanged(SelectionChangedEvent selectionChangedEvent)
             {
               setSelection(selectionChangedEvent.getSelection());
             }
           };
       }
 
       // Stop listening to the old one.
       //
       if ( != null)
       {
       }
 
       // Start listening to the new one.
       //
       if (viewer != null)
       {
       }
 
       // Remember it.
       //
        = viewer;
 
       // Set the editors selection based on the current viewer's selection.
       //
     }
   }

  
This returns the viewer as required by the IViewerProvider interface.

Generated:
 
   public Viewer getViewer()
   {
     return ;
   }

  
This creates a context menu for the viewer and adds a listener as well registering the menu for extension.

Generated:
  protected void createContextMenuFor(StructuredViewer viewer)
  {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menucontextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenunew UnwrappingSelectionProvider(viewer));
    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
    viewer.addDragSupport(dndOperationstransfersnew ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperationstransfersnew EditingDomainViewerDropAdapter(viewer));
  }

  
This is the method called to load a resource into the editing domain's resource set based on the editor's input.

Generated:
  public void createModel()
  {
    URI resourceURI = EditUIUtil.getURI(getEditorInput());
    Exception exception = null;
    Resource resource = null;
    try
    {
      // Load the resource through the editing domain.
      //
      resource = .getResourceSet().getResource(resourceURItrue);
    }
    catch (Exception e)
    {
      exception = e;
      resource = .getResourceSet().getResource(resourceURIfalse);
    }
    Diagnostic diagnostic = analyzeResourceProblems(resourceexception);
    if (diagnostic.getSeverity() != .)
    {
      .put(resource,  analyzeResourceProblems(resourceexception));
    }
    .getResourceSet().eAdapters().add();
  }

  
Returns a diagnostic describing the errors and warnings listed in the resource and the specified exception (if any).

Generated:
  public Diagnostic analyzeResourceProblems(Resource resourceException exception
  {
    if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty())
    {
      BasicDiagnostic basicDiagnostic =
        new BasicDiagnostic
          (.,
           "org.eclipse.emf.java.editor",
           0,
           getString("_UI_CreateModelError_message"resource.getURI()),
           new Object [] { exception == null ? (Object)resource : exception });
      basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resourcetrue));
      return basicDiagnostic;
    }
    else if (exception != null)
    {
      return
        new BasicDiagnostic
          (.,
           "org.eclipse.emf.java.editor",
           0,
           getString("_UI_CreateModelError_message"resource.getURI()),
           new Object[] { exception });
    }
    else
    {
      return .;
    }
  }

  
This is the method used by the framework to install your own controls.

Generated:
EATM
  public void createPages()
  {
    // I assume that the input is a file object.
    //
    try
    {
      Map<StringObjectextensionToFactoryMap = .getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap();
      extensionToFactoryMap.put("java"new JavaResourceFactoryImpl());
      extensionToFactoryMap.put("packages"new JavaPackageResourceFactoryImpl());
      
      setupClassLoader(modelFile.getFile().getProject());
      // Load the resource through the editing domain.
      //
      .loadResource
        (URI.createPlatformResourceURI(modelFile.getFile().getFullPath().toString(), true).toString());
        new EcoreUtil.UnresolvedProxyCrossReferencer(.getResourceSet())
        {
          private static final long serialVersionUID = 1L;
          @Override
          protected TreeIterator<NotifiernewContentsIterator()
          {
            return 
              new EcoreUtil.ContentTreeIterator<Notifier>()
              {
                private static final long serialVersionUID = 1L;
                @Override
                protected Iterator<? extends EObjectgetEObjectChildren(EObject eObject)
                {
                  if (eObject instanceof JCompilationUnit)
                  {
                    // final JCompilationUnit jCompilationUnit = (JCompilationUnit)eObject;
                    final List<JClasstypes = ((JCompilationUnit)eObject).getTypes();
                    return 
                      new Iterator<EObject>()
                      {
                        int index = 0;
  
                        public boolean hasNext()
                        {
                          return  < types.size();
                        }
  
                        public EObject next()
                        {
                          return types.get(++);
                        }
  
                        public void remove()
                        {
                          throw new UnsupportedOperationException();
                        }
                      };
                  }
                  else
                  {
                    return super.getEObjectChildren(eObject);
                  }
                }
  
                @Override
                protected Iterator<EObjectgetResourceChildren(Resource r)
                {
                    final List<EObjectcontents = r.getContents();
                    return 
                      new Iterator<EObject>()
                      {
                        int index = 0;
  
                        public boolean hasNext()
                        {
                          return  < contents.size();
                        }
  
                        public EObject next()
                        {
                          return contents.get(++);
                        }
  
                        public void remove()
                        {
                          throw new UnsupportedOperationException();
                        }
                      };
                }
              };
          }
  
  /*
          protected void handleCrossReference(EObject eObject)
          {
            if (eObject instanceof JCompilationUnit)
            {
              JCompilationUnit jCompilationUnit =  (JCompilationUnit)eObject;
              if (".class".equals(jCompilationUnit.getName()))
              {
                List types = jCompilationUnit.getTypes();
                for (int i = 0; i < types.size(); ++i)
                {
                  JClass jClass = (JClass)types.get(i);
                  crossReference(jCompilationUnit, JavaPackage.eINSTANCE.getJCompilationUnit_Types(), jClass);
                }
                return;
              }
            }
  
            super.handleCrossReference(eObject);
          }
  */
  
          @Override
          {
            // EATM MEGA KLUDGE.
            crossReference();
  
            return super.findUnresolvedProxyCrossReferences();
          }
      for (Map.Entry<?, ?> entry : map.entrySet())
      {
        ..println("Unresolved proxy: " + entry);
      }
      // The one object in the resource's extent should be the root object.
      //
      // rootObject = (EObject)((Resource)editingDomain.getResourceSet().getResources().iterator().next()).getContents().get(0);
    }
    catch (Exception exception)
    {
      exception.printStackTrace();
    }
    // Create a page for the selection tree view.
    //
    {
      ViewerPane viewerPane =
        new ViewerPane(getSite().getPage(), JavaEditor.this)
        {
          @Override
          public Viewer createViewer(Composite composite)
          {
            Tree tree = new Tree(composite, SWT.MULTI);
            TreeViewer newTreeViewer = new TreeViewer(tree);
            return newTreeViewer;
          }
          @Override
          public void requestActivation()
          {
            super.requestActivation();
            setCurrentViewerPane(this);
          }
        };
      viewerPane.createControl(getContainer());
       = (TreeViewer)viewerPane.getViewer();
      .setContentProvider(new AdapterFactoryContentProvider());
      .setLabelProvider(new AdapterFactoryLabelProvider());
      .setInput(.getResourceSet());
      .setSelection(new StructuredSelection(.getResourceSet().getResources().get(0)), true);
      viewerPane.setTitle(.getResourceSet());
      new AdapterFactoryTreeEditor(.getTree(), );
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndexgetString("_UI_SelectionPage_label"));
    }
    // Create a page for the parent tree view.
    //
    {
      ViewerPane viewerPane =
        new ViewerPane(getSite().getPage(), JavaEditor.this)
        {
          @Override
          public Viewer createViewer(Composite composite)
          {
            Tree tree = new Tree(composite, SWT.MULTI);
            TreeViewer newTreeViewer = new TreeViewer(tree);
            return newTreeViewer;
          }
          @Override
          public void requestActivation()
          {
            super.requestActivation();
            setCurrentViewerPane(this);
          }
        };
      viewerPane.createControl(getContainer());
       = (TreeViewer)viewerPane.getViewer();
      .setLabelProvider(new AdapterFactoryLabelProvider());
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndexgetString("_UI_ParentPage_label"));
    }
    // This is the page for the list viewer
    //
    {
      ViewerPane viewerPane =
        new ViewerPane(getSite().getPage(), JavaEditor.this)
        {
          @Override
          public Viewer createViewer(Composite composite)
          {
            return new ListViewer(composite);
          }
          @Override
          public void requestActivation()
          {
            super.requestActivation();
            setCurrentViewerPane(this);
          }
        };
      viewerPane.createControl(getContainer());
       = (ListViewer)viewerPane.getViewer();
      .setContentProvider(new AdapterFactoryContentProvider());
      .setLabelProvider(new AdapterFactoryLabelProvider());
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndexgetString("_UI_ListPage_label"));
    }
    // This is the page for the tree viewer
    //
    {
      ViewerPane viewerPane =
        new ViewerPane(getSite().getPage(), JavaEditor.this)
        {
          @Override
          public Viewer createViewer(Composite composite)
          {
            return new TreeViewer(composite);
          }
          @Override
          public void requestActivation()
          {
            super.requestActivation();
            setCurrentViewerPane(this);
          }
        };
      viewerPane.createControl(getContainer());
       = (TreeViewer)viewerPane.getViewer();
      .setContentProvider(new AdapterFactoryContentProvider());
      .setLabelProvider(new AdapterFactoryLabelProvider());
      new AdapterFactoryTreeEditor(.getTree(), );
      int pageIndex = addPage(viewerPane.getControl());
      setPageText(pageIndexgetString("_UI_TreePage_label"));
    }
    // This is the page for the table viewer.
    //
    {
      ViewerPane viewerPane =
        new ViewerPane(getSite().getPage(), JavaEditor.this)
        {
          @Override
          public Viewer createViewer(Composite composite)
          {