X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FOptsAndParamsPage.java;h=577a1ef1d45ebe42f4b76787cec0ca092ae5bfc7;hb=747167089ecf8d6afc70d417f5a20352e029bd95;hp=00c5a926fc7fb7f73298d2394022cf5b66a02604;hpb=85ef061623b5d90777dbf04febaac30f28c0075a;p=jalview.git diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 00c5a92..577a1ef 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -36,7 +36,6 @@ import jalview.ws.params.simple.FileParameter; import jalview.ws.params.simple.LogarithmicParameter; import jalview.ws.params.simple.RadioChoiceParameter; import jalview.ws.params.simple.StringParameter; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -47,6 +46,8 @@ import java.awt.Font; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -126,18 +127,19 @@ public class OptsAndParamsPage OptionI option; - JComboBox val; + JComboBox 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(opt.getName()); + enabled = new JCheckBox(opt.getLabel()); enabled.setSelected(opt.isRequired()); /* @@ -147,7 +149,7 @@ public class OptsAndParamsPage if (opt.isRequired() && !(opt instanceof JabaOption)) { finfo = null; - add(new JLabel(opt.getName())); + add(new JLabel(opt.getLabel())); } else { @@ -190,6 +192,7 @@ public class OptsAndParamsPage if (finfo != null) { hasLink = true; + String description = desc; if (desc == null || desc.trim().isEmpty()) { @@ -275,11 +278,13 @@ public class OptsAndParamsPage @Override public void mouseEntered(MouseEvent e) { + } @Override public void mouseExited(MouseEvent e) { + } @Override @@ -329,7 +334,6 @@ public class OptsAndParamsPage { return option == null ? super.toString() : option.toString(); } - } /** @@ -357,7 +361,7 @@ public class OptsAndParamsPage /* * drop-down list of choice options (if applicable) */ - JComboBox choicebox; + JComboBox choicebox; /* * radio buttons as an alternative to combo box @@ -397,9 +401,7 @@ public class OptsAndParamsPage finfo = parm.getFurtherDetails(); validator = parm.getValidValue(); parameter = parm; - isLogarithmicParameter = parm instanceof LogarithmicParameter; - if (validator != null) { ValueType type = validator.getType(); @@ -438,6 +440,7 @@ public class OptsAndParamsPage else { addExpandableParam(parm); + } } @@ -449,6 +452,7 @@ public class OptsAndParamsPage private void addCompactParameter(ParameterI parm) { setLayout(new MigLayout("", "[][grow]")); + String ttipText = null; controlsPanel.setLayout(new BorderLayout()); @@ -498,6 +502,7 @@ public class OptsAndParamsPage firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30, PARAM_CLOSEDHEIGHT - 30)); + if (parm.getDescription() != null && parm.getDescription().trim().length() > 0) { @@ -574,7 +579,6 @@ public class OptsAndParamsPage showDescBtn.setBounds(new Rectangle(10, 10, 16, 16)); container.add(showDescBtn); } - @Override public void actionPerformed(ActionEvent e) { @@ -600,6 +604,7 @@ public class OptsAndParamsPage pmdialogbox.argSetModified(this, modified); } + @Override public int getBaseline(int width, int height) { @@ -638,7 +643,6 @@ public class OptsAndParamsPage value = valueField.getText(); } prm.setValue(value); - return prm; } @@ -660,11 +664,13 @@ public class OptsAndParamsPage @Override public void mouseEntered(MouseEvent e) { + } @Override public void mouseExited(MouseEvent e) { + } @Override @@ -679,6 +685,7 @@ public class OptsAndParamsPage @Override public void mouseReleased(MouseEvent e) { + } @Override @@ -765,6 +772,8 @@ public class OptsAndParamsPage valueField.addActionListener(this); valueField.addKeyListener(new KeyAdapter() { + + @Override public void keyReleased(KeyEvent e) { @@ -778,6 +787,16 @@ public class OptsAndParamsPage } } } + + }); + valueField.addFocusListener(new FocusAdapter() { + + @Override + public void focusLost(FocusEvent e) + { + actionPerformed(null); + } + }); valueField.setPreferredSize(new Dimension(65, 25)); if (parm instanceof FileParameter) @@ -903,6 +922,11 @@ public class OptsAndParamsPage return valueField.getText().trim(); } + if (validator.getMin() == null || validator.getMax() == null) + { + slider.setVisible(false); + } + valueField.setText(valueField.getText().trim()); /* @@ -928,7 +952,6 @@ public class OptsAndParamsPage valueField.setBackground(Color.yellow); return Float.NaN; } - if (isIntegerParameter) { int iVal = 0; @@ -951,16 +974,15 @@ public class OptsAndParamsPage { slider.setVisible(false); } - return new Integer(iVal); + return Integer.valueOf(iVal); } - if (isLogarithmicParameter) { double dVal = 0d; try { double eValue = Double.valueOf(valueField.getText()); - dVal = Math.log(eValue) * sliderScaleFactor; + dVal = Math.log(eValue); } catch (Exception e) { // shouldn't be possible here @@ -973,16 +995,16 @@ public class OptsAndParamsPage * sliderScaleFactor; double scaleMax = Math.log(validator.getMax().doubleValue()) * sliderScaleFactor; - slider.getModel().setRangeProperties((int) (dVal), 1, + slider.getModel().setRangeProperties( + (int) (sliderScaleFactor * dVal), 1, (int) scaleMin, 1 + (int) scaleMax, true); } else { slider.setVisible(false); } - return new Double(dVal); + return Double.valueOf(dVal); } - float fVal = 0f; try { @@ -1005,7 +1027,7 @@ public class OptsAndParamsPage { slider.setVisible(false); } - return new Float(fVal); + return Float.valueOf(fVal); } } @@ -1017,6 +1039,7 @@ public class OptsAndParamsPage * * @param paramContainer */ + public OptsAndParamsPage(OptsParametersContainerI paramContainer, boolean compact) { @@ -1046,6 +1069,7 @@ public class OptsAndParamsPage mnu.show(invoker, x, y); } + public Map getOptSet() { return optSet; @@ -1066,6 +1090,7 @@ public class OptsAndParamsPage this.paramSet = paramSet; } + OptionBox addOption(OptionI opt) { OptionBox cb = optSet.get(opt.getName()); @@ -1109,9 +1134,11 @@ public class OptsAndParamsPage } else { - throw new Error(String.format("Invalid value '%s' for option '%s'", - string, option.getName())); + throw new Error(MessageManager.formatMessage( + "error.invalid_value_for_option", new String[] + { string, option.getName() })); } + } if (option.isRequired() && !cb.enabled.isSelected()) { @@ -1172,13 +1199,15 @@ public class OptsAndParamsPage * @param opt * @return */ - protected static JComboBox buildComboBox(OptionI opt) + protected static JComboBox buildComboBox(OptionI opt) { - JComboBox cb = null; + JComboBox cb = null; List displayNames = opt.getDisplayNames(); if (displayNames != null) { - cb = JvSwingUtils.buildComboWithTooltips(displayNames, + List displayNamesObjects = new ArrayList<>(); + displayNamesObjects.addAll(displayNames); + cb = JvSwingUtils.buildComboWithTooltips(displayNamesObjects, opt.getPossibleValues()); } else