Author: joern
Date: Tue Nov  8 11:38:37 2011
New Revision: 1199197

URL: http://svn.apache.org/viewvc?rev=1199197&view=rev
Log:
UIMA-2273 updated actions to not remember the document, otherwise it will be 
old document after an input change.

Modified:
    
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/action/DeleteFeatureStructureAction.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.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/fsview/TypeCombo.java
    
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java

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=1199197&r1=1199196&r2=1199197&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
 Tue Nov  8 11:38:37 2011
@@ -1547,7 +1547,7 @@ public final class AnnotationEditor exte
 
     // create delete action
     DeleteFeatureStructureAction deleteAnnotationAction = new 
DeleteFeatureStructureAction(
-            getDocument());
+            this);
     deleteAnnotationAction.setText("Delete Annotation");
     
getSite().getSelectionProvider().addSelectionChangedListener(deleteAnnotationAction);
 
@@ -1569,25 +1569,25 @@ public final class AnnotationEditor exte
     setAction(ITextEditorActionConstants.FIND, findAnnotateAction);
     
     // Lower left side of annotation action
-    LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new 
LowerLeftAnnotationSideAction(getDocument());
+    LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new 
LowerLeftAnnotationSideAction(this);
     
lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID);
     setAction(LowerLeftAnnotationSideAction.ID, lowerLeftAnnotationSideAction);
     
getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction);
     
     // Wide left side of annotation action
-    WideLeftAnnotationSideAction wideLeftAnnotationSide = new 
WideLeftAnnotationSideAction(getDocument());
+    WideLeftAnnotationSideAction wideLeftAnnotationSide = new 
WideLeftAnnotationSideAction(this);
     
wideLeftAnnotationSide.setActionDefinitionId(WideLeftAnnotationSideAction.ID);
     setAction(WideLeftAnnotationSideAction.ID, wideLeftAnnotationSide);
     
getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSide);
     
     // Lower right side of annotation
-    LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new 
LowerRightAnnotationSideAction(getDocument());
+    LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new 
LowerRightAnnotationSideAction(this);
     
lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID);
     setAction(LowerRightAnnotationSideAction.ID, 
lowerRightAnnotationSideAction);
     
getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotationSideAction);
     
     // Wide right side of annotation
-    WideRightAnnotationSideAction wideRightAnnotationSideAction = new 
WideRightAnnotationSideAction(getDocument());
+    WideRightAnnotationSideAction wideRightAnnotationSideAction = new 
WideRightAnnotationSideAction(this);
     
wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID);
     setAction(WideRightAnnotationSideAction.ID, wideRightAnnotationSideAction);
     
getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction);

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
 Tue Nov  8 11:38:37 2011
@@ -21,7 +21,7 @@ package org.apache.uima.caseditor.editor
 
 
 import org.apache.uima.caseditor.editor.FeatureStructureSelection;
-import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
 
@@ -29,17 +29,17 @@ import org.eclipse.ui.actions.BaseSelect
  * Deletes all selected annotations.
  */
 public class DeleteFeatureStructureAction extends BaseSelectionListenerAction {
-  private ICasDocument mDocument;
+  private ICasEditor editor;
 
   /**
    * Initializes the current instance.
    *
    * @param document
    */
-  public DeleteFeatureStructureAction(ICasDocument document) {
+  public DeleteFeatureStructureAction(ICasEditor editor) {
     super("DeleteAction");
 
-    mDocument = document;
+    this.editor = editor;
 
     setEnabled(false);
   }
@@ -61,6 +61,6 @@ public class DeleteFeatureStructureActio
     FeatureStructureSelection featureStructures =
       new FeatureStructureSelection(getStructuredSelection());
 
-    mDocument.removeFeatureStructures(featureStructures.toList());
+    editor.getDocument().removeFeatureStructures(featureStructures.toList());
   }
 }
\ No newline at end of file

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
 Tue Nov  8 11:38:37 2011
