Search in sources :

Example 1 with Tab1

use of org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_TabBox.Tab1 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));
}
Also used : P_Seq(org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_TabBox.Tab1.P_TreeBox.P_Seq) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Holder(org.eclipse.scout.rt.platform.holders.Holder) Tab1(org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_TabBox.Tab1) P_Button2(org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_RadioButtonGroup.P_Button2) IFormFieldVisitor(org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IFormFieldVisitor (org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor)1 P_Button2 (org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_RadioButtonGroup.P_Button2)1 Tab1 (org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_TabBox.Tab1)1 P_Seq (org.eclipse.scout.rt.client.ui.form.fields.FormFieldVisibilityTest.P_GroupBox.P_TabBox.Tab1.P_TreeBox.P_Seq)1 Holder (org.eclipse.scout.rt.platform.holders.Holder)1 Test (org.junit.Test)1