Example usage for com.vaadin.ui Button setDescription

List of usage examples for com.vaadin.ui Button setDescription

Introduction

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

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the component's description.

Usage

From source file:jp.primecloud.auto.ui.WinServiceAdd.java

License:Open Source License

WinServiceAdd(Application ap) {
    apl = ap;//  ww w .ja va  2  s  .  c  o  m

    //
    setIcon(Icons.ADD.resource());
    setCaption(ViewProperties.getCaption("window.winServiceAdd"));
    setModal(true);
    setWidth("630px");
    //setHeight("500px");

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(false, true, false, true);
    layout.setSpacing(false);

    // 
    layout.addComponent(new BasicForm());

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(false, false, true, false);
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // Add
    Button addButton = new Button(ViewProperties.getCaption("button.add"));
    addButton.setDescription(ViewProperties.getCaption("description.addService"));
    addButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinServiceAdd.this.addButtonClick(event);
        }
    });
    okbar.addComponent(addButton);
    // [Enter]?addButton
    addButton.setClickShortcut(KeyCode.ENTER);
    addButton.focus();

    // Cancel
    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinServiceAdd.this.close();
        }
    });
    okbar.addComponent(cancelButton);

    // ??
    initValidation();

    // ???
    initData();

    // 
    showServices();
}

From source file:jp.primecloud.auto.ui.WinServiceEdit.java

License:Open Source License

WinServiceEdit(Application ap, Long componentNo) {
    apl = ap;/*w ww. j a  va  2s. co  m*/
    this.componentNo = componentNo;

    // ???
    initData();

    //
    setIcon(Icons.EDITMINI.resource());
    setCaption(ViewProperties.getCaption("window.winServiceEdit"));
    setModal(true);
    setWidth("600px");

    VerticalLayout layout = (VerticalLayout) getContent();
    //        layout.setWidth("100%");
    layout.setMargin(false, true, false, true);
    layout.setSpacing(true);

    // 
    layout.addComponent(tab);

    basicTab = new BasicTab();
    tab.addTab(basicTab, ViewProperties.getCaption("tab.basic"), Icons.BASIC.resource());

    detailTab = new DetailTab();
    Boolean useCustomPara = BooleanUtils.toBooleanObject(Config.getProperty("userCustomize.useCustomParam"));
    if (BooleanUtils.isTrue(useCustomPara)) {
        tab.addTab(detailTab, ViewProperties.getCaption("tab.detail"), Icons.BASIC.resource());
    }

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(false, false, true, false);
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // OK
    Button okButton = new Button(ViewProperties.getCaption("button.ok"));
    okButton.setDescription(ViewProperties.getCaption("description.editService.ok"));
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            okButtonClick(event);
        }
    });
    okbar.addComponent(okButton);
    // [Enter]?okButton
    okButton.setClickShortcut(KeyCode.ENTER);
    okButton.focus();

    // Cancel
    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    okbar.addComponent(cancelButton);

    // ??
    initValidation();

    // ?
    basicTab.showData();

    // ?
    detailTab.showData();
}

From source file:jp.primecloud.auto.ui.WinUserAuthAddEdit.java

License:Open Source License

WinUserAuthAddEdit(Long masterUserNo, Long userNo) {

    this.masterUserNo = masterUserNo;
    this.userNo = userNo;

    //?/*from  w  w w  .  j ava 2 s . c  om*/
    isAddUser = (userNo == null) ? true : false;

    // ???
    initData();

    //
    //????
    if (isAddUser) {
        //??
        setIcon(Icons.ADD.resource());
        setCaption(ViewProperties.getCaption("window.winUserAdd"));
    } else {
        //?
        setIcon(Icons.EDIT.resource());
        setCaption(ViewProperties.getCaption("window.winUserEdit"));
    }
    //
    setModal(true);
    setWidth("450px");
    //
    setResizable(false);

    //
    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(false, true, false, true);
    layout.setSpacing(false);

    // 
    layout.addComponent(new AuthAddForm());

    // ?
    userAuthTable = new UserAuthTable();
    layout.addComponent(userAuthTable);

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(true, false, true, false);
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // OK
    Button okButton = new Button(ViewProperties.getCaption("button.ok"));
    if (isAddUser) {
        //??
        okButton.setDescription(ViewProperties.getCaption("description.addUserAuth.ok"));
    } else {
        //?
        okButton.setDescription(ViewProperties.getCaption("description.editUserAuth.ok"));
    }
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinUserAuthAddEdit.this.okButtonClick(event);
        }
    });
    okbar.addComponent(okButton);

    //Delete
    if (!isAddUser) {
        //?????
        Button deleteButton = new Button(ViewProperties.getCaption("button.delete"));
        deleteButton.setDescription(ViewProperties.getCaption("description.editUserAuth.delete"));
        deleteButton.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                WinUserAuthAddEdit.this.deleteButtonClick(event);
            }
        });
        okbar.addComponent(deleteButton);
    }

    // Cancel
    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinUserAuthAddEdit.this.cancelButtonClick(event);
        }
    });
    okbar.addComponent(cancelButton);

    // ??
    showData();

    // ??
    initValidation();
}