@@ -24,6 +24,7 @@ import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
 import org.apache.uima.caseditor.editor.util.AnnotationSelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -35,7 +36,7 @@ public final class LowerLeftAnnotationSi
   
   public static final String ID = "LowerLeftAnnotationSide";
   
-  private ICasDocument mDocument;
+  private ICasEditor editor;
 
   /**
    * Initializes a new instance.
@@ -43,10 +44,10 @@ public final class LowerLeftAnnotationSi
    * @param document
    *
    */
-  public LowerLeftAnnotationSideAction(ICasDocument document) {
+  public LowerLeftAnnotationSideAction(ICasEditor editor) {
     super("LowerLeftAnnotationSide");
 
-    mDocument = document;
+    this.editor = editor;
 
     setEnabled(false);
   }
@@ -78,6 +79,6 @@ public final class LowerLeftAnnotationSi
 
     AnnotationFS annotation = annotations.getFirst();
 
-    lowerLeftAnnotationSide(mDocument, annotation);
+    lowerLeftAnnotationSide(editor.getDocument(), annotation);
   }
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
 Tue Nov  8 11:38:37 2011
@@ -24,6 +24,7 @@ import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
 import org.apache.uima.caseditor.editor.util.AnnotationSelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -35,17 +36,17 @@ public final class LowerRightAnnotationS
   
   public static final String ID = "LowerRightAnnotationSide";
   
-  private ICasDocument mDocument;
+  private ICasEditor editor;
 
   /**
    * Initializes the current instance.
    *
    * @param document
    */
-  public LowerRightAnnotationSideAction(ICasDocument document) {
+  public LowerRightAnnotationSideAction(ICasEditor editor) {
     super("LowerRightAnnotationSide");
 
-    mDocument = document;
+    this.editor = editor;
 
     setEnabled(false);
   }
@@ -78,6 +79,6 @@ public final class LowerRightAnnotationS
 
     AnnotationFS annotation = annotations.getFirst();
 
-    lowerRightAnnotationSide(mDocument, annotation);
+    lowerRightAnnotationSide(editor.getDocument(), annotation);
   }
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
 Tue Nov  8 11:38:37 2011
