KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > browser > plugin > java > PropertiesPanel


1 /*====================================================================
2
3 Objectweb Browser framework
4 Copyright (C) 2000-2003 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.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.util.browser.plugin.java;
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.browser.api.TreeView;
39 import org.objectweb.util.browser.api.Panel;
40
41 /**
42  *
43  *
44  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
45  *
46  * @version 0.1
47  */

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

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

66     /**
67      * Empty constructor
68      */

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

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

87     /**
88      * @see org.objectweb.util.browser.api.Panel#selected(org.objectweb.util.browser.api.TreeView)
89      */

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

106     public JPanel JavaDoc getPanel() {
107         return panel_;
108     }
109
110     /**
111      * Overriding methods
112      * @see org.objectweb.util.browser.api.Panel#unselected(org.objectweb.util.browser.api.TreeView)
113      */

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