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.opennms.features.vaadin.surveillanceviews.ui.SurveillanceViewConfigurationWindow.java

License:Open Source License

/**
 * The constructor for instantiating this component.
 *
 * @param surveillanceViewService the surveillance view service to be used
 * @param view                    the view to edit
 * @param saveActionListener      the save action listener
 *///  w  w  w.  jav  a2 s.c  o m
public SurveillanceViewConfigurationWindow(final SurveillanceViewService surveillanceViewService,
        final View view, final SaveActionListener saveActionListener) {
    /**
     * Setting the title
     */
    super("Surveillance view configuration");

    /**
     * Setting the modal and size properties
     */
    setModal(true);
    setClosable(false);
    setResizable(false);
    setWidth(80, Sizeable.Unit.PERCENTAGE);
    setHeight(75, Sizeable.Unit.PERCENTAGE);

    /**
     * Title field
     */
    final TextField titleField = new TextField();
    titleField.setValue(view.getName());
    titleField.setImmediate(true);
    titleField.setCaption("Title");
    titleField.setDescription("Title of this surveillance view");
    titleField.setWidth(25, Unit.PERCENTAGE);

    /**
     * Adding simple validator
     */
    titleField.addValidator(new AbstractStringValidator("Please use an unique name for the surveillance view") {
        @Override
        protected boolean isValidValue(String string) {
            if ("".equals(string.trim())) {
                return false;
            }
            if (SurveillanceViewProvider.getInstance().containsView(string) && !view.getName().equals(string)) {
                return false;
            }
            return true;
        }
    });

    /**
     * Refresh seconds field setup and validator
     */
    final TextField refreshSecondsField = new TextField();
    refreshSecondsField.setValue(String.valueOf(view.getRefreshSeconds()));
    refreshSecondsField.setImmediate(true);
    refreshSecondsField.setCaption("Refresh seconds");
    refreshSecondsField.setDescription("Refresh duration in seconds");

    refreshSecondsField.addValidator(new AbstractStringValidator("Only numbers allowed here") {
        @Override
        protected boolean isValidValue(String s) {
            int number;
            try {
                number = Integer.parseInt(s);
            } catch (NumberFormatException numberFormatException) {
                return false;
            }
            return (number >= 0);
        }
    });

    /**
     * Columns table
     */
    final Table columnsTable = new Table();

    columnsTable.setSortEnabled(false);
    columnsTable.setWidth(25, Unit.PERCENTAGE);

    final BeanItemContainer<ColumnDef> columns = new BeanItemContainer<ColumnDef>(ColumnDef.class,
            view.getColumns());

    final Map<ColumnDef, Integer> columnOrder = new HashMap<>();

    int c = 0;
    for (ColumnDef columnDef : view.getColumns()) {
        columnOrder.put(columnDef, c++);
    }

    columnsTable.setContainerDataSource(columns);

    columnsTable.setVisibleColumns("label");
    columnsTable.setColumnHeader("label", "Columns");
    columnsTable.setColumnExpandRatio("label", 1.0f);
    columnsTable.setSelectable(true);
    columnsTable.setMultiSelect(false);

    /**
     * Create custom sorter
     */
    columns.setItemSorter(new DefaultItemSorter() {
        @Override
        public int compare(Object o1, Object o2) {
            if (o1 == null) {
                if (o2 == null) {
                    return 0;
                } else {
                    return -1;
                }
            }
            if (o2 == null) {
                return 1;
            }

            if (columnOrder.get(o1).intValue() == columnOrder.get(o2).intValue()) {
                return 0;
            } else {
                if (columnOrder.get(o1).intValue() > columnOrder.get(o2).intValue()) {
                    return 1;
                } else {
                    return -1;
                }
            }
        }
    });

    /**
     * Adding the buttons...
     */
    final Button columnsAddButton = new Button("Add");
    columnsAddButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getUI().addWindow(new SurveillanceViewConfigurationCategoryWindow(surveillanceViewService,
                    columnsTable.getItemIds(), new ColumnDef(),
                    new SurveillanceViewConfigurationCategoryWindow.SaveActionListener() {
                        @Override
                        public void save(Def def) {
                            columns.addItem((ColumnDef) def);
                            columnOrder.put((ColumnDef) def, columnOrder.size());

                            columns.sort(new Object[] { "label" }, new boolean[] { true });
                            columnsTable.refreshRowCache();
                        }
                    }));
        }
    });

    columnsAddButton.setEnabled(true);
    columnsAddButton.setStyleName("small");
    columnsAddButton.setDescription("Add column");
    columnsAddButton.setEnabled(true);

    final Button columnsEditButton = new Button("Edit");
    columnsEditButton.setEnabled(true);
    columnsEditButton.setStyleName("small");
    columnsEditButton.setDescription("Edit column");
    columnsEditButton.setEnabled(false);

    columnsEditButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getUI().addWindow(new SurveillanceViewConfigurationCategoryWindow(surveillanceViewService,
                    columnsTable.getItemIds(), (ColumnDef) columnsTable.getValue(),
                    new SurveillanceViewConfigurationCategoryWindow.SaveActionListener() {
                        @Override
                        public void save(Def def) {
                            ColumnDef columnToBeReplaced = (ColumnDef) columnsTable.getValue();
                            int index = columnOrder.get(columnToBeReplaced);

                            columns.removeItem(columnToBeReplaced);
                            columnOrder.remove(columnToBeReplaced);

                            columns.addItem((ColumnDef) def);
                            columnOrder.put((ColumnDef) def, index);

                            columns.sort(new Object[] { "label" }, new boolean[] { true });
                            columnsTable.refreshRowCache();
                        }
                    }));
        }
    });

    final Button columnsRemoveButton = new Button("Remove");
    columnsRemoveButton.setEnabled(true);
    columnsRemoveButton.setStyleName("small");
    columnsRemoveButton.setDescription("Remove column");
    columnsRemoveButton.setEnabled(false);

    columnsRemoveButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            ColumnDef columnDef = (ColumnDef) columnsTable.getValue();
            if (columnDef != null) {
                columnsTable.unselect(columnDef);
                columns.removeItem(columnDef);
            }

            columnsTable.refreshRowCache();
        }
    });

    final Button columnUpButton = new Button();
    columnUpButton.setStyleName("small");
    columnUpButton.setIcon(new ThemeResource("../runo/icons/16/arrow-up.png"));
    columnUpButton.setDescription("Move this a column entry one position up");
    columnUpButton.setEnabled(false);

    columnUpButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            ColumnDef columnDef = (ColumnDef) columnsTable.getValue();
            if (columnDef != null) {
                int columnDefIndex = columnOrder.get(columnDef);

                ColumnDef columnDefToSwap = null;

                for (Map.Entry<ColumnDef, Integer> entry : columnOrder.entrySet()) {
                    if (entry.getValue().intValue() == columnDefIndex - 1) {
                        columnDefToSwap = entry.getKey();
                        break;
                    }
                }

                if (columnDefToSwap != null) {
                    columnsTable.unselect(columnDef);
                    columnOrder.remove(columnDef);
                    columnOrder.remove(columnDefToSwap);
                    columnOrder.put(columnDef, columnDefIndex - 1);
                    columnOrder.put(columnDefToSwap, columnDefIndex);

                    columns.sort(new Object[] { "label" }, new boolean[] { true });
                    columnsTable.refreshRowCache();
                    columnsTable.select(columnDef);
                }

            }
        }
    });

    final Button columnDownButton = new Button();
    columnDownButton.setStyleName("small");
    columnDownButton.setIcon(new ThemeResource("../runo/icons/16/arrow-down.png"));
    columnDownButton.setDescription("Move this a column entry one position down");
    columnDownButton.setEnabled(false);

    columnDownButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            ColumnDef columnDef = (ColumnDef) columnsTable.getValue();
            if (columnDef != null) {
                int columnDefIndex = columnOrder.get(columnDef);

                ColumnDef columnDefToSwap = null;

                for (Map.Entry<ColumnDef, Integer> entry : columnOrder.entrySet()) {
                    if (entry.getValue().intValue() == columnDefIndex + 1) {
                        columnDefToSwap = entry.getKey();
                        break;
                    }
                }

                if (columnDefToSwap != null) {
                    columnsTable.unselect(columnDef);
                    columnOrder.remove(columnDef);
                    columnOrder.remove(columnDefToSwap);
                    columnOrder.put(columnDef, columnDefIndex + 1);
                    columnOrder.put(columnDefToSwap, columnDefIndex);

                    columns.sort(new Object[] { "label" }, new boolean[] { true });
                    columnsTable.refreshRowCache();
                    columnsTable.select(columnDef);
                }
            }
        }
    });

    columnsTable.setSizeFull();

    columnUpButton.setSizeFull();
    columnDownButton.setSizeFull();
    columnsAddButton.setSizeFull();
    columnsEditButton.setSizeFull();
    columnsRemoveButton.setSizeFull();

    columnsTable.setImmediate(true);

    /**
     * ...and a listener
     */
    columnsTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            boolean somethingSelected = (columnsTable.getValue() != null);
            columnsRemoveButton.setEnabled(somethingSelected);
            columnsEditButton.setEnabled(somethingSelected);
            columnsAddButton.setEnabled(true);
            columnUpButton
                    .setEnabled(somethingSelected && columnOrder.get(columnsTable.getValue()).intValue() > 0);
            columnDownButton.setEnabled(somethingSelected
                    && columnOrder.get(columnsTable.getValue()).intValue() < columnOrder.size() - 1);
        }
    });

    /**
     * Rows table
     */
    final Table rowsTable = new Table();

    rowsTable.setSortEnabled(false);
    rowsTable.setWidth(25, Unit.PERCENTAGE);

    final BeanItemContainer<RowDef> rows = new BeanItemContainer<RowDef>(RowDef.class, view.getRows());

    final Map<RowDef, Integer> rowOrder = new HashMap<>();

    int r = 0;
    for (RowDef rowDef : view.getRows()) {
        rowOrder.put(rowDef, r++);
    }

    rowsTable.setContainerDataSource(rows);

    rowsTable.setVisibleColumns("label");
    rowsTable.setColumnHeader("label", "Rows");
    rowsTable.setColumnExpandRatio("label", 1.0f);
    rowsTable.setSelectable(true);
    rowsTable.setMultiSelect(false);

    /**
     * Create custom sorter
     */
    rows.setItemSorter(new DefaultItemSorter() {
        @Override
        public int compare(Object o1, Object o2) {
            if (o1 == null) {
                if (o2 == null) {
                    return 0;
                } else {
                    return -1;
                }
            }
            if (o2 == null) {
                return 1;
            }

            if (rowOrder.get(o1).intValue() == rowOrder.get(o2).intValue()) {
                return 0;
            } else {
                if (rowOrder.get(o1).intValue() > rowOrder.get(o2).intValue()) {
                    return 1;
                } else {
                    return -1;
                }
            }
        }
    });

    /**
     * Adding the buttons...
     */
    final Button rowsAddButton = new Button("Add");
    rowsAddButton.setEnabled(true);
    rowsAddButton.setStyleName("small");
    rowsAddButton.setDescription("Add row");
    rowsAddButton.setEnabled(true);

    rowsAddButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getUI().addWindow(new SurveillanceViewConfigurationCategoryWindow(surveillanceViewService,
                    rowsTable.getItemIds(), new RowDef(),
                    new SurveillanceViewConfigurationCategoryWindow.SaveActionListener() {
                        @Override
                        public void save(Def def) {
                            rows.addItem((RowDef) def);
                            rowOrder.put((RowDef) def, rowOrder.size());

                            rows.sort(new Object[] { "label" }, new boolean[] { true });
                            rowsTable.refreshRowCache();
                        }
                    }));
        }
    });

    final Button rowsEditButton = new Button("Edit");
    rowsEditButton.setEnabled(true);
    rowsEditButton.setStyleName("small");
    rowsEditButton.setDescription("Edit row");
    rowsEditButton.setEnabled(false);

    rowsEditButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            getUI().addWindow(new SurveillanceViewConfigurationCategoryWindow(surveillanceViewService,
                    rowsTable.getItemIds(), (RowDef) rowsTable.getValue(),
                    new SurveillanceViewConfigurationCategoryWindow.SaveActionListener() {
                        @Override
                        public void save(Def def) {
                            RowDef rowToBeReplaced = (RowDef) rowsTable.getValue();
                            int index = rowOrder.get(rowToBeReplaced);

                            rows.removeItem(rowToBeReplaced);
                            rowOrder.remove(rowToBeReplaced);

                            rows.addItem((RowDef) def);
                            rowOrder.put((RowDef) def, index);

                            rows.sort(new Object[] { "label" }, new boolean[] { true });
                            rowsTable.refreshRowCache();
                        }
                    }));
        }
    });

    final Button rowsRemoveButton = new Button("Remove");
    rowsRemoveButton.setEnabled(true);
    rowsRemoveButton.setStyleName("small");
    rowsRemoveButton.setDescription("Remove row");
    rowsRemoveButton.setEnabled(false);

    rowsRemoveButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            RowDef rowDef = (RowDef) rowsTable.getValue();
            if (rowDef != null) {
                rowsTable.unselect(rowDef);
                rows.removeItem(rowDef);
            }

            rowsTable.refreshRowCache();
        }
    });

    final Button rowUpButton = new Button();
    rowUpButton.setStyleName("small");
    rowUpButton.setIcon(new ThemeResource("../runo/icons/16/arrow-up.png"));
    rowUpButton.setDescription("Move this a row entry one position up");
    rowUpButton.setEnabled(false);

    rowUpButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            RowDef rowDef = (RowDef) rowsTable.getValue();
            if (rowDef != null) {
                int rowDefIndex = rowOrder.get(rowDef);

                RowDef rowDefToSwap = null;

                for (Map.Entry<RowDef, Integer> entry : rowOrder.entrySet()) {
                    if (entry.getValue().intValue() == rowDefIndex - 1) {
                        rowDefToSwap = entry.getKey();
                        break;
                    }
                }

                if (rowDefToSwap != null) {
                    rowsTable.unselect(rowDef);
                    rowOrder.remove(rowDef);
                    rowOrder.remove(rowDefToSwap);
                    rowOrder.put(rowDef, rowDefIndex - 1);
                    rowOrder.put(rowDefToSwap, rowDefIndex);

                    rows.sort(new Object[] { "label" }, new boolean[] { true });
                    rowsTable.refreshRowCache();
                    rowsTable.select(rowDef);
                }
            }
        }
    });

    final Button rowDownButton = new Button();
    rowDownButton.setStyleName("small");
    rowDownButton.setIcon(new ThemeResource("../runo/icons/16/arrow-down.png"));
    rowDownButton.setDescription("Move this a row entry one position down");
    rowDownButton.setEnabled(false);

    rowDownButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            RowDef rowDef = (RowDef) rowsTable.getValue();
            if (rowDef != null) {
                int rowDefIndex = rowOrder.get(rowDef);

                RowDef rowDefToSwap = null;

                for (Map.Entry<RowDef, Integer> entry : rowOrder.entrySet()) {
                    if (entry.getValue().intValue() == rowDefIndex + 1) {
                        rowDefToSwap = entry.getKey();
                        break;
                    }
                }

                if (rowDefToSwap != null) {
                    rowsTable.unselect(rowDef);
                    rowOrder.remove(rowDef);
                    rowOrder.remove(rowDefToSwap);
                    rowOrder.put(rowDef, rowDefIndex + 1);
                    rowOrder.put(rowDefToSwap, rowDefIndex);

                    rows.sort(new Object[] { "label" }, new boolean[] { true });
                    rowsTable.refreshRowCache();
                    rowsTable.select(rowDef);
                }
            }
        }
    });

    rowsTable.setSizeFull();

    rowUpButton.setSizeFull();
    rowDownButton.setSizeFull();
    rowsAddButton.setSizeFull();
    rowsEditButton.setSizeFull();
    rowsRemoveButton.setSizeFull();

    rowsTable.setImmediate(true);

    /**
     * ...and a listener
     */
    rowsTable.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            boolean somethingSelected = (rowsTable.getValue() != null);
            rowsRemoveButton.setEnabled(somethingSelected);
            rowsEditButton.setEnabled(somethingSelected);
            rowsAddButton.setEnabled(true);
            rowUpButton.setEnabled(somethingSelected && rowOrder.get(rowsTable.getValue()).intValue() > 0);
            rowDownButton.setEnabled(
                    somethingSelected && rowOrder.get(rowsTable.getValue()).intValue() < rowOrder.size() - 1);
        }
    });

    /**
     * Create form layouts...
     */
    FormLayout baseFormLayout = new FormLayout();
    baseFormLayout.addComponent(titleField);
    baseFormLayout.addComponent(refreshSecondsField);

    FormLayout columnTableFormLayout = new FormLayout();
    columnTableFormLayout.addComponent(columnsAddButton);
    columnTableFormLayout.addComponent(columnsEditButton);
    columnTableFormLayout.addComponent(columnsRemoveButton);
    columnTableFormLayout.addComponent(columnUpButton);
    columnTableFormLayout.addComponent(columnDownButton);

    FormLayout rowTableFormLayout = new FormLayout();
    rowTableFormLayout.addComponent(rowsAddButton);
    rowTableFormLayout.addComponent(rowsEditButton);
    rowTableFormLayout.addComponent(rowsRemoveButton);
    rowTableFormLayout.addComponent(rowUpButton);
    rowTableFormLayout.addComponent(rowDownButton);

    /**
     * Adding the different {@link com.vaadin.ui.FormLayout} instances to a {@link com.vaadin.ui.GridLayout}
     */
    baseFormLayout.setMargin(true);
    columnTableFormLayout.setMargin(true);
    rowTableFormLayout.setMargin(true);

    GridLayout gridLayout = new GridLayout();
    gridLayout.setSizeFull();
    gridLayout.setColumns(4);
    gridLayout.setRows(1);
    gridLayout.setMargin(true);

    gridLayout.addComponent(rowsTable);
    gridLayout.addComponent(rowTableFormLayout);
    gridLayout.addComponent(columnsTable);
    gridLayout.addComponent(columnTableFormLayout);

    gridLayout.setColumnExpandRatio(1, 0.5f);
    gridLayout.setColumnExpandRatio(2, 1.0f);
    gridLayout.setColumnExpandRatio(3, 0.5f);
    gridLayout.setColumnExpandRatio(4, 1.0f);

    /**
     * Creating the vertical layout...
     */
    VerticalLayout verticalLayout = new VerticalLayout();

    verticalLayout.addComponent(baseFormLayout);
    verticalLayout.addComponent(gridLayout);

    /**
     * Using an additional {@link com.vaadin.ui.HorizontalLayout} for layouting the buttons
     */
    HorizontalLayout horizontalLayout = new HorizontalLayout();

    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    horizontalLayout.setWidth(100, Unit.PERCENTAGE);

    /**
     * Adding the cancel button...
     */
    Button cancel = new Button("Cancel");
    cancel.setDescription("Cancel editing properties");
    cancel.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });

    cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null);
    horizontalLayout.addComponent(cancel);
    horizontalLayout.setExpandRatio(cancel, 1);
    horizontalLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT);

    /**
     * ...and the OK button
     */
    Button ok = new Button("Save");
    ok.setDescription("Save properties and close");

    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!titleField.isValid()) {
                ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error", "Please use an unique title",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (!refreshSecondsField.isValid()) {
                ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error",
                        "Please enter a valid number in the \"Refresh seconds\" field",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (columns.getItemIds().isEmpty() || rows.getItemIds().isEmpty()) {
                ((SurveillanceViewsConfigUI) getUI()).notifyMessage("Error",
                        "You must define at least one row category and one column category",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }

            View finalView = new View();

            for (ColumnDef columnDef : columns.getItemIds()) {
                finalView.getColumns().add(columnDef);
            }

            for (RowDef rowDef : rows.getItemIds()) {
                finalView.getRows().add(rowDef);
            }

            finalView.setName(titleField.getValue());
            finalView.setRefreshSeconds(Integer.parseInt(refreshSecondsField.getValue()));

            saveActionListener.save(finalView);

            close();
        }
    });

    ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    horizontalLayout.addComponent(ok);

    verticalLayout.addComponent(horizontalLayout);

    setContent(verticalLayout);
}

