下面列出了怎么用javafx.scene.control.TableView的API类实例代码及写法,或者点击链接到github查看源代码。
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
TableRow<?> row = null;
for (Node tableRow : tableRowCell) {
TableRow<?> r = (TableRow<?>) tableRow;
if (r.getIndex() == rowIndex) {
row = r;
break;
}
}
Set<Node> cells = row.lookupAll(".table-cell");
for (Node node : cells) {
TableCell<?, ?> cell = (TableCell<?, ?>) node;
if (tableView.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;
}
public TableVisualisation(final AbstractTableTranslator<? extends AnalyticResult<?>, C> translator) {
this.translator = translator;
this.tableVisualisation = new VBox();
this.tableFilter = new TextField();
tableFilter.setPromptText("Type here to filter results");
this.table = new TableView<>();
table.setPlaceholder(new Label("No results"));
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
table.setId("table-visualisation");
table.setPadding(new Insets(5));
tableVisualisation.getChildren().addAll(tableFilter, table);
}
@Override
public void commitEdit(String item) {
// This block is necessary to support commit on losing focus, because the baked-in mechanism
// sets our editing state to false before we can intercept the loss of focus.
// The default commitEdit(...) method simply bails if we are not editing...
if (!isEditing() && !item.equals(getItem())) {
TableView<SelectionTableRowData> table = getTableView();
if (table != null) {
TableColumn<SelectionTableRowData, String> column = getTableColumn();
CellEditEvent<SelectionTableRowData, String> event = new CellEditEvent<>(table,
new TablePosition<>(table, getIndex(), column), TableColumn.editCommitEvent(), item);
Event.fireEvent(column, event);
}
}
super.commitEdit(item);
setContentDisplay(ContentDisplay.TEXT_ONLY);
}
public final void availabeMethodsUI(){
initializeAvailableMethodList();
methodDescriptionLabel = new Label("Selected method description");
methodDescriptionLabel.setId("smalltext");
UIUtils.setSize(methodDescriptionLabel,Main.columnWidthLEFT,24);
VBox methodsLEFT = new VBox();
methodsLEFT.getChildren().addAll(methodList,new Rectangle(0,3),methodDescriptionLabel);
// Right part
applyButton = createApplyMethodButton();
UIUtils.setSize(applyButton, Main.columnWidthRIGHT, 24);
parameterTable = new TableView<>();
UIUtils.setSize(parameterTable, Main.columnWidthRIGHT, 64);
initializeParameterTable();
VBox methodsRIGHT = new VBox();
methodsRIGHT.getChildren().addAll(parameterTable,new Rectangle(0,3),applyButton);
// Both parts
HBox methodsBOTH = new HBox(5);
methodsBOTH.getChildren().addAll(methodsLEFT,methodsRIGHT);
grid.add(methodsBOTH,0,2);
}
private ActionSourceTransformer getActionSourceTransformer() {
return new ActionSourceTransformer() {
@Override
public Object getParentWidget(Object originwidget) {
if (originwidget instanceof GanttTaskCell) {
GanttTaskCell<?> gantttaskcell = (GanttTaskCell<?>) originwidget;
GanttDisplay<?> parentdisplay = gantttaskcell.getParentGanttDisplay();
return parentdisplay;
}
if (originwidget instanceof TableRow) {
TableRow<?> tablerow = (TableRow<?>) originwidget;
TableView<?> table = tablerow.getTableView();
return table;
}
return originwidget;
}
};
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void selectEditable() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
Point2D point = getPoint(tableView, 2, 1);
ComboBoxTableCell cell = (ComboBoxTableCell) getCellAt(tableView, 1, 2);
cell.setEditable(true);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
cell.startEdit();
tableView.edit(1, (TableColumn) tableView.getColumns().get(2));
Person person = (Person) tableView.getItems().get(1);
person.setLastName("Jones");
cell.commitEdit("Jones");
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("Jones", recording.getParameters()[0]);
}
public ButtonCell(TableColumn<T, Boolean> column, Glyph onGraphic, Glyph offGraphic) {
button = new ToggleButton();
button.setGraphic(onGraphic);
button.setSelected(true);
button.setOnMouseClicked(event -> {
final TableView<T> tableView = getTableView();
tableView.getSelectionModel().select(getTableRow().getIndex());
tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column);
if (button.isSelected()) {
commitEdit(true);
button.setGraphic(onGraphic);
} else {
commitEdit(false);
button.setGraphic(offGraphic);
}
});
}
@SuppressWarnings("unchecked")
@Test
public void selectACell() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
tableView.getSelectionModel().setCellSelectionEnabled(true);
Point2D point = getPoint(tableView, 1, 1);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TableColumn column = getTableColumnAt(tableView, 1);
tableView.getSelectionModel().select(1, column);
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"]]}", recording.getParameters()[0]);
}
public MemoryController(TableView<MemoryBean> tableView, Machine machine,
Button jump, Button last, Button next, ComboBox<String> typeBox,
TextField addressText, int pageNum, Memory memory) {
this.tableView = tableView;
this.pageNum = pageNum;
this.memoryListWrapper = new MemoryListWrapper(memory, pageNum);
this.machine = machine;
machine.addCpuListener(this);
TimingRenderer.register(this);
this.jump = jump;
this.last = last;
this.next = next;
this.typeBox = typeBox;
this.addressText = addressText;
initView();
}
@Test
public void selectMulpitleRows() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
Point2D point = getPoint(tableView, 1, 1);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
tableView.getSelectionModel().selectIndices(1, 3);
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("{\"rows\":[1,3]}", recording.getParameters()[0]);
}
private void createCyclesTable() {
TableGroupHeadline headline = new TableGroupHeadline(Res.get("dao.results.cycles.header"));
GridPane.setRowIndex(headline, ++gridRow);
GridPane.setMargin(headline, new Insets(Layout.GROUP_DISTANCE, -10, -10, -10));
GridPane.setColumnSpan(headline, 2);
root.getChildren().add(headline);
cyclesTableView = new TableView<>();
cyclesTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.processingData")));
cyclesTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
createCycleColumns(cyclesTableView);
GridPane.setRowIndex(cyclesTableView, gridRow);
GridPane.setMargin(cyclesTableView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, -10, -15, -10));
GridPane.setColumnSpan(cyclesTableView, 2);
GridPane.setVgrow(cyclesTableView, Priority.SOMETIMES);
root.getChildren().add(cyclesTableView);
cyclesTableView.setItems(sortedCycleListItemList);
sortedCycleListItemList.comparatorProperty().bind(cyclesTableView.comparatorProperty());
}
@Test
public void select() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
Point2D point = getPoint(tableView, 0, 1);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
Person person = (Person) tableView.getItems().get(1);
person.invitedProperty().set(true);
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals(":checked", recording.getParameters()[0]);
}
private void createDetailsView() {
TableGroupHeadline conflictTableHeadline = new TableGroupHeadline(getConflictTableHeadLine());
GridPane.setRowIndex(conflictTableHeadline, ++gridRow);
GridPane.setMargin(conflictTableHeadline, new Insets(Layout.GROUP_DISTANCE, -10, -10, -10));
root.getChildren().add(conflictTableHeadline);
conflictTableView = new TableView<>();
conflictTableView.setPlaceholder(new AutoTooltipLabel(Res.get("table.placeholder.noData")));
conflictTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
conflictTableView.setPrefHeight(100);
createConflictColumns();
GridPane.setRowIndex(conflictTableView, gridRow);
GridPane.setHgrow(conflictTableView, Priority.ALWAYS);
GridPane.setVgrow(conflictTableView, Priority.SOMETIMES);
GridPane.setMargin(conflictTableView, new Insets(Layout.FIRST_ROW_AND_GROUP_DISTANCE, -10, 5, -10));
root.getChildren().add(conflictTableView);
conflictTableView.setItems(sortedConflictList);
}
public ColorTableCell(TableColumn<T, Color> column) {
colorPicker = new ColorPicker();
colorPicker.editableProperty().bind(column.editableProperty());
colorPicker.disableProperty().bind(column.editableProperty().not());
colorPicker.setOnShowing(event -> {
final TableView<T> tableView = getTableView();
tableView.getSelectionModel().select(getTableRow().getIndex());
tableView.edit(tableView.getSelectionModel().getSelectedIndex(),
column);
});
colorPicker.valueProperty()
.addListener((observable, oldValue, newValue) -> {
commitEdit(newValue);
});
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
public final void availabeMethodsUI(){
initializeAvailableMethodList();
methodDescriptionLabel = new Label("Selected method description");
methodDescriptionLabel.setId("smalltext");
UIUtils.setSize(methodDescriptionLabel,Main.columnWidthLEFT,24);
VBox methodsLEFT = new VBox();
methodsLEFT.getChildren().addAll(methodList,new Rectangle(0,3),methodDescriptionLabel);
// Right part
applyButton = createApplyMethodButton();
UIUtils.setSize(applyButton, Main.columnWidthRIGHT, 24);
parameterTable = new TableView<>();
UIUtils.setSize(parameterTable, Main.columnWidthRIGHT, 64);
initializeParameterTable();
VBox methodsRIGHT = new VBox();
methodsRIGHT.getChildren().addAll(parameterTable,new Rectangle(0,3),applyButton);
// Both parts
HBox methodsBOTH = new HBox(5);
methodsBOTH.getChildren().addAll(methodsLEFT,methodsRIGHT);
grid.add(methodsBOTH,0,2);
}
@SuppressWarnings("unchecked")
@Test
public void selectMultipleCells() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
tableView.getSelectionModel().setCellSelectionEnabled(true);
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
Point2D point = getPoint(tableView, 1, 1);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
@SuppressWarnings("rawtypes")
TableColumn column = getTableColumnAt(tableView, 1);
tableView.getSelectionModel().select(1, column);
tableView.getSelectionModel().select(2, column);
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("{\"cells\":[[\"1\",\"Last\"],[\"2\",\"Last\"]]}", recording.getParameters()[0]);
}
@SuppressWarnings("unchecked")
@Test
public void selectAllCells() {
TableView<?> tableView = (TableView<?>) getPrimaryStage().getScene().getRoot().lookup(".table-view");
LoggingRecorder lr = new LoggingRecorder();
Platform.runLater(() -> {
tableView.getSelectionModel().setCellSelectionEnabled(true);
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
Point2D point = getPoint(tableView, 1, 1);
RFXTableView rfxTableView = new RFXTableView(tableView, null, point, lr);
rfxTableView.focusGained(null);
tableView.getSelectionModel().selectRange(0, getTableColumnAt(tableView, 0), 5, getTableColumnAt(tableView, 2));
rfxTableView.focusLost(null);
});
List<Recording> recordings = lr.waitAndGetRecordings(1);
Recording recording = recordings.get(0);
AssertJUnit.assertEquals("recordSelect", recording.getCall());
AssertJUnit.assertEquals("all", recording.getParameters()[0]);
}
public ArchiveListPane()
{
archive_list = new TableView<>(FXCollections.observableArrayList(Preferences.archive_urls));
final TableColumn<ArchiveDataSource, String> arch_col = new TableColumn<>(Messages.ArchiveName);
arch_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getName()));
arch_col.setMinWidth(0);
archive_list.getColumns().add(arch_col);
final MenuItem item_info = new MenuItem(Messages.ArchiveServerInfo, Activator.getIcon("info_obj"));
item_info.setOnAction(event -> showArchiveInfo());
ContextMenu menu = new ContextMenu(item_info);
archive_list.setContextMenu(menu);
archive_list.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
archive_list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
setCenter(archive_list);
}
public ColorTableCell(TableColumn<T, Color> column) {
colorPicker = new ColorPicker();
colorPicker.editableProperty().bind(column.editableProperty());
colorPicker.disableProperty().bind(column.editableProperty().not());
colorPicker.setOnShowing(event -> {
final TableView<T> tableView = getTableView();
tableView.getSelectionModel().select(getTableRow().getIndex());
tableView.edit(tableView.getSelectionModel().getSelectedIndex(), column);
});
colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> {
if (isEditing()) {
commitEdit(newValue);
}
});
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
}
@Override
public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
if (selector.equals("mnth-cell")) {
return Arrays.asList(
new JavaFXTableCellElement(this, ((Integer) params[0]).intValue() - 1, ((Integer) params[1]).intValue() - 1));
} else if (selector.equals("all-cells")) {
TableView<?> tableView = (TableView<?>) getComponent();
int rowCount = tableView.getItems().size();
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 JavaFXTableCellElement(this, i, j));
}
}
return r;
} else if (selector.equals("select-by-properties")) {
return findSelectByProperties(new JSONObject((String) params[0]));
}
return super.getByPseudoElement(selector, params);
}
private Tab createMacros(final Macros orig_macros)
{
final Macros macros = (orig_macros == null) ? new Macros() : orig_macros;
// Use text field to allow copying the name and value
// Table uses list of macro names as input
// Name column just displays the macro name,..
final TableColumn<String, String> name = new TableColumn<>(Messages.WidgetInfoDialog_Name);
name.setCellFactory(col -> new ReadOnlyTextCell<>());
name.setCellValueFactory(param -> new ReadOnlyStringWrapper(param.getValue()));
// .. value column fetches the macro value
final TableColumn<String, String> value = new TableColumn<>(Messages.WidgetInfoDialog_Value);
value.setCellFactory(col -> new ReadOnlyTextCell<>());
value.setCellValueFactory(param -> new ReadOnlyStringWrapper(macros.getValue(param.getValue())));
final TableView<String> table =
new TableView<>(FXCollections.observableArrayList(macros.getNames()));
table.getColumns().add(name);
table.getColumns().add(value);
table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
return new Tab(Messages.WidgetInfoDialog_TabMacros, table);
}
public AttributeNodeProvider() {
schemaLabel = new Label(SeparatorConstants.HYPHEN);
schemaLabel.setPadding(new Insets(5));
attributeInfo = FXCollections.observableArrayList();
table = new TableView<>();
table.setItems(attributeInfo);
table.setPlaceholder(new Label("No schema available"));
}
/**
* Retrieve data from the given table as comma-separated values.
*
* @param table the table to retrieve data from.
* @param includeHeader if true, the table headers will be included in the
* output.
* @param selectedOnly if true, only the data from selected rows in the
* table will be included in the output.
* @return a String of comma-separated values representing the table.
*/
public static String getTableData(final TableView<ObservableList<String>> table,
final boolean includeHeader, final boolean selectedOnly) {
final List<Integer> visibleIndices = table.getVisibleLeafColumns().stream()
.map(column -> table.getColumns().indexOf(column))
.collect(Collectors.toList());
final StringBuilder data = new StringBuilder();
if (includeHeader) {
data.append(visibleIndices.stream()
.filter(Objects::nonNull)
.map(index -> table.getColumns().get(index).getText())
.reduce((header1, header2) -> header1 + SeparatorConstants.COMMA + header2)
.get());
data.append(SeparatorConstants.NEWLINE);
}
if (selectedOnly) {
table.getSelectionModel().getSelectedItems().forEach(selectedItem -> {
data.append(visibleIndices.stream()
.filter(Objects::nonNull)
.map(index -> selectedItem.get(index))
.reduce((cell1, cell2) -> cell1 + SeparatorConstants.COMMA + cell2)
.get());
data.append(SeparatorConstants.NEWLINE);
});
} else {
table.getItems().forEach(item -> {
data.append(visibleIndices.stream()
.filter(Objects::nonNull)
.map(index -> item.get(index))
.reduce((cell1, cell2) -> cell1 + SeparatorConstants.COMMA + cell2)
.get());
data.append(SeparatorConstants.NEWLINE);
});
}
return data.toString();
}
/**
* Write data from the given table to a CSV file.
*
* @param table the table to retrieve data from.
* @param selectedOnly if true, only the data from selected rows in the
* table will be included in the output file.
*/
public static void exportToCsv(final TableView<ObservableList<String>> table, final boolean selectedOnly) {
Platform.runLater(() -> {
final FileChooser fileChooser = new FileChooser();
final ExtensionFilter csvFilter = new ExtensionFilter("CSV files", "*.csv");
fileChooser.getExtensionFilters().add(csvFilter);
final File csvFile = fileChooser.showSaveDialog(null);
if (csvFile != null) {
PluginExecution.withPlugin(new ExportToCsvFilePlugin(csvFile, table, selectedOnly)).executeLater(null);
}
});
}
private <R> void onItemClicked(TableView<R> tableView, int position, String text) {
if(tableView==tv1){
statusBar.setText("配置 "+text+" 加载成功");
opt.setCurrentPlanName(text);
try_read_configureLet(tv1.getItems().get(position));
tv1.refresh();
dirtyFlag|=0x1;
}else{
statusBar.setText("当前词典 : "+text);
adapter_idx=position;
tv2.refresh();
lastName=md.get(position)._Dictionary_fName;
dirtyFlag|=0x2;
}
}
public ExportToExcelFilePlugin(final File file,
final TableView<ObservableList<String>> table,
final boolean selectedOnly, final String sheetName) {
this.file = file;
this.table = table;
this.selectedOnly = selectedOnly;
this.sheetName = sheetName;
}
public TableViewPane(final TableViewTopComponent parent) {
this.parent = parent;
this.columnIndex = new CopyOnWriteArrayList<>();
this.elementIdToRowIndex = new HashMap<>();
this.rowToElementIdIndex = new HashMap<>();
this.lastChange = null;
final ToolBar toolbar = initToolbar();
setLeft(toolbar);
this.table = new TableView<>();
table.itemsProperty().addListener((v, o, n) -> table.refresh());
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
table.setPadding(new Insets(5));
setCenter(table);
// TODO: experiment with caching
table.setCache(false);
this.progress = new BorderPane();
final ProgressIndicator progressIndicator = new ProgressIndicator();
progressIndicator.setMaxSize(50, 50);
progress.setCenter(progressIndicator);
this.tableSelectionListener = (v, o, n) -> {
if (parent.getCurrentState() != null && !parent.getCurrentState().isSelectedOnly()) {
TableViewUtilities.copySelectionToGraph(table, rowToElementIdIndex,
parent.getCurrentState().getElementType(), parent.getCurrentGraph());
}
};
this.selectedProperty = table.getSelectionModel().selectedItemProperty();
selectedProperty.addListener(tableSelectionListener);
this.scheduledExecutorService = Executors.newScheduledThreadPool(1);
}
public TableSample1() {
final ObservableList<Person> data = FXCollections.observableArrayList(
new Person("Jacob", "Smith", "[email protected]"),
new Person("Isabella", "Johnson", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
new Person("Ethan", "Williams", "[email protected]"),
new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]xample.com"));
TableColumn firstNameCol = new TableColumn();
firstNameCol.setText("First");
firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
TableColumn lastNameCol = new TableColumn();
lastNameCol.setText("Last");
lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
TableColumn emailCol = new TableColumn();
emailCol.setText("Email");
emailCol.setMinWidth(200);
emailCol.setCellValueFactory(new PropertyValueFactory("email"));
TableView tableView = new TableView();
tableView.setItems(data);
tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
getChildren().add(tableView);
}
public static void restoreNode(String windowPrefix, Node root, Node n)
{
// TODO skip property
String name = getFullName(windowPrefix, root, n);
if(name == null)
{
return;
}
if(n instanceof SplitPane)
{
restoreSplitPane(name, (SplitPane)n);
}
else if(n instanceof TableView)
{
restoreTableView(name, (TableView)n);
}
if(n instanceof Parent)
{
for(Node ch: ((Parent)n).getChildrenUnmodifiable())
{
restoreNode(windowPrefix, root, ch);
}
}
LocalSettings s = LocalSettings.find(n);
if(s != null)
{
restoreLocalSettings(name, s);
}
Runnable r = getOnSettingsLoaded(n);
if(r != null)
{
r.run();
}
}
@Test
public void testTableClickErrorShowsIt() {
Platform.runLater(() -> BadaboomCollector.INSTANCE.add(new IllegalArgumentException("test exception")));
WaitForAsyncUtils.waitForFxEvents();
Platform.runLater(() -> {
final TableView<?> table = find("#table");
table.getSelectionModel().select(0);
});
WaitForAsyncUtils.waitForFxEvents();
final TextArea stack = find("#stack");
assertFalse(stack.getText().isEmpty());
}