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)
*