From source file:org.vaadin.addons.sitekit.flow.AbstractFlowViewlet.java

License:Apache License

@Override
public final void attach() {
    super.attach();

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

    topLayout = new HorizontalLayout();
    layout.addComponent(topLayout, 0, 0);

    topBackButton = new Button(getSite().localize("button-back"));
    topBackButton.setEnabled(false);
    topBackButton.addListener(this);
    topLayout.addComponent(topBackButton);
    topLayout.setExpandRatio(topBackButton, 0.0f);

    topPathLabel = new Label("", Label.CONTENT_XHTML);

    topLayout.addComponent(topPathLabel);
    topLayout.setComponentAlignment(topPathLabel, Alignment.MIDDLE_LEFT);
    topLayout.setExpandRatio(topPathLabel, 1f);

    topRightLayout = new HorizontalLayout();
    topLayout.addComponent(topRightLayout);
    topLayout.setComponentAlignment(topRightLayout, Alignment.MIDDLE_RIGHT);
    topLayout.setExpandRatio(topRightLayout, 0.0f);
    topLayout.setWidth(100, Unit.PERCENTAGE);

    bottomLayout = new HorizontalLayout();
    layout.addComponent(bottomLayout, 0, 2);

    bottomBackButton = new Button(getSite().localize("button-back"));
    bottomBackButton.setEnabled(false);
    bottomBackButton.addListener(this);
    bottomLayout.addComponent(bottomBackButton);
    bottomLayout.setExpandRatio(bottomBackButton, 0f);

    bottomPathLabel = new Label("", Label.CONTENT_XHTML);

    bottomLayout.addComponent(bottomPathLabel);
    bottomLayout.setExpandRatio(bottomPathLabel, 1f);
    bottomLayout.setComponentAlignment(bottomPathLabel, Alignment.MIDDLE_LEFT);

    bottomRightLayout = new HorizontalLayout();
    bottomLayout.addComponent(bottomRightLayout);
    bottomLayout.setComponentAlignment(bottomRightLayout, Alignment.MIDDLE_RIGHT);
    bottomLayout.setExpandRatio(bottomRightLayout, 0f);
    bottomLayout.setWidth(100, Unit.PERCENTAGE);

    tabSheet = new TabSheet();
    tabSheet.setStyleName("flow-sheet");
    tabSheet.hideTabs(true);
    tabSheet.setSizeFull();
    layout.addComponent(tabSheet, 0, 1);

    addFlowlets();

    tabSheet.setSelectedTab((Component) getRootFlowlet());
}

