1
2
3
4
5
6
7 package org.asyrinx.joey.gui.swing.listview;
8
9 import javax.swing.JButton;
10 import javax.swing.JMenuItem;
11 import javax.swing.KeyStroke;
12
13 import org.asyrinx.joey.gui.swing.EntityListViewTable;
14
15 /***
16 * @author akima
17 */
18 public class ListViewMenuItem extends JMenuItem {
19
20 public ListViewMenuItem(EntityListViewTable owner,
21 EntityListViewTableAction action) {
22 super(action);
23 this.owner = owner;
24 this.listViewTableAction = action;
25 this.setHorizontalTextPosition(JButton.TRAILING);
26 this.setVerticalTextPosition(JButton.CENTER);
27 }
28
29 protected final EntityListViewTable owner;
30
31 protected final EntityListViewTableAction listViewTableAction;
32
33
34
35
36
37
38 public String getName() {
39 return (listViewTableAction == null) ? null : listViewTableAction
40 .getName();
41 }
42
43
44
45
46
47
48 public boolean isArmed() {
49 return (listViewTableAction == null) ? false : listViewTableAction
50 .isEnabled(this.owner);
51 }
52
53
54
55
56
57
58 public String getText() {
59 return (listViewTableAction == null) ? null : listViewTableAction
60 .getName();
61 }
62
63
64
65
66
67
68 public KeyStroke getAccelerator() {
69 return (listViewTableAction == null) ? null : listViewTableAction
70 .getAccelerator();
71 }
72
73
74
75
76
77
78 public boolean isEnabled() {
79 return (listViewTableAction == null) ? false : listViewTableAction
80 .isEnabled(this.owner);
81 }
82
83 /***
84 * @return
85 */
86 public EntityListViewTable getOwner() {
87 return owner;
88 }
89
90 }