import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Comparator;
import java.util.Deque;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import java.util.Vector;
import javax.swing.ButtonGroup;
{
if (discoverer.hasServices())
{
- for (WebServiceI service : discoverer.getServices())
+ var services = new ArrayList<>(discoverer.getServices());
+ services.sort(Comparator
+ .<WebServiceI, String>comparing(o -> o.getHostName())
+ .<String>thenComparing(o -> o.getName()));
+ Map<String, String> lastHostForOperation = new HashMap<>();
+ for (final WebServiceI service : services)
{
+ var host = service.getHostName();
for (Operation op : service.getOperations())
{
JMenu atpoint = JvSwingUtils.findOrCreateMenu(menu, op.getTypeName());
+ String lastHost = lastHostForOperation.get(op.getTypeName());
+ if (lastHost != host) {
+ if (lastHost != null)
+ atpoint.addSeparator();
+ var menuItem = new JMenuItem(host);
+ menuItem.setForeground(Color.blue);
+ menuItem.addActionListener(e -> Desktop.showUrl(host));
+ atpoint.add(menuItem);
+ lastHostForOperation.put(op.getTypeName(), host);
+ }
+ atpoint.addSeparator();
op.getMenuBuilder().buildMenu(atpoint, this);
}
}