Tomas Jelinek has uploaded a new change for review. Change subject: frontend: ListModelTypeAheadListBox adjustements ......................................................................
frontend: ListModelTypeAheadListBox adjustements This patch contains the following changes: 1: changed the styling of the suggestions to make the size proportional to the content 2: changed the styling (added bottom borders and changed the coloring) 3: the selected item is now the one set as setValue() Change-Id: I4ff487d93b752540feb7b9e9392fae1479662d59 Signed-off-by: Tomas Jelinek <tjeli...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java 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/ListModelTypeAheadListBox.ui.xml 3 files changed, 51 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/18212/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java index 813677e..37b0a71 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationTemplates.java @@ -67,7 +67,11 @@ @Template("<i>{0}</i>") SafeHtml italicText(String text); - @Template("<div style='width: 600px'><div style='width: 30%; display: inline-block; border-right: 1px solid black; font-weight:bold; padding-right: 25px; float: left'>{0}</div><div style='display: inline-block; margin-left: 25px;'>{1}</div></div>") + @Template("<table style='min-width: 200px; width: 100%; border-bottom: 1px solid #acacac;'><tr>" + + "<td style='width: 49%;'>{0}</td>" + + "<td style='width: 2%; border-left: 1px solid #acacac;'></td>" + + "<td style='white-space: normal; width: 49%; color: #acacac;'>{1}</td>" + + "</tr></table>") SafeHtml typeAheadNameDescription(String name, String description); @Template("<div style='width: {0}; font-style: italic;'>{1}</div>") 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 5d041a0..8a24ec6 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 @@ -8,12 +8,12 @@ import com.google.gwt.event.dom.client.MouseUpHandler; import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.user.client.ui.MenuBar; +import com.google.gwt.user.client.ui.MenuItem; import java.util.ArrayList; import java.util.Collection; import java.util.List; - import org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadListBoxEditor.SuggestBoxRenderer; - import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.event.dom.client.BlurEvent; @@ -148,6 +148,8 @@ suggestBox.setText(null); suggestBox.showSuggestionList(); + selectInMenu(getValue()); + Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute () { setFocus(true); @@ -156,6 +158,42 @@ } } + private void selectInMenu(T toSelect) { + if (!(getSuggestionMenu() instanceof MenuBar)) { + // can not select if the it is not a menu bar + return; + } + + MenuBar menuBar = (MenuBar) getSuggestionMenu(); + List<MenuItem> items = getItems(menuBar); + if (items == null) { + return; + } + + String selectedReplacementString = renderer.getReplacementString(toSelect); + if (selectedReplacementString == null) { + return; + } + + int selectedItemIndex = -1; + for (T acceptableValue : acceptableValues) { + selectedItemIndex ++; + String acceptableValueReplacement = renderer.getReplacementString(acceptableValue); + if (acceptableValueReplacement != null && acceptableValueReplacement.equals(selectedReplacementString)) { + if (items.size() > selectedItemIndex) { + menuBar.selectItem(items.get(selectedItemIndex)); + } + + break; + } + } + } + + // extremely ugly - there is just no better way how to find the items as MenuItems + private native List<MenuItem> getItems(MenuBar menuBar) /*-{ + return menub...@com.google.gwt.user.client.ui.MenuBar::getItems()(); + }-*/; + private void adjustSelectedValue() { if (acceptableValues.size() == 0) { return; diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.ui.xml index b408a6e..d09f421 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.ui.xml @@ -5,6 +5,12 @@ <ui:with field='resources' type='org.ovirt.engine.ui.common.CommonApplicationResources' /> <ui:style type="org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadListBox.Style"> + @external gwt-SuggestBoxPopup .suggestPopupMiddleCenterInner; + + .gwt-SuggestBoxPopup .suggestPopupMiddleCenterInner { + height: 100%; + } + .mainStyle,.enabledMainPanel,.disabledMainPanel { display: inline-block; height: 17px; -- To view, visit http://gerrit.ovirt.org/18212 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4ff487d93b752540feb7b9e9392fae1479662d59 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tomas Jelinek <tjeli...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches