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.save.reports.promodeals.PromoDealReportUI.java

private Window filterReport() {
    Window sub = new Window("FILTER REPORT");
    sub.setWidth("400px");
    sub.setModal(true);/* www  . ja va  2 s.c  om*/
    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;
}

From source file:com.save.reports.reimbursement.ReimbursementReportUI.java

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

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

    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 employeeComboBox = CommonComboBox.getAllEmpployees(null);
    employeeComboBox.setEnabled(false);
    f.addComponent(employeeComboBox);
    employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> {
        employeeComboBox.setEnabled((boolean) e.getProperty().getValue());
        isEmployee = (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());
        isAmount = (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());
        isDate = (boolean) e.getProperty().getValue();
    });

    f.addComponent(h);

    Button generate = new CommonButton("Generate Report");
    generate.addClickListener((Button.ClickEvent e) -> {
        if (!isEmployee && !isAmount && !isDate) {
            mrDataGrid.setContainerDataSource(new ReimbursementDataContainer());
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && !isAmount && !isDate) {
            if (employeeComboBox.getValue() == null) {
                Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            mrDataGrid.setContainerDataSource(
                    new ReimbursementDataContainer(employeeComboBox.getValue().toString()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && isAmount && !isDate) {
            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 ReimbursementDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && !isAmount && isDate) {
            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 ReimbursementDataContainer(from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && isAmount && !isDate) {
            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 ReimbursementDataContainer(employeeComboBox.getValue().toString(),
                            CommonUtilities.convertStringToDouble(amountField.getValue().trim())));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && !isAmount && isDate) {
            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 ReimbursementDataContainer(
                    employeeComboBox.getValue().toString(), from.getValue(), to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (!isEmployee && isAmount && isDate) {
            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 ReimbursementDataContainer(
                    CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(),
                    to.getValue()));
            mrDataGrid.setFrozenColumnCount(2);
        }

        if (isEmployee && isAmount && isDate) {
            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 ReimbursementDataContainer(employeeComboBox.getValue().toString(),
                            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:cz.opendata.linked.metadata.form.ExtractorDialog.java

private VerticalLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);//from w w  w .  j ava 2s.  co m
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfDatasetUri = new TextField();
    tfDatasetUri.setCaption("Dataset URI:");
    tfDatasetUri.setWidth("100%");
    mainLayout.addComponent(tfDatasetUri);

    tfDistributionUri = new TextField();
    tfDistributionUri.setCaption("Distribution URI:");
    tfDistributionUri.setWidth("100%");
    mainLayout.addComponent(tfDistributionUri);

    tfDataDumpUrl = new TextField();
    tfDataDumpUrl.setCaption("Data dump URL:");
    tfDataDumpUrl.setWidth("100%");
    mainLayout.addComponent(tfDataDumpUrl);

    cbMime = new ComboBox();
    cbMime.setCaption("Media Type:");
    cbMime.setNewItemsAllowed(false);
    cbMime.setNullSelectionAllowed(false);
    cbMime.setWidth("100%");
    for (String u : mimes)
        cbMime.addItem(u);
    mainLayout.addComponent(cbMime);

    tfSparqlEndpointUrl = new TextField();
    tfSparqlEndpointUrl.setCaption("Sparql Endpoint URI:");
    tfSparqlEndpointUrl.setWidth("100%");
    mainLayout.addComponent(tfSparqlEndpointUrl);

    tfContactPoint = new TextField();
    tfContactPoint.setCaption("Contact Point URL:");
    tfContactPoint.setWidth("100%");
    mainLayout.addComponent(tfContactPoint);

    tfTitleCs = new TextField();
    tfTitleCs.setCaption("Title (cs):");
    tfTitleCs.setWidth("100%");
    mainLayout.addComponent(tfTitleCs);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Title (en):");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    tfDescCs = new TextField();
    tfDescCs.setCaption("Description (cs):");
    tfDescCs.setWidth("100%");
    mainLayout.addComponent(tfDescCs);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description (en):");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    chkQb = new CheckBox();
    chkQb.setCaption("Dataset is RDF Data Cube");
    chkQb.setWidth("100%");
    mainLayout.addComponent(chkQb);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkNow = new CheckBox();
    chkNow.setCaption("Always use current date instead");
    chkNow.setWidth("100%");
    mainLayout.addComponent(chkNow);

    cbPeriodicity = new ComboBox();
    cbPeriodicity.setCaption("Periodicity:");
    cbPeriodicity.setNewItemsAllowed(false);
    cbPeriodicity.setNullSelectionAllowed(false);
    cbPeriodicity.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    cbPeriodicity.setWidth("100%");
    for (URLandCaption u : periodicities) {
        cbPeriodicity.addItem(u.url.toString());
        cbPeriodicity.setItemCaption(u.url.toString(), u.caption);
    }
    mainLayout.addComponent(cbPeriodicity);

    tcsLicenses = new TwinColSelect();
    tcsLicenses.setWidth("97%");
    tcsLicenses.setNewItemsAllowed(true);
    tcsLicenses.setLeftColumnCaption("Available licenses");
    tcsLicenses.setRightColumnCaption("Selected licenses");
    mainLayout.addComponent(tcsLicenses);

    tcsExamples = new TwinColSelect();
    tcsExamples.setWidth("97%");
    tcsExamples.setNewItemsAllowed(true);
    tcsExamples.setLeftColumnCaption("Available example resources");
    tcsExamples.setRightColumnCaption("Selected example resources");
    mainLayout.addComponent(tcsExamples);

    tcsSources = new TwinColSelect();
    tcsSources.setWidth("97%");
    tcsSources.setNewItemsAllowed(true);
    tcsSources.setLeftColumnCaption("Available sources");
    tcsSources.setRightColumnCaption("Selected sources");
    mainLayout.addComponent(tcsSources);

    tcsKeywords = new TwinColSelect();
    tcsKeywords.setWidth("97%");
    tcsKeywords.setNewItemsAllowed(true);
    tcsKeywords.setLeftColumnCaption("Available keywords");
    tcsKeywords.setRightColumnCaption("Selected keywords");
    mainLayout.addComponent(tcsKeywords);

    tcsThemes = new TwinColSelect();
    tcsThemes.setWidth("97%");
    tcsThemes.setNewItemsAllowed(true);
    tcsThemes.setLeftColumnCaption("Available themes");
    tcsThemes.setRightColumnCaption("Selected themes");
    mainLayout.addComponent(tcsThemes);

    tcsLanguages = new TwinColSelect();
    tcsLanguages.setWidth("97%");
    tcsLanguages.setLeftColumnCaption("Available languages");
    tcsLanguages.setRightColumnCaption("Selected languages");
    mainLayout.addComponent(tcsLanguages);

    tcsAuthors = new TwinColSelect();
    tcsAuthors.setWidth("97%");
    tcsAuthors.setNewItemsAllowed(true);
    tcsAuthors.setLeftColumnCaption("Available authors");
    tcsAuthors.setRightColumnCaption("Selected authors");
    mainLayout.addComponent(tcsAuthors);

    tcsPublishers = new TwinColSelect();
    tcsPublishers.setWidth("97%");
    tcsPublishers.setNewItemsAllowed(true);
    tcsPublishers.setLeftColumnCaption("Available publishers");
    tcsPublishers.setRightColumnCaption("Selected publishers");
    mainLayout.addComponent(tcsPublishers);

    return mainLayout;
}

From source file:cz.opendata.unifiedviews.dpus.datasetMetadata.DatasetMetadataVaadinDialog.java

License:Creative Commons License

@Override
protected void buildDialogLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);//from   www.  j av  a 2s. com
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfDatasetUri = new TextField();
    tfDatasetUri.setCaption("Dataset URI:");
    tfDatasetUri.setInputPrompt("http://data.mydomain.com/resource/dataset/mydataset");
    tfDatasetUri.setWidth("100%");
    mainLayout.addComponent(tfDatasetUri);

    tfLanguage = new TextField();
    tfLanguage.setCaption("Original language (RDF language tag, e.g. cs):");
    tfLanguage.setInputPrompt("cs|en|sk|it");
    tfLanguage.setWidth("100%");
    mainLayout.addComponent(tfLanguage);

    tfTitle = new TextField();
    tfTitle.setCaption("Dataset title original language:");
    tfTitle.setInputPrompt("My dataset");
    tfTitle.setWidth("100%");
    mainLayout.addComponent(tfTitle);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Dataset title in English:");
    tfTitleEn.setInputPrompt("My dataset");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    tfDesc = new TextField();
    tfDesc.setCaption("Description in original language:");
    tfDesc.setInputPrompt("Longer description in original language");
    tfDesc.setWidth("100%");
    mainLayout.addComponent(tfDesc);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description in English:");
    tfDescEn.setInputPrompt("Longer description in English");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    dfIssued = new DateField();
    dfIssued.setCaption("Issued:");
    dfIssued.setWidth("100%");
    dfIssued.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfIssued);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkNow = new CheckBox();
    chkNow.setCaption("Use current date as modified");
    chkNow.setWidth("100%");
    chkNow.setImmediate(true);
    chkNow.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfModified.setEnabled(!chkNow.getValue());
        }
    });
    mainLayout.addComponent(chkNow);

    tfIdentifier = new TextField();
    tfIdentifier.setCaption("Identifier:");
    tfIdentifier.setInputPrompt("CTIA_1");
    tfIdentifier.setWidth("100%");
    mainLayout.addComponent(tfIdentifier);

    lsKeywords_orig = new ListSelect();
    lsKeywords_orig.setWidth("100%");
    lsKeywords_orig.setNewItemsAllowed(true);
    lsKeywords_orig.setCaption("Keywords in original language");
    lsKeywords_orig.setMultiSelect(true);
    lsKeywords_orig.setRows(3);
    mainLayout.addComponent(lsKeywords_orig);

    lsKeywords_en = new ListSelect();
    lsKeywords_en.setWidth("100%");
    lsKeywords_en.setNewItemsAllowed(true);
    lsKeywords_en.setCaption("Keywords in English");
    lsKeywords_en.setMultiSelect(true);
    lsKeywords_en.setRows(3);
    mainLayout.addComponent(lsKeywords_en);

    lsLanguages = new ListSelect();
    lsLanguages.setWidth("100%");
    lsLanguages.setNewItemsAllowed(true);
    lsLanguages.setCaption("Languages");
    lsLanguages.setMultiSelect(true);
    lsLanguages.addItems(languages);
    lsLanguages.setRows(3);
    mainLayout.addComponent(lsLanguages);

    tfContactPoint = new TextField();
    tfContactPoint.setCaption("Contact point email:");
    tfContactPoint.setInputPrompt("contact@myorganization.com");
    tfContactPoint.setWidth("100%");
    mainLayout.addComponent(tfContactPoint);

    dfTemporalStart = new DateField();
    dfTemporalStart.setCaption("Temporal coverage start:");
    dfTemporalStart.setWidth("100%");
    dfTemporalStart.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalStart);

    dfTemporalEnd = new DateField();
    dfTemporalEnd.setCaption("Temporal coverage end:");
    dfTemporalEnd.setWidth("100%");
    dfTemporalEnd.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalEnd);

    tfSpatial = new TextField();
    tfSpatial.setCaption("Spatial coverage URI:");
    tfSpatial.setInputPrompt("http://ruian.linked.opendata.cz/resource/adresni-mista/25958810");
    tfSpatial.setWidth("100%");
    mainLayout.addComponent(tfSpatial);

    tfPeriodicity = new TextField();
    tfPeriodicity.setCaption("Periodicity:");
    tfPeriodicity.setInputPrompt("R-P1Y");
    tfPeriodicity.setWidth("100%");
    mainLayout.addComponent(tfPeriodicity);

    tfSchema = new TextField();
    tfSchema.setCaption("Schema URL:");
    tfSchema.setInputPrompt("http://data.example.org/dataset/myschema");
    tfSchema.setWidth("100%");
    mainLayout.addComponent(tfSchema);

    tfLandingPage = new TextField();
    tfLandingPage.setCaption("Landing page URL:");
    tfLandingPage.setInputPrompt("http://data.example.org/dataset/mydataset");
    tfLandingPage.setWidth("100%");
    mainLayout.addComponent(tfLandingPage);

    lsLicenses = new ListSelect();
    lsLicenses.setWidth("100%");
    lsLicenses.setNewItemsAllowed(true);
    lsLicenses.setCaption("Licenses");
    lsLicenses.setMultiSelect(false);
    lsLicenses.setNullSelectionAllowed(false);
    lsLicenses.setRows(3);
    lsLicenses.addItems(licenses);
    mainLayout.addComponent(lsLicenses);

    lsSources = new ListSelect();
    lsSources.setWidth("100%");
    lsSources.setNewItemsAllowed(true);
    lsSources.setCaption("Sources");
    lsSources.setMultiSelect(true);
    lsSources.setRows(2);
    mainLayout.addComponent(lsSources);

    lsThemes = new ListSelect();
    lsThemes.setWidth("100%");
    lsThemes.setNewItemsAllowed(true);
    lsThemes.setCaption("Themes");
    lsThemes.setMultiSelect(true);
    lsThemes.setRows(3);
    mainLayout.addComponent(lsThemes);

    lsAuthors = new ListSelect();
    lsAuthors.setWidth("100%");
    lsAuthors.setNewItemsAllowed(true);
    lsAuthors.setCaption("Selected authors");
    lsAuthors.setMultiSelect(true);
    lsAuthors.setRows(2);
    mainLayout.addComponent(lsAuthors);

    lsPublishers = new ListSelect();
    lsPublishers.setWidth("100%");
    lsPublishers.setNewItemsAllowed(true);
    lsPublishers.setCaption("Publishers");
    lsPublishers.setMultiSelect(true);
    lsPublishers.addItems(publishers);
    lsPublishers.setRows(2);
    mainLayout.addComponent(lsPublishers);

    Panel p = new Panel();
    p.setSizeFull();
    p.setContent(mainLayout);

    setCompositionRoot(p);
}

