01: /*
02: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
03: * NETSCAPE COMMUNICATIONS CORPORATION
04: *
05: * Copyright (c) 1996 Netscape Communications Corporation.
06: * All Rights Reserved.
07: * Use of this Source Code is subject to the terms of the applicable
08: * license agreement from Netscape Communications Corporation.
09: */
10:
11: package graphical;
12:
13: import netscape.application.Image;
14: import netscape.application.ListItem;
15:
16: /**
17: BTListItem.
18: <p>
19: Special ListItem for handling TreeView's BinaryTree
20: representation.
21: Tracks whether the representation of the current
22: BTreeNode is OPEN or CLOSED.
23: <p>
24: <b>Open Issues</b>
25: <ul>
26: <li>Allow user to set images (incomplete).
27: </ul>
28: *
29: */
30: public class BTListItem extends ListItem {
31: /**
32: * The node is open.
33: */
34: public final static int OPEN = 101;
35: /**
36: * The node is closed.
37: * A terminus is always closed.
38: */
39: public final static int CLOSED = 102;
40:
41: private int state;
42:
43: private int selectedOpenPixels[];
44: private int unselectedOpenPixels[];
45: private int selectedClosedPixels[];
46: private int unselectedClosedPixels[];
47:
48: /**
49: * Construct instance of TreeView.
50: */
51: public BTListItem() {
52: super ();
53: state = CLOSED;
54: }
55:
56: /**
57: * Set the state of the binary tree list item to be open or closed.
58: * A protected operation managed by TreeView which must update when
59: * the state changes.
60: * @param state either OPEN or CLOSED
61: * @exception IllegalArgumentException if not passed a legal type
62: */
63: protected void setState(int state) {
64: if ((state == OPEN) || (state == CLOSED)) {
65: this .state = state;
66: } else {
67: throw new IllegalArgumentException(
68: Messages.UNKNOWNNODESTATE);
69: }
70: }
71:
72: /**
73: * Get state of the BTListItem, either OPEN or CLOSED.
74: */
75: public int getState() {
76: return state;
77: }
78: }
|