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;
}
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;
}
Aggregations