From source file:org.vaadin.addons.sitekit.module.audit.view.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(), 130, ">=", Date.class, new DateTime().withTimeAtStartOfDay().toDate()));
    filterDescriptors.add(new FilterDescriptor("endTime", "created", getSite().localize("filter-end-time"),
            new TimestampField(), 130, "<=", 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  ww w.j a va 2 s.co m*/
    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 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) {
            final AuditLogEntry entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final AuditLogEntryFlowlet contentView = getFlow().forward(AuditLogEntryFlowlet.class);
            contentView.edit(entity, false);
        }
    });

}

From source file:org.vaadin.addons.sitekit.module.content.view.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  w w  w.  j av  a2  s  .  c  om*/
    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) {
            if (isValid()) {
                contentEditor.commit();
                ContentDao.saveContent(entityManager, entity);
                editPrivilegesButton.setEnabled(true);
            } else {
                Notification.show(getSite().localize("message-invalid-form-content"),
                        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) {
            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.vaadin.addons.sitekit.module.content.view.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 ww w .  j  av a  2  s.  c  o m
    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) {
            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) {
            entityContainer.removeItem(entityGrid.getSelectedItemId());
            entityContainer.commit();
        }
    });
}

From source file:org.vaadin.addons.sitekit.site.FixedWidthView.java

License:Apache License

/**
 * {@inheritDoc}//from w w w  .ja v a 2s .  c  o  m
 */
@Override
protected void initializeComponents() {
    final int columnCount = 5;
    final int rowCount = 3;

    final GridLayout layout = this;
    layout.setMargin(true);
    layout.setColumns(columnCount);
    layout.setRows(rowCount);
    layout.setColumnExpandRatio(0, MARGIN_COLUMN_EXPAND_RATIO);
    layout.setColumnExpandRatio(MARGIN_COLUMN_RIGTH_INDEX, MARGIN_COLUMN_EXPAND_RATIO);
    layout.setRowExpandRatio(1, 1.0f);
    layout.setSizeFull();
    layout.setMargin(false);
    layout.setSpacing(true);

    final AbstractComponent logoComponent = getComponent("logo");
    logoComponent.setWidth(NAVIGATION_COLUMN_WIDTH, Unit.PIXELS);
    layout.addComponent(logoComponent, 1, 0);

    final AbstractComponent navigationComponent = getComponent("navigation");
    navigationComponent.setWidth(NAVIGATION_COLUMN_WIDTH, Unit.PIXELS);
    navigationComponent.setHeight(NAVIGATION_HEIGHT, Unit.PIXELS);
    layout.addComponent(navigationComponent, 1, 1);

    final AbstractComponent headerComponent = getComponent("header");
    headerComponent.setWidth(CONTENT_COLUMN_WIDTH, Unit.PIXELS);
    headerComponent.setSizeFull();
    layout.addComponent(headerComponent, 2, 0);

    final AbstractComponent contentComponent = getComponent("content");
    contentComponent.setWidth(CONTENT_COLUMN_WIDTH, Unit.PIXELS);
    contentComponent.setSizeFull();
    layout.addComponent(contentComponent, 2, 1);

    final AbstractComponent footerComponent = getComponent("footer");
    headerComponent.setWidth(CONTENT_COLUMN_WIDTH, Unit.PIXELS);
    layout.addComponent(footerComponent, 2, 2);
}

