Search in sources :

Example 1 with IExtensionRegistry

use of org.eclipse.scout.rt.shared.extension.IExtensionRegistry 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)

Example 2 with IExtensionRegistry

use of org.eclipse.scout.rt.shared.extension.IExtensionRegistry in project scout.rt by eclipse.

the class ContributionOnlyOneTemplateTest method testContributeToDtoInOnlyOneTemplate.

@Test
public void testContributeToDtoInOnlyOneTemplate() throws Exception {
    IExtensionRegistry extensionRegistry = BEANS.get(IExtensionRegistry.class);
    extensionRegistry.register(PropertyExtensionData.class, new ClassIdentifier(SecondUseOfTemplateBox.class, SecondStringInTemplate.class));
    doTest();
}
Also used : SecondStringInTemplate(org.eclipse.scout.rt.shared.extension.dto.fixture.AbstractTemplateBoxData.SecondStringInTemplate) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) SecondUseOfTemplateBox(org.eclipse.scout.rt.shared.extension.dto.fixture.OrigFormData.SecondUseOfTemplateBox) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Aggregations

IExtensionRegistry (org.eclipse.scout.rt.shared.extension.IExtensionRegistry)2 Test (org.junit.Test)2 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 ClassIdentifier (org.eclipse.scout.rt.platform.classid.ClassIdentifier)1 SecondStringInTemplate (org.eclipse.scout.rt.shared.extension.dto.fixture.AbstractTemplateBoxData.SecondStringInTemplate)1 SecondUseOfTemplateBox (org.eclipse.scout.rt.shared.extension.dto.fixture.OrigFormData.SecondUseOfTemplateBox)1