01: /* SimpleTreeModel.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Aug 10 2007, Created by Jeff Liu
10: }}IS_NOTE
11:
12: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zul;
20:
21: /**
22: * A simple implementation of {@link TreeModel}.
23: * Note: It assumes the content is immutable.
24: *
25: * @author Jeff Liu
26: * @since ZK 3.0.0
27: */
28: public class SimpleTreeModel extends AbstractTreeModel {
29:
30: /**
31: * Constructor
32: * @param root - the root of tree
33: */
34: public SimpleTreeModel(SimpleTreeNode root) {
35: super (root);
36: }
37:
38: //--TreeModel--//
39: public Object getChild(Object parent, int index) {
40: SimpleTreeNode node = (SimpleTreeNode) parent;
41: return node.getChildAt(index);
42: }
43:
44: //--TreeModel--//
45: public int getChildCount(Object parent) {
46: SimpleTreeNode node = (SimpleTreeNode) parent;
47: return node.getChildCount();
48: }
49:
50: //--TreeModel--//
51: public boolean isLeaf(Object node) {
52: if (node instanceof SimpleTreeNode) {
53: SimpleTreeNode node_ = (SimpleTreeNode) node;
54: return node_.isLeaf();
55: } else {
56: return true;
57: }
58: }
59:
60: }
|