From source file:org.vaadin.addons.sitekit.viewlet.administrator.company.CompanyFlowlet.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);//from  w  w  w .j  a  va 2s. c o  m
    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);

    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, 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.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            companyEditor.commit();
            invoicingAddressEditor.commit();
            deliveryAddressEditor.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) {
            companyEditor.discard();
            invoicingAddressEditor.discard();
            deliveryAddressEditor.discard();
        }
    });

}

From source file:org.vaadin.addons.sitekit.viewlet.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);/*from   w  w  w .  j a  v a 2  s . co  m*/
    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);

    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, 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.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

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

            CustomerDao.saveCustomer(entityManager, entity);

            //entityManager.detach(entity);
        }
    });

    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) {
            customerEditor.discard();
            invoicingAddressEditor.discard();
            deliveryAddressEditor.discard();
        }
    });

}

From source file:org.vaadin.addons.sitekit.viewlet.administrator.customer.CustomersFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDefinitions = SiteFields.getFieldDescriptors(Customer.class);

    final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>();
    filterDefinitions.add(new FilterDescriptor("companyName", "companyName", "Company Name", new TextField(),
            101, "=", String.class, ""));
    filterDefinitions.add(new FilterDescriptor("lastName", "lastName", "Last Name", new TextField(), 101, "=",
            String.class, ""));

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<Customer>(entityManager, true, false, false, Customer.class, 1000,
            new String[] { "companyName", "lastName", "firstName" }, new boolean[] { true, true, true },
            "customerId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }/*from   w w  w. j a  v a 2 s .c  o m*/

    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);

    final Table table = new Table();
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button addButton = new Button("Add");
    addButton.setIcon(getSite().getIcon("button-icon-add"));
    addButton.setWidth(100, UNITS_PIXELS);
    buttonLayout.addComponent(addButton);

    addButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer customer = new Customer();
            customer.setCreated(new Date());
            customer.setModified(customer.getCreated());
            customer.setInvoicingAddress(new PostalAddress());
            customer.setDeliveryAddress(new PostalAddress());
            customer.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(customer, true);
        }
    });

    final Button editButton = new Button("Edit");
    editButton.setIcon(getSite().getIcon("button-icon-edit"));
    editButton.setWidth(100, UNITS_PIXELS);
    buttonLayout.addComponent(editButton);
    editButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final Customer entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final CustomerFlowlet customerView = getFlow().forward(CustomerFlowlet.class);
            customerView.edit(entity, false);
        }
    });

    final Button removeButton = new Button("Remove");
    removeButton.setIcon(getSite().getIcon("button-icon-remove"));
    removeButton.setWidth(100, UNITS_PIXELS);
    buttonLayout.addComponent(removeButton);
    removeButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

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

}

