1 26 27 package org.objectweb.ccm.demo2.monolithic; 28 29 import org.objectweb.ccm.demo2.*; 30 31 43 44 public class ProducerImpl 45 extends org.omg.CORBA.LocalObject 46 implements CCM_Producer, 47 org.omg.Components.SessionComponent, 48 java.awt.event.ActionListener 49 { 50 56 57 private String name_; 58 59 60 private javax.swing.JFrame frame_; 61 62 63 private javax.swing.JList list_; 64 65 66 private CCM_Producer_Context the_context_; 67 68 74 75 public 76 ProducerImpl() 77 { 78 } 79 80 86 92 98 104 public void 105 configuration_complete () 106 throws org.omg.Components.InvalidConfiguration 107 { 108 if(name_ == null) 110 throw new org.omg.Components.InvalidConfiguration(); 111 112 114 frame_ = new javax.swing.JFrame (name_ + "'s Producer GUI"); 116 frame_.setSize(400, 300); 118 119 String [] data = { 121 "apple", "pear", "carrot", "corn", "milk", "orange" , "beer", 122 "radish", "beans", "pumpkin", "salad", "worm", "potato", "nothing" 123 }; 124 list_ = new javax.swing.JList (data); 125 126 javax.swing.JButton button = new javax.swing.JButton ("Do crop"); 128 button.addActionListener(this); 129 130 javax.swing.JPanel panel = new javax.swing.JPanel ( 132 new java.awt.BorderLayout () 133 ); 134 frame_.getContentPane().add(panel); 135 panel.add(new javax.swing.JScrollPane (list_), 136 java.awt.BorderLayout.CENTER); 137 panel.add(button, java.awt.BorderLayout.SOUTH); 138 frame_.pack(); 139 frame_.show(); 140 } 141 142 148 155 public void 156 set_session_context(org.omg.Components.SessionContext context) 157 throws org.omg.Components.CCMException 158 { 159 the_context_ = (CCM_Producer_Context)context; 160 } 161 162 167 public void 168 ccm_activate() 169 throws org.omg.Components.CCMException 170 { 171 } 173 174 179 public void 180 ccm_passivate() 181 throws org.omg.Components.CCMException 182 { 183 } 185 186 191 public void 192 ccm_remove() 193 throws org.omg.Components.CCMException 194 { 195 frame_.dispose(); 197 frame_ = null; 198 } 199 200 206 211 public void 212 name(String n) 213 { 214 name_ = n; 215 216 if (frame_ != null) 217 frame_.setTitle(name_ + "'s Producer GUI"); 218 } 219 220 225 public String 226 name() 227 { 228 return name_; 229 } 230 231 237 242 public void 243 actionPerformed(java.awt.event.ActionEvent e) 244 { 245 if (list_.isSelectionEmpty()) 246 return; 247 248 Object [] texts = list_.getSelectedValues(); 249 for (int i=0; i<texts.length; i++) 250 { 251 the_context_.push_crop(new FoodImpl( (String )texts[i] )); 252 } 253 254 list_.clearSelection(); 255 } 256 } 257 | Popular Tags |