Search in sources :

Example 6 with ClassIdentifier

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

the class MoveFormFieldTest method testMultiTemplateUsageFormMoveWithDeepLinkedTarget.

@Test
public void testMultiTemplateUsageFormMoveWithDeepLinkedTarget() throws Exception {
    BEANS.get(IExtensionRegistry.class).registerMove(new ClassIdentifier(MainBoxStringField.class), 15d, new ClassIdentifier(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) 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) 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 7 with ClassIdentifier

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

the class FormDataStatementBuilderTest method testTemplate1PropertyData_temlateValueDefinition.

@Test
public void testTemplate1PropertyData_temlateValueDefinition() {
    m_builder.setBasicDefinition(new ClassIdentifier(FormData.Template1GroupBox.class, FormData.Template1GroupBox.TemplateProp.class), "TEMPLATE1_PROP", DataModelConstants.OPERATOR_EQ);
    assertEquals("  AND TEMPLATE1_PROP=:__a1", m_builder.build(m_formData));
    assertNotNull(m_builder.getBindMap());
    assertEquals(1, m_builder.getBindMap().size());
    assertEquals(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 8 with ClassIdentifier

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

the class BasicPartDefinition method createInstance.

/**
 * Override this method to intercept and change part instance properties such as values, operation type, etc.<br>
 * Sometimes it is convenient to set the operation to {@link DataModelConstants#OPERATOR_NONE} which uses the
 * attribute itself as the complete statement part.
 *
 * @param builder
 * @param formData
 *          the form data to be checked.
 * @return the result EntityContribution. null if that part is to be ignored
 *         <p>
 *         normally calls
 *         {@link FormDataStatementBuilder#createSqlPart(Integer, String, int, List, List, boolean, Map)}
 *         <p>
 *         Can make use of alias markers such as @Person@.LAST_NAME, these are resolved in the
 *         {@link FormDataStatementBuilder}
 *         <p>
 *         Only additional bind values - other than the bindValues passed to createStatementPart - must be added using
 *         {@link FormDataStatementBuilder#addBind(String, Object)}
 */
public EntityContribution createInstance(FormDataStatementBuilder builder, AbstractFormData formData, Map<String, String> parentAliasMap) {
    Map<Integer, Map<String, AbstractFormFieldData>> fieldsBreathFirstMap = formData.getAllFieldsRec();
    Map<Integer, Map<String, AbstractPropertyData<?>>> propertiesBreathFirstMap = formData.getAllPropertiesRec();
    ClassIdentifier[] valueTypes = getValueTypeClassIdentifiers();
    /**
     * the form data objects containing the runtime values {@link AbstractFormFieldData} and
     * {@link AbstractPropertyData}
     */
    ArrayList<Object> valueDatas = new ArrayList<Object>(valueTypes.length);
    /**
     * by default the names "a", "b", "c", ... represent the bindValues in the same order as the values
     */
    ArrayList<String> bindNames = new ArrayList<String>(valueTypes.length);
    /**
     * the values of the {@link AbstractFormFieldData}s and {@link AbstractPropertyData}s in the same order
     */
    ArrayList<Object> bindValues = new ArrayList<Object>(valueTypes.length);
    for (int i = 0; i < valueTypes.length; i++) {
        if (AbstractFormFieldData.class.isAssignableFrom(valueTypes[i].getLastSegment())) {
            AbstractFormFieldData field = formData.findFieldByClass(fieldsBreathFirstMap, valueTypes[i]);
            valueDatas.add(field);
            bindNames.add("" + (char) (('a') + i));
            if (field instanceof AbstractValueFieldData<?>) {
                bindValues.add(((AbstractValueFieldData<?>) field).getValue());
            } else {
                bindValues.add(null);
            }
        } else if (AbstractPropertyData.class.isAssignableFrom(valueTypes[i].getLastSegment())) {
            AbstractPropertyData<?> property = formData.findPropertyByClass(propertiesBreathFirstMap, valueTypes[i]);
            valueDatas.add(property);
            bindNames.add("" + (char) (('a') + i));
            bindValues.add(property.getValue());
        } else {
            valueDatas.add(null);
            bindNames.add("" + (char) (('a') + i));
            bindValues.add(null);
        }
    }
    // 
    String wherePart = createInstanceImpl(builder, valueDatas, bindNames, bindValues, parentAliasMap);
    return EntityContribution.create(wherePart);
}
Also used : AbstractFormFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractFormFieldData) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) ArrayList(java.util.ArrayList) AbstractValueFieldData(org.eclipse.scout.rt.shared.data.form.fields.AbstractValueFieldData) AbstractPropertyData(org.eclipse.scout.rt.shared.data.form.properties.AbstractPropertyData) Map(java.util.Map)

Example 9 with ClassIdentifier

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

the class ClassIdentifierTest method testConvertClassArray_nullClasses.

@Test
public void testConvertClassArray_nullClasses() {
    ClassIdentifier[] cids = ClassIdentifier.convertClassArrayToClassIdentifierArray(String.class, null, Integer.class);
    assertNotNull(cids);
    assertEquals(2, cids.length);
    assertArrayEquals(new ClassIdentifier[] { new ClassIdentifier(String.class), new ClassIdentifier(Integer.class) }, cids);
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 10 with ClassIdentifier

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

the class ClassIdentifierTest method testCreateWithContextOnly.

@Test
public void testCreateWithContextOnly() {
    ClassIdentifier cid = new ClassIdentifier(String.class);
    ClassIdentifier cid2 = new ClassIdentifier(cid);
    ClassIdentifier cid3 = new ClassIdentifier(cid, (Class[]) null);
    assertNotSame(cid, cid2);
    assertNotSame(cid, cid3);
    assertEquals(cid, cid2);
    assertEquals(cid, cid3);
    assertArrayEquals(new Class[] { String.class }, cid2.getClasses());
    assertArrayEquals(new Class[] { String.class }, cid3.getClasses());
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) 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