You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/07/24 18:03:46 UTC

svn commit: r559091 - in /incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor: core/model/NlpProject.java editor/AnnotationEditor.java

Author: schor
Date: Tue Jul 24 09:03:45 2007
New Revision: 559091

URL: http://svn.apache.org/viewvc?view=rev&rev=559091
Log:
[UIMA-511] Committed as patched

Modified:
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java?view=diff&rev=559091&r1=559090&r2=559091
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java Tue Jul 24 09:03:45 2007
@@ -6,9 +6,9 @@
  * 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
@@ -21,8 +21,11 @@
 
 import java.util.Collection;
 import java.util.LinkedList;
+import java.util.List;
 
 import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.core.model.delta.INlpElementDelta;
 import org.apache.uima.caseditor.core.model.dotcorpus.EditorAnnotationStatus;
@@ -65,7 +68,7 @@
 
   /**
    * Initializes the current nlp project instance.
-   * 
+   *
    * @param model
    */
   void setNlpModel(NlpModel model) {
@@ -76,7 +79,7 @@
    * Initializes the current instance. This method is called before this instance can be used.
    * Currently it recognizes and loads all nlp resources. Node: This method should only be called
    * during static {@link NlpModel} creation.
-   * 
+   *
    * @throws CoreException
    */
   void initialize() throws CoreException {
@@ -95,33 +98,40 @@
     //}
 
     IFile typeSystemFile = getDotCorpus().getTypeSystemFile();
-    
+
     if (typeSystemFile != null && typeSystemFile.exists()) {
       mTypesystem = new TypesystemElement(typeSystemFile, this);
     }
 
     if (getTypesystemElement() != null && getTypesystemElement().getTypeSystem() != null) {
-      mEditorAnnotationStatus = new EditorAnnotationStatus(getTypesystemElement().getTypeSystem()
-              .getType(CAS.TYPE_NAME_ANNOTATION), null);
+
+      TypeSystem typeSystem = getTypesystemElement().getTypeSystem();
+
+      Type annotationType = typeSystem.getType(CAS.TYPE_NAME_ANNOTATION);
+
+      List<Type> displayTypes = typeSystem.getProperlySubsumedTypes(annotationType);
+
+      mEditorAnnotationStatus = new EditorAnnotationStatus(
+              annotationType, displayTypes);
     }
   }
 
   /**
-   * Retrvies the name.
+   * Retrieves the name.
    */
   public String getName() {
     return mProject.getName();
   }
 
   /**
-   * Retrives the resource.
+   * Retrieves the resource.
    */
   public IResource getResource() {
     return getProject();
   }
 
   /**
-   * Retrives the parent element {@link NlpModel}.
+   * Retrieves the parent element {@link NlpModel}.
    */
   public INlpElement getParent() {
     return mModel;
@@ -142,7 +152,7 @@
   }
 
   /**
-   * Retrives the {@link IProject}.
+   * Retrieves the {@link IProject}.
    */
   public IProject getProject() {
     return mProject;
@@ -156,8 +166,8 @@
   }
 
   /**
-   * Retrives the {@link EditorAnnotationStatus} for the current project instance.
-   * 
+   * Retrieves the {@link EditorAnnotationStatus} for the current project instance.
+   *
    * @return status
    */
   public EditorAnnotationStatus getEditorAnnotationStatus() {
@@ -166,7 +176,7 @@
 
   /**
    * Sets the {@link EditorAnnotationStatus} for the current project instance.
-   * 
+   *
    * @param status
    */
   public void setEditorAnnotationStatus(EditorAnnotationStatus status) {
@@ -186,7 +196,7 @@
 
   /**
    * Retrives the corporas.
-   * 
+   *
    * @return the corpus collection
    */
   public Collection<CorpusElement> getCorpora() {
@@ -205,7 +215,7 @@
 
   /**
    * Retrives all non-nlp resources of the current instance.
-   * 
+   *
    * @return the resources
    * @throws CoreException
    */
@@ -225,7 +235,7 @@
         if (mDotCorpusElement.isCorpusFolder((IFolder) element)) {
           continue;
         }
-        
+
         if (mDotCorpusElement.isCasProcessorFolder((IFolder) element)) {
           continue;
         }
@@ -256,7 +266,7 @@
           return this;
         }
       }
-      
+
       if (mTypesystem != null) {
     	  if (mTypesystem.getResource().equals(resource)) {
     		  return this;
@@ -303,7 +313,7 @@
       else if (mTypesystem != null && mTypesystem.findMember(resource) != null) {
     	  return mTypesystem.findMember(resource);
       }
-      
+
       for (CasProcessorFolder sourceFolder : getCasProcessorFolders()) {
         boolean isElementFound = sourceFolder.findMember(resource) != null;
 
@@ -326,7 +336,7 @@
 
   /**
    * Retrives the UimaSourceFolder
-   * 
+   *
    * @return the UimaSourceFolder
    */
   public Collection<CasProcessorFolder> getCasProcessorFolders() {
@@ -336,7 +346,7 @@
   private void createCasProcessorFolders() throws CoreException {
     for (IFolder processorFolder : mDotCorpusElement.getCasProcessorFolders()) {
       if (processorFolder.exists()) {
-        CasProcessorFolder processorElement = 
+        CasProcessorFolder processorElement =
             new CasProcessorFolder(processorFolder, this);
 
         mUimaSourceFolder.add(processorElement);
@@ -346,7 +356,7 @@
 
   /**
    * Retrives the {@link DotCorpusElement}.
-   * 
+   *
    * @return the {@link DotCorpusElement}
    */
   public DotCorpusElement getDotCorpus() {
@@ -437,7 +447,7 @@
 
     if (mTypesystem != null && resource.equals(mTypesystem.getResource())) {
       mTypesystem.changedResource(resource, delta);
-      
+
       if (getTypesystemElement().getTypeSystem() != null) {
           mEditorAnnotationStatus = new EditorAnnotationStatus(getTypesystemElement().getTypeSystem()
                   .getType(CAS.TYPE_NAME_ANNOTATION), null);
@@ -491,10 +501,10 @@
 
   /**
    * Adds a NLP nature to a project.
-   * 
+   *
    * @param project -
    *          the project to add the nature
-   * 
+   *
    * @throws CoreException
    */
   public static void addNLPNature(IProject project) throws CoreException {
@@ -509,7 +519,7 @@
 
   /**
    * Retrives the typesystem.
-   * 
+   *
    * @return typesystem
    */
   public TypesystemElement getTypesystemElement() {

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java?view=diff&rev=559091&r1=559090&r2=559091
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java Tue Jul 24 09:03:45 2007
@@ -192,7 +192,7 @@
       // to avoid this behavior this action is reposted
       // to the END of the ui thread queue
 
-      // this does not happen if for the action is no key explict
+      // this does not happen if for the action is no key explicit
       // configured with setActivationKey(...)
 
       // TODO:
@@ -292,7 +292,7 @@
 
       Menu newSubMenu;
 
-      // has this type subtypes ?
+      // has this type sub types ?
       // yes
       if (childs.size() != 0) {
         MenuItem subMenuItem = new MenuItem(parentMenu, SWT.CASCADE);
@@ -352,11 +352,17 @@
   }
 
   /**
-   * Creates the show annotations context submenu.
+   * Creates the show annotations context sub menu.
    */
   private class ShowAnnotationsMenu extends TypeMenu {
 
-    private Collection<Type> mTypesToDisplay = new HashSet<Type>();
+    /**
+     * This collection contains all type names which are displayed in
+     * the editor.
+     */
+    private Collection<String> mTypesToDisplay = new HashSet<String>();
+
+    private final TypeSystem typeSystem;
 
     /**
      * Initializes a new instance.
@@ -367,7 +373,14 @@
     ShowAnnotationsMenu(EditorAnnotationStatus status, TypeSystem typeSystem) {
       super(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION), typeSystem);
 
-      mTypesToDisplay.addAll(status.getDisplayAnnotations());
+      this.typeSystem = typeSystem;
+
+      Collection<Type> displayAnnotations = status.getDisplayAnnotations();
+
+      for (Type type : displayAnnotations) {
+        mTypesToDisplay.add(type.getName());
+      }
+
     }
 
     @Override
@@ -375,7 +388,7 @@
       final MenuItem actionItem = new MenuItem(parentMenu, SWT.CHECK);
       actionItem.setText(type.getShortName());
 
-      if (mTypesToDisplay.contains(type)) {
+      if (mTypesToDisplay.contains(type.getName())) {
         actionItem.setSelection(true);
       }
 
@@ -384,14 +397,14 @@
       actionItem.addListener(SWT.Selection, new Listener() {
         public void handleEvent(Event e) {
           if (actionItem.getSelection()) {
-            mTypesToDisplay.add(type);
+            mTypesToDisplay.add(type.getName());
 
           } else {
-            mTypesToDisplay.remove(type);
+            mTypesToDisplay.remove(type.getName());
           }
 
           // TODO: only synchronize annotation which
-          // must be removed/addeded
+          // must be removed/added
           syncAnnotations();
 
           EditorAnnotationStatus status = mDocument.getProject().getEditorAnnotationStatus();
@@ -403,12 +416,21 @@
     }
 
     Collection<Type> getSelectedTypes() {
-    	return Collections.unmodifiableCollection(mTypesToDisplay);
+      Collection<Type> selectedTypes = new LinkedList<Type>();
+
+      for (String typeName : mTypesToDisplay) {
+        selectedTypes.add(typeSystem.getType(typeName));
+      }
+
+    	return Collections.unmodifiableCollection(selectedTypes);
     }
 
     void setSelectedTypes(Collection<Type> types) {
-      mTypesToDisplay = new HashSet<Type>();
-      mTypesToDisplay.addAll(types);
+      mTypesToDisplay = new HashSet<String>();
+
+      for (Type type : types) {
+        mTypesToDisplay.add(type.getName());
+      }
     }
   }