Search in sources :

Example 21 with ClassIdentifier

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

the class FormDataStatementBuilderTest method testTemplate1FieldData_temlateValueDefinition.

@Test
public void testTemplate1FieldData_temlateValueDefinition() {
    m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template1GroupBox.class, FormData.Template1GroupBox.TemplateText.class), "TEMPLATE1_TEXT", DataModelConstants.OPERATOR_EQ);
    assertEquals("  AND TEMPLATE1_TEXT=:__a1", m_builder.build(m_formData));
    assertNotNull(m_builder.getBindMap());
    assertEquals(1, m_builder.getBindMap().size());
    assertEquals(TEMPLATE1_TEXT, m_builder.getBindMap().get("__a1"));
}
Also used : AbstractFormData(org.eclipse.scout.rt.shared.data.form.AbstractFormData) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 22 with ClassIdentifier

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

the class FormDataStatementBuilderTest method testMasterTemplate1FieldData_temlateValueDefinition.

@Test
public void testMasterTemplate1FieldData_temlateValueDefinition() {
    m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template1GroupBox.class, AbstractTemplateFieldData.MasterTemplateGroupBox.class, AbstractMasterTemplateFieldData.MasterTemplateText.class), "MASTER_TEMPLATE1_TEXT", DataModelConstants.OPERATOR_EQ);
    assertEquals("  AND MASTER_TEMPLATE1_TEXT=:__a1", m_builder.build(m_formData));
    assertNotNull(m_builder.getBindMap());
    assertEquals(1, m_builder.getBindMap().size());
    assertEquals(MASTER_TEMPLATE1_TEXT, m_builder.getBindMap().get("__a1"));
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 23 with ClassIdentifier

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

the class FormDataStatementBuilderTest method testTemplate1andTemplate2FieldData_temlateValueDefinition.

@Test
public void testTemplate1andTemplate2FieldData_temlateValueDefinition() {
    m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template1GroupBox.class, FormData.Template1GroupBox.TemplateText.class), "TEMPLATE1_TEXT", DataModelConstants.OPERATOR_EQ);
    m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template2GroupBox.class, FormData.Template2GroupBox.TemplateText.class), "TEMPLATE2_TEXT", DataModelConstants.OPERATOR_LE);
    assertEquals("  AND TEMPLATE1_TEXT=:__a1  AND TEMPLATE2_TEXT<=:__a2", m_builder.build(m_formData));
    assertNotNull(m_builder.getBindMap());
    assertEquals(2, m_builder.getBindMap().size());
    assertEquals(TEMPLATE1_TEXT, m_builder.getBindMap().get("__a1"));
    assertEquals(TEMPLATE2_TEXT, m_builder.getBindMap().get("__a2"));
}
Also used : AbstractFormData(org.eclipse.scout.rt.shared.data.form.AbstractFormData) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 24 with ClassIdentifier

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

the class FormDataStatementBuilderTest method testMasterTemplate1PropertyData_temlateValueDefinition.

@Test
public void testMasterTemplate1PropertyData_temlateValueDefinition() {
    m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template1GroupBox.class, FormData.Template1GroupBox.MasterTemplateGroupBox.class, FormData.Template1GroupBox.MasterTemplateGroupBox.MasterTemplateProp.class), "MASTER_TEMPLATE1_PROP", DataModelConstants.OPERATOR_EQ);
    assertEquals("  AND MASTER_TEMPLATE1_PROP=:__a1", m_builder.build(m_formData));
    assertNotNull(m_builder.getBindMap());
    assertEquals(1, m_builder.getBindMap().size());
    assertEquals(MASTER_TEMPLATE1_PROPERTY, m_builder.getBindMap().get("__a1"));
}
Also used : AbstractFormData(org.eclipse.scout.rt.shared.data.form.AbstractFormData) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 25 with ClassIdentifier

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

the class BasicPartDefinition method accept.

/**
 * Computes whether this {@link BasicPartDefinition} takes part in building the filter criterion.
 *
 * @param formData
 *          the form data to be checked.
 * @return <code>true</code> if the properties in the form data are sufficient in order to append this part to the
 *         result statement This will result in a call to
 *         {@link BasicPartDefinition#createInstanceImpl(FormDataStatementBuilder, List, List, List, Map)} building
 *         that part.
 *         <p>
 *         Default accepts when any of the value of the valueType set is set (isValueSet) and has a non-null value in
 *         the form data
 */
public boolean accept(AbstractFormData formData) {
    Map<Integer, Map<String, AbstractFormFieldData>> fieldsBreathFirstMap = formData.getAllFieldsRec();
    Map<Integer, Map<String, AbstractPropertyData<?>>> propertiesBreathFirstMap = formData.getAllPropertiesRec();
    if (getValueTypeClassIdentifiers().length > 0) {
        for (ClassIdentifier valueType : getValueTypeClassIdentifiers()) {
            Object dataObject = formData.findFieldByClass(fieldsBreathFirstMap, valueType);
            if (dataObject instanceof AbstractFormFieldData) {
                AbstractValueFieldData<?> v = (dataObject instanceof AbstractValueFieldData<?> ? (AbstractValueFieldData<?>) dataObject : null);
                AbstractFormFieldData f = (AbstractFormFieldData) dataObject;
                if (f.isValueSet() && (v == null || v.getValue() != null)) {
                    return true;
                }
            }
            dataObject = formData.findPropertyByClass(propertiesBreathFirstMap, valueType);
            if (dataObject instanceof AbstractPropertyData<?>) {
                AbstractPropertyData<?> p = (AbstractPropertyData<?>) dataObject;
                if (p.isValueSet() && p.getValue() != null) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) AbstractValueFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractValueFieldData) AbstractPropertyData(org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData) Map(java.util.Map)

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