From: Jouni Koivuviita Date: Wed, 7 Oct 2009 10:40:37 +0000 (+0000) Subject: Fix for #2611: ComboBox in readonly differs from readonly TextField X-Git-Tag: 6.7.0.beta1~2425 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7fff35a8588eae4b0ebad74d0952ad5a94bef2a2;p=vaadin-framework.git Fix for #2611: ComboBox in readonly differs from readonly TextField svn changeset:9124/svn branch:6.2 --- diff --git a/WebContent/VAADIN/themes/base/datefield/datefield.css b/WebContent/VAADIN/themes/base/datefield/datefield.css index 1427ff2195..720a80716f 100644 --- a/WebContent/VAADIN/themes/base/datefield/datefield.css +++ b/WebContent/VAADIN/themes/base/datefield/datefield.css @@ -1,5 +1,6 @@ .v-datefield { white-space: nowrap; + float: left; /* Force minimum width */ } .v-datefield-textfield { vertical-align: top; diff --git a/WebContent/VAADIN/themes/base/select/select.css b/WebContent/VAADIN/themes/base/select/select.css index 7da7c1201f..5899b48664 100644 --- a/WebContent/VAADIN/themes/base/select/select.css +++ b/WebContent/VAADIN/themes/base/select/select.css @@ -55,11 +55,11 @@ font-style: italic; } .v-filterselect-button { - float: right; cursor: pointer; + float: right; } .v-filterselect.v-readonly .v-filterselect-button { - display: none; + cursor: default; } .v-filterselect-suggestpopup { background: #fff; diff --git a/WebContent/VAADIN/themes/base/styles.css b/WebContent/VAADIN/themes/base/styles.css index 93258c44fc..886de8cc1c 100644 --- a/WebContent/VAADIN/themes/base/styles.css +++ b/WebContent/VAADIN/themes/base/styles.css @@ -454,6 +454,7 @@ div.v-app-loading { .v-datefield { white-space: nowrap; + float: left; /* Force minimum width */ } .v-datefield-textfield { vertical-align: top; @@ -886,11 +887,11 @@ div.v-progressindicator-indeterminate-disabled { font-style: italic; } .v-filterselect-button { - float: right; cursor: pointer; + float: right; } .v-filterselect.v-readonly .v-filterselect-button { - display: none; + cursor: default; } .v-filterselect-suggestpopup { background: #fff; diff --git a/WebContent/VAADIN/themes/reindeer/styles.css b/WebContent/VAADIN/themes/reindeer/styles.css index 88b8acccc4..31575a32b2 100644 --- a/WebContent/VAADIN/themes/reindeer/styles.css +++ b/WebContent/VAADIN/themes/reindeer/styles.css @@ -454,6 +454,7 @@ div.v-app-loading { .v-datefield { white-space: nowrap; + float: left; /* Force minimum width */ } .v-datefield-textfield { vertical-align: top; @@ -886,11 +887,11 @@ div.v-progressindicator-indeterminate-disabled { font-style: italic; } .v-filterselect-button { - float: right; cursor: pointer; + float: right; } .v-filterselect.v-readonly .v-filterselect-button { - display: none; + cursor: default; } .v-filterselect-suggestpopup { background: #fff; diff --git a/WebContent/VAADIN/themes/runo/select/select.css b/WebContent/VAADIN/themes/runo/select/select.css index a677dde1c6..ac1eaf18fc 100644 --- a/WebContent/VAADIN/themes/runo/select/select.css +++ b/WebContent/VAADIN/themes/runo/select/select.css @@ -53,11 +53,8 @@ } .v-disabled .v-filterselect-button:hover, .v-readonly .v-filterselect-button:hover { - background-position: top left; -} -.v-filterselect.v-readonly .v-filterselect-input { - background: transparent; - color: black; + background-position: top left; + cursor: default; } .v-filterselect-suggestpopup { background: #f6f7f7; diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css index ec5fcb2de1..95f65f5770 100644 --- a/WebContent/VAADIN/themes/runo/styles.css +++ b/WebContent/VAADIN/themes/runo/styles.css @@ -454,6 +454,7 @@ div.v-app-loading { .v-datefield { white-space: nowrap; + float: left; /* Force minimum width */ } .v-datefield-textfield { vertical-align: top; @@ -886,11 +887,11 @@ div.v-progressindicator-indeterminate-disabled { font-style: italic; } .v-filterselect-button { - float: right; cursor: pointer; + float: right; } .v-filterselect.v-readonly .v-filterselect-button { - display: none; + cursor: default; } .v-filterselect-suggestpopup { background: #fff; @@ -2413,10 +2414,7 @@ div.v-tree-node-leaf { .v-disabled .v-filterselect-button:hover, .v-readonly .v-filterselect-button:hover { background-position: top left; -} -.v-filterselect.v-readonly .v-filterselect-input { - background: transparent; - color: black; + cursor: default; } .v-filterselect-suggestpopup { background: #f6f7f7; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 779b36cd5a..9d1482952c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -594,6 +594,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, private boolean nullSelectionAllowed; private boolean nullSelectItem; private boolean enabled; + private boolean readonly; // shown in unfocused empty field, disappears on focus (e.g "Search here") private static final String CLASSNAME_PROMPT = "prompt"; @@ -683,16 +684,11 @@ public class VFilterSelect extends Composite implements Paintable, Field, paintableId = uidl.getId(); this.client = client; - boolean readonly = uidl.hasAttribute("readonly"); - boolean disabled = uidl.hasAttribute("disabled"); + readonly = uidl.hasAttribute("readonly"); + enabled = !uidl.hasAttribute("disabled"); - if (disabled || readonly) { - tb.setEnabled(false); - enabled = false; - } else { - tb.setEnabled(true); - enabled = true; - } + tb.setEnabled(enabled); + tb.setReadOnly(readonly); if (client.updateComponent(this, uidl, true)) { return; @@ -887,7 +883,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, } public void onKeyDown(KeyDownEvent event) { - if (enabled) { + if (enabled && !readonly) { if (suggestionPopup.isAttached()) { popupKeyDown(event); } else { @@ -956,7 +952,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, } public void onKeyUp(KeyUpEvent event) { - if (enabled) { + if (enabled && !readonly) { switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: case KeyCodes.KEY_TAB: @@ -996,7 +992,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, * Listener for popupopener */ public void onClick(ClickEvent event) { - if (enabled) { + if (enabled && !readonly) { // ask suggestionPopup if it was just closed, we are using GWT // Popup's auto close feature if (!suggestionPopup.isJustClosed()) { diff --git a/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java b/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java index 0d474daa54..21e2759ddf 100644 --- a/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java +++ b/src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java @@ -2,47 +2,34 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.ComboBox; +import com.vaadin.ui.VerticalLayout; public class ComboBoxValueInput extends TestBase { @Override protected void setup() { - ComboBox cb = new ComboBox("A combobox without input prompt"); - cb.setImmediate(true); - cb.addItem("Value 1"); - cb.addItem("Value 2"); - cb.addItem("Value 3"); + ((VerticalLayout) getLayout()).setSpacing(true); + ComboBox cb = getComboBox("A combobox", false); addComponent(cb); - cb = new ComboBox("A combobox with input prompt"); + cb = getComboBox("A combobox with input prompt", false); cb.setInputPrompt("Please select"); - cb.setImmediate(true); - cb.addItem("Value 1"); - cb.addItem("Value 2"); - cb.addItem("Value 3"); + addComponent(cb); + cb = getComboBox("A combobox with null item", true); addComponent(cb); - cb = new ComboBox("A combobox with null item"); + cb = getComboBox("A combobox with null item and input prompt", true); cb.setInputPrompt("Please select"); - cb.setImmediate(true); - cb.addItem("Null item"); - cb.addItem("Value 1"); - cb.addItem("Value 2"); - cb.addItem("Value 3"); - cb.setNullSelectionItemId("Null item"); - addComponent(cb); - cb = new ComboBox("A combobox with null item and input prompt"); - cb.setImmediate(true); - cb.addItem("Null item"); - cb.addItem("Value 1"); - cb.addItem("Value 2"); - cb.addItem("Value 3"); - cb.setNullSelectionItemId("Null item"); + cb = getComboBox("A disabled combobox", true); + cb.setEnabled(false); + addComponent(cb); + cb = getComboBox("A read-only combobox", true); + cb.setReadOnly(true); addComponent(cb); } @@ -56,4 +43,18 @@ public class ComboBoxValueInput extends TestBase { return 3268; } + private ComboBox getComboBox(String caption, boolean addNullItem) { + ComboBox cb = new ComboBox(caption); + cb.setImmediate(true); + if (addNullItem) { + cb.addItem("Null item"); + cb.setNullSelectionItemId("Null item"); + } + cb.addItem("Value 1"); + cb.addItem("Value 2"); + cb.addItem("Value 3"); + + return cb; + } + }