Example usage for com.vaadin.ui HorizontalLayout setCaption

List of usage examples for com.vaadin.ui HorizontalLayout setCaption

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout setCaption.

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:com.fnc.view.ui.thirteenth.ThirteenthMonthUI.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("50%");

    corporation.setCaption("Corporation: ");
    corporation.addStyleName(ValoTheme.COMBOBOX_SMALL);
    trade.setCaption("Trade: ");
    trade.addStyleName(ValoTheme.COMBOBOX_SMALL);
    branch.setCaption("Branch: ");
    branch.addStyleName(ValoTheme.COMBOBOX_SMALL);

    corporation.addValueChangeListener(new CorporateComboBoxPropertyListener(trade, trade.getCaption()));
    form.addComponent(corporation);/*from   w ww . j av a 2s .c  o m*/

    trade.addValueChangeListener(new CorporateComboBoxPropertyListener(branch, branch.getCaption()));
    form.addComponent(trade);

    branch.addValueChangeListener(branchPropertyChangeListener);
    form.addComponent(branch);

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Year: ");
    h.setWidth("100%");
    h.setSpacing(true);

    h.addComponent(selectYear());
    h.addComponent(button());

    form.addComponent(h);

    return form;
}

From source file:com.hris.payroll.alphalist.AlphaListMainUI.java

public AlphaListMainUI(int branchId) {
    this.branchId = branchId;

    setSizeFull();/*from ww w  . j  a v a  2 s  .  c o m*/
    setMargin(new MarginInfo(true, true, false, true));
    setSpacing(true);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setCaption("Year: ");
    h1.setWidthUndefined();
    h1.setSpacing(true);

    h1.addComponent(employmentStatus);
    h1.addComponent(selectYear());
    h1.addComponent(alphaListButton());
    h1.addComponent(exportToExcelButton());

    addComponent(h1);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setWidthUndefined();
    h2.setSpacing(true);

    progress.setWidth("410px");
    h2.addComponent(progress);
    h2.setComponentAlignment(progress, Alignment.MIDDLE_LEFT);

    status.setValue("0%");
    h2.addComponent(status);

    processLabel.setValue("");
    h2.addComponent(processLabel);

    addComponent(h2);
    addComponent(grid);
    setExpandRatio(grid, 3);
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds library screen. This method overrides an existing
 * method./*from w ww  .  j  ava  2 s. c  o m*/
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    HorizontalLayout root = new HorizontalLayout();
    root.setSizeFull();
    root.setCaption("Media Library");
    root.setHeight("200%");
    root.setWidth("100%");

    this.content = new VerticalLayout();
    content.setSizeFull();
    root.addComponent(content);

    final GridLayout grid = new GridLayout(4, 1);
    Panel top = new Panel("Music Collection", grid);
    top.setSizeFull();
    top.addStyleName(Runo.PANEL_LIGHT);
    grid.setWidth("100%");
    grid.setMargin(true);
    grid.addStyleName(Runo.LAYOUT_DARKER);
    content.addComponent(top);
    content.setExpandRatio(top, 1);

    grid.addLayoutClickListener(new LayoutClickListener() {

        private static final long serialVersionUID = -1864555729437118182L;

        @Override
        public void layoutClick(LayoutClickEvent event) {
            for (Iterator<Component> it = grid.iterator(); it.hasNext();) {
                Component c = it.next();
                c.removeStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED);

            }

            if (event.getChildComponent() != null) {
                event.getChildComponent().addStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED);
            }
        }
    });

    buildAudioLibrary(grid, null);

    return root;

}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java

License:Open Source License

