KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > demo3 > cif > ConsumerImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.demo3.cif;
28
29 import org.objectweb.ccm.demo3.*;
30
31 /**
32  * This is the implementation of the OMG IDL3 demo3::Consumer component type.
33  *
34  * This class inherits from the skeleton
35  * generated by the OpenCCM's CIF to Java mapping generator.
36  *
37  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</A>
38  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</A>
39  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</A>
40  */

41
42 public class ConsumerImpl
43      extends org.objectweb.ccm.demo3.ConsumerSessionComposition.ComponentImpl
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     /** The name of the component. */
52     private String JavaDoc name_;
53
54     /** To refer to the GUI frame. */
55     private javax.swing.JFrame JavaDoc frame_;
56
57     /** To refer to the GUI user output area. */
58     private javax.swing.JTextArea JavaDoc textArea_;
59
60     // ==================================================================
61
//
62
// Constructor.
63
//
64
// ==================================================================
65

66     /** The default constructor. */
67     public
68     ConsumerImpl()
69     {
70     }
71
72     // ==================================================================
73
//
74
// Internal methods.
75
//
76
// ==================================================================
77

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

84     // ==================================================================
85
//
86
// Methods for OMG IDL Components::EnterpriseComponent
87
//
88
// ==================================================================
89

90     /**
91      * Completes the component configuration.
92      *
93      * @exception org.omg.Components.InvalidConfiguration
94      * Thrown if the configuration is invalid.
95      */

96     public void
97     configuration_complete()
98     throws org.omg.Components.InvalidConfiguration
99     {
100         // Checks if the configuration is not completed.
101
if(name_ == null)
102             throw new org.omg.Components.InvalidConfiguration();
103
104         // Instantiating the GUI.
105

106         // Creates a Swing Frame.
107
frame_ = new javax.swing.JFrame JavaDoc(name_ + "'s Consumer GUI");
108         // Sets its size.
109
frame_.setSize(400, 300);
110
111         // Creates a text area for displaying inputs.
112
textArea_ = new javax.swing.JTextArea JavaDoc(40, 20);
113         textArea_.setEditable(false);
114
115         // Constructs and shows the GUI.
116
javax.swing.JPanel JavaDoc panel = new javax.swing.JPanel JavaDoc(
117                                         new java.awt.BorderLayout JavaDoc());
118         frame_.getContentPane().add(panel);
119         panel.add(new javax.swing.JScrollPane JavaDoc(textArea_),
120                   java.awt.BorderLayout.CENTER);
121         frame_.pack();
122         frame_.show();
123     }
124
125     // ==================================================================
126
//
127
// Methods for the OMG IDL org.omg.Components.SessionComponent
128
//
129
// ==================================================================
130

131     /**
132      * Container callback to signal that the component is removed.
133      *
134      * @throw org.omg.Components.CCMException For any problems.
135      */

136     public void
137     ccm_remove()
138     throws org.omg.Components.CCMException
139     {
140         // Release the associated frame.
141
frame_.dispose();
142         frame_ = null;
143     }
144
145     // ==================================================================
146
//
147
// Methods for OMG IDL demo3::CCM_NamedComponent_Executor
148
//
149
// ==================================================================
150

151     /**
152      * The mutator method for the attribute name.
153      *
154      * @param n The name.
155      */

156     public void
157     name(String JavaDoc n)
158     {
159         name_ = n;
160
161         if (frame_ != null)
162             frame_.setTitle(name_ + "'s Consumer GUI");
163     }
164
165     /**
166      * The accessor method for the attribute name.
167      *
168      * @return The name.
169      */

170     public String JavaDoc
171     name()
172     {
173         return name_;
174     }
175
176     // ==================================================================
177
//
178
// Methods for OMG IDL demo3::CCM_TextEventConsumer
179
//
180
// ==================================================================
181

182     /**
183      * To receive demo3::Event events published by demo3::Server components.
184      *
185      * @param event The received event.
186      */

187     public void
188     push(TextEvent event)
189     {
190         // Put the text into the text area.
191
textArea_.append(event.text + "\n");
192     }
193 }
194
195
Popular Tags