Update git submodules
[LibreOffice.git] / odk / examples / java / Inspector / HideableMutableTreeNode.java
blobc601d075e6a056d11e41802c3dce6aaba35e2ce7
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 import javax.swing.tree.*;
22 /**
23 * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
24 * implementation that works with <code>HideableTreeModel</code>.
26 public class HideableMutableTreeNode extends DefaultMutableTreeNode {
27 /**
28 * The node is visible flag.
30 private boolean bIsvisible = true;
31 private static final String SDUMMY = "Dummy";
34 /**
35 * Creates a tree node that has no parent and no children, but which
36 * allows children.
38 public HideableMutableTreeNode() {
39 super();
42 /**
43 * Creates a tree node with no parent, no children, but which allows
44 * children, and initializes it with the specified user object.
46 * @param _userObject - an Object provided by the user that
47 * constitutes the node's data
49 public HideableMutableTreeNode(Object _userObject) {
50 super(_userObject);
53 /**
54 * Creates a tree node with no parent, no children, initialized with the
55 * specified user object, and that allows children only if specified.
57 * @param _userObject - an Object provided by the user that describes the node's data
58 * @param _ballowsChildren - if true, the node is allowed to have childnodes -- otherwise, it is always a leaf node
60 public HideableMutableTreeNode(Object _userObject, boolean _ballowsChildren) {
61 super(_userObject, _ballowsChildren);
64 /**
65 * Checks if the node is visible.
67 * @return true if the node is visible, else false
69 public boolean isVisible() {
70 return this.bIsvisible;
73 /**
74 * Sets if the node is visible.
76 * @param _bIsVisible true if the node is visible, else false
78 public void setVisible(boolean _bIsVisible) {
79 this.bIsvisible = _bIsVisible;
83 public void addDummyNode(){
84 removeDummyNode();
85 DefaultMutableTreeNode oDefaultMutableTreeNode = new DefaultMutableTreeNode(SDUMMY);
86 add(oDefaultMutableTreeNode);
91 public boolean removeDummyNode(){
92 boolean breturn = false;
93 if (getChildCount() == 1){
94 DefaultMutableTreeNode oDefaultMutableTreeNode = (DefaultMutableTreeNode) getChildAt(0);
95 if (oDefaultMutableTreeNode != null){
96 if (oDefaultMutableTreeNode.getUserObject().equals(SDUMMY)){
97 remove(0);
98 breturn = true;
102 return breturn;
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */