Example usage for com.vaadin.ui HorizontalLayout setSpacing

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

Introduction

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

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

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

License:Apache License

@Override
public void initWidget() throws WidgetInitalizeException {
    getAddUserButton().setCaption(I18NResource.localize("Add new user"));
    getAddUserButton().setIcon(new ThemeResource(SecurityDefaultTheme.ICON_16x16_ADD));
    getAddUserButton().setWidth(100, UNITS_PERCENTAGE);
    getAddUserButton().addStyleName(SecurityDefaultTheme.CSS_SMALL);
    getRefreshButton().setCaption("Refresh");
    getRefreshButton().setIcon(new ThemeResource(SecurityDefaultTheme.ICON_16x16_REFRESH));
    getRefreshButton().addStyleName(SecurityDefaultTheme.CSS_SMALL);
    VerticalLayout content = ((VerticalLayout) getContent());
    content.setMargin(true);//from w  w  w  . j av a2 s  .c o  m
    content.setHeight(600, UNITS_PIXELS);
    content.removeAllComponents();
    if (null != getDataViewListTable()) {
        getDataViewListTable().setSizeFull();
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setSpacing(true);
        buttonLayout.setWidth(100F, UNITS_PERCENTAGE);
        buttonLayout.addComponent(getAddUserButton());
        buttonLayout.addComponent(getRefreshButton());
        buttonLayout.setExpandRatio(getAddUserButton(), 1);
        content.addComponent(buttonLayout);
        content.addComponent(getDataViewListTable());
        content.setExpandRatio(getDataViewListTable(), 1);
        content.setSpacing(true);
    }
}

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

License:Apache License

