summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
index e69967d..bf48c5b 100644
--- a/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
+++ b/vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java
@@ -69,6 +69,46 @@ class DataMappingLayout extends FormLayout {
}
});
//
+ class IntegerObjectProperty implements Property {
+ Integer data = 0;
+ boolean readOnly = false;
+ public Class<?> getType() {
+ return Integer.class;
+ }
+ public Object getValue() {
+ return data;
+ }
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+ public void setReadOnly(boolean newStatus) {
+ readOnly = newStatus;
+ }
+ public void setValue(Object newValue) throws ReadOnlyException, ConversionException {
+ if (readOnly)
+ throw new ReadOnlyException();
+ if (newValue instanceof Integer)
+ data = (Integer) newValue;
+ else if (newValue instanceof String)
+ try {
+ data = Integer.parseInt((String) newValue, 16);
+ } catch (NumberFormatException e) {
+ throw new ConversionException("Must be an integer (from property)");
+ }
+ else
+ throw new ConversionException("Unknown entry type (from property)");
+ }
+ @Override
+ public String toString() {
+ return Integer.toHexString(data)+" (hex)";
+ }
+ };
+ final IntegerObjectProperty intProperty = new IntegerObjectProperty();
+ intProperty.setValue(666);
+ final TextField tf4 = new TextField("MyObjectProperty",intProperty);
+ tf4.setImmediate(true);
+ addComponent(tf4);
+ //
Button closeButton = new Button("close the application");
closeButton.setDescription("This will close the application");
addComponent(closeButton );