From 435105991f17a7f96fd031e934b507ac34a987f5 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 20 Apr 2018 18:04:53 +0100 Subject: [PATCH] JAL-591 tidy and comment code --- src/jalview/gui/WsJobParameters.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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"); -- 1.7.10.2