From source file:jp.primecloud.auto.ui.WinUserAuthEditDetail.java

License:Open Source License

WinUserAuthEditDetail(Long userNo, Long farmNo) {

    this.userNo = userNo;
    this.farmNo = farmNo;

    ///*from w  ww.  j a  va2s. c o  m*/
    setIcon(Icons.EDIT.resource());
    setCaption(ViewProperties.getCaption("window.winUserDetailEdit"));

    //
    setModal(true);
    setWidth("300px");
    //
    setResizable(false);

    //
    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(false, true, false, true);
    layout.setSpacing(false);

    layout.addComponent(new AuthForm());

    // ??
    HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setMargin(false, false, true, false);
    layout.addComponent(okbar);
    layout.setComponentAlignment(okbar, Alignment.BOTTOM_RIGHT);

    // OK
    Button okButton = new Button(ViewProperties.getCaption("button.ok"));
    okButton.setDescription(ViewProperties.getCaption("description.editUserAuthDetail.ok"));
    okButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinUserAuthEditDetail.this.okButtonClick(event);
        }
    });
    okbar.addComponent(okButton);

    // Cancel
    Button cancelButton = new Button(ViewProperties.getCaption("button.cancel"));
    cancelButton.setDescription(ViewProperties.getCaption("description.cancel"));
    cancelButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            WinUserAuthEditDetail.this.cancelButtonClick(event);
        }
    });
    okbar.addComponent(cancelButton);

    // ??
    initData();

    // ?
    showData();

    // ??
    initValidation();
}

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

License:Open Source License

/**
 * creates the tab to generate the offers with the respective packages
 * @return vaadin component holding the offer generator
 *//*  ww w .j  a  va  2 s .co m*/