@@ -23,6 +23,7 @@ package org.apache.uima.caseditor.editor
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
 import org.apache.uima.caseditor.editor.util.AnnotationSelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -34,17 +35,17 @@ import org.eclipse.ui.actions.BaseSelect
  * in conflict case do nothing
  */
 public class MergeAnnotationAction extends BaseSelectionListenerAction {
-  private ICasDocument mDocument;
+  private ICasEditor editor;
 
   /**
    * Initializes the current instance.
    *
    * @param document
    */
-  public MergeAnnotationAction(ICasDocument document) {
+  public MergeAnnotationAction(ICasEditor editor) {
     super("MergeAnnotationAction");
-
-    mDocument = document;
+    
+    this.editor = editor;
 
     setEnabled(false);
   }
@@ -63,12 +64,14 @@ public class MergeAnnotationAction exten
   public void run() {
     AnnotationSelection annotations = new 
AnnotationSelection(getStructuredSelection());
 
-    CAS documentCAS = mDocument.getCAS();
+    ICasDocument document = editor.getDocument();
+    
+    CAS documentCAS = document.getCAS();
 
     AnnotationFS mergedAnnotation = 
documentCAS.createAnnotation(annotations.getFirst().getType(),
             annotations.getFirst().getBegin(), annotations.getLast().getEnd());
 
-    mDocument.removeFeatureStructures(annotations.toList());
-    mDocument.addFeatureStructure(mergedAnnotation);
+    document.removeFeatureStructures(annotations.toList());
+    document.addFeatureStructure(mergedAnnotation);
   }
 }
\ No newline at end of file

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
 Tue Nov  8 11:38:37 2011
@@ -24,6 +24,7 @@ import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
 import org.apache.uima.caseditor.editor.util.AnnotationSelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -35,17 +36,17 @@ public final class WideLeftAnnotationSid
   
   public static final String ID = "WideLeftAnnotationSide";
   
-  private ICasDocument mDocument;
+  private ICasEditor editor;
 
   /**
    * Initializes a new instance.
    *
    * @param document
    */
-  public WideLeftAnnotationSideAction(ICasDocument document) {
+  public WideLeftAnnotationSideAction(ICasEditor editor) {
     super("WideLeftAnnotationSside");
 
-    mDocument = document;
+    this.editor = editor;
 
     setEnabled(false);
   }
@@ -84,6 +85,6 @@ public final class WideLeftAnnotationSid
 
     AnnotationFS annotation = annotations.getFirst();
     
-    wideLeftAnnotationSide(mDocument, annotation);
+    wideLeftAnnotationSide(editor.getDocument(), annotation);
   }
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
 Tue Nov  8 11:38:37 2011
@@ -24,6 +24,7 @@ import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.editor.ICasDocument;
+import org.apache.uima.caseditor.editor.ICasEditor;
 import org.apache.uima.caseditor.editor.util.AnnotationSelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -35,17 +36,17 @@ public final class WideRightAnnotationSi
   
   public static final String ID = "WideRightAnnotationSide";
   
-  private ICasDocument mDocument;
+  private ICasEditor editor;
 
   /**
    * Initializes a new instance.
    *
    * @param document
    */
-  public WideRightAnnotationSideAction(ICasDocument document) {
+  public WideRightAnnotationSideAction(ICasEditor editor) {
     super("WideRightAnnotationSide");
 
-    mDocument = document;
+    this.editor = editor;
 
     setEnabled(false);
   }
@@ -77,6 +78,6 @@ public final class WideRightAnnotationSi
 
     AnnotationFS annotation = annotations.getFirst();
 
-    wideRightAnnotationSide(mDocument, annotation);
+    wideRightAnnotationSide(editor.getDocument(), annotation);
   }
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
 Tue Nov  8 11:38:37 2011
@@ -167,8 +167,9 @@ public class CreateFeatureStructureDialo
       Label typeLabel = new Label(typePanel, SWT.NONE);
       typeLabel.setText("Type: ");
       
-      typeSelection = new TypeCombo(typePanel, superType, typeSystem, 
filterTypes);
-
+      typeSelection = new TypeCombo(typePanel);
+      typeSelection.setInput(superType, typeSystem, filterTypes);
+      
       selectedType = typeSelection.getType();
 
       // maybe consider to show the type of the array and disable the selector

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=1199197&r1=1199196&r2=1199197&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
 Tue Nov  8 11:38:37 2011
@@ -65,14 +65,12 @@ import org.eclipse.ui.part.Page;
 /**
  * The actual view page which contains the ui code for this view.
  */
-public final class FeatureStructureBrowserViewPage extends Page {
+public final class FeatureStructureBrowserViewPage extends Page implements 
ICasEditorInputListener {
 
   private static final String LAST_SELECTED_FS_TYPE = 
"lastSelectedFeatureStructureBrowserViewType";
 
   final class FeatureStructureTreeContentProvider extends 
AbstractAnnotationDocumentListener
-          implements ITreeContentProvider , ICasEditorInputListener {
-
-    private ICasDocument mDocument;
+          implements ITreeContentProvider, ICasEditorInputListener {
 
     private Type mCurrentType;
 
@@ -80,7 +78,6 @@ public final class FeatureStructureBrows
 
     FeatureStructureTreeContentProvider(ICasEditor editor) {
       mEditor = editor;
-      mDocument = editor.getDocument();
       mEditor.addCasEditorInputListener(this);
     }
 
@@ -91,13 +88,15 @@ public final class FeatureStructureBrows
 
       StrictTypeConstraint typeConstrain = new 
StrictTypeConstraint(mCurrentType);
 
-      FSIterator<FeatureStructure> strictTypeIterator = 
mDocument.getCAS().createFilteredIterator(
-              
mDocument.getCAS().getIndexRepository().getAllIndexedFS(mCurrentType), 
typeConstrain);
+      ICasDocument document = mEditor.getDocument();
+      
+      FSIterator<FeatureStructure> strictTypeIterator = 
document.getCAS().createFilteredIterator(
+              
document.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(document, 
strictTypeIterator.next()));
       }
 
       ModelFeatureStructure[] featureStructureArray = new 
ModelFeatureStructure[featureStrucutreList
@@ -109,14 +108,14 @@ public final class FeatureStructureBrows
     }
 
     public void dispose() {
-      mDocument.removeChangeListener(this);
+      mEditor.getDocument().removeChangeListener(this);
       mEditor.removeCasEditorInputListener(this);
     }
 
     public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
 
       if (oldInput != null) {
-        mDocument.removeChangeListener(this);
+        mEditor.getDocument().removeChangeListener(this);
       }
 
       if (newInput == null) {
@@ -127,7 +126,7 @@ public final class FeatureStructureBrows
 
       mCurrentType = (Type) newInput;
 
-      mDocument.addChangeListener(this);
+      mEditor.getDocument().addChangeListener(this);
 
       Display.getDefault().syncExec(new Runnable() {
         public void run() {
@@ -162,7 +161,7 @@ public final class FeatureStructureBrows
       Type type = featureStructure.getType();
 
       for (Feature feature : type.getFeatures()) {
-        childs.add(new FeatureValue(mDocument, featureStructure, feature));
+        childs.add(new FeatureValue(mEditor.getDocument(), featureStructure, 
feature));
       }
 
       assert childs.size() > 0;
@@ -216,7 +215,7 @@ public final class FeatureStructureBrows
 
       for (AnnotationFS annotation : annotations) {
         if (annotation.getType() == mCurrentType) {
-          featureStrucutreList.add(new ModelFeatureStructure(mDocument, 
annotation));
+          featureStrucutreList.add(new 
ModelFeatureStructure(mEditor.getDocument(), annotation));
         }
       }
 
@@ -233,7 +232,7 @@ public final class FeatureStructureBrows
 
       for (FeatureStructure structure : structres) {
         if (structure.getType() == mCurrentType) {
-          featureStrucutreList.add(new ModelFeatureStructure(mDocument, 
structure));
+          featureStrucutreList.add(new 
ModelFeatureStructure(mEditor.getDocument(), structure));
         }
       }
 
@@ -251,7 +250,7 @@ public final class FeatureStructureBrows
 
       for (AnnotationFS annotation : annotations) {
         if (annotation.getType() == mCurrentType) {
-          featureStrucutreList.add(new ModelFeatureStructure(mDocument, 
annotation));
+          featureStrucutreList.add(new 
ModelFeatureStructure(mEditor.getDocument(), annotation));
         }
       }
 
@@ -269,7 +268,7 @@ public final class FeatureStructureBrows
 
       for (FeatureStructure structure : structres) {
         if (structure.getType() == mCurrentType) {
-          featureStrucutreList.add(new ModelFeatureStructure(mDocument, 
structure));
+          featureStrucutreList.add(new 
ModelFeatureStructure(mEditor.getDocument(), structure));
         }
       }
 
@@ -295,11 +294,12 @@ public final class FeatureStructureBrows
 
     public void casDocumentChanged(IEditorInput oldInput, ICasDocument 
oldDocument, 
             IEditorInput newInput, ICasDocument 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);
+      
+      if (oldDocument != null)
+        oldDocument.removeChangeListener(this);
+
+      if (newDocument != null)
+        newDocument.addChangeListener(this);
     }
   }
 
@@ -315,11 +315,11 @@ public final class FeatureStructureBrows
         return;
       }
 
-      FeatureStructure newFeatureStructure = 
mDocument.getCAS().createFS(mCurrentType);
+      FeatureStructure newFeatureStructure = 
mCasEditor.getDocument().getCAS().createFS(mCurrentType);
 
-      mDocument.addFeatureStructure(newFeatureStructure);
+      mCasEditor.getDocument().addFeatureStructure(newFeatureStructure);
 
-      mFSList.refresh();
+      mFSList.refresh(); // TODO: Should not be necessary?
     }
   }
 
@@ -331,10 +331,12 @@ public final class FeatureStructureBrows
     }
   }
 
-  private ICasDocument mDocument;
+//  private ICasDocument mDocument;
 
   private ICasEditor mCasEditor;
 
+  private TypeCombo typeCombo;
+  
   private ListViewer mFSList;
 
   private Composite mInstanceComposite;
@@ -357,15 +359,13 @@ public final class FeatureStructureBrows
     if (editor == null)
       throw new IllegalArgumentException("editor parameter must not be null!");
 
-    mDocument = editor.getDocument();
-
     mCasEditor = editor;
 
-    mDeleteAction = new DeleteFeatureStructureAction(this.mDocument);
+    mDeleteAction = new DeleteFeatureStructureAction(editor);
 
     mSelectAllAction = new SelectAllAction();
 
-    TypeSystem ts = mDocument.getCAS().getTypeSystem();
+    TypeSystem ts = editor.getDocument().getCAS().getTypeSystem();
 
     filterTypes = new HashSet<Type>();
     filterTypes.add(ts.getType(CAS.TYPE_NAME_ARRAY_BASE));
@@ -434,22 +434,18 @@ public final class FeatureStructureBrows
     typeLabelData.horizontalAlignment = SWT.LEFT;
     typeLabel.setLayoutData(typeLabelData);
 
-    TypeCombo typeCombo = new TypeCombo(typePanel, 
mDocument.getCAS().getTypeSystem()
-            .getType(CAS.TYPE_NAME_TOP), mDocument.getCAS().getTypeSystem(), 
filterTypes);
     GridData typeComboData = new GridData();
+    
+    typeCombo = new TypeCombo(typePanel);
+    
     typeComboData.horizontalAlignment = SWT.FILL;
     typeComboData.grabExcessHorizontalSpace = true;
     typeCombo.setLayoutData(typeComboData);
 
+    
     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) {
@@ -479,8 +475,8 @@ public final class FeatureStructureBrows
 
     getSite().setSelectionProvider(mFSList);
     
-    if (lastUsedType != null)
-      mFSList.setInput(lastUsedType);
+    // That call sets the content on the type combo
+    casDocumentChanged(null, null, mCasEditor.getEditorInput(), 
mCasEditor.getDocument());
   }
 
   /**
@@ -538,4 +534,22 @@ public final class FeatureStructureBrows
     mInstanceComposite.setFocus();
   }
 
+  public void casDocumentChanged(IEditorInput oldInput, ICasDocument 
oldDocument,
+          IEditorInput newInput, ICasDocument newDocument) {
+    
+    
typeCombo.setInput(newDocument.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_TOP),
+            newDocument.getCAS().getTypeSystem(), filterTypes);
+    
+    final IPreferenceStore store = 
mCasEditor.getCasDocumentProvider().getSessionPreferenceStore(
+            mCasEditor.getEditorInput());
+    
+    Type lastUsedType = 
newDocument.getType(store.getString(LAST_SELECTED_FS_TYPE));
+
+    if (lastUsedType != null) {
+      typeCombo.select(lastUsedType);
+    }
+    
+    if (lastUsedType != null)
+      mFSList.setInput(lastUsedType);
+  }
 }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java
 Tue Nov  8 11:38:37 2011
@@ -20,6 +20,7 @@
 package org.apache.uima.caseditor.editor.fsview;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -50,16 +51,9 @@ public class TypeCombo extends Composite
   
   private List<String> typeNameList;
   
-  public TypeCombo(Composite parent, Type superType, TypeSystem typeSystem) {
-    this(parent, superType, typeSystem, new LinkedList<Type>());
-  }
-  
-  public TypeCombo(Composite parent, Type superType, TypeSystem typeSystem,
-          Collection<Type> filterTypes) {
+  public TypeCombo(Composite parent) {
     super(parent, SWT.NONE);
 
-    this.typeSystem = typeSystem;
-
     setLayout(new FillLayout());
 
     typeCombo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
@@ -73,7 +67,12 @@ public class TypeCombo extends Composite
         }
       }
     });
-
+  }
+  
+  public void setInput(Type superType, TypeSystem typeSystem,
+          Collection<Type> filterTypes) {
+    this.typeSystem = typeSystem;
+    
     typeNameList = new LinkedList<String>();
 
     typeNameList.add(superType.getName());
@@ -91,6 +90,10 @@ public class TypeCombo extends Composite
     typeCombo.select(0);
   }
   
+  public void setInput(Type superType, TypeSystem typeSystem) {
+    setInput(superType, typeSystem, Collections.<Type>emptyList());
+  }
+  
   /**
    * Selects the given type or does nothing if the
    * type is not listed.
@@ -105,6 +108,12 @@ public class TypeCombo extends Composite
     }
   }
   
+  /**
+   * Retrieves the selected type. Behavior is undefined when called
+   * before setInput.
+   * 
+   * @return
+   */
   public Type getType() {
     return typeSystem.getType(typeCombo.getText());
   }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java?rev=1199197&r1=1199196&r2=1199197&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
 Tue Nov  8 11:38:37 2011
