RFR: 8293119: Alternative CONSTRAINED_RESIZE_POLICY [v4]

Kevin Rushforth kcr at openjdk.org
Wed Nov 23 22:04:29 UTC 2022


On Mon, 21 Nov 2022 23:32:52 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> The current CONSTRAINED_RESIZE_POLICY has a number of issues as explained in [JDK-8292810](https://bugs.openjdk.org/browse/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
>> - 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
>> - add corresponding public static constants to Tree/TableView
>> - make Tree/TableView.CONSTRAINED_RESIZE_POLICY an alias to AUTO_RESIZE_SUBSEQUENT_COLUMNS (a slight behavioral change - discuss)
>> - add getContentWidth() and setColumnWidth(TableColumnBase<S,?> col, double width) methods to ResizeFeatureBase
>> - suppress the horizontal scroll bar when resize policy is instanceof ConstrainedColumnResizeBase
>> - update javadoc
>> 
>> 
>> 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. The reason an abstract class ( ConstrainedColumnResizeBase) was chosen instead of a marker interface is exactly for its toString() method which supplies "constrained-resize" value. The implementors might choose to use a different value, however they must ensure the stylesheet contains the same adjustments for the new policy as those made in modena.css for "constrained-resize" value.
>
> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8293119: newline

Behavioral issues:

All the policies work much better than the existing (buggy) `CONSTRAINED_RESIZE_POLICY`. I did notice a few oddities, though. More manual testing is needed by a few folks.

1. The divider being dragged doesn't track the cursor. All policies other than `CONSTRAINED_RESIZE_POLICY_ALL_COLUMNS` should be able to track (the Swing implementation does).
2. I found a bug in the implementation of `CONSTRAINED_RESIZE_POLICY_SUBSEQUENT_COLUMNS` with data = "fixed in the middle". To reproduce, drag the divider between C3 and C4 to the right. It will not move much at first, and then it will jump. Dragging it back to the left is even more odd in that it will immediately jump and resize the previous columns. That part is definitely a bug, since C1 and C2 shouldn't be resized at all.
3. The space doesn't seem to be distributed evenly with `CONSTRAINED_RESIZE_POLICY_ALL_COLUMNS`. The easiest way to see this is to start dragging the divider between C2 and C3 to the right. C1 doesn't start resizing at all until its made C3 and C4 quite a bit smaller. And when dragging back and forth a bit it doesn't look quite right.

-------------

PR: https://git.openjdk.org/jfx/pull/897


More information about the openjfx-dev mailing list