From e8681d11026ff970970e86acd75ecaa2388c1a7a Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 20 Apr 2018 10:05:08 +0100 Subject: [PATCH] JAL-591 OptionBox FlowLayout, tweaks to wrapping of options and params --- src/jalview/gui/OptsAndParamsPage.java | 521 ++++++++++---------- src/jalview/gui/WsJobParameters.java | 328 +++++------- src/jalview/ws/jws2/Jws2Client.java | 12 +- src/jalview/ws/params/simple/DoubleParameter.java | 29 +- src/jalview/ws/params/simple/IntegerParameter.java | 23 +- .../ws/params/simple/LogarithmicParameter.java | 4 +- src/jalview/ws/params/simple/Option.java | 32 +- test/jalview/ws/gui/Jws2ParamView.java | 17 +- 8 files changed, 466 insertions(+), 500 deletions(-) diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 3e09a35..0d12347 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -22,6 +22,7 @@ package jalview.gui; import static jalview.ws.params.simple.LogarithmicParameter.LOGSLIDERSCALE; +import jalview.bin.Cache; import jalview.util.MessageManager; import jalview.ws.params.ArgumentI; import jalview.ws.params.OptionI; @@ -29,12 +30,13 @@ import jalview.ws.params.ParameterI; import jalview.ws.params.ValueConstrainI; import jalview.ws.params.ValueConstrainI.ValueType; import jalview.ws.params.simple.LogarithmicParameter; +import jalview.ws.params.simple.StringParameter; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Font; -import java.awt.GridLayout; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -120,9 +122,8 @@ public class OptsAndParamsPage public OptionBox(OptionI opt) { option = opt; - setLayout(new BorderLayout()); + setLayout(new FlowLayout(FlowLayout.LEFT)); enabled.setSelected(opt.isRequired()); // TODO: lock required options - // enabled.setEnabled(!opt.isRequired()); enabled.setFont(new Font("Verdana", Font.PLAIN, 11)); enabled.setText(""); enabled.setText(opt.getName()); @@ -149,17 +150,16 @@ public class OptsAndParamsPage JvSwingUtils.wrapTooltip(true, opt.getDescription())); } } - add(enabled, BorderLayout.NORTH); + add(enabled); for (String str : opt.getPossibleValues()) { val.addItem(str); } val.setSelectedItem(opt.getValue()); - if (opt.getPossibleValues().size() > 1) + if (opt.getPossibleValues().size() > 1 || opt.isRequired()) { - setLayout(new GridLayout(1, 2)); val.addActionListener(this); - add(val, BorderLayout.SOUTH); + add(val); } // TODO: add actionListeners for popup (to open further info), // and to update list of parameters if an option is enabled @@ -241,15 +241,11 @@ public class OptsAndParamsPage @Override public void mouseEntered(MouseEvent e) { - // TODO Auto-generated method stub - } @Override public void mouseExited(MouseEvent e) { - // TODO Auto-generated method stub - } @Override @@ -291,6 +287,15 @@ public class OptsAndParamsPage } } + /** + * toString representation for identification in the debugger only + */ + @Override + public String toString() + { + return option == null ? super.toString() : option.toString(); + } + } /** @@ -301,24 +306,24 @@ public class OptsAndParamsPage { private static final float SLIDERSCALE = 1000f; - boolean isLogarithmic; + boolean isLogarithmicParameter; + + boolean isChoiceParameter; - boolean adjusting = false; + boolean isIntegerParameter; - boolean choice = false; + boolean adjusting; JComboBox choicebox; - JPanel controlPanel = new JPanel(); + JPanel controlsPanel = new JPanel(); - boolean descisvisible = false; + boolean descriptionIsVisible = false; JScrollPane descPanel = new JScrollPane(); final URL finfo; - boolean integ = false; - Object lastVal; ParameterI parameter; @@ -327,62 +332,61 @@ public class OptsAndParamsPage JPanel settingPanel = new JPanel(); - JButton showDesc = new JButton(); + JSlider slider; - JSlider slider = null; + JTextArea descriptionText = new JTextArea(); - JTextArea string = new JTextArea(); + ValueConstrainI validator; - ValueConstrainI validator = null; + JTextField valueField; - JTextField valueField = null; + private String descTooltip; - public ParamBox(final OptsParametersContainerI pmlayout, + public ParamBox(final OptsParametersContainerI paramContainer, ParameterI parm) { - pmdialogbox = pmlayout; + pmdialogbox = paramContainer; finfo = parm.getFurtherDetails(); validator = parm.getValidValue(); parameter = parm; if (validator != null) { - integ = validator.getType() == ValueType.Integer; + isIntegerParameter = validator.getType() == ValueType.Integer; } - else + else if (parameter.getPossibleValues() != null) { - if (parameter.getPossibleValues() != null) - { - choice = true; - } + isChoiceParameter = true; } if (parm instanceof LogarithmicParameter) { - isLogarithmic = true; + isLogarithmicParameter = true; } - if (!compact) + if (compact) { - makeExpanderParam(parm); + addCompactParameter(parm); } else { - makeCompactParam(parm); - + addExpandableParam(parm); } } - private void makeCompactParam(ParameterI parm) + /** + * Adds a 'compact' format parameter, with any help text shown as a tooltip + * + * @param parm + */ + private void addCompactParameter(ParameterI parm) { setLayout(new MigLayout("", "[][grow]")); - String ttipText = null; - controlPanel.setLayout(new BorderLayout()); + controlsPanel.setLayout(new BorderLayout()); if (parm.getDescription() != null && parm.getDescription().trim().length() > 0) { - // Only create description boxes if there actually is a description. ttipText = (JvSwingUtils.wrapTooltip(true, parm.getDescription() + (finfo != null ? "
" @@ -391,91 +395,57 @@ public class OptsAndParamsPage : ""))); } - JvSwingUtils.mgAddtoLayout(this, ttipText, new JLabel(parm.getName()), - controlPanel, ""); + JvSwingUtils.addtoLayout(this, ttipText, new JLabel(parm.getName()), + controlsPanel, ""); updateControls(parm); validate(); } - private void makeExpanderParam(ParameterI parm) + /** + * Adds an 'expanded' format parameter, with any help shown in a panel that + * may be shown or hidden + * + * @param parm + */ + private void addExpandableParam(ParameterI parm) { setPreferredSize(new Dimension(PARAM_WIDTH, PARAM_CLOSEDHEIGHT)); setBorder(new TitledBorder(parm.getName())); setLayout(null); - showDesc.setFont(new Font("Verdana", Font.PLAIN, 6)); - showDesc.setText("+"); - string.setFont(new Font("Verdana", Font.PLAIN, 11)); - string.setBackground(getBackground()); + descriptionText.setFont(new Font("Verdana", Font.PLAIN, 11)); + descriptionText.setBackground(getBackground()); - string.setEditable(false); - descPanel.getViewport().setView(string); + descriptionText.setEditable(false); + descPanel.getViewport().setView(descriptionText); descPanel.setVisible(false); JPanel firstrow = new JPanel(); firstrow.setLayout(null); - controlPanel.setLayout(new BorderLayout()); - controlPanel.setBounds(new Rectangle(39, 10, PARAM_WIDTH - 70, + controlsPanel.setLayout(new BorderLayout()); + controlsPanel.setBounds(new Rectangle(39, 10, PARAM_WIDTH - 70, PARAM_CLOSEDHEIGHT - 50)); - firstrow.add(controlPanel); + firstrow.add(controlsPanel); firstrow.setBounds(new Rectangle(10, 20, PARAM_WIDTH - 30, PARAM_CLOSEDHEIGHT - 30)); - final ParamBox me = this; - if (parm.getDescription() != null && parm.getDescription().trim().length() > 0) { - // Only create description boxes if there actually is a description. - if (finfo != null) - { - showDesc.setToolTipText(JvSwingUtils.wrapTooltip(true, - MessageManager.formatMessage( - "label.opt_and_params_show_brief_desc_image_link", - new String[] - { linkImageURL.toExternalForm() }))); - showDesc.addMouseListener(this); - } - else - { - showDesc.setToolTipText( - JvSwingUtils.wrapTooltip(true, MessageManager.getString( - "label.opt_and_params_show_brief_desc"))); - } - showDesc.addActionListener(new ActionListener() - { - - @Override - public void actionPerformed(ActionEvent e) - { - descisvisible = !descisvisible; - descPanel.setVisible(descisvisible); - descPanel.getVerticalScrollBar().setValue(0); - me.setPreferredSize(new Dimension(PARAM_WIDTH, - (descisvisible) ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT)); - me.validate(); - pmdialogbox.refreshParamLayout(); - } - }); - string.setWrapStyleWord(true); - string.setLineWrap(true); - string.setColumns(32); - string.setText(parm.getDescription()); - showDesc.setBounds(new Rectangle(10, 10, 16, 16)); - firstrow.add(showDesc); + addExpandableHelp(firstrow, parm); } add(firstrow); validator = parm.getValidValue(); parameter = parm; if (validator != null) { - integ = validator.getType() == ValueType.Integer; + isIntegerParameter = validator.getType() == ValueType.Integer; } else { if (parameter.getPossibleValues() != null) { - choice = true; + isChoiceParameter = true; } } updateControls(parm); @@ -485,6 +455,57 @@ public class OptsAndParamsPage validate(); } + /** + * Adds a button which can be clicked to show or hide help text + * + * @param container + * @param param + */ + protected void addExpandableHelp(JPanel container, ParameterI param) + { + JButton showDescBtn = new JButton("+"); + showDescBtn.setFont(new Font("Verdana", Font.PLAIN, 8)); + if (finfo != null) + { + descTooltip = JvSwingUtils.wrapTooltip(true, + MessageManager.formatMessage( + "label.opt_and_params_show_brief_desc_image_link", + new String[] + { linkImageURL.toExternalForm() })); + showDescBtn.addMouseListener(this); + } + else + { + descTooltip = JvSwingUtils.wrapTooltip(true, MessageManager + .getString("label.opt_and_params_show_brief_desc")); + } + showDescBtn.setToolTipText(descTooltip); + showDescBtn.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + descriptionIsVisible = !descriptionIsVisible; + showDescBtn.setText(descriptionIsVisible ? "-" : "+"); + showDescBtn.setToolTipText( + descriptionIsVisible ? null : descTooltip); + descPanel.setVisible(descriptionIsVisible); + descPanel.getVerticalScrollBar().setValue(0); + ParamBox.this.setPreferredSize(new Dimension(PARAM_WIDTH, + (descriptionIsVisible) ? PARAM_HEIGHT + : PARAM_CLOSEDHEIGHT)); + ParamBox.this.validate(); + pmdialogbox.refreshParamLayout(); + } + }); + descriptionText.setWrapStyleWord(true); + descriptionText.setLineWrap(true); + descriptionText.setColumns(32); + descriptionText.setText(param.getDescription()); + showDescBtn.setBounds(new Rectangle(10, 10, 16, 16)); + container.add(showDescBtn); + } + @Override public void actionPerformed(ActionEvent e) { @@ -492,33 +513,26 @@ public class OptsAndParamsPage { return; } - if (!choice) + if (!isChoiceParameter) { updateSliderFromValueField(); } checkIfModified(); } + /** + * Checks whether the value of this parameter has been changed and notifies + * the parent page accordingly + */ private void checkIfModified() { - Object cstate = updateSliderFromValueField(); - boolean notmod = false; - if (cstate.getClass() == lastVal.getClass()) + Object newValue = updateSliderFromValueField(); + boolean modified = true; + if (newValue.getClass() == lastVal.getClass()) { - if (cstate instanceof int[]) - { - notmod = (((int[]) cstate)[0] == ((int[]) lastVal)[0]); - } - else if (cstate instanceof float[]) - { - notmod = (((float[]) cstate)[0] == ((float[]) lastVal)[0]); - } - else if (cstate instanceof String[]) - { - notmod = (((String[]) cstate)[0].equals(((String[]) lastVal)[0])); - } + modified = !newValue.equals(lastVal); } - pmdialogbox.argSetModified(this, !notmod); + pmdialogbox.argSetModified(this, modified); } @Override @@ -536,15 +550,10 @@ public class OptsAndParamsPage return Component.BaselineResizeBehavior.CONSTANT_ASCENT; } - public int getBoxHeight() - { - return (descisvisible ? PARAM_HEIGHT : PARAM_CLOSEDHEIGHT); - } - public ParameterI getParameter() { ParameterI prm = parameter.copy(); - if (choice) + if (isChoiceParameter) { prm.setValue((String) choicebox.getSelectedItem()); } @@ -605,12 +614,12 @@ public class OptsAndParamsPage { if (!adjusting) { - if (!isLogarithmic) + if (!isLogarithmicParameter) { /* * set (int or float formatted) text field value */ - valueField.setText(integ ? String.valueOf(slider.getValue()) + valueField.setText(isIntegerParameter ? String.valueOf(slider.getValue()) : String.valueOf(slider.getValue() / SLIDERSCALE)); } else @@ -631,29 +640,30 @@ public class OptsAndParamsPage * @param value * @return */ - public String formatDouble(double value) + String formatDouble(double value) { String format = value < 0.001 ? "%3.3e" : "%3.3f"; return String.format(format, value); } - public void updateControls(ParameterI parm) + void updateControls(ParameterI parm) { adjusting = true; boolean init = (choicebox == null && valueField == null); if (init) { - if (choice) + if (isChoiceParameter) { choicebox = new JComboBox<>(); choicebox.addActionListener(this); - controlPanel.add(choicebox, BorderLayout.CENTER); + controlsPanel.add(choicebox, BorderLayout.CENTER); } else { slider = new JSlider(); slider.addChangeListener(this); - valueField = new JTextField(); + int cols = parm instanceof StringParameter ? 20 : 0; + valueField = new JTextField(cols); valueField.addActionListener(this); valueField.addKeyListener(new KeyAdapter() { @@ -669,15 +679,15 @@ public class OptsAndParamsPage } } }); - valueField.setPreferredSize(new Dimension(80, 25)); - controlPanel.add(slider, BorderLayout.WEST); - controlPanel.add(valueField, BorderLayout.EAST); + valueField.setPreferredSize(new Dimension(60, 25)); + controlsPanel.add(slider, BorderLayout.WEST); + controlsPanel.add(valueField, BorderLayout.EAST); } } if (parm != null) { - if (choice) + if (isChoiceParameter) { if (init) { @@ -712,163 +722,171 @@ public class OptsAndParamsPage adjusting = false; } - public Object updateSliderFromValueField() + /** + * Action depends on the type of the input parameter: + * + * Answers the (possibly modified) input value, as a String, Integer, Float + * or Double. + * + * @return + */ + Object updateSliderFromValueField() { - int iVal; - float fVal; - double dVal; - if (validator != null) + if (validator == null) { - if (integ) + if (!isChoiceParameter) { - iVal = 0; - try - { - 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) - { - System.err.println(e.getMessage()); - } - // update value field to reflect any bound checking we performed. - valueField.setText("" + iVal); - if (validator.getMin() != null && validator.getMax() != null) + slider.setVisible(false); + return valueField.getText().trim(); + } + else + { + return choicebox.getSelectedItem(); + } + } + if (isIntegerParameter) + { + int iVal = 0; + try + { + valueField.setText(valueField.getText().trim()); + iVal = Integer.valueOf(valueField.getText()); + + /* + * ensure not outside min-max range + * TODO: provide some visual indicator if limit reached + */ + if (validator.getMin() != null + && validator.getMin().intValue() > iVal) { - slider.getModel().setRangeProperties(iVal, 1, - validator.getMin().intValue(), - validator.getMax().intValue() + 1, true); + iVal = validator.getMin().intValue(); + valueField.setText(String.valueOf(iVal)); } - else + if (validator.getMax() != null + && validator.getMax().intValue() < iVal) { - slider.setVisible(false); + iVal = validator.getMax().intValue(); + valueField.setText(String.valueOf(iVal)); } - return new int[] { iVal }; - } - else if (isLogarithmic) + } catch (Exception e) { - dVal = 0d; - try - { - valueField.setText(valueField.getText().trim()); - double eValue = Double.valueOf(valueField.getText()); + Cache.log.error(e.getMessage()); + } - dVal = Math.log(eValue) / Math - .log(((LogarithmicParameter) parameter).getBase()) - * LOGSLIDERSCALE; + if (validator.getMin() != null && validator.getMax() != null) + { + slider.getModel().setRangeProperties(iVal, 1, + validator.getMin().intValue(), + validator.getMax().intValue() + 1, true); + } + else + { + slider.setVisible(false); + } + return new Integer(iVal); + } + else if (isLogarithmicParameter) + { + double dVal = 0d; + try + { + valueField.setText(valueField.getText().trim()); + double eValue = Double.valueOf(valueField.getText()); - if (validator.getMin() != null - && validator.getMin().doubleValue() > dVal) - { - dVal = validator.getMin().doubleValue(); - // TODO: provide visual indication that hard limit was reached for - // this parameter - // update value field to reflect any bound checking we performed. - valueField.setText(formatDouble(eValue)); - } - if (validator.getMax() != null - && validator.getMax().doubleValue() < dVal) - { - dVal = validator.getMax().doubleValue(); - // TODO: provide visual indication that hard limit was reached for - // this parameter - // update value field to reflect any bound checking we performed. - valueField.setText(formatDouble(eValue)); - } - } catch (Exception e) - { - } + dVal = Math.log(eValue) + / Math.log(((LogarithmicParameter) parameter).getBase()) + * LOGSLIDERSCALE; - if (validator.getMin() != null && validator.getMax() != null) + /* + * ensure not outside min-max range + * TODO: provide some visual indicator if limit reached + */ + if (validator.getMin() != null + && validator.getMin().doubleValue() > dVal) { - slider.getModel().setRangeProperties((int) (dVal), 1, - (int) (validator.getMin().doubleValue()), - 1 + (int) (validator.getMax().doubleValue()), - true); + dVal = validator.getMin().doubleValue(); + valueField.setText(formatDouble(eValue)); } - else + if (validator.getMax() != null + && validator.getMax().doubleValue() < dVal) { - slider.setVisible(false); + dVal = validator.getMax().doubleValue(); + valueField.setText(formatDouble(eValue)); } - return new double[] { dVal }; + } catch (Exception e) + { + } + + if (validator.getMin() != null && validator.getMax() != null) + { + slider.getModel().setRangeProperties((int) (dVal), 1, + (int) (validator.getMin().doubleValue()), + 1 + (int) (validator.getMax().doubleValue()), true); } else { - fVal = 0f; - try - { - valueField.setText(valueField.getText().trim()); - 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 - // update value field to reflect any bound checking we performed. - valueField.setText("" + fVal); - } - if (validator.getMax() != null - && validator.getMax().floatValue() < fVal) - { - fVal = validator.getMax().floatValue(); - // TODO: provide visual indication that hard limit was reached for - // this parameter - // update value field to reflect any bound checking we performed. - valueField.setText("" + fVal); - } - } catch (Exception e) - { - } + slider.setVisible(false); + } + return new Double(dVal); + } + else + { + float fVal = 0f; + try + { + valueField.setText(valueField.getText().trim()); + fVal = Float.valueOf(valueField.getText()); - if (validator.getMin() != null && validator.getMax() != null) + /* + * ensure not outside min-max range + * TODO: provide some visual indicator if limit reached + */ + if (validator.getMin() != null + && validator.getMin().floatValue() > fVal) { - slider.getModel().setRangeProperties((int) (fVal * SLIDERSCALE), 1, - (int) (validator.getMin().floatValue() * SLIDERSCALE), - 1 + (int) (validator.getMax().floatValue() * SLIDERSCALE), - true); + fVal = validator.getMin().floatValue(); + valueField.setText(String.valueOf(fVal)); } - else + if (validator.getMax() != null + && validator.getMax().floatValue() < fVal) { - slider.setVisible(false); + fVal = validator.getMax().floatValue(); + valueField.setText(String.valueOf(fVal)); } - return new float[] { fVal }; + } catch (Exception e) + { } - } - else - { - if (!choice) + + if (validator.getMin() != null && validator.getMax() != null) { - slider.setVisible(false); - return new String[] { valueField.getText().trim() }; + slider.getModel().setRangeProperties((int) (fVal * SLIDERSCALE), + 1, (int) (validator.getMin().floatValue() * SLIDERSCALE), + 1 + (int) (validator.getMax().floatValue() * SLIDERSCALE), + true); } else { - return new String[] { (String) choicebox.getSelectedItem() }; + slider.setVisible(false); } + return new Float(fVal); } - } } - public OptsAndParamsPage(OptsParametersContainerI paramContainer) - { - this(paramContainer, false); - } - + /** + * Constructor with the option to show 'compact' format (parameter description + * as tooltip) or 'expanded' format (parameter description in a textbox which + * may be opened or closed). Use compact for simple description text, expanded + * for more wordy or formatted text. + * + * @param paramContainer + */ public OptsAndParamsPage(OptsParametersContainerI paramContainer, boolean compact) { @@ -1013,5 +1031,4 @@ public class OptsAndParamsPage return argSet; } - } diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index bf97b6a..a1fcc6f 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -50,7 +50,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; -import java.net.URL; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -63,7 +62,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.border.TitledBorder; import javax.swing.event.DocumentEvent; @@ -74,7 +72,6 @@ import compbio.metadata.Option; import compbio.metadata.Parameter; import compbio.metadata.Preset; import compbio.metadata.PresetManager; -import compbio.metadata.RunnerConfig; import net.miginfocom.swing.MigLayout; /** @@ -99,36 +96,29 @@ public class WsJobParameters extends JPanel implements ItemListener, private static final int DEFAULT_HEIGHT = 640; - URL linkImageURL = getClass().getResource("/images/link.gif"); + // the default parameter set shown to the user + private static final String SVC_DEF = "Defaults"; - private static final String SVC_DEF = "Defaults"; // this is the null - // parameter set as shown to - // user + private int maxOptWidth = 200; - /** - * manager for options and parameters. + // URL linkImageURL = getClass().getResource("/images/link.gif"); + + /* + * controller for options and parameters layout */ - OptsAndParamsPage opanp = new OptsAndParamsPage(this); + OptsAndParamsPage opanp; - /** + /* * panel containing job options */ - JPanel jobOptions = new JPanel(); + JPanel optionsPanel = new JPanel(); - /** + /* * panel containing job parameters */ - JPanel paramList = new JPanel(); - - JPanel SetNamePanel = new JPanel(); - - JPanel setDetails = new JPanel(); - - JSplitPane settingsPanel = new JSplitPane(); - - JPanel jobPanel = new JPanel(); + JPanel paramsPanel = new JPanel(); - JScrollPane jobOptionsPane = new JScrollPane(); + JPanel setNamePanel = new JPanel(); JButton createpref = new JButton(); @@ -138,61 +128,52 @@ public class WsJobParameters extends JPanel implements ItemListener, JButton updatepref = new JButton(); - JButton startjob = new JButton(); - - JButton canceljob = new JButton(); - - JComboBox setName = new JComboBox(); + JComboBox setName = new JComboBox<>(); JTextArea setDescr = new JTextArea(); JScrollPane paramPane = new JScrollPane(); - // ScrollablePanel optsAndparams = new ScrollablePanel(); - JPanel optsAndparams = new JPanel(); + ParamDatastoreI paramStore; - RunnerConfig serviceOptions; + // set true when 'Start Job' is clicked + boolean startJob = false; - ParamDatastoreI paramStore; + JDialog frame = null; - private int MAX_OPTWIDTH = 200; + Jws2Instance service; - WsJobParameters(Jws2Instance service) - { - this(service, null); - } + /* + * list of service presets in the gui + */ + Hashtable servicePresets = null; + + /* + * set if dialog is being set - so handlers will avoid spurious events + */ + boolean settingDialog = false; + + private Hashtable modifiedElements = new Hashtable<>(); + + String lastParmSet = null; public WsJobParameters(ParamDatastoreI store, WsParamSetI preset, List args) { super(); + + // parameters dialog in 'compact' format (help as tooltips) + opanp = new OptsAndParamsPage(this, true); jbInit(); this.paramStore = store; this.service = null; - // argSetModified(false); - // populate parameter table init(preset, args); - // display in new JFrame attached to parent. validate(); } - public WsJobParameters(Jws2Instance service, WsParamSetI preset) - { - this(service, preset, null); - } - - /** - * - * @param service - * @param preset - */ - public WsJobParameters(Jws2Instance service, - WsParamSetI preset, List jobArgset) - { - this(null, service, preset, jobArgset); - } - /** + * Constructor given a set of parameters and presets, a service to be invoked, + * and a list of (Jabaws client) arguments * * @param paramStorei * @param service @@ -203,6 +184,10 @@ public class WsJobParameters extends JPanel implements ItemListener, WsParamSetI preset, List jobArgset) { super(); + + // parameters dialog in 'expanded' format (help text boxes) + opanp = new OptsAndParamsPage(this, false); + jbInit(); this.paramStore = paramStorei; if (paramStore == null && service != null) @@ -210,19 +195,13 @@ public class WsJobParameters extends JPanel implements ItemListener, paramStore = service.getParamStore(); } this.service = service; - // argSetModified(false); - // populate parameter table initForService(preset, jobArgset); - // display in new JFrame attached to parent. validate(); } - int response = -1; - - JDialog frame = null; - /** - * shows a modal dialog containing the parameters. + * Shows a modal dialog containing the parameters and Start or Cancel options. + * Answers true if the job is started, false if cancelled. * * @return */ @@ -259,11 +238,7 @@ public class WsJobParameters extends JPanel implements ItemListener, }); frame.setVisible(true); - if (response > 0) - { - return true; - } - return false; + return startJob; } private void jbInit() @@ -293,7 +268,7 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void actionPerformed(ActionEvent e) { - update_actionPerformed(e); + update_actionPerformed(); } }); deletepref = JvSwingUtils.makeButton( @@ -305,7 +280,7 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void actionPerformed(ActionEvent e) { - delete_actionPerformed(e); + delete_actionPerformed(); } }); createpref = JvSwingUtils.makeButton( @@ -317,7 +292,7 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void actionPerformed(ActionEvent e) { - create_actionPerformed(e); + create_actionPerformed(); } }); revertpref = JvSwingUtils.makeButton( @@ -330,10 +305,11 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void actionPerformed(ActionEvent e) { - revert_actionPerformed(e); + revert_actionPerformed(); } }); - startjob = JvSwingUtils.makeButton( + + JButton startjob = JvSwingUtils.makeButton( MessageManager.getString("action.start_job"), MessageManager.getString("label.start_job_current_settings"), new ActionListener() @@ -341,10 +317,10 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void actionPerformed(ActionEvent e) { - startjob_actionPerformed(e); + startjob_actionPerformed(); } }); - canceljob = JvSwingUtils.makeButton( + JButton canceljob = JvSwingUtils.makeButton( MessageManager.getString("action.cancel_job"), MessageManager.getString("label.cancel_job_close_dialog"), new ActionListener() @@ -352,10 +328,11 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void actionPerformed(ActionEvent e) { - canceljob_actionPerformed(e); + canceljob_actionPerformed(); } }); + JPanel setDetails = new JPanel(); setDetails.setBorder( new TitledBorder(MessageManager.getString("label.details"))); setDetails.setLayout(new BorderLayout()); @@ -374,7 +351,7 @@ public class WsJobParameters extends JPanel implements ItemListener, setName.getEditor().addActionListener(this); JPanel setNameInfo = new JPanel(new FlowLayout(FlowLayout.LEFT)); GridBagLayout gbl = new GridBagLayout(); - SetNamePanel.setLayout(gbl); + setNamePanel.setLayout(gbl); JLabel setNameLabel = new JLabel( MessageManager.getString("label.current_parameter_set_name")); @@ -389,9 +366,7 @@ public class WsJobParameters extends JPanel implements ItemListener, revertpref.setVisible(false); createpref.setVisible(false); JPanel setsavebuts = new JPanel(); - setsavebuts.setLayout(new FlowLayout(FlowLayout.LEFT)); // GridLayout(1,2)); - ((FlowLayout) setsavebuts.getLayout()).setHgap(10); - ((FlowLayout) setsavebuts.getLayout()).setVgap(0); + setsavebuts.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0)); // GridLayout(1,2)); JPanel spacer = new JPanel(); spacer.setPreferredSize(new Dimension(2, 30)); setsavebuts.add(spacer); @@ -402,11 +377,11 @@ public class WsJobParameters extends JPanel implements ItemListener, // setsavebuts.setSize(new Dimension(150, 30)); JPanel buttonArea = new JPanel(new GridLayout(1, 1)); buttonArea.add(setsavebuts); - SetNamePanel.add(setNameInfo); + setNamePanel.add(setNameInfo); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridheight = 2; gbl.setConstraints(setNameInfo, gbc); - SetNamePanel.add(buttonArea); + setNamePanel.add(buttonArea); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; @@ -416,36 +391,33 @@ public class WsJobParameters extends JPanel implements ItemListener, // paramPane.setPreferredSize(new Dimension(360, 400)); // paramPane.setPreferredSize(null); - jobOptions.setBorder( + optionsPanel.setBorder( new TitledBorder(MessageManager.getString("label.options"))); - jobOptions.setOpaque(true); - paramList.setBorder( + optionsPanel.setOpaque(true); + paramsPanel.setBorder( new TitledBorder(MessageManager.getString("label.parameters"))); - paramList.setOpaque(true); - JPanel bjo = new JPanel(new BorderLayout()); - JPanel bjp = new JPanel(new BorderLayout()); - bjo.add(jobOptions, BorderLayout.CENTER); - bjp.add(paramList, BorderLayout.CENTER); - bjp.setOpaque(true); - bjo.setOpaque(true); + paramsPanel.setOpaque(true); // optsAndparams.setScrollableWidth(ScrollableSizeHint.FIT); // optsAndparams.setScrollableHeight(ScrollableSizeHint.NONE); // optsAndparams.setLayout(new BorderLayout()); + JPanel optsAndparams = new JPanel(); optsAndparams.setLayout(new BorderLayout()); - optsAndparams.add(jobOptions, BorderLayout.NORTH); - optsAndparams.add(paramList, BorderLayout.CENTER); + optsAndparams.add(optionsPanel, BorderLayout.NORTH); + optsAndparams.add(paramsPanel, BorderLayout.CENTER); JPanel jp = new JPanel(new BorderLayout()); jp.add(optsAndparams, BorderLayout.CENTER); paramPane.getViewport().setView(jp); paramPane.setBorder(null); setLayout(new BorderLayout()); + + JPanel jobPanel = new JPanel(); jobPanel.setPreferredSize(null); jobPanel.setLayout(new BorderLayout()); jobPanel.add(setDetails, BorderLayout.NORTH); jobPanel.add(paramPane, BorderLayout.CENTER); // jobPanel.setOrientation(JSplitPane.VERTICAL_SPLIT); - add(SetNamePanel, BorderLayout.NORTH); + add(setNamePanel, BorderLayout.NORTH); add(jobPanel, BorderLayout.CENTER); JPanel dialogpanel = new JPanel(); @@ -460,13 +432,13 @@ public class WsJobParameters extends JPanel implements ItemListener, validate(); } - protected void revert_actionPerformed(ActionEvent e) + protected void revert_actionPerformed() { reInitDialog(lastParmSet); updateWebServiceMenus(); } - protected void update_actionPerformed(ActionEvent e) + protected void update_actionPerformed() { if (isUserPreset) { @@ -484,7 +456,7 @@ public class WsJobParameters extends JPanel implements ItemListener, paramStore.deletePreset(lastParmSet2); } - protected void delete_actionPerformed(ActionEvent e) + protected void delete_actionPerformed() { if (isUserPreset) { @@ -495,7 +467,7 @@ public class WsJobParameters extends JPanel implements ItemListener, updateWebServiceMenus(); } - protected void create_actionPerformed(ActionEvent e) + protected void create_actionPerformed() { String curname = ((String) setName.getSelectedItem()).trim(); if (curname.length() > 0) @@ -514,36 +486,24 @@ public class WsJobParameters extends JPanel implements ItemListener, } } - protected void canceljob_actionPerformed(ActionEvent e) + protected void canceljob_actionPerformed() { - response = 0; + startJob = false; if (frame != null) { frame.setVisible(false); } } - protected void startjob_actionPerformed(ActionEvent e) + protected void startjob_actionPerformed() { - response = 1; + startJob = true; if (frame != null) { frame.setVisible(false); } } - Jws2Instance service; - - /** - * list of service presets in the gui - */ - Hashtable servicePresets = null; - - /** - * set if dialog is being set - so handlers will avoid spurious events - */ - boolean settingDialog = false; - void initForService(WsParamSetI jabap, List jabajobArgset) { WsParamSetI p = null; @@ -562,12 +522,12 @@ public class WsJobParameters extends JPanel implements ItemListener, void init(WsParamSetI p, List jobArgset) { - Hashtable exnames = new Hashtable(); + Hashtable exnames = new Hashtable<>(); for (int i = 0, iSize = setName.getItemCount(); i < iSize; i++) { exnames.put(setName.getItemAt(i), setName.getItemAt(i)); } - servicePresets = new Hashtable(); + servicePresets = new Hashtable<>(); // Add the default entry - if not present already. if (!exnames.contains(SVC_DEF)) { @@ -575,7 +535,8 @@ public class WsJobParameters extends JPanel implements ItemListener, exnames.put(SVC_DEF, SVC_DEF); servicePresets.put(SVC_DEF, SVC_DEF); } - String curname = (p == null ? "" : p.getName()); + + // String curname = (p == null ? "" : p.getName()); for (WsParamSetI pr : paramStore.getPresets()) { if (!pr.isModifiable()) @@ -653,9 +614,9 @@ public class WsJobParameters extends JPanel implements ItemListener, OptionI opt = (OptionI) myarg; OptionBox ob = opanp.addOption(opt); ob.resetToDefault(setDefaultParams); - if (MAX_OPTWIDTH < ob.getPreferredSize().width) + if (maxOptWidth < ob.getPreferredSize().width) { - MAX_OPTWIDTH = ob.getPreferredSize().width; + maxOptWidth = ob.getPreferredSize().width; } ob.validate(); cw += ob.getPreferredSize().width + 5; @@ -724,8 +685,6 @@ public class WsJobParameters extends JPanel implements ItemListener, return modifiedElements.size() > 0; } - private Hashtable modifiedElements = new Hashtable(); - /** * reset gui and modification state settings */ @@ -790,7 +749,7 @@ public class WsJobParameters extends JPanel implements ItemListener, if (b && modifiedElements.size() > 0) { makeSetNameValid(!isUserPreset); - SetNamePanel.revalidate(); + setNamePanel.revalidate(); } updateButtonDisplay(); } @@ -837,7 +796,7 @@ public class WsJobParameters extends JPanel implements ItemListener, // sync the gui with the preset database for (int i = 0, iS = setName.getItemCount(); i < iS; i++) { - String snm = (String) setName.getItemAt(i); + String snm = setName.getItemAt(i); if (snm.equals(nm)) { makeupdate = true; @@ -860,90 +819,70 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void refreshParamLayout() { - // optsAndparams.setPreferredSize(null); - FlowLayout fl = new FlowLayout(FlowLayout.LEFT); - int sep = fl.getVgap(); - boolean fh = true; - int s = jobOptions.getBorder().getBorderInsets(jobOptions).bottom - + jobOptions.getBorder().getBorderInsets(jobOptions).top - + 2 * sep; - - int panewidth = paramPane.getViewport().getSize().width - 120 - - jobOptions.getBorder().getBorderInsets(jobOptions).left - + jobOptions.getBorder().getBorderInsets(jobOptions).right; - - // int w = 2 * fl.getHgap() - // + (MAX_OPTWIDTH > OptsAndParamsPage.PARAM_WIDTH ? MAX_OPTWIDTH - // : OptsAndParamsPage.PARAM_WIDTH); - int hgap = fl.getHgap(); - int cw = hgap; + final int rightMargin = 40; + final int availableWidth = paramPane.getViewport().getSize().width + - rightMargin + - optionsPanel.getBorder().getBorderInsets(optionsPanel).left + + optionsPanel.getBorder().getBorderInsets(optionsPanel).right; if (opanp.getOptSet().size() > 0) { + int hgap = 5; + int currentWidth = hgap; - jobOptions.setLayout(new MigLayout("", "", "")); - jobOptions.removeAll(); + optionsPanel.setLayout(new MigLayout("nogrid", "", "")); + optionsPanel.removeAll(); + JPanel lastAdded = null; for (OptionBox pbox : opanp.getOptSet().values()) { pbox.validate(); - cw += pbox.getSize().width + hgap; - if (cw + 120 > panewidth) - { - jobOptions.add(pbox, "wrap"); - // System.out.println("Wrap on "+pbox.option.getName()); - cw = hgap + pbox.getSize().width; - fh = true; - } - else - { - jobOptions.add(pbox); - } - if (fh) + int boxWidth = pbox.getSize().width; + currentWidth += boxWidth + hgap; + boolean wrapAfterLast = currentWidth > availableWidth + && lastAdded != null; + // System.out.println(String.format( + // "%s width=%d, paneWidth=%d, currentWidth=%d, wrapAfterLast=%s", + // pbox.toString(), boxWidth, panewidth, currentWidth, + // wrapAfterLast)); + if (wrapAfterLast) { - // finalh += pbox.getSize().height + fl.getVgap(); - fh = false; + optionsPanel.remove(lastAdded); + optionsPanel.add(lastAdded, "wrap"); + currentWidth = hgap + boxWidth; } + optionsPanel.add(pbox); + lastAdded = pbox; } - jobOptions.revalidate(); + optionsPanel.revalidate(); } else { - jobOptions.setVisible(false); + optionsPanel.setVisible(false); } - // Now layout the parameters assuming they occupy one column - to calculate - // total height of options+parameters - fl = new FlowLayout(FlowLayout.LEFT); - // helpful hint from - // http://stackoverflow.com/questions/2743177/top-alignment-for-flowlayout - fl.setAlignOnBaseline(true); if (opanp.getParamSet().size() > 0) { - paramList.removeAll(); - paramList.setLayout(new MigLayout("", "", "")); - fh = true; + paramsPanel.removeAll(); + paramsPanel.setLayout(new MigLayout("", "", "")); + int hgap = 5; + int currentWidth = hgap; + + JPanel lastAdded = null; for (ParamBox pbox : opanp.getParamSet().values()) { pbox.validate(); - cw += pbox.getSize().width + hgap; - if (cw + 160 > panewidth) - { - paramList.add(pbox, "wrap"); - cw = pbox.getSize().width + hgap; - fh = true; - } - else - { - paramList.add(pbox); - } - if (fh) + currentWidth += pbox.getSize().width + hgap; + if (currentWidth /*+ 160*/ > availableWidth && lastAdded != null) { - // finalh += pbox.getSize().height + fl.getVgap(); - fh = false; + paramsPanel.remove(lastAdded); + paramsPanel.add(lastAdded, "wrap"); + currentWidth = pbox.getSize().width + hgap; } - + paramsPanel.add(pbox); + lastAdded = pbox; } + /* * s = 2 * sep; for (ParamBox pbox : opanp.getParamSet().values()) { * pbox.validate(); s += sep + @@ -955,11 +894,11 @@ public class WsJobParameters extends JPanel implements ItemListener, * .getBorder().getBorderInsets(paramList).bottom+paramList * .getBorder().getBorderInsets(paramList).top; */ - paramList.revalidate(); + paramsPanel.revalidate(); } else { - paramList.setVisible(false); + paramsPanel.setVisible(false); } // TODO: waste some time trying to eliminate any unnecessary .validate calls // here @@ -1124,8 +1063,8 @@ public class WsJobParameters extends JPanel implements ItemListener, e.printStackTrace(); } } - WsJobParameters pgui = new WsJobParameters(lastserv, - new JabaPreset(lastserv, pr)); + WsJobParameters pgui = new WsJobParameters(null, lastserv, + new JabaPreset(lastserv, pr), null); JFrame jf = new JFrame(MessageManager .formatMessage("label.ws_parameters_for", new String[] { lastserv.getActionText() })); @@ -1219,8 +1158,6 @@ public class WsJobParameters extends JPanel implements ItemListener, return opanp.getCurrentSettings(); } - String lastParmSet = null; - /* * Hashtable editedParams = new Hashtable(); @@ -1260,10 +1197,10 @@ public class WsJobParameters extends JPanel implements ItemListener, int n = 0; // remove any set names in the drop down menu that aren't either a reserved // setting, or a user defined or service preset. - Vector items = new Vector(); + Vector items = new Vector<>(); while (n < setName.getItemCount()) { - String item = (String) setName.getItemAt(n); + String item = setName.getItemAt(n); if (!item.equals(SVC_DEF) && !paramStore.presetExists(item)) { setName.removeItemAt(n); @@ -1331,7 +1268,7 @@ public class WsJobParameters extends JPanel implements ItemListener, initArgSetModified(); syncSetNamesWithStore(); setName.setSelectedItem(lastParmSet); - SetNamePanel.validate(); + setNamePanel.validate(); validate(); settingDialog = false; } @@ -1353,7 +1290,8 @@ public class WsJobParameters extends JPanel implements ItemListener, @Override public void itemStateChanged(ItemEvent e) { - if (e.getSource() == setName && e.getStateChange() == e.SELECTED) + if (e.getSource() == setName + && e.getStateChange() == ItemEvent.SELECTED) { final String setname = (String) setName.getSelectedItem(); // System.out.println("Item state changed for " + setname diff --git a/src/jalview/ws/jws2/Jws2Client.java b/src/jalview/ws/jws2/Jws2Client.java index 60e25b0..7d661a4 100644 --- a/src/jalview/ws/jws2/Jws2Client.java +++ b/src/jalview/ws/jws2/Jws2Client.java @@ -31,6 +31,7 @@ import jalview.util.MessageManager; import jalview.ws.jws2.dm.AAConSettings; import jalview.ws.jws2.dm.JabaWsParamSet; import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.WsParamSetI; import jalview.ws.uimodel.AlignAnalysisUIText; @@ -108,8 +109,12 @@ public abstract class Jws2Client extends jalview.ws.WSClient } WsJobParameters jobParams = (preset == null && paramset != null && paramset.size() > 0) - ? new WsJobParameters(sh, null, paramset) - : new WsJobParameters(sh, preset); + ? new WsJobParameters((ParamDatastoreI) null, sh, + (WsParamSetI) null, + paramset) + : new WsJobParameters((ParamDatastoreI) null, sh, + preset, + (List) null); if (adjustingExisting) { jobParams.setName(MessageManager @@ -117,8 +122,9 @@ public abstract class Jws2Client extends jalview.ws.WSClient } if (!jobParams.showRunDialog()) { - return false; + return false; // dialog cancelled } + WsParamSetI prset = jobParams.getPreset(); if (prset == null) { diff --git a/src/jalview/ws/params/simple/DoubleParameter.java b/src/jalview/ws/params/simple/DoubleParameter.java index d6ccf46..6b76170 100644 --- a/src/jalview/ws/params/simple/DoubleParameter.java +++ b/src/jalview/ws/params/simple/DoubleParameter.java @@ -10,16 +10,17 @@ import jalview.ws.params.ValueConstrainI; */ public class DoubleParameter extends Option implements ParameterI { - Double defval; + double defval; - Double min, max; + double min; + + double max; @Override public ValueConstrainI getValidValue() { return new ValueConstrainI() { - @Override public ValueType getType() { @@ -29,27 +30,13 @@ public class DoubleParameter extends Option implements ParameterI @Override public Number getMin() { - if (min < max) - { - return min; - } - else - { - return null; - } + return min < max ? min : null; } @Override public Number getMax() { - if (min < max) - { - return max; - } - else - { - return null; - } + return min < max ? max : null; } }; } @@ -62,7 +49,7 @@ public class DoubleParameter extends Option implements ParameterI } public DoubleParameter(String name, String description, boolean required, - Double defValue, Double min, Double max) + Double defValue, double min, double max) { super(name, description, required, String.valueOf(defValue), null, null, null); @@ -72,7 +59,7 @@ public class DoubleParameter extends Option implements ParameterI } public DoubleParameter(String name, String description, boolean required, - Double defValue, Double value, Double min, Double max) + Double defValue, Double value, double min, double max) { super(name, description, required, String.valueOf(defValue), String.valueOf(value), null, null); diff --git a/src/jalview/ws/params/simple/IntegerParameter.java b/src/jalview/ws/params/simple/IntegerParameter.java index fb34e89..b3a01b2 100644 --- a/src/jalview/ws/params/simple/IntegerParameter.java +++ b/src/jalview/ws/params/simple/IntegerParameter.java @@ -31,8 +31,11 @@ public class IntegerParameter extends Option implements ParameterI { int defval; - int min, max; + int min; + int max; + + @Override public ValueConstrainI getValidValue() { return new ValueConstrainI() @@ -47,27 +50,13 @@ public class IntegerParameter extends Option implements ParameterI @Override public Number getMin() { - if (min < max) - { - return min; - } - else - { - return null; - } + return min < max ? min : null; } @Override public Number getMax() { - if (min < max) - { - return max; - } - else - { - return null; - } + return min < max ? max : null; } }; } diff --git a/src/jalview/ws/params/simple/LogarithmicParameter.java b/src/jalview/ws/params/simple/LogarithmicParameter.java index 5f57d54..b127183 100644 --- a/src/jalview/ws/params/simple/LogarithmicParameter.java +++ b/src/jalview/ws/params/simple/LogarithmicParameter.java @@ -58,7 +58,7 @@ public class LogarithmicParameter extends Option implements ParameterI } public LogarithmicParameter(String name, String description, - boolean required, double defValue, double min, double max, + boolean required, Double defValue, double min, double max, double base) { super(name, description, required, String.valueOf(defValue), null, null, @@ -70,7 +70,7 @@ public class LogarithmicParameter extends Option implements ParameterI } public LogarithmicParameter(String name, String description, - boolean required, double defValue, double value, double min, + boolean required, Double defValue, double value, double min, double max, double base) { super(name, description, required, String.valueOf(defValue), diff --git a/src/jalview/ws/params/simple/Option.java b/src/jalview/ws/params/simple/Option.java index 653359f..f0126df 100644 --- a/src/jalview/ws/params/simple/Option.java +++ b/src/jalview/ws/params/simple/Option.java @@ -29,10 +29,21 @@ import java.util.List; public class Option implements OptionI { + String name; - String name, value, defvalue, description; + /* + * current value in string format, or "null" if undefined + */ + String value; - ArrayList possibleVals = new ArrayList(); + /* + * default value in string format, or "null" if undefined + */ + String defvalue; + + String description; + + ArrayList possibleVals = new ArrayList<>(); boolean required; @@ -84,11 +95,17 @@ public class Option implements OptionI { name = new String(opt.name); if (opt.value != null) + { value = new String(opt.value); + } if (opt.defvalue != null) + { defvalue = new String(opt.defvalue); + } if (opt.description != null) + { description = new String(opt.description); + } if (opt.possibleVals != null) { possibleVals = (ArrayList) opt.possibleVals.clone(); @@ -113,7 +130,7 @@ public class Option implements OptionI this.defvalue = defValue; if (possibleVals != null) { - this.possibleVals = new ArrayList(); + this.possibleVals = new ArrayList<>(); this.possibleVals.addAll(possibleVals); } this.fdetails = fdetails; @@ -125,4 +142,13 @@ public class Option implements OptionI Option opt = new Option(this); return opt; } + + /** + * toString method to help identify options in the debugger only + */ + @Override + public String toString() + { + return this.getClass().getName() + ":" + name; + } } diff --git a/test/jalview/ws/gui/Jws2ParamView.java b/test/jalview/ws/gui/Jws2ParamView.java index 80b48c3..134fbd1 100644 --- a/test/jalview/ws/gui/Jws2ParamView.java +++ b/test/jalview/ws/gui/Jws2ParamView.java @@ -28,6 +28,7 @@ import jalview.ws.jabaws.JalviewJabawsTestUtils; import jalview.ws.jws2.JabaPreset; import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.ParamDatastoreI; import java.awt.BorderLayout; import java.awt.event.WindowAdapter; @@ -42,6 +43,7 @@ import javax.swing.JPanel; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import compbio.metadata.Argument; import compbio.metadata.Preset; import compbio.metadata.PresetManager; @@ -58,12 +60,12 @@ public class Jws2ParamView /** * which services to test */ - public static List serviceTests = new ArrayList(); + public static List serviceTests = new ArrayList<>(); /** * which presets to test for services */ - public static List presetTests = new ArrayList(); + public static List presetTests = new ArrayList<>(); static { serviceTests.add("AAConWS".toLowerCase()); @@ -127,11 +129,12 @@ public class Jws2ParamView } pr = en.next(); } - WsJobParameters pgui = new WsJobParameters(service, - new JabaPreset(service, pr)); - JFrame jf = new JFrame(MessageManager.formatMessage( - "label.ws_parameters_for", - new String[] { service.getActionText() })); + WsJobParameters pgui = new WsJobParameters((ParamDatastoreI) null, + service, new JabaPreset(service, pr), + (List) null); + JFrame jf = new JFrame(MessageManager + .formatMessage("label.ws_parameters_for", new String[] + { service.getActionText() })); jf.setSize(700, 800); JPanel cont = new JPanel(new BorderLayout()); pgui.validate(); -- 1.7.10.2