*/
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 (Cache.getDefault("SHOW_WSDISCOVERY_ERRORS", true))
+ {
if (serviceChangedDialog == null)
{
// only run if we aren't already displaying one of these.
.showInternalMessageDialog(
Desktop.desktop,
ermsg
- + "\nPlease check the web services preferences.\n",
+ + "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);
+ }
+ }
}
}
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.net.URL;
import java.util.Vector;
private boolean needWsMenuUpdate;
private boolean oldJws1, oldJws2, oldIndexByHost, oldIndexByType,
- oldEnfin;
+ oldEnfin, oldWsWarning;
private void initFromPreferences()
{
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);
if (sel > -1)
{
wsUrls.removeElementAt(sel);
+ update++;
updateList();
}
}
int present = wsUrls.indexOf(url);
if (present == -1)
{
+ update++;
wsUrls.setElementAt(url, sel);
updateList();
}
"WSMENU_BYTYPE",
Boolean.valueOf(old ? oldIndexByType : indexByType.isSelected())
.toString());
+ Cache.setProperty("SHOW_WSDISCOVERY_ERRORS",
+ Boolean.valueOf(old ? oldWsWarning : displayWsWarning.isSelected()).toString());
updateServiceList();
}
{
wsUrls.addElement(url);
}
+ update++;
updateList();
}
}
public void run()
{
+ // force a refresh.
+ lastrefresh = update - 1;
updateWsMenuConfig(false);
refreshWsMenu(true);
}
}
/**
+ * 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
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();
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)
*
protected JCheckBox enableEnfinServices = new JCheckBox();
+ protected JCheckBox displayWsWarning = new JCheckBox();
+
protected JButton refreshWs = new JButton();
protected JButton resetWs = new JButton();
enableJws1Services_actionPerformed(e);
}
});
+ displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
+ displayWsWarning.setText("Display warnings");
+ displayWsWarning
+ .setToolTipText("<html>Check this option if you want to be informed<br>when a web service URL cannot be accessed by Jalview<br>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()
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));
add(wsMenuRefreshButs, BorderLayout.SOUTH);
}
+ protected void displayWsWarning_actionPerformed(ActionEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
protected void resetWs_actionPerformed(ActionEvent e)
{