You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/11/07 14:33:01 UTC

svn commit: r1198730 - in /incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor: namefinder/NameFinderViewPage.java sentdetect/SentenceDetectorViewPage.java

Author: joern
Date: Mon Nov  7 13:33:01 2011
New Revision: 1198730

URL: http://svn.apache.org/viewvc?rev=1198730&view=rev
Log:
OPENNLP-356 Now uses cas editor listener to listen for input changes. If input is changed view is refreshed.

Modified:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java?rev=1198730&r1=1198729&r2=1198730&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java Mon Nov  7 13:33:01 2011
@@ -24,6 +24,7 @@ import org.apache.uima.caseditor.Images;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
 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.util.AnnotationSelection;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
@@ -53,7 +54,7 @@ import org.eclipse.ui.part.PageBook;
 
 // TODO: There should be a way to display error messages in this view, e.g.
 //       when no names are detected. -> give an indication what could be wrong!
-class NameFinderViewPage extends Page implements ISelectionListener {
+class NameFinderViewPage extends Page implements ISelectionListener, ICasEditorInputListener {
 
   private static final String QUICK_ANNOTATE_ACTION_ID = "QuickAnnotate";
   
@@ -69,6 +70,8 @@ class NameFinderViewPage extends Page im
     
     IPreferenceStore store = editor.getCasDocumentProvider().getTypeSystemPreferenceStore(editor.getEditorInput());
     NameFinderPreferenceInitializer.initializeDefaultPreferences(store);
+    
+    editor.addCasEditorInputListener(this);
   }
 
   public void createControl(Composite parent) {
@@ -214,4 +217,15 @@ class NameFinderViewPage extends Page im
     toolBarManager.add(action);
     
   }
+
+  @Override
+  public void dispose() {
+    super.dispose();
+    editor.addCasEditorInputListener(this);
+  }
+  
+  @Override
+  public void casDocumentChanged(ICasDocument oldDoc, ICasDocument newDoc) {
+    entityList.setInput(newDoc);
+  }
 }

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java?rev=1198730&r1=1198729&r2=1198730&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java Mon Nov  7 13:33:01 2011
@@ -23,7 +23,9 @@ import org.apache.opennlp.caseditor.name
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
+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.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -42,7 +44,7 @@ import org.eclipse.ui.actions.BaseSelect
 import org.eclipse.ui.part.Page;
 import org.eclipse.ui.part.PageBook;
 
-public class SentenceDetectorViewPage extends Page {
+public class SentenceDetectorViewPage extends Page implements ICasEditorInputListener {
   
   private static final String QUICK_ANNOTATE_ACTION_ID = "QuickAnnotate";
 
@@ -58,6 +60,7 @@ public class SentenceDetectorViewPage ex
   
   public SentenceDetectorViewPage(ICasEditor editor) {
     this.editor = editor;
+    editor.addCasEditorInputListener(this);
   }
 
   @Override
@@ -166,6 +169,27 @@ public class SentenceDetectorViewPage ex
         .getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));
     
     toolBarManager.add(action);
+    
+    // TODO: Add an action which can move editor selection to the right based on EOS chars like
+    //       sentence detector would do.
+    
+    // TODO: Write the same action which can move editor selection to the left based on EOS chars
+    //       like the sentence detector would do.
+    
+    // TODO: Confirm action should use selection bounds in the editor!
+    
+    // Note: The same mechanism could be used in the name finder view, to change token bounds of an annotation!
   }
+
+  @Override
+  public void dispose() {
+    super.dispose();
     
+    editor.removeCasEditorInputListener(this);
+  }
+  
+  @Override
+  public void casDocumentChanged(ICasDocument oldDoc, ICasDocument newDoc) {
+    sentenceList.setInput(newDoc);
+  }
 }