Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8293119: Additional constrained resize policies for Tree/TableView #897

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
d5a319b
8293119: initial classes
andy-goryachev-oracle Aug 30, 2022
2ac98fa
8293119: suppress horizontal scroll bar
andy-goryachev-oracle Aug 31, 2022
432aa46
8293119: abstract for now
andy-goryachev-oracle Sep 2, 2022
f2f217c
8293119: is constrained
andy-goryachev-oracle Sep 2, 2022
5624da1
8293119: return value
andy-goryachev-oracle Sep 2, 2022
fb90755
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Sep 6, 2022
cbb1f66
8293119: first run
andy-goryachev-oracle Sep 7, 2022
700a02f
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Sep 7, 2022
9a6cd94
8293119: is constrained
andy-goryachev-oracle Sep 9, 2022
fc4c63a
8293119: removed first run
andy-goryachev-oracle Sep 12, 2022
7653f45
8293119: resize mode
andy-goryachev-oracle Sep 12, 2022
5db4d18
8293119: moved policy to control pkg
andy-goryachev-oracle Sep 12, 2022
bb74a60
8293119: removed demo
andy-goryachev-oracle Sep 12, 2022
734011b
8293119: whitespace
andy-goryachev-oracle Sep 12, 2022
d3b11ff
8293119: avoid endless loops
andy-goryachev-oracle Sep 13, 2022
4002eeb
8293119: tester
andy-goryachev-oracle Sep 13, 2022
02ad26a
8293119: whitespace
andy-goryachev-oracle Sep 13, 2022
77c9962
8293119: fixed unconstrained label in tester
andy-goryachev-oracle Sep 14, 2022
af5d2b6
8293119: replacement policy
andy-goryachev-oracle Sep 14, 2022
e161de0
8293119: test
andy-goryachev-oracle Sep 16, 2022
52d2f20
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Sep 16, 2022
c6e85c5
8293119: custom policy test
andy-goryachev-oracle Sep 16, 2022
548fdbe
8293119: exhaustive test
andy-goryachev-oracle Sep 19, 2022
a0b2a1f
8293119: improved redistribution
andy-goryachev-oracle Sep 20, 2022
ff04a0b
8293119: back to delta
andy-goryachev-oracle Sep 21, 2022
12c2839
8293119: distribute
andy-goryachev-oracle Sep 21, 2022
c87fd72
8293119: adj
andy-goryachev-oracle Sep 21, 2022
4295476
8293119: distribute flex
andy-goryachev-oracle Sep 21, 2022
14cf15e
8293119: two phase flex
andy-goryachev-oracle Sep 21, 2022
fb68f8d
8293119: two flex policies
andy-goryachev-oracle Sep 22, 2022
3772d57
8293119: remainder
andy-goryachev-oracle Sep 22, 2022
618b520
8293119: remainder 2
andy-goryachev-oracle Sep 22, 2022
ca38548
8293119: tester
andy-goryachev-oracle Sep 22, 2022
b4e0052
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Sep 23, 2022
dd9a651
8293119: all columns corner case
andy-goryachev-oracle Sep 23, 2022
28266e6
8293119: javadoc
andy-goryachev-oracle Sep 23, 2022
6aab64a
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Sep 23, 2022
32a8887
8293119: tester
andy-goryachev-oracle Sep 23, 2022
314ee31
8293119: test
andy-goryachev-oracle Sep 26, 2022
ba464be
8293119: cleanup
andy-goryachev-oracle Sep 26, 2022
ca569fc
8293119: cleanup
andy-goryachev-oracle Sep 26, 2022
c784307
8293119: whitespace
andy-goryachev-oracle Sep 26, 2022
3cb3f25
8293119: not abstract
andy-goryachev-oracle Sep 26, 2022
9b479e0
8293119: show right boundary when needed
andy-goryachev-oracle Sep 27, 2022
818ce5c
8293119: whitespace + javadoc
andy-goryachev-oracle Sep 28, 2022
21c5dff
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Oct 12, 2022
ec8ca56
8293119: javadoc
andy-goryachev-oracle Oct 12, 2022
1049a8c
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Nov 21, 2022
d261e85
8293119: moved tester to its own package and project
andy-goryachev-oracle Nov 21, 2022
bd8af8f
8293119: newline
andy-goryachev-oracle Nov 21, 2022
1a0a5fc
8293119: moved to com.sun
andy-goryachev-oracle Nov 23, 2022
7d6b7e6
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Nov 23, 2022
1b1f463
8293119: review comments
andy-goryachev-oracle Nov 23, 2022
6d6cda1
8293119: no link
andy-goryachev-oracle Nov 24, 2022
8ef19aa
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Nov 28, 2022
cc5d9b8
8293119: review comments
andy-goryachev-oracle Nov 28, 2022
0f6bdd5
8293119: subsequent columns
andy-goryachev-oracle Nov 29, 2022
e030451
8293119: cleanup
andy-goryachev-oracle Nov 30, 2022
6cc8b33
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Nov 30, 2022
7d290b6
8293119: all columns
andy-goryachev-oracle Nov 30, 2022
6a340d3
8293119: descriptions
andy-goryachev-oracle Nov 30, 2022
9512f3c
8293119: tester
andy-goryachev-oracle Nov 30, 2022
82a3d92
8293119: use integers for rounded values
andy-goryachev-oracle Nov 30, 2022
a58c9ce
8293119: more integers
andy-goryachev-oracle Nov 30, 2022
5129466
8293119: more integers
andy-goryachev-oracle Nov 30, 2022
760f789
8293119: step1
andy-goryachev-oracle Dec 1, 2022
b6e2ae5
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Dec 1, 2022
bbfa7ac
8293119: pref
andy-goryachev-oracle Dec 2, 2022
f8e02fb
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Dec 2, 2022
fb40d98
8293119: small delta
andy-goryachev-oracle Dec 3, 2022
0122d5f
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Dec 6, 2022
924669d
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Dec 9, 2022
bb2d069
8293119: review comments
andy-goryachev-oracle Dec 9, 2022
671d977
8293119: <p>
andy-goryachev-oracle Dec 12, 2022
d4c7066
8293119: abstract
andy-goryachev-oracle Dec 13, 2022
44a995a
8293119: review comments
andy-goryachev-oracle Dec 14, 2022
8bdae30
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Dec 14, 2022
4391de5
8293119: review comments
andy-goryachev-oracle Dec 19, 2022
5f4a4fc
8293119: snap to pixel
andy-goryachev-oracle Dec 20, 2022
72958cc
8293119: scale info
andy-goryachev-oracle Dec 21, 2022
6e9a6dc
8293119: rm
andy-goryachev-oracle Dec 21, 2022
8b8954e
8293119: update title
andy-goryachev-oracle Dec 21, 2022
cf12ee0
8293119: delta less than 1
andy-goryachev-oracle Dec 21, 2022
8e6dd3f
8293119: fractional
andy-goryachev-oracle Dec 21, 2022
b1734f1
8293119: error
andy-goryachev-oracle Dec 21, 2022
83f128c
8293119: small delta
andy-goryachev-oracle Dec 21, 2022
ce4d589
cleanup
andy-goryachev-oracle Dec 22, 2022
b4e3b9f
cleanup
andy-goryachev-oracle Dec 22, 2022
6ec8af1
snap after resizing
andy-goryachev-oracle Dec 22, 2022
56634c1
snap after resize
andy-goryachev-oracle Dec 23, 2022
f412294
shrink small
andy-goryachev-oracle Dec 23, 2022
06ecfbe
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Dec 23, 2022
a53eb23
whitespace
andy-goryachev-oracle Dec 23, 2022
9b8fd1f
whitespace
andy-goryachev-oracle Dec 23, 2022
645407e
small delta
andy-goryachev-oracle Jan 3, 2023
fc70ce0
2023
andy-goryachev-oracle Jan 3, 2023
d7741c4
2023
andy-goryachev-oracle Jan 3, 2023
2f3df75
width indicator in tester
andy-goryachev-oracle Jan 4, 2023
e09246a
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Jan 4, 2023
16d7477
8293119: removed debug printouts
andy-goryachev-oracle Jan 5, 2023
795d196
Merge remote-tracking branch 'origin/master' into 8293119.constrained
andy-goryachev-oracle Jan 5, 2023
e17c796
8293119: review comments
andy-goryachev-oracle Jan 9, 2023
6a607f9
8293119: added tree table view tests
andy-goryachev-oracle Jan 9, 2023
01b526a
8293119: whitespace
andy-goryachev-oracle Jan 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.javafx.scene.control;

