use of org.eclipse.scout.rt.client.ui.form.fields.ICompositeField in project scout.rt by eclipse.
the class FindFieldByXmlIdsVisitor method visitField.
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
int fieldIdRank = getFieldIdRank(field);
if (fieldIdRank > 0) {
int enclosingFieldPathRank = getEnclosingFieldPathRank(field);
CompositeObject key;
if (field instanceof IValueField) {
key = new CompositeObject(fieldIdRank, enclosingFieldPathRank, 2);
} else if (!(field instanceof ICompositeField)) {
key = new CompositeObject(fieldIdRank, enclosingFieldPathRank, 1);
} else {
key = new CompositeObject(fieldIdRank, enclosingFieldPathRank, 0);
}
if (m_prioMap.containsKey(key)) {
m_ambiguousFieldKeys.add(key);
} else {
m_prioMap.put(key, field);
}
}
return true;
}
use of org.eclipse.scout.rt.client.ui.form.fields.ICompositeField in project scout.rt by eclipse.
the class FindFieldByXmlIdsVisitor method getEnclosingFieldPathRank.
/**
* @return Returns the rank of the given field's enclosing field path and the one the is requested by this visitor. A
* perfect match yields 0. Every mismatch reduces the match by 1. Hence the smallest (negative) number has the
* worst match.
*/
private int getEnclosingFieldPathRank(IFormField f) {
int rank = 0;
// the last segment is the field id, i.e. not part of the enclosing field path
int i = m_xmlFieldIds.length - 2;
List<ICompositeField> enclosingFieldList = f.getEnclosingFieldList();
Collections.reverse(enclosingFieldList);
for (ICompositeField p : enclosingFieldList) {
if (i >= 0 && p.getFieldId().equals(m_xmlFieldIds[i])) {
i--;
} else {
rank--;
}
}
return rank;
}
Aggregations