Search in sources :

Example 1 with SecondGroupBox

use of org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.Contribution2.SecondGroupBox in project scout.rt by eclipse.

the class NestedContributionTest method testNestedContribution.

@Test
public void testNestedContribution() throws Exception {
    // find the contribution that will be at the second position in a HashMap
    final Map<Class, Boolean> findOrder = new HashMap<>(2);
    findOrder.put(FirstGroupBox.class, Boolean.TRUE);
    findOrder.put(SecondGroupBox.class, Boolean.FALSE);
    final Iterator<Class> iterator = findOrder.keySet().iterator();
    // skip first;
    iterator.next();
    // will be the second element in the contribution map. The element to search (boolean field) must be a child contribution of this class.
    final Class second = iterator.next();
    final IExtensionRegistry registry = BEANS.get(IExtensionRegistry.class);
    registry.register(Contribution1.class);
    registry.register(Contribution2.class);
    // register the boolean field contribution into the second contribution (which is either FirstGroupBox or SecondGroupBox).
    registry.register(BooleanField.class, second);
    final MyForm frm = new MyForm();
    final MainBox mainBox = frm.getMainBox();
    assertNotNull(mainBox.getContribution(FirstGroupBox.class));
    assertNotNull(mainBox.getContribution(SecondGroupBox.class));
    assertNotNull(mainBox.getContribution(BooleanField.class));
}
Also used : MainBox(org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.MyForm.MainBox) AbstractBooleanField(org.eclipse.scout.rt.client.ui.form.fields.booleanfield.AbstractBooleanField) HashMap(java.util.HashMap) SecondGroupBox(org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.Contribution2.SecondGroupBox) FirstGroupBox(org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.Contribution1.FirstGroupBox) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 FirstGroupBox (org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.Contribution1.FirstGroupBox)1 SecondGroupBox (org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.Contribution2.SecondGroupBox)1 MainBox (org.eclipse.scout.rt.client.extension.ui.form.fields.NestedContributionTest.MyForm.MainBox)1 AbstractBooleanField (org.eclipse.scout.rt.client.ui.form.fields.booleanfield.AbstractBooleanField)1 IExtensionRegistry (org.eclipse.scout.rt.shared.extension.IExtensionRegistry)1 Test (org.junit.Test)1