/*package*/ void moveRoot(Component comp, Component refRoot) { final AbstractComponent nc = (AbstractComponent) comp; if (!isMyRoot(comp) || nc._next == refRoot/*nothing changed*/) return; //detach nc setNext(nc._prev, nc._next); setPrev(nc._next, nc._prev); nc._next = nc._prev = null; --_nRoot; //add if (refRoot != null) { final AbstractComponent ref = (AbstractComponent) refRoot; setNext(nc, ref); setPrev(nc, ref._prev); setNext(ref._prev, nc); setPrev(ref, nc); ++_nRoot; } else { addRoot(nc); //add to end } }
/** The same as {@link #getFellow(String)}. * In other words, the recurse parameter is not applicable. * @since 5.0.0 */ public Component getFellow(String compId, boolean recurse) throws ComponentNotFoundException { return getFellow(compId); }
/** The same as {@link #getFellowIfAny(String)}. * In other words, the recurse parameter is not applicable. * @since 5.0.0 */ public Component getFellowIfAny(String compId, boolean recurse) { return getFellowIfAny(compId); }
/*package*/ void removeRoot(Component comp) { //Note: when AbstractComponent.setPage0 is called, parent is already //null. Thus, we have to check if it is a root component if (isMyRoot(comp)) { final AbstractComponent oc = (AbstractComponent) comp; setNext(oc._prev, oc._next); setPrev(oc._next, oc._prev); oc._next = oc._prev = null; --_nRoot; } }
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); init(); //read children for (AbstractComponent q = null;;) { final AbstractComponent child = (AbstractComponent) s.readObject(); if (child == null) { _lastRoot = q; break; //no more } if (q != null) q._next = child; else _firstRoot = child; child._prev = q; child._page = this; q = child; } fixFellows(getRoots()); }
private final void fixFellows(Collection<Component> c) { for (Component comp : c) { final String compId = comp.getId(); if (compId.length() > 0) addFellow(comp); if (!(comp instanceof IdSpace)) fixFellows(comp.getChildren()); //recursive } }
if (_page != null) { if (bRoot) ((AbstractPage) _page).removeRoot(this); if (page == null && ((DesktopCtrl) _page.getDesktop()).removeComponent(this, true) && !(this instanceof StubComponent)) //Bug ZK-1452: don't need to reset StubComponent's uuid ((AbstractPage) _page).addRoot(this); //Not depends on uuid final Desktop desktop = _page.getDesktop(); if (oldpage == null) {
/** The same as {@link #hasFellow(String)}. * In other words, the recurse parameter is not applicable. * @since 5.0.0 */ public boolean hasFellow(String compId, boolean recurse) { return hasFellow(compId); }
protected AbstractPage() { init(); }
private static void addFellow(Component comp, IdSpace owner) { if (owner instanceof Component) ((AbstractComponent) owner).bindToIdSpace(comp); else if (owner instanceof Page) ((AbstractPage) owner).addFellow(comp); if (owner == null && comp instanceof ShadowElement) addToShadowIdMap(comp); }
public void destroy() { Configuration config = WebApps.getCurrent().getConfiguration(); for (Component root: this.getRoots()) { config.invokeCallback("destroy", root); } super.destroy(); try { if (_ips != null) { final List<Interpreter> ips = new ArrayList<Interpreter>(_ips.values()); _ips.clear(); _ips = null; //not just clear since it is better to NPE than memory leak for (Interpreter ip : ips) { try { ip.destroy(); } catch (Throwable ex) { log.warn("Failed to destroy " + ip, ex); } } } } catch (Throwable ex) { //avoid racing log.warn("Failed to clean up interpreters of " + this, ex); } //theoretically, the following is not necessary, but, to be safe... _desktop = null; _owner = null; _listeners = null; _resolvers = null; _mappers = null; _attrs.getAttributes().clear(); }