From 4675f3a836a3973ae6d617c0ef25d9f762760ffb Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Fri, 30 Nov 2018 10:21:14 -0800 Subject: [PATCH] corefx - updated details panel css, changed how graph toolbar node/device selection works --- .../main/java/com/core/ui/GraphToolbar.java | 38 +++++++++---------- .../com/core/ui/dialogs/SessionsDialog.java | 7 +--- corefx/src/main/resources/css/main.css | 2 +- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/corefx/src/main/java/com/core/ui/GraphToolbar.java b/corefx/src/main/java/com/core/ui/GraphToolbar.java index ff4f5dd1..f64ca73a 100644 --- a/corefx/src/main/java/com/core/ui/GraphToolbar.java +++ b/corefx/src/main/java/com/core/ui/GraphToolbar.java @@ -168,50 +168,48 @@ public class GraphToolbar extends VBox { private void setupNodesButton() { nodesButton.setTooltip(new Tooltip("Network Nodes (host, pc, etc)")); - nodesList.getSelectionModel().selectedItemProperty().addListener((ov, old, current) -> { - if (current == null) { + nodesList.setOnMouseClicked(event -> { + Label selectedLabel = nodesList.getSelectionModel().getSelectedItem(); + if (selectedLabel == null) { return; } - updateButtonValues(nodesButton, current); - selectedNodeType = NodeType.get((int) current.getUserData()); + updateButtonValues(nodesButton, selectedLabel); + selectedNodeType = NodeType.get((int) selectedLabel.getUserData()); logger.info("selected node type: {}", selectedNodeType); setSelectedEditButton(nodesButton); devicesList.getSelectionModel().clearSelection(); controller.getNetworkGraph().setNodeType(selectedNodeType); - logger.info("node selected: {} - type: {}", current, selectedNodeType); + logger.info("node selected: {} - type: {}", selectedLabel, selectedNodeType); + setEditMode(); }); JFXPopup popup = new JFXPopup(nodesList); - nodesButton.setOnAction(event -> { - setEditMode(); - popup.show(nodesButton, JFXPopup.PopupVPosition.TOP, - JFXPopup.PopupHPosition.LEFT, nodesButton.getWidth(), 0); - }); + nodesButton.setOnAction(event -> popup.show(nodesButton, JFXPopup.PopupVPosition.TOP, + JFXPopup.PopupHPosition.LEFT, nodesButton.getWidth(), 0)); } private void setupDevicesButton() { devicesButton.setTooltip(new Tooltip("Device Nodes (WLAN, EMANE, Switch, etc)")); - devicesList.getSelectionModel().selectedItemProperty().addListener((ov, old, current) -> { - if (current == null) { + devicesList.setOnMouseClicked(event -> { + Label selectedLabel = devicesList.getSelectionModel().getSelectedItem(); + if (selectedLabel == null) { return; } - updateButtonValues(devicesButton, current); - selectedNodeType = NodeType.get((int) current.getUserData()); + updateButtonValues(devicesButton, selectedLabel); + selectedNodeType = NodeType.get((int) selectedLabel.getUserData()); logger.info("selected node type: {}", selectedNodeType); controller.getNetworkGraph().setNodeType(selectedNodeType); setSelectedEditButton(devicesButton); nodesList.getSelectionModel().clearSelection(); - logger.info("device selected: {} - type: {}", current, selectedNodeType); + logger.info("device selected: {} - type: {}", selectedLabel, selectedNodeType); + setEditMode(); }); JFXPopup popup = new JFXPopup(devicesList); - devicesButton.setOnAction(event -> { - setEditMode(); - popup.show(devicesButton, JFXPopup.PopupVPosition.TOP, - JFXPopup.PopupHPosition.LEFT, devicesButton.getWidth(), 0); - }); + devicesButton.setOnAction(event -> popup.show(devicesButton, JFXPopup.PopupVPosition.TOP, + JFXPopup.PopupHPosition.LEFT, devicesButton.getWidth(), 0)); } @FXML diff --git a/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java b/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java index d1f1a2ac..528fa77b 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java @@ -80,12 +80,9 @@ public class SessionsDialog extends StageDialog { } public void showDialog() throws IOException { - sessionsTable.getItems().clear(); List sessions = getCoreClient().getSessions(); - sessionsTable.getItems().addAll(sessions.stream() - .map(SessionRow::new) - .collect(Collectors.toList())); - + List rows = sessions.stream().map(SessionRow::new).collect(Collectors.toList()); + sessionsTable.getItems().setAll(rows); show(); } } diff --git a/corefx/src/main/resources/css/main.css b/corefx/src/main/resources/css/main.css index f7585fd4..81a47cc7 100644 --- a/corefx/src/main/resources/css/main.css +++ b/corefx/src/main/resources/css/main.css @@ -12,7 +12,7 @@ } .details-label { - -fx-background-color: slategrey; + -fx-background-color: black; -fx-pref-width: Infinity; -fx-text-fill: white; -fx-alignment: center;