JIDE 3.5.15

com.jidesoft.grid
Class TableHeaderPopupMenuInstaller

java.lang.Object
  extended by java.awt.event.MouseAdapter
      extended by com.jidesoft.grid.TableHeaderPopupMenuInstaller
All Implemented Interfaces:
MouseListener, MouseMotionListener, MouseWheelListener, PropertyChangeListener, EventListener

public class TableHeaderPopupMenuInstaller
extends MouseAdapter
implements PropertyChangeListener

TableHeaderPopupMenuInstaller allows you to add a popup menu to table header and customize it. To use it, you just need to call


 TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(table);
 
Or if you want to uninstall it, call

 TableHeaderPopupMenuInstaller.getTableHeaderPopupMenuInstaller(table).uninstallListeners();
 
However TableHeaderPopupMenuInstaller has no menu items. You can use one of the existing TableHeaderPopupMenuCustomizers to add more menu items or create your own TableHeaderPopupMenuCustomizer to do it.


Field Summary
static String CLIENT_PROPERTY_POPUP_MENU_INSTALLER
          Client property used by JTable to provide its own TableColumnPopupMenuCustomizer.
 
Constructor Summary
TableHeaderPopupMenuInstaller(JTable table)
          Creates a TableColumnPopupMenuCustomizer.
 
Method Summary
static void addSeparatorIfNecessary(JPopupMenu popup)
          Adds a separator to the popup menu if there are menu items on it already.
 void addTableHeaderPopupMenuCustomizer(TableHeaderPopupMenuCustomizer customizer)
           
protected  JPopupMenu createPopupMenu()
           
protected  void customizeMenuItems(JTableHeader header, JPopupMenu popup, int clickingColumn)
          Customizes the menu items for the popup menu.
 TableHeaderPopupMenuCustomizer[] getTableHeaderPopupMenuCustomizers()
           
static TableHeaderPopupMenuInstaller getTableHeaderPopupMenuInstaller(JTable table)
          Gets the Searchable installed on the component.
 void installListeners()
          Installs the listeners needed in order to show the popup menu for the table header.
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void propertyChange(PropertyChangeEvent evt)
           
 void removeTableHeaderPopupMenuCustomizer(TableHeaderPopupMenuCustomizer customizer)
           
 void uninstallListeners()
          Uninstalls the listeners needed in order to show the popup menu for the table header.
 
Methods inherited from class java.awt.event.MouseAdapter
mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseWheelMoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_PROPERTY_POPUP_MENU_INSTALLER

public static final String CLIENT_PROPERTY_POPUP_MENU_INSTALLER
Client property used by JTable to provide its own TableColumnPopupMenuCustomizer.

See Also:
Constant Field Values
Constructor Detail

TableHeaderPopupMenuInstaller

public TableHeaderPopupMenuInstaller(JTable table)
Creates a TableColumnPopupMenuCustomizer.

Parameters:
table - the table.
Method Detail

addTableHeaderPopupMenuCustomizer

public void addTableHeaderPopupMenuCustomizer(TableHeaderPopupMenuCustomizer customizer)

removeTableHeaderPopupMenuCustomizer

public void removeTableHeaderPopupMenuCustomizer(TableHeaderPopupMenuCustomizer customizer)

getTableHeaderPopupMenuCustomizers

public TableHeaderPopupMenuCustomizer[] getTableHeaderPopupMenuCustomizers()

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class MouseAdapter

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class MouseAdapter

createPopupMenu

protected JPopupMenu createPopupMenu()

customizeMenuItems

protected void customizeMenuItems(JTableHeader header,
                                  JPopupMenu popup,
                                  int clickingColumn)
Customizes the menu items for the popup menu.

Parameters:
header - the table header.
popup - the popup menu.
clickingColumn - the column that user right clicks. -1 means invalid clicking column. However, it might be -2 or less in GroupTableHeader.

addSeparatorIfNecessary

public static void addSeparatorIfNecessary(JPopupMenu popup)
Adds a separator to the popup menu if there are menu items on it already.

Parameters:
popup - the popup menu.

installListeners

public void installListeners()
Installs the listeners needed in order to show the popup menu for the table header.


uninstallListeners

public void uninstallListeners()
Uninstalls the listeners needed in order to show the popup menu for the table header.


getTableHeaderPopupMenuInstaller

public static TableHeaderPopupMenuInstaller getTableHeaderPopupMenuInstaller(JTable table)
Gets the Searchable installed on the component. Null is no Searchable was installed.

Parameters:
table - the table
Returns:
the Searchable installed. Null is no Searchable was installed.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

JIDE 3.5.15