Example usage for com.vaadin.server FontAwesome SPINNER

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

Introduction

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

Prototype

FontAwesome SPINNER

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

Click Source Link

Usage

From source file:com.mycollab.module.project.view.milestone.MilestoneRoadmapViewImpl.java

License:Open Source License

private void displayWidget() {
    final MilestoneSearchCriteria tmpCriteria = BeanUtility.deepClone(baseCriteria);
    tmpCriteria.setStatuses(new SetSearchField<>(MilestoneStatus.Closed.name()));
    int totalCloseCount = milestoneService.getTotalCount(tmpCriteria);
    closeMilestoneSelection.setCaption(String.format("%s (%d)",
            UserUIContext.getMessage(MilestoneI18nEnum.WIDGET_CLOSED_PHASE_TITLE), totalCloseCount));
    closeMilestoneSelection.setIcon(FontAwesome.MINUS_CIRCLE);
    filterPanel.addComponent(closeMilestoneSelection);

    tmpCriteria.setStatuses(new SetSearchField<>(MilestoneStatus.InProgress.name()));
    int totalInProgressCount = milestoneService.getTotalCount(tmpCriteria);
    inProgressMilestoneSelection.setCaption(String.format("%s (%d)",
            UserUIContext.getMessage(MilestoneI18nEnum.WIDGET_INPROGRESS_PHASE_TITLE), totalInProgressCount));
    inProgressMilestoneSelection.setIcon(FontAwesome.SPINNER);
    filterPanel.addComponent(inProgressMilestoneSelection);

    tmpCriteria.setStatuses(new SetSearchField<>(MilestoneStatus.Future.name()));
    int totalFutureCount = milestoneService.getTotalCount(tmpCriteria);
    futureMilestoneSelection.setCaption(String.format("%s (%d)",
            UserUIContext.getMessage(MilestoneI18nEnum.WIDGET_FUTURE_PHASE_TITLE), totalFutureCount));
}

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  .jav a2s.  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  ww  .  jav a 2  s.co m
 * @throws SQLException :
 */
static Component createOfferManagerTabPackageComponent(SQLContainer offerGridContainer, String selectedOfferID,
        String packagesType) throws SQLException {

    Database db = qOfferManager.getDb();

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

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

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

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

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

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

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

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

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

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

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

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

    packSettingsLayout.setSpacing(true);

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

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

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

    selectedPacksInOfferGrid = new RefreshableGrid(packsContainer);

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

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

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

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

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

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

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

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

    return packQuantityLayout;
}

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

License:Open Source License

/**
 * creates the tab for creating new packages
 * @return vaadin component//from w w  w.j a va2  s  . com
 * @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:org.jumpmind.metl.ui.views.manage.ExecutionRunPanel.java

License:Open Source License

protected void refreshUI(ExecutionData data) {
    if (!lastDataRefreshWasDone) {
        flowLabel.setValue(data.execution.getFlowName());
        startLabel.setValue(formatDate(data.execution.getStartTime()));
        if (data.execution.getStatus() != null) {
            if (data.execution.getStatus().equals(ExecutionStatus.ERROR.name())) {
                statusLabel.setStyleName("error");
                statusLabel.setValue(FontAwesome.WARNING.getHtml() + " " + data.execution.getStatus());
            } else if (data.execution.getStatus().equals(ExecutionStatus.DONE.name())) {
                statusLabel.setStyleName("done");
                statusLabel.setValue(FontAwesome.CHECK.getHtml() + " " + data.execution.getStatus());
            } else if (data.execution.getStatus().equals(ExecutionStatus.RUNNING.name())) {
                statusLabel.setStyleName("running");
                statusLabel.setValue(FontAwesome.SPINNER.getHtml() + " " + data.execution.getStatus());
            } else {
                statusLabel.setStyleName("");
                statusLabel.setValue(data.execution.getStatus());
            }/*from w w  w.ja v a 2s.  c o m*/
        }
        endLabel.setValue(formatDate(data.execution.getEndTime()));

        if (showDiagramCheckbox.getValue()) {
            redrawFlow();
        }

        @SuppressWarnings("unchecked")
        Set<String> selected = (Set<String>) stepTable.getValue();
        stepContainer.removeAllItems();
        stepContainer.addAll(data.steps);
        if (selected != null && selected.size() > 0) {
            stepTable.setValue(selected);
        } else if (data.steps.size() > 0) {
            selected = new HashSet<>();
            selected.add(data.steps.get(0).getId());
            stepTable.setValue(selected);
        }

        List<ExecutionStepLog> logMessages = new ArrayList<>(logContainer.getItemIds());

        List<ExecutionStepLog> newLogMessages = new ArrayList<>(data.logs);

        for (ExecutionStepLog logMsg : logMessages) {
            newLogMessages.remove(logMsg);
        }

        if (newLogMessages.size() > 0) {
            logContainer.addAll(newLogMessages);
            if (lastSortOrder != null) {
                logTable.setSortOrder(lastSortOrder);
            }
        }
    }

    rerunButton.setVisible(isDone() && flowRunnable != null);
    removeButton.setVisible(isDone());
    cancelButton.setVisible(!isDone());

    lastDataRefreshWasDone = isDone();
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java

