Skip to content

Commit

Permalink
Updated TableController.java
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rkMindz committed Apr 3, 2018
1 parent 3927fce commit 5dc4122
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/controllers/TableController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import javafx.scene.control.*;
import javafx.scene.text.Text;
import javafx.util.Callback;
import models.schema.Column;
import models.schema.Row;
import models.schema.Table;

Expand Down Expand Up @@ -108,6 +107,7 @@ public ObservableValue<String> call(TableColumn.CellDataFeatures<ObservableList,
return new SimpleStringProperty(cellValue);
}
});

// add all columns to the table
this.tableView.getColumns().addAll(col);
}
Expand All @@ -128,4 +128,20 @@ public ObservableValue<String> call(TableColumn.CellDataFeatures<ObservableList,
e.printStackTrace();
}
}

private void setTableEditable() {
this.tableView.setEditable(true);
this.tableView.getSelectionModel().cellSelectionEnabledProperty().set(true);
this.tableView.setOnKeyPressed(event -> {
if (event.getCode().isLetterKey() || event.getCode().isDigitKey()) {
this.editFocusedCell();
}
});
}

private void editFocusedCell() {
// TODO continue here (https://dzone.com/articles/editable-tables-in-javafx)(https://docs.oracle.com/javafx/2/ui_controls/table-view.htm)
final TablePosition<?,?> focusedCell = this.tableView.focusModelProperty().get();
this.tableView.edit(focusedCell.getRow(), focusedCell.getTableColumn());
}
}

0 comments on commit 5dc4122

Please sign in to comment.