From 90cceb69c9997d1de2d0865d3e55dd7107d63219 Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 24 Nov 2024 04:59:57 -0500 Subject: [PATCH] Add rename keybind to workspace explorer --- .../recaf/ui/control/tree/WorkspaceTree.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTree.java b/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTree.java index bc3ebac57..447e3fbd0 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTree.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/control/tree/WorkspaceTree.java @@ -4,6 +4,7 @@ import jakarta.annotation.Nullable; import jakarta.enterprise.context.Dependent; import jakarta.inject.Inject; +import javafx.scene.control.TreeItem; import net.greypanther.natsort.CaseInsensitiveSimpleNaturalComparator; import software.coley.recaf.info.AndroidClassInfo; import software.coley.recaf.info.ClassInfo; @@ -15,15 +16,18 @@ import software.coley.recaf.path.DirectoryPathNode; import software.coley.recaf.path.EmbeddedResourceContainerPathNode; import software.coley.recaf.path.FilePathNode; +import software.coley.recaf.path.PathNode; import software.coley.recaf.path.PathNodes; import software.coley.recaf.path.ResourcePathNode; import software.coley.recaf.path.WorkspacePathNode; import software.coley.recaf.services.cell.CellConfigurationService; import software.coley.recaf.services.navigation.Actions; import software.coley.recaf.services.workspace.WorkspaceCloseListener; +import software.coley.recaf.ui.config.KeybindingConfig; import software.coley.recaf.ui.config.WorkspaceExplorerConfig; import software.coley.recaf.ui.control.PathNodeTree; import software.coley.recaf.util.FxThreadUtil; +import software.coley.recaf.util.NodeEvents; import software.coley.recaf.util.StringUtil; import software.coley.recaf.workspace.model.Workspace; import software.coley.recaf.workspace.model.WorkspaceModificationListener; @@ -64,9 +68,18 @@ public class WorkspaceTree extends PathNodeTree implements */ @Inject public WorkspaceTree(@Nonnull CellConfigurationService configurationService, @Nonnull Actions actions, - @Nonnull WorkspaceExplorerConfig explorerConfig) { + @Nonnull KeybindingConfig keys, @Nonnull WorkspaceExplorerConfig explorerConfig) { super(configurationService, actions); + // Additional workspace-explorer specific bind handling + NodeEvents.addKeyPressHandler(this, e -> { + if (keys.getRename().match(e)) { + TreeItem> selectedItem = getSelectionModel().getSelectedItem(); + if (selectedItem != null) + actions.rename(selectedItem.getValue()); + } + }); + this.explorerConfig = explorerConfig; }