protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException { super.renderProperties(renderer); if (!"none".equals(_sortDscNm)) render(renderer, "sortDescending", _sortDscNm); if (!"none".equals(_sortAscNm)) render(renderer, "sortAscending", _sortAscNm); if (!"natural".equals(_sortDir)) render(renderer, "sortDirection", _sortDir); if (_maxlength > 0) renderer.render("maxlength", _maxlength); org.zkoss.zul.impl.Utils.renderCrawlableText(getLabel()); }
final String dir = getSortDirection(); if (ascending) { if ("ascending".equals(dir)) return false; return doSort(ascending);
public Object clone() { final Treecol clone = (Treecol) super.clone(); clone.fixClone(); return clone; }
/** It invokes {@link #sort(boolean)} to sort list items and maintain * {@link #getSortDirection}. * @since 5.0.6 */ public void onSort() { final String dir = getSortDirection(); if ("ascending".equals(dir)) sort(false); else if ("descending".equals(dir)) sort(true); else if (!sort(true)) sort(false); }
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Treecol self = (Treecol) comp; wh.write("<th id=\"").write(self.getUuid()).write("\" z.type=\"Tcol\"") .write(self.getOuterAttrs()).write(self.getInnerAttrs()) .write("><div id=\"").write(self.getUuid()).write("!cave\" class=\"") .write(self.getZclass()).write("-cnt\">") .write(self.getImgTag()); new Out(self.getLabel()).render(out); wh.writeChildren(self); wh.writeln("</div></th>"); } }
/** Sets the sort direction. This does not sort the data, it only serves * as an indicator as to how the tree is sorted. (unless the tree has "autosort" attribute) * * <p>If you use {@link #sort(boolean)} to sort treechildren ({@link Treeitem}), * the sort direction is maintained automatically. * If you want to sort it in customized way, you have to set the * sort direction manually. * @since 5.0.6 * @param sortDir one of "ascending", "descending" and "natural" */ public void setSortDirection(String sortDir) throws WrongValueException { if (sortDir == null || (!"ascending".equals(sortDir) && !"descending".equals(sortDir) && !"natural".equals(sortDir))) throw new WrongValueException("Unknown sort direction: " + sortDir); if (!Objects.equals(_sortDir, sortDir)) { _sortDir = sortDir; if (!"natural".equals(sortDir) && !_ignoreSort) { Tree tree = getTree(); if (tree != null && tree.isAutosort()) { doSort("ascending".equals(sortDir)); } } smartUpdate("sortDirection", _sortDir); } }
wh.write("<th id=\"").write(child.getUuid()).write("!hdfaker\"").write(child.getOuterAttrs()) .write("><div style=\"overflow:hidden\"></div></th>"); wh.write("<th id=\"").write(child.getUuid()).write("!bdfaker\"").write(child.getOuterAttrs()) .write("><div style=\"overflow:hidden\"></div></th>"); wh.write("<th id=\"").write(child.getUuid()).write("!ftfaker\"").write(child.getOuterAttrs()) .write("><div style=\"overflow:hidden\"></div></th>");
@Override public String getSortDirection() { return target.as(Treecol.class).getSortDirection(); }
private Comparator<?> toComparator(String clsnm) throws ClassNotFoundException, InstantiationException, IllegalAccessException { if (clsnm == null || clsnm.length() == 0) return null; final Page page = getPage(); final Class cls = page != null ? page.resolveClass(clsnm) : Classes.forNameByThread(clsnm); if (cls == null) throw new ClassNotFoundException(clsnm); if (!Comparator.class.isAssignableFrom(cls)) throw new UiException("Comparator must be implemented: " + clsnm); return (Comparator<?>) cls.newInstance(); }
/** Returns the maximal length for this cell, which is decided by * the corresponding {@link #getTreecol}'s {@link Treecol#getMaxlength}. */ public int getMaxlength() { final Tree tree = getTree(); if (tree == null) return 0; final Treecol lc = getTreecol(); return lc != null ? lc.getMaxlength() : 0; }
@SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { final int index = _index < 0 && _treecol != null ? _treecol.getColumnIndex() : _index;
wh.write("<th id=\"").write(child.getUuid()).write("!hdfaker\"").write(child.getOuterAttrs()) .write("><div style=\"overflow:hidden\"></div></th>"); wh.write("<th id=\"").write(child.getUuid()).write("!bdfaker\"").write(child.getOuterAttrs()) .write("><div style=\"overflow:hidden\"></div></th>"); wh.write("<th id=\"").write(child.getUuid()).write("!ftfaker\"").write(child.getOuterAttrs()) .write("><div style=\"overflow:hidden\"></div></th>");
private static boolean doSort(Tree tree) { Treecols cols = tree.getTreecols(); if (!tree.isAutosort() || cols == null) return false; for (Component c : cols.getChildren()) { final Treecol hd = (Treecol) c; String dir = hd.getSortDirection(); if (!"natural".equals(dir)) { hd.doSort("ascending".equals(dir)); return true; } } return false; }