Java Code Examples for com.smartgwt.client.data.DataSource#setFields()

The following examples show how to use com.smartgwt.client.data.DataSource#setFields() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DcRecordDataSource.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
/**
     * Holds element text content and its attributes
     */
    private static DataSource createDcElementDataSource(String name) {
        DataSource ds = new DataSource();
//        ds.setID("DcElementDataSource");
        ds.setTagName(name);
        DataSourceField lang = new DataSourceField(FIELD_XML_LANG, FieldType.TEXT);
        lang.setXmlAttribute(true);

        ds.setFields(lang);

        ds.setXmlNamespaces(XML_NAMESPACES);
        ds.setGlobalNamespaces(XML_NAMESPACE_MAP);

        return ds;
    }
 
Example 2
Source File: NewIssueEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
private DynamicForm createForm() {
    DataSource ds = new DataSource();
    ds.setClientOnly(true);
    DataSourceIntegerField fDays = new DataSourceIntegerField(
            DigitalObjectResourceApi.DIGITALOBJECT_SERIES_DAYS_INCLUDED_PARAM);
    fDays.setMultiple(true);
    DataSourceDateField fDateFrom = new DataSourceDateField(
            DigitalObjectResourceApi.DIGITALOBJECT_SERIES_DATE_FROM_PARAM);
    DataSourceDateField fDateTo = new DataSourceDateField(
            DigitalObjectResourceApi.DIGITALOBJECT_SERIES_DATE_TO_PARAM);
    DataSourceIntegerField fPartNumberFrom = new DataSourceIntegerField(
            DigitalObjectResourceApi.DIGITALOBJECT_SERIES_PARTNUMBER_FROM_PARAM);
    ds.setFields(fDateFrom, fDateTo, fDays, fPartNumberFrom);

    DynamicForm df = new DynamicForm();
    df.setWidth(200);
    df.setItemHoverWidth(200);
    df.setWrapItemTitles(false);
    df.setSaveOnEnter(true);

    IntegerItem partNumberStart = createPartName(fPartNumberFrom.getName());

    DateRangeValidator dateRangeValidator = new DateRangeValidator();
    DateItem dateStart = createDateFrom(fDateFrom.getName(), dateRangeValidator);

    DateItem dateEnd = new DateItem(fDateTo.getName(), i18n.NewIssueEditor_dateTo_Title());
    dateEnd.setTooltip(i18n.NewIssueEditor_dateTo_Hint());
    dateEnd.setUseTextField(true);
    dateEnd.setValidators(dateRangeValidator);
    dateEnd.setStartDate(new Date(1900 - 1900, 1, 1));

    SelectItem issueDays = createDayChooser(fDays.getName());

    df.setDataSource(ds, partNumberStart, dateStart, dateEnd, issueDays);
    return df;
}
 
Example 3
Source File: RegisterLayout.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
public RegisterLayout() {
    super(i18n.registration());
    setStyleName("n52_sensorweb_client_form_content");
    
    DataSourceTextField userNameField = new DataSourceTextField("userName", i18n.userName(), 50, true);
    DataSourceTextField nameField = new DataSourceTextField("name", i18n.name(), 50, false);
    DataSourcePasswordField passwordField = new DataSourcePasswordField("password", i18n.password(), 20, true);
    DataSourceTextField emailField = new DataSourceTextField("email", i18n.email(), 100, true);

    RegExpValidator emailValidator = new RegExpValidator();
    emailValidator.setErrorMessage(i18n.invalidEmail());
    emailValidator.setExpression("^([a-zA-Z0-9_.\\-+])+@(([a-zA-Z0-9\\-])+\\.)+[a-zA-Z0-9]{2,4}$");
    emailField.setValidators(emailValidator);

    DataSource dataSource = new DataSource();
    dataSource.setFields(userNameField, nameField, passwordField, emailField);
    this.form.setDataSource(dataSource);

    createNameTextInputs();
    createPasswordTextInputs();
    createEmailTextInputs();
    createAcceptTermsOfUse();
    ButtonItem registerButton = createRegisterButton();
    LinkItem backToLoginLink = createBackToLoginLink();
    this.form.setFields(this.headerItem, this.userNameItem, this.nameItem, this.passwordItem, this.verifyPasswordItem,
            this.emailItem, this.verifyEmailItem, this.linkTerms, this.acceptBox, registerButton, backToLoginLink);
    
    addMember(this.form);
    setAutoWidth();
}
 
Example 4
Source File: DcRecordDataSource.java    From proarc with GNU General Public License v3.0 4 votes vote down vote up
private static DataSource createDcDataSource() {
        final DataSource dsDC = new DataSource() {

            @Override
            protected void transformResponse(DSResponse response, DSRequest request, Object data) {
                // data is a xml Document
                // WARNING: it is com.google.gwt.dom.client.Document not com.google.gwt.xml.client.Document!!!
                // following fix transforms parsed result that contains various object types to array of Records for each Record's attribute
                // Maybe we should create own data result from data parameter using
                // XMLTools or XMLParser instead of fixing default result.
                // In order to get data as string use DataSource.setDataFormat(DSDataFormat.CUSTOM)
                // or setDataProtocol(DSProtocol.CLIENTCUSTOM).
                // Do not use XMLTools.loadXMLSchema as it does not work well with tricky ComplexTypes.

                LOG.fine(ClientUtils.format("transformResponse.data: %s, class: %s", data, data.getClass()));

                Record[] rs = response.getData();
                if (rs != null) {
                    for (Record r : rs) {
                        fixDcRecord(r);
                    }
                }

                super.transformResponse(response, request, data);
            }
        };

        dsDC.setID("DcDataSource");
//        dsDC.setDataURL("ds/dc.xml");
//        dsDC.setDataURL("ds/dc_drobnustky.xml");
        dsDC.setXmlNamespaces(XML_NAMESPACES);
        dsDC.setGlobalNamespaces(XML_NAMESPACE_MAP);
//        dsDC.setRecordXPath("oai_dc:dc");
//        dsDC.setRecordXPath("/dc");
        dsDC.setTagName(FIELD_DC.getQualifiedName());
        dsDC.setSendExtraFields(false);
        dsDC.setDropExtraFields(true);

        dsDC.setFields(
                createDcDataSourceField(FIELD_TITLE),
                createDcDataSourceField(FIELD_CREATOR),
                createDcDataSourceField(FIELD_SUBJECT),
                createDcDataSourceField(FIELD_DESCRIPTION),
                createDcDataSourceField(FIELD_PUBLISHER),
                createDcDataSourceField(FIELD_CONTRIBUTOR),
                createDcDataSourceField(FIELD_DATE),
                createDcDataSourceField(FIELD_TYPE),
                createDcDataSourceField(FIELD_FORMAT),
                createDcDataSourceField(FIELD_IDENTIFIER),
                createDcDataSourceField(FIELD_SOURCE),
                createDcDataSourceField(FIELD_LANGUAGE),
                createDcDataSourceField(FIELD_RELATION),
                createDcDataSourceField(FIELD_COVERAGE),
                createDcDataSourceField(FIELD_RIGHTS)
        );

        return dsDC;
    }