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 2013/05/06 12:40:16 UTC

svn commit: r1479513 - /uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java

Author: joern
Date: Mon May  6 10:38:24 2013
New Revision: 1479513

URL: http://svn.apache.org/r1479513
Log:
UIMA-2872 Fixed the logic to retrieve the annotation mode type from the settings during initialization. If the annotation mode type can't be retrieved it now reliably uses the default uima.tcas.Annotation type.

Modified:
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.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=1479513&r1=1479512&r2=1479513&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 Mon May  6 10:38:24 2013
@@ -963,12 +963,18 @@ public final class AnnotationEditor exte
       
       // TODO: Define constants for these settings!
       
-      String lastModeTypeName = sessionPreferences.getString("LastUsedModeType");
+      Type annotationModeType = getDocument().getType(
+          sessionPreferences.getString("LastUsedModeType"));
       
-      if (lastModeTypeName.length() == 0)
-        lastModeTypeName = CAS.TYPE_NAME_ANNOTATION;
+      // Note: The type in the configuration might not exist anymore, or there is
+      // no type stored yet, in these cases the built-in uima.tcas.Annotation type is used.
+      // Not setting the annotation type will cause NPEs after the editor opened.
       
-      setAnnotationMode(getDocument().getType(lastModeTypeName));
+      if (annotationModeType == null) {
+    	  annotationModeType = getDocument().getType(CAS.TYPE_NAME_ANNOTATION);
+      }
+      
+      setAnnotationMode(annotationModeType);
       
       String lastActiveViewName = sessionPreferences.getString("LastActiveCasViewName");
       
@@ -1071,6 +1077,10 @@ public final class AnnotationEditor exte
   protected void setAnnotationMode(Type type) {
     // TODO: check if this type is a subtype of Annotation
 
+    if (type == null) {
+      throw new IllegalArgumentException("type must not be null!");
+    }
+
     mAnnotationMode = type;
 
     highlight(0, 0);