KickJava   Java API By Example, From Geeks To Geeks.

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


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 ClientStatsPanel extends XContainer implements Poller {
22   private CacheActivityPanel m_cacheActivity;
23   private RatePanel m_txnRate;
24
25   public ClientStatsPanel(ConnectionContext cc, ObjectName JavaDoc bean) {
26     AdminClientContext acc = AdminClient.getContext();
27
28     load((ContainerResource)acc.topRes.getComponent("ClientStatsPanel"));
29
30     m_cacheActivity = new CacheActivityPanel(cc, bean, SwingConstants.VERTICAL);
31     addPanel("Panel1", m_cacheActivity);
32
33     String JavaDoc stat = "TransactionRate";
34     String JavaDoc header = acc.getMessage("dso.transaction.rate");
35     String JavaDoc xAxis = null;
36     String JavaDoc yAxis = acc.getMessage("dso.transaction.rate.range.label");
37     
38     m_txnRate = new RatePanel(cc, bean, stat, header, xAxis, yAxis);
39     addPanel("Panel2", m_txnRate);
40   }
41
42   private void addPanel(String JavaDoc parentPanelName, XContainer panel) {
43     Container parentPanel = (Container)getChild(parentPanelName);
44
45     parentPanel.setLayout(new BorderLayout JavaDoc());
46     parentPanel.add(panel);
47   }
48
49   public void stop() {
50     if(m_cacheActivity != null)
51       m_cacheActivity.stop();
52     
53     if(m_txnRate != null)
54       m_txnRate.stop();
55   }
56
57   public void start() {
58     if(m_cacheActivity != null)
59       m_cacheActivity.start();
60     
61     if(m_txnRate != null)
62       m_txnRate.start();
63   }
64
65   public void tearDown() {
66     stop();
67
68     super.tearDown();
69
70     m_cacheActivity = null;
71     m_txnRate = null;
72   }
73 }
74
Popular Tags