Example usage for com.vaadin.ui GridLayout GridLayout

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

Introduction

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

Prototype

public GridLayout(int columns, int rows) 

Source Link

Document

Constructor for a grid of given size (number of columns and rows).

Usage

From source file:org.activiti.kickstart.ui.popup.FormPopupWindow.java

License:Apache License

protected void initUi() {
    GridLayout layout = new GridLayout(2, 4);
    layout.setSpacing(true);/*from   w w w  .  java 2 s  . c  o m*/
    addComponent(layout);

    // Title
    layout.addComponent(new Label(FORM_TITLE));
    titleField = new TextField();
    layout.addComponent(titleField);

    // Description
    layout.addComponent(new Label(DESCRIPTION));
    descriptionField = new TextField();
    descriptionField.setRows(2);
    descriptionField.setColumns(25);
    layout.addComponent(descriptionField);

    // Property table
    propertyTable = new PropertyTable();
    layout.addComponent(new Label(DATA));
    layout.addComponent(propertyTable);
    fillFormFields();

    // Buttons
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);

    // Save button
    Button saveButton = new Button("Save");
    buttons.addComponent(saveButton);
    saveButton.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = -2906886872414089331L;

        public void buttonClick(ClickEvent event) {
            FormDto form = createForm();
            formModel.addForm(taskItemId, form);
            close();
        }
    });

    // Delete button
    Button deleteButton = new Button("Delete");
    buttons.addComponent(deleteButton);
    deleteButton.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = 5267967369680365653L;

        public void buttonClick(ClickEvent event) {
            formModel.removeForm(taskItemId);
            close();
        }
    });

    layout.addComponent(new Label(""));
    layout.addComponent(buttons);
}

From source file:org.agocontrol.site.viewlet.bus.BusesFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields.getFieldDescriptors(Bus.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<Bus>(entityManager, true, true, false, Bus.class, 1000,
            new String[] { "name" }, new boolean[] { true }, "busId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from ww w.j a v a2  s. c o  m*/
    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);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 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 Bus bus = new Bus();
            bus.setCreated(new Date());
            bus.setModified(bus.getCreated());
            bus.setInventorySynchronized(new Date(0L));
            bus.setConnectionStatus(BusConnectionStatus.Disconnected);
            bus.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final BusFlowlet busView = getViewSheet().forward(BusFlowlet.class);
            busView.edit(bus, 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) {
            final Bus entity = container.getEntity(grid.getSelectedItemId());
            final BusFlowlet busView = getViewSheet().forward(BusFlowlet.class);
            busView.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) {
            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:org.agocontrol.site.viewlet.bus.BusFlowlet.java

License:Apache License

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

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

    busEditor = new ValidatingEditor(AgoControlSiteFields.getFieldDescriptors(Bus.class));
    busEditor.setCaption("Bus");
    busEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(busEditor, 0, 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.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            busEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

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

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

}

From source file:org.agocontrol.site.viewlet.element.ElementFlowlet.java

License:Apache License

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

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

    elementEditor = new ValidatingEditor(AgoControlSiteFields.getFieldDescriptors(Element.class));
    elementEditor.setCaption("Element");
    elementEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(elementEditor, 0, 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.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            elementEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
            final BusClient busClient = ((AgoControlSiteUI) UI.getCurrent()).getBusClient(entity.getBus());
            if (busClient != null) {
                if (busClient.saveElement(entity) && busClient.synchronizeInventory()) {
                    Notification.show("Element save sent to bus.", Notification.Type.HUMANIZED_MESSAGE);
                } else {
                    Notification.show("Element save bus error.", Notification.Type.ERROR_MESSAGE);
                }
            }
        }
    });

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

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

}

