diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-09-26 14:50:04 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-09-26 14:50:04 +0200 |
commit | dc0608d8e8c82aeec8261f11dea51e79cf8e38b9 (patch) | |
tree | 74ce6114c33c53bf7bfbb7c557b34dbbe1f9211e /vaadin-app/src | |
parent | 36b613ad4b43a177a7a6a275f8cf0feb7c2b9211 (diff) | |
download | skeletons-dc0608d8e8c82aeec8261f11dea51e79cf8e38b9.zip skeletons-dc0608d8e8c82aeec8261f11dea51e79cf8e38b9.tar.gz |
vaadin-app: instanciate Property abscract class
Diffstat (limited to 'vaadin-app/src')
-rw-r--r-- | vaadin-app/src/ch/asynk/helloworld/HelloWorldApp.java | 40 |
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 ); |