static Component createOfferGeneratorTab() {

    Database db = qOfferManager.getDb();
    TabSheet managerTabs = qOfferManager.getManagerTabs();

    ComboBox selectedProjectComboBox = new ComboBox("Select Project");
    selectedProjectComboBox.setInputPrompt("No project selected!");
    selectedProjectComboBox.setDescription("Please select a project before its too late! :P");
    selectedProjectComboBox.addItems(db.getProjects());
    selectedProjectComboBox.setWidth("300px");

    Button completeButton = new Button("Complete");
    completeButton.setDescription("Click here to finalize the offer and save it into the DB!");
    completeButton.setIcon(FontAwesome.CHECK_CIRCLE);
    completeButton.setEnabled(false);

    // get the package ids and names as a bean container
    final BeanItemContainer<String> packageIdsAndNamesContainer = new BeanItemContainer<>(String.class);
    packageIdsAndNamesContainer.addAll(db.getPackageIdsAndNames());

    TwinColSelect selectPackagesTwinColSelect = new TwinColSelect();
    selectPackagesTwinColSelect.setContainerDataSource(packageIdsAndNamesContainer);
    selectPackagesTwinColSelect.setLeftColumnCaption("Available packages");
    selectPackagesTwinColSelect.setRightColumnCaption("Selected packages");
    selectPackagesTwinColSelect.setSizeFull();

    // text field which functions as a filter for the left side of the twin column select
    TextField twinColSelectFilter = new TextField();
    twinColSelectFilter.setCaption("Filter available packages");
    twinColSelectFilter.addTextChangeListener((FieldEvents.TextChangeListener) event -> {
        packageIdsAndNamesContainer.removeAllContainerFilters();
        packageIdsAndNamesContainer.addContainerFilter(new Container.Filter() {

            @Override
            public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException {
                return ((String) itemId).toLowerCase().contains(event.getText().toLowerCase())
                        || ((Collection) selectPackagesTwinColSelect.getValue()).contains(itemId);
            }

            @Override
            public boolean appliesToProperty(Object propertyId) {
                return true;
            }
        });
    });

    VerticalLayout right = new VerticalLayout();
    right.setSpacing(true);
    right.setMargin(true);

    VerticalLayout addPackLayout = new VerticalLayout();
    addPackLayout.setMargin(true);
    addPackLayout.setSpacing(true);

    Panel packageDescriptionPanel = new Panel("Package Details");
    packageDescriptionPanel.setContent(right);

    @SuppressWarnings("deprecation")
    Label packageDetailsLabel = new Label("Package details will appear here!", Label.CONTENT_XHTML);
    packageDetailsLabel.addStyleName(ValoTheme.LABEL_BOLD);
    right.addComponent(packageDetailsLabel);

    addListeners(db, managerTabs, selectedProjectComboBox, completeButton, addPackLayout,
            selectPackagesTwinColSelect, packageDescriptionPanel, packageDetailsLabel, twinColSelectFilter);

    addPackLayout.addComponent(selectedProjectComboBox);

    return addPackLayout;
}

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/*from  ww  w.j av a2 s . 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. jav a  2s. com
 * @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// ww  w.  j  ava2 s  .  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;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);//from w w w  .j a va2s  . c o  m
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private Layout getButtonPreviews() {
    Layout grid = getPreviewLayout("Buttons");

    Button button = new Button("Button");
    grid.addComponent(button);//from   w  w  w.j a  v  a2  s  .  c  om

    button = new Button("Default");
    button.setStyleName("default");
    grid.addComponent(button);

    button = new Button("Small");
    button.setStyleName("small");
    grid.addComponent(button);

    button = new Button("Small Default");
    button.setStyleName("small default");
    grid.addComponent(button);

    button = new Button("Big");
    button.setStyleName("big");
    grid.addComponent(button);

    button = new Button("Big Default");
    button.setStyleName("big default");
    grid.addComponent(button);

    button = new Button("Disabled");
    button.setEnabled(false);
    grid.addComponent(button);

    button = new Button("Disabled default");
    button.setEnabled(false);
    button.setStyleName("default");
    grid.addComponent(button);

    button = new Button("Link style");
    button.setStyleName(BaseTheme.BUTTON_LINK);
    grid.addComponent(button);

    button = new Button("Disabled link");
    button.setStyleName(BaseTheme.BUTTON_LINK);
    button.setEnabled(false);
    grid.addComponent(button);

    button = new Button("120px overflows out of the button");
    button.setIcon(new ThemeResource("../runo/icons/16/document.png"));
    button.setWidth("120px");
    grid.addComponent(button);

    button = new Button("Small");
    button.setStyleName("small");
    button.setIcon(new ThemeResource("../runo/icons/16/document.png"));
    grid.addComponent(button);

    button = new Button("Big");
    button.setStyleName("big");
    button.setIcon(new ThemeResource("../runo/icons/16/document.png"));
    grid.addComponent(button);

    button = new Button("Big Default");
    button.setStyleName("big default");
    button.setIcon(new ThemeResource("../runo/icons/32/document-txt.png"));
    grid.addComponent(button);

    button = new Button("Big link");
    button.setStyleName(BaseTheme.BUTTON_LINK + " big");
    button.setIcon(new ThemeResource("../runo/icons/32/document.png"));
    grid.addComponent(button);

    button = new Button("Borderless");
    button.setStyleName("borderless");
    button.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    grid.addComponent(button);

    button = new Button("Borderless icon on top");
    button.setStyleName("borderless icon-on-top");
    button.setIcon(new ThemeResource("../runo/icons/32/note.png"));
    grid.addComponent(button);

    button = new Button("Icon on top");
    button.setStyleName("icon-on-top");
    button.setIcon(new ThemeResource("../runo/icons/32/users.png"));
    grid.addComponent(button);

    button = new Button("Wide Default");
    button.setStyleName("wide default");
    grid.addComponent(button);

    button = new Button("Wide");
    button.setStyleName("wide");
    grid.addComponent(button);

    button = new Button("Tall");
    button.setStyleName("tall");
    grid.addComponent(button);

    button = new Button("Wide, Tall & Big");
    button.setStyleName("wide tall big");
    grid.addComponent(button);

    button = new Button("Icon on right");
    button.setStyleName("icon-on-right");
    button.setIcon(new ThemeResource("../runo/icons/16/document.png"));
    grid.addComponent(button);

    button = new Button("Big icon");
    button.setStyleName("icon-on-right big");
    button.setIcon(new ThemeResource("../runo/icons/16/document.png"));
    grid.addComponent(button);

    button = new Button("Toggle (down)");
    button.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (event.getButton().getStyleName().endsWith("down")) {
                event.getButton().removeStyleName("down");
            } else {
                event.getButton().addStyleName("down");
            }
        }
    });
    button.addStyleName("down");
    grid.addComponent(button);
    button.setDescription(
            button.getDescription() + "<br><strong>Stylename switching logic must be done separately</strong>");

    button = new Button();
    button.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (event.getButton().getStyleName().endsWith("down")) {
                event.getButton().removeStyleName("down");
            } else {
                event.getButton().addStyleName("down");
            }
        }
    });
    button.addStyleName("icon-only");
    button.addStyleName("down");
    button.setIcon(new ThemeResource("../runo/icons/16/user.png"));
    grid.addComponent(button);
    button.setDescription(
            button.getDescription() + "<br><strong>Stylename switching logic must be done separately</strong>");

    Link l = new Link("Link: vaadin.com", new ExternalResource("http://vaadin.com"));
    grid.addComponent(l);

    l = new Link("Link: vaadin.com", new ExternalResource("http://vaadin.com"));
    l.setIcon(new ThemeResource("../runo/icons/32/globe.png"));
    grid.addComponent(l);

    return grid;
}