use of org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_InnerForm.MainBox in project scout.rt by eclipse.
the class FormFieldEnabledTest method testWrappedFormField.
@Test
public void testWrappedFormField() {
P_OuterForm frm = new P_OuterForm();
final AtomicReference<P_String> ref = new AtomicReference<>();
frm.visitFields(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
if (field instanceof P_String) {
ref.set((P_String) field);
}
return ref.get() == null;
}
});
P_String stringField = ref.get();
Assert.assertNotNull(stringField);
final AtomicInteger counter = new AtomicInteger(0);
stringField.visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
counter.incrementAndGet();
return true;
}
});
Assert.assertEquals(7, counter.intValue());
MainBox innerMainBox = frm.getFieldByClass(Wrapped.class).getInnerForm().getFieldByClass(MainBox.class);
final AtomicInteger counter2 = new AtomicInteger(0);
innerMainBox.visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField field, int level, int fieldIndex) {
counter2.incrementAndGet();
return true;
}
});
Assert.assertEquals(2, counter2.intValue());
}
Aggregations