diff options
Diffstat (limited to 'src/com/itmill/toolkit/ui')
-rw-r--r-- | src/com/itmill/toolkit/ui/ComboBox.java | 31 | ||||
-rw-r--r-- | src/com/itmill/toolkit/ui/RichTextArea.java | 11 | ||||
-rw-r--r-- | src/com/itmill/toolkit/ui/TextField.java | 26 |
3 files changed, 58 insertions, 10 deletions
diff --git a/src/com/itmill/toolkit/ui/ComboBox.java b/src/com/itmill/toolkit/ui/ComboBox.java index f29b51b7d9..1c251ef0a0 100644 --- a/src/com/itmill/toolkit/ui/ComboBox.java +++ b/src/com/itmill/toolkit/ui/ComboBox.java @@ -7,6 +7,8 @@ package com.itmill.toolkit.ui; import java.util.Collection;
import com.itmill.toolkit.data.Container;
+import com.itmill.toolkit.terminal.PaintException;
+import com.itmill.toolkit.terminal.PaintTarget;
/**
* A filtering dropdown single-select. Suitable for newItemsAllowed, but it's
@@ -18,7 +20,7 @@ import com.itmill.toolkit.data.Container; */
public class ComboBox extends Select {
- private String emptyText = null;
+ private String inputPrompt = null;
public ComboBox() {
setMultiSelect(false);
@@ -51,21 +53,32 @@ public class ComboBox extends Select { super.setMultiSelect(multiSelect);
}
- /*- TODO enable and test this - client impl exists
- public String getEmptyText() {
- return emptyText;
+ /**
+ * Gets the current input prompt.
+ *
+ * @see #setInputPrompt(String)
+ * @return the current input prompt, or null if not enabled
+ */
+ public String getInputPrompt() {
+ return inputPrompt;
}
- public void setEmptyText(String emptyText) {
- this.emptyText = emptyText;
+ /**
+ * Sets the input prompt - a textual prompt that is displayed when the
+ * select would otherwise be empty, to prompt the user for input.
+ *
+ * @param inputPrompt
+ * the desired input prompt, or null to disable
+ */
+ public void setInputPrompt(String inputPrompt) {
+ this.inputPrompt = inputPrompt;
}
public void paintContent(PaintTarget target) throws PaintException {
- if (emptyText != null) {
- target.addAttribute("emptytext", emptyText);
+ if (inputPrompt != null) {
+ target.addAttribute("prompt", inputPrompt);
}
super.paintContent(target);
}
- -*/
}
diff --git a/src/com/itmill/toolkit/ui/RichTextArea.java b/src/com/itmill/toolkit/ui/RichTextArea.java index 213eb2635b..fad763819d 100644 --- a/src/com/itmill/toolkit/ui/RichTextArea.java +++ b/src/com/itmill/toolkit/ui/RichTextArea.java @@ -8,7 +8,7 @@ import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; /** - * A simple RichTextEditor to edit HTML format text. + * A simple RichTextArea to edit HTML format text. * * Note, that using {@link TextField#setMaxLength(int)} method in * {@link RichTextArea} may produce unexpected results as formatting is counted @@ -22,4 +22,13 @@ public class RichTextArea extends TextField { super.paintContent(target); } + /** + * RichTextArea does not support input prompt. + */ + @Override + public void setInputPrompt(String inputPrompt) { + throw new UnsupportedOperationException( + "RichTextArea does not support inputPrompt"); + } + } diff --git a/src/com/itmill/toolkit/ui/TextField.java b/src/com/itmill/toolkit/ui/TextField.java index 0b7336e215..e5572f0b9f 100644 --- a/src/com/itmill/toolkit/ui/TextField.java +++ b/src/com/itmill/toolkit/ui/TextField.java @@ -73,6 +73,8 @@ public class TextField extends AbstractField { */ private boolean nullSettingAllowed = false; + private String inputPrompt = null; + /** * Maximum character count in text field. */ @@ -159,6 +161,10 @@ public class TextField extends AbstractField { target.addAttribute("maxLength", getMaxLength()); } + if (inputPrompt != null) { + target.addAttribute("prompt", inputPrompt); + } + // Adds the number of column and rows final int c = getColumns(); final int r = getRows(); @@ -475,6 +481,26 @@ public class TextField extends AbstractField { } /** + * 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; + } + + /** * Gets the value formatter of TextField. * * @return the Format used to format the value. |