use of org.eclipse.scout.rt.client.ui.form.fields.AbstractCompositeField in project scout.rt by eclipse.
the class MoveFormFieldsHandler method findContainer.
protected ICompositeField findContainer(ICompositeField container, ClassIdentifier newModelContainerClassIdentifier, ICompositeField ignoredChildContainer) {
// 1. no new container defined. Hence do not move field into different container.
if (newModelContainerClassIdentifier == null) {
return container;
}
Class<?> newModelContainerClass = newModelContainerClassIdentifier.getLastSegment();
// 2. field is moved to root, i.e. into the main box
if (newModelContainerClass == IMoveModelObjectToRootMarker.class) {
return container.getForm().getRootGroupBox();
}
// 3. current container matches
if (newModelContainerClass.isInstance(container) && matchesClassIdentifier(container, newModelContainerClassIdentifier)) {
return container;
}
// 4. check current container's child composite fields
for (IFormField c : container.getFields()) {
if (newModelContainerClass.isInstance(c) && c instanceof ICompositeField && matchesClassIdentifier((ICompositeField) c, newModelContainerClassIdentifier)) {
return (ICompositeField) c;
}
}
// 5. visit child containers
for (IFormField c : container.getFields()) {
if (c == ignoredChildContainer || !(c instanceof ICompositeField)) {
continue;
}
ICompositeField recursiveContainer = findContainer((ICompositeField) c, newModelContainerClassIdentifier, container);
if (recursiveContainer != null) {
return recursiveContainer;
}
}
// 6. current container is a template field. Do not exit template scope
if (container instanceof AbstractCompositeField && ((AbstractCompositeField) container).isTemplateField()) {
return null;
}
// 7. continue search on parent container (without revisiting the current container)
ICompositeField parent = container.getParentField();
if (parent != null && parent != ignoredChildContainer) {
return findContainer(parent, newModelContainerClassIdentifier, container);
}
return null;
}
Aggregations