private HorizontalLayout createSeriesLayout() {
    HorizontalLayout seriesLayout = new HorizontalLayout();
    seriesLayout.setSpacing(true);//from   w  ww  .  j a  v  a  2  s.  co  m
    seriesLayout.setCaption("Series");
    seriesSelect.addItem("Test");
    Button addSeries = new Button("new series");
    addSeries.addStyleName("link");

    seriesLayout.addComponent(seriesSelect);
    seriesLayout.addComponent(addSeries);
    return seriesLayout;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java

License:Open Source License

private HorizontalLayout createAuthorsLayout() {
    HorizontalLayout authorsLayout = new HorizontalLayout();
    authorsLayout.setSpacing(true);/*from   w  ww .  java 2  s. c  om*/
    authorsLayout.setCaption("Author");
    authorSelect.addItem("Test");
    Button addAuthor = new Button("new author");
    addAuthor.addStyleName("link");
    /*
    addAuthor.addClickListener(new Button.ClickListener() {
    @Override
    public void buttonClick(Button.ClickEvent event) {
        try {
            String path = Path.getAbsolutePath(parentItem.applyChanges().getPath(), NEW_NODE_NAME);
            DetailLocation location = new DetailLocation(getDefinition().getAppName(), getDefinition().getSubAppId(), DetailView.ViewType.EDIT, path, "");
            locationController.goTo(location);
        } catch (RepositoryException e) {
            throw new ActionExecutionException(e);
        }
    }
    });
    */

    authorsLayout.addComponent(authorSelect);
    authorsLayout.addComponent(addAuthor);
    return authorsLayout;
}

From source file:com.peergreen.example.webconsole.extensions.NavigatorExtension.java

License:Open Source License

@PostConstruct
public void init() {
    Label guide = new Label(
            "The path of a navigable extension is the path of its parent concatenated with the string "
                    + "inside the class annotation @Navigable(\"alias\")");
    guide.addStyleName("h2");
    addComponent(guide);//  ww w . jav a2 s .co m

    HorizontalLayout row = new HorizontalLayout();
    row.setSpacing(true);
    row.setMargin(true);
    row.setCaption("Type the alias of an extension you want to navigate to");
    final ComboBox comboBox = new ComboBox();
    comboBox.setWidth("400px");
    comboBox.setNullSelectionAllowed(false);
    comboBox.addItem("/example/simple");
    comboBox.addItem("/example/notifier");
    comboBox.addItem("/example/window");
    comboBox.addItem("/example/confirm");
    row.addComponent(comboBox);
    Button navigate = new Button("Navigate");
    navigate.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (comboBox.getValue() != null && !"".equals(comboBox.getValue())) {
                uiContext.getViewNavigator().navigateTo(comboBox.getValue().toString());
            }
        }
    });
    row.addComponent(navigate);
    addComponent(row);
    setExpandRatio(row, 1.5f);
}

From source file:com.peergreen.webconsole.scope.logs.LogsScope.java

License:Open Source License

