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());
}
}
}
@@ -536,14 +606,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
{
@@ -551,6 +620,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
isUserPreset = false;
// first call - so create a dummy name
+
setName.setSelectedItem(lastSetName = SVC_DEF);
}
}
@@ -563,20 +633,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());
}
}
@@ -642,13 +712,18 @@ 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
@@ -675,7 +750,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))
{
@@ -686,10 +762,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;
+ renamed = true;
}
if (i > 0)
{
@@ -715,27 +791,27 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
if (renamed)
{
- settingDialog=false; // we need this name change to be registered.
+ 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)
@@ -749,27 +825,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(string!=null); // 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!
}
@@ -791,7 +867,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
JTextField valueField = null;
- ValueConstrain validator = null;
+ ValueConstrainI validator = null;
JPanel settingPanel = new JPanel();
@@ -807,7 +883,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));
@@ -828,12 +904,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()
{
@@ -891,7 +975,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
boolean adjusting = false;
- Parameter parameter;
+ ParameterI parameter;
JComboBox choicebox;
@@ -900,7 +984,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);
@@ -956,23 +1040,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;
}
@@ -990,6 +1067,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)
{
}
@@ -1013,6 +1104,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)
{
}
@@ -1099,7 +1204,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());
}
}
@@ -1140,15 +1245,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());
@@ -1162,15 +1265,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)
@@ -1218,25 +1325,17 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
}
- public Option getOptionIfEnabled()
+ public OptionI getOptionIfEnabled()
{
if (!enabled.isSelected())
{
return null;
}
- Option opt=null;
- try
- {
- 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 opt;
}
@@ -1258,9 +1357,12 @@ public class WsJobParameters extends JPanel implements ItemListener,
if (initVal != null)
{
notmod &= initVal.equals(val.getSelectedItem());
- } else {
+ }
+ else
+ {
// compare against default service setting
- notmod &= option.getDefaultValue()==null || option.getDefaultValue().equals(val.getSelectedItem());
+ notmod &= option.getDefaultValue() == null
+ || option.getDefaultValue().equals(val.getSelectedItem());
}
}
else
@@ -1304,7 +1406,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)
@@ -1340,10 +1442,10 @@ public class WsJobParameters extends JPanel implements ItemListener,
{
FlowLayout fl = new FlowLayout();
paramList.setLayout(fl);
- int s = 2*fl.getVgap();
+ int s = 2 * fl.getVgap();
for (ParamBox pbox : paramSet.values())
{
- s += fl.getVgap()+pbox.getBoxHeight(); // getBoxHeight();
+ s += fl.getVgap() + pbox.getBoxHeight(); // getBoxHeight();
}
paramList.setPreferredSize(new Dimension(PARAM_WIDTH, s));
validate();
@@ -1418,7 +1520,7 @@ public class WsJobParameters extends JPanel implements ItemListener,
}
{
System.out.println("Testing opts dupes for "
- + lastserv.getHost() + " : "
+ + lastserv.getUri() + " : "
+ lastserv.getActionText() + ":" + pr.getName());
List