1 28 29 30 package org.objectweb.ccm.logdemo; 31 32 36 public class ClientWithLogImpl 37 extends Client_MainSegBase 38 implements java.io.Serializable , java.awt.event.ActionListener , 39 org.coach.ECM.ECMExecutor, org.objectweb.ccm.logservice.LogCallback 40 { 41 private String _name; 43 private javax.swing.JFrame _frame; 44 private javax.swing.JTextField _text; 45 46 public 48 ClientWithLogImpl() 49 { 50 _name = null; 52 _frame = null; 53 _text = null; 54 } 55 56 60 final public void 61 configuration_complete() 62 throws org.omg.Components.InvalidConfiguration 63 { 64 _text = new javax.swing.JTextField ("", 1); 67 68 javax.swing.JButton printb = new javax.swing.JButton ("Send"); 70 printb.addActionListener(this); 71 72 javax.swing.JPanel panel = new javax.swing.JPanel (new java.awt.BorderLayout ()); 74 panel.add(new javax.swing.JScrollPane (_text), java.awt.BorderLayout.NORTH); 75 panel.add(printb, java.awt.BorderLayout.CENTER); 76 _frame = new javax.swing.JFrame (_name+" GUI"); 77 _frame.setSize(400, 300); 78 _frame.getContentPane().add(panel); 79 _frame.pack(); 80 _frame.show(); 81 } 82 83 84 88 final public org.omg.CORBA.Object 89 get_service_callback(String sid, String cid) 90 throws org.coach.ECM.UnknownService, 91 org.coach.ECM.UnknownServiceCallback 92 { 93 if (!sid.equals(org.objectweb.ccm.logservice.LOG_SERVICE_ID.value)) { 94 throw new org.coach.ECM.UnknownService(); 95 } 96 97 if (!cid.equals(org.objectweb.ccm.logservice.LOG_SERVICE_CALLBACK_ID.value)) { 98 throw new org.coach.ECM.UnknownServiceCallback(); 99 } 100 101 return this; 102 } 103 104 108 final public String 109 get_identity() 110 { 111 return "Client:"+name(); 112 } 113 114 118 final public void 119 name(String n) 120 { 121 _name = n; 122 123 if (_frame!=null) { 124 _frame.setTitle(_name+" GUI"); 125 } 126 } 127 128 final public String 129 name() 130 { 131 return _name; 132 } 133 134 138 final public void 139 actionPerformed(java.awt.event.ActionEvent e) 140 { 141 try { 142 Message msg = new Message(); 144 msg.header = _name; 145 msg.content = _text.getText(); 146 147 AsyncMessage amsg = new AsyncMessageImpl(msg); 149 150 org.omg.Components.LocalEvents levts = getCCM2Context().get_events(); 152 int chid = levts.get_channel("async_display"); 153 levts.push(amsg, chid); 154 155 org.omg.Components.LocalReceptacles lrecs = getCCM2Context().get_receptacles(); 157 org.omg.CORBA.Object obj = lrecs.get_connections("display")[0].ref(); 158 SynchronousDisplay dis = SynchronousDisplayHelper.narrow(obj); 159 if(dis!=null) { 161 dis.print(msg); 162 } 163 } catch (Exception ex) { 164 ex.printStackTrace(); 165 } 166 } 167 } 168 | Popular Tags |