View Javadoc

1   /*
2    * joey and its relative products are published under the terms
3    * of the Apache Software License.
4    * 
5    * Created on 2004/06/09 5:13:39
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  	 * (non-Javadoc)
35  	 * 
36  	 * @see java.awt.Component#getName()
37  	 */
38  	public String getName() {
39  		return (listViewTableAction == null) ? null : listViewTableAction
40  				.getName();
41  	}
42  
43  	/*
44  	 * (non-Javadoc)
45  	 * 
46  	 * @see javax.swing.JMenuItem#isArmed()
47  	 */
48  	public boolean isArmed() {
49  		return (listViewTableAction == null) ? false : listViewTableAction
50  				.isEnabled(this.owner);
51  	}
52  
53  	/*
54  	 * (non-Javadoc)
55  	 * 
56  	 * @see javax.swing.AbstractButton#getText()
57  	 */
58  	public String getText() {
59  		return (listViewTableAction == null) ? null : listViewTableAction
60  				.getName();
61  	}
62  
63  	/*
64  	 * (non-Javadoc)
65  	 * 
66  	 * @see javax.swing.JMenuItem#getAccelerator()
67  	 */
68  	public KeyStroke getAccelerator() {
69  		return (listViewTableAction == null) ? null : listViewTableAction
70  				.getAccelerator();
71  	}
72  
73  	/*
74  	 * (non-Javadoc)
75  	 * 
76  	 * @see java.awt.Component#isEnabled()
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  }