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/17 13:23:38 UTC

svn commit: r1203164 - in /incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor: namefinder/ sentdetect/

Author: joern
Date: Thu Nov 17 12:23:37 2011
New Revision: 1203164

URL: http://svn.apache.org/viewvc?rev=1203164&view=rev
Log:
OPENNLP-356 Now uses new CasEditorView as a base which handles input changes by re-creation of the view page.

Modified:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java
    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/SentenceDetectorView.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/NameFinderView.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java?rev=1203164&r1=1203163&r2=1203164&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java Thu Nov 17 12:23:37 2011
@@ -17,11 +17,12 @@
 
 package org.apache.opennlp.caseditor.namefinder;
 
-import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.apache.uima.caseditor.editor.CasEditorView;
 import org.apache.uima.caseditor.editor.ICasDocument;
 import org.apache.uima.caseditor.editor.ICasEditor;
+import org.eclipse.ui.part.IPageBookViewPage;
 
-public class NameFinderView extends AnnotationEditorView {
+public class NameFinderView extends CasEditorView {
 
   public static final String ID = "org.apache.opennlp.caseditor.NameFinderView";
 
@@ -29,21 +30,14 @@ public class NameFinderView extends Anno
     super("The Name Finder View is currently not available.");
   }
 
-  protected PageRec doCreatePage(ICasEditor editor) {
-    PageRec result = null;
-
+  @Override
+  protected IPageBookViewPage doCreatePage(ICasEditor editor) {
     ICasDocument document = editor.getDocument();
 
     if (document != null) {
-
-      NameFinderViewPage page = new NameFinderViewPage(editor, document);
-      initPage(page);
-      page.createControl(getPageBook());
-
-      result = new PageRec(editor, page);
+      return new NameFinderViewPage(editor, document);
     }
 
-    return result;
+    return null;
   }
-
 }

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=1203164&r1=1203163&r2=1203164&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 Thu Nov 17 12:23:37 2011
@@ -55,7 +55,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, ICasEditorInputListener {
+class NameFinderViewPage extends Page implements ISelectionListener {
 
   private static final String QUICK_ANNOTATE_ACTION_ID = "QuickAnnotate";
   
@@ -71,8 +71,6 @@ class NameFinderViewPage extends Page im
     
     IPreferenceStore store = editor.getCasDocumentProvider().getTypeSystemPreferenceStore(editor.getEditorInput());
     NameFinderPreferenceInitializer.initializeDefaultPreferences(store);
-    
-    editor.addCasEditorInputListener(this);
   }
 
   public void createControl(Composite parent) {
@@ -218,16 +216,4 @@ class NameFinderViewPage extends Page im
     toolBarManager.add(action);
     
   }
-
-  @Override
-  public void dispose() {
-    super.dispose();
-    editor.addCasEditorInputListener(this);
-  }
-  
-  @Override
-  public void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDoc,
-      IEditorInput newsInput, ICasDocument newDoc) {
-    entityList.setInput(newDoc);
-  }
 }

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorView.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorView.java?rev=1203164&r1=1203163&r2=1203164&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorView.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorView.java Thu Nov 17 12:23:37 2011
@@ -18,16 +18,18 @@
 package org.apache.opennlp.caseditor.sentdetect;
 
 import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.apache.uima.caseditor.editor.CasEditorView;
 import org.apache.uima.caseditor.editor.ICasDocument;
 import org.apache.uima.caseditor.editor.ICasEditor;
+import org.eclipse.ui.part.IPageBookViewPage;
 
-public class SentenceDetectorView extends AnnotationEditorView {
+public class SentenceDetectorView extends CasEditorView {
 
   public SentenceDetectorView() {
     super("The Sentence Detector View is currently not available.");
   }
 
-  protected PageRec doCreatePage(ICasEditor editor) {
+  protected PageRec doCreatePages(ICasEditor editor) {
     PageRec result = null;
 
     ICasDocument document = editor.getDocument();
@@ -43,4 +45,16 @@ public class SentenceDetectorView extend
 
     return result;
   }
+
+  @Override
+  protected IPageBookViewPage doCreatePage(ICasEditor editor) {
+    ICasDocument document = editor.getDocument();
+
+    if (document != null) {
+      return new SentenceDetectorViewPage(editor);
+    }
+
+    return null;
+  }
+  
 }

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=1203164&r1=1203163&r2=1203164&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 Thu Nov 17 12:23:37 2011
@@ -45,7 +45,7 @@ import org.eclipse.ui.actions.BaseSelect
 import org.eclipse.ui.part.Page;
 import org.eclipse.ui.part.PageBook;
 
-public class SentenceDetectorViewPage extends Page implements ICasEditorInputListener {
+public class SentenceDetectorViewPage extends Page {
   
   private static final String QUICK_ANNOTATE_ACTION_ID = "QuickAnnotate";
 
@@ -61,7 +61,6 @@ public class SentenceDetectorViewPage ex
   
   public SentenceDetectorViewPage(ICasEditor editor) {
     this.editor = editor;
-    editor.addCasEditorInputListener(this);
   }
 
   @Override
@@ -181,17 +180,4 @@ public class SentenceDetectorViewPage ex
     
     // 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(IEditorInput oldInput, ICasDocument oldDoc,
-      IEditorInput newsInput, ICasDocument newDoc) {
-    sentenceList.setInput(newDoc);
-  }
 }