01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.admin.dso;
05:
06: import org.dijon.Container;
07: import org.dijon.ContainerResource;
08:
09: import com.tc.admin.AdminClient;
10: import com.tc.admin.AdminClientContext;
11: import com.tc.admin.ConnectionContext;
12: import com.tc.admin.common.Poller;
13: import com.tc.admin.common.RatePanel;
14: import com.tc.admin.common.XContainer;
15:
16: import java.awt.BorderLayout;
17:
18: import javax.management.ObjectName;
19: import javax.swing.SwingConstants;
20:
21: public class StatsPanel extends XContainer implements Poller {
22: private CacheActivityPanel m_cacheActivity;
23: private RatePanel m_txnRate;
24: private RatePanel m_cacheMissRate;
25:
26: public StatsPanel(ConnectionContext cc, ObjectName bean) {
27: AdminClientContext acc = AdminClient.getContext();
28:
29: load((ContainerResource) acc.topRes.getComponent("StatsPanel"));
30:
31: m_cacheActivity = new CacheActivityPanel(cc, bean,
32: SwingConstants.HORIZONTAL);
33: addPanel("Panel1", m_cacheActivity);
34:
35: String stat = "TransactionRate";
36: String header = acc.getMessage("dso.transaction.rate");
37: String yAxis = acc
38: .getMessage("dso.transaction.rate.range.label");
39: String xAxis = null;
40:
41: m_txnRate = new RatePanel(cc, bean, stat, header, xAxis, yAxis);
42: addPanel("Panel2", m_txnRate);
43:
44: stat = "CacheMissRate";
45: header = acc.getMessage("dso.cache.miss.rate");
46: yAxis = acc.getMessage("dso.cache.miss.rate.label");
47:
48: m_cacheMissRate = new RatePanel(cc, bean, stat, header, xAxis,
49: yAxis);
50:
51: addPanel("Panel3", m_cacheMissRate);
52: }
53:
54: private void addPanel(String parentPanelName, XContainer panel) {
55: Container parentPanel = (Container) getChild(parentPanelName);
56:
57: parentPanel.setLayout(new BorderLayout());
58: parentPanel.add(panel);
59: }
60:
61: public void stop() {
62: if (m_cacheActivity != null)
63: m_cacheActivity.stop();
64:
65: if (m_txnRate != null)
66: m_txnRate.stop();
67:
68: if (m_cacheMissRate != null)
69: m_cacheMissRate.stop();
70: }
71:
72: public void start() {
73: if (m_cacheActivity != null)
74: m_cacheActivity.start();
75:
76: if (m_txnRate != null)
77: m_txnRate.start();
78:
79: if (m_cacheMissRate != null)
80: m_cacheMissRate.start();
81: }
82:
83: public void tearDown() {
84: stop();
85:
86: super.tearDown();
87:
88: m_cacheActivity = null;
89: m_txnRate = null;
90: m_cacheMissRate = null;
91: }
92: }
|