From e568f853187c30c707c02db4e01a30a7530b74e3 Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 4 Nov 2010 14:52:12 +0000 Subject: [PATCH] made ws warning dialog optional, and fixed its wording (JAL-693) --- src/jalview/bin/Cache.java | 2 ++ src/jalview/gui/Desktop.java | 48 ++++++++++++++++++------------ src/jalview/gui/WsPreferences.java | 52 +++++++++++++++++++++++++++++---- src/jalview/jbgui/GWsPreferences.java | 20 +++++++++++++ 4 files changed, 97 insertions(+), 25 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index d666b01..48837ff 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -127,6 +127,8 @@ import org.biojava.dasobert.dasregistry.Das1Source; *
  • FOLLOW_SELECTIONS (true) Controls whether a new alignment view should * respond to selections made in other alignments containing the same sequences. *
  • + *
  • SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery + * warning dialog box is displayed.
  • * *
  • * diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index d263e88..6912e19 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -2179,32 +2179,42 @@ public class Desktop extends jalview.jbgui.GDesktop implements */ protected void JalviewServicesChanged(PropertyChangeEvent evt) { - if (evt.getNewValue() instanceof Vector) + if (evt.getNewValue() == null || evt.getNewValue() instanceof Vector) { final String ermsg = jalview.ws.jws2.Jws2Discoverer.getDiscoverer() .getErrorMessages(); if (ermsg != null) { - if (serviceChangedDialog == null) + if (Cache.getDefault("SHOW_WSDISCOVERY_ERRORS", true)) { - // only run if we aren't already displaying one of these. - javax.swing.SwingUtilities - .invokeLater(serviceChangedDialog = new Runnable() - { - public void run() - { + if (serviceChangedDialog == null) - JOptionPane - .showInternalMessageDialog( - Desktop.desktop, - ermsg - + "\nPlease check the web services preferences.\n", - "Preferences Problem", - JOptionPane.WARNING_MESSAGE); - serviceChangedDialog = null; - - } - }); + { + // only run if we aren't already displaying one of these. + javax.swing.SwingUtilities + .invokeLater(serviceChangedDialog = new Runnable() + { + public void run() + { + + JOptionPane + .showInternalMessageDialog( + Desktop.desktop, + ermsg + + "It may be that you have invalid JABA URLs\nin your web service preferences.\n\nGo to the Web services tab of the\nTools->Preferences dialog box to change them.\n", + "Preferences Problem", + JOptionPane.WARNING_MESSAGE); + serviceChangedDialog = null; + + } + }); + } + } + else + { + Cache.log + .error("Errors reported by JABA discovery service. Check web services preferences.\n" + + ermsg); } } } diff --git a/src/jalview/gui/WsPreferences.java b/src/jalview/gui/WsPreferences.java index 4fb8e6e..ff149c1 100644 --- a/src/jalview/gui/WsPreferences.java +++ b/src/jalview/gui/WsPreferences.java @@ -19,6 +19,7 @@ package jalview.gui; import java.awt.BorderLayout; import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.net.URL; import java.util.Vector; @@ -45,7 +46,7 @@ public class WsPreferences extends GWsPreferences private boolean needWsMenuUpdate; private boolean oldJws1, oldJws2, oldIndexByHost, oldIndexByType, - oldEnfin; + oldEnfin, oldWsWarning; private void initFromPreferences() { @@ -63,16 +64,34 @@ public class WsPreferences extends GWsPreferences updateList(); enableEnfinServices.setSelected(oldEnfin = Cache.getDefault( "SHOW_ENFIN_SERVICES", true)); + enableEnfinServices.addActionListener(updateAction); enableJws1Services.setSelected(oldJws1 = Cache.getDefault( "SHOW_JWS1_SERVICES", true)); + enableJws1Services.addActionListener(updateAction); enableJws2Services.setSelected(oldJws2 = Cache.getDefault( "SHOW_JWS2_SERVICES", true)); + enableJws2Services.addActionListener(updateAction); indexByHost.setSelected(oldIndexByHost = Cache.getDefault( "WSMENU_BYHOST", true)); + indexByHost.addActionListener(updateAction); indexByType.setSelected(oldIndexByType = Cache.getDefault( "WSMENU_BYTYPE", true)); + indexByType.addActionListener(updateAction); + displayWsWarning.setSelected(oldWsWarning = Cache.getDefault( + "SHOW_WSDISCOVERY_ERRORS", true)); } + ActionListener updateAction = new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + update++; + } + + }; + private void updateList() { wsList.setListData(wsUrls); @@ -97,6 +116,7 @@ public class WsPreferences extends GWsPreferences if (sel > -1) { wsUrls.removeElementAt(sel); + update++; updateList(); } } @@ -119,6 +139,7 @@ public class WsPreferences extends GWsPreferences int present = wsUrls.indexOf(url); if (present == -1) { + update++; wsUrls.setElementAt(url, sel); updateList(); } @@ -165,6 +186,8 @@ public class WsPreferences extends GWsPreferences "WSMENU_BYTYPE", Boolean.valueOf(old ? oldIndexByType : indexByType.isSelected()) .toString()); + Cache.setProperty("SHOW_WSDISCOVERY_ERRORS", + Boolean.valueOf(old ? oldWsWarning : displayWsWarning.isSelected()).toString()); updateServiceList(); } @@ -297,6 +320,7 @@ public class WsPreferences extends GWsPreferences { wsUrls.addElement(url); } + update++; updateList(); } } @@ -316,6 +340,8 @@ public class WsPreferences extends GWsPreferences public void run() { + // force a refresh. + lastrefresh = update - 1; updateWsMenuConfig(false); refreshWsMenu(true); } @@ -324,6 +350,8 @@ public class WsPreferences extends GWsPreferences } /** + * Refresh the web services menus - but only if there has been a change in the + * configuration (indicated by update!=lastrefresh) * * @param showProgress * show progress in dialog or on desktop @@ -340,8 +368,12 @@ public class WsPreferences extends GWsPreferences progressBar.setVisible(true); validate(); progressBar.setIndeterminate(true); - Desktop.instance.startServiceDiscovery(true); // wait around for all - // threads to complete + if (lastrefresh != update) + { + lastrefresh = update; + Desktop.instance.startServiceDiscovery(true); // wait around for all + // threads to complete + } progressBar.setIndeterminate(false); progressBar.setVisible(false); validate(); @@ -359,15 +391,23 @@ public class WsPreferences extends GWsPreferences long ct = System.currentTimeMillis(); Desktop.instance.setProgressBar("Refreshing Web Service Menus", ct); - Desktop.instance.startServiceDiscovery(true); - Desktop.instance.setProgressBar(null, - ct); + if (lastrefresh != update) + { + lastrefresh = update; + Desktop.instance.startServiceDiscovery(true); + } + Desktop.instance.setProgressBar(null, ct); } }).start(); } } + /** + * state counters for ensuring that updates only happen if config has changed. + */ + private long update = 0, lastrefresh = 0; + /* * (non-Javadoc) * diff --git a/src/jalview/jbgui/GWsPreferences.java b/src/jalview/jbgui/GWsPreferences.java index 2b30f47..da9322c 100644 --- a/src/jalview/jbgui/GWsPreferences.java +++ b/src/jalview/jbgui/GWsPreferences.java @@ -71,6 +71,8 @@ public class GWsPreferences extends JPanel protected JCheckBox enableEnfinServices = new JCheckBox(); + protected JCheckBox displayWsWarning = new JCheckBox(); + protected JButton refreshWs = new JButton(); protected JButton resetWs = new JButton(); @@ -178,6 +180,17 @@ public class GWsPreferences extends JPanel enableJws1Services_actionPerformed(e); } }); + displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); + displayWsWarning.setText("Display warnings"); + displayWsWarning + .setToolTipText("Check this option if you want to be informed
    when a web service URL cannot be accessed by Jalview
    when it starts up"); + displayWsWarning.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + displayWsWarning_actionPerformed(e); + } + }); newWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); newWsUrl.setText("New Service URL"); newWsUrl.addActionListener(new ActionListener() @@ -294,6 +307,7 @@ public class GWsPreferences extends JPanel wsMenuButtons.add(enableJws1Services); wsMenuButtons.add(enableJws2Services); wsMenuButtons.add(enableEnfinServices); + wsMenuButtons.add(displayWsWarning); wsMenuRefreshButs.setLayout(new FlowLayout()); wsMenuRefreshButs.setPreferredSize(new Dimension(480, 30)); wsMenuRefreshButs.setSize(new Dimension(480, 30)); @@ -306,6 +320,12 @@ public class GWsPreferences extends JPanel add(wsMenuRefreshButs, BorderLayout.SOUTH); } + protected void displayWsWarning_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + protected void resetWs_actionPerformed(ActionEvent e) { -- 1.7.10.2