JDK-8293119 : Additional constrained resize policies for Tree/TableView
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: other
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-08-30
  • Updated: 2023-01-12
  • Resolved: 2023-01-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx20 b15Fixed
Related Reports
Blocks :  
CSR :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The current CONSTRAINED_RESIZE_POLICY has a number of issues as explained in JDK-8292810.

We propose to address all these issues by replacing the old column resize algorithm with a different one, which not only honors all the constraints when resizing, but also provides 4 different resize modes similar to JTable's.  The new implementation brings changes to the public API for Tree/TableView and ResizeFeaturesBase classes.  Specifically:

- create a public abstract javafx.scene.control.ConstrainedColumnResizeBase class.  any user-provided constrained resize policies must extends ConstrainedColumnResizeBase.
- provide an out-of-the box implementation via javafx.scene.control.ConstrainedColumnResize class, offeting 4 resize modes: AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_SUBSEQUENT_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_FLEX_HEAD, CONSTRAINED_RESIZE_POLICY_FLEX_HEAD, and CONSTRAINED_RESIZE_POLICY_FLEX_TAIL
- add corresponding public static constants to Tree/TableView
- mark Tree/TableView.CONSTRAINED_RESIZE_POLICY as deprecated and an alias to CONSTRAINED_RESIZE_POLICY_FLEX_TAIL (a slight behavioral change - discuss)
- add getContentWidth() and setColumnWidth(TableColumnBase<S,?> col, double width) methods to ResizeFeatureBase
- suppress the horizontal scroll bar when the resize policy is instanceof ConstrainedColumnResizeBase
- update javadoc

CSR is required because of public API changes in Tree/TableView, ResizeFeatureBase classes.

Notes

1. The current resize policies' toString() methods return "unconstrained-resize" and "constrained-resize", used by the skin base to set a pseudostate.  All constrained policies that extend ConstrainedColumnResizeBase will return "constrained-resize" value.
2. In the presence of snapping and fractional scale, the implemented algorithm would never work correctly. The reason is that the distance between snapped positions is not the same. As a result, changing a single column width requires shifting of subsequent or all the columns, which in turn might require a change in their widths, and so on.  See JDK-8299753.
3. A very minor cosmetic issue is observed with snapping and fractional scale, see JDK-8299755.




Comments
Changeset: 1ac97fc5 Author: Andy Goryachev <angorya@openjdk.org> Date: 2023-01-10 16:34:15 +0000 URL: https://git.openjdk.org/jfx/commit/1ac97fc566591e413d67bc7230ea0b351271d7a8
10-01-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/897 Date: 2022-09-12 21:58:47 +0000
12-10-2022

Suggestions from the team (thank you [~kcr] [~prr]!): - setColumnWidth instead of doSetWidth - horizontal scroll bar is controlled by an internal property - check if documentation should be improved to make developers aware of the behavior in an over-constrained situation(s) - fix the existing CONSTRAINED_RESIZE_POLICY instead of retaining the buggy version - possibly provide additional constrained policies by adding constants (why didn't I think of that??)
31-08-2022