.v-datefield {
white-space: nowrap;
+ float: left; /* Force minimum width */
}
.v-datefield-textfield {
vertical-align: top;
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;
.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;
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";
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;
}
public void onKeyDown(KeyDownEvent event) {
- if (enabled) {
+ if (enabled && !readonly) {
if (suggestionPopup.isAttached()) {
popupKeyDown(event);
} else {
}
public void onKeyUp(KeyUpEvent event) {
- if (enabled) {
+ if (enabled && !readonly) {
switch (event.getNativeKeyCode()) {
case KeyCodes.KEY_ENTER:
case KeyCodes.KEY_TAB:
* 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()) {
\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
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