From a4ac411e56ff39e5b0c015f9ba8b1c65bf569e36 Mon Sep 17 00:00:00 2001 From: Andrei Molnar <1995am@pm.me> Date: Wed, 18 Nov 2026 00:20:20 +0100 Subject: [PATCH] Deactivated nav items show as greyed out --- .../sopa/ui/editor/TestCaseEditorPane.java | 8 ++++++-- .../sopa/ui/editor/step/StepEditorPane.java | 8 ++++++-- .../com/molnarandrei/sopa/ui/navpane/SopaTreeCell.java | 10 +++++++--- src/main/resources/style.css | 5 +++++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/molnarandrei/sopa/ui/editor/TestCaseEditorPane.java b/src/main/java/com/molnarandrei/sopa/ui/editor/TestCaseEditorPane.java index a01c0fe..73bb239 100644 --- a/src/main/java/com/molnarandrei/sopa/ui/editor/TestCaseEditorPane.java +++ b/src/main/java/com/molnarandrei/sopa/ui/editor/TestCaseEditorPane.java @@ -85,7 +85,12 @@ public class TestCaseEditorPane extends BorderPane implements Destroyable { bottom.getChildren().add(actions); activeToggle = new ToggleSwitch("Activo"); - activeToggle.selectedProperty().addListener((obs, old, value)-> testCase.setActive(value)); + activeToggle.setSelected(testCase.isActive()); + // Listener added after the initial value, so opening the editor does not save. + activeToggle.selectedProperty().addListener((obs, old, value)-> { + testCase.setActive(value); + submit.run(); + }); actions.getChildren().add(activeToggle); actions.getChildren().add(new Spacer()); @@ -108,7 +113,6 @@ public class TestCaseEditorPane extends BorderPane implements Destroyable { private void loadTestCase(TestCase testCase) { title.setText("Caso %s".formatted(testCase.getName())); - activeToggle.setSelected(testCase.isActive()); nameField.setText(testCase.getName()); endpointField.setText(testCase.getEndpoint()); actionField.setText(testCase.getAction()); diff --git a/src/main/java/com/molnarandrei/sopa/ui/editor/step/StepEditorPane.java b/src/main/java/com/molnarandrei/sopa/ui/editor/step/StepEditorPane.java index 59a37df..61a3ff5 100644 --- a/src/main/java/com/molnarandrei/sopa/ui/editor/step/StepEditorPane.java +++ b/src/main/java/com/molnarandrei/sopa/ui/editor/step/StepEditorPane.java @@ -95,7 +95,12 @@ public class StepEditorPane extends BorderPane implements Destroyable { setBottom(bottom); activeToggle = new ToggleSwitch("Activo"); - activeToggle.selectedProperty().addListener((obs, old, value)-> step.setActive(value)); + activeToggle.setSelected(step.isActive()); + // Listener added after the initial value, so opening the editor does not save. + activeToggle.selectedProperty().addListener((obs, old, value)-> { + step.setActive(value); + StepService.write(stepPath, step); + }); bottom.getChildren().add(activeToggle); bottom.getChildren().add(new Spacer()); @@ -156,7 +161,6 @@ public class StepEditorPane extends BorderPane implements Destroyable { private void loadStep(Step step) { title.setText("Paso %s".formatted(step.getName())); - activeToggle.setSelected(step.isActive()); payload.setXml(step.getPayload()); } } diff --git a/src/main/java/com/molnarandrei/sopa/ui/navpane/SopaTreeCell.java b/src/main/java/com/molnarandrei/sopa/ui/navpane/SopaTreeCell.java index 08ec2c4..f1bc2d5 100644 --- a/src/main/java/com/molnarandrei/sopa/ui/navpane/SopaTreeCell.java +++ b/src/main/java/com/molnarandrei/sopa/ui/navpane/SopaTreeCell.java @@ -125,7 +125,7 @@ public class SopaTreeCell extends TreeCell { if (empty || item == null) return; - getStyleClass().remove("text-bold"); + getStyleClass().removeAll("text-bold", "inactive"); var path = item.path(); try { switch (item.kind()) { @@ -136,12 +136,16 @@ public class SopaTreeCell extends TreeCell { getStyleClass().add("text-bold"); break; case testcase: - setText(TestCaseRepository.get(path).getName()); + var testCase = TestCaseRepository.get(path); + setText(testCase.getName()); + if (!testCase.isActive()) getStyleClass().add("inactive"); setGraphic(null); setContextMenu(new TestCaseContextMenu(item.path())); break; case step: - setText(StepRepository.get(path).getName()); + var step = StepRepository.get(path); + setText(step.getName()); + if (!step.isActive()) getStyleClass().add("inactive"); setContextMenu(new StepContextMenu(item.path())); setGraphic(flightIcon(flightStates.apply(path))); break; diff --git a/src/main/resources/style.css b/src/main/resources/style.css index 2e1509a..e1dd6f9 100644 --- a/src/main/resources/style.css +++ b/src/main/resources/style.css @@ -43,3 +43,8 @@ .tree-cell .flight-icon.exception { -fx-icon-color: -color-danger-fg; } + +/* Deactivated testcases and steps appear de-emphasized in the project tree. */ +.tree-cell.inactive { + -color-cell-fg: -color-fg-muted; +}