import jalview.gui.AlignFrame;
import jalview.ws.WSMenuEntryProviderI;
import jalview.ws.api.ServiceWithParameters;
-import jalview.ws.jws2.MsaWSClient;
import jalview.ws.jws2.PreferredServiceRegistry;
-import jalview.ws.jws2.SequenceAnnotationWSClient;
import java.beans.PropertyChangeSupport;
import java.io.IOError;
return instance;
}
- private void addMsaServiceClient(JMenu alignmentMenu,
- SlivkaService service, AlignFrame alignFrame)
+ List<ServiceWithParameters> getServiceInstances()
{
- SlivkaMsaServiceInstance instance = new SlivkaMsaServiceInstance(
- slivkaClient, service);
- MsaWSClient client = new MsaWSClient();
- client.attachWSMenuEntry(alignmentMenu, instance, alignFrame);
- alignmentMenu.addSeparator();
- }
-
- private void addDisorderServiceClient(JMenu disorderMenu,
- SlivkaService service, AlignFrame alignFrame)
- {
- SlivkaAnnotationServiceInstance serviceInstance = new SlivkaAnnotationServiceInstance(
- slivkaClient, service, false);
-
- SequenceAnnotationWSClient client = new SequenceAnnotationWSClient();
- client.attachWSMenuEntry(disorderMenu, serviceInstance, alignFrame);
- disorderMenu.addSeparator();
- }
+ List<ServiceWithParameters> instances = new ArrayList<>();
+ for (SlivkaService service : services)
+ {
+ for (String classifier : service.classifiers)
+ {
+ if (classifier.contains("Multiple sequence alignment"))
+ {
+ instances
+ .add(new SlivkaMsaServiceInstance(slivkaClient, service));
+ }
+ else if (classifier.contains("Protein sequence analysis"))
+ {
+ instances.add(new SlivkaAnnotationServiceInstance(slivkaClient,
+ service, false));
+ }
+ else if (classifier
+ .contains("Sequence alignment analysis (conservation)"))
+ {
+ instances.add(new SlivkaAnnotationServiceInstance(slivkaClient,
+ service, true));
+ }
- private void addConservationServiceClient(JMenu conservationMenu,
- SlivkaService service, AlignFrame alignFrame)
- {
- SlivkaAnnotationServiceInstance serviceInstance = new SlivkaAnnotationServiceInstance(
- slivkaClient, service, true);
- SequenceAnnotationWSClient client = new SequenceAnnotationWSClient();
- client.attachWSMenuEntry(conservationMenu, serviceInstance, alignFrame);
- conservationMenu.addSeparator();
+ }
+ }
+ return instances;
}
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
slivkaMenu.add(disorderMenu);
JMenu conservationMenu = new JMenu("Conservation");
slivkaMenu.add(conservationMenu);
+ PreferredServiceRegistry.getRegistry().populateWSMenuEntry(
+ getServiceInstances(),
+ changeSupport, slivkaMenu, alignFrame, null);
+
+ }
+
+ List<SlivkaService>services=null;
+
+ volatile boolean started = false, finished = false;
+
+ Thread discoverer = null;
+ @Override
+ public void run()
+ {
+ discoverer = Thread.currentThread();
+ started = true;
try
{
- List<ServiceWithParameters> instances = new ArrayList<>();
- for (SlivkaService service : slivkaClient.getServices())
- {
- for (String classifier : service.classifiers)
- {
- if (classifier.contains("Multiple sequence alignment"))
- {
- instances.add(
- new SlivkaMsaServiceInstance(slivkaClient, service));
- // addMsaServiceClient(alignmentMenu, service, alignFrame);
- }
- else if (classifier.contains("Protein sequence analysis"))
- {
- instances.add(new SlivkaAnnotationServiceInstance(slivkaClient,
- service, false));
- // addDisorderServiceClient(disorderMenu, service, alignFrame);
- }
- else if (classifier
- .contains("Sequence alignment analysis (conservation)"))
- {
- instances.add(new SlivkaAnnotationServiceInstance(slivkaClient,
- service, true));
- // addConservationServiceClient(conservationMenu, service,
- // alignFrame);
- }
-
- }
- }
- PreferredServiceRegistry.getRegistry().populateWSMenuEntry(instances,
- changeSupport, slivkaMenu, alignFrame, null);
+ services = slivkaClient.getServices();
} catch (IOException e)
{
throw new IOError(e);
}
+ finished = true;
}
- @Override
- public void run()
+ public static List<ServiceWithParameters> getServices()
{
+ SlivkaWSDiscoverer us = getInstance();
+ if (us.services == null)
+ {
+ us.run();
+ }
+ return us.getServiceInstances();
+ }
+ public boolean hasServices()
+ {
+ return finished == true && services != null && services.size() > 0;
+ }
+
+ public boolean isRunning()
+ {
+ return discoverer != null && discoverer.isAlive();
}
}