Make paused checkboxes clickable
This commit is contained in:
parent
ecf9fc2746
commit
0e627aef12
|
@ -3,6 +3,7 @@ package ctbrec.ui;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -104,26 +105,31 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
scrollPane.setFitToWidth(true);
|
scrollPane.setFitToWidth(true);
|
||||||
BorderPane.setMargin(scrollPane, new Insets(5));
|
BorderPane.setMargin(scrollPane, new Insets(5));
|
||||||
|
|
||||||
table.setEditable(false);
|
table.setEditable(true);
|
||||||
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
TableColumn<JavaFxModel, String> name = new TableColumn<>("Model");
|
TableColumn<JavaFxModel, String> name = new TableColumn<>("Model");
|
||||||
name.setPrefWidth(200);
|
name.setPrefWidth(200);
|
||||||
name.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("name"));
|
name.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("name"));
|
||||||
|
name.setEditable(false);
|
||||||
TableColumn<JavaFxModel, String> url = new TableColumn<>("URL");
|
TableColumn<JavaFxModel, String> url = new TableColumn<>("URL");
|
||||||
url.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("url"));
|
url.setCellValueFactory(new PropertyValueFactory<JavaFxModel, String>("url"));
|
||||||
url.setPrefWidth(400);
|
url.setPrefWidth(400);
|
||||||
|
url.setEditable(false);
|
||||||
TableColumn<JavaFxModel, Boolean> online = new TableColumn<>("Online");
|
TableColumn<JavaFxModel, Boolean> online = new TableColumn<>("Online");
|
||||||
online.setCellValueFactory((cdf) -> cdf.getValue().getOnlineProperty());
|
online.setCellValueFactory((cdf) -> cdf.getValue().getOnlineProperty());
|
||||||
online.setCellFactory(CheckBoxTableCell.forTableColumn(online));
|
online.setCellFactory(CheckBoxTableCell.forTableColumn(online));
|
||||||
online.setPrefWidth(100);
|
online.setPrefWidth(100);
|
||||||
|
online.setEditable(false);
|
||||||
TableColumn<JavaFxModel, Boolean> recording = new TableColumn<>("Recording");
|
TableColumn<JavaFxModel, Boolean> recording = new TableColumn<>("Recording");
|
||||||
recording.setCellValueFactory((cdf) -> cdf.getValue().getRecordingProperty());
|
recording.setCellValueFactory((cdf) -> cdf.getValue().getRecordingProperty());
|
||||||
recording.setCellFactory(CheckBoxTableCell.forTableColumn(recording));
|
recording.setCellFactory(CheckBoxTableCell.forTableColumn(recording));
|
||||||
recording.setPrefWidth(100);
|
recording.setPrefWidth(100);
|
||||||
|
recording.setEditable(false);
|
||||||
TableColumn<JavaFxModel, Boolean> paused = new TableColumn<>("Paused");
|
TableColumn<JavaFxModel, Boolean> paused = new TableColumn<>("Paused");
|
||||||
paused.setCellValueFactory((cdf) -> cdf.getValue().getPausedProperty());
|
paused.setCellValueFactory((cdf) -> cdf.getValue().getPausedProperty());
|
||||||
paused.setCellFactory(CheckBoxTableCell.forTableColumn(paused));
|
paused.setCellFactory(CheckBoxTableCell.forTableColumn(paused));
|
||||||
paused.setPrefWidth(100);
|
paused.setPrefWidth(100);
|
||||||
|
paused.setEditable(true);
|
||||||
table.getColumns().addAll(name, url, online, recording, paused);
|
table.getColumns().addAll(name, url, online, recording, paused);
|
||||||
table.setItems(observableModels);
|
table.setItems(observableModels);
|
||||||
table.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
|
table.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
|
||||||
|
@ -299,6 +305,13 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
|
||||||
int index = observableModels.indexOf(updatedModel);
|
int index = observableModels.indexOf(updatedModel);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
observableModels.add(updatedModel);
|
observableModels.add(updatedModel);
|
||||||
|
updatedModel.getPausedProperty().addListener((obs, oldV, newV) -> {
|
||||||
|
if(newV) {
|
||||||
|
pauseRecording(Collections.singletonList(updatedModel));
|
||||||
|
} else {
|
||||||
|
resumeRecording(Collections.singletonList(updatedModel));
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// make sure to update the JavaFX online property, so that the table cell is updated
|
// make sure to update the JavaFX online property, so that the table cell is updated
|
||||||
JavaFxModel oldModel = observableModels.get(index);
|
JavaFxModel oldModel = observableModels.get(index);
|
||||||
|
|
Loading…
Reference in New Issue