Update TableView resize policy to match changes in JFX20
This commit is contained in:
parent
6ef6b5502c
commit
d9cd61f7fb
@ -157,7 +157,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
|
|
||||||
var table = new TableView<>(Flight.random(5));
|
var table = new TableView<>(Flight.random(5));
|
||||||
table.getColumns().setAll(col1, col2, col3, col4);
|
table.getColumns().setAll(col1, col2, col3, col4);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
//snippet_1:end
|
//snippet_1:end
|
||||||
|
|
||||||
@ -198,7 +200,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
|
|
||||||
var table = new TableView<>(Flight.random(5));
|
var table = new TableView<>(Flight.random(5));
|
||||||
table.getColumns().setAll(col1, col2, col3, col4);
|
table.getColumns().setAll(col1, col2, col3, col4);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
|
|
||||||
var borderToggle = new ToggleSwitch("Bordered");
|
var borderToggle = new ToggleSwitch("Bordered");
|
||||||
@ -272,7 +276,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
// -color-cell-bg-selected-focused: -color-accent-emphasis;
|
// -color-cell-bg-selected-focused: -color-accent-emphasis;
|
||||||
// -color-cell-fg-selected-focused: -color-fg-emphasis;
|
// -color-cell-fg-selected-focused: -color-fg-emphasis;
|
||||||
table.setStyle(style);
|
table.setStyle(style);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
//snippet_3:end
|
//snippet_3:end
|
||||||
|
|
||||||
@ -314,7 +320,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
var table = new TableView<>(Flight.random(5));
|
var table = new TableView<>(Flight.random(5));
|
||||||
table.getColumns().setAll(col1, col2, col3, col4);
|
table.getColumns().setAll(col1, col2, col3, col4);
|
||||||
table.getStyleClass().add(Tweaks.EDGE_TO_EDGE);
|
table.getStyleClass().add(Tweaks.EDGE_TO_EDGE);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
//snippet_5:end
|
//snippet_5:end
|
||||||
|
|
||||||
@ -364,7 +372,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
|
|
||||||
var table = new TableView<>(Flight.random(5));
|
var table = new TableView<>(Flight.random(5));
|
||||||
table.getColumns().setAll(col1, col2, col3, col4);
|
table.getColumns().setAll(col1, col2, col3, col4);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
//snippet_6:end
|
//snippet_6:end
|
||||||
|
|
||||||
@ -484,7 +494,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
|
|
||||||
var table = new TableView<>(Flight.random(5));
|
var table = new TableView<>(Flight.random(5));
|
||||||
table.getColumns().setAll(col1, col2, col3);
|
table.getColumns().setAll(col1, col2, col3);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
//snippet_8:end
|
//snippet_8:end
|
||||||
|
|
||||||
@ -524,7 +536,9 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
|
|
||||||
var table = new TableView<>(Flight.random(50));
|
var table = new TableView<>(Flight.random(50));
|
||||||
table.getColumns().setAll(col1, col2, col3, col4);
|
table.getColumns().setAll(col1, col2, col3, col4);
|
||||||
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
table.setColumnResizePolicy(
|
||||||
|
TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
table.getSelectionModel().selectFirst();
|
table.getSelectionModel().selectFirst();
|
||||||
|
|
||||||
var pg = new Pagination(25, 0);
|
var pg = new Pagination(25, 0);
|
||||||
@ -678,14 +692,34 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final var unconResizeItem = new RadioMenuItem("Unconstrained");
|
final var sizeUnconstrainedItem = new RadioMenuItem("Unconstrained");
|
||||||
unconResizeItem.setToggleGroup(resizePolGroup);
|
sizeUnconstrainedItem.setToggleGroup(resizePolGroup);
|
||||||
unconResizeItem.setUserData(TableView.UNCONSTRAINED_RESIZE_POLICY);
|
sizeUnconstrainedItem.setUserData(TableView.UNCONSTRAINED_RESIZE_POLICY);
|
||||||
unconResizeItem.setSelected(true);
|
sizeUnconstrainedItem.setSelected(true);
|
||||||
|
|
||||||
final var conResizeItem = new RadioMenuItem("Constrained");
|
final var sizeAllColumnsItem = new RadioMenuItem("Resize All Columns");
|
||||||
conResizeItem.setToggleGroup(resizePolGroup);
|
sizeAllColumnsItem.setToggleGroup(resizePolGroup);
|
||||||
conResizeItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY);
|
sizeAllColumnsItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY_ALL_COLUMNS);
|
||||||
|
|
||||||
|
final var sizeLastColumnItem = new RadioMenuItem("Resize Last Column");
|
||||||
|
sizeLastColumnItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeLastColumnItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY_LAST_COLUMN);
|
||||||
|
|
||||||
|
final var sizeNextColumnItem = new RadioMenuItem("Resize Next Column");
|
||||||
|
sizeNextColumnItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeNextColumnItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY_NEXT_COLUMN);
|
||||||
|
|
||||||
|
final var sizeSubsequentItem = new RadioMenuItem("Resize Subsequent Column");
|
||||||
|
sizeSubsequentItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeSubsequentItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY_SUBSEQUENT_COLUMNS);
|
||||||
|
|
||||||
|
final var sizeFlexHeadItem = new RadioMenuItem("Flex Head");
|
||||||
|
sizeFlexHeadItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeFlexHeadItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_NEXT_COLUMN);
|
||||||
|
|
||||||
|
final var sizeFlexTailItem = new RadioMenuItem("Flex Tail");
|
||||||
|
sizeFlexTailItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeFlexTailItem.setUserData(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);
|
||||||
|
|
||||||
// ~
|
// ~
|
||||||
|
|
||||||
@ -721,8 +755,14 @@ public final class TableViewPage extends OutlinePage {
|
|||||||
final var propsMenu = new MenuButton("Properties");
|
final var propsMenu = new MenuButton("Properties");
|
||||||
propsMenu.getItems().setAll(
|
propsMenu.getItems().setAll(
|
||||||
resizePolCaption,
|
resizePolCaption,
|
||||||
unconResizeItem,
|
sizeUnconstrainedItem,
|
||||||
conResizeItem,
|
sizeAllColumnsItem,
|
||||||
|
sizeLastColumnItem,
|
||||||
|
sizeNextColumnItem,
|
||||||
|
sizeSubsequentItem,
|
||||||
|
sizeFlexHeadItem,
|
||||||
|
sizeFlexTailItem,
|
||||||
|
new SeparatorMenuItem(),
|
||||||
selModeCaption,
|
selModeCaption,
|
||||||
singleSelItem,
|
singleSelItem,
|
||||||
multiSelItem,
|
multiSelItem,
|
||||||
|
@ -88,7 +88,9 @@ public final class TreeTableViewPage extends OutlinePage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
var treeTable = new TreeTableView<Vehicle>();
|
var treeTable = new TreeTableView<Vehicle>();
|
||||||
treeTable.setColumnResizePolicy(TreeTableView.CONSTRAINED_RESIZE_POLICY);
|
treeTable.setColumnResizePolicy(
|
||||||
|
TreeTableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN
|
||||||
|
);
|
||||||
treeTable.getColumns().setAll(col1, col2);
|
treeTable.getColumns().setAll(col1, col2);
|
||||||
|
|
||||||
var make1 = FAKER.vehicle().make();
|
var make1 = FAKER.vehicle().make();
|
||||||
@ -268,22 +270,42 @@ public final class TreeTableViewPage extends OutlinePage {
|
|||||||
|
|
||||||
private MenuButton createPropertiesMenu(TreeTableView<Product> treeTable) {
|
private MenuButton createPropertiesMenu(TreeTableView<Product> treeTable) {
|
||||||
final var resizePolCaption = new CaptionMenuItem("Resize Policy");
|
final var resizePolCaption = new CaptionMenuItem("Resize Policy");
|
||||||
final var resizePolicyGroup = new ToggleGroup();
|
final var resizePolGroup = new ToggleGroup();
|
||||||
resizePolicyGroup.selectedToggleProperty().addListener((obs, old, val) -> {
|
resizePolGroup.selectedToggleProperty().addListener((obs, old, val) -> {
|
||||||
if (val != null && val.getUserData() instanceof Callback<?, ?> policy) {
|
if (val != null && val.getUserData() instanceof Callback<?, ?> policy) {
|
||||||
//noinspection rawtypes,unchecked
|
//noinspection rawtypes,unchecked
|
||||||
treeTable.setColumnResizePolicy((Callback<TreeTableView.ResizeFeatures, Boolean>) policy);
|
treeTable.setColumnResizePolicy((Callback<TreeTableView.ResizeFeatures, Boolean>) policy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final var unconResizeItem = new RadioMenuItem("Unconstrained");
|
final var sizeUnconstrainedItem = new RadioMenuItem("Unconstrained");
|
||||||
unconResizeItem.setToggleGroup(resizePolicyGroup);
|
sizeUnconstrainedItem.setToggleGroup(resizePolGroup);
|
||||||
unconResizeItem.setUserData(TreeTableView.UNCONSTRAINED_RESIZE_POLICY);
|
sizeUnconstrainedItem.setUserData(TreeTableView.UNCONSTRAINED_RESIZE_POLICY);
|
||||||
unconResizeItem.setSelected(true);
|
sizeUnconstrainedItem.setSelected(true);
|
||||||
|
|
||||||
final var conResizeItem = new RadioMenuItem("Constrained");
|
final var sizeAllColumnsItem = new RadioMenuItem("Resize All Columns");
|
||||||
conResizeItem.setToggleGroup(resizePolicyGroup);
|
sizeAllColumnsItem.setToggleGroup(resizePolGroup);
|
||||||
conResizeItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY);
|
sizeAllColumnsItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY_ALL_COLUMNS);
|
||||||
|
|
||||||
|
final var sizeLastColumnItem = new RadioMenuItem("Resize Last Column");
|
||||||
|
sizeLastColumnItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeLastColumnItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY_LAST_COLUMN);
|
||||||
|
|
||||||
|
final var sizeNextColumnItem = new RadioMenuItem("Resize Next Column");
|
||||||
|
sizeNextColumnItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeNextColumnItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY_NEXT_COLUMN);
|
||||||
|
|
||||||
|
final var sizeSubsequentItem = new RadioMenuItem("Resize Subsequent Column");
|
||||||
|
sizeSubsequentItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeSubsequentItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY_SUBSEQUENT_COLUMNS);
|
||||||
|
|
||||||
|
final var sizeFlexHeadItem = new RadioMenuItem("Flex Head");
|
||||||
|
sizeFlexHeadItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeFlexHeadItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY_FLEX_NEXT_COLUMN);
|
||||||
|
|
||||||
|
final var sizeFlexTailItem = new RadioMenuItem("Flex Tail");
|
||||||
|
sizeFlexTailItem.setToggleGroup(resizePolGroup);
|
||||||
|
sizeFlexTailItem.setUserData(TreeTableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);
|
||||||
|
|
||||||
// ~
|
// ~
|
||||||
|
|
||||||
@ -356,8 +378,14 @@ public final class TreeTableViewPage extends OutlinePage {
|
|||||||
final var propsMenu = new MenuButton("Properties");
|
final var propsMenu = new MenuButton("Properties");
|
||||||
propsMenu.getItems().setAll(
|
propsMenu.getItems().setAll(
|
||||||
resizePolCaption,
|
resizePolCaption,
|
||||||
unconResizeItem,
|
sizeUnconstrainedItem,
|
||||||
conResizeItem,
|
sizeAllColumnsItem,
|
||||||
|
sizeLastColumnItem,
|
||||||
|
sizeNextColumnItem,
|
||||||
|
sizeSubsequentItem,
|
||||||
|
sizeFlexHeadItem,
|
||||||
|
sizeFlexTailItem,
|
||||||
|
new SeparatorMenuItem(),
|
||||||
selModeCaption,
|
selModeCaption,
|
||||||
singleSelItem,
|
singleSelItem,
|
||||||
multiSelItem,
|
multiSelItem,
|
||||||
|
@ -63,7 +63,7 @@ final class IconBrowser extends TableView<List<Ikon>> {
|
|||||||
getColumns().add(col);
|
getColumns().add(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_ALL_COLUMNS);
|
||||||
getSelectionModel().setCellSelectionEnabled(true);
|
getSelectionModel().setCellSelectionEnabled(true);
|
||||||
getStyleClass().add("icon-browser");
|
getStyleClass().add("icon-browser");
|
||||||
}
|
}
|
||||||
@ -128,4 +128,4 @@ final class IconBrowser extends TableView<List<Ikon>> {
|
|||||||
setGraphic(root);
|
setGraphic(root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user