KickJava   Java API By Example, From Geeks To Geeks.

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


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 /** OMG Trading Service imports. */
38 import org.omg.CosTrading.LinkPackage.LinkInfo;
39 import org.omg.CosTrading.FollowOption;
40
41 /**
42  * OMG CosTradingRepos TypeStruct Panel.
43  *
44  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
45  * @version 0.1
46  */

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

55     /** The link to display. */
56     protected LinkInfo linkInfo_;
57
58     // ==================================================================
59
//
60
// Constructors.
61
//
62
// ==================================================================
63

64     /**
65      * Default constructor.
66      */

67     public LinkInfoPanel() {
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 the string image of a follow option.
80      *
81      * @return The string image of a follow option.
82      */

83     protected String JavaDoc optionToString(FollowOption o) {
84         if (o.value() == FollowOption._local_only) return "local_only";
85         if (o.value() == FollowOption._if_no_local) return "if_no_local";
86         return "always";
87     }
88
89     // ==================================================================
90
//
91
// Public methods.
92
//
93
// ==================================================================
94

95     /**
96      * Creates the content of the Panel.
97      */

98     public void onSetTreeView() {
99         if (getTreeView() == null) return;
100         linkInfo_ = (LinkInfo)getTreeView().getSelectedObject();
101         String JavaDoc name = getTreeView().getSelectedEntry().getName().toString();
102         if (linkInfo_ != null) {
103
104             JPanel JavaDoc infoPanel = new JPanel JavaDoc();
105             infoPanel.setBackground(Color.white);
106             infoPanel.setBorder(new TitledBorder JavaDoc(null," " + name + " ",TitledBorder.CENTER,TitledBorder.TOP));
107             
108             Box JavaDoc box = Box.createVerticalBox();
109
110             box.add(Box.createVerticalGlue());
111
112             JLabel JavaDoc def = new JLabel JavaDoc();
113             def.setText("Default Follow Link Rule: " + optionToString(linkInfo_.def_pass_on_follow_rule) + ".");
114             box.add(def);
115
116             box.add(Box.createVerticalStrut(10));
117
118             JLabel JavaDoc limit = new JLabel JavaDoc();
119             limit.setText("Limiting Follow Link Rule: " + optionToString(linkInfo_.limiting_follow_rule) + ".");
120             box.add(limit);
121
122             box.add(Box.createVerticalGlue());
123             infoPanel.add(box);
124
125             add(infoPanel);
126         }
127     }
128 }
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
Popular Tags