Search in sources :

Example 1 with DefaultFormFieldInjection

use of org.eclipse.scout.rt.client.ui.form.DefaultFormFieldInjection in project scout.rt by eclipse.

the class AbstractCompositeField method initConfig.

@Override
protected void initConfig() {
    /*
     * call first super initConfig to ensure all properties are applied to the field only.
     * E.g. setEnabled(getConfiguredEnabled()) would enable/disable all children when called
     * after field creation. -> all fields would have the enabled state of the MainBox.
     */
    m_fields = CollectionUtility.emptyArrayList();
    m_movedFormFieldsByClass = new HashMap<Class<? extends IFormField>, IFormField>();
    m_fieldPropertyChangeListener = new P_FieldPropertyChangeListener();
    super.initConfig();
    // prepare injected fields
    DefaultFormFieldInjection injectedFields = null;
    List<Class<IFormField>> declaredFields = getConfiguredFields();
    List<Class<? extends IFormField>> configuredFields = new ArrayList<Class<? extends IFormField>>(declaredFields.size());
    for (Class<? extends IFormField> clazz : declaredFields) {
        if (ConfigurationUtility.isInjectFieldAnnotationPresent(clazz)) {
            if (injectedFields == null) {
                injectedFields = new DefaultFormFieldInjection(this);
            }
            injectedFields.addField(clazz);
        } else {
            configuredFields.add(clazz);
        }
    }
    try {
        List<IFormField> contributedFields = m_contributionHolder.getContributionsByClass(IFormField.class);
        if (injectedFields != null) {
            FormFieldInjectionThreadLocal.push(injectedFields);
        }
        FormFieldInjectionThreadLocal.pushContainerField(this);
        filterFieldsInternal(configuredFields);
        // create instances
        OrderedCollection<IFormField> fields = new OrderedCollection<IFormField>();
        for (Class<? extends IFormField> clazz : configuredFields) {
            IFormField f = ConfigurationUtility.newInnerInstance(this, clazz);
            fields.addOrdered(f);
        }
        // handle contributions
        fields.addAllOrdered(contributedFields);
        injectFieldsInternal(fields);
        // connect
        for (IFormField f : fields) {
            f.setParentFieldInternal(this);
        }
        m_fields = fields.getOrderedList();
        // attach a proxy controller to each child field in the group for: visible, saveNeeded
        for (IFormField f : m_fields) {
            f.addPropertyChangeListener(m_fieldPropertyChangeListener);
        }
    } finally {
        if (injectedFields != null) {
            m_formFieldReplacements = injectedFields.getReplacementMapping();
            FormFieldInjectionThreadLocal.pop(injectedFields);
        }
        FormFieldInjectionThreadLocal.popContainerField(this);
    }
    handleFieldVisibilityChanged();
}
Also used : DefaultFormFieldInjection(org.eclipse.scout.rt.client.ui.form.DefaultFormFieldInjection) ArrayList(java.util.ArrayList) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection)

Aggregations

ArrayList (java.util.ArrayList)1 DefaultFormFieldInjection (org.eclipse.scout.rt.client.ui.form.DefaultFormFieldInjection)1 OrderedCollection (org.eclipse.scout.rt.platform.util.collection.OrderedCollection)1