summaryrefslogtreecommitdiffstats
path: root/vaadin-app/src/ch/asynk/helloworld
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-10-06 11:19:49 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-10-06 11:19:49 +0200
commit9227201462ed009ba8fccd6e1c198abcfea3b5c5 (patch)
tree64fce727d527a0154cd97822ea645adc616afe59 /vaadin-app/src/ch/asynk/helloworld
parent034c2ad36a0d659cd768922ba14cf7de77ba1ac0 (diff)
downloadskeletons-9227201462ed009ba8fccd6e1c198abcfea3b5c5.zip
skeletons-9227201462ed009ba8fccd6e1c198abcfea3b5c5.tar.gz
vaadin-app: update DataMappingLayout
Diffstat (limited to 'vaadin-app/src/ch/asynk/helloworld')
-rw-r--r--vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java45
1 files changed, 35 insertions, 10 deletions
diff --git a/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java b/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java
index 70d3b0e..42801d8 100644
--- a/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java
+++ b/vaadin-app/src/ch/asynk/helloworld/DataMappingLayout.java
@@ -6,13 +6,17 @@ import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.Validator;
import com.vaadin.data.validator.DoubleValidator;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.Panel;
import com.vaadin.ui.Label;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.TextField;
-public class DataMappingLayout extends FormLayout {
+public class DataMappingLayout extends VerticalLayout {
//
private static final long serialVersionUID = 1L;
//
@@ -21,13 +25,27 @@ public class DataMappingLayout extends FormLayout {
public DataMappingLayout(Context context) {
ctx = context;
//
+ final AbstractComponent pa = buildPanel();
+ pa.setWidth(600,UNITS_PIXELS);
+ pa.setHeight(400,UNITS_PIXELS);
+ addComponent(pa);
+ setComponentAlignment(pa, Alignment.MIDDLE_CENTER);
+ //
+ }
+ //
+ private AbstractComponent buildPanel() {
+ Panel panel = new Panel("Data Mapping Layout");
+ FormLayout layout = new FormLayout();
+ panel.setContent(layout);
+ //
final TextField tf1 = new TextField("Property.ValueChangeListener");
tf1.setImmediate(true);
- addComponent(tf1);
+ layout.addComponent(tf1);
final Label lb1 = new Label();
lb1.setCaption("The Value");
- addComponent(lb1);
+ layout.addComponent(lb1);
tf1.addListener( new Property.ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
@Override
public void valueChange(ValueChangeEvent event) {
String value = (String) tf1.getValue();
@@ -41,17 +59,18 @@ public class DataMappingLayout extends FormLayout {
tf2.setImmediate(true);
tf2.addValidator( new DoubleValidator("It should be a double") );
//tf2.setValidationVisible(false); // nothing will happen
- addComponent(tf2);
+ layout.addComponent(tf2);
final Label lb2 = new Label(property);
lb2.setCaption("The Value");
- addComponent(lb2);
+ layout.addComponent(lb2);
//
final TextField tf3 = new TextField("No spaces");
- addComponent(tf3);
+ layout.addComponent(tf3);
tf3.setComponentError(null); // (actually the default)
final Button b1 = new Button("Ok!");
- addComponent(b1);
+ layout.addComponent(b1);
b1.addListener(new Button.ClickListener() {
+ private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
if (! ((String) tf3.getValue()).matches("^\\w*$")) {
@@ -64,6 +83,7 @@ public class DataMappingLayout extends FormLayout {
//
// final Validator intValidator = new Validator() { ... }
class MyIntValidator implements Validator {
+ private static final long serialVersionUID = 1L;
public boolean isValid(Object value) {
if (value == null || !(value instanceof String)) {
return false;
@@ -83,9 +103,10 @@ public class DataMappingLayout extends FormLayout {
final TextField tf5 = new TextField("MyIntValidator");
tf5.addValidator(new MyIntValidator());
tf5.setImmediate(true);
- addComponent(tf5);
+ layout.addComponent(tf5);
//
class IntegerObjectProperty implements Property {
+ private static final long serialVersionUID = 1L;
Integer data = 0;
boolean readOnly = false;
public Class<?> getType() {
@@ -124,22 +145,26 @@ public class DataMappingLayout extends FormLayout {
final TextField tf4 = new TextField("MyObjectProperty",intProperty);
tf4.setImmediate(true);
tf4.setErrorHandler(new ComponentErrorHandler() {
+ private static final long serialVersionUID = 1L;
@Override
public boolean handleComponentError(ComponentErrorEvent event) {
tf4.setComponentError(new UserError("Must be an integer (from handler)"));
return true;
}
});
- addComponent(tf4);
+ layout.addComponent(tf4);
//
Button nextButton = new Button("next layout");
nextButton.setDescription("Go to next layout");
- addComponent(nextButton );
+ layout.addComponent(nextButton );
nextButton.addListener( new Button.ClickListener() {
+ private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
getApplication().getMainWindow().setContent( new LayoutLayout(ctx) );
}
});
+ //
+ return panel;
}
}