import javax.swing.JMenuItem;
import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
+import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
public class SlivkaWSDiscoverer
implements Runnable, WSMenuEntryProviderI
@Override
public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
{
- JMenu submenu = new JMenu("Slivka");
+ JMenu slivkaMenu = new JMenu("Slivka");
+ wsmenu.add(slivkaMenu);
+ JMenu categoryMenu = new JMenu("Alignment");
+ slivkaMenu.add(categoryMenu);
- String[] services = { "clustalo", "clustalw", "probcons", "muscle", "mafft", "tcoffee" };
- String[] names = { "ClustalO", "ClustalW2", "Probcons", "Muscle", "Mafft", "TCoffe" };
-
- for (int i = 0; i < services.length; i++)
+ try
{
- try
- {
- SlivkaWSInstance instance = new SlivkaWSInstance(client,
- client.getService(services[i]));
-
- JMenuItem defaultMenuItem = new JMenuItem(
- String.format("%s with defaults", names[i]));
- defaultMenuItem.addActionListener((ActionEvent e) -> {
+ for (SlivkaService service: client.getServices()) {
+ msaClassifier: {
+ for (String classifier: service.classifiers) {
+ if (classifier.contains("Multiple sequence alignment")) {
+ break msaClassifier;
+ }
+ }
+ continue;
+ }
+ SlivkaWSInstance instance = new SlivkaWSInstance(client, service);
+ JMenuItem defaultEntry = new JMenuItem(String.format("%s with defaults", service.label));
+ defaultEntry.addActionListener((ActionEvent evt) -> {
AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (msa != null)
- {
- new MsaWSClient(instance, alignFrame.getTitle(), msa, false, true,
+ if (msa != null) {
+ new MsaWSClient(
+ instance, alignFrame.getTitle(), msa, false, true,
alignFrame.getViewport().getAlignment().getDataset(),
- alignFrame);
+ alignFrame
+ );
}
});
- submenu.add(defaultMenuItem);
-
- JMenuItem customMenuItem = new JMenuItem(
- String.format("%s with custom parameters", names[i]));
- customMenuItem.addActionListener((ActionEvent e) -> {
+ categoryMenu.add(defaultEntry);
+
+ JMenuItem customEntry = new JMenuItem(String.format("%s with custom parameters", service.label));
+ customEntry.addActionListener((ActionEvent evt) -> {
AlignmentView msa = alignFrame.gatherSequencesForAlignment();
- if (msa != null)
- {
+ if (msa != null) {
try
{
- SlivkaParamSet paramSet = new SlivkaParamSet(
- instance.getService());
- new MsaWSClient(instance, paramSet, null, true,
- alignFrame.getTitle(), msa, false, true,
- alignFrame.getViewport().getAlignment().getDataset(),
- alignFrame);
- } catch (IOException e1)
+ SlivkaParamSet paramSet = new SlivkaParamSet(service);
+ new MsaWSClient(
+ instance, paramSet, null, true, alignFrame.getTitle(), msa, false, true,
+ alignFrame.getViewport().getAlignment().getDataset(), alignFrame);
+ } catch (IOException exc)
{
- throw new IOError(e1);
+ throw new IOError(exc);
}
-
}
});
- submenu.add(customMenuItem);
- } catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ categoryMenu.add(customEntry);
+
+ categoryMenu.addSeparator();
}
+ } catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
-
- wsmenu.add(submenu);
}
@Override