import javax.swing.JMenu;
import javax.swing.JMenuItem;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
import org.apache.log4j.Level;
import jalview.datamodel.AlignmentView;
import jalview.gui.AlignFrame;
import jalview.ws.WSMenuEntryProviderI;
+import jalview.ws.params.ParamDatastoreI;
import compbio.data.msa.MsaWS;
import compbio.metadata.Option;
import compbio.metadata.Preset;
PresetManager presets = null;
+ public JabaParamStore paramStore=null;
+
/**
* non thread safe - gets the presets for this service (blocks whilst it
* calls the service to get the preset set)
}
super.finalize();
}
+
+ public ParamDatastoreI getParamStore()
+ {
+ if (paramStore == null)
+ {
+ try {
+ paramStore = new JabaParamStore(this);
+ } catch (Exception ex)
+ {}
+
+ }
+ return paramStore;
+ }
};
/**
public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
{
+ // dynamically regenerate service list.
+ final JMenu jws2al = new JMenu("JABA Alignment");
+ jws2al.addMenuListener(new MenuListener() {
+ // TODO: future: add menu listener to parent menu - so submenus are populated *before* they are selected.
+ @Override
+ public void menuSelected(MenuEvent e)
+ {
+ populateWSMenuEntry(jws2al, alignFrame);
+ }
+
+ @Override
+ public void menuDeselected(MenuEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void menuCanceled(MenuEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ wsmenu.add(jws2al);
+ }
+ private void populateWSMenuEntry(JMenu jws2al, final AlignFrame alignFrame)
+ {
if (running || services == null || services.size() == 0)
{
return;
* eventually, JWS2 services will appear under the same align/etc submenus.
* for moment we keep them separate.
*/
- JMenu atpoint, jws2al = new JMenu("JABA Alignment");
+ JMenu atpoint;
MsaWSClient msacl = new MsaWSClient();
Vector hostLabels = new Vector();
+ jws2al.removeAll();
for (final Jws2Instance service : services)
{
atpoint = jws2al;
* alignFrame); } });
*/
}
- if (services.size() > 0)
- {
- wsmenu.add(jws2al);
- }
-
}
public static void main(String[] args)
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import jalview.gui.*;
import compbio.data.msa.MsaWS;
import compbio.metadata.Argument;
+import compbio.metadata.Option;
import compbio.metadata.Preset;
import compbio.metadata.PresetManager;
import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
+import jalview.ws.jws2.dm.JabaWsParamSet;
+import jalview.ws.params.WsParamSetI;
/**
* DOCUMENT ME!
// TODO Auto-generated constructor stub
}
- public MsaWSClient(Jws2Discoverer.Jws2Instance sh, Preset preset,
+ public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset,
String altitle, jalview.datamodel.AlignmentView msa,
boolean submitGaps, boolean preserveOrder, Alignment seqdataset,
AlignFrame _alignFrame)
* DOCUMENT ME!
*/
- public MsaWSClient(Jws2Discoverer.Jws2Instance sh, Preset preset,
+ public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset,
List<Argument> arguments, boolean editParams, String altitle,
jalview.datamodel.AlignmentView msa, boolean submitGaps,
boolean preserveOrder, Alignment seqdataset,
return;
}
server = sh.service;
- this.preset = preset;
+ if (preset!=null) {
+ if (preset instanceof JabaPreset){
+ this.preset = ((JabaPreset)preset).p;
+ } else
+ if (preset instanceof JabaWsParamSet) {
+ JabaWsParamSet pset = ((JabaWsParamSet)preset);
+ if (arguments!=null && arguments.size()>0)
+ {
+ // merge arguments with preset's own arguments.
+ List<Argument> oldargs = arguments;
+ arguments = new ArrayList<Argument>();
+ for (Option opt : pset.getjabaArguments()) {
+ arguments.add(opt);
+ }
+ for (Argument opt: oldargs)
+ {
+ arguments.add(opt);
+ }
+ }
+
+ }else{
+ throw new Error("Implementation error: Can only instantiate Jaba parameter sets.");
+ }
+ }
this.paramset = arguments;
if (editParams)
{
+ if (sh.paramStore==null)
+ {
+ sh.paramStore = new JabaParamStore(sh);
+ }
WsJobParameters jobParams = new WsJobParameters(sh, preset);
if (!jobParams.showRunDialog())
{
return;
}
- if ((this.preset = jobParams.getPreset())==null)
+ WsParamSetI prset = jobParams.getPreset();
+ if (prset==null)
{
- paramset = jobParams.getJobParams();
+ paramset = JabaParamStore.getJabafromJwsArgs(jobParams.getJobParams());
} else {
+ this.preset = ((JabaPreset)prset).p;
paramset = null; // no user supplied parameters.
}
}
String svcname = WebServiceName;
if (svcname.endsWith("WS"))
{
- svcname = svcname.substring(0,svcname.length()-2);
+ svcname = svcname.substring(0, svcname.length() - 2);
}
String calcName = svcname + " ";
if (canSubmitGaps())
}
});
msawsmenu.add(method);
- PresetManager presets = service.getPresets();
- if (presets != null && presets.getPresets().size() > 0)
+ List<WsParamSetI> presets = service.getParamStore().getPresets();
+ if (presets != null && presets.size() > 0)
{
JMenu presetlist = new JMenu(calcName + "Presets");
- for (final Preset preset : (List<Preset>) presets.getPresets())
+ for (final WsParamSetI preset : presets)
{
final JMenuItem methodR = new JMenuItem(preset.getName());
- methodR.setToolTipText("<html><p>"+preset.getDescription()+"</p></html>");
+ methodR.setToolTipText("<html><p><strong>"
+ + (preset.isModifiable() ? "User Preset"
+ : "Service Preset") + "</strong><br/>"
+ + preset.getDescription() + "</p></html>");
methodR.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)