From c683bcbf0c7ae667bea1786635738b8d4bb687f5 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 24 Nov 2024 05:41:01 -0500 Subject: [PATCH] Tweak cell style for classes that have been modified --- .../cell/CellConfigurationService.java | 20 +++++++++++++++++++ .../coley/recaf/ui/window/QuickNavWindow.java | 1 + recaf-ui/src/main/resources/style/tweaks.css | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/recaf-ui/src/main/java/software/coley/recaf/services/cell/CellConfigurationService.java b/recaf-ui/src/main/java/software/coley/recaf/services/cell/CellConfigurationService.java index 71b35aec5..da44e1a50 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/services/cell/CellConfigurationService.java +++ b/recaf-ui/src/main/java/software/coley/recaf/services/cell/CellConfigurationService.java @@ -54,6 +54,7 @@ public class CellConfigurationService implements Service { public static final String SERVICE_ID = "cell-configuration"; private static final String UNKNOWN_TEXT = "[ERROR]"; + private static final String CLASS_EDITED = "modified-class-cell"; private static final Node UNKNOWN_GRAPHIC = new FontIconView(CarbonIcons.MISUSE_ALT); private static final Logger logger = Logging.get(WorkspaceTreeCell.class); private final CellConfigurationServiceConfig config; @@ -102,6 +103,7 @@ public CellConfigurationService(@Nonnull CellConfigurationServiceConfig config, */ public void reset(@Nonnull Cell cell) { FxThreadUtil.run(() -> { + cell.getStyleClass().remove(CLASS_EDITED); cell.setText(null); cell.setGraphic(null); cell.setContextMenu(null); @@ -119,6 +121,7 @@ public void reset(@Nonnull Cell cell) { */ public void configure(@Nonnull Cell cell, @Nonnull PathNode item, @Nonnull ContextSource source) { FxThreadUtil.run(() -> { + configureStyle(cell, item); cell.setText(textOf(item)); cell.setGraphic(graphicOf(item)); cell.setOnMouseClicked(contextMenuHandlerOf(cell, item, source)); @@ -154,6 +157,23 @@ private Navigable openPath(@Nonnull PathNode item) { return null; } + /** + * @param cell + * Cell node to configure style of. + * @param item + * Content within the cell. + */ + public void configureStyle(@Nonnull Node cell, @Nonnull PathNode item) { + // Add the edited class CSS style to classes with changes made to them + cell.getStyleClass().remove(CLASS_EDITED); + if (item instanceof ClassPathNode classPathNode) { + var bundle = classPathNode.getValueOfType(ClassBundle.class); + if (bundle != null && bundle.hasHistory(classPathNode.getValue().getName())) { + cell.getStyleClass().add(CLASS_EDITED); + } + } + } + /** * @param item * Item to create text for. diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/window/QuickNavWindow.java b/recaf-ui/src/main/java/software/coley/recaf/ui/window/QuickNavWindow.java index 21f7bf180..3270a889b 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/window/QuickNavWindow.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/window/QuickNavWindow.java @@ -91,6 +91,7 @@ public QuickNavWindow(@Nonnull WorkspaceManager workspaceManager, @Nonnull Comme packageName = formatConfig.filterMaxLength(packageName); Label classDisplay = new Label(); + configurationService.configureStyle(classDisplay, classPath); classDisplay.setText(configurationService.textOf(classPath)); classDisplay.setGraphic(configurationService.graphicOf(classPath)); diff --git a/recaf-ui/src/main/resources/style/tweaks.css b/recaf-ui/src/main/resources/style/tweaks.css index 980fe8af1..d9cfb514b 100644 --- a/recaf-ui/src/main/resources/style/tweaks.css +++ b/recaf-ui/src/main/resources/style/tweaks.css @@ -70,6 +70,11 @@ -fx-background-insets: 0; } +/* Indicates a class in the workspace tree has been edited */ +.modified-class-cell { + -fx-text-fill: rgb(75, 175, 210); +} + /* Applies background colors */ .background { -fx-background-color: -color-bg-default;