Example usage for com.vaadin.server FontAwesome TRASH_O

List of usage examples for com.vaadin.server FontAwesome TRASH_O

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome TRASH_O.

Prototype

FontAwesome TRASH_O

To view the source code for com.vaadin.server FontAwesome TRASH_O.

Click Source Link

Usage

From source file:com.save.client.promodeals.PDDataContainer.java

public PDDataContainer(int clientId) {
    this.clientId = clientId;

    addContainerProperty("sn", Integer.class, null);
    addContainerProperty("promo items", String.class, null);
    addContainerProperty("amount", Double.class, null);
    addContainerProperty("quantity", Double.class, null);
    addContainerProperty("product", String.class, null);
    addContainerProperty("view", String.class, null);
    addContainerProperty("edit", String.class, null);
    addContainerProperty("del", String.class, null);

    for (PromoDeals p : pds.getPromoDealsByClientId(getClientId())) {
        Item item = getItem(addItem());// ww  w. j a  v  a2 s. co m
        item.getItemProperty("sn").setValue(p.getPromoId());
        item.getItemProperty("promo items").setValue(p.getPromoItem());
        item.getItemProperty("amount").setValue(p.getPromoAmount());
        item.getItemProperty("quantity").setValue(p.getQuantity());
        item.getItemProperty("product").setValue(p.getProductItem());
        item.getItemProperty("view").setValue(FontAwesome.PRINT.getHtml());
        item.getItemProperty("edit").setValue(FontAwesome.PENCIL.getHtml());
        item.getItemProperty("del").setValue(FontAwesome.TRASH_O.getHtml());
    }
}

From source file:com.save.employee.maintenance.MRDataContainer.java

public MRDataContainer(int employeeId) {
    this.employeeId = employeeId;

    addContainerProperty("plate no.", String.class, null);
    addContainerProperty("amount", Double.class, null);
    addContainerProperty("date", String.class, null);
    addContainerProperty("type", String.class, null);
    addContainerProperty("edit", String.class, null);
    addContainerProperty("del", String.class, null);
    addContainerProperty("id", String.class, null);

    for (MaintenanceReimbursement mr : mrs.getMaintenanceReimbursementByEmployee(getEmployeeId())) {
        Item item = getItem(addItem());/*from   www . j  av a  2s  .  c  o  m*/
        item.getItemProperty("plate no.").setValue(mr.getPlateNo());
        item.getItemProperty("amount").setValue(mr.getAmount());
        item.getItemProperty("date")
                .setValue(CommonUtilities.convertDateWithFormat(mr.getDateCovered().toString(), "yyyy-MMM-dd"));
        item.getItemProperty("type").setValue(mr.getFormType());
        item.getItemProperty("edit").setValue(FontAwesome.PENCIL.getHtml());
        item.getItemProperty("del").setValue(FontAwesome.TRASH_O.getHtml());
        item.getItemProperty("id").setValue(String.valueOf(mr.getMaintenanceId()));
    }
}

From source file:com.save.employee.request.RLDataContainer.java

public RLDataContainer(int employeeId) {
    this.employeeId = employeeId;

    addContainerProperty("control no.", String.class, null);
    addContainerProperty("reimbursement", Double.class, null);
    //        addContainerProperty("area", Integer.class, null);
    addContainerProperty("activity", String.class, null);
    addContainerProperty("date", String.class, null);
    addContainerProperty("venue", String.class, null);
    addContainerProperty("edit", String.class, null);
    addContainerProperty("liquidate", String.class, null);
    addContainerProperty("view", String.class, null);
    addContainerProperty("del", String.class, null);
    addContainerProperty("id", Integer.class, null);

    for (LiquidationForm lf : rls.getAllRLByEmployeeId(getEmployeeId())) {
        Item item = getItem(addItem());//from w  ww  . j a  v  a  2s  .  co m
        item.getItemProperty("control no.").setValue(lf.getControlNo());
        item.getItemProperty("reimbursement").setValue(lf.getReimbursedAmount());
        //            item.getItemProperty("area").setValue(lf.getAreaCode());
        item.getItemProperty("activity").setValue(lf.getActivity());
        item.getItemProperty("date").setValue(
                CommonUtilities.convertDateWithFormat(lf.getDateOfActivity().toString(), "yyyy-MMM-dd"));
        item.getItemProperty("venue").setValue(lf.getVenue());
        item.getItemProperty("edit").setValue(FontAwesome.PENCIL.getHtml());
        item.getItemProperty("liquidate").setValue(FontAwesome.LEAF.getHtml());
        item.getItemProperty("view").setValue(FontAwesome.EYE.getHtml());
        item.getItemProperty("del").setValue(FontAwesome.TRASH_O.getHtml());
        item.getItemProperty("id").setValue(lf.getRequestId());
    }
}

