KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.awt.event.ActionEvent JavaDoc;
7 import java.awt.event.KeyEvent JavaDoc;
8
9 import javax.swing.Icon JavaDoc;
10 import javax.swing.JPopupMenu JavaDoc;
11 import javax.swing.KeyStroke JavaDoc;
12
13 import com.tc.admin.AdminClient;
14 import com.tc.admin.AdminClientContext;
15 import com.tc.admin.ConnectionContext;
16 import com.tc.admin.common.ComponentNode;
17 import com.tc.admin.common.XAbstractAction;
18
19 public class LocksNode extends ComponentNode {
20   private ConnectionContext m_cc;
21   private JPopupMenu JavaDoc m_popupMenu;
22
23   private static final String JavaDoc REFRESH_ACTION = "RefreshAction";
24   //private static final String DETECT_DEADLOCKS_ACTION = "DetectDeadlocksAction";
25

26   public LocksNode(ConnectionContext cc) {
27     super();
28
29     m_cc = cc;
30
31     setLabel(AdminClient.getContext().getMessage("dso.locks"));
32     setComponent(new LocksPanel(m_cc));
33     
34     initMenu();
35   }
36
37   private void initMenu() {
38     RefreshAction refreshAction = new RefreshAction();
39     //DetectDeadlocksAction detectDeadlocksAction = new DetectDeadlocksAction();
40

41     m_popupMenu = new JPopupMenu JavaDoc("Lock Actions");
42     m_popupMenu.add(refreshAction);
43     //m_popupMenu.add(detectDeadlocksAction);
44

45     addActionBinding(REFRESH_ACTION, refreshAction);
46     //addActionBinding(DETECT_DEADLOCKS_ACTION, detectDeadlocksAction);
47
}
48
49   public JPopupMenu JavaDoc getPopupMenu() {
50     return m_popupMenu;
51   }
52
53   public Icon JavaDoc getIcon() {
54     return LocksHelper.getHelper().getLocksIcon();
55   }
56
57   public void refresh() {
58     ((LocksPanel)getComponent()).refresh();
59   }
60
61   private class RefreshAction extends XAbstractAction {
62     private RefreshAction() {
63       super();
64
65       AdminClientContext acc = AdminClient.getContext();
66       
67       setName(acc.getMessage("refresh.name"));
68       setSmallIcon(LocksHelper.getHelper().getRefreshIcon());
69       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true));
70     }
71
72     public void actionPerformed(ActionEvent JavaDoc ae) {
73       refresh();
74     }
75   }
76
77   /*
78   private void detectDeadlocks() {
79     LocksHelper.getHelper().detectDeadlocks(m_cc);
80   }
81
82   private class DetectDeadlocksAction extends XAbstractAction {
83     private DetectDeadlocksAction() {
84       super();
85
86       AdminClientContext acc = AdminClient.getContext();
87       
88       setName(acc.getMessage("dso.deadlocks.detect"));
89       setSmallIcon(LocksHelper.getHelper().getDetectDeadlocksIcon());
90       setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0, true));
91     }
92
93     public void actionPerformed(ActionEvent ae) {
94       AdminClientContext acc = AdminClient.getContext();
95
96       acc.controller.setStatus(acc.getMessage("dso.deadlocks.detecting"));
97       try {
98         detectDeadlocks();
99       }
100       catch(Throwable t) {
101         t.printStackTrace();
102       }
103       acc.controller.clearStatus();
104     }
105   }
106   */

107   
108   public void tearDown() {
109     super.tearDown();
110
111     m_cc = null;
112     m_popupMenu = null;
113   }
114 }
115
Popular Tags