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/12/01 16:53:23 UTC

svn commit: r1209125 - in /incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect: SentenceContentProvider.java SentenceDetectorView.java SentenceDetectorViewPage.java

Author: joern
Date: Thu Dec  1 15:53:21 2011
New Revision: 1209125

URL: http://svn.apache.org/viewvc?rev=1209125&view=rev
Log:
OPENNLP-408 Now only updates selection when sentence detector view is active.

Modified:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.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/sentdetect/SentenceContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java?rev=1209125&r1=1209124&r2=1209125&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java Thu Dec  1 15:53:21 2011
@@ -125,19 +125,22 @@ public class SentenceContentProvider imp
                 }
               }
               
-              int newSelectionIndex = -1;
-              
-              if (sentenceTable.getSelectionIndex() == -1 && sentenceTable.getItemCount() > 0) {
-                newSelectionIndex = 0;
-              }
-              
-              if (selectionIndex < sentenceTable.getItemCount()) {
-                newSelectionIndex = selectionIndex;
-              }
-              
-              if (newSelectionIndex != -1) {
-                SentenceContentProvider.this.sentenceList.setSelection(
-                    new StructuredSelection(SentenceContentProvider.this.sentenceList.getElementAt(selectionIndex)));
+              // is sentence detector view active ?!
+              if (SentenceContentProvider.this.sentenceDetectorView.isActive()) {
+                int newSelectionIndex = -1;
+                
+                if (sentenceTable.getSelectionIndex() == -1 && sentenceTable.getItemCount() > 0) {
+                  newSelectionIndex = 0;
+                }
+                
+                if (selectionIndex < sentenceTable.getItemCount()) {
+                  newSelectionIndex = selectionIndex;
+                }
+                
+                if (newSelectionIndex != -1) {
+                  SentenceContentProvider.this.sentenceList.setSelection(
+                      new StructuredSelection(SentenceContentProvider.this.sentenceList.getElementAt(selectionIndex)));
+                }
               }
             }
             else {

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=1209125&r1=1209124&r2=1209125&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 Dec  1 15:53:21 2011
@@ -17,7 +17,6 @@
 
 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;
@@ -36,7 +35,7 @@ public class SentenceDetectorView extend
 
     if (document != null) {
 
-      SentenceDetectorViewPage page = new SentenceDetectorViewPage(editor);
+      SentenceDetectorViewPage page = new SentenceDetectorViewPage(this, editor);
       initPage(page);
       page.createControl(getPageBook());
 
@@ -51,7 +50,7 @@ public class SentenceDetectorView extend
     ICasDocument document = editor.getDocument();
 
     if (document != null) {
-      return new SentenceDetectorViewPage(editor);
+      return new SentenceDetectorViewPage(this, 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=1209125&r1=1209124&r2=1209125&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 Dec  1 15:53:21 2011
@@ -23,9 +23,7 @@ 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;
@@ -40,7 +38,7 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
 import org.eclipse.ui.part.Page;
 import org.eclipse.ui.part.PageBook;
@@ -58,8 +56,11 @@ public class SentenceDetectorViewPage ex
   private TableViewer sentenceList; 
   
   private SentenceContentProvider contentProvider;
+
+  private SentenceDetectorView sentenceDetectorView;
   
-  public SentenceDetectorViewPage(ICasEditor editor) {
+  public SentenceDetectorViewPage(SentenceDetectorView sentenceDetectorView, ICasEditor editor) {
+    this.sentenceDetectorView = sentenceDetectorView;
     this.editor = editor;
   }
 
@@ -180,4 +181,10 @@ public class SentenceDetectorViewPage ex
     
     // Note: The same mechanism could be used in the name finder view, to change token bounds of an annotation!
   }
+  
+  boolean isActive() {
+    IWorkbenchPart activePart = getSite().getPage().getActivePart();
+    
+    return sentenceDetectorView == activePart;
+  }
 }