Search in sources :

Example 1 with InjectFieldTo

use of org.eclipse.scout.rt.platform.extension.InjectFieldTo in project scout.rt by eclipse.

the class DefaultFormFieldInjection method addField.

public void addField(Class<? extends IFormField> fieldClass) {
    if (fieldClass == null) {
        throw new IllegalArgumentException("fieldClass must not be null");
    }
    Replace replace = fieldClass.getAnnotation(Replace.class);
    InjectFieldTo injectFieldTo = fieldClass.getAnnotation(InjectFieldTo.class);
    if (replace == null && injectFieldTo == null) {
        LOG.warn("Ignoring field [{}] since neither @{} nor @{} is declared.", fieldClass, InjectFieldTo.class.getSimpleName(), Replace.class.getSimpleName());
        return;
    }
    if (replace != null && injectFieldTo != null) {
        LOG.warn("@{} annotation is ignored since @{} is available as well on class [{}]. You should remove one of both annotations.", InjectFieldTo.class.getSimpleName(), Replace.class.getSimpleName(), fieldClass);
    } else if (injectFieldTo != null && !ICompositeField.class.isAssignableFrom(injectFieldTo.value())) {
        LOG.warn("Ignoring field [{}] since it is not injected into an {}, but @{}({})", fieldClass, ICompositeField.class.getSimpleName(), InjectFieldTo.class.getSimpleName(), injectFieldTo.value());
        return;
    }
    m_injectedFieldList.add(fieldClass);
    m_injectingFields = null;
    m_replacingFields = null;
}
Also used : Replace(org.eclipse.scout.rt.platform.Replace) InjectFieldTo(org.eclipse.scout.rt.platform.extension.InjectFieldTo) ICompositeField(org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)

Aggregations

ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)1 Replace (org.eclipse.scout.rt.platform.Replace)1 InjectFieldTo (org.eclipse.scout.rt.platform.extension.InjectFieldTo)1