/** Checks the uniqueness in ID space when changing parent. */ private static void checkIdSpacesDown(Component comp, Component newparent) { final IdSpace is = spaceOwnerNoVirtual(newparent); //exclude virtual IdSpace //for checking, it is better NOT to ignore virtual IdSpace //but, for better performance, we don't. if (is != null) checkIdSpacesDown(comp, is); }
private static IdSpace getSpaceOwnerOfParent(Component comp) { final Component parent = comp.getParent(); return parent != null ? spaceOwnerNoVirtual(parent) : //ignore virtual IdSpace comp.getPage(); }
/** * Checks the parent-child relation. * Notice it will create parent._chdinf * @param parent the parent (will-be). It may be null. * @param child the child (will-be). It cannot be null. */ private static void checkParentChild(Component parent, Component child) throws UiException { if (child == null) throw new UiException("Child cannot be null"); if (parent != null) { final AbstractComponent acp = (AbstractComponent) parent; if (acp.initChildInfo().inAdding(child)) return; //check only once if (Components.isAncestor(child, parent)) throw new UiException("A child cannot be a parent of its ancestor: " + child); if (!acp.isChildable()) throw new UiException("Child not allowed in " + parent.getClass().getName()); final Page parentpg = parent.getPage(), childpg = child.getPage(); if (parentpg != null && childpg != null && parentpg.getDesktop() != childpg.getDesktop()) throw new UiException("The parent and child must be in the same desktop: " + parent); final Component oldparent = child.getParent(); if (spaceOwnerNoVirtual(parent) != (oldparent != null ? spaceOwnerNoVirtual(oldparent) : childpg)) checkIdSpacesDown(child, parent); } else { final Page childpg = child.getPage(); if (childpg != null) checkDetach(childpg); } }