KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > admin > dso > StatsPanel


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.admin.dso;
5
6 import org.dijon.Container;
7 import org.dijon.ContainerResource;
8
9 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 JavaDoc;
17
18 import javax.management.ObjectName JavaDoc;
19 import javax.swing.SwingConstants JavaDoc;
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 JavaDoc bean) {
27     AdminClientContext acc = AdminClient.getContext();
28
29     load((ContainerResource) acc.topRes.getComponent("StatsPanel"));
30
31     m_cacheActivity = new CacheActivityPanel(cc, bean, SwingConstants.HORIZONTAL);
32     addPanel("Panel1", m_cacheActivity);
33
34     String JavaDoc stat = "TransactionRate";
35     String JavaDoc header = acc.getMessage("dso.transaction.rate");
36     String JavaDoc yAxis = acc.getMessage("dso.transaction.rate.range.label");
37     String JavaDoc xAxis = null;
38
39     m_txnRate = new RatePanel(cc, bean, stat, header, xAxis, yAxis);
40     addPanel("Panel2", m_txnRate);
41
42     stat = "CacheMissRate";
43     header = acc.getMessage("dso.cache.miss.rate");
44     yAxis = acc.getMessage("dso.cache.miss.rate.label");
45
46     m_cacheMissRate = new RatePanel(cc, bean, stat, header, xAxis, yAxis);
47
48     addPanel("Panel3", m_cacheMissRate);
49   }
50
51   private void addPanel(String JavaDoc parentPanelName, XContainer panel) {
52     Container parentPanel = (Container) getChild(parentPanelName);
53
54     parentPanel.setLayout(new BorderLayout JavaDoc());
55     parentPanel.add(panel);
56   }
57
58   public void stop() {
59     if (m_cacheActivity != null) m_cacheActivity.stop();
60
61     if (m_txnRate != null) m_txnRate.stop();
62
63     if (m_cacheMissRate != null) m_cacheMissRate.stop();
64   }
65
66   public void start() {
67     if (m_cacheActivity != null) m_cacheActivity.start();
68
69     if (m_txnRate != null) m_txnRate.start();
70
71     if (m_cacheMissRate != null) m_cacheMissRate.start();
72   }
73
74   public void tearDown() {
75     stop();
76
77     super.tearDown();
78
79     m_cacheActivity = null;
80     m_txnRate = null;
81     m_cacheMissRate = null;
82   }
83 }
84
Popular Tags