Update ooo320-m1
[ooovba.git] / odk / examples / java / Inspector / HideableMutableTreeNode.java
blob37ac35f116b18575af0f114c268fb07e5f9ddc47
1 // *** HideableMutableTreeNode ***
2 import javax.swing.*;
3 import javax.swing.tree.*;
5 /**
6 * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
7 * implementation that works with <code>HideableTreeModel</code>.
8 */
9 public class HideableMutableTreeNode extends DefaultMutableTreeNode {
10 /**
11 * The node is visible flag.
13 public boolean bIsvisible = true;
14 private static final String SDUMMY = "Dummy";
17 /**
18 * Creates a tree node that has no parent and no children, but which
19 * allows children.
21 public HideableMutableTreeNode() {
22 super();
25 /**
26 * Creates a tree node with no parent, no children, but which allows
27 * children, and initializes it with the specified user object.
29 * @param userObject - an Object provided by the user that
30 * constitutes the node's data
32 public HideableMutableTreeNode(Object _userObject) {
33 super(_userObject);
36 /**
37 * Creates a tree node with no parent, no children, initialized with the
38 * specified user object, and that allows children only if specified.
40 * @param _userObject - an Object provided by the user that describes the node's data
41 * @param _ballowsChildren - if true, the node is allowed to have childnodes -- otherwise, it is always a leaf node
43 public HideableMutableTreeNode(Object _userObject, boolean _ballowsChildren) {
44 super(_userObject, _ballowsChildren);
47 /**
48 * Checks if the node is visible.
50 * @return true if the node is visible, else false
52 public boolean isVisible() {
53 return this.bIsvisible;
56 /**
57 * Sets if the node is visible.
59 * @param returns true if the node is visible, else false
61 public void setVisible(boolean _bIsVisible) {
62 this.bIsvisible = _bIsVisible;
66 public void addDummyNode(){
67 removeDummyNode();
68 DefaultMutableTreeNode oDefaultMutableTreeNode = new DefaultMutableTreeNode(SDUMMY);
69 add(oDefaultMutableTreeNode);
74 public boolean removeDummyNode(){
75 boolean breturn = false;
76 if (getChildCount() == 1){
77 DefaultMutableTreeNode oDefaultMutableTreeNode = (DefaultMutableTreeNode) getChildAt(0);
78 if (oDefaultMutableTreeNode != null){
79 if (oDefaultMutableTreeNode.getUserObject().equals(SDUMMY)){
80 remove(0);
81 breturn = true;
85 return breturn;