mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-3349 added support for mulitple default action context providers. Previously, all default (non-focused) context was provided by the Listing. Now the default provider is registered for each ActionContext class.
This commit is contained in:
parent
8aa9c8be3a
commit
5da5af23fb
149 changed files with 1354 additions and 1232 deletions
|
@ -606,7 +606,7 @@ public class FrontEndPlugin extends Plugin
|
|||
if (e != null) {
|
||||
Component source = (Component) e.getSource();
|
||||
if (source instanceof ToolButton) {
|
||||
return new ActionContext(provider, source);
|
||||
return new DefaultActionContext(provider, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -704,8 +704,8 @@ public class FrontEndPlugin extends Plugin
|
|||
connectionButton.setContentAreaFilled(false);
|
||||
connectionButton.setSelected(isConnected);
|
||||
connectionButton
|
||||
.setBorder(isConnected ? BorderFactory.createBevelBorder(BevelBorder.LOWERED)
|
||||
: BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
.setBorder(isConnected ? BorderFactory.createBevelBorder(BevelBorder.LOWERED)
|
||||
: BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
connectionIconPanel.add(connectionButton);
|
||||
if (isConnected) {
|
||||
|
||||
|
@ -717,7 +717,7 @@ public class FrontEndPlugin extends Plugin
|
|||
}
|
||||
}
|
||||
repositoryLabel
|
||||
.setText("Project Repository: " + repository.getName() + getAccessString(user));
|
||||
.setText("Project Repository: " + repository.getName() + getAccessString(user));
|
||||
|
||||
String serverName = repository.getServerInfo().getServerName();
|
||||
connectionButton.setToolTipText(
|
||||
|
@ -989,7 +989,7 @@ public class FrontEndPlugin extends Plugin
|
|||
};
|
||||
renameToolAction.setPopupMenuData(new MenuData(new String[] { "Rename..." }, "tool"));
|
||||
renameToolAction
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Rename Tool"));
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Rename Tool"));
|
||||
|
||||
propertiesAction = new ToolButtonAction(PROPERTIES_ACTION_NAME) {
|
||||
@Override
|
||||
|
@ -1013,7 +1013,7 @@ public class FrontEndPlugin extends Plugin
|
|||
new MenuData(new String[] { "Configure Plugins..." }, "zproperties"));
|
||||
|
||||
propertiesAction
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Configure_Tool"));
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Configure_Tool"));
|
||||
|
||||
tool.addLocalAction(frontEndProvider, exportToolAction);
|
||||
tool.addLocalAction(frontEndProvider, renameToolAction);
|
||||
|
|
|
@ -24,8 +24,7 @@ import java.util.Map;
|
|||
|
||||
import javax.swing.*;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.ComponentProvider;
|
||||
import docking.*;
|
||||
import docking.widgets.tabbedpane.DockingTabRenderer;
|
||||
import ghidra.framework.client.NotConnectedException;
|
||||
import ghidra.framework.main.datatable.ProjectDataTablePanel;
|
||||
|
@ -368,7 +367,7 @@ class ProjectDataPanel extends JSplitPane implements ProjectViewListener {
|
|||
|
||||
while (comp != null) {
|
||||
if (comp instanceof JTabbedPane) {
|
||||
return new ActionContext(provider, comp);
|
||||
return new DefaultActionContext(provider, comp);
|
||||
}
|
||||
if (comp instanceof ProjectDataTreePanel) {
|
||||
ProjectDataTreePanel panel = (ProjectDataTreePanel) comp;
|
||||
|
|
|
@ -19,15 +19,15 @@ import java.awt.Component;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.ComponentProvider;
|
||||
import docking.DefaultActionContext;
|
||||
import ghidra.framework.model.*;
|
||||
|
||||
/**
|
||||
* A context that understands files that live in a {@link Project}. Most of the clients of
|
||||
* this context will use its notion of selected {@link DomainFile}s and folders.
|
||||
*/
|
||||
public class ProjectDataContext extends ActionContext implements DomainFileContext {
|
||||
public class ProjectDataContext extends DefaultActionContext implements DomainFileContext {
|
||||
|
||||
private List<DomainFolder> selectedFolders;
|
||||
private List<DomainFile> selectedFiles;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DefaultActionContext;
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import ghidra.framework.main.datatable.ProjectTreeContext;
|
||||
import ghidra.framework.model.*;
|
||||
|
@ -28,7 +28,7 @@ import ghidra.framework.model.*;
|
|||
/**
|
||||
* Context specific to the DataTreeDialog.
|
||||
*/
|
||||
public class DialogProjectTreeContext extends ActionContext implements ProjectTreeContext {
|
||||
public class DialogProjectTreeContext extends DefaultActionContext implements ProjectTreeContext {
|
||||
|
||||
private TreePath[] selectionPaths;
|
||||
private DataTree tree;
|
||||
|
|
|
@ -20,8 +20,7 @@ import java.io.FileNotFoundException;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DialogComponentProvider;
|
||||
import docking.*;
|
||||
import docking.action.DockingActionIf;
|
||||
import ghidra.app.util.GenericHelpTopics;
|
||||
import ghidra.framework.main.AppInfo;
|
||||
|
@ -145,7 +144,7 @@ public class VersionHistoryDialog extends DialogComponentProvider implements Pro
|
|||
|
||||
@Override
|
||||
public ActionContext getActionContext(MouseEvent event) {
|
||||
ActionContext actionContext = new ActionContext(null, this, versionPanel.getTable());
|
||||
ActionContext actionContext = new DefaultActionContext(null, this, versionPanel.getTable());
|
||||
actionContext.setMouseEvent(event);
|
||||
return actionContext;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
*/
|
||||
package ghidra.framework.main.projectdata.actions;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.DefaultActionContext;
|
||||
|
||||
public class CheckoutsActionContext extends ActionContext {
|
||||
public class CheckoutsActionContext extends DefaultActionContext {
|
||||
|
||||
private int[] selectedRows;
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* 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.
|
||||
|
@ -413,6 +413,31 @@ public abstract class PluginTool extends AbstractDockingTool {
|
|||
winMgr.setDefaultComponent(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an action context provider as the default provider for a specific action
|
||||
* context type. Note that this registers a default provider for exactly
|
||||
* that type and not a subclass of that type. If the provider want to support a hierarchy of
|
||||
* types, then it must register separately for each type. See {@link ActionContext} for details
|
||||
* on how the action context system works.
|
||||
* @param type the ActionContext class to register a default provider for
|
||||
* @param provider the ActionContextProvider that provides default tool context for actions
|
||||
* that consume the given ActionContext type
|
||||
*/
|
||||
public void registerDefaultContextProvider(Class<? extends ActionContext> type,
|
||||
ActionContextProvider provider) {
|
||||
winMgr.registerDefaultContextProvider(type, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the default provider for the given ActionContext type.
|
||||
* @param type the subclass of ActionContext to remove a provider for
|
||||
* @param provider the ActionContextProvider to remove for the given ActionContext type
|
||||
*/
|
||||
public void unregisterDefaultContextProvider(Class<? extends ActionContext> type,
|
||||
ActionContextProvider provider) {
|
||||
winMgr.unregisterDefaultContextProvider(type, provider);
|
||||
}
|
||||
|
||||
public ToolTemplate getToolTemplate(boolean includeConfigState) {
|
||||
throw new UnsupportedOperationException(
|
||||
"You cannot create templates for generic tools: " + getClass().getName());
|
||||
|
@ -1027,7 +1052,7 @@ public abstract class PluginTool extends AbstractDockingTool {
|
|||
|
||||
saveAsAction.setEnabled(true);
|
||||
saveAsAction
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Tool_Changes"));
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Tool_Changes"));
|
||||
|
||||
addAction(saveAction);
|
||||
addAction(saveAsAction);
|
||||
|
@ -1053,7 +1078,7 @@ public abstract class PluginTool extends AbstractDockingTool {
|
|||
menuData.setMenuSubGroup(Integer.toString(subGroup++));
|
||||
exportToolAction.setMenuBarData(menuData);
|
||||
exportToolAction
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Export_Tool"));
|
||||
.setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Export_Tool"));
|
||||
addAction(exportToolAction);
|
||||
|
||||
DockingAction exportDefautToolAction =
|
||||
|
@ -1076,42 +1101,42 @@ public abstract class PluginTool extends AbstractDockingTool {
|
|||
|
||||
protected void addHelpActions() {
|
||||
new ActionBuilder("About Ghidra", ToolConstants.TOOL_OWNER)
|
||||
.menuPath(ToolConstants.MENU_HELP, "&About Ghidra")
|
||||
.menuGroup("ZZA")
|
||||
.helpLocation(new HelpLocation(ToolConstants.ABOUT_HELP_TOPIC, "About_Ghidra"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(c -> DockingWindowManager.showDialog(new AboutDialog()))
|
||||
.buildAndInstall(this);
|
||||
.menuPath(ToolConstants.MENU_HELP, "&About Ghidra")
|
||||
.menuGroup("ZZA")
|
||||
.helpLocation(new HelpLocation(ToolConstants.ABOUT_HELP_TOPIC, "About_Ghidra"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(c -> DockingWindowManager.showDialog(new AboutDialog()))
|
||||
.buildAndInstall(this);
|
||||
|
||||
new ActionBuilder("User Agreement", ToolConstants.TOOL_OWNER)
|
||||
.menuPath(ToolConstants.MENU_HELP, "&User Agreement")
|
||||
.menuGroup(ToolConstants.HELP_CONTENTS_MENU_GROUP)
|
||||
.helpLocation(new HelpLocation(ToolConstants.ABOUT_HELP_TOPIC, "User_Agreement"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(
|
||||
c -> DockingWindowManager.showDialog(new UserAgreementDialog(false, false)))
|
||||
.buildAndInstall(this);
|
||||
.menuPath(ToolConstants.MENU_HELP, "&User Agreement")
|
||||
.menuGroup(ToolConstants.HELP_CONTENTS_MENU_GROUP)
|
||||
.helpLocation(new HelpLocation(ToolConstants.ABOUT_HELP_TOPIC, "User_Agreement"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(
|
||||
c -> DockingWindowManager.showDialog(new UserAgreementDialog(false, false)))
|
||||
.buildAndInstall(this);
|
||||
|
||||
final ErrorReporter reporter = ErrLogDialog.getErrorReporter();
|
||||
if (reporter != null) {
|
||||
new ActionBuilder("Report Bug", ToolConstants.TOOL_OWNER)
|
||||
.menuPath(ToolConstants.MENU_HELP, "&Report Bug...")
|
||||
.menuGroup("BBB")
|
||||
.helpLocation(new HelpLocation("ErrorReporting", "Report_Bug"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(c -> reporter.report(getToolFrame(), "User Bug Report", null))
|
||||
.buildAndInstall(this);
|
||||
.menuPath(ToolConstants.MENU_HELP, "&Report Bug...")
|
||||
.menuGroup("BBB")
|
||||
.helpLocation(new HelpLocation("ErrorReporting", "Report_Bug"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(c -> reporter.report(getToolFrame(), "User Bug Report", null))
|
||||
.buildAndInstall(this);
|
||||
}
|
||||
|
||||
HelpService help = Help.getHelpService();
|
||||
|
||||
new ActionBuilder("Contents", ToolConstants.TOOL_OWNER)
|
||||
.menuPath(ToolConstants.MENU_HELP, "&Contents")
|
||||
.menuGroup(ToolConstants.HELP_CONTENTS_MENU_GROUP)
|
||||
.helpLocation(new HelpLocation("Misc", "Welcome_to_Ghidra_Help"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(c -> help.showHelp(null, false, getToolFrame()))
|
||||
.buildAndInstall(this);
|
||||
.menuPath(ToolConstants.MENU_HELP, "&Contents")
|
||||
.menuGroup(ToolConstants.HELP_CONTENTS_MENU_GROUP)
|
||||
.helpLocation(new HelpLocation("Misc", "Welcome_to_Ghidra_Help"))
|
||||
.inWindow(ActionBuilder.When.ALWAYS)
|
||||
.onAction(c -> help.showHelp(null, false, getToolFrame()))
|
||||
.buildAndInstall(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1490,11 +1515,6 @@ public abstract class PluginTool extends AbstractDockingTool {
|
|||
winMgr.removePreferenceState(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionContext getDefaultToolContext() {
|
||||
return winMgr.getDefaultToolContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextChanged(ComponentProvider provider) {
|
||||
if (isDisposed) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue