KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > swing > lib > BasicTablePanel


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@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): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.util.explorer.swing.lib;
27
28 import java.awt.BorderLayout JavaDoc;
29 import java.awt.Color JavaDoc;
30
31 import javax.swing.BorderFactory JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33
34 import org.objectweb.util.explorer.api.Panel;
35 import org.objectweb.util.explorer.api.Table;
36 import org.objectweb.util.explorer.api.Tree;
37 import org.objectweb.util.explorer.api.TreeView;
38 import org.objectweb.util.explorer.interpreter.api.DescriptionInterpreter;
39 import org.objectweb.util.explorer.resolver.api.PropertyResolver;
40 import org.objectweb.util.explorer.swing.lib.DynamicTable;
41
42 /**
43  *
44  *
45  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
46  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
47  *
48  * @version 0.1
49  */

50 public class BasicTablePanel
51   implements Panel JavaDoc
52 {
53
54     //==================================================================
55
//
56
// Internal States.
57
//
58
// ==================================================================
59

60     protected JPanel JavaDoc panel_;
61
62     /**
63      * The used table
64      */

65     protected Table table_;
66
67     /**
68      * The used PropertyResolver
69      */

70     protected PropertyResolver propertyResolver_;
71
72     /**
73      * The used DescriptionInterpreter
74      */

75     protected DescriptionInterpreter descriptionInterpreter_;
76
77     /**
78      * The current tree
79      */

80     protected Tree tree_;
81
82     
83 // protected AdminCustomization custom_;
84

85 // protected Decoder decoder_;
86

87     
88     // ==================================================================
89
//
90
// Constructors.
91
//
92
// ==================================================================
93

94     /*
95     public BasicTablePanel(Table table, AdminCustomization custom, Decoder currentDecoder){
96         panel_ = new JPanel();
97         panel_.setBackground(Color.white);
98         panel_.setBorder(BorderFactory.createLineBorder(Color.black));
99         table_ = table;
100         decoder_ = currentDecoder;
101         custom_ = custom;
102         //panel_.setLayout(new BoxLayout(panel_, BoxLayout.Y_AXIS));
103         panel_.setLayout(new BorderLayout());
104     }
105
106     public BasciTablePanel(Table table, AdminCustomization custom){
107         this(table, custom, null);
108     }
109     */

110     
111     public BasicTablePanel(){
112         panel_ = new JPanel JavaDoc();
113         panel_.setBackground(Color.white);
114         panel_.setBorder(BorderFactory.createLineBorder(Color.black));
115         //panel_.setLayout(new BoxLayout(panel_, BoxLayout.Y_AXIS));
116
panel_.setLayout(new BorderLayout JavaDoc());
117     }
118     
119     // ==================================================================
120
//
121
// Internal methods.
122
//
123
// ==================================================================
124

125     // ==================================================================
126
//
127
// Public methods for ... interface.
128
//
129
// ==================================================================
130

131     public void setPropertyResolver(PropertyResolver propertyResolver){
132         // TODO: A fractal assembly is needed here!!! (dynamic bindings)
133
propertyResolver_ = propertyResolver;
134     }
135     
136     public void setDescriptionInterpreter(DescriptionInterpreter descriptionInterpreter){
137         // TODO: A fractal assembly is needed here!!! (dynamic bindings)
138
descriptionInterpreter_ = descriptionInterpreter;
139     }
140     
141     public void setTree(Tree tree){
142         // TODO: A fractal assembly is needed here!!! (dynamic bindings)
143
tree_ = tree;
144     }
145     
146     public void setTable(Table table){
147         table_ = table;
148     }
149     
150     // ==================================================================
151
//
152
// Public methods for ... interface.
153
//
154
// ==================================================================
155

156     /* (non-Javadoc)
157      * @see org.objectweb.util.explorer.api.Panel#selected(org.objectweb.util.explorer.api.TreeView)
158      */

159     public void selected(TreeView treeView) {
160         if(table_!=null){
161             DynamicTable dynamicTable = null;
162 // if(decoder_!=null)
163
// dynamicTable = new DynamicTable(decoder_);
164
// else
165
dynamicTable = new DynamicTable();
166                 dynamicTable.setPropertyResolver(propertyResolver_);
167                 dynamicTable.setDescriptionInterpreter(descriptionInterpreter_);
168                 dynamicTable.setTree(tree_);
169 // dynamicTable.setAdminCustomization(custom_);
170
String JavaDoc[] headers = table_.getHeaders(treeView);
171             Object JavaDoc[][] values = table_.getRows(treeView);
172             if(values!=null && values.length>0){
173                 dynamicTable.setData(headers,values);
174                 //panel_.add(new JScrollPane(dynamicTable));
175
panel_.add(dynamicTable.getTableHeader(),BorderLayout.NORTH);
176                 panel_.add(dynamicTable,BorderLayout.CENTER);
177             }
178         }
179     }
180
181     /* (non-Javadoc)
182      * @see org.objectweb.util.explorer.api.Panel#getPanel()
183      */

184     public Object JavaDoc getPanel() {
185         return panel_;
186     }
187
188     /* (non-Javadoc)
189      * @see org.objectweb.util.explorer.api.Panel#unselected(org.objectweb.util.explorer.api.TreeView)
190      */

191     public void unselected(TreeView treeview) {
192         // Nothing to do!
193
}
194
195 }
196
197
198
Popular Tags