diff options
-rw-r--r-- | WebContent/VAADIN/themes/base/datefield/datefield.css | 4 | ||||
-rw-r--r-- | WebContent/VAADIN/themes/base/styles.css | 8 | ||||
-rw-r--r-- | WebContent/VAADIN/themes/reindeer/datefield/datefield.css | 7 | ||||
-rw-r--r-- | WebContent/VAADIN/themes/reindeer/styles.css | 15 | ||||
-rw-r--r-- | WebContent/VAADIN/themes/runo/datefield/datefield.css | 4 | ||||
-rw-r--r-- | WebContent/VAADIN/themes/runo/styles.css | 12 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java | 38 | ||||
-rw-r--r-- | src/com/vaadin/ui/PopupDateField.java | 34 |
8 files changed, 115 insertions, 7 deletions
diff --git a/WebContent/VAADIN/themes/base/datefield/datefield.css b/WebContent/VAADIN/themes/base/datefield/datefield.css index e7a26a97fd..f1c38513e1 100644 --- a/WebContent/VAADIN/themes/base/datefield/datefield.css +++ b/WebContent/VAADIN/themes/base/datefield/datefield.css @@ -8,6 +8,10 @@ .v-datefield-button { cursor: pointer; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: italic; +} .v-datefield .v-datefield-button-readonly { display: none; } diff --git a/WebContent/VAADIN/themes/base/styles.css b/WebContent/VAADIN/themes/base/styles.css index fd3522e312..f445cb2500 100644 --- a/WebContent/VAADIN/themes/base/styles.css +++ b/WebContent/VAADIN/themes/base/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"9_9_9_INTERNAL-DEBUG-BUILD";} -.v-theme-version-9_9_9_INTERNAL-DEBUG-BUILD {display: none;} +.v-theme-version:after {content:"6_4_0_dev-20100607";} +.v-theme-version-6_4_0_dev-20100607 {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -493,6 +493,10 @@ div.v-app-loading { .v-datefield-button { cursor: pointer; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: italic; +} .v-datefield .v-datefield-button-readonly { display: none; } diff --git a/WebContent/VAADIN/themes/reindeer/datefield/datefield.css b/WebContent/VAADIN/themes/reindeer/datefield/datefield.css index 2ae4cb59ee..3601b38e84 100644 --- a/WebContent/VAADIN/themes/reindeer/datefield/datefield.css +++ b/WebContent/VAADIN/themes/reindeer/datefield/datefield.css @@ -258,6 +258,10 @@ td.v-datefield-calendarpanel-nextyear { -moz-border-radius: 3px; -webkit-border-radius: 3px; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: normal; +} .v-datefield-popupcalendar .v-datefield-button { width: 24px; height: 23px; @@ -361,4 +365,7 @@ td.v-datefield-calendarpanel-nextyear { } .black .v-datefield-calendarpanel .v-last { background-image: url(img/weekday-last-black.png); /** sprite-ref: black-verticals; sprite-alignment: right */ +} +.black .v-datefield-prompt .v-datefield-textfield { + color: #5f6366; }
\ No newline at end of file diff --git a/WebContent/VAADIN/themes/reindeer/styles.css b/WebContent/VAADIN/themes/reindeer/styles.css index 7252230469..740423593f 100644 --- a/WebContent/VAADIN/themes/reindeer/styles.css +++ b/WebContent/VAADIN/themes/reindeer/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"9_9_9_INTERNAL-DEBUG-BUILD";} -.v-theme-version-9_9_9_INTERNAL-DEBUG-BUILD {display: none;} +.v-theme-version:after {content:"6_4_0_dev-20100607";} +.v-theme-version-6_4_0_dev-20100607 {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -493,6 +493,10 @@ div.v-app-loading { .v-datefield-button { cursor: pointer; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: italic; +} .v-datefield .v-datefield-button-readonly { display: none; } @@ -3056,6 +3060,10 @@ td.v-datefield-calendarpanel-nextyear { -moz-border-radius: 3px; -webkit-border-radius: 3px; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: normal; +} .v-datefield-popupcalendar .v-datefield-button { width: 24px; height: 23px; @@ -3194,6 +3202,9 @@ td.v-datefield-calendarpanel-nextyear { -background-image: url(common/img/black-vertical-sprites-ie6.png); background-position: right -294px; } +.black .v-datefield-prompt .v-datefield-textfield { + color: #5f6366; +} .v-formlayout-errorcell { width: 13px; diff --git a/WebContent/VAADIN/themes/runo/datefield/datefield.css b/WebContent/VAADIN/themes/runo/datefield/datefield.css index 290784d97d..0b65fd9054 100644 --- a/WebContent/VAADIN/themes/runo/datefield/datefield.css +++ b/WebContent/VAADIN/themes/runo/datefield/datefield.css @@ -139,6 +139,10 @@ td.v-datefield-calendarpanel-month { .v-datefield-rendererror .v-textfield { background: #ff9999; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: normal; +} /* IE specific styles */ .v-ie7 .v-datefield-button { background-position: right 1px; diff --git a/WebContent/VAADIN/themes/runo/styles.css b/WebContent/VAADIN/themes/runo/styles.css index 1b248f22d8..a8f3fd26f9 100644 --- a/WebContent/VAADIN/themes/runo/styles.css +++ b/WebContent/VAADIN/themes/runo/styles.css @@ -1,5 +1,5 @@ -.v-theme-version:after {content:"9_9_9_INTERNAL-DEBUG-BUILD";} -.v-theme-version-9_9_9_INTERNAL-DEBUG-BUILD {display: none;} +.v-theme-version:after {content:"6_4_0_dev-20100607";} +.v-theme-version-6_4_0_dev-20100607 {display: none;} /* Automatically compiled css file from subdirectories. */ .v-absolutelayout-wrapper { @@ -493,6 +493,10 @@ div.v-app-loading { .v-datefield-button { cursor: pointer; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: italic; +} .v-datefield .v-datefield-button-readonly { display: none; } @@ -2654,6 +2658,10 @@ td.v-datefield-calendarpanel-month { .v-datefield-rendererror .v-textfield { background: #ff9999; } +.v-datefield-prompt .v-datefield-textfield { + color: #999; + font-style: normal; +} /* IE specific styles */ .v-ie7 .v-datefield-button { background-position: right 1px; diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java index 209c5cabde..92e3aad39b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java @@ -44,6 +44,11 @@ public class VTextualDate extends VDateField implements Paintable, Field, private boolean lenient; + private static final String CLASSNAME_PROMPT = "prompt"; + private static final String ATTR_INPUTPROMPT = "prompt"; + private String inputPrompt = ""; + private boolean prompting = false; + public VTextualDate() { super(); @@ -57,6 +62,10 @@ public class VTextualDate extends VDateField implements Paintable, Field, public void onFocus(FocusEvent event) { text.addStyleName(VTextField.CLASSNAME + "-" + VTextField.CLASSNAME_FOCUS); + if (prompting) { + text.setText(""); + setPrompting(false); + } if (client != null && client.hasEventListeners(VTextualDate.this, EventId.FOCUS)) { @@ -68,6 +77,12 @@ public class VTextualDate extends VDateField implements Paintable, Field, public void onBlur(BlurEvent event) { text.removeStyleName(VTextField.CLASSNAME + "-" + VTextField.CLASSNAME_FOCUS); + String value = getText(); + setPrompting(inputPrompt != null + && (value == null || "".equals(value))); + if (prompting) { + text.setText(readonly ? "" : inputPrompt); + } if (client != null && client.hasEventListeners(VTextualDate.this, EventId.BLUR)) { @@ -91,6 +106,8 @@ public class VTextualDate extends VDateField implements Paintable, Field, formatStr = uidl.getStringAttribute("format"); } + inputPrompt = uidl.getStringAttribute(ATTR_INPUTPROMPT); + lenient = !uidl.getBooleanAttribute("strict"); buildDate(); @@ -163,7 +180,7 @@ public class VTextualDate extends VDateField implements Paintable, Field, dateText = ""; } - text.setText(dateText); + setText(dateText); text.setEnabled(enabled); text.setReadOnly(readonly); @@ -175,6 +192,15 @@ public class VTextualDate extends VDateField implements Paintable, Field, } + protected void setPrompting(boolean prompting) { + this.prompting = prompting; + if (prompting) { + addStyleDependentName(CLASSNAME_PROMPT); + } else { + removeStyleDependentName(CLASSNAME_PROMPT); + } + } + public void onChange(ChangeEvent event) { if (!text.getText().equals("")) { try { @@ -357,10 +383,20 @@ public class VTextualDate extends VDateField implements Paintable, Field, } protected String getText() { + if (prompting) { + return ""; + } return text.getText(); } protected void setText(String text) { + if (inputPrompt != null && (text == null || "".equals(text))) { + text = readonly ? "" : inputPrompt; + setPrompting(true); + } else { + setPrompting(false); + } + this.text.setText(text); } diff --git a/src/com/vaadin/ui/PopupDateField.java b/src/com/vaadin/ui/PopupDateField.java index 5164601f0d..e975cb23d2 100644 --- a/src/com/vaadin/ui/PopupDateField.java +++ b/src/com/vaadin/ui/PopupDateField.java @@ -7,6 +7,8 @@ package com.vaadin.ui; import java.util.Date;
import com.vaadin.data.Property;
+import com.vaadin.terminal.PaintException;
+import com.vaadin.terminal.PaintTarget;
/**
* <p>
@@ -24,6 +26,8 @@ import com.vaadin.data.Property; @SuppressWarnings("serial")
public class PopupDateField extends DateField {
+ private String inputPrompt = null;
+
public PopupDateField() {
super();
type = TYPE_POPUP;
@@ -49,4 +53,34 @@ public class PopupDateField extends DateField { type = TYPE_POPUP;
}
+ @Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ super.paintContent(target);
+
+ if (inputPrompt != null) {
+ target.addAttribute("prompt", inputPrompt);
+ }
+ }
+
+ /**
+ * Gets the current input prompt.
+ *
+ * @see #setInputPrompt(String)
+ * @return the current input prompt, or null if not enabled
+ */
+ public String getInputPrompt() {
+ return inputPrompt;
+ }
+
+ /**
+ * Sets the input prompt - a textual prompt that is displayed when the field
+ * would otherwise be empty, to prompt the user for input.
+ *
+ * @param inputPrompt
+ */
+ public void setInputPrompt(String inputPrompt) {
+ this.inputPrompt = inputPrompt;
+ requestRepaint();
+ }
+
}
|