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