Search in sources :

Example 1 with Widget

use of com.axelor.db.annotations.Widget in project axelor-open-suite by axelor.

the class ConfiguratorCreatorServiceImpl method completeSelection.

/**
 * Fill {@link MetaJsonField#selection} searching in java class code.
 *
 * @param metaField a meta field.
 * @param newField a meta json field.
 */
protected void completeSelection(MetaField metaField, MetaJsonField newField) {
    try {
        Field correspondingField = Class.forName(metaField.getMetaModel().getPackageName() + "." + metaField.getMetaModel().getName()).getDeclaredField(metaField.getName());
        Widget widget = correspondingField.getAnnotation(Widget.class);
        if (widget == null) {
            return;
        }
        String selection = widget.selection();
        if (!Strings.isNullOrEmpty(selection)) {
            newField.setSelection(selection);
        }
    } catch (ClassNotFoundException | NoSuchFieldException e) {
        TraceBackService.trace(e);
    }
}
Also used : MetaJsonField(com.axelor.meta.db.MetaJsonField) MetaField(com.axelor.meta.db.MetaField) Field(java.lang.reflect.Field) Widget(com.axelor.db.annotations.Widget)

Aggregations

Widget (com.axelor.db.annotations.Widget)1 MetaField (com.axelor.meta.db.MetaField)1 MetaJsonField (com.axelor.meta.db.MetaJsonField)1 Field (java.lang.reflect.Field)1