⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagingtree.zul

📁 ZK是一个Ajax Java Web框架
💻 ZUL
字号:
<?xml version="1.0" encoding="UTF-8"?><!--pagingTree.zul{{IS_NOTE	Purpose:			Description:			History:		Thu Nov 20 15:08:00     2008, Created by jumperchen}}IS_NOTECopyright (C) 2008 Potix Corporation. All Rights Reserved.{{IS_RIGHT}}IS_RIGHT--><window id="demo" apply="org.zkoss.zkdemo.userguide.DemoWindowComposer">	<html><![CDATA[  		<h4>Paging with Tree</h4>		<p>Alike Paging controls with Grid and Listbox, paging are supported by tree by setting mold="paging".<a href="javascript:;" onclick="if (!zk.isVisible($e('infos'))) {anima.slideDown($e('infos'));} else {anima.slideUp($e('infos'));}">More..</a></p>		<p style="display:none" id="infos">It is better to display a large number of data across multiple pages by specifying the paging mold. You can also specify the paging position to be either top, bottom, or both</p>	]]></html>	See the <toolbarbutton id="target" label="org.zkoss.zkdemo.test2.tree.BinaryTreeModel" popup="details"/>
	and the <toolbarbutton id="target2" label="org.zkoss.zkdemo.userguide.BigList" popup="details2"/> implementation.
	<separator/>
	<popup id="details" fulfill="target.onClick" width="550px">
	<div style="border:1px solid #538BA2; background: #FFF; ">
		<html><![CDATA[
<pre style='color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>class</span> BinaryTreeModel <span style='color:#7f0055; font-weight:bold; '>extends</span> AbstractTreeModel{
  
    <span style='color:#7f0055; font-weight:bold; '>private</span> ArrayList _tree =<span style='color:#7f0055; font-weight:bold; '>null</span>;
    
    <span style='color:#7f0055; font-weight:bold; '>public</span> BinaryTreeModel(<span style='color:#7f0055; font-weight:bold; '>List</span> tree){
        <span style='color:#7f0055; font-weight:bold; '>super</span>(tree.get(0));
        _tree = (ArrayList)tree;
    }
    
    <span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>Object</span> getChild(<span style='color:#7f0055; font-weight:bold; '>Object</span> parent, <span style='color:#7f0055; font-weight:bold; '>int</span> index) {
        <span style='color:#7f0055; font-weight:bold; '>int</span> i = _tree.indexOf(parent) *2 +1 + index;
        <span style='color:#7f0055; font-weight:bold; '>if</span>( i>= _tree.size())
            <span style='color:#7f0055; font-weight:bold; '>return</span> <span style='color:#7f0055; font-weight:bold; '>null</span>;
        <span style='color:#7f0055; font-weight:bold; '>else</span>
            <span style='color:#7f0055; font-weight:bold; '>return</span> _tree.get(i);
    }
    
    <span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>int</span> getChildCount(<span style='color:#7f0055; font-weight:bold; '>Object</span> parent) {
        <span style='color:#7f0055; font-weight:bold; '>int</span> count = 0;
        <span style='color:#7f0055; font-weight:bold; '>if</span>(getChild(parent,0) != <span style='color:#7f0055; font-weight:bold; '>null</span>)
            count++;
        <span style='color:#7f0055; font-weight:bold; '>if</span>(getChild(parent,1) != <span style='color:#7f0055; font-weight:bold; '>null</span>)
            count++;
        <span style='color:#7f0055; font-weight:bold; '>return</span> count;
    }
    
    <span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>boolean</span> isLeaf(<span style='color:#7f0055; font-weight:bold; '>Object</span> node) {
        <span style='color:#7f0055; font-weight:bold; '>return</span> (getChildCount(node) == 0);
    }

}
</pre>	
		]]></html>
		</div>
	</popup>
	<popup id="details2" fulfill="target2.onClick" width="450px">
	<div style="border:1px solid #538BA2; background: #FFF; ">
		<html><![CDATA[
<pre style='color:#000000;background:#ffffff;'><span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>class</span> BigList <span style='color:#7f0055; font-weight:bold; '>extends</span> java.util.AbstractList {
    <span style='color:#7f0055; font-weight:bold; '>private</span> <span style='color:#7f0055; font-weight:bold; '>int</span> _sz;
    <span style='color:#7f0055; font-weight:bold; '>public</span> BigList(<span style='color:#7f0055; font-weight:bold; '>int</span> sz) {
        <span style='color:#7f0055; font-weight:bold; '>if</span> (sz &lt; 0)
            <span style='color:#7f0055; font-weight:bold; '>throw</span> <span style='color:#7f0055; font-weight:bold; '>new</span> <span style='color:#7f0055; font-weight:bold; '>IllegalArgumentException</span>(
                <span style='color:#2a00ff; '>"Negative not allowed: "</span>+sz);
        _sz = sz;
    }
    <span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>int</span> size() {
        <span style='color:#7f0055; font-weight:bold; '>return</span> _sz;
    }
    <span style='color:#7f0055; font-weight:bold; '>public</span> <span style='color:#7f0055; font-weight:bold; '>Object</span> get(<span style='color:#7f0055; font-weight:bold; '>int</span> j) {
        <span style='color:#7f0055; font-weight:bold; '>return</span> <span style='color:#7f0055; font-weight:bold; '>new</span> <span style='color:#7f0055; font-weight:bold; '>Integer</span>(j);
    }
}
</pre>
		]]></html>
		</div>
	</popup>	
	<separator/>	<tabbox width="100%" tabscroll="false">		<tabs>			<tab id="demoView" label="Demo"/>			<tab id="srcView" label="View Source"/>		</tabs>		<tabpanels>			<tabpanel>				<window id="view">				</window>			</tabpanel>						<tabpanel>				<panel>					<panelchildren>						<textbox id="codeView" class="code" rows="20" width="95%">			<attribute name="value"><![CDATA[<zk>	Paging can be supported to locate at three position: Top, Bottom, and Both.	<radiogroup		onCheck="tree.pagingPosition = self.selectedItem.label;">		<radio label="top" />		<radio label="bottom" checked="true" />		<radio label="both" />	</radiogroup>
	<separator/>
	<button label="Change Paging Mold">
		<attribute name="onClick">
		tree.pagingChild.mold = "os".equals(tree.pagingChild.mold) ? "default" : "os";
		</attribute>
	</button>	<zscript>						import org.zkoss.zkdemo.test2.tree.BinaryTreeModel;		BinaryTreeModel btm = new BinaryTreeModel(new ArrayList(new org.zkoss.zkdemo.userguide.BigList(1000)));	</zscript>	<tree id="tree" mold="paging" pageSize="15" model="&#36;{btm}">		<attribute name="onCreate">		tree.renderItemByPath(new int[]{1,1,1,1,1,1,1,1,1,1,1,1});		tree.renderItemByPath(new int[]{0,0,0,0,0,0,0,0,0,0,0,0});		</attribute>	</tree></zk>			]]></attribute>						</textbox>					</panelchildren>					<toolbar mold="panel">
						<button id="tryBtn" label="Try me!"/>						<button id="reloadBtn" label="Reload" height="18px"/>					</toolbar>				</panel>			</tabpanel>		</tabpanels>	</tabbox></window>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -