Example usage for com.vaadin.ui GridLayout setSizeFull

List of usage examples for com.vaadin.ui GridLayout setSizeFull

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setSizeFull.

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

From source file:org.apache.ace.target.management.ui.TargetManagementExtension.java

License:Apache License

public Component create(Map<String, Object> context) {
    GridLayout result = new GridLayout(1, 4);
    result.setCaption(CAPTION);//from  w  w  w . j a va  2 s .  co  m

    result.setMargin(true);
    result.setSpacing(true);
    result.setSizeFull();

    final StatefulTargetObject target = getRepositoryObjectFromContext(context);

    final CheckBox registerCB = new CheckBox("Registered?");
    registerCB.setImmediate(true);
    registerCB.setEnabled(!target.isRegistered());
    registerCB.setValue(Boolean.valueOf(target.isRegistered()));

    result.addComponent(registerCB);

    final CheckBox autoApproveCB = new CheckBox("Auto approve?");
    autoApproveCB.setImmediate(true);
    autoApproveCB.setEnabled(target.isRegistered());
    autoApproveCB.setValue(Boolean.valueOf(target.getAutoApprove()));

    result.addComponent(autoApproveCB);

    final Button approveButton = new Button("Approve changes");
    approveButton.setImmediate(true);
    approveButton.setEnabled(getApproveButtonEnabledState(target));

    result.addComponent(approveButton);

    // Add a spacer that fill the remainder of the available space...
    result.addComponent(new Label(" "));
    result.setRowExpandRatio(3, 1.0f);

    // Add all listeners...
    registerCB.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            if (event.getButton().booleanValue()) {
                target.register();
                registerCB.setEnabled(!target.isRegistered());
                autoApproveCB.setEnabled(target.isRegistered());
            }
        }
    });
    autoApproveCB.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            target.setAutoApprove(event.getButton().booleanValue());
            approveButton.setEnabled(getApproveButtonEnabledState(target));
        }
    });
    approveButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            target.approve();
            approveButton.setEnabled(getApproveButtonEnabledState(target));
        }
    });

    return result;
}

From source file:org.bubblecloud.ilves.component.grid.Grid.java

License:Apache License

/**
 * Constructs the grid layout./*from w  w w  .ja v a2s  .  co  m*/
 * @param table the table
 * @param container the container
 * @param showFilters true if filters should be shown.
 */
private void construct(final Table table, final LazyQueryContainer container, final boolean showFilters) {
    this.table = table;

    table.setImmediate(true);
    table.setSelectable(true);
    table.setBuffered(false);
    table.setColumnCollapsingAllowed(true);
    table.setContainerDataSource(container);
    table.setSizeFull();

    if (showFilters) {
        final GridLayout layout = new GridLayout(1, 2);
        layout.setSpacing(true);
        layout.setRowExpandRatio(0, 0f);
        layout.setRowExpandRatio(1, 1f);

        filterLayout = new HorizontalLayout();
        ((HorizontalLayout) filterLayout).setSpacing(true);

        layout.addComponent(filterLayout, 0, 0);
        layout.addComponent(table, 0, 1);

        setCompositionRoot(layout);
        layout.setSizeFull();
        setSizeFull();
    } else {
        setCompositionRoot(table);
        setSizeFull();
    }
}

From source file:org.bubblecloud.ilves.module.audit.AuditLogEntryFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);/*from  www.  jav  a  2  s . c  o m*/
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    auditLogEntryEditor = new ValidatingEditor(
            FieldSetDescriptorRegister.getFieldSetDescriptor(AuditLogEntry.class).getFieldDescriptors());
    auditLogEntryEditor.setReadOnly(true);
    auditLogEntryEditor.setCaption("AuditLogEntry");
    auditLogEntryEditor.addListener(this);
    gridLayout.addComponent(auditLogEntryEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

}

From source file:org.bubblecloud.ilves.module.audit.AuditLogFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<AuditLogEntry>(entityManager, true, false, false, AuditLogEntry.class,
            1000, new String[] { "created" }, new boolean[] { false }, "auditLogEntryId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    filterDescriptors.add(new FilterDescriptor("startTime", "created", getSite().localize("filter-start-time"),
            new TimestampField(), 200, ">=", Date.class, new DateTime().withTimeAtStartOfDay().toDate()));
    filterDescriptors.add(new FilterDescriptor("endTime", "created", getSite().localize("filter-end-time"),
            new TimestampField(), 200, "<=", Date.class,
            new DateTime().withTimeAtStartOfDay().plusDays(1).toDate()));
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister
            .getFieldSetDescriptor(AuditLogEntry.class).getFieldDescriptors();
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);//from   w  ww.  ja va 2s . com
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    final Table table = new FormattingTable();
    table.setPageLength(13);

    // Initialize grid
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button viewButton = getSite().getButton("view");
    buttonLayout.addComponent(viewButton);
    viewButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final AuditLogEntry entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final AuditLogEntryFlowlet contentView = getFlow().forward(AuditLogEntryFlowlet.class);
            contentView.edit(entity, false);
        }
    });

}

