1 package org.jacorb.poa.gui.poa; 2 3 22 23 import org.jacorb.poa.gui.*; 24 import org.jacorb.poa.gui.beans.*; 25 import org.jacorb.poa.util.*; 26 27 import java.awt.Label ; 28 import java.awt.Color ; 29 30 36 public class POAFrame 37 extends java.awt.Frame 38 implements org.jacorb.poa.gui.beans.CloseButtonPanelController, 39 DetailsButtonController, ObjectListItemController, 40 QueueListItemController, 41 org.jacorb.poa.gui.POAMonitorView, java.awt.event.WindowListener 42 { 43 44 private POAMonitorController controller = null; 45 private static Color aomBarColor = new java.awt.Color (196,196,0); 46 private static Color queueBarColor = new java.awt.Color (0,128,128); 47 private static Color activeRequestsBarColor1 = new java.awt.Color (0,128,0); 48 private static Color activeRequestsBarColor2 = new java.awt.Color (128,0,0); 49 private static Color threadPoolBarColor = new java.awt.Color (0,128,0); 50 private String poaName = ""; 51 private FillLevelBar aomBar = null; 52 private FillLevelBar queueBar = null; 53 private FillLevelBar activeRequestsBar = null; 54 private FillLevelBar threadPoolBar = null; 55 private Label stateLabel = null; 56 private Label threadLabel = null; 57 private Label lifespanLabel = null; 58 private Label idUniquenessLabel = null; 59 private Label idAssignmentLabel = null; 60 private Label servantRetentionLabel = null; 61 private Label requestProcessingLabel = null; 62 private Label implicitActivationLabel = null; 63 private java.awt.FontMetrics fontMetrics1 = null; 64 private org.jacorb.poa.gui.beans.CloseButtonPanel ivjButtonPanel = null; 65 private org.jacorb.poa.gui.beans.ConsolePanel ivjConsolePanel = null; 66 private java.awt.Panel ivjContentsPane = null; 67 private POAStatePanel ivjPOAStatePanel = null; 68 public void _actionCloseButtonPressed() { 69 if (controller != null) { 70 controller.actionCloseView(); 71 } 72 } 73 public void _actionDeactivateObject(String oidStr) { 74 if (controller != null) { 75 controller.actionDeactivateObject(oidStr); 76 } 77 } 78 public void _actionDetailsButtonPressed(String source) { 79 if (source.equals("aom")) { 80 _showAOMDialog(); 81 } else if (source.equals("queue")) { 82 _showQueueDialog(); 83 } else { 84 System.err.println("details unknown source: "+source); 85 } 86 } 87 91 92 private void connEtoC1(java.awt.event.WindowEvent arg1) { 93 try { 94 this._actionCloseButtonPressed(); 97 } catch (java.lang.Throwable ivjExc) { 100 handleException(ivjExc); 103 } 104 } 105 public void _destroy() { 106 dispose(); 107 } 108 private java.awt.FontMetrics _fontMetrics1() { 109 if (fontMetrics1 == null) { 110 fontMetrics1 = getPOAStatePanel()._getPolicyPanel()._getThreadLabel().getGraphics().getFontMetrics(); 111 } 112 return fontMetrics1; 113 } 114 private FillLevelBar _getActiveRequestsBar() { 115 if (activeRequestsBar == null) { 116 activeRequestsBar = getPOAStatePanel()._getTMPanel()._getActiveRequestsBar(); 117 } 118 return activeRequestsBar; 119 } 120 private FillLevelBar _getAOMBar() { 121 if (aomBar == null) { 122 aomBar = getPOAStatePanel()._getAOMPanel()._getAOMBar(); 123 } 124 return aomBar; 125 } 126 130 131 private org.jacorb.poa.gui.beans.CloseButtonPanel getButtonPanel() { 132 if (ivjButtonPanel == null) { 133 try { 134 ivjButtonPanel = new org.jacorb.poa.gui.beans.CloseButtonPanel(); 135 ivjButtonPanel.setName("ButtonPanel"); 136 } catch (java.lang.Throwable ivjExc) { 139 handleException(ivjExc); 142 } 143 }; 144 return ivjButtonPanel; 145 } 146 150 151 private org.jacorb.poa.gui.beans.ConsolePanel getConsolePanel() { 152 if (ivjConsolePanel == null) { 153 try { 154 ivjConsolePanel = new org.jacorb.poa.gui.beans.ConsolePanel(); 155 ivjConsolePanel.setName("ConsolePanel"); 156 } catch (java.lang.Throwable ivjExc) { 159 handleException(ivjExc); 162 } 163 }; 164 return ivjConsolePanel; 165 } 166 170 171 private java.awt.Panel getContentsPane() { 172 if (ivjContentsPane == null) { 173 try { 174 ivjContentsPane = new java.awt.Panel (); 175 ivjContentsPane.setName("ContentsPane"); 176 ivjContentsPane.setLayout(new java.awt.BorderLayout ()); 177 ivjContentsPane.setBackground(java.awt.SystemColor.control); 178 getContentsPane().add(getButtonPanel(), "South"); 179 getContentsPane().add(getConsolePanel(), "Center"); 180 getContentsPane().add(getPOAStatePanel(), "North"); 181 } catch (java.lang.Throwable ivjExc) { 184 handleException(ivjExc); 187 } 188 }; 189 return ivjContentsPane; 190 } 191 private Label _getIdAssignmentLabel() { 192 if (idAssignmentLabel == null) { 193 idAssignmentLabel = getPOAStatePanel()._getPolicyPanel()._getIdAssignmentLabel(); 194 } 195 return idAssignmentLabel; 196 } 197 private Label _getIdUniquenessLabel() { 198 if (idUniquenessLabel == null) { 199 idUniquenessLabel = getPOAStatePanel()._getPolicyPanel()._getIdUniquenessLabel(); 200 } 201 return idUniquenessLabel; 202 } 203 private Label _getImplicitActivationLabel() { 204 if (implicitActivationLabel == null) { 205 implicitActivationLabel = getPOAStatePanel()._getPolicyPanel()._getImplicitActivationLabel(); 206 } 207 return implicitActivationLabel; 208 } 209 private Label _getLifespanLabel() { 210 if (lifespanLabel == null) { 211 lifespanLabel = getPOAStatePanel()._getPolicyPanel()._getLifespanLabel(); 212 } 213 return lifespanLabel; 214 } 215 219 220 private POAStatePanel getPOAStatePanel() { 221 if (ivjPOAStatePanel == null) { 222 try { 223 ivjPOAStatePanel = new org.jacorb.poa.gui.poa.POAStatePanel(); 224 ivjPOAStatePanel.setName("POAStatePanel"); 225 } catch (java.lang.Throwable ivjExc) { 228 handleException(ivjExc); 231 } 232 }; 233 return ivjPOAStatePanel; 234 } 235 private FillLevelBar _getQueueBar() { 236 if (queueBar == null) { 237 queueBar = getPOAStatePanel()._getQueuePanel()._getQueueBar(); 238 } 239 return queueBar; 240 } 241 private Label _getRequestProcessingLabel() { 242 if (requestProcessingLabel == null) { 243 requestProcessingLabel = getPOAStatePanel()._getPolicyPanel()._getRequestProcessingLabel(); 244 } 245 return requestProcessingLabel; 246 } 247 private Label _getServantRetentionLabel() { 248 if (servantRetentionLabel == null) { 249 servantRetentionLabel = getPOAStatePanel()._getPolicyPanel()._getServantRetentionLabel(); 250 } 251 return servantRetentionLabel; 252 } 253 private Label _getStateLabel() { 254 if (stateLabel == null) { 255 stateLabel = getPOAStatePanel()._getStatePanel()._getStateLabel(); 256 } 257 return stateLabel; 258 } 259 private Label _getThreadLabel() { 260 if (threadLabel == null) { 261 threadLabel = getPOAStatePanel()._getPolicyPanel()._getThreadLabel(); 262 } 263 return threadLabel; 264 } 265 private FillLevelBar _getThreadPoolBar() { 266 if (threadPoolBar == null) { 267 threadPoolBar = getPOAStatePanel()._getTMPanel()._getThreadPoolBar(); 268 } 269 return threadPoolBar; 270 } 271 275 private void handleException(Throwable exception) { 276 277 278 } 281 public void _initActiveRequestsBar(int avg, int max) { 282 _getActiveRequestsBar().init(0, avg, max, activeRequestsBarColor1, activeRequestsBarColor2, true, false); 283 } 284 public void _initAOMBar(int max, boolean isVariable) { 285 _getAOMBar().init(0, 0, max, aomBarColor, null, false, isVariable); 286 } 287 290 291 private void initConnections() { 292 this.addWindowListener(this); 295 } 296 299 300 private void initialize() { 301 setName("POAFrame"); 304 setLayout(new java.awt.BorderLayout ()); 305 setSize(698, 310); 306 setTitle("POA Monitor"); 307 add(getContentsPane(), "Center"); 308 initConnections(); 309 getButtonPanel()._init(this, "Close"); 311 getPOAStatePanel()._getAOMPanel()._init(this); 312 getPOAStatePanel()._getQueuePanel()._init(this); 313 } 315 public void _initQueueBar(int max, boolean isVariable) { 316 _getQueueBar().init(0, 0, max, queueBarColor, null, false, isVariable); 317 } 318 public void _initThreadPoolBar(int max) { 319 _getThreadPoolBar().init(0, 0, max, threadPoolBarColor, null, false, false); 320 } 321 public void _inspectRequest(String oidStr) { 322 new MessageDialog(this, "Message", "This function is not yet implemented!").setVisible(true); 323 } 324 public void _inspectServantClass(String oidStr) { 325 new MessageDialog(this, "Message", "This function is not yet implemented!").setVisible(true); 326 } 327 public POAFrame(POAMonitorController _controller) { 328 super(); 329 controller = _controller; 330 initialize(); 331 } 332 336 public POAFrame(String title) { 337 super(title); 338 } 339 343 public static void main(java.lang.String [] args) { 344 try { 345 POAFrame aPOAFrame; 346 aPOAFrame = new POAFrame(); 347 try { 348 Class aCloserClass = Class.forName("com.ibm.uvm.abt.edit.WindowCloser"); 349 Class parmTypes[] = { java.awt.Window .class }; 350 Object parms[] = { aPOAFrame }; 351 java.lang.reflect.Constructor aCtor = aCloserClass.getConstructor(parmTypes); 352 aCtor.newInstance(parms); 353 } catch (java.lang.Throwable exc) {}; 354 aPOAFrame.setVisible(true); 355 } catch (Throwable exception) { 356 System.err.println("Exception occurred in main() of java.awt.Frame"); 357 exception.printStackTrace(System.out); 358 } 359 } 360 public void _printMessage(String str) { 361 getConsolePanel()._printMessage(str); 362 } 363 public void _removeRequest(String ridStr) { 364 if (controller != null) { 365 controller.actionRemoveRequestFromQueue(ridStr); 366 } 367 } 368 public void _setMaxThreadPoolBar(int value) { 369 _getThreadPoolBar().setMaxValue(value); 370 } 371 public void _setName(String str) { 372 poaName = str; 373 setTitle(poaName+" Monitor ("+_getStateLabel().getText()+")"); 374 } 375 public void _setPolicyIdAssignment(String str) { 376 _getIdAssignmentLabel().setText(" "+str); 377 } 378 public void _setPolicyIdUniqueness(String str) { 379 _getIdUniquenessLabel().setText(" "+str); 380 } 381 public void _setPolicyImplicitActivation(String str) { 382 _getImplicitActivationLabel().setText(" "+str); 383 } 384 public void _setPolicyLifespan(String str) { 385 _getLifespanLabel().setText(" "+str); 386 } 387 public void _setPolicyRequestProcessing(String str) { 388 _getRequestProcessingLabel().setText(" "+str); 389 } 390 public void _setPolicyServantRetention(String str) { 391 _getServantRetentionLabel().setText(" "+str); 392 } 393 public void _setPolicyThread(String str) { 394 _getThreadLabel().setText(" "+str); 395 } 396 public void _setState(String str) { 397 _getStateLabel().setText(str); 398 setTitle(poaName+" Monitor ("+str+")"); 399 } 400 public void _setValueActiveRequestsBar(int value) { 401 _getActiveRequestsBar().setCurrentValue(value); 402 } 403 public void _setValueAOMBar(int value) { 404 _getAOMBar().setCurrentValue(value); 405 } 406 public void _setValueQueueBar(int value) { 407 _getQueueBar().setCurrentValue(value); 408 } 409 public void _setValueThreadPoolBar(int value) { 410 _getThreadPoolBar().setCurrentValue(value); 411 } 412 public void _setVisible(boolean visible) { 413 setVisible(visible); 414 } 415 private void _showAOMDialog() { 416 417 if (controller == null) return; 418 419 StringPair[] data = controller.actionRetrieveAOMContent(); 420 421 DoubleListDialog showDialog = new DoubleListDialog(this, "Active Object Map Snapshot"); 422 showDialog._setHeaderLabel1("Object ID"); 423 showDialog._setHeaderLabel2("Servant Class"); 424 425 if (data != null) { 426 427 ObjectListItem[] items = new ObjectListItem[data.length]; 428 String helpStr; 429 int firstMax = 100; 430 int secondMax = 100; 431 int helpInt; 432 for (int i=0; i<data.length; i++) { 433 items[i] = new ObjectListItem(); 434 items[i]._init(this, data[i].first); 435 helpStr = POAUtil.convert(data[i].first.getBytes()); 436 items[i]._getFirstLabel().setText(helpStr); 437 items[i]._getSecondLabel().setText(data[i].second); 438 439 helpInt = _fontMetrics1().stringWidth(items[i]._getFirstLabel().getText()); 440 if (helpInt > firstMax) firstMax = helpInt; 441 442 helpInt = _fontMetrics1().stringWidth(items[i]._getSecondLabel().getText()); 443 if (helpInt > secondMax) secondMax = helpInt; 444 } 445 446 showDialog._setSize(firstMax+20, secondMax+20); 447 448 for (int i=0; i<data.length; i++) { 449 items[i]._setWidth(firstMax+20, secondMax+20); 450 showDialog._addItem(items[i]); 451 } 452 } 453 454 showDialog.setVisible(true); 455 } 456 private void _showQueueDialog() { 457 if (controller == null) return; 458 459 StringPair[] data = controller.actionRetrieveQueueContent(); 460 461 DoubleListDialog showDialog = new DoubleListDialog(this, "Queue Snapshot"); 462 showDialog._setHeaderLabel1("Request ID"); 463 showDialog._setHeaderLabel2("Object ID"); 464 465 if (data != null) { 466 467 QueueListItem[] items = new QueueListItem[data.length]; 468 String helpStr; 469 int firstMax = 100; 470 int secondMax = 100; 471 int helpInt; 472 for (int i=0; i<data.length; i++) { 473 items[i] = new QueueListItem(); 474 items[i]._init(this, data[i].first); 475 items[i]._getFirstLabel().setText(data[i].first); 476 helpStr = POAUtil.convert(data[i].second.getBytes()); 477 items[i]._getSecondLabel().setText(helpStr); 478 479 helpInt = _fontMetrics1().stringWidth(items[i]._getFirstLabel().getText()); 480 if (helpInt > firstMax) firstMax = helpInt; 481 482 helpInt = _fontMetrics1().stringWidth(items[i]._getSecondLabel().getText()); 483 if (helpInt > secondMax) secondMax = helpInt; 484 } 485 486 showDialog._setSize(firstMax+20, secondMax+20); 487 488 for (int i=0; i<data.length; i++) { 489 items[i]._setWidth(firstMax+20, secondMax+20); 490 showDialog._addItem(items[i]); 491 } 492 } 493 494 showDialog.setVisible(true); 495 } 496 499 500 public POAFrame() { 501 super(); 502 initialize(); 503 } 504 508 509 public void windowActivated(java.awt.event.WindowEvent e) { 510 } 515 519 public void windowClosed(java.awt.event.WindowEvent e) { 520 } 525 529 530 public void windowClosing(java.awt.event.WindowEvent e) { 531 if ((e.getSource() == this) ) { 534 connEtoC1(e); 535 } 536 } 539 543 public void windowDeactivated(java.awt.event.WindowEvent e) { 544 } 545 549 public void windowDeiconified(java.awt.event.WindowEvent e) { 550 } 551 555 public void windowIconified(java.awt.event.WindowEvent e) { 556 } 557 561 public void windowOpened(java.awt.event.WindowEvent e) { 562 } 563 } 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | Popular Tags |