From 99040c05c8b911a47fed2e3a240f80736544eaa3 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 21 Jun 2010 10:16:14 +0000 Subject: [PATCH] organisation by host and service type --- src/jalview/ws/jws2/Jws2Discoverer.java | 87 ++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index 784ff49..d982981 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -5,7 +5,9 @@ import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.net.ConnectException; +import java.net.URL; import java.util.HashSet; +import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; @@ -61,11 +63,13 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } boolean running = false; - Thread oldthread=null; + + Thread oldthread = null; + @Override public void run() { - if (running && oldthread!=null && oldthread.isAlive()) + if (running && oldthread != null && oldthread.isAlive()) { return; } @@ -151,8 +155,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } System.out.println("Discovered service: " + jwsservers + " " + srv.toString()); - services.add(new Jws2Instance(jwsservers, "Align with " - + srv.toString(), service2)); + services.add(new Jws2Instance(jwsservers, srv.toString(), service2)); } public class Jws2Instance @@ -195,6 +198,32 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } return presets; } + + public String getHost() + { + return hosturl; +/* try + { + URL serviceurl = new URL(hosturl); + if (serviceurl.getPort()!=80) + { + return serviceurl.getHost()+":"+serviceurl.getPort(); + } + return serviceurl.getHost(); + } catch (Exception e) + { + System.err.println("Failed to parse service URL '" + hosturl + + "' as a valid URL!"); + } + return null; */ + } + /** + * @return short description of what the service will do + */ + public String getActionText() { + return "Align with " + + serviceType; + } }; /** @@ -202,6 +231,31 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ Vector services; + /** + * find or add a submenu with the given title in the given menu + * @param menu + * @param submenu + * @return the new or existing submenu + */ + private JMenu findOrCreateMenu(JMenu menu, String submenu) + { + JMenu submenuinstance = null; + for (int i=0,iSize=menu.getMenuComponentCount(); i 0) { - wsmenu.add(jws2); + wsmenu.add(jws2al); } } -- 1.7.10.2