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/01 17:01:11 UTC

svn commit: r1196073 - in /incubator/opennlp/sandbox/caseditor-corpus-server-plugin: ./ src/main/java/org/apache/opennlp/corpus_server/caseditor/

Author: joern
Date: Tue Nov  1 16:01:10 2011
New Revision: 1196073

URL: http://svn.apache.org/viewvc?rev=1196073&view=rev
Log:
OPENNLP-346 Now remembers last used server. Renamed Activator to CorpusServerPlugin.

Added:
    incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPlugin.java   (contents, props changed)
      - copied, changed from r1195457, incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/Activator.java
    incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPreferenceConstants.java   (with props)
Removed:
    incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/Activator.java
Modified:
    incubator/opennlp/sandbox/caseditor-corpus-server-plugin/pom.xml
    incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java
    incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/DefaultCasDocumentProvider.java

Modified: incubator/opennlp/sandbox/caseditor-corpus-server-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-corpus-server-plugin/pom.xml?rev=1196073&r1=1196072&r2=1196073&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-corpus-server-plugin/pom.xml (original)
+++ incubator/opennlp/sandbox/caseditor-corpus-server-plugin/pom.xml Tue Nov  1 16:01:10 2011
@@ -209,7 +209,7 @@
 							<manifestLocation>META-INF/</manifestLocation>
 							<instructions>
 								<Bundle-SymbolicName>org.apache.opennlp.corpus_server.caseditor.CorpusServerPlugin;singleton:=true</Bundle-SymbolicName>
-								<Bundle-Activator>org.apache.opennlp.corpus_server.caseditor.Activator</Bundle-Activator>
+								<Bundle-Activator>org.apache.opennlp.corpus_server.caseditor.CorpusServerPlugin</Bundle-Activator>
 								<Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
 								<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
 								<Export-Package>

Modified: incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java?rev=1196073&r1=1196072&r2=1196073&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java (original)
+++ incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusExplorerView.java Tue Nov  1 16:01:10 2011
@@ -22,6 +22,7 @@ import javax.ws.rs.core.MediaType;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.IOpenListener;
 import org.eclipse.jface.viewers.ITableLabelProvider;
@@ -29,6 +30,8 @@ import org.eclipse.jface.viewers.OpenEve
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Image;
@@ -70,7 +73,23 @@ public class CorpusExplorerView extends 
     GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
         .applyTo(serverUrl);
 
-    serverUrl.setText("http://localhost:8080/corpus-server/rest/corpora/wikinews");
+    final IPreferenceStore store = CorpusServerPlugin.getDefault().getPreferenceStore();
+    
+    String lastUsedServer = store.getString(CorpusServerPreferenceConstants.LAST_USED_SERVER_ADDRESS);
+    
+    if (lastUsedServer.isEmpty()) {
+      lastUsedServer = "http://localhost:8080/corpus-server/rest/corpora/wikinews";
+    }
+    
+    serverUrl.setText(lastUsedServer);
+    
+    serverUrl.addModifyListener(new ModifyListener() {
+      
+      @Override
+      public void modifyText(ModifyEvent event) {
+        store.setValue(CorpusServerPreferenceConstants.LAST_USED_SERVER_ADDRESS, serverUrl.getText());
+      }
+    });
     
     // Search field to view content of corpus, default initialized to hit
     // everything
@@ -153,31 +172,23 @@ public class CorpusExplorerView extends 
 
       @Override
       public void addListener(ILabelProviderListener arg0) {
-        // TODO Auto-generated method stub
-        
       }
 
       @Override
       public void dispose() {
-        // TODO Auto-generated method stub
-        
       }
 
       @Override
       public boolean isLabelProperty(Object arg0, String arg1) {
-        // TODO Auto-generated method stub
         return false;
       }
 
       @Override
       public void removeListener(ILabelProviderListener arg0) {
-        // TODO Auto-generated method stub
-        
       }
 
       @Override
       public Image getColumnImage(Object arg0, int arg1) {
-        // TODO Auto-generated method stub
         return null;
       }
 
@@ -191,10 +202,6 @@ public class CorpusExplorerView extends 
       @Override
       public void open(OpenEvent event) {
         
-        // open an editor
-        // need an editor input for that
-        // document provider can be choosen based on editor input? or how?
-        
         IWorkbenchPage page = CorpusExplorerView.this.getSite().getPage();
         
         StructuredSelection selection = (StructuredSelection) searchResultViewer.getSelection();

Copied: incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPlugin.java (from r1195457, incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/Activator.java)
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPlugin.java?p2=incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPlugin.java&p1=incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/Activator.java&r1=1195457&r2=1196073&rev=1196073&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/Activator.java (original)
+++ incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPlugin.java Tue Nov  1 16:01:10 2011
@@ -23,15 +23,15 @@ import org.osgi.framework.BundleContext;
 /**
  * The activator class controls the plug-in life cycle
  */
-public class Activator extends AbstractUIPlugin {
+public class CorpusServerPlugin extends AbstractUIPlugin {
 
   // The plug-in ID
   public static final String PLUGIN_ID = "CorpusServerPlugin"; //$NON-NLS-1$
 
   // The shared instance
-  private static Activator plugin;
+  private static CorpusServerPlugin plugin;
 
-  public Activator() {
+  public CorpusServerPlugin() {
   }
 
   public void start(BundleContext context) throws Exception {
@@ -49,7 +49,7 @@ public class Activator extends AbstractU
    * 
    * @return the shared instance
    */
-  public static Activator getDefault() {
+  public static CorpusServerPlugin getDefault() {
     return plugin;
   }
 }

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

Added: incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPreferenceConstants.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPreferenceConstants.java?rev=1196073&view=auto
==============================================================================
--- incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPreferenceConstants.java (added)
+++ incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/CorpusServerPreferenceConstants.java Tue Nov  1 16:01:10 2011
@@ -0,0 +1,22 @@
+/*
+ * 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.corpus_server.caseditor;
+
+public class CorpusServerPreferenceConstants {
+  static final String LAST_USED_SERVER_ADDRESS = CorpusServerPlugin.PLUGIN_ID + ".LAST_USED_SERVER_ADDRESS";
+}

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

Modified: incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/DefaultCasDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/DefaultCasDocumentProvider.java?rev=1196073&r1=1196072&r2=1196073&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/DefaultCasDocumentProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-corpus-server-plugin/src/main/java/org/apache/opennlp/corpus_server/caseditor/DefaultCasDocumentProvider.java Tue Nov  1 16:01:10 2011
@@ -268,7 +268,7 @@ public class DefaultCasDocumentProvider 
     
     if (tsStore == null) {
       
-      IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+      IPreferenceStore store = CorpusServerPlugin.getDefault().getPreferenceStore();
       
       String tsStoreString = store.getString(getTypeSystemId((CorpusServerCasEditorInput) element));
       
@@ -305,7 +305,7 @@ public class DefaultCasDocumentProvider 
         e.printStackTrace();
       }
       
-      IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+      IPreferenceStore store = CorpusServerPlugin.getDefault().getPreferenceStore();
       store.putValue(getTypeSystemId((CorpusServerCasEditorInput) element), 
           new String(tsStoreBytes.toByteArray(), Charset.forName("UTF-8")));
     }