01: /*
02: * BrowserTreeNode.java
03: *
04: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * of the License, or any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19: *
20: */
21:
22: package org.executequery.gui.browser;
23:
24: import javax.swing.tree.DefaultMutableTreeNode;
25:
26: /* ----------------------------------------------------------
27: * CVS NOTE: Changes to the CVS repository prior to the
28: * release of version 3.0.0beta1 has meant a
29: * resetting of CVS revision numbers.
30: * ----------------------------------------------------------
31: */
32:
33: /**
34: *
35: * @author Takis Diakoumis
36: * @version $Revision: 1.4 $
37: * @date $Date: 2006/05/14 06:56:54 $
38: */
39: public class BrowserTreeNode extends DefaultMutableTreeNode {
40:
41: private boolean typeParent;
42: private boolean expanded;
43: private DatabaseObject userObject;
44:
45: public BrowserTreeNode(DatabaseObject userObject,
46: boolean allowsChildren) {
47: this (userObject, allowsChildren, true);
48: }
49:
50: public BrowserTreeNode(DatabaseObject userObject,
51: boolean allowsChildren, boolean typeParent) {
52: super (userObject, allowsChildren);
53: this .userObject = userObject;
54: this .typeParent = typeParent;
55: expanded = false;
56: }
57:
58: public int getNodeType() {
59: return userObject.getType();
60: }
61:
62: /**
63: * Returns whether this is the parent node of this type.
64: *
65: * @return true | false
66: */
67: public boolean isTypeParent() {
68: return typeParent;
69: }
70:
71: public void setExpanded(boolean expanded) {
72: this .expanded = expanded;
73: }
74:
75: public boolean isExpanded() {
76: return expanded;
77: }
78:
79: public String toString() {
80: return userObject.toString();
81: }
82:
83: public DatabaseObject getDatabaseUserObject() {
84: return userObject;
85: }
86:
87: public boolean isLeaf() {
88: if (userObject.getType() == BrowserConstants.HOST_NODE) {
89: return super.isLeaf();
90: } else {
91: return !allowsChildren;
92: }
93: }
94:
95: }
|