JAL-1620 version bump and release notes
[jalview.git] / src / jalview / gui / WsPreferences.java
index cffb1d8..d92cddb 100644 (file)
@@ -1,24 +1,28 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
+ * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.gui;
 
 import jalview.bin.Cache;
 import jalview.jbgui.GWsPreferences;
+import jalview.util.MessageManager;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.rest.RestServiceDescription;
 
@@ -29,6 +33,7 @@ import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.net.URL;
+import java.util.List;
 import java.util.Vector;
 
 import javax.swing.JLabel;
@@ -48,7 +53,9 @@ public class WsPreferences extends GWsPreferences
     initFromPreferences();
   }
 
-  Vector<String> wsUrls, oldUrls, rsbsUrls, oldRsbsUrls;
+  List<String> wsUrls;
+
+  Vector<String> oldUrls, rsbsUrls, oldRsbsUrls;
 
   private boolean needWsMenuUpdate;
 
@@ -58,8 +65,8 @@ public class WsPreferences extends GWsPreferences
   private void initFromPreferences()
   {
 
-    wsUrls = jalview.ws.jws2.Jws2Discoverer.getServiceUrls();
-    if (wsUrls != null)
+    wsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
+    if (!wsUrls.isEmpty())
     {
       oldUrls = new Vector<String>(wsUrls);
     }
@@ -121,7 +128,7 @@ public class WsPreferences extends GWsPreferences
     }
 
     wsList.setModel(new WsUrlTableModel(tdat));
-    wsList.getColumn("Status").setMinWidth(10);
+    wsList.getColumn(MessageManager.getString("label.status")).setMinWidth(10);
   }
 
   private class JabaWSStatusRenderer extends JPanel implements
