import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.event.WindowStateListener;
+import java.net.URL;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.HashSet;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
+import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JSplitPane;
import compbio.metadata.WrongParameterException;
import compbio.metadata.ValueConstrain.Type;
+import jalview.util.jarInputStreamProvider;
import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.jws2.ParameterUtils;
import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
/**
JDialog frame = null;
+ /**
+ * shows a modal dialog containing the parameters.
+ *
+ * @return
+ */
public boolean showRunDialog()
{
frame.setTitle("Edit parameters for " + service.getActionText());
Rectangle deskr = Desktop.instance.getBounds();
frame.setBounds(new Rectangle((int) (deskr.getCenterX() - 240),
- (int) (deskr.getCenterY() - 92), 380, 385));
+ (int) (deskr.getCenterY() - 250), 480, 500));
frame.setContentPane(this);
-
+ // should recover defaults from user prefs.
+ frame.validate();
+ settingsPanel.setDividerLocation(0.4);
+ jobPanel.setDividerLocation(0.3);
frame.setVisible(true);
if (response > 0)
setsavebuts.add(renmodified, BorderLayout.CENTER);
setsavebuts.add(deletesetting, BorderLayout.CENTER);
setsavebuts.add(savmodified, BorderLayout.EAST);
- SetNamePanel.add(setsavebuts,BorderLayout.EAST);
+ SetNamePanel.add(setsavebuts, BorderLayout.EAST);
setDetails.add(setDescrView, BorderLayout.CENTER);
// setDetails.setPreferredSize(new Dimension(360, 100));
jobParameters.setBorder(new TitledBorder("Parameters"));
settingsPanel.setLeftComponent(jobOptionsPanel);
settingsPanel.setRightComponent(jobParameters);
settingsPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
- settingsPanel.setDividerLocation(0.4);
setLayout(new BorderLayout());
// setPreferredSize(new Dimension(400, 600));
jobPanel.setLeftComponent(setDetails);
jobPanel.setRightComponent(settingsPanel);
jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT);
- jobPanel.setDividerLocation(0.8);
add(SetNamePanel, BorderLayout.NORTH);
add(jobPanel, BorderLayout.CENTER);
JPanel dialogpanel = new JPanel();
protected void deleteSetting_actionPerformed(ActionEvent e)
{
String setname = (String) setName.getSelectedItem();
- int p=setName.getSelectedIndex();
- if (_getUserPreset(setname)!=null)
+ int p = setName.getSelectedIndex();
+ if (_getUserPreset(setname) != null)
{
_deleteUserPreset(setname);
-
+
}
- if (p>0 && p+1==setName.getItemCount())
+ if (p > 0 && p + 1 == setName.getItemCount())
{
p--;
}
setName.setSelectedIndex(p);
-
+
}
protected void renModified_actionPerformed(ActionEvent e)
{
- if (curSetName==null || _getUserPreset(lastSetName)==null) {
- System.err.println("can't rename - names unchanged or original name not a preset.");
+ if (curSetName == null || _getUserPreset(lastSetName) == null)
+ {
+ System.err
+ .println("can't rename - names unchanged or original name not a preset.");
return;
}
_deleteUserPreset(lastSetName);
- lastSetName=curSetName;
+ lastSetName = curSetName;
savModified_actionPerformed(e);
- curSetName=null;
+ curSetName = null;
boolean setd = settingDialog;
- settingDialog=true;
+ settingDialog = true;
syncSetNamesWithStore();
- settingDialog=setd;
+ settingDialog = setd;
}
protected void savModified_actionPerformed(ActionEvent e)
{
_storeUserPreset(lastSetName=(String) setName.getSelectedItem(), setDescr.getText(), getJobParams());
- curSetName=null;
+ curSetName = null;
initArgSetModified(); // reset the modification state
}
{
if (arg instanceof Option)
{
- System.out.println("Setting option " + arg.getName() + " with "
- + arg.getDefaultValue());
+// System.out.println("Setting option "
+// + System.identityHashCode(arg) + ":" + arg.getName()
+// + " with " + arg.getDefaultValue());
selectOption((Option) arg, arg.getDefaultValue());
}
}
if (isServicePreset(nm))
{
nm = "User " + nm;
+ String tnm=nm;
renamed = true;
+ int i=0;
+ while (_getUserPreset(tnm)!=null)
+ {
+ tnm = nm+" ("+(++i)+")";
+ }
+ if (i>0)
+ {
+ nm = tnm;
+ }
}
// if ()
// if nm exists in user's preset store then savmodified will update an
Map<String, ParamBox> paramSet = new Hashtable<String, ParamBox>();
public class ParamBox extends JPanel implements ChangeListener,
- ActionListener
+ ActionListener, MouseListener
{
JButton showDesc = new JButton();
final WsJobParameters pmdialogbox;
+ final URL finfo;
+
public ParamBox(final WsJobParameters pmlayout, Parameter parm)
{
pmdialogbox = pmlayout;
// string.setMinimumSize(new Dimension(140,80));
// string.setMaximumSize(new Dimension(280,80));
final ParamBox me = this;
+ finfo = parm.getFurtherDetails();
+ if (finfo != null)
+ {
+ showDesc.setToolTipText("<html><p>Click to show brief description, and right click to open link for further information.</p></html>");
+ showDesc.addMouseListener(this);
+ }
+ else
+ {
+ showDesc.setToolTipText("<html><p>Click to show brief description.</p></html>");
+ }
showDesc.addActionListener(new ActionListener()
{
public Parameter getParameter()
{
+ Parameter prm = ParameterUtils.copyParameter(parameter);
try
{
if (choice)
{
- parameter.setDefaultValue((String) choicebox.getSelectedItem());
+ prm.setDefaultValue((String) choicebox.getSelectedItem());
}
else
{
- parameter.setDefaultValue(valueField.getText());
+ prm.setDefaultValue(valueField.getText());
}
} catch (WrongParameterException e)
{
e.printStackTrace();
return null;
}
- return parameter;
+ return prm;
}
public Object updateSliderFromValueField()
}
pmdialogbox.argSetModified(this, !notmod);
}
+
+ public void mouseClicked(MouseEvent e)
+ {
+ if (javax.swing.SwingUtilities.isRightMouseButton(e))
+ {
+ Desktop.showUrl(finfo.toString());
+ }
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseReleased(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseEntered(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
Map<String, OptionBox> optSet = new Hashtable<String, OptionBox>();
- public class OptionBox extends JPanel implements ActionListener
+ public class OptionBox extends JPanel implements MouseListener,
+ ActionListener
{
JComboBox val = new JComboBox();
JCheckBox enabled = new JCheckBox();
+ JLabel optlabel = new JLabel();
+
+ URL linkImageURL = getClass().getResource("/images/link.gif");
+
+ final URL finfo;
+
+ boolean hasLink = false;
+
Option option;
public OptionBox(Option opt)
setLayout(new BorderLayout());
enabled.setSelected(opt.isRequired()); // TODO: lock required options
enabled.setFont(new Font("Verdana", Font.PLAIN, 11));
+ enabled.setText("");
enabled.setText(opt.getName());
- enabled.setToolTipText(opt.getDescription());
enabled.addActionListener(this);
+ finfo = option.getFurtherDetails();
+ if (finfo != null)
+ {
+ hasLink = true;
+ // optlabel.setToolTipText("<html><p>"+opt.getDescription()+"</p><img src=\""+linkImageURL+"\"/></html>");
+ enabled.setToolTipText("<html><p>" + opt.getDescription()
+ + "</p><img src=\"" + linkImageURL + "\"/></html>");
+ // optlabel.addMouseListener(this);
+ enabled.addMouseListener(this);
+ }
+ else
+ {
+ // optlabel.setToolTipText(opt.getDescription());
+ enabled.setToolTipText(opt.getDescription());
+ }
add(enabled, BorderLayout.NORTH);
if (opt.getPossibleValues().size() > 1)
{
}
try
{
+ Option opt = jalview.ws.jws2.ParameterUtils.copyOption(option);
+
if (val.getSelectedItem() != null)
{
- option.setDefaultValue((String) val.getSelectedItem());
+ opt.setDefaultValue((String) val.getSelectedItem());
}
} catch (WrongParameterException e)
{
}
argSetModified(this, !notmod);
}
+
+ public void mouseClicked(MouseEvent e)
+ {
+ if (javax.swing.SwingUtilities.isRightMouseButton(e))
+ {
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
+ }
+ }
+
+ public void mousePressed(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseReleased(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseEntered(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseExited(MouseEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
private OptionBox addOption(Option opt)
return cb;
}
+ public static void showUrlPopUp(JComponent invoker, final String finfo,
+ int x, int y)
+ {
+
+ JPopupMenu mnu = new JPopupMenu();
+ JMenuItem mitem = new JMenuItem("View " + finfo);
+ mitem.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ Desktop.showUrl(finfo);
+
+ }
+ });
+ mnu.add(mitem);
+ mnu.show(invoker, x, y);
+ }
+
protected void refreshParamLayout()
{
int s = 100;
for (Jws2Discoverer.Jws2Instance service : disc.getServices())
{
lastserv = service;
- if (p < args.length && service.serviceType.equalsIgnoreCase(args[p]))
+ if (p >= args.length || service.serviceType.equalsIgnoreCase(args[p]))
{
- break;
- }
- }
- if (lastserv != null)
- {
- List<Preset> prl = null;
- Preset pr = null;
- if (++p < args.length)
- {
- PresetManager prman = lastserv.getPresets();
- if (prman != null)
+ if (lastserv != null)
{
- pr = prman.getPresetByName(args[p]);
- if (pr == null)
+ List<Preset> prl = null;
+ Preset pr = null;
+ if (++p < args.length)
{
- // just grab the last preset.
- prl = prman.getPresets();
+ PresetManager prman = lastserv.getPresets();
+ if (prman != null)
+ {
+ pr = prman.getPresetByName(args[p]);
+ if (pr == null)
+ {
+ // just grab the last preset.
+ prl = prman.getPresets();
+ }
+ }
+ } else {
+ PresetManager prman = lastserv.getPresets();
+ if (prman!=null) {
+ prl = prman.getPresets();
+ }
}
- }
- }
- Iterator<Preset> en = (prl == null) ? null : prl.iterator();
- while (true)
- {
- if (en != null)
- {
- if (!en.hasNext())
+ Iterator<Preset> en = (prl == null) ? null : prl.iterator();
+ while (en!=null && en.hasNext())
{
- en = prl.iterator();
- }
- pr = en.next();
- }
- WsJobParameters pgui = new WsJobParameters(lastserv, pr);
- JFrame jf = new JFrame("Parameters for " + lastserv.getActionText());
- JPanel cont = new JPanel();
- // jf.setPreferredSize(new Dimension(600, 800));
- cont.add(pgui);
- jf.add(cont);
- final Thread thr = Thread.currentThread();
- jf.addWindowListener(new WindowListener()
- {
+ if (en != null)
+ {
+ if (!en.hasNext())
+ {
+ en = prl.iterator();
+ }
+ pr = en.next();
+ }
+ {
+ System.out.println("Testing opts dupes for "+lastserv.getHost()+" : "+lastserv.getActionText()+":"+pr.getName());
+ List<Option> rg = lastserv.getRunnerConfig().getOptions();
+ for (Option o : rg)
+ {
+ try
+ {
+ Option cpy = jalview.ws.jws2.ParameterUtils.copyOption(o);
+ } catch (Exception e)
+ {
+ System.err.println("Failed to copy " + o.getName());
+ e.printStackTrace();
+ } catch (Error e)
+ {
+ System.err.println("Failed to copy " + o.getName());
+ e.printStackTrace();
+ }
+ }
+ }
+ {
+ System.out.println("Testing param dupes:");
+ List<Parameter> rg = lastserv.getRunnerConfig()
+ .getParameters();
+ for (Parameter o : rg)
+ {
+ try
+ {
+ Parameter cpy = jalview.ws.jws2.ParameterUtils
+ .copyParameter(o);
+ } catch (Exception e)
+ {
+ System.err.println("Failed to copy " + o.getName());
+ e.printStackTrace();
+ } catch (Error e)
+ {
+ System.err.println("Failed to copy " + o.getName());
+ e.printStackTrace();
+ }
+ }
+ }
+ WsJobParameters pgui = new WsJobParameters(lastserv, pr);
+ JFrame jf = new JFrame("Parameters for "
+ + lastserv.getActionText());
+ JPanel cont = new JPanel();
+ // jf.setPreferredSize(new Dimension(600, 800));
+ cont.add(pgui);
+ jf.add(cont);
+ final Thread thr = Thread.currentThread();
+ jf.addWindowListener(new WindowListener()
+ {
- public void windowActivated(WindowEvent e)
- {
- // TODO Auto-generated method stub
+ public void windowActivated(WindowEvent e)
+ {
+ // TODO Auto-generated method stub
- }
+ }
- public void windowClosed(WindowEvent e)
- {
- }
+ public void windowClosed(WindowEvent e)
+ {
+ }
- public void windowClosing(WindowEvent e)
- {
- thr.interrupt();
+ public void windowClosing(WindowEvent e)
+ {
+ thr.interrupt();
- }
+ }
- public void windowDeactivated(WindowEvent e)
- {
- // TODO Auto-generated method stub
+ public void windowDeactivated(WindowEvent e)
+ {
+ // TODO Auto-generated method stub
- }
+ }
- public void windowDeiconified(WindowEvent e)
- {
- // TODO Auto-generated method stub
+ public void windowDeiconified(WindowEvent e)
+ {
+ // TODO Auto-generated method stub
- }
+ }
- public void windowIconified(WindowEvent e)
- {
- // TODO Auto-generated method stub
+ public void windowIconified(WindowEvent e)
+ {
+ // TODO Auto-generated method stub
- }
+ }
- public void windowOpened(WindowEvent e)
- {
- // TODO Auto-generated method stub
+ public void windowOpened(WindowEvent e)
+ {
+ // TODO Auto-generated method stub
- }
+ }
- });
- jf.setVisible(true);
- boolean inter = false;
- while (!inter)
- {
- try
- {
- Thread.sleep(10000);
- } catch (Exception e)
- {
- inter = true;
+ });
+ jf.setVisible(true);
+ boolean inter = false;
+ while (!inter)
+ {
+ try
+ {
+ Thread.sleep(10000);
+ } catch (Exception e)
+ {
+ inter = true;
+ }
+ ;
+ }
+ jf.dispose();
}
- ;
}
- jf.dispose();
}
}
}
pset[0] = storeSetName;
pset[1] = descr;
pset[2] = jobParams;
+ //writeParam("Saving " + storeSetName + ": ", jobParams);
+ }
+
+ private void writeParam(String nm, List<Argument> params)
+ {
+ for (Argument p : params)
+ {
+ System.out.println(nm + ":" + System.identityHashCode(p) + " Name: "
+ + p.getName() + " Value: " + p.getDefaultValue());
+ }
}
private Object[] _getUserPreset(String setName)
{
- return editedParams.get(setName);
+ Object[] pset = editedParams.get(setName);
+ //if (pset != null)
+ // writeParam("Retrieving " + setName + ": ", (List<Argument>) pset[2]);
+ return pset;
}
/**
{
settingDialog = true;
syncSetNamesWithStore();
- // updateTable(null,null);
+ // updateTable(null,null); // first reset to defaults
+
Object[] pset = _getUserPreset(nextPreset);
if (pset != null)
{
}
if (curSetName == null || !setname.equals(curSetName))
{
- if (isModified()
- && javax.swing.JOptionPane.showConfirmDialog(this,
- "Parameter set is modifed - save ?",
- "Save changes ?",
- javax.swing.JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
+ settingDialog = true;
+ if (isModified())
{
- savModified_actionPerformed(null);
+ System.out.println("Prompting for "+setname);
+ if (javax.swing.JOptionPane.showConfirmDialog(this,
+ "Parameter set is modifed - save ?", "Save changes ?",
+ javax.swing.JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)
+ {
+ System.out.println("Saving for "+setname);
+ savModified_actionPerformed(null);
+ }
}
reInitDialog(setname);
+
}
}
}
{
// rename any existing records we know about for this set.
String newname = (String) e.getActionCommand();
- String msg=null;
- if (isServicePreset(newname)) {
- JOptionPane.showConfirmDialog(this, "Invalid name - preset already exists.", "Invalid name", JOptionPane.OK_OPTION);
+ String msg = null;
+ if (isServicePreset(newname))
+ {
+ JOptionPane.showConfirmDialog(this,
+ "Invalid name - preset already exists.", "Invalid name",
+ JOptionPane.OK_OPTION);
return;
}
curSetName = newname;