Skip to content

Commit

Permalink
Tweak cell style for classes that have been modified
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Nov 24, 2024
1 parent d2c43da commit c683bcb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
5 changes: 5 additions & 0 deletions recaf-ui/src/main/resources/style/tweaks.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c683bcb

Please sign in to comment.