From source file:cz.opendata.unifiedviews.dpus.distributionMetadata.DistributionMetadataVaadinDialog.java

License:Creative Commons License

@Override
protected void buildDialogLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);//from  w ww.  jav a  2  s .c  o m
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfDownloadURL = new TextField();
    tfDownloadURL.setCaption("Download URL:");
    tfDownloadURL.setInputPrompt("http://data.mydomain.com/dumps/dataset.ttl");
    tfDownloadURL.setWidth("100%");
    mainLayout.addComponent(tfDownloadURL);

    tfMediaType = new TextField();
    tfMediaType.setCaption("Media (MIME) type:");
    tfMediaType.setInputPrompt("text/turtle|text/csv");
    tfMediaType.setWidth("100%");
    mainLayout.addComponent(tfMediaType);

    tfAccessURL = new TextField();
    tfAccessURL.setCaption("Access URL:");
    tfAccessURL.setInputPrompt("http://data.mydomain.com/dataset/dataset");
    tfAccessURL.setWidth("100%");
    mainLayout.addComponent(tfAccessURL);

    lsExampleResources = new ListSelect();
    lsExampleResources.setWidth("100%");
    lsExampleResources.setNewItemsAllowed(true);
    lsExampleResources.setCaption("Example resources");
    lsExampleResources.setMultiSelect(true);
    lsExampleResources.setRows(3);
    mainLayout.addComponent(lsExampleResources);

    tfSPARQLEndpointURL = new TextField();
    tfSPARQLEndpointURL.setCaption("SPARQL Endpoint URL:");
    tfSPARQLEndpointURL.setInputPrompt("http://linked.opendata.cz/sparql");
    tfSPARQLEndpointURL.setWidth("100%");
    mainLayout.addComponent(tfSPARQLEndpointURL);

    tfSchemaType = new TextField();
    tfSchemaType.setCaption("Schema MIME type:");
    tfSchemaType.setInputPrompt("text/csv");
    tfSchemaType.setWidth("100%");
    mainLayout.addComponent(tfSchemaType);

    chkSchemaFromInput = new CheckBox();
    chkSchemaFromInput.setCaption("Use schema from dataset");
    chkSchemaFromInput.setWidth("100%");
    chkSchemaFromInput.setImmediate(true);
    chkSchemaFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfSchema.setEnabled(!chkSchemaFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkSchemaFromInput);

    tfSchema = new TextField();
    tfSchema.setCaption("Schema URL:");
    tfSchema.setInputPrompt("http://data.example.org/dataset/myschema");
    tfSchema.setWidth("100%");
    mainLayout.addComponent(tfSchema);

    chkDatasetURIFromInput = new CheckBox();
    chkDatasetURIFromInput.setCaption("Get dataset URI from dataset");
    chkDatasetURIFromInput.setWidth("100%");
    chkDatasetURIFromInput.setImmediate(true);
    chkDatasetURIFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfDatasetURI.setEnabled(!chkDatasetURIFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkDatasetURIFromInput);

    tfDatasetURI = new TextField();
    tfDatasetURI.setCaption("Dataset URI:");
    tfDatasetURI.setInputPrompt("http://data.mydomain.com/resource/dataset/mydataset");
    tfDatasetURI.setWidth("100%");
    mainLayout.addComponent(tfDatasetURI);

    chkGenerateDistroURIFromDataset = new CheckBox();
    chkGenerateDistroURIFromDataset.setCaption("Generate distribution URI from dataset (+\"/distribution\")");
    chkGenerateDistroURIFromDataset.setWidth("100%");
    chkGenerateDistroURIFromDataset.setImmediate(true);
    chkGenerateDistroURIFromDataset.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfDistributionURI.setEnabled(!chkGenerateDistroURIFromDataset.getValue());
        }
    });
    mainLayout.addComponent(chkGenerateDistroURIFromDataset);

    tfDistributionURI = new TextField();
    tfDistributionURI.setCaption("Distribution URI:");
    tfDistributionURI.setInputPrompt("http://data.mydomain.com/resource/dataset/mydataset/distribution/rdf");
    tfDistributionURI.setWidth("100%");
    mainLayout.addComponent(tfDistributionURI);

    chkLanguageFromInput = new CheckBox();
    chkLanguageFromInput.setCaption("Get original language from dataset");
    chkLanguageFromInput.setWidth("100%");
    chkLanguageFromInput.setImmediate(true);
    chkLanguageFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfLanguage.setEnabled(!chkLanguageFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkLanguageFromInput);

    tfLanguage = new TextField();
    tfLanguage.setCaption("Original language (RDF language tag, e.g. cs):");
    tfLanguage.setInputPrompt("cs|en|sk|it");
    tfLanguage.setWidth("100%");
    mainLayout.addComponent(tfLanguage);

    chkTitleFromInput = new CheckBox();
    chkTitleFromInput.setCaption("Get title from dataset");
    chkTitleFromInput.setWidth("100%");
    chkTitleFromInput.setImmediate(true);
    chkTitleFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfTitle.setEnabled(!chkTitleFromInput.getValue());
            tfTitleEn.setEnabled(!chkTitleFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkTitleFromInput);

    tfTitle = new TextField();
    tfTitle.setCaption("Dataset title in original language:");
    tfTitle.setInputPrompt("My dataset");
    tfTitle.setWidth("100%");
    mainLayout.addComponent(tfTitle);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Dataset title in English:");
    tfTitleEn.setInputPrompt("My dataset");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    chkDescriptionFromInput = new CheckBox();
    chkDescriptionFromInput.setCaption("Get description from dataset");
    chkDescriptionFromInput.setWidth("100%");
    chkDescriptionFromInput.setImmediate(true);
    chkDescriptionFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfDesc.setEnabled(!chkDescriptionFromInput.getValue());
            tfDescEn.setEnabled(!chkDescriptionFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkDescriptionFromInput);

    tfDesc = new TextField();
    tfDesc.setCaption("Description in original language:");
    tfDesc.setInputPrompt("Longer description in original language");
    tfDesc.setWidth("100%");
    mainLayout.addComponent(tfDesc);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description in English:");
    tfDescEn.setInputPrompt("Longer description in English");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    chkIssuedFromInput = new CheckBox();
    chkIssuedFromInput.setCaption("Use issued date from dataset");
    chkIssuedFromInput.setWidth("100%");
    chkIssuedFromInput.setImmediate(true);
    chkIssuedFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfIssued.setEnabled(!chkIssuedFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkIssuedFromInput);

    dfIssued = new DateField();
    dfIssued.setCaption("Issued:");
    dfIssued.setWidth("100%");
    dfIssued.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfIssued);

    chkNow = new CheckBox();
    chkNow.setCaption("Use current date as modified");
    chkNow.setWidth("100%");
    chkNow.setImmediate(true);
    chkNow.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfModified.setEnabled(!chkNow.getValue());
        }
    });
    mainLayout.addComponent(chkNow);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkTemporalFromInput = new CheckBox();
    chkTemporalFromInput.setCaption("Use temporal coverage from dataset");
    chkTemporalFromInput.setWidth("100%");
    chkTemporalFromInput.setImmediate(true);
    chkTemporalFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfTemporalStart.setEnabled(!chkTemporalFromInput.getValue());
            dfTemporalEnd.setEnabled(!chkTemporalFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkTemporalFromInput);

    dfTemporalStart = new DateField();
    dfTemporalStart.setCaption("Temporal coverage start:");
    dfTemporalStart.setWidth("100%");
    dfTemporalStart.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalStart);

    dfTemporalEnd = new DateField();
    dfTemporalEnd.setCaption("Temporal coverage end:");
    dfTemporalEnd.setWidth("100%");
    dfTemporalEnd.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalEnd);

    chkSpatialFromInput = new CheckBox();
    chkSpatialFromInput.setCaption("Use spatial coverage from dataset");
    chkSpatialFromInput.setWidth("100%");
    chkSpatialFromInput.setImmediate(true);
    chkSpatialFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfSpatial.setEnabled(!chkSpatialFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkSpatialFromInput);

    tfSpatial = new TextField();
    tfSpatial.setCaption("Spatial coverage URI:");
    tfSpatial.setInputPrompt("http://ruian.linked.opendata.cz/resource/adresni-mista/25958810");
    tfSpatial.setWidth("100%");
    mainLayout.addComponent(tfSpatial);

    chkLicensesFromInput = new CheckBox();
    chkLicensesFromInput.setCaption("Use license from dataset");
    chkLicensesFromInput.setWidth("100%");
    chkLicensesFromInput.setImmediate(true);
    chkLicensesFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            lsLicenses.setEnabled(!chkLicensesFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkLicensesFromInput);

    lsLicenses = new ListSelect();
    lsLicenses.setWidth("100%");
    lsLicenses.setNewItemsAllowed(true);
    lsLicenses.setCaption("License");
    lsLicenses.setMultiSelect(false);
    lsLicenses.setNullSelectionAllowed(false);
    lsLicenses.setRows(3);
    lsLicenses.addItems(licenses);
    mainLayout.addComponent(lsLicenses);

    Panel p = new Panel();
    p.setSizeFull();
    p.setContent(mainLayout);

    setCompositionRoot(p);
}

