private class JXTableHeader.HeaderListener extends Object implements MouseInputListener, Serializable
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.
Modifier and Type | Field and Description |
---|---|
private TableColumn |
cachedResizingColumn |
private SortOrder[] |
cachedSortOrderCycle |
private int |
sortColumn |
Modifier | Constructor and Description |
---|---|
private |
HeaderListener() |
Modifier and Type | Method and Description |
---|---|
private void |
cacheResizingColumn(MouseEvent e)
Caches the resizing column if set.
|
private void |
cacheSortColumn(MouseEvent e) |
private boolean |
canCacheSortColumn(MouseEvent e) |
private void |
disableToggleSortOrder(MouseEvent e) |
private void |
doDoubleSort(MouseEvent e) |
private void |
doResize(MouseEvent e)
Packs caches resizing column on double click, if available.
|
private boolean |
hasCachedSortColumn() |
private boolean |
hasSortController() |
private boolean |
isInResizeRegion(MouseEvent e)
Returns true if the mouseEvent happened in the resizing region.
|
void |
mouseClicked(MouseEvent e)
Packs column on double click in resize region.
|
void |
mouseDragged(MouseEvent e)
Resets all cached state.
|
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e)
Resets all cached state.
|
void |
mouseMoved(MouseEvent e)
Resets all cached state.
|
void |
mousePressed(MouseEvent e)
Resets sort enablement always, set resizing marker if available.
|
void |
mouseReleased(MouseEvent e)
Sets resizing marker if available, disables table sorting if in
resize region and sort gesture (aka: single click).
|
private void |
resetToggleSortOrder(MouseEvent e) |
private boolean |
shouldIgnore(MouseEvent e)
Returns a boolean indication if the mouse event should be ignored.
|
private void |
uncacheResizingColumn()
Sets the cached resizing column to null.
|
private void |
uncacheSortColumn() |
private TableColumn cachedResizingColumn
private SortOrder[] cachedSortOrderCycle
private int sortColumn
private HeaderListener()
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
private void doDoubleSort(MouseEvent e)
private boolean hasCachedSortColumn()
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
private void cacheSortColumn(MouseEvent e)
private void uncacheSortColumn()
private boolean canCacheSortColumn(MouseEvent e)
private boolean shouldIgnore(MouseEvent e)
e
- private void doResize(MouseEvent e)
e
- private void disableToggleSortOrder(MouseEvent e)
e
- private boolean hasSortController()
private void resetToggleSortOrder(MouseEvent e)
private void cacheResizingColumn(MouseEvent e)
e
- private void uncacheResizingColumn()
private boolean isInResizeRegion(MouseEvent e)
e
- public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses