Search in sources :

Example 16 with ClassIdentifier

use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.

the class FormDataStatementBuilderCheck method checkValueField.

protected void checkValueField(AbstractValueFieldData<?> v) {
    BasicPartDefinition part = null;
    for (BasicPartDefinition f : builder.getBasicPartDefinitions()) {
        if (part != null) {
            break;
        }
        for (ClassIdentifier t : f.getValueTypeClassIdentifiers()) {
            if (part != null) {
                break;
            }
            if (t.getLastSegment() == v.getClass()) {
                part = f;
            }
        }
    }
    if (part == null) {
        String name = fieldToName(v);
        String sqlColumnName = toSqlColumn(name);
        String sqlTemplate = "\"${sqlName}\"";
        String sql = sqlTemplate.replace("${sqlColumnName}", sqlColumnName);
        String op;
        Class<?> dataType = v.getHolderType();
        if (String.class.isAssignableFrom(dataType)) {
            op = "DataModelConstants.OPERATOR_CONTAINS";
        } else {
            op = "DataModelConstants.OPERATOR_EQ";
        }
        addBodyLine("setBasicDefinition(" + resolveImport(v.getClass()) + ".class," + sql + "," + op + ");");
    }
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier)

Example 17 with ClassIdentifier

use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.

the class ExtendFormWithDeepLinkingTest method testContributeOnlyToOneTemplateUsage.

@Test
public void testContributeOnlyToOneTemplateUsage() throws Exception {
    BEANS.get(IExtensionRegistry.class).register(ContributedTestField.class, new ClassIdentifier(TopFieldsBox.class, AbstractTemplateFieldsBox.class), null);
    MultiTemplateUsageForm form = new MultiTemplateUsageForm();
    assertTypes(form.getMainBox().getFields(), FirstTemplateBox.class, SecondTemplateBox.class, MainBoxStringField.class);
    // first template box
    FirstTemplateBox firstTemplateBox = form.getFirstTemplateBox();
    assertTypes(firstTemplateBox.getFields(), TopFieldsBox.class, MiddleStringField.class, BottomFieldsBox.class);
    assertTypes(firstTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, BottomStringField.class, ContributedTestField.class);
    assertTypes(firstTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    // second template box
    SecondTemplateBox secondTemplateBox = form.getSecondTemplateBox();
    assertTypes(secondTemplateBox.getFields(), TopFieldsBox.class, BottomFieldsBox.class);
    assertTypes(secondTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, BottomStringField.class, ContributedTestField.class);
    assertTypes(secondTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
}
Also used : FirstTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.FirstTemplateBox) TopFieldsBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateGroupsBox.TopFieldsBox) MultiTemplateUsageForm(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm) AbstractTemplateFieldsBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateFieldsBox) SecondTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.SecondTemplateBox) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Example 18 with ClassIdentifier

use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.

the class ExtendFormWithDeepLinkingTest method testExtendOnlyToOneTemplateUses.

@Test
public void testExtendOnlyToOneTemplateUses() throws Exception {
    BEANS.get(IExtensionRegistry.class).register(TemplateStringFieldExtension.class, new ClassIdentifier(TopFieldsBox.class, AbstractStringField.class), null);
    MultiTemplateUsageForm form = new MultiTemplateUsageForm();
    form.initForm();
    assertTypes(form.getMainBox().getFields(), FirstTemplateBox.class, SecondTemplateBox.class, MainBoxStringField.class);
    // first template box
    FirstTemplateBox firstTemplateBox = form.getFirstTemplateBox();
    assertTypes(firstTemplateBox.getFields(), TopFieldsBox.class, MiddleStringField.class, BottomFieldsBox.class);
    assertTypes(firstTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    assertTypes(firstTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    // second template box
    SecondTemplateBox secondTemplateBox = form.getSecondTemplateBox();
    assertTypes(secondTemplateBox.getFields(), TopFieldsBox.class, BottomFieldsBox.class);
    assertTypes(secondTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    assertTypes(secondTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    // behavior checks
    assertEquals("A", form.getFirstTemplateBox().getTopFieldsBox().getTopStringField().getValue());
    assertEquals("A", form.getFirstTemplateBox().getTopFieldsBox().getBottomStringField().getValue());
    assertNull(form.getMiddleStringField().getValue());
    assertNull(form.getFirstTemplateBox().getBottomFieldsBox().getTopStringField().getValue());
    assertNull(form.getFirstTemplateBox().getBottomFieldsBox().getBottomStringField().getValue());
    assertEquals("A", form.getSecondTemplateBox().getTopFieldsBox().getTopStringField().getValue());
    assertEquals("A", form.getSecondTemplateBox().getTopFieldsBox().getBottomStringField().getValue());
    assertNull(form.getSecondTemplateBox().getBottomFieldsBox().getTopStringField().getValue());
    assertNull(form.getSecondTemplateBox().getBottomFieldsBox().getBottomStringField().getValue());
}
Also used : FirstTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.FirstTemplateBox) TopFieldsBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateGroupsBox.TopFieldsBox) MultiTemplateUsageForm(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm) SecondTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.SecondTemplateBox) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) AbstractStringField(org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Example 19 with ClassIdentifier

use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.

the class MoveFormFieldTest method testMultiTemplateUsageFormMoveWithDeepLinkedTargetOverspecified.

@Test
public void testMultiTemplateUsageFormMoveWithDeepLinkedTargetOverspecified() throws Exception {
    BEANS.get(IExtensionRegistry.class).registerMove(new ClassIdentifier(MainBoxStringField.class), 15d, new ClassIdentifier(MultiTemplateUsageForm.class, MultiTemplateUsageForm.MainBox.class, SecondTemplateBox.class, TopFieldsBox.class));
    MultiTemplateUsageForm form = new MultiTemplateUsageForm();
    assertClasses(form.getMainBox().getFields(), FirstTemplateBox.class, SecondTemplateBox.class);
    // first template box
    FirstTemplateBox firstTemplateBox = form.getFirstTemplateBox();
    assertClasses(firstTemplateBox.getFields(), TopFieldsBox.class, MiddleStringField.class, BottomFieldsBox.class);
    assertClasses(firstTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    assertClasses(firstTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
    // second template box
    SecondTemplateBox secondTemplateBox = form.getSecondTemplateBox();
    assertClasses(secondTemplateBox.getFields(), TopFieldsBox.class, BottomFieldsBox.class);
    assertClasses(secondTemplateBox.getTopFieldsBox().getFields(), TopStringField.class, MainBoxStringField.class, BottomStringField.class);
    assertClasses(secondTemplateBox.getBottomFieldsBox().getFields(), TopStringField.class, BottomStringField.class);
}
Also used : FirstTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.FirstTemplateBox) MultiTemplateUsageForm(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm) TopFieldsBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateGroupsBox.TopFieldsBox) SecondTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.SecondTemplateBox) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) MainBoxStringField(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.MainBoxStringField) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Example 20 with ClassIdentifier

