aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2009-05-14 07:06:56 +0000
committerHenri Sara <henri.sara@itmill.com>2009-05-14 07:06:56 +0000
commita7b834307fc89a1b194cf460e07ac60e92274b4a (patch)
tree553b079189d19db2eca06ed63f947a83d554514b
parent96a58e53f1e1d0e79204b97bd0f1d4e48783aada (diff)
downloadvaadin-framework-a7b834307fc89a1b194cf460e07ac60e92274b4a.tar.gz
vaadin-framework-a7b834307fc89a1b194cf460e07ac60e92274b4a.zip
Reformatted AddressBook PersonForm with Eclipse default formatting settings.
svn changeset:7788/svn branch:6.0
-rw-r--r--src/com/vaadin/demo/tutorial/addressbook/ui/PersonForm.java296
1 files changed, 148 insertions, 148 deletions
diff --git a/src/com/vaadin/demo/tutorial/addressbook/ui/PersonForm.java b/src/com/vaadin/demo/tutorial/addressbook/ui/PersonForm.java
index c15bcd17ba..131c1ae9fd 100644
--- a/src/com/vaadin/demo/tutorial/addressbook/ui/PersonForm.java
+++ b/src/com/vaadin/demo/tutorial/addressbook/ui/PersonForm.java
@@ -24,153 +24,153 @@ import com.vaadin.ui.Button.ClickListener;
public class PersonForm extends Form implements ClickListener {
- private Button save = new Button("Save", (ClickListener) this);
- private Button cancel = new Button("Cancel", (ClickListener) this);
- private Button edit = new Button("Edit", (ClickListener) this);
- private final ComboBox cities = new ComboBox("City");
-
- private AddressBookApplication app;
- private boolean newContactMode = false;
- private Person newPerson = null;
-
- public PersonForm(AddressBookApplication app) {
- this.app = app;
-
- /*
- * Enable buffering so that commit() must be called for the form before
- * input is written to the data. (Form input is not written immediately
- * through to the underlying object.)
- */
- setWriteThrough(false);
-
- HorizontalLayout footer = new HorizontalLayout();
- footer.setSpacing(true);
- footer.addComponent(save);
- footer.addComponent(cancel);
- footer.addComponent(edit);
- footer.setVisible(false);
-
- setFooter(footer);
-
- /* Allow the user to enter new cities */
- cities.setNewItemsAllowed(true);
- /* We do not want to use null values */
- cities.setNullSelectionAllowed(false);
- /* Add an empty city used for selecting no city */
- cities.addItem("");
-
- /* Populate cities select using the cities in the data container */
- PersonContainer ds = app.getDataSource();
- for (Iterator<Person> it = ds.getItemIds().iterator(); it.hasNext();) {
- String city = (it.next()).getCity();
- cities.addItem(city);
- }
-
- /*
- * Field factory for overriding how the component for city selection is
- * created
- */
- setFormFieldFactory(new DefaultFieldFactory() {
- @Override
- public Field createField(Item item, Object propertyId,
- Component uiContext) {
- if (propertyId.equals("city")) {
- cities.setWidth("200px");
- return cities;
- }
-
- Field field = super.createField(item, propertyId, uiContext);
- if (propertyId.equals("postalCode")) {
- TextField tf = (TextField) field;
- /*
- * We do not want to display "null" to the user when the
- * field is empty
- */
- tf.setNullRepresentation("");
-
- /* Add a validator for postalCode and make it required */
- tf.addValidator(new PostalCodeValidator());
- tf.setRequired(true);
- } else if (propertyId.equals("email")) {
- /* Add a validator for email and make it required */
- field.addValidator(new EmailValidator());
- field.setRequired(true);
-
- }
-
- field.setWidth("200px");
- return field;
- }
- });
- }
-
- public void buttonClick(ClickEvent event) {
- Button source = event.getButton();
-
- if (source == save) {
- /* If the given input is not valid there is no point in continuing */
- if (!isValid()) {
- return;
- }
-
- commit();
- if (newContactMode) {
- /* We need to add the new person to the container */
- Item addedItem = app.getDataSource().addItem(newPerson);
- /*
- * We must update the form to use the Item from our datasource
- * as we are now in edit mode (no longer in add mode)
- */
- setItemDataSource(addedItem);
-
- newContactMode = false;
- }
- setReadOnly(true);
- } else if (source == cancel) {
- if (newContactMode) {
- newContactMode = false;
- /* Clear the form and make it invisible */
- setItemDataSource(null);
- } else {
- discard();
- }
- setReadOnly(true);
- } else if (source == edit) {
- setReadOnly(false);
- }
- }
-
- @Override
- public void setItemDataSource(Item newDataSource) {
- newContactMode = false;
-
- if (newDataSource != null) {
- List<Object> orderedProperties = Arrays
- .asList(PersonContainer.NATURAL_COL_ORDER);
- super.setItemDataSource(newDataSource, orderedProperties);
-
- setReadOnly(true);
- getFooter().setVisible(true);
- } else {
- super.setItemDataSource(null);
- getFooter().setVisible(false);
- }
- }
-
- @Override
- public void setReadOnly(boolean readOnly) {
- super.setReadOnly(readOnly);
- save.setVisible(!readOnly);
- cancel.setVisible(!readOnly);
- edit.setVisible(readOnly);
- }
-
- public void addContact() {
- // Create a temporary item for the form
- newPerson = new Person();
- setItemDataSource(new BeanItem(newPerson));
- newContactMode = true;
- setReadOnly(false);
- }
+ private Button save = new Button("Save", (ClickListener) this);
+ private Button cancel = new Button("Cancel", (ClickListener) this);
+ private Button edit = new Button("Edit", (ClickListener) this);
+ private final ComboBox cities = new ComboBox("City");
+
+ private AddressBookApplication app;
+ private boolean newContactMode = false;
+ private Person newPerson = null;
+
+ public PersonForm(AddressBookApplication app) {
+ this.app = app;
+
+ /*
+ * Enable buffering so that commit() must be called for the form before
+ * input is written to the data. (Form input is not written immediately
+ * through to the underlying object.)
+ */
+ setWriteThrough(false);
+
+ HorizontalLayout footer = new HorizontalLayout();
+ footer.setSpacing(true);
+ footer.addComponent(save);
+ footer.addComponent(cancel);
+ footer.addComponent(edit);
+ footer.setVisible(false);
+
+ setFooter(footer);
+
+ /* Allow the user to enter new cities */
+ cities.setNewItemsAllowed(true);
+ /* We do not want to use null values */
+ cities.setNullSelectionAllowed(false);
+ /* Add an empty city used for selecting no city */
+ cities.addItem("");
+
+ /* Populate cities select using the cities in the data container */
+ PersonContainer ds = app.getDataSource();
+ for (Iterator<Person> it = ds.getItemIds().iterator(); it.hasNext();) {
+ String city = (it.next()).getCity();
+ cities.addItem(city);
+ }
+
+ /*
+ * Field factory for overriding how the component for city selection is
+ * created
+ */
+ setFormFieldFactory(new DefaultFieldFactory() {
+ @Override
+ public Field createField(Item item, Object propertyId,
+ Component uiContext) {
+ if (propertyId.equals("city")) {
+ cities.setWidth("200px");
+ return cities;
+ }
+
+ Field field = super.createField(item, propertyId, uiContext);
+ if (propertyId.equals("postalCode")) {
+ TextField tf = (TextField) field;
+ /*
+ * We do not want to display "null" to the user when the
+ * field is empty
+ */
+ tf.setNullRepresentation("");
+
+ /* Add a validator for postalCode and make it required */
+ tf.addValidator(new PostalCodeValidator());
+ tf.setRequired(true);
+ } else if (propertyId.equals("email")) {
+ /* Add a validator for email and make it required */
+ field.addValidator(new EmailValidator());
+ field.setRequired(true);
+
+ }
+
+ field.setWidth("200px");
+ return field;
+ }
+ });
+ }
+
+ public void buttonClick(ClickEvent event) {
+ Button source = event.getButton();
+
+ if (source == save) {
+ /* If the given input is not valid there is no point in continuing */
+ if (!isValid()) {
+ return;
+ }
+
+ commit();
+ if (newContactMode) {
+ /* We need to add the new person to the container */
+ Item addedItem = app.getDataSource().addItem(newPerson);
+ /*
+ * We must update the form to use the Item from our datasource
+ * as we are now in edit mode (no longer in add mode)
+ */
+ setItemDataSource(addedItem);
+
+ newContactMode = false;
+ }
+ setReadOnly(true);
+ } else if (source == cancel) {
+ if (newContactMode) {
+ newContactMode = false;
+ /* Clear the form and make it invisible */
+ setItemDataSource(null);
+ } else {
+ discard();
+ }
+ setReadOnly(true);
+ } else if (source == edit) {
+ setReadOnly(false);
+ }
+ }
+
+ @Override
+ public void setItemDataSource(Item newDataSource) {
+ newContactMode = false;
+
+ if (newDataSource != null) {
+ List<Object> orderedProperties = Arrays
+ .asList(PersonContainer.NATURAL_COL_ORDER);
+ super.setItemDataSource(newDataSource, orderedProperties);
+
+ setReadOnly(true);
+ getFooter().setVisible(true);
+ } else {
+ super.setItemDataSource(null);
+ getFooter().setVisible(false);
+ }
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) {
+ super.setReadOnly(readOnly);
+ save.setVisible(!readOnly);
+ cancel.setVisible(!readOnly);
+ edit.setVisible(readOnly);
+ }
+
+ public void addContact() {
+ // Create a temporary item for the form
+ newPerson = new Person();
+ setItemDataSource(new BeanItem(newPerson));
+ newContactMode = true;
+ setReadOnly(false);
+ }
} \ No newline at end of file