001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.unifiedGui;
032:
033: import java.util.*;
034:
035: import javax.swing.tree.*;
036:
037: import de.ug2t.kernel.*;
038:
039: public class ConvertingTreeNode implements TreeNode {
040: protected KeTreeElement pdm_root;
041:
042: public ConvertingTreeNode(KeTreeElement xRoot) {
043: pdm_root = xRoot;
044:
045: return;
046: };
047:
048: // Returns the children of the reciever as an Enumeration.
049: public Enumeration children() {
050: Vector l_childs = new Vector();
051: Iterator l_it = ((KeTreeNode) pdm_root).pcmf_getAllSubs()
052: .iterator();
053:
054: while (l_it.hasNext())
055: l_childs.addElement(new ConvertingTreeNode(
056: (KeTreeElement) l_it.next()));
057:
058: return (l_childs.elements());
059: };
060:
061: // Returns true if the receiver allows children.
062: public boolean getAllowsChildren() {
063: if (this .pdm_root instanceof KeTreeNode)
064: return (true);
065: else
066: return (false);
067: };
068:
069: // Returns the child TreeNode at index childIndex.
070: public TreeNode getChildAt(int childIndex) {
071: return (new ConvertingTreeNode(
072: (KeTreeElement) ((KeTreeNode) pdm_root)
073: .pcmf_getAllSubs().get(childIndex)));
074: };
075:
076: // Returns the number of children TreeNodes the receiver contains.
077: public int getChildCount() {
078: return (((KeTreeNode) this .pdm_root).pcmf_getAllSubs().size());
079: };
080:
081: // Returns the index of node in the receivers children.
082: public int getIndex(TreeNode node) {
083: return (((KeTreeNode) this .pdm_root).pcmf_getAllSubs()
084: .indexOf(((ConvertingTreeNode) node).pdm_root));
085: };
086:
087: // Returns the parent TreeNode of the receiver.
088: public TreeNode getParent() {
089: KeTreeNode l_parent = this .pdm_root.pcmf_getParentNode();
090: if (l_parent != null)
091: return (new ConvertingTreeNode(l_parent));
092: else
093: return (null);
094: };
095:
096: // Returns true if the receiver is a leaf
097: public boolean isLeaf() {
098: if (this .pdm_root instanceof KeTreeNode
099: && ((KeTreeNode) this .pdm_root).pcmf_getAllSubs()
100: .size() > 0)
101: return (false);
102: else
103: return (true);
104: };
105:
106: public String toString() {
107: if (pdm_root != null)
108: return (pdm_root.toString());
109: else
110: return ("null");
111: };
112:
113: public KeTreeElement pcmf_getTreeElement() {
114: return (this .pdm_root);
115: };
116:
117: public boolean equals(Object xtoCmp) {
118: if (xtoCmp instanceof ConvertingTreeNode) {
119: if (this .pdm_root == ((ConvertingTreeNode) xtoCmp).pdm_root)
120: return (true);
121: else
122: return (false);
123: } else {
124: if (this .pdm_root == xtoCmp)
125: return (true);
126: else
127: return (false);
128: }
129: };
130: };
|