use of org.eclipse.scout.rt.platform.classid.ClassIdentifier in project scout.rt by eclipse.

the class MoveFormFieldTest method testMultiTemplateUsageFormMoveTopStringFieldInFirstTemplateBoxUsingOverspecifiedClassIdentifier.

@Test
public void testMultiTemplateUsageFormMoveTopStringFieldInFirstTemplateBoxUsingOverspecifiedClassIdentifier() throws Exception {
    BEANS.get(IExtensionRegistry.class).registerMove(new ClassIdentifier(MultiTemplateUsageForm.class, MultiTemplateUsageForm.MainBox.class, FirstTemplateBox.class, TopStringField.class), 30d);
    MultiTemplateUsageForm form = new MultiTemplateUsageForm();
    assertEquals(3, form.getMainBox().getFieldCount());
    assertSame(form.getFirstTemplateBox(), form.getMainBox().getFields().get(0));
    assertSame(form.getSecondTemplateBox(), form.getMainBox().getFields().get(1));
    assertSame(form.getMainBoxStringField(), form.getMainBox().getFields().get(2));
    // first template box
    FirstTemplateBox firstTemplateBox = form.getFirstTemplateBox();
    assertEquals(3, firstTemplateBox.getFieldCount());
    assertSame(firstTemplateBox.getTopFieldsBox(), firstTemplateBox.getFields().get(0));
    assertSame(form.getMiddleStringField(), firstTemplateBox.getFields().get(1));
    assertSame(firstTemplateBox.getBottomFieldsBox(), firstTemplateBox.getFields().get(2));
    // top fields box in first template box
    assertAbstractTemplateFieldsBox(firstTemplateBox.getTopFieldsBox(), false);
    assertAbstractTemplateFieldsBox(firstTemplateBox.getBottomFieldsBox(), false);
    // second template box
    SecondTemplateBox secondTemplateBox = form.getSecondTemplateBox();
    assertEquals(2, secondTemplateBox.getFieldCount());
    assertSame(secondTemplateBox.getTopFieldsBox(), secondTemplateBox.getFields().get(0));
    assertSame(secondTemplateBox.getBottomFieldsBox(), secondTemplateBox.getFields().get(1));
    // top fields box in first template box
    assertAbstractTemplateFieldsBox(secondTemplateBox.getTopFieldsBox(), true);
    assertAbstractTemplateFieldsBox(secondTemplateBox.getBottomFieldsBox(), true);
}
Also used : FirstTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.FirstTemplateBox) MultiTemplateUsageForm(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm) SecondTemplateBox(org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.SecondTemplateBox) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) TopStringField(org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateFieldsBox.TopStringField) IExtensionRegistry(org.eclipse.scout.rt.shared.extension.IExtensionRegistry) Test(org.junit.Test)

Aggregations

ClassIdentifier (org.eclipse.scout.rt.platform.classid.ClassIdentifier)31 Test (org.junit.Test)23 IExtensionRegistry (org.eclipse.scout.rt.shared.extension.IExtensionRegistry)11 MultiTemplateUsageForm (org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm)10 FirstTemplateBox (org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.FirstTemplateBox)10 SecondTemplateBox (org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.SecondTemplateBox)10 TopFieldsBox (org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateGroupsBox.TopFieldsBox)7 AbstractTemplateFieldsBox (org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateFieldsBox)4 AbstractFormData (org.eclipse.scout.rt.shared.data.form.AbstractFormData)4 AbstractStringField (org.eclipse.scout.rt.client.ui.form.fields.stringfield.AbstractStringField)3 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 TopStringField (org.eclipse.scout.rt.client.extension.ui.form.fixture.AbstractTemplateFieldsBox.TopStringField)2 MainBoxStringField (org.eclipse.scout.rt.client.extension.ui.form.fixture.MultiTemplateUsageForm.MainBox.MainBoxStringField)2 AbstractFormFieldData (org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData)2 AbstractValueFieldData (org.eclipse.scout.rt.shared.data.form.fields.AbstractValueFieldData)2 AbstractPropertyData (org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1