JIDE 3.5.15

com.jidesoft.grid
Class GroupTablePopupMenuCustomizer

java.lang.Object
  extended by com.jidesoft.grid.GroupTablePopupMenuCustomizer
All Implemented Interfaces:
TableHeaderPopupMenuCustomizer

public class GroupTablePopupMenuCustomizer
extends Object
implements TableHeaderPopupMenuCustomizer

A TableHeaderPopupMenuCustomizer for AggregateTable. To use it, you can use the code like this.

 TableHeaderPopupMenuInstaller installer = new TableHeaderPopupMenuInstaller(aggregateTable)
 installer.addTableHeaderPopupMenuCustomizer(new AggregateTablePopupMenuCustomizer());
 
The AggregateTablePopupMenuCustomizer will add the "Group", "Ungroup", "Expand" and "Collapse" etc menu items to the popup menu.


Field Summary
static String CONTEXT_MENU_COLLAPSE
           
static String CONTEXT_MENU_COLLAPSE_ALL
           
static String CONTEXT_MENU_EXPAND
           
static String CONTEXT_MENU_EXPAND_ALL
           
static String CONTEXT_MENU_GROUP
           
static String CONTEXT_MENU_UNGROUP
          CONTEXT_MENU_...
 
Constructor Summary
GroupTablePopupMenuCustomizer()
           
 
Method Summary
 void customizePopupMenu(JTableHeader header, JPopupMenu popup, int clickingColumn)
          The method generates the context menu items by clickingColumn.
 int[] getGroupableColumns()
          Gets the grouped columns.
protected  String getResourceString(String key)
          Gets the localized string from resource bundle.
 void setGroupableColumns(int[] groupableColumns)
          Sets the groupable columns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_MENU_UNGROUP

public static final String CONTEXT_MENU_UNGROUP
CONTEXT_MENU_... are the possible menu names displayed in the menu. You can use these string as name to locate the existing menu items.

See Also:
customizePopupMenu(javax.swing.table.JTableHeader, javax.swing.JPopupMenu, int), Constant Field Values

CONTEXT_MENU_GROUP

public static final String CONTEXT_MENU_GROUP
See Also:
Constant Field Values

CONTEXT_MENU_EXPAND

public static final String CONTEXT_MENU_EXPAND
See Also:
Constant Field Values

CONTEXT_MENU_COLLAPSE

public static final String CONTEXT_MENU_COLLAPSE
See Also:
Constant Field Values

CONTEXT_MENU_EXPAND_ALL

public static final String CONTEXT_MENU_EXPAND_ALL
See Also:
Constant Field Values

CONTEXT_MENU_COLLAPSE_ALL

public static final String CONTEXT_MENU_COLLAPSE_ALL
See Also:
Constant Field Values
Constructor Detail

GroupTablePopupMenuCustomizer

public GroupTablePopupMenuCustomizer()
Method Detail

getGroupableColumns

public int[] getGroupableColumns()
Gets the grouped columns. By default, all columns are groupable but you can use setGroupableColumns(int[]) to set the columns.

Returns:
the groupable columns.

setGroupableColumns

public void setGroupableColumns(int[] groupableColumns)
Sets the groupable columns. Only columns included in the array is allowed to be grouped.

Parameters:
groupableColumns - the groupable columns

getResourceString

protected String getResourceString(String key)
Gets the localized string from resource bundle. Subclass can override it to provide its own string. Available keys are defined in grid.properties that begin with "GroupTable.".

Parameters:
key - the resource string key
Returns:
the localized string.

customizePopupMenu

public void customizePopupMenu(JTableHeader header,
                               JPopupMenu popup,
                               int clickingColumn)
The method generates the context menu items by clickingColumn. After the process, the popup will contain all the generated menu items. You can override the method to add some new menu items or delete some existing menu items as you wish. You can use CONTEXT_MENU_... as the name to find the existing menu items.
      for (int i = 0; i < popup.getComponentCount(); i++) {
          if (CONTEXT_MENU_UNGROUP.equals(popup.getComponent(i).getName())) {
              popup.remove(popup.getComponent(i));
          }
      }
 

Specified by:
customizePopupMenu in interface TableHeaderPopupMenuCustomizer
Parameters:
header - the table header
popup - the popup menu to be displayed
clickingColumn - the column index clicked

JIDE 3.5.15