KickJava   Java API By Example, From Geeks To Geeks.

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


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

26
27 package org.objectweb.openccm.explorer.CosTrading.gui;
28
29 import java.awt.Color JavaDoc;
30
31 import javax.swing.Box JavaDoc;
32 import javax.swing.BoxLayout JavaDoc;
33 import javax.swing.JPanel JavaDoc;
34 import javax.swing.border.TitledBorder JavaDoc;
35
36 import org.objectweb.openccm.explorer.menu.LabelBox;
37 import org.omg.CosTrading.Admin;
38 import org.omg.CosTrading.FollowOption;
39
40 /**
41  * OMG CosTradingRepos TypeStruct Panel.
42  *
43  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
44  * @version 0.1
45  */

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

56     /** The CosTrading Admin reference. */
57     protected Admin admin_;
58
59     // ==================================================================
60
//
61
// Constructors.
62
//
63
// ==================================================================
64

65     /**
66      * Default constructor. */

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

78     /**
79      * Returns a new management panel for attributes described in the
80      * SupportAttributes OMG IDL interface.
81      *
82      * @return A new JPanel with all to manage SupportAttributes of a
83      * trader.
84      */

85     protected JPanel JavaDoc addSupportAttributes() {
86         JPanel JavaDoc supportPanel = new JPanel JavaDoc();
87         supportPanel.setBackground(Color.white);
88         supportPanel.setBorder(new TitledBorder JavaDoc(null," Support attributes ",TitledBorder.CENTER,TitledBorder.TOP));
89
90         Box JavaDoc box = Box.createVerticalBox();
91
92         // supports_modifiable_properties
93
BooleanBox supports_modifiable_properties = new BooleanBox("Supports of modifiable properties: ",
94                                                                    admin_.supports_modifiable_properties());
95         supports_modifiable_properties.addItemListener(new AbstractItemListener(admin_)
96             {
97                 protected void doAdminAction(Object JavaDoc modified_item) {
98                     adm_.set_supports_modifiable_properties(new Boolean JavaDoc((String JavaDoc)modified_item).booleanValue());
99                 }
100             });
101         supports_modifiable_properties.setToolTipText("Whether the trader supports property modification.");
102
103         // supports_dynamic_properties
104
BooleanBox supports_dynamic_properties = new BooleanBox("Supports of dynamic properties: ",
105                                                                 admin_.supports_dynamic_properties());
106         supports_dynamic_properties.addItemListener(new AbstractItemListener(admin_)
107             {
108                 protected void doAdminAction(Object JavaDoc modified_item) {
109                     adm_.set_supports_dynamic_properties(new Boolean JavaDoc((String JavaDoc)modified_item).booleanValue());
110                 }
111             });
112         supports_dynamic_properties.setToolTipText("Whether the trader supports dynamic properties.");
113
114         // supports_proxy_offers
115
BooleanBox supports_proxy_offers = new BooleanBox("Supports of proxy offers: ",
116                                                           admin_.supports_proxy_offers());
117         supports_proxy_offers.addItemListener(new AbstractItemListener(admin_)
118             {
119                 protected void doAdminAction(Object JavaDoc modified_item) {
120                     adm_.set_supports_proxy_offers(new Boolean JavaDoc((String JavaDoc)modified_item).booleanValue());
121                 }
122             });
123         supports_proxy_offers.setToolTipText("Whether the trader supports proxy offers.");
124
125         box.add(supports_modifiable_properties);
126         box.add(Box.createVerticalStrut(10));
127         box.add(supports_dynamic_properties);
128         box.add(Box.createVerticalStrut(10));
129         box.add(supports_proxy_offers);
130
131         supportPanel.add(box);
132
133         return supportPanel;
134     }
135
136     /**
137      * Returns a new management panel for attributes described in the
138      * LinkAttributes OMG IDL interface.
139      *
140      * @return A new JPanel with all to manage LinkAttributes of a
141      * trader.
142      */

143     protected JPanel JavaDoc addLinkAttributes() {
144         JPanel JavaDoc linkAttrPanel = new JPanel JavaDoc();
145         linkAttrPanel.setBackground(Color.white);
146         linkAttrPanel.setBorder(new TitledBorder JavaDoc(null," Link attributes ",TitledBorder.CENTER,TitledBorder.TOP));
147
148         // max_link_follow_policy
149
FollowOptionBox max_link_follow_policy = new FollowOptionBox("Maximum link follow policy allowed: ",
150                                                                      admin_.max_link_follow_policy());
151         max_link_follow_policy.addItemListener(new AbstractItemListener(admin_)
152             {
153                 protected void doAdminAction(Object JavaDoc modified_item) {
154                     FollowOption opt;
155                     String JavaDoc value = (String JavaDoc)modified_item;
156                     if (value.equals("local_only")) opt = FollowOption.local_only;
157                     else if (value.equals("if_no_local")) opt = FollowOption.if_no_local;
158                     else opt = FollowOption.always;
159                     adm_.set_max_link_follow_policy(opt);
160                 }
161             });
162         max_link_follow_policy.setToolTipText("Most permissive follow policy " +
163                                               "allowed when creating new links.");
164
165         Box JavaDoc box = Box.createVerticalBox();
166         box.add(max_link_follow_policy);
167
168         linkAttrPanel.add(box);
169
170         return linkAttrPanel;
171     }
172
173     /**
174      * Returns a new management panel for attributes described in the
175      * ImportAttributes OMG IDL interface.
176      *
177      * @return A new JPanel with all to manage ImportAttributes of a
178      * trader.
179      */

180     protected JPanel JavaDoc addImportAttributes() {
181         JPanel JavaDoc importAttrPanel = new JPanel JavaDoc();
182         importAttrPanel.setBackground(Color.white);
183         importAttrPanel.setBorder(new TitledBorder JavaDoc(null," Import attributes ",TitledBorder.CENTER,TitledBorder.TOP));
184
185         // def_search_card
186
LabelBox def_search_card = new LabelBox("Default search cardinality: ", String.valueOf(admin_.def_search_card()));
187         def_search_card.addActionListener(new AbstractTextActionListener(admin_)
188             {
189                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
190                     adm_.set_def_search_card(Integer.parseInt(e.getActionCommand()));
191                 }
192             });
193         def_search_card.setToolTipText("Default upper bound of offers to be searched for a query operation.");
194
195         // max_search_card
196
LabelBox max_search_card = new LabelBox("Maximum search cardinality: ", String.valueOf(admin_.max_search_card()));
197         max_search_card.addActionListener(new AbstractTextActionListener(admin_)
198             {
199                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
200                     adm_.set_max_search_card(Integer.parseInt(e.getActionCommand()));
201                 }
202             });
203         max_search_card.setToolTipText("Maximum upper bound of offers to be searched for a query operation.");
204
205         // def_match_card
206
LabelBox def_match_card = new LabelBox("Default match cardinality: ", String.valueOf(admin_.def_match_card()));
207         def_match_card.addActionListener(new AbstractTextActionListener(admin_)
208             {
209                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
210                     adm_.set_def_match_card(Integer.parseInt(e.getActionCommand()));
211                 }
212             });
213         def_match_card.setToolTipText("Default upper bound of matched offers to be ordered in applying a preference criteria.");
214
215         // max_match_card
216
LabelBox max_match_card = new LabelBox("Maximum match cardinality: ", String.valueOf(admin_.max_match_card()));
217         max_match_card.addActionListener(new AbstractTextActionListener(admin_)
218             {
219                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
220                     adm_.set_max_match_card(Integer.parseInt(e.getActionCommand()));
221                 }
222             });
223         max_match_card.setToolTipText("Maximum upper bound of matched offers to be ordered in applying a preference criteria.");
224
225         // def_return_card
226
LabelBox def_return_card = new LabelBox("Default return cardinality: ", String.valueOf(admin_.def_return_card()));
227         def_return_card.addActionListener(new AbstractTextActionListener(admin_)
228             {
229                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
230                     adm_.set_def_return_card(Integer.parseInt(e.getActionCommand()));
231                 }
232             });
233         def_return_card.setToolTipText("Default upper bound of ordered offers to be returned to an importer.");
234
235         // max_return_card
236
LabelBox max_return_card = new LabelBox("Maximum return cardinality: ", String.valueOf(admin_.max_return_card()));
237         max_return_card.addActionListener(new AbstractTextActionListener(admin_)
238             {
239                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
240                     adm_.set_max_return_card(Integer.parseInt(e.getActionCommand()));
241                 }
242             });
243         max_return_card.setToolTipText("Maximum upper bound of ordered offers to be returned to an importer.");
244
245         // max_list
246
LabelBox max_list = new LabelBox("Maximum list size: ", String.valueOf(admin_.max_list()));
247         max_list.addActionListener(new AbstractTextActionListener(admin_)
248             {
249                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
250                     adm_.set_max_list(Integer.parseInt(e.getActionCommand()));
251                 }
252             });
253         max_list.setToolTipText("The upper bound on the size of any list returned by the trader.");
254
255         // def_hop_count
256
LabelBox def_hop_count = new LabelBox("Default hop count: ", String.valueOf(admin_.def_hop_count()));
257         def_hop_count.addActionListener(new AbstractTextActionListener(admin_)
258             {
259                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
260                     adm_.set_def_hop_count(Integer.parseInt(e.getActionCommand()));
261                 }
262             });
263         def_hop_count.setToolTipText("Default upper bound of depth of links to be traversed.");
264
265         // max_hop_count
266
LabelBox max_hop_count = new LabelBox("Maximum hop count: ", String.valueOf(admin_.max_hop_count()));
267         def_hop_count.addActionListener(new AbstractTextActionListener(admin_)
268             {
269                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
270                     adm_.set_def_hop_count(Integer.parseInt(e.getActionCommand()));
271                 }
272             });
273         max_hop_count.setToolTipText("Maximum upper bound of depth of links to be traversed.");
274
275         // def_follow_policy
276
FollowOptionBox def_follow_policy = new FollowOptionBox("Default follow policy: ",
277                                                                 admin_.def_follow_policy());
278         def_follow_policy.addItemListener(new AbstractItemListener(admin_)
279             {
280                 protected void doAdminAction(Object JavaDoc modified_item) {
281                     FollowOption opt;
282                     String JavaDoc value = (String JavaDoc)modified_item;
283                     if (value.equals("local_only")) opt = FollowOption.local_only;
284                     else if (value.equals("if_no_local")) opt = FollowOption.if_no_local;
285                     else opt = FollowOption.always;
286                     adm_.set_def_follow_policy(opt);
287                 }
288             });
289         def_follow_policy.setToolTipText("Default link follow behavior for a particular trader.");
290
291         // max_follow_policy
292
FollowOptionBox max_follow_policy = new FollowOptionBox("Maximum follow policy: ",
293                                                                 admin_.max_follow_policy());
294         max_follow_policy.addItemListener(new AbstractItemListener(admin_)
295             {
296                 protected void doAdminAction(Object JavaDoc modified_item) {
297                     FollowOption opt;
298                     String JavaDoc value = (String JavaDoc)modified_item;
299                     if (value.equals("local_only")) opt = FollowOption.local_only;
300                     else if (value.equals("if_no_local")) opt = FollowOption.if_no_local;
301                     else opt = FollowOption.always;
302                     adm_.set_max_follow_policy(opt);
303                 }
304             });
305         max_follow_policy.setToolTipText("Limiting link follow policy for all links of the trader - overrides both link and importer policies.");
306
307
308         // Adding them to the box
309
Box JavaDoc box = Box.createVerticalBox();
310         box.add(def_search_card);
311         box.add(Box.createVerticalStrut(10));
312         box.add(max_search_card);
313         box.add(Box.createVerticalStrut(10));
314         box.add(def_match_card);
315         box.add(Box.createVerticalStrut(10));
316         box.add(max_match_card);
317         box.add(Box.createVerticalStrut(10));
318         box.add(def_return_card);
319         box.add(Box.createVerticalStrut(10));
320         box.add(max_return_card);
321         box.add(Box.createVerticalStrut(10));
322         box.add(max_list);
323         box.add(Box.createVerticalStrut(10));
324         box.add(def_hop_count);
325         box.add(Box.createVerticalStrut(10));
326         box.add(max_hop_count);
327         box.add(Box.createVerticalStrut(10));
328         box.add(def_follow_policy);
329         box.add(Box.createVerticalStrut(10));
330         box.add(max_follow_policy);
331         importAttrPanel.add(box);
332
333         return importAttrPanel;
334     }
335
336     /**
337      * Returns a new management panel for other configurable things of
338      * the Admin OMG IDL interface.
339      *
340      * @return A new JPanel with all to manage other things
341      * configurable via the Admin OMG IDL interface.
342      */

343     protected JPanel JavaDoc addOtherAttributes() {
344         JPanel JavaDoc otherAttrPanel = new JPanel JavaDoc();
345         otherAttrPanel.setBackground(Color.white);
346         otherAttrPanel.setBorder(new TitledBorder JavaDoc(null," Other attributes ",TitledBorder.CENTER,TitledBorder.TOP));
347
348         // request_id_stem
349
LabelBox request_id_stem = new LabelBox("request_id_stem: ", new String JavaDoc(admin_.request_id_stem()));
350         request_id_stem.addActionListener(new AbstractTextActionListener(admin_)
351             {
352                 protected void doAdminAction(java.awt.event.ActionEvent JavaDoc e) {
353                     adm_.set_request_id_stem(e.getActionCommand().getBytes());
354                 }
355             });
356         request_id_stem.setToolTipText("Identification of the trader, to be \n" +
357                                        "used as the stem for the production of \n" +
358                                        "an id for a query request from one trader \n" +
359                                        "to another.");
360
361         Box JavaDoc box = Box.createVerticalBox();
362         box.add(request_id_stem);
363         otherAttrPanel.add(box);
364
365         return otherAttrPanel;
366     }
367
368     // ==================================================================
369
//
370
// Public methods.
371
//
372
// ==================================================================
373

374     /**
375      * Creates the content of the Panel.
376      */

377     public void onSetTreeView() {
378         if (getTreeView() == null) return;
379         admin_ = (Admin)getTreeView().getSelectedObject();
380         if (admin_ != null) {
381             add(addSupportAttributes());
382             add(addLinkAttributes());
383             add(addImportAttributes());
384             add(addOtherAttributes());
385         }
386     }
387 }
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
Popular Tags