Example usage for com.vaadin.ui DateField DateField

List of usage examples for com.vaadin.ui DateField DateField

Introduction

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

Prototype

public DateField() 

Source Link

Document

Constructs an empty DateField with no caption.

Usage

From source file:com.jorambarrez.PropertyPanel.java

License:Apache License

public void showNodeProperties(Node node) {
    currentNode = node;/*from w  w w  . j  a va 2 s .com*/

    title.setValue(node.getText());
    title.setContentMode(Label.CONTENT_DEFAULT);

    // Demo
    propertyLayout.removeAllComponents();
    Label assigneeLabel = new Label("Assignee");
    assigneeLabel.addStyleName(STYLE_BOLD);
    propertyLayout.addComponent(assigneeLabel);
    TextField assigneeTextField = new TextField();
    assigneeTextField.setValue(node.getProperty("Assignee"));
    propertyLayout.addComponent(assigneeTextField);

    Label deadlineLabel = new Label("Deadline");
    deadlineLabel.addStyleName(STYLE_BOLD);
    propertyLayout.addComponent(deadlineLabel);
    DateField deadlineField = new DateField();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    try {
        deadlineField.setValue(dateFormat.parseObject(node.getProperty("Deadline")));
        propertyLayout.addComponent(deadlineField);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.klwork.explorer.ui.task.DueDateComponent.java

License:Apache License

protected void initDueDateField() {
    dueDateField = new DateField();
    if (task.getDueDate() != null) {
        dueDateField.setValue(task.getDueDate());
    } else {//from   ww w  .j av  a 2  s  .  c o m
        dueDateField.setValue(new Date());
    }
    dueDateField.setWidth(125, UNITS_PIXELS);
    dueDateField.setResolution(DateField.RESOLUTION_DAY);
    dueDateField.setImmediate(true);
}

From source file:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void initAboutSection() {
    // Header//w ww. java  2 s . c  om
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth(100, Unit.PERCENTAGE);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);

    Label aboutLabel = createProfileHeader(i18nManager.getMessage(Messages.PROFILE_ABOUT));
    header.addComponent(aboutLabel);
    header.setExpandRatio(aboutLabel, 1.0f);

    // only show edit/save buttons if current user matches
    if (isCurrentLoggedInUser) {
        Button actionButton = null;
        if (!editable) {
            actionButton = initEditProfileButton();
        } else {
            actionButton = initSaveProfileButton();
        }
        header.addComponent(actionButton);
        header.setComponentAlignment(actionButton, Alignment.MIDDLE_RIGHT);
    }

    // 'About' fields
    GridLayout aboutLayout = createInfoSectionLayout(2, 4);

    // Name
    if (!editable && (isDefined(user.getFirstName()) || isDefined(user.getLastName()))) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_NAME),
                user.getFirstName() + " " + user.getLastName());
    } else if (editable) {
        firstNameField = new TextField();
        firstNameField.focus();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_FIRST_NAME), firstNameField,
                user.getFirstName());
        lastNameField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LAST_NAME), lastNameField,
                user.getLastName());
    }

    // Job title
    if (!editable && isDefined(jobTitle)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitle);
    } else if (editable) {
        jobTitleField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_JOBTITLE), jobTitleField,
                jobTitle);
    }

    // Birthdate
    if (!editable && isDefined(birthDate)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDate);
    } else if (editable) {
        birthDateField = new DateField();
        birthDateField.setDateFormat(Constants.DEFAULT_DATE_FORMAT);
        birthDateField.setResolution(DateField.RESOLUTION_DAY);
        try {
            birthDateField.setValue(new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT).parse(birthDate));
        } catch (Exception e) {
        } // do nothing
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_BIRTHDATE), birthDateField,
                null);
    }

    // Location
    if (!editable && isDefined(location)) {
        addProfileEntry(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), location);
    } else if (editable) {
        locationField = new TextField();
        addProfileInputField(aboutLayout, i18nManager.getMessage(Messages.PROFILE_LOCATION), locationField,
                location);
    }
}

From source file:com.mcparland.john.vaadin_cookbook.JodaFieldFactory.java

License:Apache License

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//w ww  .ja v  a  2  s  .co m
public <T extends Field> T createField(Class<?> type, Class<T> fieldType) {
    T field;
    if (type.isAssignableFrom(DateTime.class)) {
        DateField dateField = new DateField();
        dateField.setConverter(new DateTimeConverter());
        field = (T) dateField;
    } else {
        field = super.createField(type, fieldType);
    }
    return field;
}