From source file:com.terralcode.frontend.vista.widgets.alumno.AlumnoVista.java

public AlumnoVista() {
    super();/* w  w  w  . java 2  s.com*/
    saveOperation = menubar.addItem("", FontAwesome.SAVE, save());
    trashOperation = menubar.addItem("", FontAwesome.TRASH_O, delete());
    editOperation = menubar.addItem("", FontAwesome.EDIT, editar());
}

From source file:com.terralcode.gestion.frontend.view.widgets.customer.CustomerView.java

public CustomerView() {
    super();/*from w  w w. j ava 2s  .c o  m*/
    saveOperation = menubar.addItem("", FontAwesome.SAVE, save());
    trashOperation = menubar.addItem("", FontAwesome.TRASH_O, delete());
}

From source file:com.terralcode.gestion.frontend.view.widgets.example.crudtestform.CrudExampleForm.java

protected Component buildContent() {
    initTable();//from   www.jav a  2s . co m
    table.setPageLength(table.size());
    addMenuItems(new MenuBar().new MenuItem("", FontAwesome.PLUS, add()),
            new MenuBar().new MenuItem("", FontAwesome.EDIT, edit()),
            new MenuBar().new MenuItem("", FontAwesome.SAVE, save()),
            new MenuBar().new MenuItem("", FontAwesome.TRASH_O, delete()));
    return table;
}

From source file:fr.univlorraine.mondossierweb.views.RechercheArborescenteView.java

License:Apache License

public void refresh() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MainUI && userController.isEnseignant()) {
        //Actualiser de l'affiche du bouton de mise en favori
        if (table != null && hc != null) {

            recuperationDesfavoris();/*from   ww w . j a  va 2s .co m*/

            if (listeBoutonFavoris != null) {

                for (ReferencedButton btnfav : listeBoutonFavoris) {

                    if (markedRows.contains(btnfav.getIdObj())) {
                        btnfav.getButton().setIcon(FontAwesome.TRASH_O);
                        btnfav.getButton().setStyleName(ValoTheme.BUTTON_DANGER);
                        btnfav.getButton().addStyleName("deletefavbutton");
                        btnfav.getButton().setDescription(
                                applicationContext.getMessage(NAME + ".supprimerfavori", null, getLocale()));
                    } else {
                        btnfav.getButton().setIcon(FontAwesome.STAR_O);
                        btnfav.getButton().setStyleName(ValoTheme.BUTTON_PRIMARY);
                        btnfav.getButton().setDescription(
                                applicationContext.getMessage(NAME + ".ajouterfavori", null, getLocale()));
                    }
                }
            }
        }
    }
}

From source file:life.qbic.components.OfferManagerTab.java

License:Open Source License

/**
 * creates the tab for displaying and modifying the offers in a vaadin grid
 * @return vaadin component/*  w w w .j av  a  2s.c  o m*/
 * @throws SQLException:
 */
static Component createOfferManagerTab() throws SQLException {

    Database db = qOfferManager.getDb();

    VerticalLayout offerManLayout = new VerticalLayout();
    HorizontalLayout editSettingsLayout = new HorizontalLayout();
    detailsLayout = new VerticalLayout();

    editSettingsLayout.setSpacing(true);
    detailsLayout.setSizeFull();

    ComboBox updateStatus = new ComboBox("Select Status");
    updateStatus.addItem("In Progress");
    updateStatus.addItem("Sent");
    updateStatus.addItem("Accepted");
    updateStatus.addItem("Rejected");

    Button updateButton = new Button("Update");
    updateButton.setIcon(FontAwesome.SPINNER);
    updateButton.setDescription("Click here to update the currently selected offer.");

    Button deleteOfferButton = new Button("Delete");
    deleteOfferButton.setIcon(FontAwesome.TRASH_O);
    deleteOfferButton.setDescription("Click here to delete the currently selected offer.");

    packageGroupComboBox = new ComboBox("Select package group");
    packageGroupComboBox.addItems("All", "Bioinformatics Analysis", "Mass spectrometry", "Project Management",
            "Sequencing", "Other");
    packageGroupComboBox.setValue("All");
    packageGroupComboBox.setNullSelectionAllowed(false);
    packageGroupComboBox
            .setDescription("Click here to select the package group for the packages displayed below.");

    Button exportTableButton = new Button("Export as .csv");
    exportTableButton.setIcon(FontAwesome.DOWNLOAD);
    exportTableButton.setDescription("Click here to export the table as .csv file.");

    editSettingsLayout.addComponent(updateStatus);
    editSettingsLayout.addComponent(updateButton);
    editSettingsLayout.addComponent(deleteOfferButton);
    editSettingsLayout.addComponent(packageGroupComboBox);
    editSettingsLayout.addComponent(exportTableButton);

    editSettingsLayout.setComponentAlignment(updateButton, Alignment.BOTTOM_CENTER);
    editSettingsLayout.setComponentAlignment(deleteOfferButton, Alignment.BOTTOM_CENTER);
    editSettingsLayout.setComponentAlignment(packageGroupComboBox, Alignment.BOTTOM_CENTER);
    editSettingsLayout.setComponentAlignment(exportTableButton, Alignment.BOTTOM_CENTER);

    Button generateOfferButton = new Button("Download offer");
    generateOfferButton.setIcon(FontAwesome.DOWNLOAD);
    generateOfferButton
            .setDescription("Select an offer from the grid then click here to download it as .docx!");
    generateOfferButton.setEnabled(false);

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

    TableQuery tq = new TableQuery("offers", DBManager.getDatabaseInstanceAlternative());
    tq.setVersionColumn("OPTLOCK");
    SQLContainer container = new SQLContainer(tq);
    container.setAutoCommit(true);

    offerManagerGrid = new RefreshableGrid(container);

    // add the filters to the grid
    GridCellFilter filter = new GridCellFilter(offerManagerGrid);
    filter.setTextFilter("offer_id", true, true);
    filter.setTextFilter("offer_number", true, false);
    filter.setTextFilter("offer_project_reference", true, false);
    filter.setTextFilter("offer_facility", true, false);
    filter.setTextFilter("offer_name", true, false);
    filter.setTextFilter("offer_description", true, false);
    filter.setDateFilter("offer_date");
    filter.setDateFilter("last_edited");
    filter.setComboBoxFilter("offer_status", Arrays.asList("In Progress", "Sent", "Accepted", "Rejected"));

    offerManagerGrid.setSelectionMode(Grid.SelectionMode.SINGLE);

    addListeners(db, updateStatus, updateButton, deleteOfferButton, generateOfferButton, container,
            exportTableButton);

    offerManagerGrid.getColumn("offer_id").setHeaderCaption("Id").setWidth(100).setEditable(false);
    offerManagerGrid.getColumn("offer_number").setHeaderCaption("Quotation Number").setWidth(200)
            .setEditable(false);
    offerManagerGrid.getColumn("offer_project_reference").setHeaderCaption("Project Reference")
            .setEditable(false);
    offerManagerGrid.getColumn("offer_name").setHeaderCaption("Offer Name").setWidth(200);
    offerManagerGrid.getColumn("offer_facility").setHeaderCaption("Prospect");
    offerManagerGrid.getColumn("offer_description").setHeaderCaption("Description").setWidth(300);
    offerManagerGrid.getColumn("offer_total").setHeaderCaption("Price ()").setEditable(false);
    offerManagerGrid.getColumn("offer_status").setHeaderCaption("Status").setEditable(false);
    offerManagerGrid.getColumn("offer_date").setHeaderCaption("Date").setEditable(false);
    offerManagerGrid.getColumn("last_edited").setHeaderCaption("Last edited").setEditable(false);
    offerManagerGrid.getColumn("added_by").setHeaderCaption("Added by").setEditable(false);

    offerManagerGrid.setColumnOrder("offer_id", "offer_project_reference", "offer_number", "offer_name",
            "offer_description", "offer_total", "offer_facility", "offer_status", "offer_date", "last_edited",
            "added_by");

    offerManagerGrid.removeColumn("discount");
    offerManagerGrid.removeColumn("internal");
    offerManagerGrid.removeColumn("offer_group");
    offerManagerGrid.removeColumn("offer_extra_price");
    offerManagerGrid.removeColumn("offer_price");

    offerManagerGrid.sort("offer_date", SortDirection.DESCENDING);
    offerManagerGrid.setWidth("100%");
    offerManagerGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    offerManagerGrid.setEditorEnabled(true);

    // add tooltips to the cells
    offerManagerGrid.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> {
        if (cell.getValue() == null)
            return null;
        return cell.getValue().toString();
    });

    // add tooltips to the header row
    for (Grid.Column column : offerManagerGrid.getColumns()) {
        Grid.HeaderCell cell = offerManagerGrid.getDefaultHeaderRow().getCell(column.getPropertyId());
        String htmlWithTooltip = String.format("<span title=\"%s\">%s</span>", cell.getText(), cell.getText());
        cell.setHtml(htmlWithTooltip);
    }

    offerManLayout.addComponent(offerManagerGrid);
    offerManLayout.addComponent(editSettingsLayout);
    offerManLayout.addComponent(detailsLayout);
    offerManLayout.addComponent(generateOfferButton);

    return offerManLayout;
}

