}\r
\r
public void buttonClick(ClickEvent event) {\r
- if (panel.getCaption().equals("")) {\r
- panel.setCaption("This is a standard Panel");\r
+ if (panel.getCaption() == null) {\r
+ panel.setCaption("This is a light Panel");\r
} else {\r
- panel.setCaption("");\r
+ panel.setCaption(null);\r
}\r
}\r
}\r
\r
public LabelRichExample() {\r
setSpacing(true);\r
+ setSizeUndefined(); // let layout grow with content\r
\r
richText = new Label("<h1>Rich text label example</h1>"\r
+ "<p>In this example, the content mode is set to "\r
\r
addComponent(richText);\r
\r
- b = new Button("Edit label");\r
+ b = new Button("Edit");\r
b.addListener(this);\r
addComponent(b);\r
+ setComponentAlignment(b, "right");\r
}\r
\r
public void buttonClick(ClickEvent event) {\r
if (getComponentIterator().next() == richText) {\r
editor.setValue(richText.getValue());\r
replaceComponent(richText, editor);\r
- b.setCaption("Show label");\r
+ b.setCaption("Apply");\r
} else {\r
richText.setValue(editor.getValue());\r
replaceComponent(editor, richText);\r
- b.setCaption("Edit label");\r
+ b.setCaption("Edit");\r
}\r
}\r
\r
import com.itmill.toolkit.demo.sampler.Feature;\r
import com.itmill.toolkit.demo.sampler.NamedExternalResource;\r
import com.itmill.toolkit.ui.Component;\r
-import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.RichTextArea;\r
\r
public class RichTextEditor extends Feature {\r
@Override\r
@Override\r
public String getDescription() {\r
return "A RichTextArea component allows editing XHTML"\r
- + " content. Click the edit button to open the"\r
+ + " content. <br/>Click the edit button to open the"\r
+ " editor and the show button to show the edited"\r
+ " result as an XHTML label.";\r
}\r
\r
@Override\r
public APIResource[] getRelatedAPI() {\r
- return new APIResource[] { new APIResource(Label.class) };\r
+ return new APIResource[] { new APIResource(RichTextArea.class) };\r
}\r
\r
@Override\r
public Class[] getRelatedFeatures() {\r
- return new Class[] { LabelPlain.class, LabelPreformatted.class,\r
- LabelRich.class, TextFieldSingle.class, TextArea.class };\r
+ return new Class[] { TextArea.class, LabelRich.class };\r
}\r
\r
@Override\r
public String getDescription() {\r
return "A multi-line Textfield component allows you to input"\r
+ " several lines of text."\r
- + "<br>In this example the text will be shown in a"\r
- + " label component after you press enter."\r
+ "<br>The amount of columns and lines can be set, and both are set here to"\r
+ " 20 characters. Note that this only affects the width and height of the"\r
- + " component, not the allowed length of input."\r
- + "<br>For sensitive data input, the textfield can"\r
- + " also be set into secret mode where the input will not be"\r
- + " echoed to display.";\r
+ + " component, not the allowed length of input.";\r
}\r
\r
@Override\r
\r
import com.itmill.toolkit.data.Property;\r
import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.HorizontalLayout;\r
import com.itmill.toolkit.ui.Label;\r
import com.itmill.toolkit.ui.TextField;\r
-import com.itmill.toolkit.ui.VerticalLayout;\r
\r
-public class TextAreaExample extends VerticalLayout implements\r
+public class TextAreaExample extends HorizontalLayout implements\r
Property.ValueChangeListener {\r
\r
+ private static final String initialText = "The quick brown fox jumps over the lazy dog.";\r
+\r
private Label plainText;\r
- private final TextField editor = new TextField();\r
+ private final TextField editor;\r
\r
public TextAreaExample() {\r
setSpacing(true);\r
\r
- plainText = new Label("Initial text.\n"\r
- + "\nPlease note that within a textarea,"\r
- + "\nthe enter key will not dispatch the"\r
- + "\nchanges to the server. To fire a"\r
- + "\nvaluechange event, you must deactivate"\r
- + "\nthe textarea.");\r
- plainText.setContentMode(Label.CONTENT_PREFORMATTED);\r
-\r
+ editor = new TextField("", initialText);\r
editor.addListener(this);\r
editor.setImmediate(true);\r
editor.setColumns(20);\r
editor.setRows(20);\r
- // editor.setSecret(true);\r
-\r
addComponent(editor);\r
+\r
+ addComponent(new Button(">>"));\r
+\r
+ plainText = new Label(initialText);\r
+ plainText.setContentMode(Label.CONTENT_XHTML);\r
addComponent(plainText);\r
}\r
\r
* label component\r
*/\r
public void valueChange(ValueChangeEvent event) {\r
- plainText.setValue(editor.getValue());\r
+ String text = (String) editor.getValue();\r
+ if (text != null) {\r
+ // replace newline with BR, because we're using Label.CONTENT_XHTML\r
+ text = text.replaceAll("\n", "<br/>");\r
+ }\r
+ plainText.setValue(text);\r
}\r
}\r
\r
import com.itmill.toolkit.demo.sampler.APIResource;\r
import com.itmill.toolkit.demo.sampler.Feature;\r
+import com.itmill.toolkit.demo.sampler.FeatureSet;\r
import com.itmill.toolkit.demo.sampler.NamedExternalResource;\r
-import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.TextField;\r
\r
public class TextFieldSingle extends Feature {\r
@Override\r
@Override\r
public String getDescription() {\r
return "A single line Textfield component allows you to input"\r
- + " one line of text."\r
- + "<br>In this example the text will be shown in a"\r
- + " label component after you press enter."\r
- + "<br>The amount of columns can be set, and is set here to"\r
- + " 5 characters. Note that this only affects the width of the"\r
- + " component, not the allowed length of input."\r
- + "<br>For sensitive data input, the textfield can"\r
+ + " one line of text.<br/>"\r
+ + "<br/>For sensitive data input, the textfield can"\r
+ " also be set into secret mode where the input will not be"\r
+ " echoed to display.";\r
}\r
\r
@Override\r
public APIResource[] getRelatedAPI() {\r
- return new APIResource[] { new APIResource(Label.class) };\r
+ return new APIResource[] { new APIResource(TextField.class) };\r
}\r
\r
@Override\r
public Class[] getRelatedFeatures() {\r
- return new Class[] { LabelPlain.class, LabelPreformatted.class,\r
- RichTextEditor.class };\r
+ return new Class[] { FeatureSet.Texts.class };\r
}\r
\r
@Override\r
\r
import com.itmill.toolkit.data.Property;\r
import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
-import com.itmill.toolkit.ui.Label;\r
import com.itmill.toolkit.ui.TextField;\r
import com.itmill.toolkit.ui.VerticalLayout;\r
\r
public class TextFieldSingleExample extends VerticalLayout implements\r
Property.ValueChangeListener {\r
\r
- private Label plainText;\r
- private final TextField editor = new TextField();\r
+ private final TextField editor = new TextField("Echo this:");\r
\r
public TextFieldSingleExample() {\r
setSpacing(true);\r
\r
- plainText = new Label("Initial text");\r
- plainText.setContentMode(Label.CONTENT_TEXT);\r
-\r
editor.addListener(this);\r
editor.setImmediate(true);\r
- editor.setColumns(5);\r
- // editor.setSecret(true);\r
+ // editor.setColumns(5); // guarantees that at least 5 chars fit\r
+ // editor.setSecret(true); // e.g. for passwords\r
\r
- addComponent(plainText);\r
addComponent(editor);\r
}\r
\r
* label component\r
*/\r
public void valueChange(ValueChangeEvent event) {\r
- plainText.setValue(editor.getValue());\r
+ // Show the new value we received\r
+ getWindow().showNotification((String) editor.getValue());\r
}\r
}\r