Skip to content

Commit

Permalink
Add rename keybind to workspace explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Nov 24, 2024
1 parent 6889c2e commit 90cceb6
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<PathNode<?>> selectedItem = getSelectionModel().getSelectedItem();
if (selectedItem != null)
actions.rename(selectedItem.getValue());
}
});

this.explorerConfig = explorerConfig;
}

Expand Down

0 comments on commit 90cceb6

Please sign in to comment.