Author: pkluegl
Date: Fri Nov  4 13:13:43 2011
New Revision: 1197545

URL: http://svn.apache.org/viewvc?rev=1197545&view=rev
Log:
UIMA-2273
The notification of views when the cas document is exchanged will now be 
processed by a new listener and controlled by the AnnotationEditor in the 
doSetInput method. Adapted known view. I hope I haven't missed any. The update 
logic should be improved by using setInput (see comments on jira)...

Added:
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
Modified:
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java
    
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeContentProvider.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/explain/apply/ApplyViewPage.java
 Fri Nov  4 13:13:43 2011
@@ -19,15 +19,13 @@
 
 package org.apache.uima.textmarker.explain.apply;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.editor.AbstractAnnotationDocumentListener;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.ICasDocument;
 import org.apache.uima.caseditor.editor.ICasDocumentListener;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
 import org.apache.uima.textmarker.addons.TextMarkerAddonsPlugin;
 import org.apache.uima.textmarker.explain.ExplainConstants;
 import org.apache.uima.textmarker.explain.tree.ExplainTree;
@@ -45,7 +43,7 @@ import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.IPageSite;
 import org.eclipse.ui.part.Page;
 
-public class ApplyViewPage extends Page implements ISelectionListener {
+public class ApplyViewPage extends Page implements ISelectionListener, 
ICasEditorInputListener {
 
   protected TreeViewer viewer;
 
@@ -123,41 +121,7 @@ public class ApplyViewPage extends Page 
     viewer.setInput(tree.getRoot());
     getSite().setSelectionProvider(viewer);
     getSite().getPage().addSelectionListener(this);
-
-    listener = new AbstractAnnotationDocumentListener() {
-
-      @Override
-      public void changed() {
-      }
-
-      @Override
-      public void viewChanged(String oldViewName, String newViewName) {
-      }
-
-      @Override
-      protected void addedAnnotation(Collection<AnnotationFS> annotations) {
-      }
-
-      @Override
-      protected void removedAnnotation(Collection<AnnotationFS> annotations) {
-      }
-
-      @Override
-      protected void updatedAnnotation(Collection<AnnotationFS> annotations) {
-      }
-
-      @Override
-      public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
-        document.removeChangeListener(this);
-        document = newDocument;
-        document.addChangeListener(this);
-        ExplainTree tree = new ExplainTree(document.getCAS());
-        viewer.setInput(tree.getRoot());
-        viewer.refresh();
-      }
-
-    };
-    document.addChangeListener(listener);
+    editor.addCasEditorInputListener(this);
     viewer.refresh();
   }
 
@@ -169,7 +133,7 @@ public class ApplyViewPage extends Page 
   public void dispose() {
     super.dispose();
     getSite().getPage().removeSelectionListener(this);
-    document.removeChangeListener(listener);
+    editor.removeCasEditorInputListener(this);
     if (images != null) {
       for (Image each : images.values()) {
         each.dispose();
@@ -194,4 +158,13 @@ public class ApplyViewPage extends Page 
 
   }
 
+  @Override
+  public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
+    editor.removeCasEditorInputListener(this);
+    document = newDocument;
+    editor.addCasEditorInputListener(this);
+    ExplainTree tree = new ExplainTree(document.getCAS());
+    viewer.setInput(tree.getRoot());
+    viewer.refresh();
+  }
 }

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/EvaluationViewPage.java
 Fri Nov  4 13:13:43 2011
@@ -26,6 +26,7 @@ import org.apache.uima.cas.FeatureStruct
 import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.ICasDocument;
 import org.apache.uima.caseditor.editor.ICasDocumentListener;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
 import 
org.apache.uima.textmarker.caseditor.view.tree.AnnotationTreeViewDragListener;
 import org.apache.uima.textmarker.testing.ui.views.tree.TestEvaluationTree;
 import org.eclipse.jface.viewers.CheckboxTreeViewer;
@@ -43,7 +44,8 @@ import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.IPageSite;
 import org.eclipse.ui.part.Page;
 
-public class EvaluationViewPage extends Page implements ICasDocumentListener, 
ISelectionListener {
+public class EvaluationViewPage extends Page implements ICasDocumentListener, 
ISelectionListener,
+        ICasEditorInputListener {
 
   private CheckboxTreeViewer viewer;
 
@@ -97,7 +99,7 @@ public class EvaluationViewPage extends 
     getSite().getPage().addSelectionListener(this);
 
     document.addChangeListener(this);
-
+    editor.addCasEditorInputListener(this);
     reloadTree();
   }
 
@@ -113,6 +115,7 @@ public class EvaluationViewPage extends 
     super.dispose();
     getSite().getPage().removeSelectionListener(this);
     document.removeChangeListener(this);
+    editor.removeCasEditorInputListener(this);
     if (images != null) {
       for (Image each : images.values()) {
         each.dispose();
@@ -123,7 +126,6 @@ public class EvaluationViewPage extends 
   @Override
   public void selectionChanged(IWorkbenchPart part, ISelection selection) {
     // TODO Auto-generated method stub
-
   }
 
   @Override

Modified: 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeContentProvider.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeContentProvider.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeContentProvider.java
 (original)
+++ 
uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-caseditor/src/main/java/org/apache/uima/textmarker/caseditor/view/tree/AnnotationTreeContentProvider.java
 Fri Nov  4 13:13:43 2011
@@ -25,26 +25,32 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.caseditor.editor.AbstractAnnotationDocumentListener;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
 
 public class AnnotationTreeContentProvider extends 
AbstractAnnotationDocumentListener implements
-        ITreeContentProvider {
+        ITreeContentProvider, ICasEditorInputListener {
 
   private ICasDocument document;
 
   private final AnnotationTreeViewPage page;
 
+  private AnnotationEditor editor;
+
   public AnnotationTreeContentProvider(AnnotationEditor editor, 
AnnotationTreeViewPage page) {
     super();
+    this.editor = editor;
     this.document = editor.getDocument();
     this.page = page;
+    editor.addCasEditorInputListener(this);
   }
 
   @Override
   public void dispose() {
     document.removeChangeListener(this);
+    editor.removeCasEditorInputListener(this);
   }
 
   /*

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
 Fri Nov  4 13:13:43 2011
@@ -131,10 +131,4 @@ public abstract class AbstractDocument i
     }
   }
 
-  protected void fireCasDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
-    for (ICasDocumentListener listener : mListener.toArray(new 
ICasDocumentListener[0])) {
-      listener.casDocumentChanged(oldDocument, newDocument);
-    }
-  }
-
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
 Fri Nov  4 13:13:43 2011
@@ -270,8 +270,5 @@ class AnnotationDocument extends Documen
 
   }
 
-  public void switchCasDocument(ICasDocument oldDocument, ICasDocument 
newDocument) {
-    ((DocumentUimaImpl) mDocument).switchCasDocument(oldDocument, newDocument);
-  }
 
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
 Fri Nov  4 13:13:43 2011
@@ -351,10 +351,7 @@ public final class AnnotationEditor exte
       // TODO: Currently do nothing ... 
     }
     
-    public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
-      // TODO: Currently do nothing ...
-    }
-    
+   
   }
 
   /**
@@ -552,6 +549,8 @@ public final class AnnotationEditor exte
 
   private Set<IAnnotationEditorModifyListener> mEditorListener = new 
HashSet<IAnnotationEditorModifyListener>();
 
+  private Set<ICasEditorInputListener> mEditorInputListener = new 
HashSet<ICasEditorInputListener>();;
+  
   /**
    * TODO: Do we really need this position variable ?
    */
@@ -576,6 +575,8 @@ public final class AnnotationEditor exte
   private IPropertyChangeListener preferenceStoreChangeListener;
   
   private CasDocumentProvider casDocumentProvider;
+
+
   
   /**
    * Creates an new AnnotationEditor object.
@@ -797,17 +798,15 @@ public final class AnnotationEditor exte
   @Override
   protected void handleElementContentReplaced() {
     super.handleElementContentReplaced();
-    ICasDocument oldDocument = getDocument();
     setInput(getEditorInput());
-    ICasDocument newDocument = getDocument();
-    oldDocument.switchCasDocument(oldDocument, newDocument);
   }
   
   @Override
   protected void doSetInput(IEditorInput input) throws CoreException {
-    
+    ICasDocument oldDocument = getDocument();
     super.doSetInput(input);
-    
+    ICasDocument newDocument = getDocument();
+    fireCasDocumentChanged(oldDocument, newDocument);
     
     if (CasEditorPlugin.getDefault().
             getAndClearShowMigrationDialogFlag()) {
@@ -871,6 +870,13 @@ public final class AnnotationEditor exte
     }
   }
   
+  private void fireCasDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
+    if (mEditorInputListener != null) {
+      for (ICasEditorInputListener listener : mEditorInputListener)
+        listener.casDocumentChanged(oldDocument, newDocument);
+    }
+  }
+
   // The editor status support is abused to display different control than the
   // text control when displaying text is not possible, e.g. because the sofa
   // is not a text sofa or not set at all
@@ -1220,6 +1226,15 @@ public final class AnnotationEditor exte
     mEditorListener.remove(listener);
   }
 
+  public void addCasEditorInputListener(ICasEditorInputListener listener) {
+    mEditorInputListener.add(listener);
+  }
+  
+  public void removeCasEditorInputListener(ICasEditorInputListener listener) {
+    mEditorInputListener.remove(listener);
+  }
+  
+  
   /**
    * Returns the selection.
    *

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
 Fri Nov  4 13:13:43 2011
@@ -373,7 +373,5 @@ public class DocumentUimaImpl extends Ab
     return cas;
   }
 
-  public void switchCasDocument(ICasDocument oldDocument, ICasDocument 
newDocument) {
-    fireCasDocumentChanged(oldDocument, newDocument);
-  }
+
 }

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=1197545&r1=1197544&r2=1197545&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
 Fri Nov  4 13:13:43 2011
@@ -134,14 +134,6 @@ public interface ICasDocument {
    */
   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=1197545&r1=1197544&r2=1197545&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
 Fri Nov  4 13:13:43 2011
@@ -91,14 +91,5 @@ public interface ICasDocumentListener {
    */
   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

Added: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java?rev=1197545&view=auto
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
 (added)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
 Fri Nov  4 13:13:43 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+public interface ICasEditorInputListener {
+
+  /**
+   * 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 casDocumentChanged(ICasDocument oldDocument, ICasDocument newDocument);
+  
+}

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java?rev=1197545&r1=1197544&r2=1197545&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
 Fri Nov  4 13:13:43 2011
@@ -599,7 +599,7 @@ final class EditViewPage extends Page im
 
 
     FeatureStructureContentProvider contentProvider =
-        new FeatureStructureContentProvider(document);
+        new FeatureStructureContentProvider(editor);
 
     viewer.setContentProvider(contentProvider);
 

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=1197545&r1=1197544&r2=1197545&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
 Fri Nov  4 13:13:43 2011
@@ -29,28 +29,35 @@ import org.apache.uima.cas.FeatureStruct
 import org.apache.uima.cas.StringArrayFS;
 import org.apache.uima.cas.Type;
 import org.apache.uima.caseditor.editor.AbstractDocumentListener;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.ArrayValue;
 import org.apache.uima.caseditor.editor.CasEditorError;
 import org.apache.uima.caseditor.editor.FeatureValue;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
 
 final class FeatureStructureContentProvider extends AbstractDocumentListener 
implements
-        ITreeContentProvider {
+        ITreeContentProvider, ICasEditorInputListener {
 
   private ICasDocument mDocument;
 
   private Viewer viewer;
 
-  FeatureStructureContentProvider(ICasDocument document) {
+  private ICasEditor mEditor;
 
-    if (document == null) {
+  FeatureStructureContentProvider(ICasEditor editor) {
+    mEditor = editor;
+    mDocument = editor.getDocument();
+    if (mDocument == null) {
       throw new IllegalArgumentException("document parameter must not be 
null!");
     }
-
-    mDocument = document;
+    if(mEditor instanceof AnnotationEditor) {
+      ((AnnotationEditor)mEditor).addCasEditorInputListener(this);
+    }
   }
 
   private int arraySize(FeatureStructure value) {
@@ -116,6 +123,9 @@ final class FeatureStructureContentProvi
 
   public void dispose() {
     mDocument.removeChangeListener(this);
+    if(mEditor instanceof AnnotationEditor) {
+      ((AnnotationEditor)mEditor).removeCasEditorInputListener(this);
+    }
   }
 
   public void inputChanged(final Viewer viewer, Object oldInput, Object 
newInput) {
@@ -241,6 +251,11 @@ final class FeatureStructureContentProvi
   }
 
   public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
-    inputChanged(viewer, oldDocument, newDocument);
+    oldDocument.removeChangeListener(this);
+    mDocument = newDocument;
+    mDocument.addChangeListener(this);
+    viewer.setInput(null);
+    viewer.refresh();
   }
+
 }
\ 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=1197545&r1=1197544&r2=1197545&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
 Fri Nov  4 13:13:43 2011
@@ -33,9 +33,11 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
 import org.apache.uima.caseditor.editor.AbstractAnnotationDocumentListener;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.FeatureValue;
 import org.apache.uima.caseditor.editor.ICasDocument;
 import org.apache.uima.caseditor.editor.ICasEditor;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
 import org.apache.uima.caseditor.editor.ModelFeatureStructure;
 import org.apache.uima.caseditor.editor.action.DeleteFeatureStructureAction;
 import org.apache.uima.caseditor.editor.util.StrictTypeConstraint;
@@ -68,14 +70,20 @@ public final class FeatureStructureBrows
   private static final String LAST_SELECTED_FS_TYPE = 
"lastSelectedFeatureStructureBrowserViewType";
 
   final class FeatureStructureTreeContentProvider extends 
AbstractAnnotationDocumentListener
-          implements ITreeContentProvider {
+          implements ITreeContentProvider , ICasEditorInputListener{
 
     private ICasDocument mDocument;
 
     private Type mCurrentType;
 
-    FeatureStructureTreeContentProvider(ICasDocument document) {
-      mDocument = document;
+    private ICasEditor mEditor;
+
+    FeatureStructureTreeContentProvider(ICasEditor editor) {
+      mEditor = editor;
+      mDocument = editor.getDocument();
+      if(mEditor instanceof AnnotationEditor) {
+        ((AnnotationEditor)mEditor).addCasEditorInputListener(this);
+      }
     }
 
     public Object[] getElements(Object inputElement) {
@@ -103,6 +111,10 @@ public final class FeatureStructureBrows
     }
 
     public void dispose() {
+      mDocument.removeChangeListener(this);
+      if(mEditor instanceof AnnotationEditor) {
+        ((AnnotationEditor)mEditor).removeCasEditorInputListener(this);
+      }
     }
 
     public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
@@ -286,7 +298,11 @@ public final class FeatureStructureBrows
     }
 
     public void casDocumentChanged(ICasDocument oldDocument, ICasDocument 
newDocument) {
-      inputChanged(mFSList, oldDocument, newDocument);
+      oldDocument.removeChangeListener(this);
+      mDocument = newDocument;
+      mDocument.addChangeListener(this);
+      // TODO retrieve the type from the new type system of the new document?
+      inputChanged(mFSList, mCurrentType, mCurrentType);
     }
   }
 
@@ -451,7 +467,7 @@ public final class FeatureStructureBrows
     instanceListData.horizontalAlignment = SWT.FILL;
     instanceListData.verticalAlignment = SWT.FILL;
     mFSList.getList().setLayoutData(instanceListData);
-    mFSList.setContentProvider(new 
FeatureStructureTreeContentProvider(mDocument));
+    mFSList.setContentProvider(new 
FeatureStructureTreeContentProvider(mCasEditor));
     mFSList.setLabelProvider(new FeatureStructureLabelProvider());
 
     mFSList.setUseHashlookup(true);

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=1197545&r1=1197544&r2=1197545&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
 Fri Nov  4 13:13:43 2011
@@ -27,13 +27,14 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.caseditor.editor.AbstractAnnotationDocumentListener;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditorInputListener;
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
 
 abstract class OutlineContentProviderBase extends 
AbstractAnnotationDocumentListener implements
-        ITreeContentProvider {
+        ITreeContentProvider, ICasEditorInputListener {
 
   protected AnnotationEditor mEditor;
 
@@ -44,13 +45,15 @@ abstract class OutlineContentProviderBas
   protected OutlineContentProviderBase(AnnotationEditor editor, TreeViewer 
viewer) {
     this.viewer = viewer;
     this.mEditor = editor;
+    mEditor.addCasEditorInputListener(this);
   }
 
   /**
    * not implemented
    */
   public void dispose() {
-    // currently not implemented
+    mInputDocument.removeChangeListener(this);
+    mEditor.removeCasEditorInputListener(this);
   }
 
   /**


Reply via email to