Search in sources :

Example 11 with ClassIdentifier

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

the class ClassIdentifierTest method testAbstractClass.

@Test
public void testAbstractClass() {
    ClassIdentifier cid = new ClassIdentifier(AbstractTemplate.class);
    assertArrayEquals(new Class[] { AbstractTemplate.class }, cid.getClasses());
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 12 with ClassIdentifier

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

the class ClassIdentifierTest method testCreateWithContextAndCalsses.

@Test
public void testCreateWithContextAndCalsses() {
    ClassIdentifier cid = new ClassIdentifier(String.class);
    ClassIdentifier cid2 = new ClassIdentifier(cid, Long.class, Boolean.class);
    assertNotSame(cid, cid2);
    assertArrayEquals(new Class[] { String.class, Long.class, Boolean.class }, cid2.getClasses());
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier) Test(org.junit.Test)

Example 13 with ClassIdentifier

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

the class AbstractMoveModelObjectHandler method moveModelObjects.

public void moveModelObjects() {
    // collect all model objects and move descriptors
    List<ORDERED> allModelObject = collectAllModelObjects();
    Set<MoveDescriptor<ORDERED>> moveDescriptors = collectMoveDescriptors(allModelObject);
    if (CollectionUtility.isEmpty(moveDescriptors)) {
        return;
    }
    StringBuilder sb = new StringBuilder();
    for (MoveDescriptor<ORDERED> moveDescriptor : moveDescriptors) {
        ORDERED modelObject = moveDescriptor.getModel();
        ORDERED oldParent = getParent(modelObject);
        Class<?> newContainer = null;
        ClassIdentifier newContainerIdentifer = moveDescriptor.getNewContainerIdentifer();
        if (newContainerIdentifer != null) {
            if (newContainerIdentifer.size() > 1) {
                throw new IllegalExtensionException("multi-segment move target class identifier are not supported by this handler. " + moveDescriptor);
            }
            newContainer = newContainerIdentifer.getLastSegment();
        }
        if (oldParent == null && (newContainer == null || newContainer == IMoveModelObjectToRootMarker.class)) {
            // 1. model object is in root list and should stay there -> just update order without sorting the list. The method expects, that the top level
            // list is sorted by the caller.
            applyOrder(moveDescriptor, modelObject);
        } else if (oldParent != null && newContainer == IMoveModelObjectToRootMarker.class) {
            // 2. model object is not in root list, but should be moved into it
            removeChild(oldParent, modelObject);
            applyOrder(moveDescriptor, modelObject);
            m_rootModelObjects.addOrdered(modelObject);
        } else if (newContainer == null) {
            // 3. model object remains in its current container -> just update order and sort items
            applyOrder(moveDescriptor, modelObject);
            sortChildren(oldParent);
        } else {
            // 4. model object is moved into another container
            // find new parent
            ORDERED newParent = null;
            for (ORDERED a : allModelObject) {
                if (newContainer.isInstance(a) && a != modelObject) {
                    newParent = a;
                    break;
                }
            }
            if (newParent == null) {
                if (sb.length() == 0) {
                    sb.append("Invalid ").append(m_modelObjectTypeName).append(" move commands:");
                }
                sb.append("  \n").append(m_modelObjectTypeName).append(" '").append(modelObject).append("' cannot be moved into container '").append(newParent).append("'");
                continue;
            }
            // remove from old parent
            if (oldParent == null) {
                // remove model object from root list
                m_rootModelObjects.remove(modelObject);
            } else {
                // remove model object from old parent
                removeChild(oldParent, modelObject);
            }
            // apply order and add to new parent
            applyOrder(moveDescriptor, modelObject);
            addChild(newParent, modelObject);
        }
    }
    if (sb.length() > 0) {
        throw new IllegalArgumentException(sb.toString());
    }
}
Also used : ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier)

Example 14 with ClassIdentifier

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

the class ExtensionScope method createGlobalScope.

/**
 * Creates a new global scope for the given class identifiers.
 */
protected Map<Class<?>, Set<ScopeItem>> createGlobalScope(Collection<ClassIdentifier> classIdentifiers, boolean topDownStrategy) {
    Map<Class<?>, Set<ScopeItem>> scopeItems = new HashMap<Class<?>, Set<ScopeItem>>(classIdentifiers.size());
    for (ClassIdentifier identifier : classIdentifiers) {
        ScopeItem item = new ScopeItem(identifier, topDownStrategy);
        addCurrentItemSegment(scopeItems, item);
    }
    return scopeItems;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ClassIdentifier(org.eclipse.scout.rt.platform.classid.ClassIdentifier)

Example 15 with ClassIdentifier

use of org.eclipse.scout.rt.platform.classid.ClassIdentifier 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

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