1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.rt.swingmonitor.ui.action;
22
23 import java.awt.Component;
24 import java.awt.event.ActionEvent;
25
26 import javax.swing.AbstractAction;
27 import javax.swing.JTabbedPane;
28
29 import net.sf.jour.rt.swingmonitor.MonitoringJPanel;
30
31
32
33 /***
34 * TODO Add docs
35 *
36 * Created on 14.12.2004
37 * Contributing Author(s):
38 *
39 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
40 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
41 *
42 * @author vlads
43 * @version $Revision: 1.3 $ ($Author: vlads $) $Date: 2004/12/16 05:35:54 $
44 */
45 public class CloseCurrentTabAction extends AbstractAction {
46
47 private JTabbedPane tabbedPane = null;
48
49 /***
50 * @param tabbedPane
51 */
52 public CloseCurrentTabAction(JTabbedPane tabbedPane) {
53 super("Close tab");
54 this.tabbedPane = tabbedPane;
55 }
56
57 public boolean isEnabled() {
58 return true;
59 }
60
61 public boolean isEnabled_TODO() {
62 Component comp = tabbedPane.getSelectedComponent();
63 if (!(comp instanceof MonitoringJPanel)) {
64 return true;
65 }
66 return ((MonitoringJPanel) comp).canCloseTab();
67 }
68
69 /***
70 * Method actionPerformed
71 */
72 public void actionPerformed(ActionEvent e) {
73 if (!isEnabled_TODO()) {
74 return;
75 }
76 Component comp = tabbedPane.getSelectedComponent();
77 tabbedPane.remove(comp);
78 }
79 }