KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > filetransfer > cif > TVPDAImpl


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): Areski Flissi.
23 Contributor(s):
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.filetransfer.cif;
28
29 import org.objectweb.ccm.filetransfer.*;
30
31 import java.awt.*;
32
33 /**
34  * This is the implementation of the OMG IDL3 filetransfer::TV component type.
35  *
36  * This class inherits from the local CCM_TV interface
37  * generated by the OpenCCM's IDL3 to IDL2 mapping generator.
38  *
39  * This class also implements the filetransfer::Images event sink interface
40  * to consume Images events.
41  *
42  * @author <a HREF="mailto:Areski.Flissi@lifl.fr">Areski Flissi</A>
43  */

44
45 public class TVPDAImpl
46     extends org.objectweb.ccm.filetransfer.TVSessionComposition.ComponentImpl {
47     // ==================================================================
48
//
49
// Internal state.
50
//
51
// ==================================================================
52

53     /** The name of the component. */
54     private String JavaDoc name_;
55
56     /** To refer to the GUI frame. */
57     private java.awt.Frame JavaDoc frame_;
58     
59     FileTransfertPDA_impl FileTransfertImpl = null;
60
61     /** To refer to the GUI output area. */
62     private Canvas screen;
63
64     static Button channel;
65     static Button welcome;
66     static Choice choice;
67
68     // ==================================================================
69
//
70
// Constructor.
71
//
72
// ==================================================================
73

74     /** The default constructor. */
75     public TVPDAImpl() {
76
77         // Instantiating the GUI.
78

79         // Creates a Swing Frame.
80
frame_ = new java.awt.Frame JavaDoc(name_ + "'s TV");
81
82         //frame_.setSize(300, 250);
83

84         GridBagLayout gridbag = new GridBagLayout();
85         GridBagConstraints c = new GridBagConstraints();
86
87         frame_.setLayout(gridbag);
88
89         c.fill = GridBagConstraints.BOTH;
90         c.weightx = 1.0;
91         c.gridwidth = GridBagConstraints.REMAINDER;
92         welcome = new Button("...Receiving....");
93         gridbag.setConstraints(welcome, c);
94         frame_.add(welcome);
95
96         c.gridwidth = GridBagConstraints.REMAINDER;
97         c.weighty = 1.0;
98         screen = new Canvas();
99         screen.setSize(202,149);
100         gridbag.setConstraints(screen, c);
101         frame_.add(screen);
102
103         c.gridwidth = GridBagConstraints.REMAINDER;
104         c.weighty = 0.0;
105         channel = new Button("...Waiting for signal....");
106         gridbag.setConstraints(channel, c);
107         frame_.add(channel);
108
109         frame_.pack();
110         frame_.show();
111         
112         FileTransfertImpl =
113                     new FileTransfertPDA_impl(screen, channel, welcome);
114         
115         
116               
117
118     }
119
120     // ==================================================================
121
//
122
// Internal methods.
123
//
124
// ==================================================================
125

126     // ==================================================================
127
//
128
// Public methods.
129
//
130
// ==================================================================
131

132     // ==================================================================
133
//
134
// Methods for OMG IDL Components::EnterpriseComponent
135
//
136
// ==================================================================
137

138     /**
139      * Complete the component configuration.
140      *
141      * @exception org.omg.Components.InvalidConfiguration
142      * Thrown if the configuration is invalid.
143      */

144     public void configuration_complete()
145         throws org.omg.Components.InvalidConfiguration {
146         // Checks if the configuration is not completed.
147
if (name_ == null)
148             throw new org.omg.Components.InvalidConfiguration();
149
150         
151     }
152
153     // ==================================================================
154
//
155
// Methods for the OMG IDL org.omg.Components.SessionComponent
156
//
157
// ==================================================================
158

159     /**
160      * Container callback to signal that the component is removed.
161      *
162      * @throw org.omg.Components.CCMException For any problems.
163      */

164     public void ccm_remove() throws org.omg.Components.CCMException {
165         // Release the associated frame.
166
frame_.dispose();
167         frame_ = null;
168     }
169
170     // ==================================================================
171
//
172
// Methods for OMG IDL filetransfer::CCM_TV
173
//
174
// ==================================================================
175

176     /**
177      * The mutator method for the attribute name.
178      *
179      * @param n The name.
180      */

181     public void the_name(String JavaDoc n) {
182         name_ = n;
183
184         if (frame_ != null)
185             frame_.setTitle(name_ + "'s TV");
186     }
187
188     /**
189      * The accessor method for the attribute name.
190      *
191      * @return The name.
192      */

193     public String JavaDoc the_name() {
194         return name_;
195     }
196
197     // ==================================================================
198
//
199
// Methods for the OMG IDL filetransfer::CCM_FilesReceiver interface.
200
//
201
// ==================================================================
202

203     /**
204      * Implementation of the OMG IDL filetransfer::FilesReceiver::push operation.
205      *
206      * @param event The received event.
207      */

208     public void push(Images event) {
209     
210     if (event.datafile != null) {
211         // Display images
212
FileTransfertImpl.display_image(event.datafile, event.filename);
213         System.out.println(event.filename + " received by TV component");
214     }
215         
216
217     }
218
219 }
220
Popular Tags