Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java?rev=1197166&r1=1197165&r2=1197166&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
 Thu Nov  3 14:49:30 2011
@@ -28,80 +28,78 @@ import org.apache.uima.cas.text.Annotati
 
 /**
  * The {@link ICasDocument} represents texts with meta information.
- *
- * A {@link ICasDocument} allows manipulation of its meta information
- * the text must not be changed.
- *
+ * 
+ * A {@link ICasDocument} allows manipulation of its meta information the text 
must not be changed.
+ * 
  * Meta information can be retrieved over the {@link CAS} object.
- *
- * Note: All changes to meta information should be done with
- * calls to the manipulation methods of the document.
- * If this is not possible, change the {@link CAS} and after
- * the change call the {@link ICasDocument#changed()} method.
+ * 
+ * Note: All changes to meta information should be done with calls to the 
manipulation methods of
+ * the document. If this is not possible, change the {@link CAS} and after the 
change call the
+ * {@link ICasDocument#changed()} method.
  */
 public interface ICasDocument {
 
   /**
    * Adds a given change listener.
-   *
+   * 
    * @param listener
    */
   void addChangeListener(ICasDocumentListener listener);
 
   /**
    * Removes the given change listener.
-   *
+   * 
    * @param listener
    */
   void removeChangeListener(ICasDocumentListener listener);
 
   /**
    * Retrieves the CAS.
-   *
+   * 
    * @return the CAS
    */
   CAS getCAS();
 
   /**
    * Adds a {@link FeatureStructure} to the document.
-   *
-   * @param structure -
-   *          the {@link FeatureStructure} to add.
+   * 
+   * @param structure
+   *          - the {@link FeatureStructure} to add.
    */
   void addFeatureStructure(FeatureStructure structure);
 
   /**
    * Adds the {@link FeatureStructure}s.
-   *
+   * 
    * @param structures
    */
   void addFeatureStructures(Collection<? extends FeatureStructure> structures);
 
   /**
    * Removes an {@link FeatureStructure} from the Document.
-   *
-   * @param structure -
-   *          the {@link FeatureStructure} to remove.
+   * 
+   * @param structure
+   *          - the {@link FeatureStructure} to remove.
    */
   void removeFeatureStructure(FeatureStructure structure);
 
   /**
    * Removes the given {@link FeatureStructure}s.
-   *
+   * 
    * @param structuresToRemove
    */
   void removeFeatureStructures(Collection<? extends FeatureStructure> 
structuresToRemove);
 
   /**
    * Updates the given {@link FeatureStructure}.
-   *
+   * 
    * @param structure
    */
   void update(FeatureStructure structure);
 
   /**
    * Updates the given {@link FeatureStructure}s.
-   *
+   * 
    * @param structures
    */
   void updateFeatureStructure(Collection<? extends FeatureStructure> 
structures);
@@ -113,27 +111,37 @@ public interface ICasDocument {
 
   /**
    * Returns all <code>Annotation</code>s of the given type.
-   *
-   * @param type -
-   *          type of the requested <code>Annotation</code>s.
+   * 
+   * @param type
+   *          - type of the requested <code>Annotation</code>s.
    * @return - return all <code>Annotation</code> of the given type or null if 
no
    *         <code>Annotation</code> of this type exist.
    */
   Collection<AnnotationFS> getAnnotations(Type type);
 
   /**
-   * Switches the view of the underlying CAS to the provided
-   * view name.
+   * Switches the view of the underlying CAS to the provided view name.
    * 
    * @param viewName
    */
   void switchView(String viewName);
-  
+
   /**
    * Retrieves the requested type.
-   *
+   * 
    * @param type
    * @return the type
    */
   Type getType(String type);
+
+  /**
+   * This method is called if an {@link ICasDocument} is exchanged.
+   * 
+   * @param oldDocument
+   *          - the replaced, old document {@link ICasDocument}.
+   * @param newDocument
+   *          - the new, current document {@link ICasDocument}.
+   */
+  void switchCasDocument(ICasDocument oldDocument, ICasDocument newDocument);
+
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java?rev=1197166&r1=1197165&r2=1197166&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
 Thu Nov  3 14:49:30 2011
@@ -29,66 +29,76 @@ import org.apache.uima.cas.FeatureStruct
 public interface ICasDocumentListener {
   /**
    * This method is called if an {@link FeatureStructure} is added.
-   *
-   * @param newFeatureStructure -
-   *          the added {@link FeatureStructure}.
+   * 
+   * @param newFeatureStructure
+   *          - the added {@link FeatureStructure}.
    */
   void added(FeatureStructure newFeatureStructure);
 
   /**
    * This method is called if multiple <code>FeatureStructure</code>s are 
added.
-   *
-   * @param newFeatureStructure -
-   *          the added {@link FeatureStructure}s.
+   * 
+   * @param newFeatureStructure
+   *          - the added {@link FeatureStructure}s.
    */
   void added(Collection<FeatureStructure> newFeatureStructure);
 
   /**
    * This method is called if an {@link FeatureStructure} is removed.
-   *
-   * @param deletedFeatureStructure -
-   *          the removed {@link FeatureStructure}.
+   * 
+   * @param deletedFeatureStructure
+   *          - the removed {@link FeatureStructure}.
    */
   void removed(FeatureStructure deletedFeatureStructure);
 
   /**
    * This method is called if multiple {@link FeatureStructure}s are removed.
-   *
-   * @param deletedFeatureStructure -
-   *          the removed <code>Annotation</code>s.
+   * 
+   * @param deletedFeatureStructure
+   *          - the removed <code>Annotation</code>s.
    */
   void removed(Collection<FeatureStructure> deletedFeatureStructure);
 
   /**
    * This method is called if the {@link FeatureStructure} changed.
-   *
+   * 
    * @param featureStructure
    */
   void updated(FeatureStructure featureStructure);
 
   /**
    * This method is called if the {@link FeatureStructure}s changed.
-   *
+   * 
    * @param featureStructure
    */
   void updated(Collection<FeatureStructure> featureStructure);
 
   /**
-   * This method is called if {@link FeatureStructure}s in the
-   * document are changed.
-   *
+   * This method is called if {@link FeatureStructure}s in the document are 
changed.
+   * 
    * Note: The text can not be changed
    */
   void changed();
-  
+
   /**
-   * This method is called when the currently active view is changed in
-   * the document. A view changed does not indicate a structural change,
-   * but usually feature structures must be completely synchronized afterward.
+   * This method is called when the currently active view is changed in the 
document. A view changed
+   * does not indicate a structural change, but usually feature structures 
must be completely
+   * synchronized afterward.
    * 
    * @param oldViewName
    * @param newViewName
    * @return
    */
   void viewChanged(String oldViewName, String newViewName);
+
+  /**
+   * This method is called when the currently active document is changed, 
e.g., the file input
+   * changed.
+   * 
+   * 
+   * @param oldDocument
+   * @param newDocument
+   * @return
+   */
+  void casDocumentChanged(ICasDocument oldDocument, ICasDocument newDocument);
 }
\ No newline at end of file

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java?rev=1197166&r1=1197165&r2=1197166&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
 Thu Nov  3 14:49:30 2011
@@ -37,8 +37,8 @@ import org.eclipse.jface.viewers.ITreeCo
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
 
-final class FeatureStructureContentProvider extends AbstractDocumentListener
-        implements ITreeContentProvider {
+final class FeatureStructureContentProvider extends AbstractDocumentListener 
implements
+        ITreeContentProvider {
 
   private ICasDocument mDocument;
 
@@ -97,8 +97,7 @@ final class FeatureStructureContentProvi
         }
 
         return featureValues.toArray();
-      }
-      else {
+      } else {
         int size = arraySize(featureStructure);
 
         ArrayValue arrayValues[] = new ArrayValue[size];
@@ -137,7 +136,7 @@ final class FeatureStructureContentProvi
   public void viewChanged(String oldViewName, String newViewName) {
     changed();
   }
-  
+
   public void changed() {
 
     Display.getDefault().syncExec(new Runnable() {
@@ -148,7 +147,7 @@ final class FeatureStructureContentProvi
   }
 
   public void removed(Collection<FeatureStructure> deletedFeatureStructure) {
-    for(FeatureStructure fs : deletedFeatureStructure) {
+    for (FeatureStructure fs : deletedFeatureStructure) {
       if (viewer.getInput() == fs) {
         viewer.setInput(null);
         break;
@@ -185,8 +184,7 @@ final class FeatureStructureContentProvi
       ArrayFS array = (ArrayFS) value.getFeatureStructure();
 
       return getElements(array.get(value.slot()));
-    }
-    else {
+    } else {
       throw new CasEditorError("Unexpected element type!");
     }
   }
@@ -199,7 +197,6 @@ final class FeatureStructureContentProvi
 
     boolean result;
 
-
     if (value != null) {
 
       if (value.getType().isArray()) {
@@ -222,8 +219,7 @@ final class FeatureStructureContentProvi
 
       if (value.getFeature().getRange().isPrimitive()) {
         return false;
-      }
-      else {
+      } else {
         return hasChildren((FeatureStructure) value.getValue());
       }
     } else if (element instanceof ArrayValue) {
@@ -235,14 +231,16 @@ final class FeatureStructureContentProvi
         ArrayFS array = (ArrayFS) value.getFeatureStructure();
 
         return hasChildren(array.get(value.slot()));
-      }
-      else {
+      } else {
         // false for primitive arrays
         return false;
       }
-    }
-    else {
+    } else {
       throw new CasEditorError("Unkown element type");
     }
   }
+
+  public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
+    inputChanged(viewer, oldDocument, newDocument);
+  }
 }
\ No newline at end of file

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java?rev=1197166&r1=1197165&r2=1197166&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
 Thu Nov  3 14:49:30 2011
@@ -64,15 +64,14 @@ import org.eclipse.ui.part.Page;
  * The actual view page which contains the ui code for this view.
  */
 public final class FeatureStructureBrowserViewPage extends Page {
-  
+
   private static final String LAST_SELECTED_FS_TYPE = 
"lastSelectedFeatureStructureBrowserViewType";
-  
+
   final class FeatureStructureTreeContentProvider extends 
AbstractAnnotationDocumentListener
           implements ITreeContentProvider {
 
     private ICasDocument mDocument;
 
-
     private Type mCurrentType;
 
     FeatureStructureTreeContentProvider(ICasDocument document) {
@@ -86,14 +85,13 @@ public final class FeatureStructureBrows
 
       StrictTypeConstraint typeConstrain = new 
StrictTypeConstraint(mCurrentType);
 
-      FSIterator<FeatureStructure> strictTypeIterator 
=mDocument.getCAS().createFilteredIterator(
+      FSIterator<FeatureStructure> strictTypeIterator = 
mDocument.getCAS().createFilteredIterator(
               
mDocument.getCAS().getIndexRepository().getAllIndexedFS(mCurrentType), 
typeConstrain);
 
       LinkedList<ModelFeatureStructure> featureStrucutreList = new 
LinkedList<ModelFeatureStructure>();
 
       while (strictTypeIterator.hasNext()) {
-        featureStrucutreList.add(new ModelFeatureStructure(mDocument,
-                strictTypeIterator.next()));
+        featureStrucutreList.add(new ModelFeatureStructure(mDocument, 
strictTypeIterator.next()));
       }
 
       ModelFeatureStructure[] featureStructureArray = new 
ModelFeatureStructure[featureStrucutreList
@@ -132,7 +130,7 @@ public final class FeatureStructureBrows
 
     /**
      * Retrieves children for a FeatureStrcuture and for FeatureValues if they 
have children.
-     *
+     * 
      * @param parentElement
      * @return the children
      */
@@ -206,8 +204,7 @@ public final class FeatureStructureBrows
     @Override
     protected void addedAnnotation(Collection<AnnotationFS> annotations) {
 
-      final LinkedList<ModelFeatureStructure> featureStrucutreList =
-        new LinkedList<ModelFeatureStructure>();
+      final LinkedList<ModelFeatureStructure> featureStrucutreList = new 
LinkedList<ModelFeatureStructure>();
 
       for (AnnotationFS annotation : annotations) {
         if (annotation.getType() == mCurrentType) {
@@ -224,8 +221,7 @@ public final class FeatureStructureBrows
 
     @Override
     public void added(Collection<FeatureStructure> structres) {
-      final LinkedList<ModelFeatureStructure> featureStrucutreList =
-        new LinkedList<ModelFeatureStructure>();
+      final LinkedList<ModelFeatureStructure> featureStrucutreList = new 
LinkedList<ModelFeatureStructure>();
 
       for (FeatureStructure structure : structres) {
         if (structure.getType() == mCurrentType) {
@@ -243,8 +239,7 @@ public final class FeatureStructureBrows
     @Override
     protected void removedAnnotation(Collection<AnnotationFS> annotations) {
 
-      final LinkedList<ModelFeatureStructure> featureStrucutreList =
-        new LinkedList<ModelFeatureStructure>();
+      final LinkedList<ModelFeatureStructure> featureStrucutreList = new 
LinkedList<ModelFeatureStructure>();
 
       for (AnnotationFS annotation : annotations) {
         if (annotation.getType() == mCurrentType) {
@@ -262,8 +257,7 @@ public final class FeatureStructureBrows
 
     @Override
     public void removed(Collection<FeatureStructure> structres) {
-      final LinkedList<ModelFeatureStructure> featureStrucutreList =
-        new LinkedList<ModelFeatureStructure>();
+      final LinkedList<ModelFeatureStructure> featureStrucutreList = new 
LinkedList<ModelFeatureStructure>();
 
       for (FeatureStructure structure : structres) {
         if (structure.getType() == mCurrentType) {
@@ -286,10 +280,14 @@ public final class FeatureStructureBrows
     public void viewChanged(String oldViewName, String newViewName) {
       changed();
     }
-    
+
     public void changed() {
       mFSList.refresh();
     }
+
+    public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
+      inputChanged(mFSList, oldDocument, newDocument);
+    }
   }
 
   private class CreateAction extends Action {
@@ -323,7 +321,7 @@ public final class FeatureStructureBrows
   private ICasDocument mDocument;
 
   private ICasEditor mCasEditor;
-  
+
   private ListViewer mFSList;
 
   private Composite mInstanceComposite;
@@ -336,21 +334,20 @@ public final class FeatureStructureBrows
 
   private Collection<Type> filterTypes;
 
-
   /**
    * Initializes a new instance.
-   *
+   * 
    * @param document
    */
   public FeatureStructureBrowserViewPage(ICasEditor editor) {
 
-       if (editor == null)
-               throw new IllegalArgumentException("editor parameter must not 
be null!");
+    if (editor == null)
+      throw new IllegalArgumentException("editor parameter must not be null!");
 
     mDocument = editor.getDocument();
 
     mCasEditor = editor;
-    
+
     mDeleteAction = new DeleteFeatureStructureAction(this.mDocument);
 
     mSelectAllAction = new SelectAllAction();
@@ -404,51 +401,49 @@ public final class FeatureStructureBrows
     layout.numColumns = 1;
 
     mInstanceComposite.setLayout(layout);
-    
+
     Composite typePanel = new Composite(mInstanceComposite, SWT.NULL);
-    
+
     GridData typePanelData = new GridData();
     typePanelData.grabExcessHorizontalSpace = true;
     typePanelData.grabExcessVerticalSpace = false;
     typePanelData.horizontalAlignment = SWT.FILL;
     typePanel.setLayoutData(typePanelData);
-    
+
     GridLayout typePanelLayout = new GridLayout();
     typePanelLayout.numColumns = 2;
     typePanel.setLayout(typePanelLayout);
-    
+
     Label typeLabel = new Label(typePanel, SWT.NONE);
     typeLabel.setText("Type: ");
 
     GridData typeLabelData = new GridData();
     typeLabelData.horizontalAlignment = SWT.LEFT;
     typeLabel.setLayoutData(typeLabelData);
-    
-    
-    TypeCombo typeCombo = new TypeCombo(typePanel,
-            mDocument.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_TOP),
-            mDocument.getCAS().getTypeSystem(), filterTypes);
+
+    TypeCombo typeCombo = new TypeCombo(typePanel, 
mDocument.getCAS().getTypeSystem()
+            .getType(CAS.TYPE_NAME_TOP), mDocument.getCAS().getTypeSystem(), 
filterTypes);
     GridData typeComboData = new GridData();
     typeComboData.horizontalAlignment = SWT.FILL;
     typeComboData.grabExcessHorizontalSpace = true;
     typeCombo.setLayoutData(typeComboData);
-    
-    final IPreferenceStore store = mCasEditor.getCasDocumentProvider().
-            getSessionPreferenceStore(mCasEditor.getEditorInput());
-    
+
+    final IPreferenceStore store = 
mCasEditor.getCasDocumentProvider().getSessionPreferenceStore(
+            mCasEditor.getEditorInput());
+
     Type lastUsedType = 
mDocument.getType(store.getString(LAST_SELECTED_FS_TYPE));
-    
+
     if (lastUsedType != null) {
       typeCombo.select(lastUsedType);
     }
-    
+
     typeCombo.addListener(new ITypePaneListener() {
-      
+
       public void typeChanged(Type newType) {
         store.setValue(LAST_SELECTED_FS_TYPE, newType.getName());
       }
     });
-    
+
     mFSList = new ListViewer(mInstanceComposite, SWT.MULTI | SWT.V_SCROLL | 
SWT.BORDER);
     GridData instanceListData = new GridData();
     instanceListData.grabExcessHorizontalSpace = true;
@@ -474,7 +469,7 @@ public final class FeatureStructureBrows
 
   /**
    * Retrieves the control
-   *
+   * 
    * @return the control
    */
   @Override
@@ -485,7 +480,7 @@ public final class FeatureStructureBrows
   /**
    * Adds the following actions to the toolbar: {@link CreateAction} {@link 
DereferenceAction}
    * {@link DeleteAction}
-   *
+   * 
    * @param menuManager
    * @param toolBarManager
    * @param statusLineManager
@@ -505,7 +500,7 @@ public final class FeatureStructureBrows
 
   /**
    * Sets global action handlers for: delete select all
-   *
+   * 
    * @param actionBars
    */
   @Override
@@ -526,4 +521,5 @@ public final class FeatureStructureBrows
   public void setFocus() {
     mInstanceComposite.setFocus();
   }
+
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java?rev=1197166&r1=1197165&r2=1197166&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
 Thu Nov  3 14:49:30 2011
@@ -28,123 +28,122 @@ import org.eclipse.jface.viewers.TreeVie
 import org.eclipse.swt.widgets.Display;
 
 /**
-   * This <code>OutlineContentProvider</code> synchronizes the 
<code>AnnotationFS</code>s with
-   * the <code>TableViewer</code>.
+ * This <code>OutlineContentProvider</code> synchronizes the 
<code>AnnotationFS</code>s with the
+ * <code>TableViewer</code>.
+ */
+class ModeSensitiveContentProvider extends OutlineContentProviderBase {
+
+  private AnnotationTreeNodeList mAnnotationNodeList;
+
+  protected ModeSensitiveContentProvider(AnnotationEditor editor, TreeViewer 
viewer) {
+    super(editor, viewer);
+    this.viewer = viewer;
+  }
+
+  /**
+   * Adds the added annotations to the viewer.
+   * 
+   * @param annotations
    */
-  class ModeSensitiveContentProvider extends OutlineContentProviderBase {
-         
-    private AnnotationTreeNodeList mAnnotationNodeList;
-
-    protected ModeSensitiveContentProvider(AnnotationEditor editor, TreeViewer 
viewer) {
-       super(editor, viewer);
-       this.viewer = viewer;
-    }
-
-    /**
-     * Adds the added annotations to the viewer.
-     *
-     * @param annotations
-     */
-    @Override
-    public void addedAnnotation(Collection<AnnotationFS> annotations) {
-      for (AnnotationFS annotation : annotations) {
-        if 
(!annotation.getType().getName().equals(mEditor.getAnnotationMode().getName())) 
{
-          return;
-        }
-
-        final AnnotationTreeNode annotationNode = new 
AnnotationTreeNode(mEditor.getDocument(),
-                annotation);
-
-        mAnnotationNodeList.add(annotationNode);
-        // mAnnotationNodeList.buildTree();
-
-        Display.getDefault().syncExec(new Runnable() {
-          public void run() {
-                 viewer.add(annotationNode.getParent() != null ? 
annotationNode.getParent()
-                    : mInputDocument, annotationNode);
-          }
-        });
+  @Override
+  public void addedAnnotation(Collection<AnnotationFS> annotations) {
+    for (AnnotationFS annotation : annotations) {
+      if 
(!annotation.getType().getName().equals(mEditor.getAnnotationMode().getName())) 
{
+        return;
       }
-    }
 
-    /**
-     * Removes the removed annotations from the viewer.
-     *
-     * @param deletedAnnotations
-     */
-    @Override
-    public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) 
{
-      // TODO: what happens if someone removes an annoation which
-      // is not an element of this list e.g in the featruestructure view ?
-      final AnnotationTreeNode[] items = new 
AnnotationTreeNode[deletedAnnotations.size()];
-
-      int i = 0;
-      for (AnnotationFS annotation : deletedAnnotations) {
-        // TODO: maybe it is a problem if the parent is not correctly set!
-        items[i] = new AnnotationTreeNode(mEditor.getDocument(), annotation);
-        mAnnotationNodeList.remove(items[i]);
-        i++;
-      }
+      final AnnotationTreeNode annotationNode = new 
AnnotationTreeNode(mEditor.getDocument(),
+              annotation);
 
+      mAnnotationNodeList.add(annotationNode);
+      // mAnnotationNodeList.buildTree();
 
       Display.getDefault().syncExec(new Runnable() {
         public void run() {
-               viewer.remove(items);
+          viewer.add(annotationNode.getParent() != null ? 
annotationNode.getParent()
+                  : mInputDocument, annotationNode);
         }
       });
     }
+  }
 
-    public void viewChanged(String oldViewName, String newViewName) {
-       changed();
-    }
-    
-    public void changed() {
+  /**
+   * Removes the removed annotations from the viewer.
+   * 
+   * @param deletedAnnotations
+   */
+  @Override
+  public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) {
+    // TODO: what happens if someone removes an annoation which
+    // is not an element of this list e.g in the featruestructure view ?
+    final AnnotationTreeNode[] items = new 
AnnotationTreeNode[deletedAnnotations.size()];
+
+    int i = 0;
+    for (AnnotationFS annotation : deletedAnnotations) {
+      // TODO: maybe it is a problem if the parent is not correctly set!
+      items[i] = new AnnotationTreeNode(mEditor.getDocument(), annotation);
+      mAnnotationNodeList.remove(items[i]);
+      i++;
+    }
+
+    Display.getDefault().syncExec(new Runnable() {
+      public void run() {
+        viewer.remove(items);
+      }
+    });
+  }
 
-      Collection<AnnotationFS> annotations = 
mEditor.getDocument().getAnnotations(
-              mEditor.getAnnotationMode());
+  public void viewChanged(String oldViewName, String newViewName) {
+    changed();
+  }
 
-      mAnnotationNodeList = annotations != null ? new 
AnnotationTreeNodeList(mEditor
-              .getDocument(), annotations) : null;
+  public void changed() {
 
-      Display.getDefault().syncExec(new Runnable() {
-        public void run() {
-               viewer.refresh();
-        }
-      });
-    }
+    Collection<AnnotationFS> annotations = 
mEditor.getDocument().getAnnotations(
+            mEditor.getAnnotationMode());
 
-    /**
-        * Retrieves all children of the {@link NlpModel}. That are the {@link 
NlpProject}s and
-        * {@link IProject}s.
-        *
-        * @param inputElement
-        *          the {@link NlpModel}
-        *          
-        * @return the nlp-projects and non-nlp projects
-        */
-       public Object[] getElements(Object inputElement) {
-         if (mAnnotationNodeList == null) {
-           return new Object[0];
-         }
-       
-         return mAnnotationNodeList.getElements().toArray();
-       }
-
-       public Object getParent(Object element) {
-         AnnotationTreeNode node = (AnnotationTreeNode) element;
-       
-         return node.getParent();
-       }
-
-       public boolean hasChildren(Object element) {
-         AnnotationTreeNode node = (AnnotationTreeNode) element;
-       
-         return node.getChildren().size() > 0;
-       }
+    mAnnotationNodeList = annotations != null ? new 
AnnotationTreeNodeList(mEditor.getDocument(),
+            annotations) : null;
 
-       public Object[] getChildren(Object parentElement) {
-      AnnotationTreeNode node = (AnnotationTreeNode) parentElement;
+    Display.getDefault().syncExec(new Runnable() {
+      public void run() {
+        viewer.refresh();
+      }
+    });
+  }
 
-      return node.getChildren().toArray();
+  /**
+   * Retrieves all children of the {@link NlpModel}. That are the {@link 
NlpProject}s and
+   * {@link IProject}s.
+   * 
+   * @param inputElement
+   *          the {@link NlpModel}
+   * 
+   * @return the nlp-projects and non-nlp projects
+   */
+  public Object[] getElements(Object inputElement) {
+    if (mAnnotationNodeList == null) {
+      return new Object[0];
     }
-  }
\ No newline at end of file
+
+    return mAnnotationNodeList.getElements().toArray();
+  }
+
+  public Object getParent(Object element) {
+    AnnotationTreeNode node = (AnnotationTreeNode) element;
+
+    return node.getParent();
+  }
+
+  public boolean hasChildren(Object element) {
+    AnnotationTreeNode node = (AnnotationTreeNode) element;
+
+    return node.getChildren().size() > 0;
+  }
+
+  public Object[] getChildren(Object parentElement) {
+    AnnotationTreeNode node = (AnnotationTreeNode) parentElement;
+
+    return node.getChildren().toArray();
+  }
+}
\ No newline at end of file

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java?rev=1197166&r1=1197165&r2=1197166&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java
 Thu Nov  3 14:49:30 2011
@@ -32,75 +32,79 @@ import org.eclipse.jface.viewers.TreeVie
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
 
-abstract class OutlineContentProviderBase extends 
AbstractAnnotationDocumentListener
-               implements ITreeContentProvider {
-       
-       protected AnnotationEditor mEditor;
-         
-       protected ICasDocument mInputDocument;
-
-    protected TreeViewer viewer;
-
-    protected OutlineContentProviderBase(AnnotationEditor editor, TreeViewer 
viewer) {
-       this.viewer = viewer;
-       this.mEditor = editor;
+abstract class OutlineContentProviderBase extends 
AbstractAnnotationDocumentListener implements
+        ITreeContentProvider {
+
+  protected AnnotationEditor mEditor;
+
+  protected ICasDocument mInputDocument;
+
+  protected TreeViewer viewer;
+
+  protected OutlineContentProviderBase(AnnotationEditor editor, TreeViewer 
viewer) {
+    this.viewer = viewer;
+    this.mEditor = editor;
+  }
+
+  /**
+   * not implemented
+   */
+  public void dispose() {
+    // currently not implemented
+  }
+
+  /**
+   * Gets called if the viewer input was changed. In this case, this only 
happens once if the
+   * {@link AnnotationOutline} is initialized.
+   * 
+   * @param viewer
+   * @param oldInput
+   * @param newInput
+   */
+  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+    if (oldInput != null) {
+      ((ICasDocument) oldInput).removeChangeListener(this);
+    }
+
+    if (newInput != null) {
+      ((ICasDocument) newInput).addChangeListener(this);
+
+      mInputDocument = (ICasDocument) newInput;
+
+      changed();
+    }
+  }
+
+  /**
+   * Updates the given annotation in the viewer.
+   * 
+   * @param annotations
+   */
+  @Override
+  protected void updatedAnnotation(Collection<AnnotationFS> featureStructres) {
+    Collection<AnnotationFS> annotations = new 
ArrayList<AnnotationFS>(featureStructres.size());
+
+    for (FeatureStructure structure : featureStructres) {
+      if (structure instanceof AnnotationFS) {
+        annotations.add((AnnotationFS) structure);
+      }
     }
-    
-    /**
-     * not implemented
-     */
-    public void dispose() {
-      // currently not implemented
+
+    final Object[] items = new Object[annotations.size()];
+
+    int i = 0;
+    for (AnnotationFS annotation : annotations) {
+      items[i++] = new AnnotationTreeNode(mEditor.getDocument(), annotation);
     }
 
-       /**
-        * Gets called if the viewer input was changed. In this case, this only 
happens once if the
-        * {@link AnnotationOutline} is initialized.
-        *
-        * @param viewer
-        * @param oldInput
-        * @param newInput
-        */
-       public void inputChanged(Viewer viewer, Object oldInput, Object 
newInput) {
-         if (oldInput != null) {
-           ((ICasDocument) oldInput).removeChangeListener(this);
-         }
-       
-         if (newInput != null) {
-           ((ICasDocument) newInput).addChangeListener(this);
-       
-           mInputDocument = (ICasDocument) newInput;
-           
-           changed();
-         }
-       }
-
-       /**
-        * Updates the given annotation in the viewer.
-        *
-        * @param annotations
-        */
-       @Override
-       protected void updatedAnnotation(Collection<AnnotationFS> 
featureStructres) {
-         Collection<AnnotationFS> annotations = new 
ArrayList<AnnotationFS>(featureStructres.size());
-       
-         for (FeatureStructure structure : featureStructres) {
-           if (structure instanceof AnnotationFS) {
-             annotations.add((AnnotationFS) structure);
-           }
-         }
-       
-         final Object[] items = new Object[annotations.size()];
-       
-         int i = 0;
-         for (AnnotationFS annotation : annotations) {
-           items[i++] = new AnnotationTreeNode(mEditor.getDocument(), 
annotation);
-         }
-       
-         Display.getDefault().syncExec(new Runnable() {
-           public void run() {
-               viewer.update(items, null);
-           }
-         });
-       }
+    Display.getDefault().syncExec(new Runnable() {
+      public void run() {
+        viewer.update(items, null);
+      }
+    });
+  }
+
+  public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
+    inputChanged(viewer, oldDocument, newDocument);
+  }
 }


Reply via email to