01: /*
02: * @(#)LazyMutableTreeNode.java 10/9/2005
03: *
04: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
05: */
06: package com.jidesoft.plaf.basic;
07:
08: import javax.swing.tree.DefaultMutableTreeNode;
09:
10: /**
11: * LazyMutableTreeNode. <br>
12: */
13: public abstract class LazyMutableTreeNode extends
14: DefaultMutableTreeNode {
15:
16: protected boolean _loaded = false;
17:
18: public LazyMutableTreeNode() {
19: super ();
20: }
21:
22: public LazyMutableTreeNode(Object userObject) {
23: super (userObject);
24: }
25:
26: public LazyMutableTreeNode(Object userObject, boolean allowsChildren) {
27: super (userObject, allowsChildren);
28: }
29:
30: @Override
31: public int getChildCount() {
32: synchronized (this ) {
33: if (!_loaded) {
34: _loaded = true;
35: initChildren();
36: }
37: }
38: return super .getChildCount();
39: }
40:
41: public void clear() {
42: removeAllChildren();
43: _loaded = false;
44: }
45:
46: public boolean isLoaded() {
47: return _loaded;
48: }
49:
50: protected abstract void initChildren();
51:
52: }
|