From source file:org.bubblecloud.ilves.module.content.AssetFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);/*from   w  w  w  .ja v  a2s  .c o m*/
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    assetEditor = new ValidatingEditor(
            FieldSetDescriptorRegister.getFieldSetDescriptor(Asset.class).getFieldDescriptors());
    assetEditor.setCaption("Asset");
    assetEditor.addListener(this);
    gridLayout.addComponent(assetEditor, 0, 1);

    final Upload upload = new Upload(getSite().localize("field-file-upload"), new Upload.Receiver() {
        @Override
        public OutputStream receiveUpload(String filename, String mimeType) {
            try {
                temporaryFile = File.createTempFile(entity.getAssetId(), ".upload");
                return new FileOutputStream(temporaryFile, false);
            } catch (IOException e) {
                throw new SiteException("Unable to create temporary file for upload.", e);
            }
        }
    });
    upload.setButtonCaption(getSite().localize("button-start-upload"));
    upload.addSucceededListener(new Upload.SucceededListener() {
        @Override
        public void uploadSucceeded(Upload.SucceededEvent event) {
            if (event.getLength() == 0) {
                return;
            }
            if (temporaryFile.length() > Long
                    .parseLong(PropertiesUtil.getProperty("site", "asset-maximum-size"))) {
                Notification.show(getSite().localize("message-file-too-large"),
                        Notification.Type.ERROR_MESSAGE);
                return;
            }

            entity.setName(event.getFilename().substring(0, event.getFilename().lastIndexOf('.')));
            entity.setExtension(event.getFilename().substring(event.getFilename().lastIndexOf('.') + 1));
            entity.setType(event.getMIMEType());
            entity.setSize((int) event.getLength());

            assetEditor.setItem(new BeanItem<Asset>(entity), assetEditor.isNewItem());
            save();
        }
    });
    gridLayout.addComponent(upload, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 2);

    saveButton = getSite().getButton("save");
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (isValid()) {
                save();
            } else {
                Notification.show(getSite().localize("message-invalid-form-asset"),
                        Notification.Type.HUMANIZED_MESSAGE);
            }
        }
    });

    discardButton = getSite().getButton("discard");
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            assetEditor.discard();
            if (temporaryFile != null) {
                temporaryFile.deleteOnExit();
                temporaryFile = null;
            }
        }
    });

    editPrivilegesButton = getSite().getButton("edit-privileges");
    buttonLayout.addComponent(editPrivilegesButton);
    editPrivilegesButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            final PrivilegesFlowlet privilegesFlowlet = getFlow().getFlowlet(PrivilegesFlowlet.class);
            privilegesFlowlet.edit(entity.getName(), entity.getAssetId(), "view", "edit");
            getFlow().forward(PrivilegesFlowlet.class);
        }
    });
}

From source file:org.bubblecloud.ilves.module.content.AssetsFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Asset>(entityManager, true, false, false, Asset.class, 1000,
            new String[] { "name" }, new boolean[] { true }, "assetId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister.getFieldSetDescriptor(Asset.class)
            .getFieldDescriptors();/*from  w w  w .ja  v  a 2  s. co  m*/
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    // Initialize grid
    entityGrid = new Grid(new Table(), entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Asset asset = new Asset();
            asset.setAssetId(UUID.randomUUID().toString());
            asset.setCreated(new Date());
            asset.setModified(asset.getCreated());
            asset.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final AssetFlowlet assetView = getFlow().forward(AssetFlowlet.class);
            assetView.edit(asset, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Asset entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final AssetFlowlet assetView = getFlow().forward(AssetFlowlet.class);
            assetView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            entityContainer.removeItem(entityGrid.getSelectedItemId());
            entityContainer.commit();
        }
    });
}

From source file:org.bubblecloud.ilves.module.content.ContentFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);//from   ww w . j a v  a  2s.c  o m
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    contentEditor = new ValidatingEditor(
            FieldSetDescriptorRegister.getFieldSetDescriptor(Content.class).getFieldDescriptors());
    contentEditor.setCaption("Content");
    contentEditor.addListener(this);
    gridLayout.addComponent(contentEditor, 0, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = getSite().getButton("save");
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            contentEditor.commit();
            ContentDao.saveContent(entityManager, entity);
            editPrivilegesButton.setEnabled(true);
        }
    });

    discardButton = getSite().getButton("discard");
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            contentEditor.discard();
        }
    });

    editPrivilegesButton = getSite().getButton("edit-privileges");
    buttonLayout.addComponent(editPrivilegesButton);
    editPrivilegesButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            final PrivilegesFlowlet privilegesFlowlet = getFlow().getFlowlet(PrivilegesFlowlet.class);
            privilegesFlowlet.edit(entity.getPage(), entity.getContentId(), "view", "edit");
            getFlow().forward(PrivilegesFlowlet.class);
        }
    });
}

From source file:org.bubblecloud.ilves.module.content.ContentsFlowlet.java

License:Apache License