License:Open Source License

protected boolean execute(final boolean runAsScript, String sqlText, final int tabPosition,
        final boolean forceNewTab) {
    boolean scheduled = false;
    if (runnersInProgress == null) {
        runnersInProgress = new HashSet<SqlRunner>();
    }//from w  ww .j  a va2s  . com

    if (sqlText == null) {
        if (!runAsScript) {
            sqlText = selectSqlToRun();
        } else {
            sqlText = sqlArea.getValue();
        }

        sqlText = sqlText != null ? sqlText.trim() : null;
    }

    if (StringUtils.isNotBlank(sqlText)) {

        final HorizontalLayout executingLayout = new HorizontalLayout();
        executingLayout.setMargin(true);
        executingLayout.setSizeFull();
        final Label label = new Label("Executing:\n\n" + StringUtils.abbreviate(sqlText, 250),
                ContentMode.PREFORMATTED);
        label.setEnabled(false);
        executingLayout.addComponent(label);
        executingLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

        final String sql = sqlText;
        final Tab executingTab;
        if (!forceNewTab && generalResultsTab != null) {
            replaceGeneralResultsWith(executingLayout, FontAwesome.SPINNER);
            executingTab = null;
        } else {
            executingTab = resultsTabs.addTab(executingLayout, StringUtils.abbreviate(sql, 20),
                    FontAwesome.SPINNER, tabPosition);
        }

        if (executingTab != null) {
            executingTab.setClosable(true);
            resultsTabs.setSelectedTab(executingTab);
        }

        final SqlRunner runner = new SqlRunner(sql, runAsScript, user, db, settingsProvider.get(), this,
                generalResultsTab != null);
        runnersInProgress.add(runner);
        runner.setConnection(connection);
        runner.setListener(new SqlRunner.ISqlRunnerListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void writeSql(String sql) {
                QueryPanel.this.appendSql(sql);
            }

            @Override
            public void reExecute(String sql) {
                QueryPanel.this.reExecute(sql);
            }

            public void finished(final FontAwesome icon, final List<Component> results,
                    final long executionTimeInMs, final boolean transactionStarted,
                    final boolean transactionEnded) {
                VaadinSession.getCurrent().access(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            if (transactionEnded) {
                                transactionEnded();
                            } else if (transactionStarted) {
                                rollbackButtonValue = true;
                                commitButtonValue = true;
                                setButtonsEnabled();
                                sqlArea.setStyleName("transaction-in-progress");
                                connection = runner.getConnection();
                            }

                            addToSqlHistory(StringUtils.abbreviate(sql, 1024 * 8), runner.getStartTime(),
                                    executionTimeInMs, user);

                            for (Component resultComponent : results) {
                                resultComponent.setSizeFull();

                                if (forceNewTab || generalResultsTab == null || results.size() > 1) {
                                    if (resultComponent instanceof TabularResultLayout) {
                                        resultComponent = ((TabularResultLayout) resultComponent)
                                                .refreshWithoutSaveButton();
                                    }
                                    addResultsTab(resultComponent, StringUtils.abbreviate(sql, 20), icon,
                                            tabPosition);
                                } else {
                                    replaceGeneralResultsWith(resultComponent, icon);
                                    resultsTabs.setSelectedTab(generalResultsTab.getComponent());
                                }

                                String statusVal;
                                if (canceled) {
                                    statusVal = "Sql canceled after " + executionTimeInMs + " ms for "
                                            + db.getName() + ".  Finished at "
                                            + SimpleDateFormat.getTimeInstance().format(new Date());
                                } else {
                                    statusVal = "Sql executed in " + executionTimeInMs + " ms for "
                                            + db.getName() + ".  Finished at "
                                            + SimpleDateFormat.getTimeInstance().format(new Date());
                                }
                                status.setValue(statusVal);
                                resultStatuses.put(resultComponent, statusVal);
                                canceled = false;
                            }
                        } finally {
                            setButtonsEnabled();
                            if (executingTab != null) {
                                resultsTabs.removeTab(executingTab);
                            } else if (results.size() > 1) {
                                resetGeneralResultsTab();
                            }
                            runnersInProgress.remove(runner);
                            runner.setListener(null);
                        }
                    }
                });

            }

        });

        final Button cancel = new Button("Cancel");
        cancel.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                log.info("Canceling sql: " + sql);
                label.setValue("Canceling" + label.getValue().substring(9));
                executingLayout.removeComponent(cancel);
                canceled = true;
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        runner.cancel();
                    }
                }).start();
            }
        });
        executingLayout.addComponent(cancel);

        scheduled = true;
        runner.start();

    }
    setButtonsEnabled();
    return scheduled;
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableInfoPanel.java

