From 474cfec88a4a0d9370c5099ca4817940089416bc Mon Sep 17 00:00:00 2001 From: gpawel <gpawel> Date: Fri, 27 May 2011 09:05:57 +0000 Subject: [PATCH] [LMS-2279] ComboBox in dialog when adding Ad Hoc vocabulary term now always filled with values SVN: 21489 --- .../field/VocabularyTermSelectionWidget.java | 42 +++++++------------ .../application/ui/widget/DropDownList.java | 8 ++-- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java index 42cb3122c46..c2453c2d7fd 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java @@ -139,22 +139,11 @@ public class VocabularyTermSelectionWidget extends private VocabularyTermSelectionWidget createTermSelectionWidget() { - List<VocabularyTerm> allTerms = getAllTerms(); - String previousTermCodeOrNull = null; - long maxOrdinal = Long.MIN_VALUE; - for (VocabularyTerm term : allTerms) - { - if (term.getOrdinal() >= maxOrdinal) - { - previousTermCodeOrNull = term.getCode(); - maxOrdinal = term.getOrdinal(); - } - } boolean mandatory = false; VocabularyTermSelectionWidget result = new VocabularyTermSelectionWidget(getId() + "_edit_pos", "Position after", - mandatory, allTerms, previousTermCodeOrNull); - result.setEmptyText("empty value == beginning"); + mandatory, vocabularyOrNull, viewContext, null, null, false); + result.setEmptyText(result.emptyText = result.chooseMsg = "empty value == beginning"); return result; } @@ -244,11 +233,20 @@ public class VocabularyTermSelectionWidget extends protected VocabularyTermSelectionWidget(String idSuffix, String label, boolean mandatory, Vocabulary vocabularyOrNull, final IViewContext<?> viewContextOrNull, List<VocabularyTerm> termsOrNull, String initialTermCodeOrNull) + { + this(idSuffix, label, mandatory, vocabularyOrNull, viewContextOrNull, termsOrNull, + initialTermCodeOrNull, allowAddingUnofficialTerms(viewContextOrNull)); + } + + protected VocabularyTermSelectionWidget(String idSuffix, String label, boolean mandatory, + Vocabulary vocabularyOrNull, final IViewContext<?> viewContextOrNull, + List<VocabularyTerm> termsOrNull, String initialTermCodeOrNull, + boolean allowAddigUnofficialTerms) { super(idSuffix, ModelDataPropertyNames.CODE_WITH_LABEL, label, - allowAddingUnofficialTerms(viewContextOrNull) ? CHOOSE_OR_ADD_MSG : CHOOSE_MSG, - EMPTY_MSG, VALUE_NOT_IN_LIST_MSG, mandatory, viewContextOrNull, - termsOrNull == null, allowAddingUnofficialTerms(viewContextOrNull)); + allowAddigUnofficialTerms ? CHOOSE_OR_ADD_MSG : CHOOSE_MSG, EMPTY_MSG, + VALUE_NOT_IN_LIST_MSG, mandatory, viewContextOrNull, termsOrNull == null, + allowAddigUnofficialTerms); this.viewContextOrNull = viewContextOrNull; this.vocabularyOrNull = vocabularyOrNull; this.initialTermCodeOrNull = initialTermCodeOrNull; @@ -299,18 +297,6 @@ public class VocabularyTermSelectionWidget extends refreshStore(); } - private List<VocabularyTerm> getAllTerms() - { - List<VocabularyTerm> terms = new ArrayList<VocabularyTerm>(); - - for (VocabularyTermModel model : store.getModels()) - { - terms.add(model.getTerm()); - } - - return terms; - } - private void setTerms(List<VocabularyTerm> terms) { final List<VocabularyTermModel> models = new ArrayList<VocabularyTermModel>(); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java index d612e85bbde..9f9412b586f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java @@ -68,10 +68,6 @@ abstract public class DropDownList<M extends ModelData, E> extends ComboBox<M> i private final String valueNotInListMsg; - private final String chooseMsg; - - private final String emptyMsg; - private final boolean mandatory; private final boolean reloadWhenRendering; @@ -82,6 +78,10 @@ abstract public class DropDownList<M extends ModelData, E> extends ComboBox<M> i protected boolean allowValueNotFromList = false; + protected String chooseMsg; + + protected String emptyMsg; + public String callbackIdOrNull; protected String resultSetKey; -- GitLab