public ComboBoxes() {
    setMargin(true);//from  w  w  w.  ja  va 2s .c o  m

    Label h1 = new Label("Combo Boxes");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    ComboBox combo = new ComboBox("Normal");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.setItemIcon(combo.getItemIds().iterator().next(), new ThemeResource("../runo/icons/16/document.png"));
    row.addComponent(combo);

    CssLayout group = new CssLayout();
    group.setCaption("Grouped with a Button");
    group.addStyleName("v-component-group");
    row.addComponent(group);

    combo = new ComboBox();
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setNullSelectionAllowed(false);
    combo.select(combo.getItemIds().iterator().next());
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.setWidth("240px");
    group.addComponent(combo);
    Button today = new Button("Do It");
    group.addComponent(today);

    combo = new ComboBox("Explicit size");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setWidth("260px");
    combo.setHeight("60px");
    row.addComponent(combo);

    combo = new ComboBox("No text input allowed");
    combo.setInputPrompt("You can click here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setTextInputAllowed(false);
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    row.addComponent(combo);

    combo = new ComboBox("Error");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    combo.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(combo);

    combo = new ComboBox("Error, borderless");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setNullSelectionAllowed(false);
    combo.select("Option One");
    combo.setComponentError(new UserError("Fix it, now!"));
    combo.addStyleName("borderless");
    row.addComponent(combo);

    combo = new ComboBox("Disabled");
    combo.setInputPrompt("You can't type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.setEnabled(false);
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("color1");
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("color2");
    row.addComponent(combo);

    combo = new ComboBox("Custom color");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("color3");
    row.addComponent(combo);

    combo = new ComboBox("Small");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("small");
    row.addComponent(combo);

    combo = new ComboBox("Large");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("large");
    row.addComponent(combo);

    combo = new ComboBox("Borderless");
    combo.setInputPrompt("You can type here");
    combo.addItem("Option One");
    combo.addItem("Option Two");
    combo.addItem("Option Three");
    combo.addStyleName("borderless");
    row.addComponent(combo);

    combo = new ComboBox("Tiny");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("tiny");
    row.addComponent(combo);

    combo = new ComboBox("Huge");
    combo.setInputPrompt("You can type here");
    combo.setContainerDataSource(ReportEngineUI.generateContainer(200, false));
    combo.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    combo.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    combo.addStyleName("huge");
    row.addComponent(combo);
}

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

License:Apache License

public Sliders() {
    setMargin(true);/*  w w w .  j  a v  a 2 s.c  om*/

    Label h1 = new Label("Sliders");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Slider slider = new Slider("Horizontal");
    slider.setValue(50.0);
    row.addComponent(slider);

    slider = new Slider("Horizontal, sized");
    slider.setValue(50.0);
    slider.setWidth("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color1");
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color2");
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("color3");
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setWidth("200px");
    slider.addStyleName("no-indicator");
    row.addComponent(slider);

    slider = new Slider("With ticks (not in IE8 & IE9)");
    slider.setValue(3.0);
    slider.setWidth("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    row.addComponent(slider);

    slider = new Slider("Toggle imitation");
    slider.setWidth("50px");
    slider.setResolution(0);
    slider.setMin(0);
    slider.setMax(1);
    row.addComponent(slider);

    slider = new Slider("Vertical");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Vertical, sized");
    slider.setValue(50.0);
    slider.setOrientation(SliderOrientation.VERTICAL);
    slider.setHeight("200px");
    row.addComponent(slider);

    slider = new Slider("Custom handle");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color1");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom track");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color2");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Custom indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("color3");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("No indicator");
    slider.setValue(50.0);
    slider.setHeight("200px");
    slider.addStyleName("no-indicator");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("With ticks");
    slider.setValue(3.0);
    slider.setHeight("200px");
    slider.setMax(4);
    slider.addStyleName("ticks");
    slider.setOrientation(SliderOrientation.VERTICAL);
    row.addComponent(slider);

    slider = new Slider("Disabled");
    slider.setValue(50.0);
    slider.setEnabled(false);
    row.addComponent(slider);

    h1 = new Label("Progress Bars");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    pb = new ProgressBar();
    pb.setCaption("Default");
    pb.setWidth("300px");
    // pb.setValue(0.6f);
    row.addComponent(pb);

    pb2 = new ProgressBar();
    pb2.setCaption("Point style");
    pb2.setWidth("300px");
    pb2.addStyleName("point");
    // pb2.setValue(0.6f);
    row.addComponent(pb2);

    if (!ReportEngineUI.isTestMode()) {
        ProgressBar pb3 = new ProgressBar();
        pb3.setIndeterminate(true);
        pb3.setCaption("Indeterminate");
        row.addComponent(pb3);
    }
}

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

License:Apache License

public Tables() {
    setMargin(true);/*ww  w  .  ja  va  2 s . co m*/
    setSpacing(true);

    Label h1 = new Label("Tables & Grids");
    h1.addStyleName("h1");
    addComponent(h1);

    Label disclaimer = new Label(
            "<p>Note that most of the toggles only affect the Table component. The Grid component supports footers, expand ratios, row indexes/captions/icons and cell renderers, but those have not been implemented here.</p>",
            ContentMode.HTML);
    disclaimer.setCaption("Toggle features/styles");
    addComponent(disclaimer);
    disclaimer.addStyleName(ValoTheme.LABEL_SMALL);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.addStyleName("wrapping");
    wrap.setSpacing(true);
    addComponent(wrap);

    wrap.addComponents(hierarchical, footer, sized, expandRatios, stripes, verticalLines, horizontalLines,
            borderless, headers, compact, small, rowIndex, rowCaption, rowIcon, componentsInCells);

    ValueChangeListener update = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            if (table == null) {
                table = new Table("Table component");
                table.setContainerDataSource(normalContainer);
                addComponent(table);
            }
            if (grid == null) {
                grid = new Grid("Grid component");
                grid.setContainerDataSource(gridContainer);
                addComponent(grid);
            }
            if (hierarchical.getValue() && table instanceof Table) {
                removeComponent(table);
                table = new TreeTable();
                table.setContainerDataSource(hierarchicalContainer);
                addComponent(table);
                removeComponent(grid);
            } else if (!hierarchical.getValue() && table instanceof TreeTable) {
                removeComponent(table);
                table = new Table();
                table.setContainerDataSource(normalContainer);
                addComponent(table);
                addComponent(grid);
            }

            configure(table, grid, footer.getValue(), sized.getValue(), expandRatios.getValue(),
                    stripes.getValue(), verticalLines.getValue(), horizontalLines.getValue(),
                    borderless.getValue(), headers.getValue(), compact.getValue(), small.getValue(),
                    rowIndex.getValue(), rowCaption.getValue(), rowIcon.getValue(),
                    componentsInCells.getValue());
        }
    };

    hierarchical.addValueChangeListener(update);
    footer.addValueChangeListener(update);
    sized.addValueChangeListener(update);
    expandRatios.addValueChangeListener(update);
    stripes.addValueChangeListener(update);
    verticalLines.addValueChangeListener(update);
    horizontalLines.addValueChangeListener(update);
    borderless.addValueChangeListener(update);
    headers.addValueChangeListener(update);
    compact.addValueChangeListener(update);
    small.addValueChangeListener(update);
    rowIndex.addValueChangeListener(update);
    rowCaption.addValueChangeListener(update);
    rowIcon.addValueChangeListener(update);
    componentsInCells.addValueChangeListener(update);

    footer.setValue(false);

}

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

License:Apache License

