Search in sources :

Example 1 with P_String

use of org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_GroupBox.P_TabBox.Tab1.P_TreeBox.P_Seq.P_String 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());
}
Also used : MainBox(org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_InnerForm.MainBox) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) P_String(org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_GroupBox.P_TabBox.Tab1.P_TreeBox.P_Seq.P_String) AtomicReference(java.util.concurrent.atomic.AtomicReference) IFormFieldVisitor(org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 IFormFieldVisitor (org.eclipse.scout.rt.client.ui.form.IFormFieldVisitor)1 P_String (org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_GroupBox.P_TabBox.Tab1.P_TreeBox.P_Seq.P_String)1 MainBox (org.eclipse.scout.rt.client.ui.form.fields.FormFieldEnabledTest.P_InnerForm.MainBox)1 Test (org.junit.Test)1