1 26 27 package org.objectweb.ccm.demo3.monolithic; 28 29 import org.objectweb.ccm.demo3.*; 30 31 44 45 public class ClientImpl 46 extends org.omg.CORBA.LocalObject 47 implements CCM_Client, 48 org.omg.Components.SessionComponent, 49 java.awt.event.ActionListener 50 { 51 57 58 private String name_; 59 60 61 private javax.swing.JFrame frame_; 62 63 64 private javax.swing.JTextField text_; 65 66 67 private CCM_Client_Context the_context_; 68 69 75 76 public 77 ClientImpl() 78 { 79 } 80 81 87 93 99 105 public void 106 configuration_complete() 107 throws org.omg.Components.InvalidConfiguration 108 { 109 if(name_ == null) 111 throw new org.omg.Components.InvalidConfiguration(); 112 113 if(the_context_.get_connection_the_service() == null) 115 throw new org.omg.Components.InvalidConfiguration(); 116 117 119 frame_ = new javax.swing.JFrame (name_ + "'s Client GUI"); 121 frame_.setSize(400, 300); 123 124 text_ = new javax.swing.JTextField ("", 1); 126 127 javax.swing.JButton button = new javax.swing.JButton ("Print Text"); 129 button.addActionListener(this); 130 131 javax.swing.JPanel panel = new javax.swing.JPanel ( 133 new java.awt.BorderLayout () 134 ); 135 frame_.getContentPane().add(panel); 136 panel.add(new javax.swing.JScrollPane (text_), 137 java.awt.BorderLayout.CENTER); 138 panel.add(button, java.awt.BorderLayout.SOUTH); 139 frame_.pack(); 140 frame_.show(); 141 } 142 143 149 156 public void 157 set_session_context(org.omg.Components.SessionContext context) 158 throws org.omg.Components.CCMException 159 { 160 the_context_ = (CCM_Client_Context)context; 161 } 162 163 168 public void 169 ccm_activate() 170 throws org.omg.Components.CCMException 171 { 172 } 174 175 180 public void 181 ccm_passivate() 182 throws org.omg.Components.CCMException 183 { 184 } 186 187 192 public void 193 ccm_remove() 194 throws org.omg.Components.CCMException 195 { 196 frame_.dispose(); 198 frame_ = null; 199 } 200 201 207 212 public void 213 name(String n) 214 { 215 name_ = n; 216 217 if (frame_ != null) 218 frame_.setTitle(name_ + "'s Client GUI"); 219 } 220 221 226 public String 227 name() 228 { 229 return name_; 230 } 231 232 238 243 public void 244 actionPerformed(java.awt.event.ActionEvent e) 245 { 246 Service service = the_context_.get_connection_the_service(); 249 250 if(service == null) 252 { 253 System.err.println("The demo3::Client::the_service receptacle is not set!"); 254 return; 255 } 256 257 service.display(name_ + ":" + text_.getText()); 259 } 260 } 261 | Popular Tags |