@@ -197,8 +197,7 @@ public final class AnnotationOutline ext
    */
   @Override
   public void setActionBars(IActionBars actionBars) {
-    DeleteFeatureStructureAction deleteAction = new 
DeleteFeatureStructureAction(editor
-            .getDocument());
+    DeleteFeatureStructureAction deleteAction = new 
DeleteFeatureStructureAction(editor);
 
     actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), 
deleteAction);
 
@@ -215,7 +214,7 @@ public final class AnnotationOutline ext
     
     // wide left annotation side action
     WideLeftAnnotationSideAction wideLeftAnnotationSideAction = new 
WideLeftAnnotationSideAction(
-            editor.getDocument());
+            editor);
     
wideLeftAnnotationSideAction.setActionDefinitionId(WideLeftAnnotationSideAction.ID);
     wideLeftAnnotationSideAction.setText("Wides the left annotation side");
     wideLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
@@ -227,7 +226,7 @@ public final class AnnotationOutline ext
 
     // lower left annotation side action
     LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new 
LowerLeftAnnotationSideAction(
-            editor.getDocument());
+            editor);
     
lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID);
     lowerLeftAnnotationSideAction.setText("Lowers the left annotation side");
     lowerLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
@@ -239,7 +238,7 @@ public final class AnnotationOutline ext
 
     // lower right annotation side action
     LowerRightAnnotationSideAction lowerRightAnnotationSideAction =
-      new LowerRightAnnotationSideAction(editor.getDocument());
+      new LowerRightAnnotationSideAction(editor);
     
lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID);
     lowerRightAnnotationSideAction.setText("Lowers the right annotation side");
     lowerRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
@@ -251,7 +250,7 @@ public final class AnnotationOutline ext
 
     // wide right annotation side action
     WideRightAnnotationSideAction wideRightAnnotationSideAction = new 
WideRightAnnotationSideAction(
-            editor.getDocument());
+            editor);
     
wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID);
     wideRightAnnotationSideAction.setText("Wides the right annotation side");
     wideRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
@@ -262,7 +261,7 @@ public final class AnnotationOutline ext
     toolBarManager.add(wideRightAnnotationSideAction);
 
     // merge action
-    MergeAnnotationAction mergeAction = new 
MergeAnnotationAction(editor.getDocument());
+    MergeAnnotationAction mergeAction = new MergeAnnotationAction(editor);
     getSite().getSelectionProvider().addSelectionChangedListener(mergeAction);
     
mergeAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.MERGE));
 


Reply via email to