KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.*;
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 TVImpl
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 javax.swing.JFrame JavaDoc frame_;
58     FileTransfert_impl FileTransfertImpl = null;
59
60     /** To refer to the GUI output area. */
61     private JButton screen;
62     static JButton label;
63     
64
65     // ==================================================================
66
//
67
// Constructor.
68
//
69
// ==================================================================
70

71     /** The default constructor. */
72     public TVImpl() {
73
74         // Instantiating the GUI.
75

76         // Creates a Swing Frame.
77
frame_ = new javax.swing.JFrame JavaDoc(name_ + "'s TV");
78         frame_.setSize(215, 204);
79         
80         javax.swing.JPanel JavaDoc border = new javax.swing.JPanel JavaDoc(new java.awt.BorderLayout JavaDoc());
81         
82         screen = new JButton();
83         label = new JButton("...Waiting for signal....");
84         
85               
86         // Packing the GUI
87
border.add(screen, java.awt.BorderLayout.CENTER);
88         border.add(label, java.awt.BorderLayout.SOUTH);
89         frame_.getContentPane().add(border);
90
91         // Display the GUI
92
frame_.show();
93         
94         FileTransfertImpl =
95                     new FileTransfert_impl(screen, label);
96         
97         
98               
99
100     }
101
102     // ==================================================================
103
//
104
// Internal methods.
105
//
106
// ==================================================================
107

108     // ==================================================================
109
//
110
// Public methods.
111
//
112
// ==================================================================
113

114     // ==================================================================
115
//
116
// Methods for OMG IDL Components::EnterpriseComponent
117
//
118
// ==================================================================
119

120     /**
121      * Complete the component configuration.
122      *
123      * @exception org.omg.Components.InvalidConfiguration
124      * Thrown if the configuration is invalid.
125      */

126     public void configuration_complete()
127         throws org.omg.Components.InvalidConfiguration {
128         // Checks if the configuration is not completed.
129
if (name_ == null)
130             throw new org.omg.Components.InvalidConfiguration();
131
132         
133     }
134
135     // ==================================================================
136
//
137
// Methods for the OMG IDL org.omg.Components.SessionComponent
138
//
139
// ==================================================================
140

141     /**
142      * Container callback to signal that the component is removed.
143      *
144      * @throw org.omg.Components.CCMException For any problems.
145      */

146     public void ccm_remove() throws org.omg.Components.CCMException {
147         // Release the associated frame.
148
frame_.dispose();
149         frame_ = null;
150     }
151
152     // ==================================================================
153
//
154
// Methods for OMG IDL filetransfer::CCM_TV
155
//
156
// ==================================================================
157

158     /**
159      * The mutator method for the attribute name.
160      *
161      * @param n The name.
162      */

163     public void the_name(String JavaDoc n) {
164         name_ = n;
165
166         if (frame_ != null)
167             frame_.setTitle(name_ + "'s TV");
168     }
169
170     /**
171      * The accessor method for the attribute name.
172      *
173      * @return The name.
174      */

175     public String JavaDoc the_name() {
176         return name_;
177     }
178
179     // ==================================================================
180
//
181
// Methods for the OMG IDL filetransfer::CCM_FilesReceiver interface.
182
//
183
// ==================================================================
184

185     /**
186      * Implementation of the OMG IDL filetransfer::FilesReceiver::push operation.
187      *
188      * @param event The received event.
189      */

190     public void push(Images event) {
191     
192     if (event.datafile != null) {
193         // Display images
194
//FileTransfertImpl.storeLastSend(event.datafile, event.filename);
195
FileTransfertImpl.display_image(event.datafile, event.filename);
196         
197         System.out.println(event.filename + " received by TV component");
198     }
199         
200
201     }
202
203 }
204
Popular Tags