import java.util.List;
import javafx.css.PseudoClass;
import javafx.scene.Node;
import javafx.scene.control.ConstrainedColumnResizeBase;
import javafx.scene.control.ResizeFeaturesBase;
import javafx.scene.control.TableColumnBase;
import javafx.scene.control.TableView;
import javafx.scene.control.TreeTableView;
import javafx.util.Callback;

/**
* A constrained column resize implementation that honors all Tree/TableColumn constraints -
* minimum, preferred, and maximum width.
*/
public class ConstrainedColumnResize extends ConstrainedColumnResizeBase {

public enum ResizeMode {
AUTO_RESIZE_FLEX_HEAD,
AUTO_RESIZE_FLEX_TAIL, // will be used to replace a (deprecated) CONSTRAINED_RESIZE_POLICY.
AUTO_RESIZE_NEXT_COLUMN,
AUTO_RESIZE_SUBSEQUENT_COLUMNS,
AUTO_RESIZE_LAST_COLUMN,
AUTO_RESIZE_ALL_COLUMNS
}

private final ResizeMode mode;

public ConstrainedColumnResize(ResizeMode m) {
this.mode = m;
}

public boolean constrainedResize(ResizeFeaturesBase rf,
List<? extends TableColumnBase<?,?>> visibleLeafColumns) {

double contentWidth = rf.getContentWidth();
if (contentWidth == 0.0) {
return false;
}

ResizeHelper h = new ResizeHelper(rf, contentWidth, visibleLeafColumns, mode);
h.resizeToContentWidth();

boolean rv;
TableColumnBase<?,?> column = rf.getColumn();
if (column == null) {
rv = false;
} else {
rv = h.resizeColumn(column);
}

// conditionally remove pseudoclass (given by this policy toString()) when the columns
// are narrower than the available area and the rightmost column boundary line needs to be drawn.
// hint: search modena.css for "constrained-resize" token
Node n = rf.getTableControl();
PseudoClass pc = PseudoClass.getPseudoClass(toString());
boolean wide = h.applySizes();
boolean current = n.getPseudoClassStates().contains(pc);
if (wide != current) {
if (wide) {
n.pseudoClassStateChanged(pc, true);
} else {
n.pseudoClassStateChanged(pc, false);
}
}
return rv;
}

public static TablePolicy forTable(ResizeMode m) {
return new TablePolicy(m);
}

public static TreeTablePolicy forTreeTable(ResizeMode m) {
return new TreeTablePolicy(m);
}

public static class TablePolicy
extends ConstrainedColumnResize
implements Callback<TableView.ResizeFeatures,Boolean> {

public TablePolicy(ResizeMode m) {
super(m);
}

@Override
public Boolean call(TableView.ResizeFeatures rf) {
List<? extends TableColumnBase<?,?>> visibleLeafColumns = rf.getTable().getVisibleLeafColumns();
return constrainedResize(rf, visibleLeafColumns);
}
}

public static class TreeTablePolicy
extends ConstrainedColumnResize
implements Callback<TreeTableView.ResizeFeatures,Boolean> {

public TreeTablePolicy(ResizeMode m) {
super(m);
}

@Override
public Boolean call(TreeTableView.ResizeFeatures rf) {
List<? extends TableColumnBase<?,?>> visibleLeafColumns = rf.getTable().getVisibleLeafColumns();
return constrainedResize(rf, visibleLeafColumns);
}
}
}
Loading