]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #2611: ComboBox in readonly differs from readonly TextField
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Wed, 7 Oct 2009 10:40:37 +0000 (10:40 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Wed, 7 Oct 2009 10:40:37 +0000 (10:40 +0000)
svn changeset:9124/svn branch:6.2

WebContent/VAADIN/themes/base/datefield/datefield.css
WebContent/VAADIN/themes/base/select/select.css
WebContent/VAADIN/themes/base/styles.css
WebContent/VAADIN/themes/reindeer/styles.css
WebContent/VAADIN/themes/runo/select/select.css
WebContent/VAADIN/themes/runo/styles.css
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
src/com/vaadin/tests/components/combobox/ComboBoxValueInput.java

index 1427ff2195e106ba3e55948e6b824ca1202aabd6..720a80716f40fbff3e478999c73ab8dbacec1a60 100644 (file)
@@ -1,5 +1,6 @@
 .v-datefield {
        white-space: nowrap;
+       float: left; /* Force minimum width */
 }
 .v-datefield-textfield {
        vertical-align: top;
index 7da7c1201fcac769ca3dda8605bfb7339dd3d3b2..5899b48664818bc1e080ff13cbb0c8a73287521f 100644 (file)
        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;
index 93258c44fc12862ba8b24650268f972fe1491c88..886de8cc1c49783cd95f8a0cb4a720ef981017d0 100644 (file)
@@ -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;
index 88b8acccc4b113d3d9bb3721bcaee33f38428491..31575a32b20ad927ae846f96639b6256e18789eb 100644 (file)
@@ -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;
index a677dde1c619bd74f9aa8abc3c5420e5b865e022..ac1eaf18fcca36af0e0b614d04cc730b27265a44 100644 (file)
 }
 .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;\r
+       cursor: default;
 }
 .v-filterselect-suggestpopup {
        background: #f6f7f7;
index ec5fcb2de1e2ae892dcf852c4cc89f7278ce1255..95f65f57703bdf304f69a6ba4edd281e8e19c9cd 100644 (file)
@@ -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;
index 779b36cd5accceeda621fa619b68d2eb34f5b83a..9d1482952c384e16a7731c1a61e14e5bec4f141f 100644 (file)
@@ -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()) {
index 0d474daa5400c5956865a9ac3b8dc795273ac6cb..21e2759ddf847f4a47c2bdcf0eaa7d04c768b7a1 100644 (file)
@@ -2,47 +2,34 @@ package com.vaadin.tests.components.combobox;
 \r
 import com.vaadin.tests.components.TestBase;\r
 import com.vaadin.ui.ComboBox;\r
+import com.vaadin.ui.VerticalLayout;\r
 \r
 public class ComboBoxValueInput extends TestBase {\r
 \r
     @Override\r
     protected void setup() {\r
-        ComboBox cb = new ComboBox("A combobox without input prompt");\r
-        cb.setImmediate(true);\r
-        cb.addItem("Value 1");\r
-        cb.addItem("Value 2");\r
-        cb.addItem("Value 3");\r
+        ((VerticalLayout) getLayout()).setSpacing(true);\r
 \r
+        ComboBox cb = getComboBox("A combobox", false);\r
         addComponent(cb);\r
 \r
-        cb = new ComboBox("A combobox with input prompt");\r
+        cb = getComboBox("A combobox with input prompt", false);\r
         cb.setInputPrompt("Please select");\r
-        cb.setImmediate(true);\r
-        cb.addItem("Value 1");\r
-        cb.addItem("Value 2");\r
-        cb.addItem("Value 3");\r
+        addComponent(cb);\r
 \r
+        cb = getComboBox("A combobox with null item", true);\r
         addComponent(cb);\r
 \r
-        cb = new ComboBox("A combobox with null item");\r
+        cb = getComboBox("A combobox with null item and input prompt", true);\r
         cb.setInputPrompt("Please select");\r
-        cb.setImmediate(true);\r
-        cb.addItem("Null item");\r
-        cb.addItem("Value 1");\r
-        cb.addItem("Value 2");\r
-        cb.addItem("Value 3");\r
-        cb.setNullSelectionItemId("Null item");\r
-\r
         addComponent(cb);\r
 \r
-        cb = new ComboBox("A combobox with null item and input prompt");\r
-        cb.setImmediate(true);\r
-        cb.addItem("Null item");\r
-        cb.addItem("Value 1");\r
-        cb.addItem("Value 2");\r
-        cb.addItem("Value 3");\r
-        cb.setNullSelectionItemId("Null item");\r
+        cb = getComboBox("A disabled combobox", true);\r
+        cb.setEnabled(false);\r
+        addComponent(cb);\r
 \r
+        cb = getComboBox("A read-only combobox", true);\r
+        cb.setReadOnly(true);\r
         addComponent(cb);\r
     }\r
 \r
@@ -56,4 +43,18 @@ public class ComboBoxValueInput extends TestBase {
         return 3268;\r
     }\r
 \r
+    private ComboBox getComboBox(String caption, boolean addNullItem) {\r
+        ComboBox cb = new ComboBox(caption);\r
+        cb.setImmediate(true);\r
+        if (addNullItem) {\r
+            cb.addItem("Null item");\r
+            cb.setNullSelectionItemId("Null item");\r
+        }\r
+        cb.addItem("Value 1");\r
+        cb.addItem("Value 2");\r
+        cb.addItem("Value 3");\r
+\r
+        return cb;\r
+    }\r
+\r
 }\r