1 4 package com.tc.admin.dso; 5 6 import org.dijon.ContainerResource; 7 8 import com.tc.admin.AdminClient; 9 import com.tc.admin.AdminClientContext; 10 import com.tc.admin.ConnectionContext; 11 import com.tc.admin.common.XAbstractAction; 12 import com.tc.admin.common.XContainer; 13 import com.tc.admin.common.XTree; 14 import com.tc.objectserver.lockmanager.api.LockMBean; 15 16 import java.awt.event.ActionEvent ; 17 import java.awt.event.KeyEvent ; 18 19 import javax.swing.KeyStroke ; 20 21 public class LocksPanel extends XContainer { 22 private ConnectionContext m_cc; 23 private LockMBean[] m_locks; 24 private XTree m_lockTree; 25 private LockTreeModel m_lockTreeModel; 26 27 private static final String REFRESH = "Refresh"; 28 29 public LocksPanel(ConnectionContext cc) { 30 super(); 31 32 AdminClientContext cntx = AdminClient.getContext(); 33 34 load((ContainerResource)cntx.topRes.getComponent("LocksPanel")); 35 36 m_cc = cc; 37 m_lockTree = (XTree)findComponent("LockTree"); 38 m_lockTree.setShowsRootHandles(true); 39 m_lockTree.setModel(m_lockTreeModel = new LockTreeModel(m_cc)); 40 41 KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true); 42 getActionMap().put(REFRESH, new RefreshAction()); 43 getInputMap().put(ks, REFRESH); 44 45 updateTreeModel(); 46 } 47 48 public class RefreshAction extends XAbstractAction { 49 public void actionPerformed(ActionEvent ae) { 50 refresh(); 51 } 52 } 53 54 private void updateTreeModel() { 55 try { 56 m_locks = LocksHelper.getHelper().getLocks(m_cc); 57 } 58 catch(Exception e) { 59 AdminClient.getContext().log(e); 60 m_locks = new LockMBean[]{}; 61 } 62 63 m_lockTreeModel.setLocks(m_locks); 64 m_lockTree.expandAll(); 65 } 66 67 public void refresh() { 68 AdminClientContext acc = AdminClient.getContext(); 69 70 acc.controller.setStatus(acc.getMessage("dso.locks.refreshing")); 71 updateTreeModel(); 72 acc.controller.clearStatus(); 73 } 74 } 75 | Popular Tags |