You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/11/08 16:00:59 UTC

svn commit: r1199272 - in /uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline: ModeSensitiveContentProvider.java OutlineContentProviderBase.java TypeGroupedContentProvider.java

Author: joern
Date: Tue Nov  8 15:00:58 2011
New Revision: 1199272

URL: http://svn.apache.org/viewvc?rev=1199272&view=rev
Log:
UIMA-2273 Clears the outline if there is incorrect input.

Modified:
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java

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=1199272&r1=1199271&r2=1199272&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 Tue Nov  8 15:00:58 2011
@@ -99,12 +99,17 @@ class ModeSensitiveContentProvider exten
 
   public void changed() {
 
+    if (mInputDocument != null) {
     Collection<AnnotationFS> annotations = mEditor.getDocument().getAnnotations(
             mEditor.getAnnotationMode());
 
     mAnnotationNodeList = annotations != null ? new AnnotationTreeNodeList(mEditor.getDocument(),
             annotations) : null;
-
+    }
+    else {
+      mAnnotationNodeList = null;
+    }
+    
     Display.getDefault().syncExec(new Runnable() {
       public void run() {
         viewer.refresh();

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=1199272&r1=1199271&r2=1199272&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 Tue Nov  8 15:00:58 2011
@@ -74,9 +74,14 @@ abstract class OutlineContentProviderBas
       ((ICasDocument) newInput).addChangeListener(this);
 
       mInputDocument = (ICasDocument) newInput;
-
-      changed();
     }
+    else {
+      mInputDocument = null;
+    }
+    
+    // Also called when input document is null,
+    // case must be handled
+    changed();
   }
 
   /**

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java?rev=1199272&r1=1199271&r2=1199272&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java Tue Nov  8 15:00:58 2011
@@ -150,36 +150,38 @@ public class TypeGroupedContentProvider 
 	public void changed() {
 		nameAnnotationTypeNodeMap.clear();
 		
-		TypeSystem typeSystem = mInputDocument.getCAS().getTypeSystem();
-		
-		List<Type> types = typeSystem.getProperlySubsumedTypes(
-				typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
-		
-		types.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
-		
-		for (Type type : types) {
-			
-			AnnotationTypeTreeNode typeNode = new AnnotationTypeTreeNode(type);
-			
-			nameAnnotationTypeNodeMap.put(type.getName(), typeNode);
-			
-			CAS cas = mInputDocument.getCAS();
-			
-			AnnotationIndex<AnnotationFS> index = cas.getAnnotationIndex(type);
-			
-			for (FSIterator<AnnotationFS> it = index.iterator(); it.hasNext(); ) {
-				AnnotationFS annotation = it.next();
-				
-				if (annotation.getType().equals(type)) {
-				  typeNode.add(new AnnotationTreeNode(mInputDocument, annotation));
-				}
-			}
+		if (mInputDocument != null) {
+  		TypeSystem typeSystem = mInputDocument.getCAS().getTypeSystem();
+  		
+  		List<Type> types = typeSystem.getProperlySubsumedTypes(
+  				typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
+  		
+  		types.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
+  		
+  		for (Type type : types) {
+  			
+  			AnnotationTypeTreeNode typeNode = new AnnotationTypeTreeNode(type);
+  			
+  			nameAnnotationTypeNodeMap.put(type.getName(), typeNode);
+  			
+  			CAS cas = mInputDocument.getCAS();
+  			
+  			AnnotationIndex<AnnotationFS> index = cas.getAnnotationIndex(type);
+  			
+  			for (FSIterator<AnnotationFS> it = index.iterator(); it.hasNext(); ) {
+  				AnnotationFS annotation = it.next();
+  				
+  				if (annotation.getType().equals(type)) {
+  				  typeNode.add(new AnnotationTreeNode(mInputDocument, annotation));
+  				}
+  			}
+  		}
 		}
-
-      Display.getDefault().syncExec(new Runnable() {
-        public void run() {
-        	viewer.refresh();
-        }
-      });
+		
+    Display.getDefault().syncExec(new Runnable() {
+      public void run() {
+      	viewer.refresh();
+      }
+    });
 	}
 }