Example usage for com.vaadin.ui VerticalLayout setSizeFull

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

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

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. java2s .  co 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// w  w  w  . java2  s  .c om
 * @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/* www .  ja va  2  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:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java

License:Open Source License

public AdminAuthView() {

    setSizeFull();//from w w  w. j a  v a 2s.c o m

    VerticalLayout header = new VerticalLayout();
    header.setSizeFull();

    HorizontalLayout content = new HorizontalLayout();
    content.setSizeFull();

    addComponents(header, content);
    setExpandRatio(header, 1);
    setExpandRatio(content, 6);

    welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>");
    welcomeText.setContentMode(ContentMode.HTML);
    welcomeText.setSizeUndefined();
    header.addComponent(welcomeText);
    header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);

    Panel controlPanel = new Panel("Administrator control panel");
    controlPanel.setSizeUndefined();

    Panel addCoordPanel = new Panel("Create a new coordinator");
    addCoordPanel.setSizeUndefined();

    Panel messagesPanel = new Panel("Administrator messages");
    messagesPanel.setWidth("580px");

    Table adminMessagesTable = new Table();

    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());

    adminMessagesTable.setColumnWidth("inputEvent", 180);
    adminMessagesTable.setSizeFull();

    VerticalLayout controlLayout = new VerticalLayout(controlPanel);
    controlLayout.setSizeFull();
    controlLayout.setMargin(false);
    controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER);

    VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel);
    coordOperationsLayout.setSizeFull();
    coordOperationsLayout.setMargin(false);
    coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER);

    /******************************************/
    coordOperationsLayout.setVisible(true); // main layout in the middle
    addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator"
    /******************************************/

    HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel);
    VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable);

    messagesExternalLayout.setSizeFull();
    messagesExternalLayout.setMargin(false);
    messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER);

    messagesInternalLayout.setMargin(false);
    messagesInternalLayout.setSizeFull();
    messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER);

    messagesPanel.setContent(messagesInternalLayout);

    TextField idCoordAdd = new TextField();
    TextField loginCoord = new TextField();
    PasswordField pwdCoord = new PasswordField();

    Label idCaptionAdd = new Label("ID");
    Label loginCaption = new Label("Login");
    Label pwdCaption = new Label("Password");

    idCaptionAdd.setSizeUndefined();
    idCoordAdd.setSizeUndefined();

    loginCaption.setSizeUndefined();
    loginCoord.setSizeUndefined();

    pwdCaption.setSizeUndefined();
    pwdCoord.setSizeUndefined();

    Button validateNewCoord = new Button("Validate");
    validateNewCoord.setClickShortcut(KeyCode.ENTER);
    validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY);

    GridLayout addCoordinatorLayout = new GridLayout(2, 4);
    addCoordinatorLayout.setSpacing(true);
    addCoordinatorLayout.setMargin(true);
    addCoordinatorLayout.setSizeFull();

    addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption,
            pwdCoord);

    addCoordinatorLayout.addComponent(validateNewCoord, 1, 3);

    addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT);
    addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT);

    addCoordPanel.setContent(addCoordinatorLayout);

    content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER);
    content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER);

    content.setExpandRatio(controlLayout, 20);
    content.setExpandRatio(coordOperationsLayout, 10);
    content.setExpandRatio(messagesExternalLayout, 28);

    Button addCoordinator = new Button("Add coordinator");
    Button deleteCoordinator = new Button("Delete coordinator");

    addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE);
    logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE);

    VerticalLayout buttons = new VerticalLayout();

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

    buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    controlPanel.setContent(buttons);

    buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn);

    /******* DELETE COORDINATOR PANEL BEGIN *********/
    Label idCaptionDel = new Label("ID");
    TextField idCoordDel = new TextField();

    Panel delCoordPanel = new Panel("Delete a coordinator");

    coordOperationsLayout.addComponent(delCoordPanel);
    delCoordPanel.setVisible(false);

    coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER);
    delCoordPanel.setSizeUndefined();

    GridLayout delCoordinatorLayout = new GridLayout(2, 2);
    delCoordinatorLayout.setSpacing(true);
    delCoordinatorLayout.setMargin(true);
    delCoordinatorLayout.setSizeFull();

    Button deleteCoordBtn = new Button("Delete");
    deleteCoordBtn.setClickShortcut(KeyCode.ENTER);
    deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);

    delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel);

    delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1);

    delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT);
    delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT);

    delCoordPanel.setContent(delCoordinatorLayout);
    /******* DELETE COORDINATOR PANEL END *********/

    /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/

    addCoordinator.addClickListener(event -> {
        if (!addCoordPanel.isVisible()) {
            delCoordPanel.setVisible(false);
            addCoordPanel.setVisible(true);
            idCoordAdd.focus();
        } else
            addCoordPanel.setVisible(false);
    });

    deleteCoordinator.addClickListener(event -> {
        if (!delCoordPanel.isVisible()) {
            addCoordPanel.setVisible(false);
            delCoordPanel.setVisible(true);
            idCoordDel.focus();
        } else
            delCoordPanel.setVisible(false);
    });

    /************************************************* MAIN BUTTONS LOGIC END *************************************************/

    /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/
    validateNewCoord.addClickListener(event -> {

        String currentURL = Page.getCurrent().getLocation().toString();
        int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName);
        String iCrashURL = currentURL.substring(0, strIndexCreator);
        String googleShebang = "#!";
        String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang;

        try {
            sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())),
                    new DtLogin(new PtString(loginCoord.getValue())),
                    new DtPassword(new PtString(pwdCoord.getValue())));

            // open new browser tab with the newly created coordinator console...
            // "_blank" instructs the browser to open a new tab instead of a new window...
            // unhappily not all browsers interpret it correctly,
            // some versions of some browsers might still open a new window instead (notably Firefox)!
            Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank");

        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordAdd.setValue("");
        loginCoord.setValue("");
        pwdCoord.setValue("");

        idCoordAdd.focus();
    });
    /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/
    /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/
    deleteCoordBtn.addClickListener(event -> {
        IcrashSystem sys = IcrashSystem.getInstance();

        try {
            sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue())));
        } catch (Exception e) {
            e.printStackTrace();
        }

        idCoordDel.setValue("");
        idCoordDel.focus();
    });
    /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminLoginView.java

