KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > swing > panel > 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.panel;
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     protected Table table_;
63
64     protected PropertyResolver propertyResolver_;
65     
66     protected DescriptionInterpreter descriptionInterpreter_;
67     
68     protected Tree tree_;
69     
70 // protected AdminCustomization custom_;
71

72 // protected Decoder decoder_;
73

74     
75     // ==================================================================
76
//
77
// Constructors.
78
//
79
// ==================================================================
80

81     /*
82     public BasicTablePanel(Table table, AdminCustomization custom, Decoder currentDecoder){
83         panel_ = new JPanel();
84         panel_.setBackground(Color.white);
85         panel_.setBorder(BorderFactory.createLineBorder(Color.black));
86         table_ = table;
87         decoder_ = currentDecoder;
88         custom_ = custom;
89         //panel_.setLayout(new BoxLayout(panel_, BoxLayout.Y_AXIS));
90         panel_.setLayout(new BorderLayout());
91     }
92
93     public BasciTablePanel(Table table, AdminCustomization custom){
94         this(table, custom, null);
95     }
96     */

97     
98     public BasicTablePanel(){
99         panel_ = new JPanel JavaDoc();
100         panel_.setBackground(Color.white);
101         panel_.setBorder(BorderFactory.createLineBorder(Color.black));
102         //panel_.setLayout(new BoxLayout(panel_, BoxLayout.Y_AXIS));
103
panel_.setLayout(new BorderLayout JavaDoc());
104     }
105     
106     // ==================================================================
107
//
108
// Internal methods.
109
//
110
// ==================================================================
111

112     // ==================================================================
113
//
114
// Public methods for ... interface.
115
//
116
// ==================================================================
117

118     public void setPropertyResolver(PropertyResolver propertyResolver){
119         // TODO: A fractal assembly is needed here!!! (dynamic bindings)
120
propertyResolver_ = propertyResolver;
121     }
122     
123     public void setDescriptionInterpreter(DescriptionInterpreter descriptionInterpreter){
124         // TODO: A fractal assembly is needed here!!! (dynamic bindings)
125
descriptionInterpreter_ = descriptionInterpreter;
126     }
127     
128     public void setTree(Tree tree){
129         // TODO: A fractal assembly is needed here!!! (dynamic bindings)
130
tree_ = tree;
131     }
132     
133     public void setTable(Table table){
134         table_ = table;
135     }
136     
137     // ==================================================================
138
//
139
// Public methods for ... interface.
140
//
141
// ==================================================================
142

143     /* (non-Javadoc)
144      * @see org.objectweb.util.explorer.api.Panel#selected(org.objectweb.util.explorer.api.TreeView)
145      */

146     public void selected(TreeView treeView) {
147         if(table_!=null){
148             DynamicTable dynamicTable = null;
149 // if(decoder_!=null)
150
// dynamicTable = new DynamicTable(decoder_);
151
// else
152
dynamicTable = new DynamicTable();
153                 dynamicTable.setPropertyResolver(propertyResolver_);
154                 dynamicTable.setDescriptionInterpreter(descriptionInterpreter_);
155                 dynamicTable.setTree(tree_);
156 // dynamicTable.setAdminCustomization(custom_);
157
String JavaDoc[] headers = table_.getHeaders(treeView);
158             Object JavaDoc[][] values = table_.getRows(treeView);
159             if(values!=null && values.length>0){
160                 dynamicTable.setData(headers,values);
161                 //panel_.add(new JScrollPane(dynamicTable));
162
panel_.add(dynamicTable.getTableHeader(),BorderLayout.NORTH);
163                 panel_.add(dynamicTable,BorderLayout.CENTER);
164             }
165         }
166     }
167
168     /* (non-Javadoc)
169      * @see org.objectweb.util.explorer.api.Panel#getPanel()
170      */

171     public Object JavaDoc getPanel() {
172         return panel_;
173     }
174
175     /* (non-Javadoc)
176      * @see org.objectweb.util.explorer.api.Panel#unselected(org.objectweb.util.explorer.api.TreeView)
177      */

178     public void unselected(TreeView treeview) {
179         // Nothing to do!
180
}
181
182 }
183
184
185
Popular Tags