From source file:org.vaadin.addons.sitekit.viewlet.administrator.directory.UserDirectoriesFlowlet.java

License:Apache License

@Override
public void initialize() {
    final List<FieldDescriptor> fieldDefinitions = new ArrayList<FieldDescriptor>(
            SiteFields.getFieldDescriptors(UserDirectory.class));

    for (final FieldDescriptor fieldDescriptor : fieldDefinitions) {
        if (fieldDescriptor.getId().equals("loginPassword")) {
            fieldDefinitions.remove(fieldDescriptor);
            break;
        }/*from   ww w.ja  v a  2s  .co m*/
    }

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

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    entityContainer = new EntityContainer<UserDirectory>(entityManager, true, false, false, UserDirectory.class,
            1000, new String[] { "address", "port" }, new boolean[] { true, true }, "userDirectoryId");

    for (final FieldDescriptor fieldDefinition : fieldDefinitions) {
        entityContainer.addContainerProperty(fieldDefinition.getId(), fieldDefinition.getValueType(),
                fieldDefinition.getDefaultValue(), fieldDefinition.isReadOnly(), fieldDefinition.isSortable());
    }

    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);

    final Table table = new Table();
    entityGrid = new Grid(table, entityContainer);
    entityGrid.setFields(fieldDefinitions);
    entityGrid.setFilters(filterDefinitions);
    //entityGrid.setFixedWhereCriteria("e.owner.companyId=:companyId");

    table.setColumnCollapsed("loginDn", true);
    table.setColumnCollapsed("userEmailAttribute", true);
    table.setColumnCollapsed("userSearchBaseDn", true);
    table.setColumnCollapsed("groupSearchBaseDn", true);
    table.setColumnCollapsed("remoteLocalGroupMapping", true);
    table.setColumnCollapsed("created", true);
    table.setColumnCollapsed("modified", true);
    table.setColumnCollapsed("company", true);
    gridLayout.addComponent(entityGrid, 0, 1);

    final Button addButton = new Button("Add");
    addButton.setIcon(getSite().getIcon("button-icon-add"));
    addButton.setWidth(100, UNITS_PIXELS);
    buttonLayout.addComponent(addButton);

    addButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final UserDirectory userDirectory = new UserDirectory();
            userDirectory.setCreated(new Date());
            userDirectory.setModified(userDirectory.getCreated());
            userDirectory.setOwner((Company) getSite().getSiteContext().getObject(Company.class));
            final UserDirectoryFlowlet userDirectoryView = getFlow().forward(UserDirectoryFlowlet.class);
            userDirectoryView.edit(userDirectory, true);
        }
    });

    final Button editButton = new Button("Edit");
    editButton.setIcon(getSite().getIcon("button-icon-edit"));
    editButton.setWidth(100, UNITS_PIXELS);
    buttonLayout.addComponent(editButton);
    editButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final UserDirectory entity = entityContainer.getEntity(entityGrid.getSelectedItemId());
            final UserDirectoryFlowlet userDirectoryView = getFlow().forward(UserDirectoryFlowlet.class);
            userDirectoryView.edit(entity, false);
        }
    });

    final Button removeButton = new Button("Remove");
    removeButton.setIcon(getSite().getIcon("button-icon-remove"));
    removeButton.setWidth(100, UNITS_PIXELS);
    buttonLayout.addComponent(removeButton);
    removeButton.addListener(new ClickListener() {
        /** Serial version UID. */
        private static final long serialVersionUID = 1L;

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

}