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