From source file:de.escidoc.admintool.view.util.LayoutHelper.java

License:Open Source License

/**
 * @param className/*from w  ww  . j av a 2  s.c o m*/
 * @param item
 * @param readOnly
 * @param propertyName
 * @param resolution
 * @return AbstractComponent
 */
public static synchronized AbstractComponent createDateElement(final String className, final POJOItem<?> item,
        final boolean readOnly, final String propertyName, final int resolution) {
    AbstractComponent comp;
    if (readOnly) {
        comp = new Label();
        ((Label) comp).setPropertyDataSource(item.getItemProperty(propertyName));
    } else {
        comp = new DateField();
        ((DateField) comp).setResolution(resolution);
        ((DateField) comp).setWriteThrough(false);
        ((DateField) comp).setPropertyDataSource(item.getItemProperty(propertyName));
        List<Field> attachedFields = ATTACHED_FIELD_MAP.get(className);
        if (attachedFields == null) {
            attachedFields = new ArrayList<Field>();
            ATTACHED_FIELD_MAP.put(className, attachedFields);
        }
        attachedFields.add((Field) comp);
    }
    return comp;
}

From source file:de.metas.ui.web.vaadin.window.components.FieldEditorFactory.java

License:Open Source License

public Field<?> createEditor(final DataFieldPropertyDescriptor descriptor) {
    final int displayType = descriptor.getDisplayType();
    final int adReferenceId = descriptor.getAD_Reference_Value_ID();
    String caption = descriptor.getCaption();

    final Field<?> field;
    if (displayType == DisplayType.List || displayType == DisplayType.Button && adReferenceId > 0) {
        field = createField_ComboBox(descriptor);
    } else if (displayType == DisplayType.TableDir || displayType == DisplayType.Table) {
        field = createField_ComboBox(descriptor);
    } else if (displayType == DisplayType.Search) {
        field = createField_LazyComboBox(descriptor);
    } else if (descriptor.isLongTextField()) {
        final TextArea textArefield = new TextArea();
        field = textArefield;//  ww w  .ja  v  a 2  s . co m
    } else if (DisplayType.isText(displayType)) {
        final TextField textField = new TextField();
        field = textField;
    } else if (DisplayType.isDate(displayType)) {
        final DateField dateField = new DateField();
        field = dateField;
    } else if (DisplayType.isNumeric(displayType)) {
        final TextField textField = new TextField();
        field = textField;
    } else if (DisplayType.YesNo == displayType) {
        final CheckBox checkbox = new CheckBox();
        if (gridMode) {
            caption = "";
        }
        field = checkbox;
    } else {
        // final Class<?> type = DisplayType.getClass(displayType, true);
        // field = defaultFieldFactory.createField(type, Field.class);
        field = null;
    }

    if (field == null) {
        return null;
    }

    field.setCaption(caption);
    return field;
}

