Lior Vernia has uploaded a new change for review. Change subject: webadmin: ListModelTypeAheadListBox to not always add to valid values ......................................................................
webadmin: ListModelTypeAheadListBox to not always add to valid values Added a parameter that determines whether the widget should automatically add values to the list of "valid" values (those suggested). This is particularly useful when the selected value is initialized to some value, that shouldn't be chosen again once it's been changed (which is the case for the vNIC widget). Change-Id: Ic35073123696fe7e727464079c31794935a7ad70 Bug-Url: https://bugzilla.redhat.com/1020861 Signed-off-by: Lior Vernia <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileEditor.java 3 files changed, 20 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/26747/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java index 77efcd2..6e00ed7 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java @@ -56,6 +56,7 @@ Style style; private final SuggestBoxRenderer<T> renderer; + private final boolean autoAddToValidValues; private Collection<T> acceptableValues = new ArrayList<T>(); @@ -73,8 +74,13 @@ } public ListModelTypeAheadListBox(SuggestBoxRenderer<T> renderer) { + this(renderer, true); + } + + public ListModelTypeAheadListBox(SuggestBoxRenderer<T> renderer, boolean autoAddToValidValues) { super(new RenderableSuggestOracle<T>(renderer)); this.renderer = renderer; + this.autoAddToValidValues = autoAddToValidValues; suggestBox = asSuggestBox(); @@ -266,7 +272,7 @@ } private void addToValidValuesIfNeeded(T value) { - if (!acceptableValues.contains(value)) { + if (!acceptableValues.contains(value) && autoAddToValidValues) { acceptableValues.add(value); } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java index 2254a8a..fac9943 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java @@ -18,11 +18,21 @@ private final WidgetWithLabelEditor<T, ListModelTypeAheadListBoxEditor<T>> editor; public ListModelTypeAheadListBoxEditor(SuggestBoxRenderer<T> renderer) { - this(renderer, new VisibilityRenderer.SimpleVisibilityRenderer()); + this(renderer, true); + } + + public ListModelTypeAheadListBoxEditor(SuggestBoxRenderer<T> renderer, boolean autoAddToValidValues) { + this(renderer, autoAddToValidValues, new VisibilityRenderer.SimpleVisibilityRenderer()); } public ListModelTypeAheadListBoxEditor(SuggestBoxRenderer<T> renderer, VisibilityRenderer visibilityRenderer) { - super(new ListModelTypeAheadListBox<T>(renderer), visibilityRenderer); + this(renderer, true, visibilityRenderer); + } + + public ListModelTypeAheadListBoxEditor(SuggestBoxRenderer<T> renderer, + boolean autoAddToValidValues, + VisibilityRenderer visibilityRenderer) { + super(new ListModelTypeAheadListBox<T>(renderer, autoAddToValidValues), visibilityRenderer); this.editor = WidgetWithLabelEditor.of(getContentWidget().asEditor(), this); } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileEditor.java index 30c7065..c4c8680 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileEditor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileEditor.java @@ -38,7 +38,7 @@ profileDescription != null ? profileDescription : "").asString(); //$NON-NLS-1$ } - }); + }, false); } } -- To view, visit http://gerrit.ovirt.org/26747 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic35073123696fe7e727464079c31794935a7ad70 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