public Trees() {
    setMargin(true);/*from  w  w w. j  ava 2  s  .  c o  m*/

    Label h1 = new Label("Trees");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    Tree tree = new Tree();
    tree.setSelectable(true);
    tree.setMultiSelect(true);
    Container generateContainer = ReportEngineUI.generateContainer(10, true);
    tree.setContainerDataSource(generateContainer);
    tree.setDragMode(TreeDragMode.NODE);
    row.addComponent(tree);
    tree.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY);
    tree.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY);
    tree.expandItem(generateContainer.getItemIds().iterator().next());

    tree.setDropHandler(new DropHandler() {
        @Override
        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        @Override
        public void drop(DragAndDropEvent event) {
            Notification.show(event.getTransferable().toString());
        }
    });

    // Add actions (context menu)
    tree.addActionHandler(ReportEngineUI.getActionHandler());
}

From source file:com.save.bi.MaintenanceSummaryLineChart.java

public MaintenanceSummaryLineChart() {
    setSizeFull();//from   w w w .  j  av  a2  s.c  o m

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

    ComboBox area = CommonComboBox.areas();
    area.setCaption(null);
    area.setInputPrompt("Select an Area.. ");
    area.setWidth("100px");
    h.addComponent(area);

    ComboBox year = CommonComboBox.yearList();
    year.setInputPrompt("Select a Year.. ");
    year.setWidth("100px");
    h.addComponent(year);

    Button button = new CommonButton("Generate Line Chart");
    button.setWidthUndefined();
    h.addComponent(button);
    h.setExpandRatio(button, 3);

    addComponent(h);
}

From source file:com.save.client.ClientInformationForm.java

FormLayout clientInformationForm() {
    form.setMargin(false);//from  w  w w .  j a v a  2  s  . com
    form.setWidth("100%");
    form.addStyleName("light");
    form.setReadOnly(readOnly);
    form.setImmediate(true);

    editClientBtn = new Button(EDIT_BUTTON_CAPTION, editBtnListener);
    editClientBtn.setEnabled(false);

    cancelBtn = new Button(CANCEL_BUTTON_CAPTION, cancelBtnListener);
    cancelBtn.setEnabled(false);

    newClientBtn = new Button(NEW_BUTTON_CAPTION, newBtnListener);

    client = new TextField("Name: ");
    client.setWidth("50%");
    client.setRequired(true);
    client.setRequiredError("Required Name!");
    form.addComponent(client);

    province.setInputPrompt("Select Province..");
    province.setRequired(true);
    province.setRequiredError("Required Province!");

    city.setInputPrompt("Select City..");
    city.setRequired(true);
    city.setRequiredError("Required City/Town!");

    province.addValueChangeListener(new ProvincePropertyChangeListener(city));
    province.setWidth("100%");
    form.addComponent(province);

    city.setWidth("100%");
    form.addComponent(city);

    address = new TextField("Street/Brgy: ");
    address.setWidth("50%");
    address.setRequired(true);
    address.setRequiredError("Required Street/Brgy!");
    form.addComponent(address);

    landline = new TextField("Landline No: ");
    landline.setWidth("50%");
    landline.setRequired(true);
    landline.setRequiredError("Required Contact No!");
    form.addComponent(landline);

    mobile = new TextField("Mobile No: ");
    mobile.setWidth("50%");
    mobile.setRequired(true);
    mobile.setRequiredError("Required Contact No!");
    form.addComponent(mobile);

    setAsDistributor = new OptionGroup("Distributor");
    setAsDistributor.addItems("Yes", "No");
    setAsDistributor.addStyleName("horizontal");
    setAsDistributor.setRequired(readOnly);
    setAsDistributor.setRequiredError("Set option(Y/N) As Distrbutor!");
    setAsDistributor.addValueChangeListener(distributorCheckboxListener);
    form.addComponent(setAsDistributor);

    clientType.setWidth("90%");
    clientType.setRequired(true);
    clientType.setRequiredError("Required Client Type!");
    clientType.setVisible(false);
    form.addComponent(clientType);

    if (getClientId() != 0) {
        editClientBtn.setEnabled(true);
        Client c = clientService.getClientDataById(getClientId());

        client.setValue(c.getClientName().toUpperCase());
        province.setValue(c.getProvince().getProvinceId());
        city.setValue(c.getCityId());
        address.setValue(c.getStreet());
        landline.setValue(c.getLandline());
        mobile.setValue(c.getMobile());

        if (c.getAsDistributor() == 0) {
            setAsDistributor.setValue("No");
            clientType.setVisible(true);
            clientType.setValue(c.getClientType());
        } else {
            setAsDistributor.setValue("Yes");
            clientType.setVisible(false);
            clientType.setValue("distributor");
        }
    }

    form.setReadOnly(true);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, true, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(editClientBtn);
    footer.addComponent(cancelBtn);
    footer.addComponent(newClientBtn);

    removeBtn = new Button("Remove Account");
    removeBtn.addClickListener(removeBtnListener);
    form.addComponent(removeBtn);

    disableFields(false);
    return form;
}

From source file:com.save.employee.PersonalInformationForm.java

public PersonalInformationForm(HorizontalSplitPanel hsplit, int employeeId, Grid grid, Object itemId) {
    this.hsplit = hsplit;
    this.employeeId = employeeId;
    this.grid = grid;
    this.itemId = itemId;

    setMargin(new MarginInfo(true, true, false, false));
    setWidth("80%");
    addStyleName("light");

    editBtn = new Button(BUTTON_CAPTION, editBtnListener);
    editBtn.setEnabled(false);/*from w  w w .jav a 2  s . com*/

    cancelBtn = new Button("CANCEL");
    cancelBtn.setEnabled(false);

    newEntryBtn = new Button("NEW ACCOUNT");

    employeeNoField = new TextField("Employee ID: ");
    employeeNoField.setWidth("50%");
    employeeNoField.setRequired(true);
    employeeNoField.setRequiredError("Required Employee ID!");
    addComponent(employeeNoField);

    firstname = new TextField("Firstname: ");
    firstname.setWidth("50%");
    firstname.setRequired(true);
    firstname.setRequiredError("Required Firstname!");
    addComponent(firstname);

    middlename = new TextField("Middlename: ");
    middlename.setWidth("50%");
    middlename.setRequired(true);
    middlename.setRequiredError("Required Middlename!");
    addComponent(middlename);

    lastname = new TextField("Lastname: ");
    lastname.setWidth("50%");
    lastname.setRequired(true);
    lastname.setRequiredError("Required Lastname!");
    addComponent(lastname);

    gender = new OptionGroup("Gender: ");
    gender.addItem("Female");
    gender.addItem("Male");
    gender.addStyleName("horizontal");
    addComponent(gender);

    status = new ComboBox("Status: ");
    status.setNullSelectionAllowed(false);
    status.addItem("Single");
    status.addItem("Married");
    status.addItem("Widow");
    status.addItem("Separated");
    addComponent(status);

    birthday = new DateField("Birthday");
    birthday.setValue(new Date());
    addComponent(birthday);

    if (getEmployeeId() != 0) {
        Employee e = es.getEmployeesPersonalDataById(getEmployeeId());
        employeeNoField.setValue(e.getEmployeeNo());
        firstname.setValue(e.getFirstname());
        middlename.setValue(e.getMiddlename());
        lastname.setValue(e.getLastname());
        gender.setValue(CommonUtilities.capitalizeFirstLetter(e.getGender()));
        status.setValue(e.getPersonalStatus());
        birthday.setValue((e.getDob() == null) ? new Date() : e.getDob());
        editBtn.setEnabled(true);
        cancelBtn.setEnabled(true);
    }

    setReadOnly(true);

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    addComponent(footer);
    footer.addComponent(editBtn);
    footer.addComponent(cancelBtn);
    footer.addComponent(newEntryBtn);

    removeBtn = new Button("REMOVE ACCOUNT");
    removeBtn.addClickListener(removeBtnListener);
    addComponent(removeBtn);

    cancelBtn.addClickListener((Button.ClickEvent event) -> {
        setReadOnly(false);
        addStyleName("light");
        editBtn.setCaption(BUTTON_CAPTION);
        editBtn.removeStyleName("primary");
        setReadOnly(true);
        disableFields(false);
        newEntryBtn.setEnabled(true);
    });

    newEntryBtn.addClickListener((Button.ClickEvent event) -> {
        setReadOnly(true);
        addStyleName("light");
        editBtn.setCaption(BUTTON_CAPTION);
        editBtn.removeStyleName("primary");

        Window sub = new CreateNewAccountWindow(getHsplit());
        UI.getCurrent().addWindow(sub);
    });

    disableFields(false);
}

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

public MaintenanceReportUI() {
    setSizeFull();/*from ww  w. j  a  va2 s  . com*/

    mrDataGrid.setFrozenColumnCount(2);
    addComponent(mrDataGrid);
    setExpandRatio(mrDataGrid, 1);

    HorizontalLayout h = new HorizontalLayout();
    h.setWidth("100%");
    h.setSpacing(true);
    h.setMargin(new MarginInfo(false, true, true, false));

    Button filter = new CommonButton("FILTER");
    filter.setWidth("200px");
    filter.addClickListener(this);
    h.addComponent(filter);
    h.setComponentAlignment(filter, Alignment.MIDDLE_RIGHT);
    h.setExpandRatio(filter, 1);

    Button exportToExcel = new CommonButton("EXPORT TO EXCEL");
    exportToExcel.setWidth("200px");
    exportToExcel.addClickListener(this);
    h.addComponent(exportToExcel);
    h.setComponentAlignment(exportToExcel, Alignment.MIDDLE_RIGHT);

    addComponent(h);
}

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

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);/* w w  w  .j  ava2 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;
}