From source file:com.moorevaadin.vaadin7.beanvalidation.EnhancedFieldGroupFieldFactory.java

License:Apache License

@SuppressWarnings({ "rawtypes", "unchecked" })
protected <T extends Field> T createDateField() {

    DateField field = new DateField();

    field.setImmediate(true);//from ww  w .  java 2s  . co  m

    return (T) field;
}

From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.promote.ArticlePromotionViewImpl.java

License:Open Source License

private void createAlert() {
    VerticalLayout alertTextLayout = new VerticalLayout();
    alertTextLayout.setSpacing(true);/*  ww w  .j  a  v  a 2s. c  o m*/
    alertTextLayout.setCaption("Alert Text");

    MagnoliaRichTextField textField = (MagnoliaRichTextField) listener.createRichTextField();
    textField.setSizeFull();

    HorizontalLayout periodLayout = new HorizontalLayout();
    periodLayout.setSpacing(true);
    // periodLayout.setWidth("100%");
    DateField startDate = new DateField();
    // startDate.setWidth("100%");
    DateField endDate = new DateField();
    // endDate.setWidth("100%");

    periodLayout.addComponent(new Label("START"));
    periodLayout.addComponent(startDate);
    periodLayout.addComponent(new Label("END"));
    periodLayout.addComponent(endDate);

    alertTextLayout.addComponent(textField);
    alertTextLayout.addComponent(periodLayout);

    HorizontalLayout alertLayout = new HorizontalLayout();
    alertLayout.setSpacing(true);
    alertLayout.setWidth("100%");
    alertLayout.addComponent(alertTextLayout);

    final Label alertPreview = new Label("", ContentMode.HTML);
    alertPreview.setCaption("Alert Preview");
    alertPreview.addStyleName("preview-label");
    textField.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            alertPreview.setValue(String.valueOf(event.getProperty().getValue()));
        }
    });
    alertPreview.setSizeUndefined();
    alertLayout.addComponent(alertPreview);
    alert.setContent(alertLayout);

    textField.setValue(
            "<b>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</b>");
}

From source file:com.peter.vaadin.components.vaadin.chart.timeline.MyTimelineDemo.java

public MyTimelineDemo() {

    timeline = new Timeline("My graph");
    timeline.setSizeFull();/*  w  w w  .ja  v a 2  s.  c  om*/
    timeline.setVerticalAxisRange(-1f, 2f);
    timeline.setZoomLevelsVisible(false);
    timeline.setDateSelectVisible(false);

    // Create the data sources
    firstDataSource = createGraphDataSource();
    datasourcesList.add(firstDataSource);
    final Container.Indexed markerDataSource = createMarkerDataSource();
    final Container.Indexed eventDataSource = createEventDataSource();

    // Add our data sources
    timeline.addGraphDataSource(firstDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.VALUE);

    // Markers and events
    timeline.setMarkerDataSource(markerDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION,
            Timeline.PropertyId.VALUE);
    timeline.setEventDataSource(eventDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION);

    // Set the caption of the graph
    timeline.setGraphLegend(firstDataSource, "Our cool graph");

    // Set the color of the graph
    timeline.setGraphOutlineColor(firstDataSource, SolidColor.RED);

    // Set the fill color of the graph
    timeline.setGraphFillColor(firstDataSource, new SolidColor(255, 0, 0, 128));

    // Set the width of the graph
    timeline.setGraphOutlineThickness(1);

    // Set the color of the browser graph
    timeline.setBrowserOutlineColor(firstDataSource, SolidColor.BLACK);

    // Set the fill color of the graph
    timeline.setBrowserFillColor(firstDataSource, new SolidColor(0, 0, 0, 128));

    // Add some zoom levels
    timeline.addZoomLevel("Day", 86400000L);
    timeline.addZoomLevel("Week", 7 * 86400000L);
    timeline.addZoomLevel("Month", 2629743830L);

    // Listen to click events from events
    timeline.addListener(new Timeline.EventClickListener() {
        @Override
        public void eventClick(EventButtonClickEvent event) {
            Item item = eventDataSource.getItem(event.getItemIds().iterator().next());
            Date sunday = (Date) item.getItemProperty(Timeline.PropertyId.TIMESTAMP).getValue();
            SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy");

            Notification.show(formatter.format(sunday));
        }
    });

    addComponent(timeline);

    HorizontalLayout addDateForm = new HorizontalLayout();
    final DateField dateField = new DateField();
    dateField.setImmediate(true);
    addDateForm.addComponent(dateField);
    final TextField valueField = new TextField();
    valueField.setImmediate(true);
    addDateForm.addComponent(valueField);
    Button addBtn = new Button("Add", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            java.util.Date d = dateField.getValue();
            Date date = new Date(d.getTime());
            float value = Float.valueOf(valueField.getValue().toString());

            // Create a point in time
            Item item = firstDataSource.addItem(date.getTime());

            if (item == null) {
                item = firstDataSource.getItem(date.getTime());
            }

            // Set the timestamp property
            item.getItemProperty(Timeline.PropertyId.TIMESTAMP).setValue(date);

            // Set the value property
            item.getItemProperty(Timeline.PropertyId.VALUE).setValue(value);
        }
    });
    addDateForm.addComponent(addBtn);
    addComponent(addDateForm);

    Button addGraphDataSource = new Button("Add graph data source", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Container.Indexed ds = createGraphDataSource();
            datasourcesList.add(ds);
            timeline.addGraphDataSource(ds);
            timeline.setGraphFillColor(ds, SolidColor.BLACK);
        }
    });
    addComponent(addGraphDataSource);

    Button removeGraphDataSource = new Button("Remove graph data source", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (datasourcesList.size() > 1) {
                Container.Indexed ds = datasourcesList.get(datasourcesList.size() - 1);
                timeline.removeGraphDataSource(ds);
                datasourcesList.remove(ds);
            }
        }
    });
    addComponent(removeGraphDataSource);

    CheckBox stacked = new CheckBox("Stacked graphs", false);
    stacked.setImmediate(true);
    stacked.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            timeline.setGraphStacking((Boolean) event.getProperty().getValue());
        }
    });
    addComponent(stacked);

    CheckBox lock = new CheckBox("Selection lock", true);
    lock.setImmediate(true);
    lock.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            timeline.setBrowserSelectionLock((Boolean) event.getProperty().getValue());
        }
    });
    addComponent(lock);

    setExpandRatio(timeline, 1);
}