License:Open Source License

public AdminLoginView() {

    actAdmin.setActorUI(UI.getCurrent());
    env.setActAdministrator(actAdmin.getName(), actAdmin);
    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctAdmin, actAdmin);

    log.debug("CHECK: ADMIN UI is " + actAdmin.getActorUI());

    welcomeText = new Label("Please login to access iCrash Administrator Console");
    hintText = new Label("(icrashadmin/7WXC1359)");
    welcomeText.setSizeUndefined();/*w  w  w . j  av a 2s  .  c  om*/
    hintText.setSizeUndefined();

    // create the username input field
    username = new TextField("Login:");
    username.setWidth("120px");
    username.setInputPrompt("Admin login");
    username.setImmediate(true);

    // create the password input field
    password = new PasswordField("Password:");
    password.setWidth("120px");
    password.setValue("");
    password.setNullRepresentation("");
    password.setImmediate(true);

    // create the login button
    loginButton = new Button("Login", this);
    loginButton.setClickShortcut(KeyCode.ENTER);
    loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY);
    loginButton.setImmediate(true);

    /*********************************************************************************************/
    Table adminMessagesTable = new Table();
    adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource());
    adminMessagesTable.setCaption("Administrator messages");
    //   adminMessagesTable.setVisibleColumns("inputEvent", "message");
    /*********************************************************************************************/

    FormLayout FL = new FormLayout(username, password, loginButton);

    VerticalLayout welcomeLayout = new VerticalLayout(welcomeText, /*hintText,*/ FL);
    VerticalLayout leftVL = new VerticalLayout(welcomeLayout);
    VerticalLayout rightVL = new VerticalLayout(adminMessagesTable);

    welcomeLayout.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER);
    // welcomeLayout.setComponentAlignment(hintText, Alignment.MIDDLE_CENTER);
    welcomeLayout.setComponentAlignment(FL, Alignment.MIDDLE_CENTER);

    setSizeFull();
    FL.setSizeUndefined();
    welcomeLayout.setSizeUndefined();
    leftVL.setSizeFull();
    rightVL.setSizeFull();

    leftVL.setComponentAlignment(welcomeLayout, Alignment.MIDDLE_CENTER);
    rightVL.setComponentAlignment(adminMessagesTable, Alignment.MIDDLE_CENTER);

    addComponent(leftVL);
    addComponent(rightVL);

    setMargin(true);
    setExpandRatio(leftVL, 6);
    setExpandRatio(rightVL, 4);
}

