Search in sources :

Example 6 with ICompositeField

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;
}
Also used : CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) ICompositeField(org.eclipse.scout.rt.client.ui.form.fields.ICompositeField) IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField)

Example 7 with ICompositeField

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;
}
Also used : ICompositeField(org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)

Aggregations

ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)7 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)2 IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)2 CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)2 P_InnerField (org.eclipse.scout.rt.client.extension.ui.form.MoveFormFieldTest.P_GroupBoxWithOneField.P_InnerField)1 IForm (org.eclipse.scout.rt.client.ui.form.IForm)1 AbstractCompositeField (org.eclipse.scout.rt.client.ui.form.fields.AbstractCompositeField)1 AbstractGroupBox (org.eclipse.scout.rt.client.ui.form.fields.groupbox.AbstractGroupBox)1 ITableField (org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField)1 Test (org.junit.Test)1