X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FWsPreferences.java;h=e37f77c48087a18ce624c411a24c057e93ce110b;hb=5640ec0623c6d1205e62f9fe15292f32bfdab7d9;hp=2f040b255654b2027c81f9c3c64cc3cb1cc497c8;hpb=865a855a4ca87eadb3e5ff284ed32ed307d9c34b;p=jalview.git
diff --git a/src/jalview/gui/WsPreferences.java b/src/jalview/gui/WsPreferences.java
index 2f040b2..e37f77c 100644
--- a/src/jalview/gui/WsPreferences.java
+++ b/src/jalview/gui/WsPreferences.java
@@ -1,28 +1,25 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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 .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
-import jalview.bin.Cache;
-import jalview.jbgui.GWsPreferences;
-import jalview.ws.jws2.Jws2Discoverer;
-import jalview.ws.rest.RestServiceDescription;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -30,16 +27,22 @@ 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;
-import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableCellRenderer;
+import jalview.bin.Cache;
+import jalview.jbgui.GWsPreferences;
+import jalview.util.MessageManager;
+import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.rest.RestServiceDescription;
+
public class WsPreferences extends GWsPreferences
{
@@ -49,7 +52,9 @@ public class WsPreferences extends GWsPreferences
initFromPreferences();
}
- Vector wsUrls, oldUrls, rsbsUrls, oldRsbsUrls;
+ List wsUrls;
+
+ Vector oldUrls, rsbsUrls, oldRsbsUrls;
private boolean needWsMenuUpdate;
@@ -59,8 +64,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(wsUrls);
}
@@ -83,20 +88,20 @@ public class WsPreferences extends GWsPreferences
rsbsUrls = new Vector();
}
updateRsbsList();
- enableEnfinServices.setSelected(oldEnfin = Cache.getDefault(
- "SHOW_ENFIN_SERVICES", true));
+ enableEnfinServices.setSelected(
+ oldEnfin = Cache.getDefault("SHOW_ENFIN_SERVICES", true));
enableEnfinServices.addActionListener(updateAction);
- enableJws2Services.setSelected(oldJws2 = Cache.getDefault(
- "SHOW_JWS2_SERVICES", true));
+ enableJws2Services.setSelected(
+ oldJws2 = Cache.getDefault("SHOW_JWS2_SERVICES", true));
enableJws2Services.addActionListener(updateAction);
- indexByHost.setSelected(oldIndexByHost = Cache.getDefault(
- "WSMENU_BYHOST", false));
+ indexByHost.setSelected(
+ oldIndexByHost = Cache.getDefault("WSMENU_BYHOST", false));
indexByHost.addActionListener(updateAction);
- indexByType.setSelected(oldIndexByType = Cache.getDefault(
- "WSMENU_BYTYPE", false));
+ indexByType.setSelected(
+ oldIndexByType = Cache.getDefault("WSMENU_BYTYPE", false));
indexByType.addActionListener(updateAction);
- displayWsWarning.setSelected(oldWsWarning = Cache.getDefault(
- "SHOW_WSDISCOVERY_ERRORS", true));
+ displayWsWarning.setSelected(oldWsWarning = Cache
+ .getDefault("SHOW_WSDISCOVERY_ERRORS", true));
}
ActionListener updateAction = new ActionListener()
@@ -117,16 +122,17 @@ public class WsPreferences extends GWsPreferences
for (String url : wsUrls)
{
int status = Jws2Discoverer.getDiscoverer().getServerStatusFor(url);
- tdat[r][1] = new Integer(status);
+ tdat[r][1] = Integer.valueOf(status);
tdat[r++][0] = url;
}
wsList.setModel(new WsUrlTableModel(tdat));
- wsList.getColumn("Status").setMinWidth(10);
+ wsList.getColumn(MessageManager.getString("label.status"))
+ .setMinWidth(10);
}
- private class JabaWSStatusRenderer extends JPanel implements
- TableCellRenderer
+ private class JabaWSStatusRenderer extends JPanel
+ implements TableCellRenderer
{
public JabaWSStatusRenderer()
{
@@ -182,6 +188,10 @@ 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)
{
this.data = tdat;
@@ -196,11 +206,7 @@ public class WsPreferences extends GWsPreferences
@Override
public String getColumnName(int column)
{
- if (column == 1)
- {
- return "Status";
- }
- return "Service URL";
+ return columnNames[column];
}
@Override
@@ -234,7 +240,7 @@ public class WsPreferences extends GWsPreferences
private void updateServiceList()
{
- jalview.ws.jws2.Jws2Discoverer.setServiceUrls(wsUrls);
+ Jws2Discoverer.getDiscoverer().setServiceUrls(wsUrls);
}
private void updateRsbsServiceList()
@@ -255,7 +261,7 @@ public class WsPreferences extends GWsPreferences
int sel = wsList.getSelectedRow();
if (sel > -1)
{
- wsUrls.removeElementAt(sel);
+ wsUrls.remove(sel);
update++;
updateList();
}
@@ -273,21 +279,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();
}
}
@@ -299,7 +306,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))
{
@@ -317,7 +324,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)
{
@@ -345,16 +352,14 @@ public class WsPreferences extends GWsPreferences
{
if (old)
{
- if (oldUrls != wsUrls
- || (wsUrls != null && oldUrls != null && !wsUrls
- .equals(oldUrls)))
+ if (oldUrls != wsUrls || (wsUrls != null && oldUrls != null
+ && !wsUrls.equals(oldUrls)))
{
update++;
}
wsUrls = (oldUrls == null) ? null : new Vector(oldUrls);
- if (oldRsbsUrls != rsbsUrls
- || (rsbsUrls != null && oldRsbsUrls != null && !oldRsbsUrls
- .equals(rsbsUrls)))
+ if (oldRsbsUrls != rsbsUrls || (rsbsUrls != null
+ && oldRsbsUrls != null && !oldRsbsUrls.equals(rsbsUrls)))
{
update++;
}
@@ -364,26 +369,21 @@ public class WsPreferences extends GWsPreferences
{
}
- Cache.setProperty(
- "SHOW_ENFIN_SERVICES",
+ Cache.setProperty("SHOW_ENFIN_SERVICES",
Boolean.valueOf(
old ? oldEnfin : enableEnfinServices.isSelected())
.toString());
- Cache.setProperty(
- "SHOW_JWS2_SERVICES",
+ Cache.setProperty("SHOW_JWS2_SERVICES",
Boolean.valueOf(old ? oldJws2 : enableJws2Services.isSelected())
.toString());
- Cache.setProperty(
- "WSMENU_BYHOST",
+ Cache.setProperty("WSMENU_BYHOST",
Boolean.valueOf(old ? oldIndexByHost : indexByHost.isSelected())
.toString());
- Cache.setProperty(
- "WSMENU_BYTYPE",
+ Cache.setProperty("WSMENU_BYTYPE",
Boolean.valueOf(old ? oldIndexByType : indexByType.isSelected())
.toString());
- Cache.setProperty(
- "SHOW_WSDISCOVERY_ERRORS",
+ Cache.setProperty("SHOW_WSDISCOVERY_ERRORS",
Boolean.valueOf(
old ? oldWsWarning : displayWsWarning.isSelected())
.toString());
@@ -405,8 +405,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++;
@@ -427,8 +427,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++;
@@ -446,15 +446,15 @@ 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;
- int resp = JOptionPane.CANCEL_OPTION;
- while (!valid
- && (resp = JOptionPane.showInternalConfirmDialog(
- Desktop.desktop, panel, title,
- JOptionPane.OK_CANCEL_OPTION)) == JOptionPane.OK_OPTION)
+ int resp = JvOptionPane.CANCEL_OPTION;
+ while (!valid && (resp = JvOptionPane.showInternalConfirmDialog(
+ Desktop.desktop, panel, title,
+ JvOptionPane.OK_CANCEL_OPTION)) == JvOptionPane.OK_OPTION)
{
try
{
@@ -471,29 +471,41 @@ public class WsPreferences extends GWsPreferences
} catch (Exception e)
{
valid = false;
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- "Invalid URL !");
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString("label.invalid_url"));
}
}
- if (valid && resp == JOptionPane.OK_OPTION)
+ if (valid && resp == JvOptionPane.OK_OPTION)
{
- int validate = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- "Validate JabaWS Server ?\n(Look in console output for results)",
- "Test Server?", JOptionPane.YES_NO_OPTION);
- if (validate == JOptionPane.OK_OPTION)
+ int validate = JvOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.getString("info.validate_jabaws_server"),
+ MessageManager.getString("label.test_server"),
+ JvOptionPane.YES_NO_OPTION);
+
+ if (validate == JvOptionPane.OK_OPTION)
{
- if (jalview.ws.jws2.Jws2Discoverer.testServiceUrl(foo))
+ if (Jws2Discoverer.testServiceUrl(foo))
{
return foo.toString();
}
else
{
- JOptionPane
- .showInternalMessageDialog(
- Desktop.desktop,
- "Service did not pass validation.\nCheck the Jalview Console for more details.");
+ int opt = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
+ "The Server '" + foo.toString()
+ + "' failed validation,\ndo you want to add it anyway? ",
+ "Server Validation Failed", JvOptionPane.YES_NO_OPTION,
+ JvOptionPane.INFORMATION_MESSAGE, null, null, null);
+ if (opt == JvOptionPane.YES_OPTION)
+ {
+ return foo.toString();
+ }
+ else
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString(
+ "warn.server_didnt_pass_validation"));
+ }
+
}
}
else
@@ -514,7 +526,8 @@ 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))
@@ -522,11 +535,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();
@@ -546,6 +559,7 @@ public class WsPreferences extends GWsPreferences
new Thread(new Runnable()
{
+ @Override
public void run()
{
// force a refresh.
@@ -571,6 +585,7 @@ public class WsPreferences extends GWsPreferences
new Thread(new Runnable()
{
+ @Override
public void run()
{
progressBar.setVisible(true);
@@ -596,11 +611,12 @@ public class WsPreferences extends GWsPreferences
new Thread(new Runnable()
{
+ @Override
public void run()
{
long ct = System.currentTimeMillis();
- Desktop.instance.setProgressBar("Refreshing Web Service Menus",
- ct);
+ Desktop.instance.setProgressBar(MessageManager
+ .getString("status.refreshing_web_service_menus"), ct);
if (lastrefresh != update)
{
lastrefresh = update;
@@ -617,7 +633,9 @@ public class WsPreferences extends GWsPreferences
/**
* state counters for ensuring that updates only happen if config has changed.
*/
- private long update = 0, lastrefresh = 0;
+ protected long update = 0;
+
+ private long lastrefresh = 0;
/*
* (non-Javadoc)
@@ -629,8 +647,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 nwsUrls = Jws2Discoverer.getDiscoverer().getServiceUrls();
if (!wsUrls.equals(nwsUrls))
{
update++;
@@ -653,6 +671,7 @@ public class WsPreferences extends GWsPreferences
new Thread(new Runnable()
{
+ @Override
public void run()
{
updateWsMenuConfig(false);