1 19 20 28 29 package org.netbeans.modules.web.monitor.client; 30 31 import java.awt.event.ActionEvent ; 32 import java.awt.event.ActionListener ; 33 import javax.swing.JMenu ; 34 import javax.swing.JMenuItem ; 35 import javax.swing.JRadioButtonMenuItem ; 36 37 import org.netbeans.modules.web.monitor.client.Controller.CompAlpha; 38 import org.netbeans.modules.web.monitor.client.Controller.CompTime; 39 40 import org.openide.nodes.Node; 41 import org.openide.util.HelpCtx; 42 import org.openide.util.NbBundle; 43 import org.openide.util.actions.NodeAction; 44 45 46 47 public class SortAction extends NodeAction { 48 private transient JMenuItem descSortMenuItem, ascSortMenuItem, alphSortMenuItem; 50 51 protected boolean enable(Node[] activatedNodes) { 52 return true; 53 } 54 55 public HelpCtx getHelpCtx() { 56 return HelpCtx.DEFAULT_HELP; 57 } 58 59 public JMenuItem getPopupPresenter() { 60 JMenu menu = new JMenu (NbBundle.getMessage(MonitorAction.class, "MON_Sort_by")); 61 62 TransactionView transView = TransactionView.getInstance(); 63 descSortMenuItem = createItem( 64 NbBundle.getMessage(MonitorAction.class, "MON_Sort_desc"), 65 transView.isDescButtonSelected()); 66 ascSortMenuItem = createItem( 67 NbBundle.getMessage(MonitorAction.class, "MON_Sort_asc"), 68 transView.isAscButtonSelected()); 69 alphSortMenuItem = createItem( 70 NbBundle.getMessage(MonitorAction.class, "MON_Sort_alph"), 71 transView.isAlphButtonSelected()); 72 73 ActionListener listener = new RadioMenuItemActioListener(); 74 descSortMenuItem.addActionListener(listener); 75 ascSortMenuItem.addActionListener(listener); 76 alphSortMenuItem.addActionListener(listener); 77 78 menu.add(descSortMenuItem); 79 menu.add(ascSortMenuItem); 80 menu.add(alphSortMenuItem); 81 82 return menu; 83 } 84 85 private JMenuItem createItem(String dispName, boolean selected) { 86 JMenuItem item = new JRadioButtonMenuItem (); 87 item.setText(dispName); 88 item.setSelected(selected); 89 return item; 90 } 91 92 public String getName() { 93 return NbBundle.getMessage(MonitorAction.class, "MON_Sort_by"); 94 } 95 96 protected void performAction(Node[] activatedNodes) { 97 } 98 99 class RadioMenuItemActioListener implements ActionListener { 100 public void actionPerformed(ActionEvent e) { 101 Controller controller = MonitorAction.getController(); 102 TransactionView transView = TransactionView.getInstance(); 103 Object source = e.getSource(); 104 if (source == descSortMenuItem) { 105 if (!transView.isDescButtonSelected()) { 106 transView.toggleTaskbarButtons(false, true, false); 107 controller.setComparator(controller.new CompTime(true)); 108 } 109 } else if (source == ascSortMenuItem) { 110 if (!transView.isAscButtonSelected()) { 111 transView.toggleTaskbarButtons(true, false, false); 112 controller.setComparator(controller.new CompTime(false)); 113 } 114 } else if (source == alphSortMenuItem) { 115 if (!transView.isAlphButtonSelected()) { 116 transView.toggleTaskbarButtons(false, false, true); 117 controller.setComparator(controller.new CompAlpha()); 118 } 119 } 120 } 121 } 122 } 123 | Popular Tags |