Skip to content

Commit dbfcf55

Browse files
authored
Merge pull request #3874 from ControlSystemStudio/CSStudio-2365
added property name to display name
2 parents db6824d + 840d0e6 commit dbfcf55

2 files changed

Lines changed: 35 additions & 14 deletions

File tree

app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeByPropertyNode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class ChannelTreeByPropertyNode {
5656
public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeByPropertyNode parentNode, String displayName) {
5757
this.model = model;
5858
this.parentNode = parentNode;
59+
this.displayName = displayName;
5960

6061
// Calculate depth
6162
if (parentNode == null) {
@@ -64,7 +65,6 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy
6465
depth = parentNode.depth + 1;
6566
}
6667

67-
this.displayName = displayName;
6868

6969
// Construct the Channel list
7070
if (parentNode == null) {
@@ -90,6 +90,7 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy
9090
}
9191
}
9292
}
93+
9394
} else {
9495
// Filter the channels that match the property name
9596
nodeChannels = new ArrayList<Channel>();
@@ -115,6 +116,7 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy
115116
} else {
116117
childrenNames = null;
117118
}
119+
118120
}
119121

120122
/**

app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeController.java

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
import java.util.logging.Level;
1313
import java.util.stream.Collectors;
1414

15-
import javafx.scene.control.Label;
15+
import javafx.beans.property.ReadOnlyObjectWrapper;
16+
import javafx.scene.control.*;
17+
import javafx.scene.layout.HBox;
1618
import org.phoebus.channelfinder.Channel;
1719
import org.phoebus.channelfinder.ChannelUtil;
1820
import org.phoebus.framework.adapter.AdapterService;
@@ -25,15 +27,6 @@
2527
import javafx.collections.FXCollections;
2628
import javafx.collections.ObservableList;
2729
import javafx.fxml.FXML;
28-
import javafx.scene.control.Button;
29-
import javafx.scene.control.CheckBox;
30-
import javafx.scene.control.ContextMenu;
31-
import javafx.scene.control.MenuItem;
32-
import javafx.scene.control.SelectionMode;
33-
import javafx.scene.control.TextField;
34-
import javafx.scene.control.TreeItem;
35-
import javafx.scene.control.TreeTableColumn;
36-
import javafx.scene.control.TreeTableView;
3730
import javafx.scene.image.ImageView;
3831

3932
/**
@@ -59,7 +52,7 @@ public class ChannelTreeController extends ChannelFinderController {
5952
Label count;
6053

6154
@FXML
62-
TreeTableColumn<ChannelTreeByPropertyNode, String> node;
55+
TreeTableColumn<ChannelTreeByPropertyNode, ChannelTreeByPropertyNode> node;
6356
@FXML
6457
TreeTableColumn<ChannelTreeByPropertyNode, String> value;
6558

@@ -70,8 +63,33 @@ public class ChannelTreeController extends ChannelFinderController {
7063
@FXML
7164
public void initialize() {
7265
dispose();
66+
// what should the value be
67+
node.setCellValueFactory(cellValue -> new ReadOnlyObjectWrapper<>(cellValue.getValue().getValue()));
68+
69+
// how should the value be displayed
70+
node.setCellFactory(column -> new TreeTableCell<>() {
71+
@Override
72+
public void updateItem(ChannelTreeByPropertyNode node, boolean isEmpty) {
73+
super.updateItem(node, isEmpty);
74+
if (isEmpty || node == null) {
75+
setGraphic(null);
76+
setText(null);
77+
} else {
78+
if (node.getPropertyName() != null) {
79+
HBox hBox = new HBox();
80+
Label propertyLabel = new Label(node.getPropertyName() + " ");
81+
propertyLabel.setStyle("-fx-font-weight: bold;");
82+
hBox.getChildren().addAll(propertyLabel, new Label(node.getDisplayName()));
83+
setGraphic(hBox);
84+
setText(null);
85+
} else {
86+
setText(node.getDisplayName());
87+
setGraphic(null);
88+
}
89+
}
90+
}
91+
});
7392

74-
node.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDisplayName()));
7593
value.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDisplayValue()));
7694

7795
treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
@@ -141,10 +159,12 @@ private void reconstructTree() {
141159
public void configure() {
142160
if (model != null) {
143161
List<String> allProperties = ChannelUtil.getPropertyNames(model.getRoot().getNodeChannels()).stream().sorted().collect(Collectors.toList());
162+
144163
OrderedSelectionDialog dialog = new OrderedSelectionDialog(allProperties, orderedProperties);
145164
Optional<List<String>> result = dialog.showAndWait();
146165
result.ifPresent(r -> {
147166
setOrderedProperties(r);
167+
148168
});
149169
}
150170
}
@@ -244,5 +264,4 @@ private ObservableList<TreeItem<ChannelTreeByPropertyNode>> buildChildren(
244264
return children;
245265
}
246266
}
247-
248267
}

0 commit comments

Comments
 (0)