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 void
Caches the resizing column if set.private void
private boolean
private void
private void
private void
Packs caches resizing column on double click, if available.private boolean
private boolean
private boolean
Returns true if the mouseEvent happened in the resizing region.void
Packs column on double click in resize region.void
Resets all cached state.void
void
Resets all cached state.void
Resets all cached state.void
Resets sort enablement always, set resizing marker if available.void
Sets resizing marker if available, disables table sorting if in resize region and sort gesture (aka: single click).private void
private boolean
Returns a boolean indication if the mouse event should be ignored.private void
Sets 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:
mouseClicked
in interfaceMouseListener
-
doDoubleSort
-
hasCachedSortColumn
private boolean hasCachedSortColumn() -
mousePressed
Resets sort enablement always, set resizing marker if available.- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
Sets resizing marker if available, disables table sorting if in resize region and sort gesture (aka: single click).- Specified by:
mouseReleased
in 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:
mouseEntered
in interfaceMouseListener
-
mouseExited
Resets all cached state.- Specified by:
mouseExited
in interfaceMouseListener
-
mouseDragged
Resets all cached state.- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseMoved
Resets all cached state.- Specified by:
mouseMoved
in interfaceMouseMotionListener
-