Add online state column. Fix capitalization
This commit is contained in:
parent
3b545d12b2
commit
4419a8d723
|
@ -31,6 +31,7 @@ public class JavaFxModel implements Model {
|
||||||
private final transient SimpleIntegerProperty priorityProperty = new SimpleIntegerProperty();
|
private final transient SimpleIntegerProperty priorityProperty = new SimpleIntegerProperty();
|
||||||
private final transient SimpleObjectProperty<Instant> lastSeenProperty = new SimpleObjectProperty<>();
|
private final transient SimpleObjectProperty<Instant> lastSeenProperty = new SimpleObjectProperty<>();
|
||||||
private final transient SimpleObjectProperty<Instant> lastRecordedProperty = new SimpleObjectProperty<>();
|
private final transient SimpleObjectProperty<Instant> lastRecordedProperty = new SimpleObjectProperty<>();
|
||||||
|
private final transient SimpleObjectProperty<State> onlineStateProperty = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
private final Model delegate;
|
private final Model delegate;
|
||||||
|
|
||||||
|
@ -39,6 +40,21 @@ public class JavaFxModel implements Model {
|
||||||
setPriority(delegate.getPriority());
|
setPriority(delegate.getPriority());
|
||||||
setLastSeen(delegate.getLastSeen());
|
setLastSeen(delegate.getLastSeen());
|
||||||
setLastRecorded(delegate.getLastRecorded());
|
setLastRecorded(delegate.getLastRecorded());
|
||||||
|
try { // TODO: split online state updates and reading from cache, so that we don't need try-catch
|
||||||
|
onlineStateProperty.setValue(delegate.getOnlineState(true));
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateFrom(JavaFxModel other) {
|
||||||
|
this.setSuspended(other.isSuspended());
|
||||||
|
this.setForcePriority(other.isForcePriority());
|
||||||
|
this.getOnlineProperty().set(other.getOnlineProperty().get());
|
||||||
|
this.getRecordingProperty().set(other.getRecordingProperty().get());
|
||||||
|
this.lastRecordedProperty().set(other.lastRecordedProperty().get());
|
||||||
|
this.lastSeenProperty().set(other.lastSeenProperty().get());
|
||||||
|
this.setRecordUntil(other.getRecordUntil());
|
||||||
|
this.setRecordUntilSubsequentAction(other.getRecordUntilSubsequentAction());
|
||||||
|
this.onlineStateProperty().set(other.onlineStateProperty().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,6 +158,10 @@ public class JavaFxModel implements Model {
|
||||||
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
||||||
return delegate.isOnline(ignoreCache);
|
return delegate.isOnline(ignoreCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnlineStateProperty(State state) throws IOException, ExecutionException {
|
||||||
|
onlineStateProperty.set(state);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
|
public State getOnlineState(boolean failFast) throws IOException, ExecutionException {
|
||||||
|
@ -294,6 +314,10 @@ public class JavaFxModel implements Model {
|
||||||
return lastRecordedProperty;
|
return lastRecordedProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleObjectProperty<State> onlineStateProperty() {
|
||||||
|
return onlineStateProperty;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLastRecorded(Instant timestamp) {
|
public void setLastRecorded(Instant timestamp) {
|
||||||
delegate.setLastRecorded(timestamp);
|
delegate.setLastRecorded(timestamp);
|
||||||
|
|
|
@ -327,7 +327,7 @@ public abstract class AbstractRecordedModelsTab extends Tab implements TabSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addAddedTimestampColumn(int columnIdx) {
|
protected void addAddedTimestampColumn(int columnIdx) {
|
||||||
TableColumn<JavaFxModel, Instant> tc = addTableColumn("addedTimestamp", "added at", columnIdx, 400);
|
TableColumn<JavaFxModel, Instant> tc = addTableColumn("addedTimestamp", "Added at", columnIdx, 400);
|
||||||
tc.setCellFactory(new DateTimeCellFactory<>(config.getDateTimeFormatter()));
|
tc.setCellFactory(new DateTimeCellFactory<>(config.getDateTimeFormatter()));
|
||||||
tc.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getAddedTimestamp()));
|
tc.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getAddedTimestamp()));
|
||||||
tc.setPrefWidth(150);
|
tc.setPrefWidth(150);
|
||||||
|
|
|
@ -106,11 +106,7 @@ public class RecordLaterTab extends AbstractRecordedModelsTab implements TabSele
|
||||||
} 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);
|
||||||
oldModel.setSuspended(updatedModel.isSuspended());
|
oldModel.updateFrom(updatedModel);
|
||||||
oldModel.getOnlineProperty().set(updatedModel.getOnlineProperty().get());
|
|
||||||
oldModel.getRecordingProperty().set(updatedModel.getRecordingProperty().get());
|
|
||||||
oldModel.lastRecordedProperty().set(updatedModel.lastRecordedProperty().get());
|
|
||||||
oldModel.lastSeenProperty().set(updatedModel.lastSeenProperty().get());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
|
||||||
priority.setUserData(idx++);
|
priority.setUserData(idx++);
|
||||||
columns.add(priority);
|
columns.add(priority);
|
||||||
table.getColumns().add(priority);
|
table.getColumns().add(priority);
|
||||||
TableColumn<JavaFxModel, Instant> lastSeen = new TableColumn<>("last seen");
|
TableColumn<JavaFxModel, Instant> lastSeen = new TableColumn<>("Last seen");
|
||||||
lastSeen.setCellValueFactory(cdf -> cdf.getValue().lastSeenProperty());
|
lastSeen.setCellValueFactory(cdf -> cdf.getValue().lastSeenProperty());
|
||||||
lastSeen.setCellFactory(new DateTimeCellFactory<>(config.getDateTimeFormatter()));
|
lastSeen.setCellFactory(new DateTimeCellFactory<>(config.getDateTimeFormatter()));
|
||||||
lastSeen.setPrefWidth(150);
|
lastSeen.setPrefWidth(150);
|
||||||
|
@ -131,7 +131,7 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
|
||||||
lastSeen.setStyle(STYLE_ALIGN_CENTER);
|
lastSeen.setStyle(STYLE_ALIGN_CENTER);
|
||||||
columns.add(lastSeen);
|
columns.add(lastSeen);
|
||||||
table.getColumns().add(lastSeen);
|
table.getColumns().add(lastSeen);
|
||||||
TableColumn<JavaFxModel, Instant> lastRecorded = new TableColumn<>("last recorded");
|
TableColumn<JavaFxModel, Instant> lastRecorded = new TableColumn<>("Last recorded");
|
||||||
lastRecorded.setCellValueFactory(cdf -> cdf.getValue().lastRecordedProperty());
|
lastRecorded.setCellValueFactory(cdf -> cdf.getValue().lastRecordedProperty());
|
||||||
lastRecorded.setCellFactory(new DateTimeCellFactory<>(config.getDateTimeFormatter()));
|
lastRecorded.setCellFactory(new DateTimeCellFactory<>(config.getDateTimeFormatter()));
|
||||||
lastRecorded.setPrefWidth(150);
|
lastRecorded.setPrefWidth(150);
|
||||||
|
@ -140,8 +140,19 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
|
||||||
lastRecorded.setUserData(idx++);
|
lastRecorded.setUserData(idx++);
|
||||||
lastRecorded.setStyle(STYLE_ALIGN_CENTER);
|
lastRecorded.setStyle(STYLE_ALIGN_CENTER);
|
||||||
columns.add(lastRecorded);
|
columns.add(lastRecorded);
|
||||||
table.getColumns().add(lastRecorded);
|
table.getColumns().add(lastRecorded);
|
||||||
|
TableColumn<JavaFxModel, Model.State> onlineState = new TableColumn<>("State");
|
||||||
|
onlineState.setCellValueFactory(cdf -> cdf.getValue().onlineStateProperty());
|
||||||
|
onlineState.setCellFactory(new ClickableCellFactory<>());
|
||||||
|
onlineState.setPrefWidth(150);
|
||||||
|
onlineState.setEditable(false);
|
||||||
|
onlineState.setId("onlineState");
|
||||||
|
onlineState.setUserData(idx++);
|
||||||
|
onlineState.setStyle(STYLE_ALIGN_CENTER);
|
||||||
|
onlineState.setVisible(false);
|
||||||
|
columns.add(onlineState);
|
||||||
|
table.getColumns().add(onlineState);
|
||||||
|
|
||||||
addAddedTimestampColumn(idx++);
|
addAddedTimestampColumn(idx++);
|
||||||
addNotesColumn(idx);
|
addNotesColumn(idx);
|
||||||
|
|
||||||
|
@ -261,14 +272,7 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
|
||||||
} 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);
|
||||||
oldModel.setSuspended(updatedModel.isSuspended());
|
oldModel.updateFrom(updatedModel);
|
||||||
oldModel.setForcePriority(updatedModel.isForcePriority());
|
|
||||||
oldModel.getOnlineProperty().set(updatedModel.getOnlineProperty().get());
|
|
||||||
oldModel.getRecordingProperty().set(updatedModel.getRecordingProperty().get());
|
|
||||||
oldModel.lastRecordedProperty().set(updatedModel.lastRecordedProperty().get());
|
|
||||||
oldModel.lastSeenProperty().set(updatedModel.lastSeenProperty().get());
|
|
||||||
oldModel.setRecordUntil(updatedModel.getRecordUntil());
|
|
||||||
oldModel.setRecordUntilSubsequentAction(updatedModel.getRecordUntilSubsequentAction());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,6 +326,9 @@ public class RecordedModelsTab extends AbstractRecordedModelsTab implements TabS
|
||||||
for (Model onlineModel : onlineModels) {
|
for (Model onlineModel : onlineModels) {
|
||||||
if (Objects.equals(onlineModel, fxm)) {
|
if (Objects.equals(onlineModel, fxm)) {
|
||||||
fxm.setOnlineProperty(true);
|
fxm.setOnlineProperty(true);
|
||||||
|
try {
|
||||||
|
fxm.setOnlineStateProperty(onlineModel.getOnlineState(true));
|
||||||
|
} catch (Exception e) {}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue