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/08 23:18:39
6    */
7   package org.asyrinx.joey.gui.swing.listview;
8   
9   import java.awt.Component;
10  import java.awt.event.ActionEvent;
11  
12  import javax.swing.AbstractAction;
13  
14  import org.asyrinx.joey.gui.swing.EntityListViewTable;
15  
16  /***
17   * @author akima
18   */
19  public abstract class AbstractEntityListViewTableAction
20  	extends AbstractAction
21  	implements EntityListViewTableAction {
22  
23  	/***
24  	 * 
25  	 */
26  	public AbstractEntityListViewTableAction() {
27  		super();
28  	}
29  
30  	protected final EntityListViewTable getListViewComponent(ActionEvent e) {
31  		if (e != null) {
32  			final Object o = e.getSource();
33  			if (o instanceof EntityListViewTable) {
34  				return (EntityListViewTable) o;
35  			} else if (o instanceof ListViewMenuItem) {
36  				final ListViewMenuItem menuItem = (ListViewMenuItem) o;
37  				return menuItem.getOwner();
38  			} else if (o instanceof Component) {
39  				final Component component = (Component) o;
40  				if (component.getParent() instanceof EntityListViewTable) {
41  					return (EntityListViewTable) component.getParent();
42  				}
43  			}
44  		}
45  		return null;
46  	}
47  
48  	public boolean isOnPopupMenu() {
49  		return true;
50  	}
51  
52  	/* (non-Javadoc)
53  	 * @see org.asyrinx.joey.gui.swing.listview.EntityListViewTableAction#isEnabled(org.asyrinx.joey.gui.swing.EntityListViewTable)
54  	 */
55  	public boolean isEnabled(EntityListViewTable table) {
56  		return true;
57  	}
58  
59  }