From source file:life.qbic.components.OfferManagerTabPackageComponent.java

License:Open Source License

/**
 * creates the component showing the packages of the respective package type of the currently selected offer in a
 * grid and enables the user to add and remove packages from the offer
 * @param offerGridContainer: sql container of all the offers
 * @param selectedOfferID: id of the currently selected offer
 * @param packagesType: type of the packages: "All", "Bioinformatics Analysis", "Project Management", "Sequencing",
 *                    "Mass spectrometry", "Other"; what type of packages the grid should display
 * @return vaadin component/*from w  w w  .  j a  v a2 s . co m*/
 * @throws SQLException :
 */
static Component createOfferManagerTabPackageComponent(SQLContainer offerGridContainer, String selectedOfferID,
        String packagesType) throws SQLException {

    Database db = qOfferManager.getDb();

    VerticalLayout packQuantityLayout = new VerticalLayout();
    packQuantityLayout.setMargin(true);
    packQuantityLayout.setSpacing(true);
    packQuantityLayout.setSizeFull();
    HorizontalLayout packSettingsLayout = new HorizontalLayout();

    ComboBox packageQuantityComboBox = new ComboBox("Select Quantity");

    for (int i = 1; i <= 1000; i++)
        packageQuantityComboBox.addItem(i);

    Button updateQuantityButton = new Button("Update quantity");
    updateQuantityButton.setIcon(FontAwesome.SPINNER);
    updateQuantityButton.setDescription("Updates the quantity of the current package.");

    Button removePackageButton = new Button("Remove");
    removePackageButton.setIcon(FontAwesome.TRASH_O);
    removePackageButton.setDescription("Removes the selected package from the current offer.");

    // we are only displaying the packages for the current package group
    ComboBox packagesAvailableForOfferComboBox = new ComboBox("Select package to add");
    packagesAvailableForOfferComboBox.setFilteringMode(FilteringMode.CONTAINS);

    String selectedPackageGroup = OfferManagerTab.getPackageGroupComboBoxValue();
    if (selectedPackageGroup.equals("All")) {
        packagesAvailableForOfferComboBox.addItems(db.getPackageIdsAndNames());
    } else {
        packagesAvailableForOfferComboBox.addItems(db.getPackageIdsAndNames(selectedPackageGroup));
    }

    Button addPackageButton = new Button("Add");
    addPackageButton.setIcon(FontAwesome.PLUS);
    addPackageButton.setDescription("Adds a package to the current offer.");

    ComboBox externalInternalPriceComboBox = new ComboBox("External/Internal Price");
    externalInternalPriceComboBox
            .setDescription("Select here whether the internal, the external academical or the "
                    + "external commercial price should be used for the current selected package.");
    externalInternalPriceComboBox.addItems("Internal", "External academic", "External commercial");

    Button externalInternalButton = new Button("Update price type");
    externalInternalButton.setIcon(FontAwesome.SPINNER);
    externalInternalButton.setDescription(
            "Updates the package price type (internal/external academic/external " + "commercial) to use.");

    packSettingsLayout.addComponent(packageQuantityComboBox);
    packSettingsLayout.addComponent(updateQuantityButton);
    packSettingsLayout.addComponent(removePackageButton);
    packSettingsLayout.addComponent(packagesAvailableForOfferComboBox);
    packSettingsLayout.addComponent(addPackageButton);
    packSettingsLayout.addComponent(externalInternalPriceComboBox);
    packSettingsLayout.addComponent(externalInternalButton);

    packSettingsLayout.setComponentAlignment(updateQuantityButton, Alignment.BOTTOM_CENTER);
    packSettingsLayout.setComponentAlignment(removePackageButton, Alignment.BOTTOM_CENTER);
    packSettingsLayout.setComponentAlignment(addPackageButton, Alignment.BOTTOM_CENTER);
    packSettingsLayout.setComponentAlignment(externalInternalPriceComboBox, Alignment.MIDDLE_CENTER);
    packSettingsLayout.setComponentAlignment(externalInternalButton, Alignment.BOTTOM_CENTER);

    packSettingsLayout.setSpacing(true);

    // we need different freeform queries if 'All' package groups are selected or e.g. only 'Bioinformatics' package groups
    String freeformQueryString = "SELECT * " + "FROM offers "
            + "INNER JOIN offers_packages ON offers.`offer_id` = offers_packages.`offer_id` "
            + "INNER JOIN packages ON packages.`package_id` = offers_packages.`package_id`"
            + "WHERE offers.offer_id = " + selectedOfferID + " AND packages.`package_group` = '" + packagesType
            + "'";
    if (Objects.equals(packagesType, "All")) {
        freeformQueryString = "SELECT * " + "FROM offers "
                + "INNER JOIN offers_packages ON offers.`offer_id` = offers_packages.`offer_id` "
                + "INNER JOIN packages ON packages.`package_id` = offers_packages.`package_id`"
                + "WHERE offers.offer_id = " + selectedOfferID;
    }

    FreeformQuery query = new FreeformQuery(freeformQueryString, DBManager.getDatabaseInstanceAlternative());

    SQLContainer packsContainer = new SQLContainer(query);
    packsContainer.setAutoCommit(true);

    selectedPacksInOfferGrid = new RefreshableGrid(packsContainer);

    // add tooltips to the cells
    selectedPacksInOfferGrid.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> {
        if (cell.getValue() == null)
            return null;
        return cell.getValue().toString();
    });

    // update the array lists holding the information about the packages of the current offer
    updatePackageArrays(packsContainer);

    addListeners(offerGridContainer, selectedOfferID, db, packageQuantityComboBox, updateQuantityButton,
            removePackageButton, packagesAvailableForOfferComboBox, addPackageButton, packsContainer,
            externalInternalPriceComboBox, externalInternalButton);

    // remove unimportant columns from the grid
    selectedPacksInOfferGrid.removeColumn("offer_id");
    selectedPacksInOfferGrid.removeColumn("offer_number");
    selectedPacksInOfferGrid.removeColumn("offer_project_reference");
    selectedPacksInOfferGrid.removeColumn("offer_facility");
    selectedPacksInOfferGrid.removeColumn("offer_name");
    selectedPacksInOfferGrid.removeColumn("offer_description");
    selectedPacksInOfferGrid.removeColumn("offer_group");
    selectedPacksInOfferGrid.removeColumn("offer_price");
    selectedPacksInOfferGrid.removeColumn("offer_extra_price");
    selectedPacksInOfferGrid.removeColumn("offer_total");
    selectedPacksInOfferGrid.removeColumn("offer_date");
    selectedPacksInOfferGrid.removeColumn("offer_status");
    selectedPacksInOfferGrid.removeColumn("last_edited");
    selectedPacksInOfferGrid.removeColumn("added_by");
    selectedPacksInOfferGrid.removeColumn("package_date");
    selectedPacksInOfferGrid.removeColumn("discount");
    selectedPacksInOfferGrid.removeColumn("internal");
    selectedPacksInOfferGrid.removeColumn("package_grp");

    // rename the header caption
    selectedPacksInOfferGrid.getColumn("package_id").setHeaderCaption("Id");
    selectedPacksInOfferGrid.getColumn("package_addon_price").setHeaderCaption("Package total price ()");
    selectedPacksInOfferGrid.getColumn("package_count").setHeaderCaption("Quantity");
    selectedPacksInOfferGrid.getColumn("package_discount").setHeaderCaption("Discount");
    selectedPacksInOfferGrid.getColumn("package_name").setHeaderCaption("Package Name").setWidth(200);
    selectedPacksInOfferGrid.getColumn("package_facility").setHeaderCaption("Package Facility");
    selectedPacksInOfferGrid.getColumn("package_description").setHeaderCaption("Description").setWidth(300);
    selectedPacksInOfferGrid.getColumn("package_group").setHeaderCaption("Group");
    selectedPacksInOfferGrid.getColumn("package_price_internal").setHeaderCaption("Internal base price ()");
    selectedPacksInOfferGrid.getColumn("package_price_external_academic")
            .setHeaderCaption("External academic base price ()");
    selectedPacksInOfferGrid.getColumn("package_price_external_commercial")
            .setHeaderCaption("External commercial base price ()");
    selectedPacksInOfferGrid.getColumn("package_unit_type").setHeaderCaption("Unit Type");
    selectedPacksInOfferGrid.getColumn("package_price_type").setHeaderCaption("Package price type");

    selectedPacksInOfferGrid.setColumnOrder("package_id", "package_name", "package_description",
            "package_addon_price", "package_count", "package_discount", "package_group", "package_facility",
            "package_price_internal", "package_price_external_academic", "package_price_external_commercial",
            "package_price_type", "package_unit_type");

    // we don't want the packages to be be editable, because this would change the package in other offers as well
    selectedPacksInOfferGrid.setEditorEnabled(false);
    selectedPacksInOfferGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    selectedPacksInOfferGrid.setWidth("100%");

    // label showing the packages group currently displayed (e.g. "All", "Project Management", etc.)
    Label packagesGroupLabel = new Label("<b><u>" + packagesType + ":</u></b>", ContentMode.HTML);
    packQuantityLayout.addComponent(packagesGroupLabel);
    packQuantityLayout.addComponent(selectedPacksInOfferGrid);
    packQuantityLayout.addComponent(packSettingsLayout);

    return packQuantityLayout;
}

