Skip to content
Merged
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 @@ -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) {
Expand All @@ -64,7 +65,6 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy
depth = parentNode.depth + 1;
}

this.displayName = displayName;

// Construct the Channel list
if (parentNode == null) {
Expand All @@ -90,6 +90,7 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy
}
}
}

} else {
// Filter the channels that match the property name
nodeChannels = new ArrayList<Channel>();
Expand All @@ -115,6 +116,7 @@ public ChannelTreeByPropertyNode(ChannelTreeByPropertyModel model, ChannelTreeBy
} else {
childrenNames = null;
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand All @@ -59,7 +52,7 @@ public class ChannelTreeController extends ChannelFinderController {
Label count;

@FXML
TreeTableColumn<ChannelTreeByPropertyNode, String> node;
TreeTableColumn<ChannelTreeByPropertyNode, ChannelTreeByPropertyNode> node;
@FXML
TreeTableColumn<ChannelTreeByPropertyNode, String> value;

Expand All @@ -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);
Expand Down Expand Up @@ -141,10 +159,12 @@ private void reconstructTree() {
public void configure() {
if (model != null) {
List<String> allProperties = ChannelUtil.getPropertyNames(model.getRoot().getNodeChannels()).stream().sorted().collect(Collectors.toList());

OrderedSelectionDialog dialog = new OrderedSelectionDialog(allProperties, orderedProperties);
Optional<List<String>> result = dialog.showAndWait();
result.ifPresent(r -> {
setOrderedProperties(r);

});
}
}
Expand Down Expand Up @@ -244,5 +264,4 @@ private ObservableList<TreeItem<ChannelTreeByPropertyNode>> buildChildren(
return children;
}
}

}
Loading