Search in sources :

Example 1 with IValueField

use of org.eclipse.scout.rt.client.ui.form.fields.IValueField in project scout.rt by eclipse.

the class AbstractColumnTest method testValidColumn_EditField.

@Test
public void testValidColumn_EditField() throws Exception {
    TestVetoTable table = new TestVetoTable();
    table.addRowsByArray(new String[] { VALID, "a" });
    TestVetoTable.ValidateTestColumn testColumn = table.getValidateTestColumn();
    testColumn.setMandatory(true);
    IValueField field = (IValueField) testColumn.prepareEdit(table.getRow(0));
    assertEquals(VALID, field.getValue());
}
Also used : IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField) Test(org.junit.Test)

Example 2 with IValueField

use of org.eclipse.scout.rt.client.ui.form.fields.IValueField in project scout.rt by eclipse.

the class AbstractSequenceBox method getComparableValueFields.

/**
 * @return Comparable {@link IValueField}s with the same holder type than the first one
 */
private ArrayList<IValueField> getComparableValueFields() {
    ArrayList<IValueField> valueFieldList = new ArrayList<IValueField>();
    Class<?> sharedType = null;
    for (IFormField f : getFields()) {
        if (f instanceof IValueField) {
            IValueField v = (IValueField) f;
            Class<?> valueType = v.getHolderType();
            if (Comparable.class.isAssignableFrom(valueType) && (sharedType == null || valueType == sharedType)) {
                sharedType = valueType;
                valueFieldList.add(v);
            }
        }
    }
    return valueFieldList;
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) ArrayList(java.util.ArrayList) IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField)

Example 3 with IValueField

use of org.eclipse.scout.rt.client.ui.form.fields.IValueField in project scout.rt by eclipse.

the class AbstractSequenceBox method attachCheckFromToListeners.

/**
 * Attach a property change listener to all {@link IValueField}s with the same holder type than the first comparable
 * value type {@link IValueField}.
 */
private void attachCheckFromToListeners() {
    // fields with equal types
    ArrayList<IValueField> valueFieldList = getComparableValueFields();
    if (valueFieldList.size() >= 2) {
        final IValueField[] valueFields = valueFieldList.toArray(new IValueField[valueFieldList.size()]);
        for (int i = 0; i < valueFields.length; i++) {
            final int index = i;
            valueFields[index].addPropertyChangeListener(IValueField.PROP_VALUE, new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent e) {
                    if (getForm() != null && isAutoCheckFromTo()) {
                        checkFromTo(valueFields, index);
                    }
                }
            });
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField)

Example 4 with IValueField

use of org.eclipse.scout.rt.client.ui.form.fields.IValueField in project scout.rt by eclipse.

the class FindFieldByFormDataIdVisitor method visitField.

@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
    if (m_searchContextRootForm == null) {
        // auto-initialize search context
        // we assume the form field tree is traversed pre-order (i.e. first node itself, then its children)
        m_searchContextRootForm = field.getForm();
    }
    if (matchesAllParts(field)) {
        int fieldTypeRank = 0;
        if (m_searchContextRootForm != null) {
            IForm form = field.getForm();
            while (form != null && form != m_searchContextRootForm) {
                fieldTypeRank += 10;
                form = form.getOuterForm();
            }
        }
        if (field instanceof IValueField) {
        // fieldTypeRank is fine
        } else if (field instanceof ITableField) {
            fieldTypeRank += 1;
        } else if (!(field instanceof ICompositeField)) {
            fieldTypeRank += 2;
        } else {
            fieldTypeRank += 3;
        }
        // Compute the enclosing field path rank that is used as additional hint for determining the
        // best matching form field for the requested formId. Note: for compatibility reasons, the enclosing
        // field path is not enforced.
        int enclosingFieldPathRank = getEnclosingFieldPathRank(field);
        m_prioMap.put(new CompositeObject(fieldTypeRank, enclosingFieldPathRank), field);
    }
    return !m_prioMap.containsKey(PERFECT_VALUE_FIELD_MATCH_KEY);
}
Also used : ITableField(org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField) CompositeObject(org.eclipse.scout.rt.platform.util.CompositeObject) IForm(org.eclipse.scout.rt.client.ui.form.IForm) ICompositeField(org.eclipse.scout.rt.client.ui.form.fields.ICompositeField) IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField)

Example 5 with IValueField

use of org.eclipse.scout.rt.client.ui.form.fields.IValueField in project scout.rt by eclipse.

the class AbstractForm method doReset.

@Override
public void doReset() {
    setFormLoading(true);
    // reset values
    P_AbstractCollectingFieldVisitor v = new P_AbstractCollectingFieldVisitor() {

        @Override
        public boolean visitField(IFormField field, int level, int fieldIndex) {
            if (field instanceof IValueField) {
                IValueField f = (IValueField) field;
                f.resetValue();
            } else if (field instanceof IComposerField) {
                IComposerField f = (IComposerField) field;
                f.resetValue();
            }
            return true;
        }
    };
    try {
        visitFields(v);
        // init again
        initForm();
        // load again
        loadStateInternal();
    } catch (RuntimeException | PlatformError e) {
        throw BEANS.get(PlatformExceptionTranslator.class).translate(e).withContextInfo("form", getClass().getName());
    }
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) PlatformExceptionTranslator(org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator) IValueField(org.eclipse.scout.rt.client.ui.form.fields.IValueField) IComposerField(org.eclipse.scout.rt.client.ui.form.fields.composer.IComposerField)

Aggregations

IValueField (org.eclipse.scout.rt.client.ui.form.fields.IValueField)7 ICompositeField (org.eclipse.scout.rt.client.ui.form.fields.ICompositeField)2 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)2 CompositeObject (org.eclipse.scout.rt.platform.util.CompositeObject)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 Cell (org.eclipse.scout.rt.client.ui.basic.cell.Cell)1 ICell (org.eclipse.scout.rt.client.ui.basic.cell.ICell)1 HeaderCell (org.eclipse.scout.rt.client.ui.basic.table.HeaderCell)1 IHeaderCell (org.eclipse.scout.rt.client.ui.basic.table.IHeaderCell)1 IForm (org.eclipse.scout.rt.client.ui.form.IForm)1 IComposerField (org.eclipse.scout.rt.client.ui.form.fields.composer.IComposerField)1 ITableField (org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField)1 PlatformError (org.eclipse.scout.rt.platform.exception.PlatformError)1 PlatformExceptionTranslator (org.eclipse.scout.rt.platform.exception.PlatformExceptionTranslator)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 Test (org.junit.Test)1