Class JXTableHeader.HeaderListener
- All Implemented Interfaces:
MouseListener, MouseMotionListener, Serializable, EventListener, MouseInputListener
- Enclosing class:
JXTableHeader
Note that the logic is critical, mostly because it must be independent of sequence of listener notification. So we check whether or not a pressed happens in the resizing region in both pressed and released, taking the header's resizingColumn property as a marker. The inResize flag can only be turned on in those. At the end of the released, we check if we are in resize and disable core sorting - which happens in clicked - if appropriate. In our clicked we hook the pack action (happens only on double click) and reset the resizing region flag always. Pressed (and all other methods) restore sorting enablement.
Supports resort on double click if enabled in the JXTableHeader (Issue #271-swingx). Is fully effective only if JXTable has control over the row sorter, that is if the row sorter is of type SortController.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidCaches the resizing column if set.private voidprivate booleanprivate voidprivate voidprivate voidPacks caches resizing column on double click, if available.private booleanprivate booleanprivate booleanReturns true if the mouseEvent happened in the resizing region.voidPacks column on double click in resize region.voidResets all cached state.voidvoidResets all cached state.voidResets all cached state.voidResets sort enablement always, set resizing marker if available.voidSets resizing marker if available, disables table sorting if in resize region and sort gesture (aka: single click).private voidprivate booleanReturns a boolean indication if the mouse event should be ignored.private voidSets the cached resizing column to null.private void
-
Field Details
-
cachedResizingColumn
-
cachedSortOrderCycle
-
sortColumn
private int sortColumn
-
-
Constructor Details
-
HeaderListener
private HeaderListener()
-
-
Method Details
-
mouseClicked
Packs column on double click in resize region. Resorts column on double click if enabled and not in resize region.- Specified by:
mouseClickedin interfaceMouseListener
-
doDoubleSort
-
hasCachedSortColumn
private boolean hasCachedSortColumn() -
mousePressed
Resets sort enablement always, set resizing marker if available.- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
Sets resizing marker if available, disables table sorting if in resize region and sort gesture (aka: single click).- Specified by:
mouseReleasedin interfaceMouseListener
-
cacheSortColumn
-
uncacheSortColumn
private void uncacheSortColumn() -
canCacheSortColumn
-
shouldIgnore
Returns a boolean indication if the mouse event should be ignored. Here: returns true if table not enabled or not an event from the left mouse button.- Parameters:
e-- Returns:
-
doResize
Packs caches resizing column on double click, if available. Does nothing otherwise.- Parameters:
e-
-
disableToggleSortOrder
- Parameters:
e-
-
hasSortController
private boolean hasSortController()- Returns:
-
resetToggleSortOrder
-
cacheResizingColumn
Caches the resizing column if set. Does nothing if null.- Parameters:
e-
-
uncacheResizingColumn
private void uncacheResizingColumn()Sets the cached resizing column to null. -
isInResizeRegion
Returns true if the mouseEvent happened in the resizing region.- Parameters:
e-- Returns:
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
Resets all cached state.- Specified by:
mouseExitedin interfaceMouseListener
-
mouseDragged
Resets all cached state.- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
Resets all cached state.- Specified by:
mouseMovedin interfaceMouseMotionListener
-