From ad2bc87d7b8ded21b39a817f1750f2b525c5cac0 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 17 Sep 2010 17:13:30 +0000 Subject: [PATCH] make sure web service menu is always refreshed on 'OK' --- src/jalview/gui/Preferences.java | 2 +- src/jalview/gui/WsPreferences.java | 37 +++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index e863d0b..b124bca 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -447,7 +447,7 @@ public class Preferences extends GPreferences .toString(padGaps.isSelected())); dasSource.saveProperties(Cache.applicationProperties); - wsPrefs.updateWsMenuConfig(false); + wsPrefs.updateAndRefreshWsMenuConfig(false); Cache.saveProperties(); try { diff --git a/src/jalview/gui/WsPreferences.java b/src/jalview/gui/WsPreferences.java index 8bf81bb..8ddd28f 100644 --- a/src/jalview/gui/WsPreferences.java +++ b/src/jalview/gui/WsPreferences.java @@ -97,6 +97,8 @@ public class WsPreferences extends GWsPreferences void updateWsMenuConfig(boolean old) { if (old) { wsUrls = (oldUrls==null) ? null : new Vector(oldUrls); + } else { + } Cache.setProperty("SHOW_ENFIN_SERVICES", Boolean.valueOf(old ? oldEnfin : enableEnfinServices.isSelected()).toString()); Cache.setProperty("SHOW_JWS1_SERVICES", Boolean.valueOf(old ? oldJws1 : enableJws1Services.isSelected()).toString()); @@ -170,13 +172,18 @@ public class WsPreferences extends GWsPreferences } if (valid && resp==JOptionPane.OK_OPTION) { - int validate = JOptionPane.showInternalConfirmDialog(Desktop.desktop, null, "Validate JabaWS Server ?\n(Look in console output for results)", JOptionPane.YES_NO_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) { if (jalview.ws.jws2.Jws2Discoverer.testServiceUrl(foo)) { return foo.toString(); + } else { + JOptionPane.showInternalMessageDialog(Desktop.desktop, "Service did not pass validation.\nCheck the Jalview Console for more details."); } + } else { + // just return the URL anyway + return foo.toString(); } } return initUrl; @@ -220,7 +227,10 @@ public class WsPreferences extends GWsPreferences }).start(); } - + /** + * + * @param showProgress show progress in dialog or on desktop + */ protected void refreshWsMenu(boolean showProgress) { if (showProgress) @@ -244,7 +254,10 @@ public class WsPreferences extends GWsPreferences public void run() { - Desktop.instance.startServiceDiscovery(false); + long ct = System.currentTimeMillis(); + Desktop.instance.setProgressBar("Refreshing Web Service Menus", ct); + Desktop.instance.startServiceDiscovery(true); + Desktop.instance.setProgressBar("Refreshing Web Service Menus", ct); } }).start(); @@ -262,9 +275,19 @@ public class WsPreferences extends GWsPreferences updateList(); } protected void ok_ActionPerformed(ActionEvent e) { - updateWsMenuConfig(false); - // todo: work out if the ws list needs updating ? - updateServiceList(); - refreshWsMenu(false); + // update everything regardless. + updateAndRefreshWsMenuConfig(false); + } + public void updateAndRefreshWsMenuConfig(final boolean showProgressInDialog) + { + new Thread(new Runnable() { + + public void run() + { + updateWsMenuConfig(false); + refreshWsMenu(showProgressInDialog); + } + }).start(); + } } -- 1.7.10.2