args = paramStore.getServiceParameters();
// split to params and required arguments
{
- for (Argument arg : args)
+ for (ArgumentI myarg : args)
{
- Argument myarg = (Argument) arg;
// Ideally, Argument would implement isRequired !
- if (myarg instanceof Parameter)
+ if (myarg instanceof ParameterI)
{
- Parameter parm = (Parameter) myarg;
+ ParameterI parm = (ParameterI) myarg;
addParameter(parm);
}
else
{
- if (myarg instanceof Option)
+ if (myarg instanceof OptionI)
{
- Option opt = (Option) myarg;
+ OptionI opt = (OptionI) myarg;
addOption(opt).resetToDefault();
}
else
{
System.err.println("Ignoring unknown service argument type "
- + arg.getClass().getName());
+ + myarg.getClass().getName());
}
}
}
@@ -525,14 +617,13 @@ public class WsJobParameters extends JPanel implements ItemListener,
// TODO - URL link
try
{
- args = p.getArguments(serviceOptions);
+ args = p.getArguments();
} catch (Exception e)
{
e.printStackTrace();
}
// TODO: check if args should be unselected prior to resetting using the
// preset
- setargs.clear();
}
else
{
@@ -540,6 +631,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
isUserPreset = false;
// first call - so create a dummy name
+
setName.setSelectedItem(lastSetName = SVC_DEF);
}
}
@@ -552,20 +644,20 @@ public class WsJobParameters extends JPanel implements ItemListener,
// get setargs from current object
if (args != null)
{
- for (Argument arg : args)
+ for (ArgumentI arg : args)
{
- if (arg instanceof Parameter)
+ if (arg instanceof ParameterI)
{
- setParameter((Parameter) arg);
+ setParameter((ParameterI) arg);
}
else
{
- if (arg instanceof Option)
+ if (arg instanceof OptionI)
{
// System.out.println("Setting option "
// + System.identityHashCode(arg) + ":" + arg.getName()
// + " with " + arg.getDefaultValue());
- selectOption((Option) arg, arg.getDefaultValue());
+ selectOption((OptionI) arg, arg.getDefaultValue());
}
}
@@ -574,10 +666,12 @@ public class WsJobParameters extends JPanel implements ItemListener,
jobOptions.setPreferredSize(new Dimension(PARAM_WIDTH, optSet.size()
* OPTSET_HEIGHT));
- jobOptions.setLayout(new GridLayout(optSet.size(), 1));
+ FlowLayout fl;
+ jobOptions.setLayout(fl=new FlowLayout(FlowLayout.LEFT));
+
refreshParamLayout();
paramPane.validate();
- validate();
+ revalidate();
}
private boolean isModified()
@@ -631,19 +725,25 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
return;
}
-
if (!b)
{
modifiedElements.remove(modifiedElement);
}
else
{
+ if (b && modifiedElement == setName
+ && modifiedElements.contains(modifiedElement))
+ {
+ // HACK! prevents iteration on makeSetNameValid
+ b = false;
+ }
modifiedElements.put(modifiedElement, modifiedElement);
}
// set mod status based on presence of elements in table
if (b && modifiedElements.size() > 0)
{
makeSetNameValid(!isUserPreset);
+ SetNamePanel.revalidate();
}
updateButtonDisplay();
}
@@ -663,7 +763,8 @@ public class WsJobParameters extends JPanel implements ItemListener,
boolean stn = settingDialog;
boolean renamed = false;
settingDialog = true;
- String nm = (String) setName.getSelectedItem();
+ String nm = (curSetName != null ? curSetName : (String) setName
+ .getSelectedItem());
// check if the name is reserved - if it is, rename it.
if (isServicePreset(nm))
{
@@ -674,9 +775,10 @@ public class WsJobParameters extends JPanel implements ItemListener,
if (newuserset)
{
int i = 0;
- while (_getUserPreset(tnm) != null)
+ while (paramStore.getPreset(tnm) != null)
{
tnm = nm + " (" + (++i) + ")";
+ renamed = true;
}
if (i > 0)
{
@@ -697,26 +799,32 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
if (!makeupdate)
{
- setName.setSelectedItem(curSetName = nm);
+ setName.addItem(curSetName = nm);
+ setName.setSelectedItem(curSetName);
+ }
+ if (renamed)
+ {
+ settingDialog = false; // we need this name change to be registered.
+ argSetModified(setName, renamed);
}
settingDialog = stn;
}
- private void addParameter(Parameter parm)
+ private void addParameter(ParameterI arg)
{
- ParamBox pb = paramSet.get(parm.getName());
+ ParamBox pb = paramSet.get(arg.getName());
if (pb == null)
{
- pb = new ParamBox(this, parm);
- paramSet.put(parm.getName(), pb);
+ pb = new ParamBox(this, arg);
+ paramSet.put(arg.getName(), pb);
paramList.add(pb);
}
pb.init();
// take the defaults from the parameter
- pb.updateControls(parm);
+ pb.updateControls(arg);
}
- private void setParameter(Parameter arg)
+ private void setParameter(ParameterI arg)
{
ParamBox pb = paramSet.get(arg.getName());
if (pb == null)
@@ -730,27 +838,27 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
- private void selectOption(Option opt, String string)
+ private void selectOption(OptionI option, String string)
{
- OptionBox cb = optSet.get(opt.getName());
+ OptionBox cb = optSet.get(option.getName());
if (cb == null)
{
- cb = addOption(opt);
+ cb = addOption(option);
}
- cb.enabled.setSelected(true); // initial state for an option.
+ cb.enabled.setSelected(string != null); // initial state for an option.
if (string != null)
{
- if (opt.getPossibleValues().contains(string))
+ if (option.getPossibleValues().contains(string))
{
cb.val.setSelectedItem(string);
}
else
{
- throw new Error("Invalid value " + string + " for option " + opt);
+ throw new Error("Invalid value " + string + " for option " + option);
}
}
- if (opt.isRequired() && !cb.enabled.isSelected())
+ if (option.isRequired() && !cb.enabled.isSelected())
{
// TODO: indicate paramset is not valid.. option needs to be selected!
}
@@ -772,7 +880,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
JTextField valueField = null;
- ValueConstrain validator = null;
+ ValueConstrainI validator = null;
JPanel settingPanel = new JPanel();
@@ -788,7 +896,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
final URL finfo;
- public ParamBox(final WsJobParameters pmlayout, Parameter parm)
+ public ParamBox(final WsJobParameters pmlayout, ParameterI parm)
{
pmdialogbox = pmlayout;
setPreferredSize(new Dimension(PARAM_WIDTH, PARAM_CLOSEDHEIGHT));
@@ -809,12 +917,20 @@ public class WsJobParameters extends JPanel implements ItemListener,
finfo = parm.getFurtherDetails();
if (finfo != null)
{
- showDesc.setToolTipText("Click to show brief description, and right click to open link for further information.
");
+ showDesc.setToolTipText(""
+ + JvSwingUtils
+ .wrapTooltip("Click to show brief description
Right click for further information.")
+ + "");
showDesc.addMouseListener(this);
}
else
{
- showDesc.setToolTipText("Click to show brief description.
");
+ showDesc.setToolTipText(""
+ + JvSwingUtils
+ .wrapTooltip("Click to show brief description.")
+ + "");
}
showDesc.addActionListener(new ActionListener()
{
@@ -872,7 +988,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
boolean adjusting = false;
- Parameter parameter;
+ ParameterI parameter;
JComboBox choicebox;
@@ -881,7 +997,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT);
}
- public void updateControls(Parameter parm)
+ public void updateControls(ParameterI parm)
{
adjusting = true;
boolean init = (choicebox == null && valueField == null);
@@ -937,23 +1053,16 @@ public class WsJobParameters extends JPanel implements ItemListener,
Object lastVal;
- public Parameter getParameter()
+ public ParameterI getParameter()
{
- Parameter prm = ParameterUtils.copyParameter(parameter);
- try
+ ParameterI prm = parameter.copy();
+ if (choice)
{
- if (choice)
- {
- prm.setDefaultValue((String) choicebox.getSelectedItem());
- }
- else
- {
- prm.setDefaultValue(valueField.getText());
- }
- } catch (WrongParameterException e)
+ prm.setDefaultValue((String) choicebox.getSelectedItem());
+ }
+ else
{
- e.printStackTrace();
- return null;
+ prm.setDefaultValue(valueField.getText());
}
return prm;
}
@@ -971,6 +1080,20 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
valueField.setText(valueField.getText().trim());
iVal = Integer.valueOf(valueField.getText());
+ if (validator.getMin() != null
+ && validator.getMin().intValue() > iVal)
+ {
+ iVal = validator.getMin().intValue();
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
+ }
+ if (validator.getMax() != null
+ && validator.getMax().intValue() < iVal)
+ {
+ iVal = validator.getMax().intValue();
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
+ }
} catch (Exception e)
{
}
@@ -994,6 +1117,20 @@ public class WsJobParameters extends JPanel implements ItemListener,
try
{
fVal = Float.valueOf(valueField.getText());
+ if (validator.getMin() != null
+ && validator.getMin().floatValue() > fVal)
+ {
+ fVal = validator.getMin().floatValue();
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
+ }
+ if (validator.getMax() != null
+ && validator.getMax().floatValue() < fVal)
+ {
+ fVal = validator.getMax().floatValue();
+ // TODO: provide visual indication that hard limit was reached for
+ // this parameter
+ }
} catch (Exception e)
{
}
@@ -1080,7 +1217,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
if (javax.swing.SwingUtilities.isRightMouseButton(e))
{
- Desktop.showUrl(finfo.toString());
+ showUrlPopUp(this, finfo.toString(), e.getX(), e.getY());
}
}
@@ -1121,15 +1258,13 @@ public class WsJobParameters extends JPanel implements ItemListener,
JLabel optlabel = new JLabel();
- URL linkImageURL = getClass().getResource("/images/link.gif");
-
final URL finfo;
boolean hasLink = false;
- Option option;
+ OptionI option;
- public OptionBox(Option opt)
+ public OptionBox(OptionI opt)
{
option = opt;
setLayout(new BorderLayout());
@@ -1143,15 +1278,19 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
hasLink = true;
// optlabel.setToolTipText(""+opt.getDescription()+"
");
- enabled.setToolTipText("" + opt.getDescription()
- + "
");
+ enabled.setToolTipText(""
+ + JvSwingUtils.wrapTooltip(opt.getDescription()
+ + "
")
+ + "");
// optlabel.addMouseListener(this);
enabled.addMouseListener(this);
}
else
{
// optlabel.setToolTipText(opt.getDescription());
- enabled.setToolTipText(opt.getDescription());
+ enabled.setToolTipText(""
+ + JvSwingUtils.wrapTooltip(opt.getDescription())
+ + "");
}
add(enabled, BorderLayout.NORTH);
if (opt.getPossibleValues().size() > 1)
@@ -1199,26 +1338,19 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
}
- public Option getOptionIfEnabled()
+ public OptionI getOptionIfEnabled()
{
if (!enabled.isSelected())
{
return null;
}
- try
- {
- Option opt = jalview.ws.jws2.ParameterUtils.copyOption(option);
+ OptionI opt = option.copy();
- if (val.getSelectedItem() != null)
- {
- opt.setDefaultValue((String) val.getSelectedItem());
- }
- } catch (WrongParameterException e)
+ if (val.getSelectedItem() != null)
{
- e.printStackTrace();
- return null;
+ opt.setDefaultValue((String) val.getSelectedItem());
}
- return option;
+ return opt;
}
public void actionPerformed(ActionEvent e)
@@ -1237,14 +1369,18 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
if (initVal != null)
{
- notmod |= initVal.equals(val.getSelectedItem());
- } else {
- notmod |= false;
+ notmod &= initVal.equals(val.getSelectedItem());
+ }
+ else
+ {
+ // compare against default service setting
+ notmod &= option.getDefaultValue() == null
+ || option.getDefaultValue().equals(val.getSelectedItem());
}
}
else
{
- notmod |= initVal == null;
+ notmod &= initVal == null;
}
argSetModified(this, !notmod);
}
@@ -1283,7 +1419,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
- private OptionBox addOption(Option opt)
+ private OptionBox addOption(OptionI opt)
{
OptionBox cb = optSet.get(opt.getName());
if (cb == null)
@@ -1317,13 +1453,14 @@ public class WsJobParameters extends JPanel implements ItemListener,
protected void refreshParamLayout()
{
- int s = 100;
+ FlowLayout fl = new FlowLayout();
+ paramList.setLayout(fl);
+ int s = 2 * fl.getVgap();
for (ParamBox pbox : paramSet.values())
{
- s += pbox.getBoxHeight();
+ s += fl.getVgap() + pbox.getBoxHeight(); // getBoxHeight();
}
paramList.setPreferredSize(new Dimension(PARAM_WIDTH, s));
- paramList.setLayout(new FlowLayout());
validate();
}
@@ -1396,7 +1533,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
{
System.out.println("Testing opts dupes for "
- + lastserv.getHost() + " : "
+ + lastserv.getUri() + " : "
+ lastserv.getActionText() + ":" + pr.getName());
List