Search in sources :

Example 11 with AbstractFormFieldData

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

the class AbstractFormData method getAllPropertiesRec.

/**
 * @return all properties of the form data and all its external template field data 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 (p1, p4)
 *   U
 *     E (p3)
 *     F
 *   V
 * B
 *   X (p2)
 *   Y
 *         </pre>
 *
 *         would be returned as p1, p4, p2, p3
 */
public Map<Integer, Map<String, /* qualified property id */
AbstractPropertyData<?>>> getAllPropertiesRec() {
    TreeMap<Integer, Map<String, AbstractPropertyData<?>>> breadthFirstMap = new TreeMap<Integer, Map<String, AbstractPropertyData<?>>>();
    HashMap<String, AbstractPropertyData<?>> rootMap = new HashMap<String, /* qualified field id */
    AbstractPropertyData<?>>();
    breadthFirstMap.put(0, rootMap);
    for (AbstractPropertyData<?> prop : getAllProperties()) {
        rootMap.put(prop.getClass().getSimpleName(), prop);
    }
    for (AbstractFormFieldData child : getFields()) {
        collectAllPropertiesRec(child, breadthFirstMap, 1, child.getFieldId() + FIELD_PATH_DELIM);
    }
    return breadthFirstMap;
}
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) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 12 with AbstractFormFieldData

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

the class AbstractFormData method findFieldByClass.

/**
 * Searches the given form field data in this form data as well as in all externally referenced template field data.
 *
 * @param breadthFirstMap
 *          The breadth-first search map as returned by {@link AbstractFormData#getAllFieldsRec()}. If
 *          <code>null</code>, a new map is created.
 * @param valueTypeIdentifier
 *          The class identifier to be searched in the form data.
 * @return Returns the form data's {@link AbstractFormFieldData} of the given valueType or <code>null</code>, if it
 *         does not exist.
 */
public AbstractFormFieldData findFieldByClass(Map<Integer, Map<String, AbstractFormFieldData>> breadthFirstMap, ClassIdentifier valueTypeIdentifier) {
    if (breadthFirstMap == null) {
        breadthFirstMap = getAllFieldsRec();
    }
    AbstractFormFieldData candidate = null;
    for (Map<String, AbstractFormFieldData> subMap : breadthFirstMap.values()) {
        for (Entry<String, AbstractFormFieldData> entry : subMap.entrySet()) {
            AbstractFormFieldData fd = entry.getValue();
            String fieldId = entry.getKey();
            if (matchesAllParts(valueTypeIdentifier, fieldId, fd)) {
                if (candidate != null) {
                    throw new ProcessingException("Found more than one field for class: [" + fd.getClass() + "]");
                }
                candidate = fd;
            }
        }
    }
    return candidate;
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

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