1 26 27 package DiningPhilosophers.monolithic; 28 29 import DiningPhilosophers.*; 30 31 48 49 public class ObserverPdaImpl 50 extends org.omg.CORBA.LocalObject 51 implements CCM_Observer, 52 CCM_StatusInfoConsumer, 53 org.omg.Components.SessionComponent 54 { 55 61 62 private CCM_Observer_Context the_context_; 63 64 65 private java.util.Hashtable philosopherStates_; 66 67 68 private java.awt.Frame frame_; 69 70 71 private java.util.Hashtable philosopherPanels_; 72 73 74 private java.awt.Panel panel_; 75 76 82 83 public 84 ObserverPdaImpl() 85 { 86 philosopherPanels_ = new java.util.Hashtable (); 87 } 88 89 95 101 107 114 public void 115 configuration_complete() 116 throws org.omg.Components.InvalidConfiguration 117 { 118 120 frame_ = new java.awt.Frame ("The Observer's GUI"); 122 frame_.setSize(400, 300); 124 125 panel_ = new java.awt.Panel (new java.awt.GridLayout (0, 1)); 127 java.awt.ScrollPane scroll_panel = new java.awt.ScrollPane (); 129 scroll_panel.add(panel_); 130 frame_.add(scroll_panel); 131 frame_.pack(); 132 frame_.show(); 133 } 134 135 141 146 public void 147 set_session_context(org.omg.Components.SessionContext context) 148 throws org.omg.Components.CCMException 149 { 150 the_context_ = (CCM_Observer_Context)context; 151 } 152 153 158 public void 159 ccm_activate() 160 throws org.omg.Components.CCMException 161 { 162 } 164 165 170 public void 171 ccm_passivate() 172 throws org.omg.Components.CCMException 173 { 174 } 176 177 182 public void 183 ccm_remove() 184 throws org.omg.Components.CCMException 185 { 186 frame_.dispose(); 188 frame_ = null; 189 } 190 191 197 201 public void 202 push_info(StatusInfo event) 203 { 204 push(event); 205 } 206 207 213 218 public synchronized void 219 push(StatusInfo event) 220 { 221 if (! philosopherPanels_.containsKey(event.name)) { 222 PhilosopherPdaPanel panel = new PhilosopherPdaPanel(event); 223 panel_.add(panel); 224 philosopherPanels_.put(event.name, panel); 225 frame_.pack(); 226 frame_.show(); 227 } else { 228 PhilosopherPdaPanel panel; 229 panel = (PhilosopherPdaPanel)philosopherPanels_.get(event.name); 230 panel.updatePanel(event); 231 } 232 } 233 } 234 | Popular Tags |