From source file:de.metas.ui.web.vaadin.window.editor.DateEditor.java

License:Open Source License

@Override
protected AbstractField<Date> createValueField() {
    final DateField dateField = new DateField();
    return dateField;
}

From source file:de.symeda.sormas.ui.configuration.DevModeView.java

License:Open Source License

public DevModeView() {
    super(VIEW_NAME);

    contentLayout = new VerticalLayout();
    contentLayout.setMargin(true);//from www.  j  av a 2  s.  c om
    contentLayout.setSpacing(true);
    contentLayout.setSizeFull();
    contentLayout.setStyleName("crud-main-layout");

    HorizontalLayout caseGeneratorLayout = new HorizontalLayout();

    TextField caseCountField = new TextField();
    caseCountField.setCaption(I18nProperties.getCaption(Captions.devModeCaseCount));
    caseGeneratorConfigBinder.forField(caseCountField)
            .withConverter(new StringToIntegerConverter("Must be a number"))
            .bind(CaseGenerationConfig::getCaseCount, CaseGenerationConfig::setCaseCount);
    caseGeneratorLayout.addComponent(caseCountField);

    DateField startDateField = new DateField();
    startDateField.setCaption(I18nProperties.getCaption(Captions.devModeStartDate));
    startDateField.setDateFormat(DateHelper.getLocalDatePattern());
    startDateField.setLenient(true);
    caseGeneratorConfigBinder.bind(startDateField, CaseGenerationConfig::getStartDate,
            CaseGenerationConfig::setStartDate);
    caseGeneratorLayout.addComponent(startDateField);

    DateField endDateField = new DateField();
    endDateField.setCaption(I18nProperties.getCaption(Captions.devModeEndDate));
    endDateField.setDateFormat(DateHelper.getLocalDatePattern());
    endDateField.setLenient(true);
    caseGeneratorConfigBinder.bind(endDateField, CaseGenerationConfig::getEndDate,
            CaseGenerationConfig::setEndDate);
    caseGeneratorLayout.addComponent(endDateField);

    ComboBox<Disease> diseaseField = new ComboBox<>(null,
            FacadeProvider.getDiseaseConfigurationFacade().getAllActivePrimaryDiseases());
    diseaseField.setCaption(I18nProperties.getCaption(Captions.devModeDisease));
    caseGeneratorConfigBinder.bind(diseaseField, CaseGenerationConfig::getDisease,
            CaseGenerationConfig::setDisease);
    caseGeneratorLayout.addComponent(diseaseField);

    List<RegionReferenceDto> regions = FacadeProvider.getRegionFacade().getAllAsReference();
    ComboBox<RegionReferenceDto> regionField = new ComboBox<RegionReferenceDto>(null, regions);
    regionField.setCaption(I18nProperties.getCaption(Captions.devModeRegion));
    caseGeneratorConfigBinder.bind(regionField, CaseGenerationConfig::getRegion,
            CaseGenerationConfig::setRegion);
    caseGeneratorLayout.addComponent(regionField);

    ComboBox<DistrictReferenceDto> districtField = new ComboBox<DistrictReferenceDto>();
    districtField.setCaption(I18nProperties.getCaption(Captions.devModeDistrict));
    caseGeneratorConfigBinder.bind(districtField, CaseGenerationConfig::getDistrict,
            CaseGenerationConfig::setDistrict);
    caseGeneratorLayout.addComponent(districtField);

    regionField.addValueChangeListener(event -> {
        RegionReferenceDto region = event.getValue();
        if (region != null) {
            districtField.setItems(FacadeProvider.getDistrictFacade().getAllByRegion(region.getUuid()));
        } else {
            districtField.setItems(new ArrayList<DistrictReferenceDto>());
        }
    });

    Button generateButton = new Button("generate cases");
    CssStyles.style(generateButton, CssStyles.FORCE_CAPTION);
    generateButton.addClickListener(e -> generateCases());
    caseGeneratorLayout.addComponent(generateButton);

    contentLayout.addComponent(caseGeneratorLayout);

    CaseGenerationConfig config = new CaseGenerationConfig();
    config.setRegion(regions.get(0));
    caseGeneratorConfigBinder.setBean(config);

    addComponent(contentLayout);
}

