use of org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor 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());
}
use of org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor in project scout.rt by eclipse.
the class FormFieldVisibilityTest method testVisitFields.
@Test
public void testVisitFields() {
ICompositeField field = createFixture();
final AtomicInteger counter = new AtomicInteger(0);
field.visitFields(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
if (f.getClass().getName().startsWith(FormFieldVisibilityTest.class.getName())) {
// ignore the filter boxes of treebox and listbox
counter.incrementAndGet();
}
return true;
}
});
Assert.assertEquals(12, counter.intValue());
}
use of org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor in project scout.rt by eclipse.
the class FormFieldVisibilityTest method testVisitParents.
@Test
public void testVisitParents() {
ICompositeField root = createFixture();
final AtomicInteger counter01 = new AtomicInteger(0);
root.getFieldByClass(P_Seq.class).visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter01.incrementAndGet();
return true;
}
});
Assert.assertEquals(4, counter01.intValue());
final AtomicInteger counter02 = new AtomicInteger(0);
root.getFieldByClass(P_Button2.class).visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter02.incrementAndGet();
return true;
}
});
Assert.assertEquals(2, counter02.intValue());
final AtomicInteger counter03 = new AtomicInteger(0);
root.visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter03.incrementAndGet();
return true;
}
});
Assert.assertEquals(0, counter03.intValue());
final AtomicInteger counter04 = new AtomicInteger(0);
final Holder<Object> lastVisited = new Holder<>(Object.class);
root.getFieldByClass(P_Seq.class).visitParents(new IFormFieldVisitor() {
@Override
public boolean visitField(IFormField f, int level, int fieldIndex) {
counter04.incrementAndGet();
lastVisited.setValue(f);
return counter04.intValue() <= 1;
}
});
Assert.assertEquals(2, counter04.intValue());
Assert.assertSame(lastVisited.getValue(), root.getFieldByClass(Tab1.class));
}
Aggregations