aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Englund <marc.englund@itmill.com>2009-02-05 14:37:01 +0000
committerMarc Englund <marc.englund@itmill.com>2009-02-05 14:37:01 +0000
commit411ce9badabef2a2f026efc1c3d0bef2f9236c0f (patch)
treeb5f6c0de5f2f5ddc30d2bed911a00e289ba442c8
parent37e44d4aaca28fbc0fb7d724386883375394bec4 (diff)
downloadvaadin-framework-411ce9badabef2a2f026efc1c3d0bef2f9236c0f.tar.gz
vaadin-framework-411ce9badabef2a2f026efc1c3d0bef2f9236c0f.zip
Sampler; sample modifications
svn changeset:6742/svn branch:trunk
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java6
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/text/LabelRichExample.java8
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/text/RichTextEditor.java9
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/text/TextArea.java7
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/text/TextAreaExample.java32
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingle.java17
-rw-r--r--src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingleExample.java15
7 files changed, 42 insertions, 52 deletions
diff --git a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java
index be49cdacad..d4dadb4914 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/panels/PanelLightExample.java
@@ -40,10 +40,10 @@ public class PanelLightExample extends VerticalLayout implements ClickListener {
}
public void buttonClick(ClickEvent event) {
- if (panel.getCaption().equals("")) {
- panel.setCaption("This is a standard Panel");
+ if (panel.getCaption() == null) {
+ panel.setCaption("This is a light Panel");
} else {
- panel.setCaption("");
+ panel.setCaption(null);
}
}
}
diff --git a/src/com/itmill/toolkit/demo/sampler/features/text/LabelRichExample.java b/src/com/itmill/toolkit/demo/sampler/features/text/LabelRichExample.java
index 354747162f..191247f81b 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/text/LabelRichExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/text/LabelRichExample.java
@@ -16,6 +16,7 @@ public class LabelRichExample extends VerticalLayout implements ClickListener {
public LabelRichExample() {
setSpacing(true);
+ setSizeUndefined(); // let layout grow with content
richText = new Label("<h1>Rich text label example</h1>"
+ "<p>In this example, the content mode is set to "
@@ -25,20 +26,21 @@ public class LabelRichExample extends VerticalLayout implements ClickListener {
addComponent(richText);
- b = new Button("Edit label");
+ b = new Button("Edit");
b.addListener(this);
addComponent(b);
+ setComponentAlignment(b, "right");
}
public void buttonClick(ClickEvent event) {
if (getComponentIterator().next() == richText) {
editor.setValue(richText.getValue());
replaceComponent(richText, editor);
- b.setCaption("Show label");
+ b.setCaption("Apply");
} else {
richText.setValue(editor.getValue());
replaceComponent(editor, richText);
- b.setCaption("Edit label");
+ b.setCaption("Edit");
}
}
diff --git a/src/com/itmill/toolkit/demo/sampler/features/text/RichTextEditor.java b/src/com/itmill/toolkit/demo/sampler/features/text/RichTextEditor.java
index 4af2b6f70f..8878584034 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/text/RichTextEditor.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/text/RichTextEditor.java
@@ -4,7 +4,7 @@ import com.itmill.toolkit.demo.sampler.APIResource;
import com.itmill.toolkit.demo.sampler.Feature;
import com.itmill.toolkit.demo.sampler.NamedExternalResource;
import com.itmill.toolkit.ui.Component;
-import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.RichTextArea;
public class RichTextEditor extends Feature {
@Override
@@ -15,20 +15,19 @@ public class RichTextEditor extends Feature {
@Override
public String getDescription() {
return "A RichTextArea component allows editing XHTML"
- + " content. Click the edit button to open the"
+ + " content. <br/>Click the edit button to open the"
+ " editor and the show button to show the edited"
+ " result as an XHTML label.";
}
@Override
public APIResource[] getRelatedAPI() {
- return new APIResource[] { new APIResource(Label.class) };
+ return new APIResource[] { new APIResource(RichTextArea.class) };
}
@Override
public Class[] getRelatedFeatures() {
- return new Class[] { LabelPlain.class, LabelPreformatted.class,
- LabelRich.class, TextFieldSingle.class, TextArea.class };
+ return new Class[] { TextArea.class, LabelRich.class };
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/text/TextArea.java b/src/com/itmill/toolkit/demo/sampler/features/text/TextArea.java
index 52611d9d7c..474a8620e4 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/text/TextArea.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/text/TextArea.java
@@ -15,14 +15,9 @@ public class TextArea extends Feature {
public String getDescription() {
return "A multi-line Textfield component allows you to input"
+ " several lines of text."
- + "<br>In this example the text will be shown in a"
- + " label component after you press enter."
+ "<br>The amount of columns and lines can be set, and both are set here to"
+ " 20 characters. Note that this only affects the width and height of the"
- + " component, not the allowed length of input."
- + "<br>For sensitive data input, the textfield can"
- + " also be set into secret mode where the input will not be"
- + " echoed to display.";
+ + " component, not the allowed length of input.";
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/text/TextAreaExample.java b/src/com/itmill/toolkit/demo/sampler/features/text/TextAreaExample.java
index f99226df23..c031e499bf 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/text/TextAreaExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/text/TextAreaExample.java
@@ -2,34 +2,33 @@ package com.itmill.toolkit.demo.sampler.features.text;
import com.itmill.toolkit.data.Property;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.HorizontalLayout;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.TextField;
-import com.itmill.toolkit.ui.VerticalLayout;
-public class TextAreaExample extends VerticalLayout implements
+public class TextAreaExample extends HorizontalLayout implements
Property.ValueChangeListener {
+ private static final String initialText = "The quick brown fox jumps over the lazy dog.";
+
private Label plainText;
- private final TextField editor = new TextField();
+ private final TextField editor;
public TextAreaExample() {
setSpacing(true);
- plainText = new Label("Initial text.\n"
- + "\nPlease note that within a textarea,"
- + "\nthe enter key will not dispatch the"
- + "\nchanges to the server. To fire a"
- + "\nvaluechange event, you must deactivate"
- + "\nthe textarea.");
- plainText.setContentMode(Label.CONTENT_PREFORMATTED);
-
+ editor = new TextField("", initialText);
editor.addListener(this);
editor.setImmediate(true);
editor.setColumns(20);
editor.setRows(20);
- // editor.setSecret(true);
-
addComponent(editor);
+
+ addComponent(new Button(">>"));
+
+ plainText = new Label(initialText);
+ plainText.setContentMode(Label.CONTENT_XHTML);
addComponent(plainText);
}
@@ -38,6 +37,11 @@ public class TextAreaExample extends VerticalLayout implements
* label component
*/
public void valueChange(ValueChangeEvent event) {
- plainText.setValue(editor.getValue());
+ String text = (String) editor.getValue();
+ if (text != null) {
+ // replace newline with BR, because we're using Label.CONTENT_XHTML
+ text = text.replaceAll("\n", "<br/>");
+ }
+ plainText.setValue(text);
}
}
diff --git a/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingle.java b/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingle.java
index aeacafb54b..50b910a456 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingle.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingle.java
@@ -2,8 +2,9 @@ package com.itmill.toolkit.demo.sampler.features.text;
import com.itmill.toolkit.demo.sampler.APIResource;
import com.itmill.toolkit.demo.sampler.Feature;
+import com.itmill.toolkit.demo.sampler.FeatureSet;
import com.itmill.toolkit.demo.sampler.NamedExternalResource;
-import com.itmill.toolkit.ui.Label;
+import com.itmill.toolkit.ui.TextField;
public class TextFieldSingle extends Feature {
@Override
@@ -14,26 +15,20 @@ public class TextFieldSingle extends Feature {
@Override
public String getDescription() {
return "A single line Textfield component allows you to input"
- + " one line of text."
- + "<br>In this example the text will be shown in a"
- + " label component after you press enter."
- + "<br>The amount of columns can be set, and is set here to"
- + " 5 characters. Note that this only affects the width of the"
- + " component, not the allowed length of input."
- + "<br>For sensitive data input, the textfield can"
+ + " one line of text.<br/>"
+ + "<br/>For sensitive data input, the textfield can"
+ " also be set into secret mode where the input will not be"
+ " echoed to display.";
}
@Override
public APIResource[] getRelatedAPI() {
- return new APIResource[] { new APIResource(Label.class) };
+ return new APIResource[] { new APIResource(TextField.class) };
}
@Override
public Class[] getRelatedFeatures() {
- return new Class[] { LabelPlain.class, LabelPreformatted.class,
- RichTextEditor.class };
+ return new Class[] { FeatureSet.Texts.class };
}
@Override
diff --git a/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingleExample.java b/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingleExample.java
index 1095fc94ee..a8f01c9870 100644
--- a/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingleExample.java
+++ b/src/com/itmill/toolkit/demo/sampler/features/text/TextFieldSingleExample.java
@@ -2,28 +2,22 @@ package com.itmill.toolkit.demo.sampler.features.text;
import com.itmill.toolkit.data.Property;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
-import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.TextField;
import com.itmill.toolkit.ui.VerticalLayout;
public class TextFieldSingleExample extends VerticalLayout implements
Property.ValueChangeListener {
- private Label plainText;
- private final TextField editor = new TextField();
+ private final TextField editor = new TextField("Echo this:");
public TextFieldSingleExample() {
setSpacing(true);
- plainText = new Label("Initial text");
- plainText.setContentMode(Label.CONTENT_TEXT);
-
editor.addListener(this);
editor.setImmediate(true);
- editor.setColumns(5);
- // editor.setSecret(true);
+ // editor.setColumns(5); // guarantees that at least 5 chars fit
+ // editor.setSecret(true); // e.g. for passwords
- addComponent(plainText);
addComponent(editor);
}
@@ -32,6 +26,7 @@ public class TextFieldSingleExample extends VerticalLayout implements
* label component
*/
public void valueChange(ValueChangeEvent event) {
- plainText.setValue(editor.getValue());
+ // Show the new value we received
+ getWindow().showNotification((String) editor.getValue());
}
}