From: gmungoc Date: Fri, 20 Apr 2018 17:04:53 +0000 (+0100) Subject: JAL-591 tidy and comment code X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=435105991f17a7f96fd031e934b507ac34a987f5;p=jalview.git JAL-591 tidy and comment code --- diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index a1fcc6f..8377a16 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -816,6 +816,9 @@ public class WsJobParameters extends JPanel implements ItemListener, settingDialog = stn; } + /** + * Rebuilds the Options and Parameters panels + */ @Override public void refreshParamLayout() { @@ -830,10 +833,19 @@ public class WsJobParameters extends JPanel implements ItemListener, int hgap = 5; int currentWidth = hgap; + /* + * layout constraint 'nogrid' prevents vertical column alignment, + * allowing controls to flow without extra space inserted to align + */ optionsPanel.setLayout(new MigLayout("nogrid", "", "")); optionsPanel.removeAll(); - JPanel lastAdded = null; + + /* + * add each control in turn; if adding would overflow the right margin, + * remove and re-add the previous parameter with "wrap" (after) + * in order to start a new row + */ for (OptionBox pbox : opanp.getOptSet().values()) { pbox.validate(); @@ -872,8 +884,11 @@ public class WsJobParameters extends JPanel implements ItemListener, for (ParamBox pbox : opanp.getParamSet().values()) { pbox.validate(); - currentWidth += pbox.getSize().width + hgap; - if (currentWidth /*+ 160*/ > availableWidth && lastAdded != null) + int boxWidth = pbox.getSize().width; + currentWidth += boxWidth + hgap; + boolean wrapAfterLast = currentWidth > availableWidth + && lastAdded != null; + if (wrapAfterLast) { paramsPanel.remove(lastAdded); paramsPanel.add(lastAdded, "wrap");