/** Returns the implicit object of the specified name, or null * if not found. * <p>It is the same as getImplicit(null, comp, name). * @since 3.6.0 */ public static Object getImplicit(Component comp, String name) { return getImplicit(null, comp, name); }
/** * * @param attrs * @param scope */ public AttributesInfo(Map attrs, String scope) { _attrs = attrs; _scope = scope == null ? Component.COMPONENT_SCOPE: Components.getScope(scope); }
/** Returns whether any component in coll is an ancestor of comp. * @param includingEquals whether to return true if a equals B */ private boolean isAncestor(Collection<Component> coll, Component comp, boolean includingEquals) { for (Iterator<Component> it = coll.iterator(); it.hasNext();) { final Component c = it.next(); if ((includingEquals || c != comp) && Components.isAncestor(c, comp)) return true; } return false; }
page = getCurrentPage(comp); return page; if ("desktop".equals(name)) return comp != null ? getDesktop(comp) : page.getDesktop(); if ("session".equals(name)) return comp != null ? getSession(comp) : page.getDesktop().getSession(); if ("application".equals(name)) return comp != null ? getWebApp(comp) : page.getDesktop().getWebApp(); if ("componentScope".equals(name)) return comp != null ? comp.getAttributes() : Collections.EMPTY_MAP; return page != null ? page.getAttributes() : Collections.EMPTY_MAP; if ("desktopScope".equals(name)) { final Desktop dt = comp != null ? getDesktop(comp) : page.getDesktop(); return dt != null ? dt.getAttributes() : Collections.EMPTY_MAP; final Session sess = comp != null ? getSession(comp) : page.getDesktop().getSession(); return sess != null ? sess.getAttributes() : Collections.EMPTY_MAP; final WebApp app = comp != null ? getWebApp(comp) : page.getDesktop().getWebApp(); return app != null ? app.getAttributes() : Collections.EMPTY_MAP;
/** Sorts the components in the list. * * <p>Note: you cannot use {@link Collections#sort} to sort * {@link Component#getChildren} because Collections.sort might cause * some replicated item in the list. * @see #sort(List, int, int, Comparator) */ public static void sort(List<? extends Component> list, Comparator<? super Component> cpr) { sort(list, 0, list.size(), cpr); }
private Page getPage() { return Components.getCurrentPage(_comp); } }
private static WebApp getWebApp(Component comp) { final Desktop dt = getDesktop(comp); return dt != null ? dt.getWebApp() : null; }
/** Returns the component definition of the specified class, or null * if not found. */ /*package*/ static ComponentDefinition getDefinition(Execution exec, Class<? extends Component> cls) { if (exec != null) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final PageDefinition pgdef = execCtrl.getCurrentPageDefinition(); final Page page = execCtrl.getCurrentPage(); final ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(cls, true) : page != null ? page.getComponentDefinition(cls, true) : null; if (compdef != null && compdef.getLanguageDefinition() != null) return compdef; //already from langdef (not from pgdef) final ComponentDefinition compdef2 = Components.getDefinitionByDeviceType(exec.getDesktop().getDeviceType(), cls); return compdef != null && (compdef2 == null || !Objects.equals(compdef.getImplementationClass(), compdef2.getImplementationClass())) ? compdef : compdef2; //Feature 2816083: use compdef2 if same class } for (String deviceType : LanguageDefinition.getDeviceTypes()) { final ComponentDefinition compdef = Components.getDefinitionByDeviceType(deviceType, cls); if (compdef != null) return compdef; } return null; }
add(list, from + j, ary[j]);
/** Injects the implicit objects in the context of the given object. */ @SuppressWarnings("unchecked") public void wireImplicit(Object x) { //Feature #3315689 if (ignoreFromWire(_controller.getClass())) return; for (String fdname : Components.getImplicitNames()) { //we cannot inject event proxy because it is not an Interface if ("event".equals(fdname)) { continue; } Object arg = myGetImplicit(x, fdname); //bug #2945974 //dirty patch if ("param".equals(fdname) && arg != null) { arg = new HashMap((Map) arg); } injectByName(arg, fdname, x instanceof Component && "page".equals(fdname)); } }
/** Sorts the treechildren. * @since 5.0.6 */ @SuppressWarnings("unchecked") private static void sort0(Treechildren treechildren, Comparator cmpr) { if (treechildren == null) return; Components.sort(treechildren.getChildren(), cmpr); for (Iterator it = treechildren.getChildren().iterator(); it.hasNext();) { Treeitem item = (Treeitem) it.next(); sort0(item.getTreechildren(), cmpr); } }
private boolean containsVariable(Object x, String fdname) { //#feature 2770471 GenericAutowireComposer shall support wiring ZScript varible if (x instanceof Page) { final Page page = (Page) x; return (!_ignoreZScript && page.getZScriptVariable(fdname) != null) || page.hasAttributeOrFellow(fdname, true) || (!_ignoreXel && page.getXelVariable(null, null, fdname, true) != null); } else { final Component cmp = (Component) x; final Page page = Components.getCurrentPage(cmp); return (!_ignoreZScript && page != null && page.getZScriptVariable(cmp, fdname) != null) || cmp.hasAttributeOrFellow(fdname, true) || (!_ignoreXel && page != null && page.getXelVariable(null, null, fdname, true) != null); } }
private static Session getSession(Component comp) { final Desktop dt = getDesktop(comp); return dt != null ? dt.getSession() : null; }
ref = pgdef.getComponentDefinition(cls, true); if (ref == null) //return null if not found ref = Components.getDefinitionByDeviceType(langdef.getDeviceType(), cls);
/** Returns the implicit object of the specified name, or null * if not found. * <p>It is the same as getImplicit(page, null, name). * @since 3.6.0 */ public static Object getImplicit(Page page, String name) { return getImplicit(page, null, name); }
/** Sorts the items. If with group, each group is sorted independently. */ @SuppressWarnings("unchecked") private static void sort0(Listbox box, Comparator cmpr) { if (box.hasGroup()) for (Listgroup g : box.getGroups()) { int index = g.getIndex() + 1; Components.sort(box.getItems(), index, index + g.getItemCount(), cmpr); } else Components.sort(box.getItems(), cmpr); }
public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); Component rootParent = ComponentsCtrl.getRootParent(); final Radiogroup rg = getRadiogroup(); // ZK-3818: update selected index in the callback if (!_explictGroup) { _group = this.getRadiogroup(); } if (rg != null && rootParent instanceof ComponentCtrl && (!Components.isAncestor(rootParent, rg) || rootParent == rg)) { ((ComponentCtrl) rootParent).addCallback(AFTER_CHILD_ADDED, new Callback<Component>() { public void call(Component rootParent) { rg.fixOnAdd(Radio.this, false); } }); } } }
_scope = scope == null ? -1 : Components.getScope(scope);
private Object getVariable(Object x, String fdname) { //#feature 2770471 GenericAutowireComposer shall support wiring ZScript varible if (x instanceof Page) { final Page page = (Page) x; Object arg = _ignoreZScript ? null : page.getZScriptVariable(fdname); if (arg == null) { arg = page.getAttributeOrFellow(fdname, true); if (!_ignoreXel && arg == null) arg = page.getXelVariable(null, null, fdname, true); } return arg; } else { final Component cmp = (Component) x; final Page page = Components.getCurrentPage(cmp); Object arg = !_ignoreZScript && page != null ? page.getZScriptVariable(cmp, fdname) : null; if (arg == null) { arg = cmp.getAttributeOrFellow(fdname, true); if (!_ignoreXel && arg == null && page != null) arg = page.getXelVariable(null, null, fdname, true); } return arg; } }
public Object getImplicit(String name) { return Components.getImplicit(_page, name); }