From source file:com.rdonasco.security.user.views.UserEditorView.java

License:Apache License

public UserEditorView() {

    this.retypedPasswordField = new PasswordField();
    this.passwordField = new PasswordField();
    this.logonIdField = new TextField();
    this.registrationTokenField = new TextField();
    this.registrationTokenExpirationField = new DateField();

    this.userDetailPanel = new Panel();
    this.otherDetailTab = new TabSheet();
    this.capabilitiesLayout = new HorizontalLayout();
    this.rolesLayout = new HorizontalLayout();
    this.groupsLayout = new HorizontalLayout();
    this.buttonsLayout = new HorizontalLayout();

    this.cancelButton = new Button();
    this.saveButton = new Button();
    this.editButton = new Button();
}

From source file:com.rex.components.valo.Tables.java

License:Apache License

static void configure(Table table, Grid grid, boolean footer, boolean sized, boolean expandRatios,
        boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers,
        boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon,
        boolean componentsInRows) {

    table.setSelectable(true);/* w  w w  . j  a  v  a  2s . com*/
    table.setMultiSelect(true);
    grid.setSelectionMode(SelectionMode.MULTI);

    table.setSortEnabled(true);
    for (Column c : grid.getColumns()) {
        if (!c.getPropertyId().equals("icon")) {
            c.setSortable(true);
        }
        c.setHidable(true);
    }

    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    grid.setColumnReorderingAllowed(true);

    table.setPageLength(6);
    grid.setHeightByRows(6);

    table.addActionHandler(ReportEngineUI.getActionHandler());
    table.setDragMode(TableDragMode.MULTIROW);
    table.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });
    table.setColumnAlignment(ReportEngineUI.DESCRIPTION_PROPERTY, Align.RIGHT);
    table.setColumnAlignment(ReportEngineUI.INDEX_PROPERTY, Align.CENTER);

    table.removeContainerProperty("textfield");
    table.removeGeneratedColumn("textfield");
    table.removeContainerProperty("button");
    table.removeGeneratedColumn("button");
    table.removeContainerProperty("label");
    table.removeGeneratedColumn("label");
    table.removeContainerProperty("checkbox");
    table.removeGeneratedColumn("checkbox");
    table.removeContainerProperty("datefield");
    table.removeGeneratedColumn("datefield");
    table.removeContainerProperty("combobox");
    table.removeGeneratedColumn("combobox");
    table.removeContainerProperty("optiongroup");
    table.removeGeneratedColumn("optiongroup");
    table.removeContainerProperty("slider");
    table.removeGeneratedColumn("slider");
    table.removeContainerProperty("progress");
    table.removeGeneratedColumn("progress");

    if (componentsInRows) {
        table.addContainerProperty("textfield", TextField.class, null);
        table.addGeneratedColumn("textfield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                TextField tf = new TextField();
                tf.setInputPrompt("Type here");
                // tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("datefield", TextField.class, null);
        table.addGeneratedColumn("datefield", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                DateField tf = new DateField();
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("combobox", TextField.class, null);
        table.addGeneratedColumn("combobox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ComboBox tf = new ComboBox();
                tf.setInputPrompt("Select");
                tf.addStyleName("compact");
                if ((Integer) itemId % 2 == 0) {
                    tf.addStyleName("borderless");
                }
                return tf;
            }
        });

        table.addContainerProperty("button", Button.class, null);
        table.addGeneratedColumn("button", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Button b = new Button("Button");
                b.addStyleName("small");
                return b;
            }
        });

        table.addContainerProperty("label", TextField.class, null);
        table.addGeneratedColumn("label", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Label label = new Label("Label component");
                label.setSizeUndefined();
                label.addStyleName("bold");
                return label;
            }
        });

        table.addContainerProperty("checkbox", TextField.class, null);
        table.addGeneratedColumn("checkbox", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                CheckBox cb = new CheckBox(null, true);
                return cb;
            }
        });

        table.addContainerProperty("optiongroup", TextField.class, null);
        table.addGeneratedColumn("optiongroup", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                OptionGroup op = new OptionGroup();
                op.addItem("Male");
                op.addItem("Female");
                op.addStyleName("horizontal");
                return op;
            }
        });

        table.addContainerProperty("slider", TextField.class, null);
        table.addGeneratedColumn("slider", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Slider s = new Slider();
                s.setValue(30.0);
                return s;
            }
        });

        table.addContainerProperty("progress", TextField.class, null);
        table.addGeneratedColumn("progress", new ColumnGenerator() {
            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                ProgressBar bar = new ProgressBar();
                bar.setValue(0.7f);
                return bar;
            }
        });
    }
    table.setFooterVisible(footer);
    if (footer) {
        table.setColumnFooter(ReportEngineUI.CAPTION_PROPERTY, "caption");
        table.setColumnFooter(ReportEngineUI.DESCRIPTION_PROPERTY, "description");
        table.setColumnFooter(ReportEngineUI.ICON_PROPERTY, "icon");
        table.setColumnFooter(ReportEngineUI.INDEX_PROPERTY, "index");
    }

    if (sized) {
        table.setWidth("400px");
        grid.setWidth("400px");
        table.setHeight("300px");
        grid.setHeight("300px");
    } else {
        table.setSizeUndefined();
        grid.setSizeUndefined();
    }

    if (componentsInRows) {
        table.setWidth("100%");
    } else {
        table.setWidth(null);
    }

    if (expandRatios) {
        if (!sized) {
            table.setWidth("100%");
        }
    }
    table.setColumnExpandRatio(ReportEngineUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0);
    table.setColumnExpandRatio(ReportEngineUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0);

    if (!stripes) {
        table.addStyleName("no-stripes");
    } else {
        table.removeStyleName("no-stripes");
    }

    if (!verticalLines) {
        table.addStyleName("no-vertical-lines");
    } else {
        table.removeStyleName("no-vertical-lines");
    }

    if (!horizontalLines) {
        table.addStyleName("no-horizontal-lines");
    } else {
        table.removeStyleName("no-horizontal-lines");
    }

    if (borderless) {
        table.addStyleName("borderless");
    } else {
        table.removeStyleName("borderless");
    }

    if (!headers) {
        table.addStyleName("no-header");
    } else {
        table.removeStyleName("no-header");
    }

    if (compact) {
        table.addStyleName("compact");
    } else {
        table.removeStyleName("compact");
    }

    if (small) {
        table.addStyleName("small");
    } else {
        table.removeStyleName("small");
    }

    if (!rowIndex && !rowCaption && rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.HIDDEN);
    }

    if (rowIndex) {
        table.setRowHeaderMode(RowHeaderMode.INDEX);
    }

    if (rowCaption) {
        table.setRowHeaderMode(RowHeaderMode.PROPERTY);
        table.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    } else {
        table.setItemCaptionPropertyId(null);
    }

    if (rowIcon) {
        table.setRowHeaderMode(RowHeaderMode.ICON_ONLY);
        table.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    } else {
        table.setItemIconPropertyId(null);
    }
}

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   w  ww  .  j av a  2s.co  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;
}