/** Sets whether to grow and shrink vertical to fit their given space, * so called vertical flexibility. * * <p>Note: this attribute is ignored if {@link #setRows} is specified */ public void setVflex(boolean vflex) { if (_vflex != vflex) { _vflex = vflex; smartUpdate("vflex", _vflex); } }
/** Sets whether the check mark shall be displayed in front * of each item. * <p>The check mark is a checkbox if {@link #isMultiple} returns * true. It is a radio button if {@link #isMultiple} returns false. */ public void setCheckmark(boolean checkmark) { if (_checkmark != checkmark) { _checkmark = checkmark; smartUpdate("checkmark", checkmark); } }
/** * Sets the inner width of this component. * The inner width is the width of the inner table. * By default, it is 100%. That is, it is the same as the width * of this component. However, it is changed when the user * is sizing the column's width. * * <p>Application developers rarely call this method, unless * they want to preserve the widths of sizable columns * changed by the user. * To preserve the widths, the developer have to store the widths of * all columns and the inner width ({@link #getInnerWidth}), * and then restore them when re-creating this component. * * @param innerWidth the inner width. If null, "100%" is assumed. * @since 3.0.0 */ public void setInnerWidth(String innerWidth) { if (innerWidth == null) innerWidth = "100%"; if (!_innerWidth.equals(innerWidth)) { _innerWidth = innerWidth; smartUpdate("innerWidth", innerWidth); } }
/** Clears the selection. */ public void clearSelection() { if (!_selItems.isEmpty()) { for (Treeitem item : _selItems) item.setSelectedDirectly(false); _selItems.clear(); _sel = null; smartUpdate("selectedItem", null); } }
/** Sets the rows. * <p>Note: if both {@link #setHeight} is specified with non-empty, * {@link #setRows} is ignored */ public void setRows(int rows) throws WrongValueException { if (rows < 0) throw new WrongValueException("Illegal rows: " + rows); if (_rows != rows) { _rows = rows; smartUpdate("rows", _rows); } }
/** Note: we have to update all selection at once, since addItemToSelection * and removeItemFromSelection might be called interchangeably. */ private void smartUpdateSelection() { final StringBuffer sb = new StringBuffer(80); for (Treeitem item : _selItems) { if (sb.length() > 0) sb.append(','); sb.append(item.getUuid()); } smartUpdate("chgSel", sb.toString()); }
/** Sets a list of HTML tag names that shall <i>not</i> cause the tree item * being selected if they are clicked. * <p>Default: null (it means button, input, textarea and a). If you want * to select no matter which tag is clicked, please specify an empty string. * @param tags a list of HTML tag names that will <i>not</i> cause the tree item * being selected if clicked. Specify null to use the default and "" to * indicate none. * @since 5.0.5 */ public void setNonselectableTags(String tags) { if (!Objects.equals(_nonselTags, tags)) { _nonselTags = tags; smartUpdate("nonselectableTags", tags); } }
/** Sets the name of this component. * <p>The name is used only to work with "legacy" Web application that * handles user's request by servlets. * It works only with HTTP/HTML-based browsers. It doesn't work * with other kind of clients. * <p>Don't use this method if your application is purely based * on ZK's event-driven model. * * @param name the name of this component. */ public void setName(String name) { if (name != null && name.length() == 0) name = null; if (!Objects.equals(_name, name)) { _name = name; smartUpdate("name", name); } }
/** Sets whether multiple selections are allowed. * <p>Notice that, if a model is assigned, it will change the model's * state (by {@link TreeSelectableModel#setMultiple}). */ public void setMultiple(boolean multiple) { if (_multiple != multiple) { _multiple = multiple; if (!_multiple && _selItems.size() > 1) { final Treeitem item = getSelectedItem(); for (Iterator<Treeitem> it = _selItems.iterator(); it.hasNext();) { final Treeitem ti = it.next(); if (ti != item) { ti.setSelectedDirectly(false); it.remove(); } } //No need to update selId because z.multiple will do the job } if (_model != null) ((TreeSelectableModel) _model).setMultiple(multiple); smartUpdate("multiple", _multiple); } }
/** Selects all items. */ public void selectAll() { if (!_multiple) throw new UiException("Appliable only to the multiple seltype: " + this); //we don't invoke getItemCount first because it is slow! boolean first = true; for (Treeitem item : getItems()) { if (!item.isSelected()) { _selItems.add(item); item.setSelectedDirectly(true); } if (first) { _sel = item; first = false; } } smartUpdate("selectAll", true); }
@SuppressWarnings("unchecked") protected void smartUpdate(String name, Object value) { Component comp = getParent(); if (comp instanceof Treeitem) { Treerow tr = ((Treeitem) comp).getTreerow(); if (tr != null) tr.smartUpdate(name, value); } else if (comp instanceof Tree) { ((Tree) comp).smartUpdate(name, value); } else { // do it later for bug ZK-2206 Map<String, Object> attributes = (Map<String, Object>) getAttribute( "org.zkoss.zul.Treechildren_smartUpdate"); if (attributes == null) { attributes = new LinkedHashMap<String, Object>(3); setAttribute("org.zkoss.zul.Treechildren_smartUpdate", attributes); } attributes.put(name, value); } }
/** Deselects all of the currently selected items and selects * the given item. * <p>It is the same as {@link #setSelectedItem}. * @param item the item to select. If null, all items are deselected. */ public void selectItem(Treeitem item) { if (item == null) { clearSelection(); } else { if (item.getTree() != this) throw new UiException("Not a child: " + item); if (_sel != item || (_multiple && _selItems.size() > 1)) { for (Treeitem ti : _selItems) ti.setSelectedDirectly(false); _selItems.clear(); _sel = item; item.setSelectedDirectly(true); _selItems.add(item); smartUpdate("selectedItem", item); } if (inPagingMold()) setActivePage(item); } }
smartUpdate("model", true); smartUpdate("model", false);
addPagingListener(_pgi); if (_pgi instanceof Component) smartUpdate("paginal", _pgi);