KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > CosTrading > gui > QueryPanel


1 /*===========================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
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): Sylvain Leblanc.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.openccm.explorer.CosTrading.gui;
28
29 /** The Java API's imports */
30 import javax.swing.JPanel JavaDoc;
31 import java.awt.Color JavaDoc;
32 import javax.swing.BoxLayout JavaDoc;
33 import javax.swing.Box JavaDoc;
34 import javax.swing.border.TitledBorder JavaDoc;
35 import javax.swing.JLabel JavaDoc;
36
37 import org.objectweb.openccm.explorer.CosTrading.Query;
38
39 /**
40  * Panel used to view content of a
41  * <code>Query</code> instance.
42  *
43  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
44  * @version 0.1
45  */

46 public class QueryPanel extends DefaultNodeViewPanel {
47
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53

54     /** The query to display. */
55     protected Query query_;
56
57     // ==================================================================
58
//
59
// Constructors.
60
//
61
// ==================================================================
62

63     /**
64      * Default constructor.
65      */

66     public QueryPanel() {
67         setBackground(Color.white);
68         setLayout(new BoxLayout JavaDoc(this, BoxLayout.Y_AXIS));
69     }
70
71     // ==================================================================
72
//
73
// Internal methods.
74
//
75
// ==================================================================
76

77     // ==================================================================
78
//
79
// Public methods.
80
//
81
// ==================================================================
82

83     /**
84      * Creates the content of the panel.
85      */

86     public void onSetTreeView() {
87         if (getTreeView() != null) {
88             query_ = (Query)getTreeView().getSelectedObject();
89             if (query_ != null) {
90
91                 // Creates a new Panel
92
JPanel JavaDoc queryPanel = new JPanel JavaDoc();
93                 queryPanel.setBackground(Color.white);
94                 queryPanel.setBorder(new TitledBorder JavaDoc(null," " + query_.getQueryLabel() + " ",TitledBorder.CENTER,TitledBorder.TOP));
95                 
96                 // Creates various labels
97
JLabel JavaDoc stn_lab = new JLabel JavaDoc("Service Type: " + query_.getServiceTypeName());
98                 JLabel JavaDoc constr_lab = new JLabel JavaDoc("Constraint: " + query_.getConstraint());
99                 JLabel JavaDoc pref_lab = new JLabel JavaDoc("Preferences: " + query_.getPref());
100                 
101                 // Creates a new Swing box
102
Box JavaDoc box = Box.createVerticalBox();
103                 box.add(stn_lab);
104                 box.add(Box.createVerticalStrut(10));
105                 box.add(constr_lab);
106                 box.add(Box.createVerticalStrut(10));
107                 box.add(pref_lab);
108                 
109                 // Adding box and panel in this panel
110
queryPanel.add(box);
111                 add(queryPanel);
112             }
113         }
114     }
115 }
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Popular Tags