本文整理汇总了Java中javafx.scene.control.TreeTableView类的典型用法代码示例。如果您正苦于以下问题:Java TreeTableView类的具体用法?Java TreeTableView怎么用?Java TreeTableView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeTableView类属于javafx.scene.control包,在下文中一共展示了TreeTableView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTestContainer
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@Override
protected Node getTestContainer() {
treeOrTreeTableView = new TreeTableView<Data>();
treeOrTreeTableView.setMinSize(300, 500);
treeOrTreeTableView.setMaxSize(300, 500);
treeOrTreeTableView.setPrefSize(300, 500);
TreeTableColumn<Data, Node> column = new TreeTableColumn<Data, Node>("Items' name");
column.setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Data, Node>, ObservableValue<Node>>() {
@Override
public ObservableValue<Node> call(final TreeTableColumn.CellDataFeatures<Data, Node> p) {
SimpleObjectProperty<Node> text = new SimpleObjectProperty<Node>();
text.setValue(new Label(p.getValue().getValue().getData()));
return text;
}
});
column.setPrefWidth(150);
((TreeTableView) treeOrTreeTableView).getColumns().add(column);
reset(0);
return treeOrTreeTableView;
}
示例2: testCollapsedNodeGraphicVisible
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
/**
* 8158784: [TEST BUG] Need test for JDK-8157398
*/
@Test
public void testCollapsedNodeGraphicVisible() throws Exception {
Color nodeColor = new Color(Math.random(), Math.random(), Math.random(), 1);
TreeTableView treeTable = (TreeTableView) testedControl.getControl();
TreeItem<String> root = new TreeItem<>("Root Node");
TreeItem<String> child = new TreeItem<>("Child", new Rectangle(10, 10, nodeColor));
TreeTableColumn<String, String> column = new TreeTableColumn<>("Column");
column.setCellValueFactory(item -> new SimpleStringProperty("Whatever"));
treeTable.getColumns().setAll(column);
root.getChildren().add(child);
root.setExpanded(true);
treeTable.setShowRoot(true);
runAndWait(() -> {
treeTable.setRoot(root);
});
Wrap nodeGraphic = parent.lookup(node -> node == child.getGraphic()).wrap();
Wrap sceneWrap = Root.ROOT.lookup().wrap();
waitForColor(nodeGraphic, 1, 1, nodeColor);
Bounds graphicBounds = child.getGraphic().localToScene(child.getGraphic().getBoundsInLocal());
root.setExpanded(false);
waitForColor(sceneWrap,
(int) (graphicBounds.getMinX() + graphicBounds.getWidth() / 2),
(int) (graphicBounds.getMinY() + graphicBounds.getHeight() / 2), Color.WHITE);
}
示例3: getTreeTableItemText
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") private String getTreeTableItemText(TreeTableView<?> treeTableView,
TreeItem<?> lastPathComponent) {
@SuppressWarnings("rawtypes")
TreeTableColumn treeTableColumn = treeTableView.getTreeColumn();
if (treeTableColumn == null) {
treeTableColumn = treeTableView.getColumns().get(0);
}
ObservableValue<?> cellObservableValue = treeTableColumn.getCellObservableValue(lastPathComponent);
String original = cellObservableValue.getValue().toString();
String itemText = original;
int suffixIndex = 0;
TreeItem<?> parent = lastPathComponent.getParent();
if (parent == null)
return itemText;
ObservableList<?> children = parent.getChildren();
for (int i = 0; i < children.indexOf(lastPathComponent); i++) {
TreeItem<?> child = (TreeItem<?>) children.get(i);
cellObservableValue = treeTableColumn.getCellObservableValue(child);
String current = cellObservableValue.getValue().toString();
if (current.equals(original)) {
itemText = String.format("%s(%d)", original, ++suffixIndex);
}
}
return itemText;
}
示例4: selectTreeTableCells
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") protected void selectTreeTableCells(TreeTableView<?> treeTableView, String value) {
@SuppressWarnings("rawtypes")
TreeTableViewSelectionModel selectionModel = treeTableView.getSelectionModel();
JSONObject cells = new JSONObject(value);
JSONArray object = (JSONArray) cells.get("cells");
for (int i = 0; i < object.length(); i++) {
JSONArray jsonArray = object.getJSONArray(i);
int rowIndex = getTreeTableNodeIndex(treeTableView, jsonArray.getString(0));
int columnIndex = getTreeTableColumnIndex(treeTableView, jsonArray.getString(1));
@SuppressWarnings("rawtypes")
TreeTableColumn column = treeTableView.getColumns().get(columnIndex);
if (getVisibleCellAt(treeTableView, rowIndex, columnIndex) == null) {
treeTableView.scrollToColumn(column);
treeTableView.scrollTo(rowIndex);
}
selectionModel.select(rowIndex, column);
}
}
示例5: getByPseudoElement
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@Override public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
if (selector.equals("root")) {
return Arrays.asList(new JavaFXTreeTableViewCellElement(this, 0, 0));
} else if (selector.equals("mnth-cell")) {
return Arrays.asList(new JavaFXTreeTableViewCellElement(this, ((Integer) params[0]).intValue() - 1,
((Integer) params[1]).intValue() - 1));
} else if (selector.equals("all-cells")) {
TreeTableView<?> tableView = (TreeTableView<?>) getComponent();
int rowCount = tableView.getExpandedItemCount();
int columnCount = tableView.getColumns().size();
ArrayList<IJavaFXElement> r = new ArrayList<>();
for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < columnCount; j++) {
r.add(new JavaFXTreeTableViewCellElement(this, i, j));
}
}
return r;
} else if (selector.equals("select-by-properties")) {
return findSelectByProperties(new JSONObject((String) params[0]));
}
return super.getByPseudoElement(selector, params);
}
示例6: selectAllCells
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") @Test public void selectAllCells() {
TreeTableView<?> treeTableNode = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
Platform.runLater(() -> {
TreeTableViewSelectionModel<?> selectionModel = treeTableNode.getSelectionModel();
selectionModel.setCellSelectionEnabled(true);
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
selectionModel.selectRange(0, getTreeTableColumnAt(treeTableNode, 0), treeTableNode.getExpandedItemCount() - 1,
getTreeTableColumnAt(treeTableNode, 1));
treeTable.marathon_select("all");
});
new Wait("Waiting for all cells to be selected") {
@Override public boolean until() {
return treeTableNode.getSelectionModel().getSelectedCells().size() == treeTableNode.getExpandedItemCount()
* treeTableNode.getColumns().size();
}
};
}
示例7: start
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@Override public void start(Stage primaryStage) {
primaryStage.setTitle("TreeTable View Sample");
primaryStage.setScene(new Scene(new ChoiceBoxTreeTableSample()));
primaryStage.sizeToScene();
primaryStage.show();
TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
示例8: start
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@Override public void start(Stage primaryStage) {
primaryStage.setTitle("TreeTable View Sample");
primaryStage.setScene(new Scene(new TreeTableSample()));
primaryStage.sizeToScene();
primaryStage.show();
TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view");
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
示例9: getPoint
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
protected Point2D getPoint(TreeTableView<?> treeTableView, int rowIndex, int columnIndex) {
Set<Node> treeTableRowCell = treeTableView.lookupAll(".tree-table-row-cell");
TreeTableRow<?> row = null;
for (Node tableRow : treeTableRowCell) {
TreeTableRow<?> r = (TreeTableRow<?>) tableRow;
if (r.getIndex() == rowIndex) {
row = r;
break;
}
}
Set<Node> cells = row.lookupAll(".tree-table-cell");
for (Node node : cells) {
TreeTableCell<?, ?> cell = (TreeTableCell<?, ?>) node;
if (treeTableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
Bounds bounds = cell.getBoundsInParent();
Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
Point2D rowLocal = row.localToScene(localToParent, true);
return rowLocal;
}
}
return null;
}
示例10: selectAllRows
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@Test public void selectAllRows() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, null, lr);
int count = treeTableView.getExpandedItemCount();
for (int i = 0; i < count; i++) {
treeTableView.getSelectionModel().select(i);
}
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
示例11: selectMultipleCells
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") @Test public void selectMultipleCells() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel();
selectionModel.setCellSelectionEnabled(true);
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
Point2D point = getPoint(treeTableView, 1, 0);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr);
rfxTreeTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0);
selectionModel.select(1, column);
selectionModel.select(3, getTreeTableColumnAt(treeTableView, 1));
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals(
"{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"],[\"/Sales Department/Michael Brown\",\"Email\"]]}",
recording.getParameters()[0]);
}
示例12: selectACell
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") @Test public void selectACell() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
TreeTableViewSelectionModel<?> selectionModel = treeTableView.getSelectionModel();
selectionModel.setCellSelectionEnabled(true);
Point2D point = getPoint(treeTableView, 1, 0);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, point, lr);
rfxTreeTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TreeTableColumn column = getTreeTableColumnAt(treeTableView, 0);
selectionModel.select(1, column);
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("{\"cells\":[[\"/Sales Department/Ethan Williams\",\"Employee\"]]}", recording.getParameters()[0]);
}
示例13: selectAllCells
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") @Test public void selectAllCells() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, null, lr);
int count = treeTableView.getExpandedItemCount();
treeTableView.getSelectionModel().selectRange(0, getTreeTableColumnAt(treeTableView, 0), count - 1,
getTreeTableColumnAt(treeTableView, 1));
rfxTreeTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
示例14: getText
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
@Test public void getText() {
TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view");
LoggingRecorder lr = new LoggingRecorder();
List<String> text = new ArrayList<>();
Platform.runLater(() -> {
RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, null, lr);
treeTableView.getSelectionModel().select(2);
rfxTreeTableView.focusLost(null);
text.add(rfxTreeTableView.getAttribute("text"));
});
new Wait("Waiting for tree table view text.") {
@Override public boolean until() {
return text.size() > 0;
}
};
AssertJUnit.assertEquals("{\"rows\":[\"/Sales Department/Emma Jones\"]}", text.get(0));
}
示例15: getTestContainer
import javafx.scene.control.TreeTableView; //导入依赖的package包/类
/**
* A container containing the tested UI.
*
* @return
*/
protected Node getTestContainer() {
content = new Pane();
content.setId(CONTENT_PANE_ID);
content.setMinSize(500, 500);
content.setMaxSize(500, 500);
content.setPrefSize(500, 500);
treeTableView = new TreeTableView<Data>();
treeTableView.setId(TESTED_CONTROL_ID);
treeTableView.setRoot(new TreeItem<Data>(new Data("fictive", 50, 10)));
treeTableView.getRoot().setExpanded(true);
treeTableView.setMinSize(400, 400);
treeTableView.setMaxSize(400, 400);
treeTableView.setPrefSize(400, 400);
reset(DATA_ITEMS_NUM - 1, DATA_FIELDS_NUM, 0);// -1, as we have root.
content.getChildren().add(treeTableView);
treeTableView.setTranslateX(50);
treeTableView.setTranslateY(50);
return content;
}