From source file:life.qbic.components.PackageManagerTab.java

License:Open Source License

/**
 * creates the tab for creating new packages
 * @return vaadin component//w  w w . ja va2s.  c  om
 * @throws SQLException:
 */
static Component createPackageManagerTab() throws SQLException {

    Database db = qOfferManager.getDb();

    VerticalLayout packManVerticalLayout = new VerticalLayout();
    packManVerticalLayout.setMargin(true);
    packManVerticalLayout.setSpacing(true);
    packManVerticalLayout.setSizeFull();

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

    Button addPackageButton = new Button("New Package");
    addPackageButton.setIcon(FontAwesome.PLUS);
    addPackageButton.setDescription("Click here to add a new package but don't forget to update the details.");

    ComboBox updatePackageGroupComboBox = new ComboBox("Select package group");
    updatePackageGroupComboBox.addItems("Sequencing", "Project Management", "Bioinformatics Analysis",
            "Mass spectrometry", "Other");
    updatePackageGroupComboBox.setDescription(
            "Select a package group for the currently selected package and hit the " + "update button.");

    Button updateSelectedPackageButton = new Button("Update");
    updateSelectedPackageButton.setIcon(FontAwesome.SPINNER);
    updateSelectedPackageButton.setDescription("Click here to update the currently selected package.");

    Button deleteSelectedPackageButton = new Button("Delete");
    deleteSelectedPackageButton.setIcon(FontAwesome.TRASH_O);
    deleteSelectedPackageButton.setDescription("Click here to delete the currently selected package.");

    Button exportTableButton = new Button("Export as .csv");
    exportTableButton.setIcon(FontAwesome.DOWNLOAD);
    exportTableButton.setDescription("Click here to export the table as .csv file.");

    CheckBox calculatePricesAutomaticallyCheckBox = new CheckBox("Auto-calculate external prices");
    calculatePricesAutomaticallyCheckBox
            .setDescription("Click here to enable/disable the automatic calculation of the "
                    + "external prices based on the internal prices.");
    calculatePricesAutomaticallyCheckBox.setValue(true);

    TableQuery tq = new TableQuery("packages", DBManager.getDatabaseInstanceAlternative());
    tq.setVersionColumn("OPTLOCK");

    SQLContainer container = new SQLContainer(tq);
    container.setAutoCommit(true);

    GeneratedPropertyContainer gpcontainer = new GeneratedPropertyContainer(container);

    // create the column holding the offer_ids where the package is being used in
    // TODO: offer_ids currently not in use; since it's extremely slow..
    /*
        gpcontainer.addGeneratedProperty("offer_ids",
            new PropertyValueGenerator<String>() {
              @Override
              public String getValue(Item item, Object itemId,
                         Object propertyId) {
            
    int package_id = (Integer) item.getItemProperty("package_id").getValue();
            
    // query offers_packages for all offer_ids of the current package
    ArrayList<String> offerIds = db.getOfferIdsForPackage(package_id);
            
    return String.join(",", offerIds);
              }
            
              @Override
              public Class<String> getType() {
    return String.class;
              }
            });
    */

    RefreshableGrid packageGrid = new RefreshableGrid(gpcontainer);

    // add the filters to the grid
    GridCellFilter filter = new GridCellFilter(packageGrid);
    filter.setTextFilter("package_id", true, true);
    filter.setTextFilter("package_name", true, false);
    filter.setTextFilter("package_facility", true, false);
    filter.setTextFilter("package_description", true, false);
    filter.setTextFilter("package_group", true, false);
    filter.setTextFilter("package_unit_type", true, false);
    filter.setComboBoxFilter("package_group", Arrays.asList("Bioinformatics Analysis", "Mass spectrometry",
            "Project Management", "Sequencing", "Other"));

    packageGrid.getColumn("package_id").setHeaderCaption("Id").setWidth(100);
    packageGrid.getColumn("package_name").setHeaderCaption("Name");
    packageGrid.getColumn("package_facility").setHeaderCaption("Facility");
    packageGrid.getColumn("package_description").setHeaderCaption("Description").setWidth(300);
    packageGrid.getColumn("package_group").setHeaderCaption("Package Group").setEditable(false);
    packageGrid.getColumn("package_price_internal").setHeaderCaption("Internal Price ()");
    packageGrid.getColumn("package_price_external_academic").setHeaderCaption("Ext. Academical Price ()");
    packageGrid.getColumn("package_price_external_commercial").setHeaderCaption("Ext. Commercial Price ()");
    // TODO: offer_ids currently not in use; since it's extremely slow..
    //packageGrid.getColumn("offer_ids").setHeaderCaption("Offer Id's");
    packageGrid.getColumn("package_unit_type").setHeaderCaption("Unit Type");

    /*
    // TODO: offer_ids currently not in use; since it's extremely slow..
    packageGrid.setColumnOrder("package_id", "package_name", "package_description", "package_group", "package_facility",
        "package_price_internal", "package_price_external_academic", "package_price_external_commercial",
        "package_unit_type", "offer_ids");*/

    packageGrid.setColumnOrder("package_id", "package_name", "package_description", "package_group",
            "package_facility", "package_price_internal", "package_price_external_academic",
            "package_price_external_commercial", "package_unit_type");

    packageGrid.removeColumn("added_by");
    packageGrid.removeColumn("package_grp");
    packageGrid.removeColumn("package_date");
    packageGrid.removeColumn("last_edited");

    packageGrid.sort("package_name", SortDirection.ASCENDING);
    packageGrid.setWidth("100%");
    packageGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
    packageGrid.setEditorEnabled(true);

    addAutomaticPriceCalculation(calculatePricesAutomaticallyCheckBox, container, packageGrid);

    // add tooltips to the cells
    packageGrid.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> {
        if (cell.getValue() == null)
            return null;
        return cell.getValue().toString();
    });

    // add tooltips to the header row
    for (Grid.Column column : packageGrid.getColumns()) {
        Grid.HeaderCell cell = packageGrid.getDefaultHeaderRow().getCell(column.getPropertyId());
        String htmlWithTooltip = String.format("<span title=\"%s\">%s</span>", cell.getText(), cell.getText());
        cell.setHtml(htmlWithTooltip);
    }

    addListeners(db, addPackageButton, updatePackageGroupComboBox, updateSelectedPackageButton,
            deleteSelectedPackageButton, container, packageGrid, exportTableButton);

    packManHorizontalLayout.addComponent(addPackageButton);
    packManHorizontalLayout.addComponent(updatePackageGroupComboBox);
    packManHorizontalLayout.addComponent(updateSelectedPackageButton);
    packManHorizontalLayout.addComponent(deleteSelectedPackageButton);
    packManHorizontalLayout.addComponent(exportTableButton);
    packManHorizontalLayout.addComponent(calculatePricesAutomaticallyCheckBox);

    packManHorizontalLayout.setComponentAlignment(addPackageButton, Alignment.BOTTOM_CENTER);
    packManHorizontalLayout.setComponentAlignment(updatePackageGroupComboBox, Alignment.MIDDLE_CENTER);
    packManHorizontalLayout.setComponentAlignment(updateSelectedPackageButton, Alignment.BOTTOM_CENTER);
    packManHorizontalLayout.setComponentAlignment(deleteSelectedPackageButton, Alignment.BOTTOM_CENTER);
    packManHorizontalLayout.setComponentAlignment(calculatePricesAutomaticallyCheckBox,
            Alignment.MIDDLE_CENTER);
    packManHorizontalLayout.setComponentAlignment(exportTableButton, Alignment.BOTTOM_CENTER);

    packManVerticalLayout.addComponent(packageGrid);
    packManVerticalLayout.addComponent(packManHorizontalLayout);

    return packManVerticalLayout;
}