License:Open Source License

protected void refreshData(final org.jumpmind.db.model.Table table, final String user, final IDb db,
        final Settings settings, boolean isInit) {

    if (!isInit) {
        tabSheet.removeTab(tabSheet.getTab(1));
    }//ww  w  .  j a  v  a 2 s.  c o m

    IDatabasePlatform platform = db.getPlatform();
    DmlStatement dml = platform.createDmlStatement(DmlType.SELECT_ALL, table, null);

    final HorizontalLayout executingLayout = new HorizontalLayout();
    executingLayout.setSizeFull();
    final ProgressBar p = new ProgressBar();
    p.setIndeterminate(true);
    final int oldPollInterval = UI.getCurrent().getPollInterval();
    UI.getCurrent().setPollInterval(100);
    executingLayout.addComponent(p);
    executingLayout.setData(isInit);
    tabSheet.addTab(executingLayout, "Data", isInit ? null : FontAwesome.SPINNER, 1);
    if (!isInit) {
        tabSheet.setSelectedTab(executingLayout);
    }

    SqlRunner runner = new SqlRunner(dml.getSql(), false, user, db, settings, explorer,
            new ISqlRunnerListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void writeSql(String sql) {
                    explorer.openQueryWindow(db).appendSql(sql);
                }

                @Override
                public void reExecute(String sql) {
                    refreshData(table, user, db, settings, false);
                }

                @Override
                public void finished(final FontAwesome icon, final List<Component> results,
                        long executionTimeInMs, boolean transactionStarted, boolean transactionEnded) {
                    VaadinSession.getCurrent().access(new Runnable() {

                        @Override
                        public void run() {
                            tabSheet.removeComponent(executingLayout);
                            VerticalLayout layout = new VerticalLayout();
                            layout.setMargin(true);
                            layout.setSizeFull();
                            if (results.size() > 0) {
                                layout.addComponent(results.get(0));
                            }
                            tabSheet.addTab(layout, "Data", null, 1);
                            UI.getCurrent().setPollInterval(oldPollInterval);
                            tabSheet.setSelectedTab(layout);
                        }
                    });
                }
            });
    runner.setShowSqlOnResults(false);
    runner.setLogAtDebug(true);
    if (!isInit) {
        runner.start();
    }

}