protected Component[] filterOutShadows(Component parent, Component[] items) { boolean hasShadow = checkShadowElementAndCreateSubChildren(parent); // check children with shadow for Bug ZK-2868 for (Component item : items) { checkShadowElementAndCreateSubChildren(item); } return hasShadow ? ShadowElementsCtrl.filterOutShadows(items) : items; }
public void afterHostChildRemoved(Component child) { if (log.isDebugEnabled()) { log.debug("afterHostChildRemoved " + child + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); } }
/**package*/ Map<Component, Integer> getIndexCacheMap() { return (Map<Component, Integer>) ShadowElementsCtrl.getDistributedIndexInfo(); }
if (host == null) throw new UiException("Host cannot be null [" + this + "]"); Object shadowInfo = ShadowElementsCtrl.getCurrentInfo(); try { ShadowElementsCtrl.setCurrentInfo(this); compose(host); } finally { ShadowElementsCtrl.setCurrentInfo(shadowInfo);
/**package*/ void destroyIndexCacheMap() { ShadowElementsCtrl.setDistributedIndexInfo(null); }
public void afterHostChildAdded(Component child, int indexOfChild) { if (log.isDebugEnabled()) { log.debug("afterHostChildAdded " + child + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); if (currentInfo instanceof HtmlShadowElement) { // added as my child in our control code if (currentInfo == this) { if (node != null) { try { ShadowElementsCtrl.setCurrentInfo(node); asShadow(node).afterHostChildAdded(child, indexOfChild); } finally { ShadowElementsCtrl.setCurrentInfo(currentInfo); // reset
/**package*/ Map<Component, Integer> initIndexCacheMap() { Map<Component, Integer> distributedIndexInfo = getIndexCacheMap(); if (distributedIndexInfo == null) { distributedIndexInfo = new HashMap<Component, Integer>(getChildren().size()); ShadowElementsCtrl.setDistributedIndexInfo(distributedIndexInfo); } return distributedIndexInfo; }
private static void doBindChildrenInFilter(Component[] shadows) { for (Component shadow : shadows) { if (shadow instanceof ShadowElement) { ShadowElement se = (ShadowElement) shadow; if (!se.getDistributedChildren().isEmpty() || !((ShadowElementCtrl) se).isDynamicValue()) continue; List<Component> children = shadow.getChildren(); if (children.size() == 0) { Events.sendEvent(new Event("onBindInit", (Component) se)); Events.sendEvent(new Event("onBindingReady", (Component) se)); children = shadow.getChildren(); } if (children.size() > 0) doBindChildrenInFilter(children.toArray(new Component[children.size()])); } } } }
else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(owner, null, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) {
public void beforeHostChildRemoved(Component child, int indexOfChild) { if (log.isDebugEnabled()) { log.debug("beforeHostChildRemoved " + child + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); if (currentInfo instanceof HtmlShadowElement) { // removed as my child in our control code if (currentInfo == this) { if (node != null) { try { ShadowElementsCtrl.setCurrentInfo(node); asShadow(node).beforeHostChildRemoved(child, indexOfChild); } finally { ShadowElementsCtrl.setCurrentInfo(currentInfo); // reset
public void beforeHostParentChanged(Component parent) { if (log.isDebugEnabled()) { log.debug("beforeHostParentChanged " + parent + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); } if (parent == null) { ((ComponentCtrl) _host).removeShadowRoot(this); } else if (_host.getParent() == null) { onHostAttached(_host); } }
ShadowElementsCtrl.setDistributedIndexInfo(indexCacheMap);
private Map<Component, Integer> getIndexMap() { Map<Component, Integer> distributedIndexInfo = (Map<Component, Integer>) ShadowElementsCtrl .getDistributedIndexInfo(); if (distributedIndexInfo == null) { throw new IllegalStateException("Distributed index map cannot be null! [" + this + "]"); } return distributedIndexInfo; }
final Component[] items = ShadowElementsCtrl.filterOutShadows(tm.create(owner, insertBefore, null, null));
public void beforeHostChildAdded(Component child, Component insertBefore, int indexOfInsertBefore) { if (log.isDebugEnabled()) { log.debug("beforeHostChildAdded " + child + ", " + insertBefore + ", in this shadow " + ShadowElementsCtrl.getCurrentInfo()); Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); if (indexOfInsertBefore < 0) { if (currentInfo instanceof HtmlShadowElement) { // in our control
} else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(item.getParent(), item, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) {
public Component newComponent(Page page, Component parent, ShadowInfo compInfo, Component insertBefore) { final Component comp = compInfo.newInstance(page, parent); Utils.setShadowInfo(comp, compInfo); Object currentInfo = ShadowElementsCtrl.getCurrentInfo(); if (currentInfo instanceof ShadowElement && ((ShadowElementCtrl) currentInfo).getShadowHostIfAny() == parent) { ((Component) currentInfo).insertBefore(comp, insertBefore); } else if (parent instanceof ShadowElement) { parent.insertBefore(comp, insertBefore); } else if (parent != null) { ((ShadowElementCtrl) comp).setShadowHost(parent, insertBefore); } else { //ZK-2955: Shadow element could be used in root element <zk> Component emptyRoot = null; String clsnm = Library.getProperty("org.zkoss.zk.ui.ShadowDefaultHost.class"); if (clsnm != null) { try { emptyRoot = (Component) Classes.newInstanceByThread(clsnm); emptyRoot.setPage(page); ((ShadowElementCtrl) comp).setShadowHost(emptyRoot, insertBefore); } catch (Throwable ex) { log.warn("Unable to load " + clsnm, ex); } } } if (comp instanceof BeforeCompose) ((BeforeCompose) comp).beforeCompose(); compInfo.applyProperties(comp); //include comp's definition Utils.setShadowInfo(comp, null); return comp; }
} else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(item.getParent(), item, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) {
} else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(ti.getParent(), ti, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) {