From 45db5005bbb38e093574c9215769f8724b7c0ccf Mon Sep 17 00:00:00 2001 From: ghidragon <106987263+ghidragon@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:42:26 -0500 Subject: [PATCH] GP-4375 added ability to toggle analyzer enablement via keyboard(space bar) --- .../plugin/core/analysis/AnalysisPanel.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java index 014fb0a9c3..bf97e48253 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/analysis/AnalysisPanel.java @@ -16,8 +16,7 @@ package ghidra.app.plugin.core.analysis; import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; +import java.awt.event.*; import java.beans.*; import java.io.File; import java.io.IOException; @@ -359,8 +358,8 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener { } File saveFile = getOptionsSaveFile(saveName); if (saveFile.exists() && OptionDialog.CANCEL_OPTION == OptionDialog - .showOptionDialogWithCancelAsDefaultButton(this, "Overwrite Configuration", - "Overwrite existing configuration file: " + saveName + " ?", "Overwrite")) { + .showOptionDialogWithCancelAsDefaultButton(this, "Overwrite Configuration", + "Overwrite existing configuration file: " + saveName + " ?", "Overwrite")) { return; } FileOptions currentOptions = getCurrentOptionsAsFileOptions(); @@ -442,6 +441,22 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener { configureEnabledColumnWidth(60); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().addListSelectionListener(this::selectedAnalyzerChanged); + + // add ability to toggle analyzers enablement using the keyboard space bar + table.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_SPACE) { + int row = table.getSelectedRow(); + int column = COLUMN_ANALYZER_IS_ENABLED; + if (row >= 0) { + boolean enabledState = (Boolean) model.getValueAt(row, column); + model.setValueAt(!enabledState, row, column); + } + } + } + }); + } private void selectedAnalyzerChanged(ListSelectionEvent event) { @@ -697,7 +712,7 @@ class AnalysisPanel extends JPanel implements PropertyChangeListener { GenericOptionsComponent.createOptionComponent(childState); HelpLocation helpLoc = analysisOptions - .getHelpLocation(analyzerName + Options.DELIMITER_STRING + childOptionName); + .getHelpLocation(analyzerName + Options.DELIMITER_STRING + childOptionName); if (helpLoc != null) { help.registerHelp(comp, helpLoc); }