@Override
public void initialize() {
    // Get entity manager from site context and prepare container.
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Content>(entityManager, true, false, false, Content.class, 1000,
            new String[] { "page" }, new boolean[] { true }, "contentId");

    // Get descriptors and set container properties.
    final List<FilterDescriptor> filterDescriptors = new ArrayList<FilterDescriptor>();
    final List<FieldDescriptor> fieldDescriptors = FieldSetDescriptorRegister
            .getFieldSetDescriptor(Content.class).getFieldDescriptors();
    ContainerUtil.addContainerProperties(entityContainer, fieldDescriptors);

    // Initialize layout
    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);//from   w  w w .  jav  a 2  s  . c om
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);
    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setSizeUndefined();
    gridLayout.addComponent(buttonLayout, 0, 0);

    // Initialize grid
    entityGrid = new Grid(new Table(), entityContainer);
    entityGrid.setFields(fieldDescriptors);
    entityGrid.setFilters(filterDescriptors);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button addButton = getSite().getButton("add");
    buttonLayout.addComponent(addButton);
    addButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Content content = new Content();
            content.setCreated(new Date());
            content.setModified(content.getCreated());
            content.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final ContentFlowlet contentView = getFlow().forward(ContentFlowlet.class);
            contentView.edit(content, true);
        }
    });

    final Button editButton = getSite().getButton("edit");
    buttonLayout.addComponent(editButton);
    editButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            final Content entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final ContentFlowlet contentView = getFlow().forward(ContentFlowlet.class);
            contentView.edit(entity, false);
        }
    });

    final Button removeButton = getSite().getButton("remove");
    buttonLayout.addComponent(removeButton);
    removeButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            if (entityGrid.getSelectedItemId() == null) {
                return;
            }
            entityContainer.removeItem(entityGrid.getSelectedItemId());
            entityContainer.commit();
        }
    });
}

From source file:org.bubblecloud.ilves.ui.administrator.company.CompanyFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(2, 3);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);/*  ww w.j a v a  2 s  . c  om*/
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    companyEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(Company.class));
    companyEditor.setCaption("Site");
    companyEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(companyEditor, 0, 0, 0, 1);

    invoicingAddressEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(PostalAddress.class));
    invoicingAddressEditor.setCaption("Invoicing Address");
    invoicingAddressEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(invoicingAddressEditor, 1, 0);

    deliveryAddressEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(PostalAddress.class));
    deliveryAddressEditor.setCaption("Delivery Address");
    deliveryAddressEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(deliveryAddressEditor, 1, 1);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 2);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            companyEditor.commit();
            invoicingAddressEditor.commit();
            deliveryAddressEditor.commit();
            if (entity.getCompanyId() == null) {
                SecurityService.addCompany(getSite().getSiteContext(), entity);
            } else {
                SecurityService.updateCompany(getSite().getSiteContext(), entity);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            companyEditor.discard();
            invoicingAddressEditor.discard();
            deliveryAddressEditor.discard();
        }
    });

}

From source file:org.bubblecloud.ilves.ui.administrator.customer.CustomerFlowlet.java

License:Apache License

@Override
public void initialize() {
    entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final GridLayout gridLayout = new GridLayout(3, 2);
    gridLayout.setSizeFull();
    gridLayout.setMargin(false);//  w  ww. java  2  s.  c  om
    gridLayout.setSpacing(true);
    gridLayout.setRowExpandRatio(1, 1f);
    setViewContent(gridLayout);

    customerEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(Customer.class));
    customerEditor.setCaption("Customer");
    customerEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(customerEditor, 0, 0);

    final VerticalLayout invoiceLayout = new VerticalLayout();
    invoicingAddressEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(PostalAddress.class));
    invoicingAddressEditor.setCaption("Invoicing Address");
    invoicingAddressEditor.addListener((ValidatingEditorStateListener) this);
    invoiceLayout.addComponent(invoicingAddressEditor);

    deliveryAddressEditor = new ValidatingEditor(SiteFields.getFieldDescriptors(PostalAddress.class));
    deliveryAddressEditor.setCaption("Delivery Address");
    deliveryAddressEditor.addListener((ValidatingEditorStateListener) this);
    invoiceLayout.addComponent(deliveryAddressEditor);
    gridLayout.addComponent(invoiceLayout, 1, 0, 2, 0);

    final HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    gridLayout.addComponent(buttonLayout, 0, 1);

    saveButton = new Button("Save");
    saveButton.setImmediate(true);
    buttonLayout.addComponent(saveButton);
    saveButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            customerEditor.commit();
            invoicingAddressEditor.commit();
            deliveryAddressEditor.commit();

            if (entity.getCustomerId() == null) {
                SecurityService.addCustomer(getSite().getSiteContext(), entity);
            } else {
                SecurityService.updateCustomer(getSite().getSiteContext(), entity);
            }
        }
    });

    discardButton = new Button("Discard");
    discardButton.setImmediate(true);
    buttonLayout.addComponent(discardButton);
    discardButton.addClickListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            customerEditor.discard();
            invoicingAddressEditor.discard();
            deliveryAddressEditor.discard();
        }
    });

}