From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileLoginView.java

License:Open Source License

public CoordMobileLoginView(String CoordID) {
    CtCoordinator ctCoordinator = (CtCoordinator) sys
            .getCtCoordinator(new DtCoordinatorID(new PtString(CoordID)));
    ActCoordinator actCoordinator = env.getActCoordinator(ctCoordinator.login);

    actCoordinator.setActorUI(UI.getCurrent());

    env.setActCoordinator(actCoordinator.getName(), actCoordinator);

    IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
    IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);

    setCaption("Login to Coord " + ctCoordinator.login.toString());

    VerticalLayout layout = new VerticalLayout();
    setContent(layout);/*from w  w  w.  j ava 2  s  . c  om*/

    VerticalComponentGroup group = new VerticalComponentGroup();
    layout.addComponent(group);

    VerticalLayout loginExtLayout = new VerticalLayout();
    loginExtLayout.setSizeFull();
    group.addComponent(loginExtLayout);

    FormLayout loginIntLayout = new FormLayout();
    loginIntLayout.setSizeUndefined();
    loginExtLayout.addComponent(loginIntLayout);

    loginExtLayout.setComponentAlignment(loginIntLayout, Alignment.MIDDLE_CENTER);

    login.setInputPrompt("Coord login");
    pwd.setValue("");
    pwd.setNullRepresentation("");

    loginBtn.setClickShortcut(KeyCode.ENTER);

    loginIntLayout.addComponents(login, pwd, loginBtn);

    ///////////////////////////////////////////////////////////////////////////////////

    Grid messagesTable = new Grid();
    messagesTable.setContainerDataSource(actCoordinator.getMessagesDataSource());
    messagesTable.setSizeUndefined();

    VerticalLayout tableLayout = new VerticalLayout();
    tableLayout.setSizeFull();

    group.addComponent(tableLayout);
    tableLayout.addComponent(messagesTable);

    tableLayout.setComponentAlignment(messagesTable, Alignment.MIDDLE_CENTER);

    ///////////////////////////////////////////////////////////////////////////////////

    loginBtn.addClickListener(event -> {
        PtBoolean res;
        try {
            res = actCoordinator.oeLogin(new DtLogin(new PtString(login.getValue())),
                    new DtPassword(new PtString(pwd.getValue())));
            log.info("oeLogin returned " + res.getValue());

            if (res.getValue()) {
                log.debug("After actCoordinator.oeLogin: JUST LOGGED IN, so Coord's vpIsLogged = "
                        + ctCoordinator.vpIsLogged.getValue());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        // refreshing this view forces redirection of the user
        // to the view, where he should go now, be it CoordLoginView or CoordAuthView
        Page.getCurrent().reload();

        actCoordinator.setActorUI(UI.getCurrent());
        env.setActCoordinator(actCoordinator.getName(), actCoordinator);

        IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator);
        IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator);
    });
}

From source file:management.limbr.ui.login.LogInViewImpl.java

License:Open Source License

@PostConstruct
public void init() {
    setSizeFull();/*from www .j  av a 2 s.  c  o m*/

    usernameField = new TextField(messages.get("usernameFieldLabel"));
    usernameField.setWidth(20.0f, Unit.EM);
    usernameField.setRequired(true);
    usernameField.setInputPrompt(messages.get("usernameFieldPrompt"));
    usernameField
            .addValidator(new StringLengthValidator(messages.get("usernameFieldValidation"), 3, 256, false));
    usernameField.setImmediate(true);
    usernameField.setInvalidAllowed(false);

    passwordField = new PasswordField(messages.get("passwordFieldLabel"));
    passwordField.setWidth(20.0f, Unit.EM);
    passwordField.setInputPrompt(messages.get("passwordFieldPrompt"));
    passwordField
            .addValidator(new StringLengthValidator(messages.get("passwordFieldValidation"), 8, 256, false));
    passwordField.setImmediate(true);
    passwordField.setRequired(true);
    passwordField.setNullRepresentation("");

    Button logInButton = new Button(messages.get("logInButtonLabel"));
    logInButton.addClickListener(event -> {
        usernameField.setValidationVisible(false);
        passwordField.setValidationVisible(false);
        try {
            usernameField.commit();
            passwordField.commit();
        } catch (Validator.InvalidValueException e) {
            Notification.show(e.getMessage());
            usernameField.setValidationVisible(true);
            passwordField.setValidationVisible(true);
            LOG.debug("Validation of log in fields failed.", e);
        }
        listeners.forEach(LogInViewListener::logInClicked);
    });

    VerticalLayout fields = new VerticalLayout(usernameField, passwordField, logInButton);
    fields.setCaption(messages.get("logInCaption", LimbrApplication.getApplicationName()));
    fields.setSpacing(true);
    fields.setMargin(new MarginInfo(true, true, true, false));
    fields.setSizeUndefined();

    VerticalLayout mainLayout = new VerticalLayout(fields);
    mainLayout.setSizeFull();
    mainLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER);
    mainLayout.setStyleName(ValoTheme.FORMLAYOUT_LIGHT);

    setCompositionRoot(mainLayout);

    listeners.forEach(listener -> listener.viewInitialized(this));
}

From source file:management.limbr.ui.VaadinUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(true);//from w  ww. j  a  va2s.  c  o m
    root.setSpacing(true);
    setContent(root);

    Image logo = new Image(null, new ExternalResource("images/logo1.png"));
    logo.setHeight(1.2f, Unit.EM);
    logo.setWidthUndefined();

    CssLayout navBar = new CssLayout();
    navBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    navBar.addComponent(logo);
    navBar.addComponent(createNavButton("Users", UsersViewImpl.VIEW_NAME));
    root.addComponent(navBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);

}

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

License:Open Source License

private void initView() {
    setCompositionRoot(root);//from w  ww  . j  av  a2 s .  co 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:net.javaforge.netty.vaadin.AddressbookUI.java

License:Apache License

private void initLayout() {

    /* Root of the user interface component tree is set */
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    setContent(splitPanel);/* w w w .jav  a2 s  .  c  o m*/

    /* Build the component tree */
    VerticalLayout leftLayout = new VerticalLayout();
    splitPanel.addComponent(leftLayout);
    splitPanel.addComponent(editorLayout);
    leftLayout.addComponent(contactList);
    HorizontalLayout bottomLeftLayout = new HorizontalLayout();
    leftLayout.addComponent(bottomLeftLayout);
    bottomLeftLayout.addComponent(searchField);
    bottomLeftLayout.addComponent(addNewContactButton);

    /* Set the contents in the left of the split panel to use all the space */
    leftLayout.setSizeFull();

    /*
       * On the left side, expand the size of the contactList so that it uses
     * all the space left after from bottomLeftLayout
     */
    leftLayout.setExpandRatio(contactList, 1);
    contactList.setSizeFull();

    /*
     * In the bottomLeftLayout, searchField takes all the width there is
     * after adding addNewContactButton. The height of the layout is defined
     * by the tallest component.
     */
    bottomLeftLayout.setWidth("100%");
    searchField.setWidth("100%");
    bottomLeftLayout.setExpandRatio(searchField, 1);

    /* Put a little margin around the fields in the right side editor */
    editorLayout.setMargin(true);
    editorLayout.setVisible(false);
}