public LogsScope() {
    setMargin(true);/*ww w.  j  a  v  a2  s  .  c  om*/
    setSpacing(true);
    setSizeFull();

    HorizontalLayout topBar = new HorizontalLayout();
    topBar.setWidth("100%");
    addComponent(topBar);
    FormLayout form = new FormLayout();
    form.setWidth("40%");
    topBar.addComponent(form);

    TextField textFieldFilter = new TextField();
    textFieldFilter.setCaption("Filter:");
    textFieldFilter.setInputPrompt("filter");
    textFieldFilter.setWidth("60%");
    textFieldFilter.addTextChangeListener(new TextChangeListener() {
        @Override
        public void textChange(final FieldEvents.TextChangeEvent event) {
            container.removeAllContainerFilters();
            Container.Filter or = new Or(new SimpleStringFilter("caller", event.getText().trim(), true, false),
                    new SimpleStringFilter("text", event.getText().trim(), true, false));
            Filter and = new And(or, filter);

            container.addContainerFilter(and);
        }
    });

    topBar.addComponent(textFieldFilter);

    //form.setWidth("100%");
    form.setSpacing(true);
    form.setMargin(true);
    HorizontalLayout systemLayout = new HorizontalLayout();
    systemLayout.setCaption("JVM System streams:");
    form.addComponent(systemLayout);
    HorizontalLayout loggerLayout = new HorizontalLayout();
    loggerLayout.setCaption("Loggers:");
    form.addComponent(loggerLayout);

    final CheckBox systemOut = new CheckBox("out");
    systemOut.setValue(true);
    systemLayout.addComponent(systemOut);

    this.container = new BeanItemContainer<TableEntry>(TableEntry.class);
    filter = new TypeFilter();
    container.addContainerFilter(filter);

    systemOut.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) event.getProperty().getValue();
            container.removeAllContainerFilters();
            filter.setAcceptSystemOut(value);
            container.addContainerFilter(filter);
        }
    });

    CheckBox systemErr = new CheckBox("err");
    systemLayout.addComponent(systemErr);
    systemErr.setValue(true);
    systemErr.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) event.getProperty().getValue();
            container.removeAllContainerFilters();
            filter.setAcceptSystemErr(value);
            container.addContainerFilter(filter);
        }
    });

    CheckBox loggerInfo = new CheckBox("Info");
    loggerLayout.addComponent(loggerInfo);
    loggerInfo.setValue(true);
    loggerInfo.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) event.getProperty().getValue();
            container.removeAllContainerFilters();
            filter.setAcceptLoggerInfo(value);
            container.addContainerFilter(filter);
        }
    });

    CheckBox loggerWarning = new CheckBox("Warning");
    loggerLayout.addComponent(loggerWarning);
    loggerWarning.setValue(true);
    loggerWarning.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) event.getProperty().getValue();
            container.removeAllContainerFilters();
            filter.setAcceptLoggerWarning(value);
            container.addContainerFilter(filter);
        }
    });

    CheckBox loggerError = new CheckBox("Error");
    loggerLayout.addComponent(loggerError);
    loggerError.setValue(true);
    loggerError.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) event.getProperty().getValue();
            container.removeAllContainerFilters();
            filter.setAcceptLoggerError(value);
            container.addContainerFilter(filter);
        }
    });

    Button clearButton = new Button("clear");
    //horizontalLayout.addComponent(clearButton);
    clearButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            container.removeAllItems();

        }
    });

    this.table = new Table();
    table.setSizeFull();
    table.setImmediate(true);

    // Define the names and data types of columns.
    table.addContainerProperty("date", Date.class, null);
    table.addContainerProperty("type", String.class, null);
    table.addContainerProperty("caller", String.class, null);
    table.addContainerProperty("text", String.class, "empty");

    table.setContainerDataSource(container);
    table.addGeneratedColumn("text", new TextColumnGenerator());

    table.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
        @Override
        public String generateDescription(Component source, Object itemId, Object propertyId) {
            TableEntry tableEntry = (TableEntry) itemId;

            return simpleDateFormat.format(tableEntry.getDate()).concat(" : ").concat(tableEntry.getType())
                    .concat(" : ").concat(tableEntry.getCaller());

        }
    });

    table.setVisibleColumns(new Object[] { "text" });
    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
    table.setSortEnabled(true);
    addComponent(table);
    setExpandRatio(table, 1.5f);
}

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

