Search in sources :

Example 1 with InputTypeProperty

use of com.enonic.xp.inputtype.InputTypeProperty in project xp by enonic.

the class XmlInputTypeDefaultMapper method buildProperty.

private InputTypeProperty buildProperty(final DomElement root) {
    final String name = XmlInputTypeDefaultMapper.resolveName(root.getTagName());
    final InputTypeProperty.Builder builder = InputTypeProperty.create(name, root.getValue());
    for (final Attr attr : root.getAttributes()) {
        addPropertyAttribute(builder, attr);
    }
    return builder.build();
}
Also used : InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) Attr(org.w3c.dom.Attr)

Example 2 with InputTypeProperty

use of com.enonic.xp.inputtype.InputTypeProperty in project xp by enonic.

the class XmlInputTypeConfigMapper method buildProperty.

private InputTypeProperty buildProperty(final DomElement root) {
    final String name = nameResolver.apply(root.getTagName());
    final String value = valueResolver.apply(name, root.getValue());
    final InputTypeProperty.Builder builder = InputTypeProperty.create(name, value);
    for (final Attr attr : root.getAttributes()) {
        addPropertyAttribute(builder, attr);
    }
    return builder.build();
}
Also used : InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) Attr(org.w3c.dom.Attr)

Example 3 with InputTypeProperty

use of com.enonic.xp.inputtype.InputTypeProperty in project xp by enonic.

the class ContentTypeMapper method serializeConfig.

private void serializeConfig(final MapGenerator gen, final InputTypeConfig config) {
    gen.map("config");
    for (String name : config.getNames()) {
        gen.array(name);
        for (final InputTypeProperty property : config.getProperties(name)) {
            serializeConfigProperty(gen, property);
        }
        gen.end();
    }
    gen.end();
}
Also used : InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty)

Example 4 with InputTypeProperty

use of com.enonic.xp.inputtype.InputTypeProperty in project xp by enonic.

the class ContentTypeHandlerTest method getForm.

private Form getForm() {
    Input myTextLine = Input.create().name("myTextLine").inputType(InputTypeName.TEXT_LINE).label("My text line").customText("Some custom text").helpText("Some help text").required(true).inputTypeConfig(InputTypeConfig.create().property(InputTypeProperty.create("regexp", "\\b\\d{3}-\\d{2}-\\d{4}\\b").build()).build()).build();
    Input myCustomInput = Input.create().name("myCheckbox").inputType(InputTypeName.CHECK_BOX).label("My checkbox input").required(false).defaultValue(InputTypeDefault.create().property(InputTypeProperty.create("default", "checked").build()).build()).build();
    final InputTypeProperty option1 = InputTypeProperty.create("option", "Option One").attribute("value", "one").build();
    final InputTypeProperty option2 = InputTypeProperty.create("option", "Option Two").attribute("value", "two").build();
    Input radioButtonInput = Input.create().name("myRadioButton").inputType(InputTypeName.RADIO_BUTTON).label("Radio button").inputTypeConfig(InputTypeConfig.create().property(option1).property(option2).build()).build();
    FieldSet myFieldSet = FieldSet.create().name("myFieldSet").label("My field set").addFormItem(Input.create().name("myTextLineInFieldSet").inputType(InputTypeName.TEXT_LINE).label("My text line").required(false).build()).build();
    FormItemSet myFormItemSet = FormItemSet.create().name("myFormItemSet").label("My form item set").addFormItem(Input.create().name("myTextLine").inputType(InputTypeName.TEXT_LINE).label("My text line").required(false).build()).build();
    final FormOptionSet formOptionSet = FormOptionSet.create().name("myOptionSet").label("My option set").helpText("Option set help text").addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption1").label("option label1").helpText("Option help text").addFormItem(Input.create().name("myTextLine1").label("myTextLine1").inputType(InputTypeName.TEXT_LINE).build()).build()).addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption2").label("option label2").helpText("Option help text").addFormItem(Input.create().name("myTextLine2").label("myTextLine2").inputType(InputTypeName.TEXT_LINE).build()).build()).build();
    return Form.create().addFormItem(myTextLine).addFormItem(myCustomInput).addFormItem(radioButtonInput).addFormItem(myFieldSet).addFormItem(myFormItemSet).addFormItem(formOptionSet).build();
}
Also used : FormOptionSet(com.enonic.xp.form.FormOptionSet) Input(com.enonic.xp.form.Input) FieldSet(com.enonic.xp.form.FieldSet) InputTypeProperty(com.enonic.xp.inputtype.InputTypeProperty) FormItemSet(com.enonic.xp.form.FormItemSet)

Aggregations

InputTypeProperty (com.enonic.xp.inputtype.InputTypeProperty)4 Attr (org.w3c.dom.Attr)2 FieldSet (com.enonic.xp.form.FieldSet)1 FormItemSet (com.enonic.xp.form.FormItemSet)1 FormOptionSet (com.enonic.xp.form.FormOptionSet)1 Input (com.enonic.xp.form.Input)1