From source file:org.agocontrol.site.viewlet.element.ElementsFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields.getFieldDescriptors(Element.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<Element>(entityManager, true, true, false, Element.class, 1000,
            new String[] { "treeIndex" }, new boolean[] { true }, "elementId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();//www.  j a v  a 2s.  com
    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);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("elementId", true);
    table.setColumnCollapsed("bus", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 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 Element element = new Element();
            element.setCreated(new Date());
            element.setModified(element.getCreated());
            element.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final ElementFlowlet elementView = getViewSheet().forward(ElementFlowlet.class);
            elementView.edit(element, 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) {
            final Element entity = container.getEntity(grid.getSelectedItemId());
            final ElementFlowlet elementView = getViewSheet().forward(ElementFlowlet.class);
            elementView.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) {
            final Element element = container.getEntity(grid.getSelectedItemId());

            container.removeItem(grid.getSelectedItemId());
            container.commit();

            final BusClient busClient = ((AgoControlSiteUI) UI.getCurrent()).getBusClient(element.getBus());
            if (busClient != null) {
                if (busClient.removeElement(element)) {
                    Notification.show("Element removal sent to bus.", Notification.Type.HUMANIZED_MESSAGE);
                } else {
                    Notification.show("Element removal bus error.", Notification.Type.ERROR_MESSAGE);
                }
            }
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

From source file:org.agocontrol.site.viewlet.record.RecordFlowlet.java

License:Apache License

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

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

    recordEditor = new ValidatingEditor(AgoControlSiteFields.getFieldDescriptors(Record.class));
    recordEditor.setCaption("Record");
    recordEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(recordEditor, 0, 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.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            recordEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

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

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

}

From source file:org.agocontrol.site.viewlet.record.RecordsFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields.getFieldDescriptors(Record.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new LazyEntityContainer<Record>(entityManager, true, false, false, Record.class, 50,
            new String[] { "created" }, new boolean[] { false }, "recordId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from www .j a  va  2 s .c o m*/
    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);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("recordId", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 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 Record record = new Record();
            record.setCreated(new Date());
            record.setModified(record.getCreated());
            record.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final RecordFlowlet recordView = getViewSheet().forward(RecordFlowlet.class);
            recordView.edit(record, 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) {
            final Record entity = container.getEntity(grid.getSelectedItemId());
            final RecordFlowlet recordView = getViewSheet().forward(RecordFlowlet.class);
            recordView.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) {
            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));

}

From source file:org.agocontrol.site.viewlet.recordset.RecordSetFlowlet.java

License:Apache License

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

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

    recordSetEditor = new ValidatingEditor(AgoControlSiteFields.getFieldDescriptors(RecordSet.class));
    recordSetEditor.setCaption("RecordSet");
    recordSetEditor.addListener((ValidatingEditorStateListener) this);
    gridLayout.addComponent(recordSetEditor, 0, 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.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            recordSetEditor.commit();
            entityManager.getTransaction().begin();
            try {
                entity = entityManager.merge(entity);
                entityManager.persist(entity);
                entityManager.getTransaction().commit();
                entityManager.detach(entity);
            } catch (final Throwable t) {
                if (entityManager.getTransaction().isActive()) {
                    entityManager.getTransaction().rollback();
                }
                throw new RuntimeException("Failed to save entity: " + entity, t);
            }
        }
    });

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

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

}

From source file:org.agocontrol.site.viewlet.recordset.RecordSetsFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDescriptors = AgoControlSiteFields.getFieldDescriptors(RecordSet.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    container = new EntityContainer<RecordSet>(entityManager, true, true, false, RecordSet.class, 1000,
            new String[] { "name" }, new boolean[] { true }, "recordSetId");

    ContainerUtil.addContainerProperties(container, fieldDescriptors);

    final GridLayout gridLayout = new GridLayout(1, 2);
    gridLayout.setSizeFull();/*from www .  jav  a2s  .  c om*/
    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);

    final Table table = new FormattingTable();
    grid = new Grid(table, container);
    grid.setFields(fieldDescriptors);
    grid.setFilters(filterDefinitions);

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    gridLayout.addComponent(grid, 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 RecordSet recordSet = new RecordSet();
            recordSet.setCreated(new Date());
            recordSet.setModified(recordSet.getCreated());
            recordSet.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final RecordSetFlowlet recordSetView = getViewSheet().forward(RecordSetFlowlet.class);
            recordSetView.edit(recordSet, 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) {
            final RecordSet entity = container.getEntity(grid.getSelectedItemId());
            final RecordSetFlowlet recordSetView = getViewSheet().forward(RecordSetFlowlet.class);
            recordSetView.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) {
            container.removeItem(grid.getSelectedItemId());
            container.commit();
        }
    });

    final Company company = getSite().getSiteContext().getObject(Company.class);
    container.removeDefaultFilters();
    container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId()));
    grid.refresh();
}

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 va2s.  c  o 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;
}