diff --git a/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeByPropertyNode.java b/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeByPropertyNode.java index 0b4a98f9b3..4dc966e94c 100644 --- a/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeByPropertyNode.java +++ b/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeByPropertyNode.java @@ -56,6 +56,7 @@ public class ChannelTreeByPropertyNode { public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeByPropertyNode parentNode, String displayName) { this.model = model; this.parentNode = parentNode; + this.displayName = displayName; // Calculate depth if (parentNode == null) { @@ -64,7 +65,6 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy depth = parentNode.depth + 1; } - this.displayName = displayName; // Construct the Channel list if (parentNode == null) { @@ -90,6 +90,7 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy } } } + } else { // Filter the channels that match the property name nodeChannels = new ArrayList(); @@ -115,6 +116,7 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy } else { childrenNames = null; } + } /** diff --git a/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeController.java b/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeController.java index 00f3a243ee..200981d524 100644 --- a/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeController.java +++ b/app/channel/views/src/main/java/org/phoebus/channel/views/ui/ChannelTreeController.java @@ -12,7 +12,9 @@ import java.util.logging.Level; import java.util.stream.Collectors; -import javafx.scene.control.Label; +import javafx.beans.property.ReadOnlyObjectWrapper; +import javafx.scene.control.*; +import javafx.scene.layout.HBox; import org.phoebus.channelfinder.Channel; import org.phoebus.channelfinder.ChannelUtil; import org.phoebus.framework.adapter.AdapterService; @@ -25,15 +27,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.MenuItem; -import javafx.scene.control.SelectionMode; -import javafx.scene.control.TextField; -import javafx.scene.control.TreeItem; -import javafx.scene.control.TreeTableColumn; -import javafx.scene.control.TreeTableView; import javafx.scene.image.ImageView; /** @@ -59,7 +52,7 @@ public class ChannelTreeController extends ChannelFinderController { Label count; @FXML - TreeTableColumn node; + TreeTableColumn node; @FXML TreeTableColumn value; @@ -70,8 +63,33 @@ public class ChannelTreeController extends ChannelFinderController { @FXML public void initialize() { dispose(); + // what should the value be + node.setCellValueFactory(cellValue -> new ReadOnlyObjectWrapper<>(cellValue.getValue().getValue())); + + // how should the value be displayed + node.setCellFactory(column -> new TreeTableCell<>() { + @Override + public void updateItem(ChannelTreeByPropertyNode node, boolean isEmpty) { + super.updateItem(node, isEmpty); + if (isEmpty || node == null) { + setGraphic(null); + setText(null); + } else { + if (node.getPropertyName() != null) { + HBox hBox = new HBox(); + Label propertyLabel = new Label(node.getPropertyName() + " "); + propertyLabel.setStyle("-fx-font-weight: bold;"); + hBox.getChildren().addAll(propertyLabel, new Label(node.getDisplayName())); + setGraphic(hBox); + setText(null); + } else { + setText(node.getDisplayName()); + setGraphic(null); + } + } + } + }); - node.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDisplayName())); value.setCellValueFactory(cellValue -> new ReadOnlyStringWrapper(cellValue.getValue().getValue().getDisplayValue())); treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); @@ -141,10 +159,12 @@ private void reconstructTree() { public void configure() { if (model != null) { List allProperties = ChannelUtil.getPropertyNames(model.getRoot().getNodeChannels()).stream().sorted().collect(Collectors.toList()); + OrderedSelectionDialog dialog = new OrderedSelectionDialog(allProperties, orderedProperties); Optional> result = dialog.showAndWait(); result.ifPresent(r -> { setOrderedProperties(r); + }); } } @@ -244,5 +264,4 @@ private ObservableList> buildChildren( return children; } } - }