From source file:eu.unifiedviews.plugins.transformer.metadata.MetadataVaadinDialog.java

License:Creative Commons License

@Override
protected void buildDialogLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);// ww w. j  a va2  s  .  c om
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    txtOutSymbolicName = new TextField();
    txtOutSymbolicName.setCaption("Output graph name:");
    txtOutSymbolicName.setWidth("100%");
    mainLayout.addComponent(txtOutSymbolicName);

    tfComsodeDatasetId = new TextField();
    tfComsodeDatasetId.setCaption("COMSODE Dataset ID (will be used as part of the URI)");
    tfComsodeDatasetId.setWidth("100%");
    tfComsodeDatasetId.setInputPrompt("MICR_3");
    mainLayout.addComponent(tfComsodeDatasetId);

    tfDatasetUri = new TextField();
    tfDatasetUri.setCaption("Dataset URI:");
    tfDatasetUri.setWidth("100%");
    mainLayout.addComponent(tfDatasetUri);

    tfDistributionUri = new TextField();
    tfDistributionUri.setCaption("Distribution URI:");
    tfDistributionUri.setWidth("100%");
    mainLayout.addComponent(tfDistributionUri);

    tfDataDumpUrl = new TextField();
    tfDataDumpUrl.setCaption("Data dump URL:");
    tfDataDumpUrl.setWidth("100%");
    mainLayout.addComponent(tfDataDumpUrl);

    cbMime = new ComboBox();
    cbMime.setCaption("Media Type:");
    cbMime.setNewItemsAllowed(false);
    cbMime.setNullSelectionAllowed(false);
    cbMime.setWidth("100%");
    for (String u : mimes) {
        cbMime.addItem(u);
    }
    mainLayout.addComponent(cbMime);

    tfSparqlEndpointUrl = new TextField();
    tfSparqlEndpointUrl.setCaption("Sparql Endpoint URI:");
    tfSparqlEndpointUrl.setWidth("100%");
    tfSparqlEndpointUrl.setNullRepresentation("");
    tfSparqlEndpointUrl.setNullSettingAllowed(true);
    mainLayout.addComponent(tfSparqlEndpointUrl);

    tfContactPoint = new TextField();
    tfContactPoint.setCaption("Contact Point URL:");
    tfContactPoint.setWidth("100%");
    mainLayout.addComponent(tfContactPoint);

    tfLanguage = new TextField();
    tfLanguage.setCaption("Original language - RDF language tag:");
    tfLanguage.setInputPrompt("cs|sk|it");
    tfLanguage.setWidth("100%");
    mainLayout.addComponent(tfLanguage);

    tfTitle = new TextField();
    tfTitle.setCaption("Title original language:");
    tfTitle.setWidth("100%");
    mainLayout.addComponent(tfTitle);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Title in English:");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    tfDesc = new TextField();
    tfDesc.setCaption("Description original language:");
    tfDesc.setWidth("100%");
    mainLayout.addComponent(tfDesc);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description in English:");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    chkQb = new CheckBox();
    chkQb.setCaption("Dataset is RDF Data Cube");
    chkQb.setWidth("100%");
    mainLayout.addComponent(chkQb);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkNow = new CheckBox();
    chkNow.setCaption("Always use current date instead");
    chkNow.setWidth("100%");
    mainLayout.addComponent(chkNow);

    cbPeriodicity = new ComboBox();
    cbPeriodicity.setCaption("Periodicity:");
    cbPeriodicity.setNewItemsAllowed(false);
    cbPeriodicity.setNullSelectionAllowed(false);
    cbPeriodicity.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    cbPeriodicity.setWidth("100%");
    for (URLandCaption u : periodicities) {
        cbPeriodicity.addItem(u.url.toString());
        cbPeriodicity.setItemCaption(u.url.toString(), u.caption);
    }
    mainLayout.addComponent(cbPeriodicity);

    tcsLicenses = new TwinColSelect();
    tcsLicenses.setWidth("97%");
    tcsLicenses.setNewItemsAllowed(true);
    tcsLicenses.setLeftColumnCaption("Available licenses");
    tcsLicenses.setRightColumnCaption("Selected licenses");
    mainLayout.addComponent(tcsLicenses);

    tcsExamples = new TwinColSelect();
    tcsExamples.setWidth("97%");
    tcsExamples.setNewItemsAllowed(true);
    tcsExamples.setLeftColumnCaption("Available example resources");
    tcsExamples.setRightColumnCaption("Selected example resources");
    mainLayout.addComponent(tcsExamples);

    tcsSources = new TwinColSelect();
    tcsSources.setWidth("97%");
    tcsSources.setNewItemsAllowed(true);
    tcsSources.setLeftColumnCaption("Available sources");
    tcsSources.setRightColumnCaption("Selected sources");
    mainLayout.addComponent(tcsSources);

    tcsKeywords = new TwinColSelect();
    tcsKeywords.setWidth("97%");
    tcsKeywords.setNewItemsAllowed(true);
    tcsKeywords.setLeftColumnCaption("Available keywords");
    tcsKeywords.setRightColumnCaption("Selected keywords");
    mainLayout.addComponent(tcsKeywords);

    tcsThemes = new TwinColSelect();
    tcsThemes.setWidth("97%");
    tcsThemes.setNewItemsAllowed(true);
    tcsThemes.setLeftColumnCaption("Available themes");
    tcsThemes.setRightColumnCaption("Selected themes");
    mainLayout.addComponent(tcsThemes);

    tcsLanguages = new TwinColSelect();
    tcsLanguages.setWidth("97%");
    tcsLanguages.setNewItemsAllowed(true);
    tcsLanguages.setLeftColumnCaption("Available languages");
    tcsLanguages.setRightColumnCaption("Selected languages");
    mainLayout.addComponent(tcsLanguages);

    tcsAuthors = new TwinColSelect();
    tcsAuthors.setWidth("97%");
    tcsAuthors.setNewItemsAllowed(true);
    tcsAuthors.setLeftColumnCaption("Available authors");
    tcsAuthors.setRightColumnCaption("Selected authors");
    mainLayout.addComponent(tcsAuthors);

    tcsPublishers = new TwinColSelect();
    tcsPublishers.setWidth("97%");
    tcsPublishers.setNewItemsAllowed(true);
    tcsPublishers.setLeftColumnCaption("Available publishers");
    tcsPublishers.setRightColumnCaption("Selected publishers");
    mainLayout.addComponent(tcsPublishers);

    Panel p = new Panel();
    p.setSizeFull();
    p.setContent(mainLayout);

    setCompositionRoot(p);
}