KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > plugin > java > swing > PropertiesPanel


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
27 package org.objectweb.util.explorer.plugin.java.swing;
28
29 import java.awt.Color JavaDoc;
30 import java.util.Enumeration JavaDoc;
31 import java.util.Properties JavaDoc;
32
33 import javax.swing.BoxLayout JavaDoc;
34 import javax.swing.JPanel JavaDoc;
35 import javax.swing.JScrollPane JavaDoc;
36 import javax.swing.JTable JavaDoc;
37
38 import org.objectweb.util.explorer.api.Panel;
39 import org.objectweb.util.explorer.api.TreeView;
40
41
42 /**
43  *
44  *
45  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
46  *
47  * @version 0.1
48  */

49 public class PropertiesPanel
50   implements Panel JavaDoc {
51
52     //==================================================================
53
//
54
// No internal state.
55
//
56
//==================================================================
57

58     /** The JPanel to display */
59     protected JPanel JavaDoc panel_;
60
61     //==================================================================
62
//
63
// Constructor.
64
//
65
//==================================================================
66

67     /**
68      * Empty constructor
69      */

70     public PropertiesPanel() {
71         panel_ = new JPanel JavaDoc();
72         panel_.setBackground(Color.white);
73         panel_.setLayout(new BoxLayout JavaDoc(panel_, BoxLayout.Y_AXIS));
74     }
75
76     //==================================================================
77
//
78
// No internal method.
79
//
80
//==================================================================
81

82     //==================================================================
83
//
84
// Public methods for ViewPanel interface.
85
//
86
//==================================================================
87

88     /* (non-Javadoc)
89      * @see org.objectweb.util.explorer.api.Panel#selected(org.objectweb.util.explorer.api.TreeView)
90      */

91     public void selected(TreeView treeView) {
92         String JavaDoc[] titre = {"Keys","Values"};
93         Properties JavaDoc properties = (Properties JavaDoc)treeView.getSelectedObject();
94         Enumeration JavaDoc keys, elements;
95         keys = properties.keys();
96         elements = properties.elements();
97         String JavaDoc[][] contenu = new String JavaDoc[properties.size()][2];
98         for (int i = 0; i < properties.size(); i++) {
99             contenu[i] = new String JavaDoc[]{(String JavaDoc) keys.nextElement(),(String JavaDoc)elements.nextElement()};
100         }
101         panel_.add(new JScrollPane JavaDoc(new JTable JavaDoc(contenu,titre)));
102     }
103
104     /* (non-Javadoc)
105      * @see org.objectweb.util.explorer.api.Panel#getPanel()
106      */

107     public Object JavaDoc getPanel() {
108         return panel_;
109     }
110
111     /* (non-Javadoc)
112      * @see org.objectweb.util.explorer.api.Panel#unselected(org.objectweb.util.explorer.api.TreeView)
113      */

114     public void unselected(TreeView treeview) {
115         // Nothing to do
116
}
117
118 }
Popular Tags