Skip to content
This repository has been archived by the owner on Dec 19, 2021. It is now read-only.

Add LastUpdated tab to viewport #97

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class MainWindowController {
private TreeTableColumn<TreeRow, Object> valueColumn;
@FXML
private TreeTableColumn<TreeRow, String> typeColumn;
@FXML
private TreeTableColumn<TreeRow, Long> lastUpdateColumn;

@FXML
@SuppressWarnings("PMD.AccessorMethodGeneration")
Expand All @@ -85,6 +87,7 @@ private void initialize() {
NetworkTableUtilities.simpleKey(param.getValue().getValue().getKey())));
valueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("value"));
typeColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("type"));
lastUpdateColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("lastUpdated"));
valueColumn.setCellFactory(param -> new TreeEntryTreeTableCell<>());

valueColumn.setOnEditCommit(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public TreeEntry(NetworkTableEntry entry) {
() -> networkTableEntry.get().getValue().getValue(), networkTableEntry));
this.type.bind(Bindings.createObjectBinding(
() -> networkTableEntry.get().getValue().getType().toString(), networkTableEntry));
this.lastUpdated.bind(Bindings.createLongBinding(
() -> networkTableEntry.get().getValue().getTime(), networkTableEntry));
}

public final NetworkTableEntry getNetworkTableEntry() {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/edu/wpi/first/outlineviewer/model/TreeRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.property.LongProperty;

import java.util.Objects;

Expand All @@ -16,6 +18,7 @@ public class TreeRow {
protected final StringProperty key = new SimpleStringProperty(this, "key", "");
protected final ObjectProperty<Object> value = new SimpleObjectProperty<>(this, "value", null);
protected final StringProperty type = new SimpleStringProperty(this, "type", "");
protected final LongProperty lastUpdated = new SimpleLongProperty(this, "lastUpdated", 0);

protected TreeRow() {
// Users must provide a key!
Expand Down Expand Up @@ -64,12 +67,21 @@ public StringProperty typeProperty() {
return type;
}

public long getLastUpdated() {
return lastUpdated.get();
}

public LongProperty lastUpdatedProperty() {
return lastUpdated;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("Key", key.getValue())
.add("Value", value.get())
.add("Type", typeProperty().getValue())
.add("Last Updated", lastUpdated.getValue())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<TreeTableColumn fx:id="keyColumn" minWidth="200" prefWidth="200" sortable="false" text="Key" id="keyColumn"/>
<TreeTableColumn fx:id="valueColumn" minWidth="200" prefWidth="200" sortable="false" text="Value" id="valueColumn"/>
<TreeTableColumn fx:id="typeColumn" editable="false" prefWidth="100" minWidth="100" sortable="false" text="Type" id="typeColumn"/>
<TreeTableColumn fx:id="lastUpdateColumn" editable="false" prefWidth="100" minWidth="100" sortable="false" text="Last Updated" id="lastUpdateColumn"/>
</columns>
</NetworkTableTree>
</center>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void getTypeTest() {

@Test
void toStringTest() {
assertEquals("TreeRow{Key=key, Value=value, Type=}", new TreeRow("key", "value").toString());
assertEquals("TreeRow{Key=key, Value=value, Type=, Last Updated=0}", new TreeRow("key", "value").toString());
}

private static class FakeTreeRow extends TreeRow {
Expand Down