KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > core > common > lib > DefaultTreeView


1 /*===========================================================================
2
3 ObjectWeb Naming Context Framework
4 Copyright (C) 2002 USTL - LIFL - GOAL
5 Contact: architecture@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jérôme Moroy.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.util.explorer.core.common.lib;
28
29 /** The Browsr API's imports */
30 import java.io.Serializable JavaDoc;
31
32 import org.objectweb.util.explorer.api.Entry;
33 import org.objectweb.util.explorer.api.Tree;
34 import org.objectweb.util.explorer.api.TreeView;
35
36 /**
37  * Offers a limited view on the tree
38  *
39  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
40  * @version 0.1
41  */

42 public class DefaultTreeView
43   implements /*ExtendedTreeView,*/TreeView, Serializable JavaDoc
44 {
45
46     // ==================================================================
47
//
48
// Internal states.
49
//
50
// ==================================================================
51

52     /** The selected entry and his parent */
53     protected Entry entry_, parent_;
54
55     /** The tree instance. */
56     protected Tree tree_;
57     
58     // ==================================================================
59
//
60
// Constructors.
61
//
62
// ==================================================================
63

64     /**
65      * Default Constuctor
66      * @param tree The associated tree
67      */

68     public DefaultTreeView(Tree tree, Entry current, Entry parent) {
69         tree_ = tree;
70         entry_ = current;
71         parent_ = parent;
72     }
73
74     // ==================================================================
75
//
76
// Protected methods.
77
//
78
// ==================================================================
79

80     /**
81      * @param entry The entry on which you want to obtain the value
82      * @return The associated value of the entry
83      */

84     protected Object JavaDoc getValue(Entry entry) {
85         return (entry != null)?entry.getValue():null;
86     }
87
88     // ==================================================================
89
//
90
// Public methods.
91
//
92
// ==================================================================
93

94     /**
95      * Returns the current selected Entry.
96      */

97     public Entry getSelectedEntry() {
98         return entry_;
99     }
100
101     /**
102      * Returns the parent entry
103      */

104     public Entry getParentEntry() {
105         return parent_;
106     }
107
108     /**
109      * Returns the wrapped object of value of the associated Entry
110      */

111     public Object JavaDoc getSelectedObject() {
112         return getValue(entry_);
113     }
114
115     /**
116      * Returns the parent object
117      */

118     public Object JavaDoc getParentObject() {
119         return getValue(parent_);
120     }
121
122     /**
123      * Returns an object to manipulate the Tree.
124      */

125    public Tree
126    getTree(){
127         return (Tree)tree_;
128     }
129     
130 }
131
Popular Tags