FormLayout buildFormLayout() {
    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);//  w  ww . j ava 2 s . c  om

    LiquidationForm lf = rls.getRLById(getRequestId());

    controlNo = new TextField("Control No.");
    controlNo.setWidth("100%");
    controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    controlNo.setValue(String.valueOf(lf.getControlNo()));
    controlNo.setEnabled(false);
    f.addComponent(controlNo);

    dateOfActivity = new DateField("Date of Activity: ");
    dateOfActivity.setWidth("100%");
    dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
    dateOfActivity.setValue(lf.getDateOfActivity());
    dateOfActivity.setEnabled(false);
    f.addComponent(dateOfActivity);

    area = CommonComboBox.areas();
    area.setWidth("100%");
    area.setValue(lf.getAreaId());
    area.setEnabled(false);
    f.addComponent(area);

    activity = new TextField("Activity: ");
    activity.setWidth("100%");
    activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    activity.setValue(lf.getActivity());
    activity.setEnabled(false);
    f.addComponent(activity);

    venue = new TextField("Venue: ");
    venue.setWidth("100%");
    venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    venue.setValue(lf.getVenue());
    venue.setEnabled(false);
    f.addComponent(venue);

    requirements = new TextArea("Requirements: ");
    requirements.setWidth("100%");
    requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
    requirements.setValue(lf.getRequirements());
    requirements.setEnabled(false);
    f.addComponent(requirements);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");
    h1.setCaption("Request Lodging");
    h1.addStyleName("light");
    //        h1.setReadOnly(true);

    requestLodgingPax = new TextField();
    requestLodgingPax.setWidth("100%");
    requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingPax.addStyleName("align-right");
    requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax()));
    requestLodgingPax.setEnabled(false);
    h1.addComponent(requestLodgingPax);

    requestLodgingBudget = new TextField();
    requestLodgingBudget.setWidth("100%");
    requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingBudget.addStyleName("align-right");
    requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget()));
    requestLodgingBudget.setEnabled(false);
    h1.addComponent(requestLodgingBudget);

    requestLodgingAmount = new TextField();
    requestLodgingAmount.setWidth("100%");
    requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestLodgingAmount.addStyleName("align-right");
    requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount()));
    requestLodgingAmount.setEnabled(false);
    h1.addComponent(requestLodgingAmount);

    f.addComponent(h1);
    f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setWidth("100%");
    h2.setCaption("Request Meals");
    //        h2.setReadOnly(true);

    requestMealsPax = new TextField();
    requestMealsPax.setWidth("100%");
    requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsPax.addStyleName("align-right");
    requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax()));
    requestMealsPax.setEnabled(false);
    h2.addComponent(requestMealsPax);

    requestMealsBudget = new TextField();
    requestMealsBudget.setWidth("100%");
    requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsBudget.addStyleName("align-right");
    requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget()));
    requestMealsBudget.setEnabled(false);
    h2.addComponent(requestMealsBudget);

    requestMealsAmount = new TextField();
    requestMealsAmount.setWidth("100%");
    requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    requestMealsAmount.addStyleName("align-right");
    requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount()));
    requestMealsAmount.setEnabled(false);
    h2.addComponent(requestMealsAmount);

    f.addComponent(h2);
    f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT);

    HorizontalLayout h3 = new HorizontalLayout();
    h3.setWidth("100%");
    h3.setCaption("Liquidated Lodging");
    //        h3.setReadOnly(true);

    liquidateLodgingPax = new TextField();
    liquidateLodgingPax.setWidth("100%");
    liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingPax.addStyleName("align-right");
    liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax()));
    liquidateLodgingPax.setEnabled(false);
    h3.addComponent(liquidateLodgingPax);

    liquidateLodgingBudget = new TextField();
    liquidateLodgingBudget.setWidth("100%");
    liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingBudget.addStyleName("align-right");
    liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget()));
    liquidateLodgingBudget.setEnabled(false);
    h3.addComponent(liquidateLodgingBudget);

    liquidateLodgingAmount = new TextField();
    liquidateLodgingAmount.setWidth("100%");
    liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateLodgingAmount.addStyleName("align-right");
    liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount()));
    liquidateLodgingAmount.setEnabled(false);
    h3.addComponent(liquidateLodgingAmount);

    f.addComponent(h3);
    f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT);

    HorizontalLayout h4 = new HorizontalLayout();
    h4.setWidth("100%");
    h4.setCaption("Liquidated Meals");
    h4.setReadOnly(true);

    liquidateMealsPax = new TextField();
    liquidateMealsPax.setWidth("100%");
    liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsPax.addStyleName("align-right");
    liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax()));
    liquidateMealsPax.setEnabled(false);
    h4.addComponent(liquidateMealsPax);

    liquidateMealsBudget = new TextField();
    liquidateMealsBudget.setWidth("100%");
    liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsBudget.addStyleName("align-right");
    liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget()));
    liquidateMealsBudget.setEnabled(false);
    h4.addComponent(liquidateMealsBudget);

    liquidateMealsAmount = new TextField();
    liquidateMealsAmount.setWidth("100%");
    liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    liquidateMealsAmount.addStyleName("align-right");
    liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount()));
    liquidateMealsAmount.setEnabled(false);
    h4.addComponent(liquidateMealsAmount);

    f.addComponent(h4);
    f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT);

    reimbursement = new TextField("Reimbursement: ");
    reimbursement.setWidth("50%");
    reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    reimbursement.setValue(String.valueOf(lf.getReimbursedAmount()));
    reimbursement.setEnabled(false);
    f.addComponent(reimbursement);

    f.addStyleName("light");
    f.setReadOnly(true);

    return f;
}

From source file:com.save.reports.maintenance.MaintenanceReportUI.java

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);//from  ww w  . j  a v  a2 s .  c  o  m
    sub.center();

    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);
    f.setSpacing(true);

    CheckBox areaCheckBox = new CheckBox("Filter by Area");
    f.addComponent(areaCheckBox);

    CheckBox employeeCheckBox = new CheckBox("Filter by Employee");
    f.addComponent(employeeCheckBox);

    CheckBox amountCheckBox = new CheckBox("Filter by Amount");
    f.addComponent(amountCheckBox);

    CheckBox dateCheckBox = new CheckBox("Filter by Date");
    f.addComponent(dateCheckBox);

    ComboBox areaComboBox = CommonComboBox.areas();
    ComboBox employeeComboBox = CommonComboBox.getAllClients();

    areaComboBox.setEnabled(false);
    f.addComponent(areaComboBox);
    areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> {
        areaComboBox.setEnabled((boolean) event.getProperty().getValue());
        employeeComboBox.setEnabled(!(boolean) event.getProperty().getValue());
        employeeCheckBox.setValue(!(boolean) event.getProperty().getValue());
        isAreaSelect = (boolean) event.getProperty().getValue();
        isEmployeeSelect = !(boolean) event.getProperty().getValue();
    });

    employeeComboBox.setEnabled(false);
    f.addComponent(employeeComboBox);
    employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        employeeComboBox.setEnabled((boolean) e.getProperty().getValue());
        areaComboBox.setEnabled(!(boolean) e.getProperty().getValue());
        areaCheckBox.setValue(!(boolean) e.getProperty().getValue());
        isAreaSelect = !(boolean) e.getProperty().getValue();
        isEmployeeSelect = (boolean) e.getProperty().getValue();
    });

    TextField amountField = new CommonTextField("Amount: ");
    amountField.addStyleName("align-right");
    amountField.setEnabled(false);
    f.addComponent(amountField);
    amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        amountField.setEnabled((boolean) e.getProperty().getValue());
        isAmountSelect = (boolean) e.getProperty().getValue();
    });

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Date: ");
    h.setWidth("100%");
    h.setSpacing(true);

    DateField from = new DateField();
    from.setWidth("100%");
    from.setEnabled(false);
    h.addComponent(from);

    DateField to = new DateField();
    to.setWidth("100%");
    to.setEnabled(false);
    h.addComponent(to);

    dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        from.setEnabled((boolean) e.getProperty().getValue());
        to.setEnabled((boolean) e.getProperty().getValue());
        isDateSelect = (boolean) e.getProperty().getValue();
    });

    f.addComponent(h);

    Button generate = new CommonButton("Generate Report");
    generate.addClickListener((Button.ClickEvent e) -> {
        if (!isEmployeeSelect && !isAmountSelect && !isDateSelect) {
            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer());
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && !isAmountSelect && !isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new MaintenanceDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployeeSelect && !isAmountSelect && !isDateSelect) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployeeSelect && isAmountSelect && !isDateSelect) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployeeSelect && !isAmountSelect && isDateSelect) {
            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer(from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && isAmountSelect && !isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(
                    new MaintenanceDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployeeSelect && isAmountSelect && !isDateSelect) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(),
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && !isAmountSelect && isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer(
                    areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployeeSelect && !isAmountSelect && isDateSelect) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(),
                    from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployeeSelect && isAmountSelect && isDateSelect) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && isAmountSelect && isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new MaintenanceDataContainer(employeeComboBox.getItemCaption(employeeComboBox.getValue()),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim()),
                            from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployeeSelect && isAmountSelect && isDateSelect) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(),
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        sub.close();
    });
    f.addComponent(generate);

    sub.setContent(f);
    sub.getContent().setHeightUndefined();

    return sub;
}

