1 26 27 package DiningPhilosophers.cif; 28 29 import DiningPhilosophers.*; 30 31 48 49 public class ObserverPdaImpl 50 extends DiningPhilosophers.ObserverServiceComposition.ObserverService_impl 51 { 52 58 59 private java.util.Hashtable philosopherStates_; 60 61 62 private java.awt.Frame frame_; 63 64 65 private java.util.Hashtable philosopherPanels_; 66 67 68 private java.awt.Panel panel_; 69 70 76 77 public 78 ObserverPdaImpl() 79 { 80 philosopherPanels_ = new java.util.Hashtable (); 81 } 82 83 89 95 101 108 public void 109 configuration_complete() 110 throws org.omg.Components.InvalidConfiguration 111 { 112 114 frame_ = new java.awt.Frame ("The Observer's GUI"); 116 frame_.setSize(400, 300); 118 119 panel_ = new java.awt.Panel (new java.awt.GridLayout (0, 1)); 121 java.awt.ScrollPane scroll_panel = new java.awt.ScrollPane (); 123 scroll_panel.add(panel_); 124 frame_.add(scroll_panel); 125 frame_.pack(); 126 frame_.show(); 127 } 128 129 135 140 public void 141 ccm_remove() 142 throws org.omg.Components.CCMException 143 { 144 frame_.dispose(); 146 frame_ = null; 147 } 148 149 155 160 public synchronized void 161 push(StatusInfo event) 162 { 163 if (! philosopherPanels_.containsKey(event.name)) { 164 PhilosopherPdaPanel panel = new PhilosopherPdaPanel(event); 165 panel_.add(panel); 166 philosopherPanels_.put(event.name, panel); 167 frame_.pack(); 168 frame_.show(); 169 } else { 170 PhilosopherPdaPanel panel; 171 panel = (PhilosopherPdaPanel)philosopherPanels_.get(event.name); 172 panel.updatePanel(event); 173 } 174 } 175 } 176 | Popular Tags |