Search in sources :

Example 1 with FieldGroup

use of com.haulmont.cuba.gui.components.FieldGroup in project cuba by cuba-platform.

the class SessionAttributeEditor method init.

@Override
public void init(Map<String, Object> params) {
    datasource = getDsContext().get("attribute");
    FieldGroup fields = (FieldGroup) getComponent("fields");
    FieldGroup.FieldConfig field = fields.getField("datatype");
    fields.addCustomField(field, new FieldGroup.CustomFieldGenerator() {

        @Override
        public Component generateField(Datasource datasource, String propertyId) {
            LookupField lookup = AppConfig.getFactory().createComponent(LookupField.class);
            lookup.setDatasource(datasource, propertyId);
            lookup.setRequiredMessage(getMessage("datatypeMsg"));
            lookup.setRequired(true);
            lookup.setPageLength(15);
            Map<String, Object> options = new TreeMap<>();
            String mainMessagePack = AppConfig.getMessagesPack();
            for (String datatypeId : Datatypes.getIds()) {
                options.put(messages.getMessage(mainMessagePack, "Datatype." + datatypeId), datatypeId);
            }
            lookup.setOptionsMap(options);
            return lookup;
        }
    });
}
Also used : Datasource(com.haulmont.cuba.gui.data.Datasource) FieldGroup(com.haulmont.cuba.gui.components.FieldGroup) LookupField(com.haulmont.cuba.gui.components.LookupField) Component(com.haulmont.cuba.gui.components.Component) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

Component (com.haulmont.cuba.gui.components.Component)1 FieldGroup (com.haulmont.cuba.gui.components.FieldGroup)1 LookupField (com.haulmont.cuba.gui.components.LookupField)1 Datasource (com.haulmont.cuba.gui.data.Datasource)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1