From source file:com.save.reports.promodeals.PromoDealReportUI.java

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);//from   ww  w.  j a va2 s .  c  o  m
    sub.center();

    FormLayout f = new FormLayout();
    f.setWidth("100%");
    f.setMargin(true);
    f.setSpacing(true);

    CheckBox areaCheckBox = new CheckBox("Filter by Area");
    f.addComponent(areaCheckBox);

    CheckBox clientCheckBox = new CheckBox("Filter by Client");
    f.addComponent(clientCheckBox);

    CheckBox amountCheckBox = new CheckBox("Filter by Amount");
    f.addComponent(amountCheckBox);

    CheckBox dateCheckBox = new CheckBox("Filter by Date");
    f.addComponent(dateCheckBox);

    ComboBox areaComboBox = CommonComboBox.areas();
    ComboBox clientComboBox = CommonComboBox.getAllClients();

    areaComboBox.setEnabled(false);
    f.addComponent(areaComboBox);
    areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> {
        areaComboBox.setEnabled((boolean) event.getProperty().getValue());
        clientComboBox.setEnabled(!(boolean) event.getProperty().getValue());
        clientCheckBox.setValue(!(boolean) event.getProperty().getValue());
        isAreaSelect = (boolean) event.getProperty().getValue();
        isClientSelect = !(boolean) event.getProperty().getValue();
    });

    clientComboBox.setEnabled(false);
    f.addComponent(clientComboBox);
    clientCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        clientComboBox.setEnabled((boolean) e.getProperty().getValue());
        areaComboBox.setEnabled(!(boolean) e.getProperty().getValue());
        areaCheckBox.setValue(!(boolean) e.getProperty().getValue());
        isClientSelect = (boolean) e.getProperty().getValue();
        isAreaSelect = !(boolean) e.getProperty().getValue();
    });

    TextField amountField = new CommonTextField("Amount: ");
    amountField.addStyleName("align-right");
    amountField.setEnabled(false);
    f.addComponent(amountField);
    amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        amountField.setEnabled((boolean) e.getProperty().getValue());
        isAmountSelect = (boolean) e.getProperty().getValue();
    });

    HorizontalLayout h = new HorizontalLayout();
    h.setCaption("Date: ");
    h.setWidth("100%");
    h.setSpacing(true);

    DateField from = new DateField();
    from.setWidth("100%");
    from.setEnabled(false);
    h.addComponent(from);

    DateField to = new DateField();
    to.setWidth("100%");
    to.setEnabled(false);
    h.addComponent(to);

    dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        from.setEnabled((boolean) e.getProperty().getValue());
        to.setEnabled((boolean) e.getProperty().getValue());
        isDateSelect = (boolean) e.getProperty().getValue();
    });

    f.addComponent(h);

    Button generate = new CommonButton("Generate Report");
    generate.addClickListener((Button.ClickEvent e) -> {
        if (!isClientSelect && !isAmountSelect && !isDateSelect) {
            promoDealGrid.setContainerDataSource(new PromoDealDataContainer());
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && !isAmountSelect && !isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(
                    new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && !isAmountSelect && !isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (!isClientSelect && isAmountSelect && !isDateSelect) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (!isClientSelect && !isAmountSelect && isDateSelect) {
            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && isAmountSelect && !isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            promoDealGrid.setContainerDataSource(
                    new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && isAmountSelect && !isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(),
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && !isAmountSelect && isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(
                    areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && !isAmountSelect && isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(),
                    from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (!isClientSelect && isAmountSelect && isDateSelect) {
            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isAreaSelect && isAmountSelect && isDateSelect) {
            if (areaComboBox.getValue() == null) {
                Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(
                    new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim()),
                            from.getValue(), to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        if (isClientSelect && isAmountSelect && isDateSelect) {
            if (clientComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) {
                Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) {
                    Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE);
                    return;
                }
            }

            if (from.getValue() == null) {
                Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            if (to.getValue() == null) {
                Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(),
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            promoDealGrid.setFrozenColumnCount(2);
        }

        sub.close();
    });
    f.addComponent(generate);

    sub.setContent(f);
    sub.getContent().setHeightUndefined();

    return sub;
}