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

📄 livetree.zul

📁 ZK是一个Ajax Java Web框架
💻 ZUL
字号:
<?xml version="1.0" encoding="UTF-8"?><!--liveTree.zul{{IS_NOTE	Purpose:			Description:			History:		Mon Nov 17 17:28:58     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>Live data</h4>
   		<p>Tree supports "load on demend" feature via a TreeModel interface. 
   		This feature will not load data into the tree until it is necessary</p>
   		<p>Try to expand the tree node and observe the values loaded dynamically.</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>			                                 	<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" model="&#36;{btm}"/>
</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 + -