RFR: 8293119: Additional constrained resize policies for Tree/TableView [v23]

Ajit Ghaisas aghaisas at openjdk.org
Mon Dec 19 13:11:04 UTC 2022


On Wed, 14 Dec 2022 17:56:00 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 with a new target base due to a merge or a rebase. The pull request now contains 77 commits:
> 
>  - Merge remote-tracking branch 'origin/master' into 8293119.constrained
>  - 8293119: review comments
>  - 8293119: abstract
>  - 8293119: <p>
>  - 8293119: review comments
>  - Merge remote-tracking branch 'origin/master' into 8293119.constrained
>  - Merge remote-tracking branch 'origin/master' into 8293119.constrained
>  - 8293119: small delta
>  - Merge remote-tracking branch 'origin/master' into 8293119.constrained
>  - 8293119: pref
>  - ... and 67 more: https://git.openjdk.org/jfx/compare/8763e8b0...8bdae30e

This has baked well. I tested on macOS and it looks good.

I see warnings on command line while trying to run `ATableViewResizeTester.java`. While the first warning is expected, we should fix others.

-----------------------------------------------------------------
`javafx/tester/ATableViewResizeTester.java:224: warning: [deprecation] CONSTRAINED_RESIZE_POLICY in TableView has been deprecated
            return TableView.CONSTRAINED_RESIZE_POLICY;
                            ^
javafx/tester/ATableViewResizeTester.java:456: warning: [unchecked] unchecked cast
            TableColumn<String,String> c = (TableColumn<String,String>)t.getColumns().remove(ix);
                                                                                            ^
  required: TableColumn<String,String>
  found:    TableColumn<String,CAP#1>
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object from capture of ?
javafx/tester/ATableViewResizeTester.java:467: warning: [unchecked] unchecked conversion
        TableView<String> table = new TableView();
                                  ^
  required: TableView<String>
  found:    TableView
javafx/tester/ATableViewResizeTester.java:640: warning: [unchecked] unchecked conversion
            List<? extends TableColumnBase<?,?>> visibleLeafColumns = rf.getTable().getVisibleLeafColumns();
                                                                                                         ^
  required: List<? extends TableColumnBase<?,?>>
  found:    ObservableList
javafx/tester/ATableViewResizeTester.java:646: warning: [unchecked] unchecked call to setColumnWidth(TableColumnBase<S,?>,double) as a member of the raw type ResizeFeaturesBase
                rf.setColumnWidth(c, w);
                                 ^
  where S is a type-variable:
    S extends Object declared in class ResizeFeaturesBase
5 warnings
`

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

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


More information about the openjfx-dev mailing list