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/10/07 00:33:35 UTC

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

Author: joern
Date: Thu Oct  6 22:33:35 2011
New Revision: 1179888

URL: http://svn.apache.org/viewvc?rev=1179888&view=rev
Log:
OPENNLP-310 Moved action to show preference dialog to an separate action. Added action to sentence detector view tool bar.

Added:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/OpenPreferenceDialog.java   (with props)
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/SentenceDetectorPreferencePage.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java

Added: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/OpenPreferenceDialog.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/OpenPreferenceDialog.java?rev=1179888&view=auto
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/OpenPreferenceDialog.java (added)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/OpenPreferenceDialog.java Thu Oct  6 22:33:35 2011
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.opennlp.caseditor;
+
+import org.apache.opennlp.caseditor.namefinder.NameFinderPreferencePage;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.IPreferencePage;
+import org.eclipse.jface.preference.PreferenceManager;
+import org.eclipse.jface.preference.PreferenceNode;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.internal.dialogs.PropertyDialog;
+
+public class OpenPreferenceDialog extends Action {
+  
+  private Shell shell;
+  private ICasEditor editor;
+
+  public OpenPreferenceDialog(Shell shell, ICasEditor editor) {
+    this.shell = shell;
+    this.editor = editor;
+  }
+  
+  @Override
+  public void run() {
+    super.run();
+    
+    PreferenceManager mgr = new PreferenceManager();
+    
+    IPreferencePage opennlpPage = new OpenNLPPreferencePage();
+    opennlpPage.setTitle("General");
+    mgr.addToRoot(new PreferenceNode("1", opennlpPage));
+    
+    IPreferencePage sentenceDetectorPage = new NameFinderPreferencePage();
+    sentenceDetectorPage.setTitle("Sentence Detector");
+    mgr.addToRoot(new PreferenceNode("1", sentenceDetectorPage));
+    
+    IPreferencePage nameFinderPage = new NameFinderPreferencePage();
+    nameFinderPage.setTitle("Name Finder");
+    mgr.addToRoot(new PreferenceNode("1", nameFinderPage));
+    
+    PropertyDialog dialog = new PropertyDialog(shell, mgr, null);
+    dialog.setPreferenceStore(((AnnotationEditor) editor).
+        getCasDocumentProvider().getTypeSystemPreferenceStore(editor.getEditorInput()));
+    dialog.create();
+    dialog.setMessage(nameFinderPage.getTitle());
+    dialog.open();
+    
+    // TODO: Need to save ts preferences ... or notify listeners about the change!
+  }
+}
\ No newline at end of file

Propchange: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/OpenPreferenceDialog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1179888&r1=1179887&r2=1179888&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 Oct  6 22:33:35 2011
@@ -18,6 +18,7 @@
 package org.apache.opennlp.caseditor.namefinder;
 
 import org.apache.opennlp.caseditor.OpenNLPPreferencePage;
+import org.apache.opennlp.caseditor.OpenPreferenceDialog;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
@@ -193,34 +194,7 @@ class NameFinderViewPage extends Page im
     // Provide the preference store to this dialog
     // Provide a type system to this preference store
     
-    IAction action = new Action() {
-      @Override
-      public void run() {
-        super.run();
-        
-        // TODO: Wire this to the type system preference store
-        
-        PreferenceManager mgr = new PreferenceManager();
-        
-        IPreferencePage opennlpPage = new OpenNLPPreferencePage();
-        opennlpPage.setTitle("OpenNLP");
-        mgr.addToRoot(new PreferenceNode("1", opennlpPage));
-        
-        IPreferencePage nameFinderPage = new NameFinderPreferencePage();
-        nameFinderPage.setTitle("Name Finder");
-        mgr.addToRoot(new PreferenceNode("1", nameFinderPage));
-        
-        
-        PropertyDialog dialog = new PropertyDialog(getSite().getShell(), mgr, null);
-        dialog.setPreferenceStore(((AnnotationEditor) editor).
-            getCasDocumentProvider().getTypeSystemPreferenceStore(editor.getEditorInput()));
-        dialog.create();
-        dialog.setMessage(nameFinderPage.getTitle());
-        dialog.open();
-        
-        // TODO: Need to save ts preferences ... or to announce the change.
-      }
-    };
+    IAction action = new OpenPreferenceDialog(getSite().getShell(), editor);
     
     action.setImageDescriptor(CasEditorPlugin
         .getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java?rev=1179888&r1=1179887&r2=1179888&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java Thu Oct  6 22:33:35 2011
@@ -28,7 +28,6 @@ public class SentenceDetectorPreferenceP
     implements IWorkbenchPreferencePage {
 
   public SentenceDetectorPreferencePage() {
-    setPreferenceStore(OpenNLPPlugin.getDefault().getPreferenceStore());
     setDescription("Sentence Detector Preferences.");
   }
   

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=1179888&r1=1179887&r2=1179888&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 Oct  6 22:33:35 2011
@@ -19,11 +19,15 @@ package org.apache.opennlp.caseditor.sen
 
 import org.apache.opennlp.caseditor.OpenNLPPlugin;
 import org.apache.opennlp.caseditor.OpenNLPPreferenceConstants;
+import org.apache.opennlp.caseditor.OpenPreferenceDialog;
 import org.apache.opennlp.caseditor.namefinder.ConfirmAnnotationAction;
 import org.apache.opennlp.caseditor.namefinder.Entity;
 import org.apache.opennlp.caseditor.namefinder.EntityLabelProvider;
+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.ICasEditor;
+import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -150,6 +154,13 @@ public class SentenceDetectorViewPage ex
     actionBars.setGlobalActionHandler(QUICK_ANNOTATE_ACTION_ID, confirmAction);
     getSite().getSelectionProvider().addSelectionChangedListener(confirmAction); // need also to unregister!!!!
     toolBarManager.add(confirmAction);
+    
+    IAction action = new OpenPreferenceDialog(getSite().getShell(), editor);
+    
+    action.setImageDescriptor(CasEditorPlugin
+        .getTaeImageDescriptor(Images.MODEL_PROCESSOR_FOLDER));
+    
+    toolBarManager.add(action);
   }
     
 }