@@ -180,6 +187,8 @@ public class WsPreferences extends GWsPreferences
   {
 
     private Object[][] data;
+    private String[] columnNames = new String[]
+    { MessageManager.getString("label.service_url"), MessageManager.getString("label.status") };
 
     public WsUrlTableModel(Object[][] tdat)
     {
@@ -195,11 +204,7 @@ public class WsPreferences extends GWsPreferences
     @Override
     public String getColumnName(int column)
     {
-      if (column == 1)
-      {
-        return "Status";
-      }
-      return "Service URL";
+        return columnNames[column];
     }
 
     @Override
@@ -233,7 +238,7 @@ public class WsPreferences extends GWsPreferences
 
   private void updateServiceList()
   {
-    jalview.ws.jws2.Jws2Discoverer.setServiceUrls(wsUrls);
+    Jws2Discoverer.getDiscoverer().setServiceUrls(wsUrls);
   }
 
   private void updateRsbsServiceList()
@@ -254,7 +259,7 @@ public class WsPreferences extends GWsPreferences
     int sel = wsList.getSelectedRow();
     if (sel > -1)
     {
-      wsUrls.removeElementAt(sel);
+      wsUrls.remove(sel);
       update++;
       updateList();
     }
@@ -272,21 +277,22 @@ public class WsPreferences extends GWsPreferences
     int sel = wsList.getSelectedRow();
     if (sel > -1)
     {
-      String url = editUrl(wsUrls.elementAt(sel), "Edit JABAWS URL");
+      String url = editUrl(wsUrls.get(sel),
+              MessageManager.getString("label.edit_jabaws_url"));
       if (url != null)
       {
         int present = wsUrls.indexOf(url);
         if (present == -1)
         {
           update++;
-          wsUrls.setElementAt(url, sel);
+          wsUrls.set(sel, url);
           updateList();
         }
         else
         {
           if (present != sel)
           {
-            wsUrls.removeElementAt(sel);
+            wsUrls.remove(sel);
             updateList();
           }
         }
@@ -298,7 +304,7 @@ public class WsPreferences extends GWsPreferences
   protected void newSbrsUrl_actionPerformed(ActionEvent e)
   {
     RestServiceEditorPane rse = new RestServiceEditorPane();
-    rse.showDialog("Add a new Simple Bioinformatics Rest Service");
+    rse.showDialog(MessageManager.getString("label.add_new_sbrs_service"));
     String rservice = rse.getEditedRestService();
     if (rservice != null && !rsbsUrls.contains(rservice))
     {
@@ -316,7 +322,7 @@ public class WsPreferences extends GWsPreferences
     {
       RestServiceEditorPane rse = new RestServiceEditorPane(
               new RestServiceDescription(rsbsUrls.elementAt(sel)));
-      rse.showDialog("Edit Simple Bioinformatics Rest Service entry");
+      rse.showDialog(MessageManager.getString("label.edit_sbrs_entry"));
       String rservice = rse.getEditedRestService();
       if (rservice != null)
       {
@@ -404,8 +410,8 @@ public class WsPreferences extends GWsPreferences
     if (p > -1 && p < wsUrls.size() - 1)
     {
       String t = wsUrls.get(p + 1);
-      wsUrls.setElementAt(wsUrls.elementAt(p), p + 1);
-      wsUrls.setElementAt(t, p);
+      wsUrls.set(p + 1, wsUrls.get(p));
+      wsUrls.set(p, t);
       updateList();
       wsList.getSelectionModel().setSelectionInterval(p + 1, p + 1);
       update++;
@@ -426,8 +432,8 @@ public class WsPreferences extends GWsPreferences
     if (p > 0)
     {
       String t = wsUrls.get(p - 1);
-      wsUrls.setElementAt(wsUrls.elementAt(p), p - 1);
-      wsUrls.setElementAt(t, p);
+      wsUrls.set(p - 1, wsUrls.get(p));
+      wsUrls.set(p, t);
       updateList();
       wsList.getSelectionModel().setSelectionInterval(p - 1, p - 1);
       update++;
@@ -445,7 +451,8 @@ public class WsPreferences extends GWsPreferences
     JTextField urltf = new JTextField(url, 40);
     JPanel panel = new JPanel(new BorderLayout());
     JPanel pane12 = new JPanel(new BorderLayout());
-    pane12.add(new JLabel("URL: "), BorderLayout.CENTER);
+    pane12.add(new JLabel(MessageManager.getString("label.url")),
+            BorderLayout.CENTER);
     pane12.add(urltf, BorderLayout.EAST);
     panel.add(pane12, BorderLayout.NORTH);
     boolean valid = false;
@@ -471,7 +478,7 @@ public class WsPreferences extends GWsPreferences
       {
         valid = false;
         JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                "Invalid URL !");
+                MessageManager.getString("label.invalid_url"));
       }
     }
     if (valid && resp == JOptionPane.OK_OPTION)
@@ -479,20 +486,40 @@ public class WsPreferences extends GWsPreferences
       int validate = JOptionPane
               .showInternalConfirmDialog(
                       Desktop.desktop,
-                      "Validate JabaWS Server ?\n(Look in console output for results)",
-                      "Test Server?", JOptionPane.YES_NO_OPTION);
+                      MessageManager.getString("info.validate_jabaws_server"),
+                      MessageManager.getString("label.test_server"), JOptionPane.YES_NO_OPTION);
+
       if (validate == JOptionPane.OK_OPTION)
       {
-        if (jalview.ws.jws2.Jws2Discoverer.testServiceUrl(foo))
+        if (Jws2Discoverer.testServiceUrl(foo))
         {
           return foo.toString();
         }
         else
         {
-          JOptionPane
-                  .showInternalMessageDialog(
+          int opt = JOptionPane
+                  .showInternalOptionDialog(
                           Desktop.desktop,
-                          "Service did not pass validation.\nCheck the Jalview Console for more details.");
+                          "The Server  '"
+                                  + foo.toString()
+                                  + "' failed validation,\ndo you want to add it anyway? ",
+                          "Server Validation Failed",
+                          JOptionPane.YES_NO_OPTION,
+                          JOptionPane.INFORMATION_MESSAGE, null, null, null);
+          if (opt == JOptionPane.YES_OPTION)
+          {
+            return foo.toString();
+          }
+          else
+          {
+            JOptionPane
+                    .showInternalMessageDialog(
+                            Desktop.desktop,
+                            MessageManager
+                                    .getString("warn.server_didnt_pass_validation"));
+          }
+
+
         }
       }
       else
@@ -513,7 +540,7 @@ public class WsPreferences extends GWsPreferences
   @Override
   protected void newWsUrl_actionPerformed(ActionEvent e)
   {
-    String url = editUrl(null, "Add new JABAWS URL");
+    String url = editUrl(null, MessageManager.getString("label.add_jabaws_url"));
     if (url != null)
     {
       if (!wsUrls.contains(url))
@@ -521,11 +548,11 @@ public class WsPreferences extends GWsPreferences
         int selind = wsList.getSelectedRow();
         if (selind > -1)
         {
-          wsUrls.insertElementAt(url, selind);
+          wsUrls.add(selind, url);
         }
         else
         {
-          wsUrls.addElement(url);
+          wsUrls.add(url);
         }
         update++;
         updateList();
@@ -598,7 +625,7 @@ public class WsPreferences extends GWsPreferences
         public void run()
         {
           long ct = System.currentTimeMillis();
-          Desktop.instance.setProgressBar("Refreshing Web Service Menus",
+          Desktop.instance.setProgressBar(MessageManager.getString("status.refreshing_web_service_menus"),
                   ct);
           if (lastrefresh != update)
           {
@@ -628,8 +655,8 @@ public class WsPreferences extends GWsPreferences
   @Override
   protected void resetWs_actionPerformed(ActionEvent e)
   {
-    jalview.ws.jws2.Jws2Discoverer.setServiceUrls(null);
-    Vector nwsUrls = jalview.ws.jws2.Jws2Discoverer.getServiceUrls();
+    Jws2Discoverer.getDiscoverer().setServiceUrls(null);
+    List<String> nwsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
     if (!wsUrls.equals(nwsUrls))
     {
       update++;