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());
}
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());
}
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());
}
}
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;
}
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();
}
Aggregations