From 02e9934037787599aefda03a6af9b7501e867dc3 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 21 Jun 2013 11:35:07 +0100 Subject: [PATCH] JAL-1127 set option widgets to service defaults only when showing default settings --- src/jalview/gui/OptsAndParamsPage.java | 7 ++++--- src/jalview/gui/WsJobParameters.java | 27 +++++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 93f5ce2..eb55994 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -235,10 +235,11 @@ public class OptsAndParamsPage } - public void resetToDefault() + + public void resetToDefault(boolean setDefaultParams) { enabled.setSelected(false); - if (option.isRequired()) + if (option.isRequired() || (setDefaultParams && option.getValue()!=null)) { // Apply default value selectOption(option, option.getValue()); @@ -258,7 +259,7 @@ public class OptsAndParamsPage initVal = (initEnabled) ? (String) val.getSelectedItem() : null; } } - + } public class ParamBox extends JPanel implements ChangeListener, diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index 8abbcee..77f3155 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -566,14 +566,27 @@ public class WsJobParameters extends JPanel implements ItemListener, @SuppressWarnings("unchecked") private void updateTable(WsParamSetI p, List jobArgset) { + boolean setDefaultParams=false; + if (lastParmSet == null) + { + isUserPreset = false; + // First call - so provide Service default settings + setName.setSelectedItem(lastSetName = SVC_DEF); + } + if (p==null && SVC_DEF.equals(""+setName.getSelectedItem())) + { + // indicate that service defaults should be set if available + setDefaultParams=true; + } // populate table from default parameter set. List args = paramStore.getServiceParameters(); // split to params and required arguments { int cw = 0; + boolean optset=false; for (ArgumentI myarg : args) - { + { // Ideally, Argument would implement isRequired ! if (myarg instanceof ParameterI) { @@ -586,7 +599,7 @@ public class WsJobParameters extends JPanel implements ItemListener, { OptionI opt = (OptionI) myarg; OptionBox ob = opanp.addOption(opt); - ob.resetToDefault(); + ob.resetToDefault(setDefaultParams); if (MAX_OPTWIDTH < ob.getPreferredSize().width) { MAX_OPTWIDTH = ob.getPreferredSize().width; @@ -620,16 +633,6 @@ public class WsJobParameters extends JPanel implements ItemListener, // TODO: check if args should be unselected prior to resetting using the // preset } - else - { - if (lastParmSet == null) - { - isUserPreset = false; - // first call - so create a dummy name - - setName.setSelectedItem(lastSetName = SVC_DEF); - } - } if (jobArgset != null) { -- 1.7.10.2