package jalview.gui;
import jalview.util.MessageManager;
+import jalview.ws.jws2.dm.JabaOption;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.OptionI;
import jalview.ws.params.ParameterI;
JComboBox<String> val;
+ /**
+ * Constructs and adds labels and controls to the panel for one Option
+ *
+ * @param opt
+ */
public OptionBox(OptionI opt)
{
option = opt;
setLayout(new FlowLayout(FlowLayout.LEFT));
- enabled = new JCheckBox();
- enabled.setSelected(opt.isRequired()); // TODO: lock required options
- enabled.setFont(new Font("Verdana", Font.PLAIN, 11));
- enabled.setText("");
- enabled.setText(opt.getName());
- enabled.addActionListener(this);
- finfo = option.getFurtherDetails();
- String desc = opt.getDescription();
- if (finfo != null)
- {
- hasLink = true;
+ enabled = new JCheckBox(opt.getName());
+ enabled.setSelected(opt.isRequired());
- enabled.setToolTipText(JvSwingUtils.wrapTooltip(true,
- ((desc == null || desc.trim().length() == 0)
- ? MessageManager.getString(
- "label.opt_and_params_further_details")
- : desc) + "<br><img src=\"" + linkImageURL
- + "\"/>"));
- enabled.addMouseListener(this);
+ /*
+ * If option is required, show a label, if optional a checkbox
+ * (but not for Jabaws pending JWS-126 resolution)
+ */
+ if (opt.isRequired() && !(opt instanceof JabaOption))
+ {
+ finfo = null;
+ add(new JLabel(opt.getName()));
}
else
{
- if (desc != null && desc.trim().length() > 0)
- {
- enabled.setToolTipText(
- JvSwingUtils.wrapTooltip(true, opt.getDescription()));
- }
+ finfo = option.getFurtherDetails();
+ configureCheckbox(opt);
+ add(enabled);
}
- add(enabled);
- // todo combo or radio buttons?
val = new JComboBox<>();
for (String str : opt.getPossibleValues())
{
val.addActionListener(this);
add(val);
}
- // TODO: add actionListeners for popup (to open further info),
- // and to update list of parameters if an option is enabled
- // that takes a value. JBPNote: is this TODO still valid ?
+
setInitialValue();
}
+ /**
+ * Configures the checkbox that controls whether or not the option is
+ * selected
+ *
+ * @param opt
+ */
+ protected void configureCheckbox(OptionI opt)
+ {
+ enabled.setFont(new Font("Verdana", Font.PLAIN, 11));
+ enabled.addActionListener(this);
+ final String desc = opt.getDescription();
+ if (finfo != null)
+ {
+ hasLink = true;
+ String description = desc;
+ if (desc == null || desc.trim().isEmpty())
+ {
+ description = MessageManager
+ .getString("label.opt_and_params_further_details");
+ }
+ description = description + "<br><img src=\"" + linkImageURL
+ + "\"/>";
+ String text = JvSwingUtils.wrapTooltip(true, description);
+ enabled.setToolTipText(text);
+ enabled.addMouseListener(this); // for popup menu to show link
+ }
+ else
+ {
+ if (desc != null && desc.trim().length() > 0)
+ {
+ enabled.setToolTipText(JvSwingUtils.wrapTooltip(true, desc));
+ }
+ }
+ }
+
@Override
public void actionPerformed(ActionEvent e)
{