Search in sources :

Example 6 with AbstractFormFieldData

use of org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData in project scout.rt by eclipse.

the class AbstractFormData method collectAllPropertiesRec.

private void collectAllPropertiesRec(AbstractFormFieldData field, Map<Integer, /* level */
Map<String, /* qualified field id */
AbstractPropertyData<?>>> breadthFirstMap, int level, String prefix) {
    Map<String, AbstractPropertyData<?>> /* qualified field id */
    subMap = breadthFirstMap.get(level);
    if (subMap == null) {
        subMap = new HashMap<String, /* qualified field id */
        AbstractPropertyData<?>>();
        breadthFirstMap.put(level, subMap);
    }
    for (AbstractPropertyData<?> prop : field.getAllProperties()) {
        subMap.put(prefix + prop.getClass().getSimpleName(), prop);
    }
    for (AbstractFormFieldData child : field.getFields()) {
        collectAllPropertiesRec(child, breadthFirstMap, level + 1, prefix + child.getFieldId() + FIELD_PATH_DELIM);
    }
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) AbstractPropertyData(org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData)

Example 7 with AbstractFormFieldData

use of org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData in project scout.rt by eclipse.

the class BasicPartDefinition method accept.

/**
 * Computes whether this {@link BasicPartDefinition} takes part in building the filter criterion.
 *
 * @param formData
 *          the form data to be checked.
 * @return <code>true</code> if the properties in the form data are sufficient in order to append this part to the
 *         result statement This will result in a call to
 *         {@link BasicPartDefinition#createInstanceImpl(FormDataStatementBuilder, List, List, List, Map)} building
 *         that part.
 *         <p>
 *         Default accepts when any of the value of the valueType set is set (isValueSet) and has a non-null value in
 *         the form data
 */
public boolean accept(AbstractFormData formData) {
    Map<Integer, Map<String, AbstractFormFieldData>> fieldsBreathFirstMap = formData.getAllFieldsRec();
    Map<Integer, Map<String, AbstractPropertyData<?>>> propertiesBreathFirstMap = formData.getAllPropertiesRec();
    if (getValueTypeClassIdentifiers().length > 0) {
        for (ClassIdentifier valueType : getValueTypeClassIdentifiers()) {
            Object dataObject = formData.findFieldByClass(fieldsBreathFirstMap, valueType);
            if (dataObject instanceof AbstractFormFieldData) {
                AbstractValueFieldData<?> v = (dataObject instanceof AbstractValueFieldData<?> ? (AbstractValueFieldData<?>) dataObject : null);
                AbstractFormFieldData f = (AbstractFormFieldData) dataObject;
                if (f.isValueSet() && (v == null || v.getValue() != null)) {
                    return true;
                }
            }
            dataObject = formData.findPropertyByClass(propertiesBreathFirstMap, valueType);
            if (dataObject instanceof AbstractPropertyData<?>) {
                AbstractPropertyData<?> p = (AbstractPropertyData<?>) dataObject;
                if (p.isValueSet() && p.getValue() != null) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) AbstractValueFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractValueFieldData) AbstractPropertyData(org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData) Map(java.util.Map)

Example 8 with AbstractFormFieldData

use of org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData in project scout.rt by eclipse.

the class AbstractFormData method collectAllFieldsRec.

private static void collectAllFieldsRec(AbstractFormFieldData field, Map<Integer, /* level */
Map<String, /* qualified field id */
AbstractFormFieldData>> breadthFirstMap, int level, String prefix, boolean isContributionTopLevelContainer) {
    Map<String, AbstractFormFieldData> /* qualified field id */
    subMap = breadthFirstMap.get(level);
    if (subMap == null) {
        subMap = new HashMap<String, /* qualified field id */
        AbstractFormFieldData>();
        breadthFirstMap.put(level, subMap);
    }
    boolean isTopLevel = field.getClass().getDeclaringClass() == null;
    String fieldId = null;
    if (isTopLevel || isContributionTopLevelContainer) {
        fieldId = FormDataUtility.getFieldDataId(field);
    } else {
        fieldId = field.getFieldId();
    }
    if (!isContributionTopLevelContainer) {
        subMap.put(prefix + fieldId, field);
    }
    String fieldPrefix = prefix;
    if (!isContributionTopLevelContainer) {
        fieldPrefix = prefix + fieldId + FIELD_PATH_DELIM;
    }
    collectFieldDatasInContributions(field, breadthFirstMap, fieldPrefix);
    for (AbstractFormFieldData child : field.getFields()) {
        collectAllFieldsRec(child, breadthFirstMap, level + 1, fieldPrefix, false);
    }
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData)

Example 9 with AbstractFormFieldData

use of org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData in project scout.rt by eclipse.

the class AbstractFormData method initConfig.

@Override
protected void initConfig() {
    // add properties
    List<Class<AbstractPropertyData>> configuredPropertyDatas = getConfiguredPropertyDatas();
    Map<Class<? extends AbstractPropertyData>, AbstractPropertyData> propMap = new HashMap<Class<? extends AbstractPropertyData>, AbstractPropertyData>(configuredPropertyDatas.size());
    for (Class<AbstractPropertyData> propertyDataClazz : configuredPropertyDatas) {
        AbstractPropertyData p = ConfigurationUtility.newInnerInstance(this, propertyDataClazz);
        propMap.put(p.getClass(), p);
    }
    if (!propMap.isEmpty()) {
        m_propertyMap = propMap;
    }
    // add fields
    List<Class<? extends AbstractFormFieldData>> formFieldDataClazzes = getConfiguredFieldDatas();
    m_fieldMap = new HashMap<Class<? extends AbstractFormFieldData>, AbstractFormFieldData>(formFieldDataClazzes.size());
    Map<Class<?>, Class<? extends AbstractFormFieldData>> replacements = ConfigurationUtility.getReplacementMapping(formFieldDataClazzes);
    if (!replacements.isEmpty()) {
        m_fieldDataReplacements = replacements;
    }
    for (Class<? extends AbstractFormFieldData> formFieldDataClazz : formFieldDataClazzes) {
        AbstractFormFieldData f = ConfigurationUtility.newInnerInstance(this, formFieldDataClazz);
        m_fieldMap.put(f.getClass(), f);
    }
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) HashMap(java.util.HashMap) AbstractPropertyData(org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData)

Example 10 with AbstractFormFieldData

use of org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData in project scout.rt by eclipse.

the class AbstractFormData method getAllFieldsRec.

/**
 * @return all fields of the form data and all its external template field datas in a map with qualified ids<br>
 *         The array of returned fields is the result of a top-down breadth-first tree traversal
 *         <p>
 *         Example:
 *
 *         <pre>
 * A
 *   U
 *     E
 *     F
 *   V
 * B
 *   X
 *   Y
 *         </pre>
 *
 *         would be returned as A B U V X Y E F
 */
public Map<Integer, Map<String, /* qualified field id */
AbstractFormFieldData>> getAllFieldsRec() {
    TreeMap<Integer, Map<String, AbstractFormFieldData>> breadthFirstMap = new TreeMap<Integer, Map<String, AbstractFormFieldData>>();
    for (AbstractFormFieldData child : getFields()) {
        collectAllFieldsRec(child, breadthFirstMap, 0, "", false);
    }
    collectFieldDatasInContributions(this, breadthFirstMap, "");
    return breadthFirstMap;
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

AbstractFormFieldData (org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData)12 Map (java.util.Map)7 HashMap (java.util.HashMap)6 AbstractPropertyData (org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData)5 TreeMap (java.util.TreeMap)2 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)2 FindFieldByFormDataIdVisitor (org.eclipse.scout.rt.client.ui.form.internal.FindFieldByFormDataIdVisitor)2 FormDataPropertyFilter (org.eclipse.scout.rt.client.ui.form.internal.FormDataPropertyFilter)2 ClassIdentifier (org.eclipse.scout.rt.platform.classid.ClassIdentifier)2 AbstractValueFieldData (org.eclipse.scout.rt.shared.data.form.fields.AbstractValueFieldData)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AbstractFormField (org.eclipse.scout.rt.client.ui.form.fields.AbstractFormField)1 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 Holder (org.eclipse.scout.rt.platform.holders.Holder)1 IHolder (org.eclipse.scout.rt.platform.holders.IHolder)1 IPropertyHolder (org.eclipse.scout.rt.shared.data.form.IPropertyHolder)1