diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java index 61ff961d46..d72df68d7b 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java @@ -127,46 +127,10 @@ public abstract class AbstractCodeBrowserPlugin
ex fieldOptions.addOptionsChangeListener(this); tool.setDefaultComponent(connectedProvider); markerChangeListener = new MarkerChangeListener(connectedProvider); - createActions(); } protected abstract P createProvider(FormatManager formatManager, boolean isConnected); - private void createActions() { - new ActionBuilder("Select All", getName()) - .menuPath(ToolConstants.MENU_SELECTION, "&All in View") - .menuGroup("Select Group", "a") - .keyBinding("ctrl A") - .supportsDefaultToolContext(true) - .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select All")) - .withContext(CodeViewerActionContext.class) - .inWindow(ActionBuilder.When.CONTEXT_MATCHES) - .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectAll()) - .buildAndInstall(tool); - - new ActionBuilder("Clear Selection", getName()) - .menuPath(ToolConstants.MENU_SELECTION, "&Clear Selection") - .menuGroup("Select Group", "b") - .supportsDefaultToolContext(true) - .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection")) - .withContext(CodeViewerActionContext.class) - .inWindow(ActionBuilder.When.CONTEXT_MATCHES) - .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()) - .setSelection(new ProgramSelection())) - .buildAndInstall(tool); - - new ActionBuilder("Select Complement", getName()) - .menuPath(ToolConstants.MENU_SELECTION, "&Complement") - .menuGroup("Select Group", "c") - .supportsDefaultToolContext(true) - .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select Complement")) - .withContext(CodeViewerActionContext.class) - .inWindow(ActionBuilder.When.CONTEXT_MATCHES) - .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectComplement()) - .buildAndInstall(tool); - - } - protected void viewChanged(AddressSetView addrSet) { ProgramLocation currLoc = getCurrentLocation(); currentView = addrSet; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java new file mode 100644 index 0000000000..93fffa3da2 --- /dev/null +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeBrowserSelectionPlugin.java @@ -0,0 +1,83 @@ +/* ### + * IP: GHIDRA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ghidra.app.plugin.core.codebrowser; + +import docking.action.builder.ActionBuilder; +import docking.tool.ToolConstants; +import ghidra.app.CorePluginPackage; +import ghidra.app.plugin.PluginCategoryNames; +import ghidra.app.util.HelpTopics; +import ghidra.framework.plugintool.*; +import ghidra.framework.plugintool.util.PluginStatus; +import ghidra.program.util.ProgramSelection; +import ghidra.util.HelpLocation; + +/** + * Plugin for adding some basic selection actions for Code Browser Listings. + */ + +//@formatter:off +@PluginInfo( + status = PluginStatus.RELEASED, + packageName = CorePluginPackage.NAME, + category = PluginCategoryNames.COMMON, + shortDescription = "Basic Selection actions", + description = "This plugin provides actions for Code Browser Listing components" +) +//@formatter:on +public class CodeBrowserSelectionPlugin extends Plugin { + + public CodeBrowserSelectionPlugin(PluginTool tool) { + super(tool); + createActions(); + } + + private void createActions() { + new ActionBuilder("Select All", getName()) + .menuPath(ToolConstants.MENU_SELECTION, "&All in View") + .menuGroup("Select Group", "a") + .keyBinding("ctrl A") + .supportsDefaultToolContext(true) + .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select All")) + .withContext(CodeViewerActionContext.class) + .inWindow(ActionBuilder.When.CONTEXT_MATCHES) + .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectAll()) + .buildAndInstall(tool); + + new ActionBuilder("Clear Selection", getName()) + .menuPath(ToolConstants.MENU_SELECTION, "&Clear Selection") + .menuGroup("Select Group", "b") + .supportsDefaultToolContext(true) + .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Clear Selection")) + .withContext(CodeViewerActionContext.class) + .inWindow(ActionBuilder.When.CONTEXT_MATCHES) + .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()) + .setSelection(new ProgramSelection())) + .buildAndInstall(tool); + + new ActionBuilder("Select Complement", getName()) + .menuPath(ToolConstants.MENU_SELECTION, "&Complement") + .menuGroup("Select Group", "c") + .supportsDefaultToolContext(true) + .helpLocation(new HelpLocation(HelpTopics.SELECTION, "Select Complement")) + .withContext(CodeViewerActionContext.class) + .inWindow(ActionBuilder.When.CONTEXT_MATCHES) + .onAction(c -> ((CodeViewerProvider) c.getComponentProvider()).selectComplement()) + .buildAndInstall(tool); + + } + +}