mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-5175 - Turned a local action into a global action (the action that
closes the window when only one provider remains)
This commit is contained in:
parent
293f5bdb0a
commit
64cdd130b3
3 changed files with 50 additions and 46 deletions
|
@ -75,15 +75,12 @@ class DockableToolBarManager {
|
|||
ToolBarCloseAction closeAction = new ToolBarCloseAction(owner);
|
||||
closeButtonManager = new ToolBarItemManager(closeAction, winMgr);
|
||||
|
||||
CloseLastProviderAction closeLastProviderAction = new CloseLastProviderAction(owner);
|
||||
|
||||
ToolBarMenuAction dropDownAction = new ToolBarMenuAction(owner);
|
||||
menuButtonManager = new ToolBarItemManager(dropDownAction, winMgr);
|
||||
|
||||
// we need to add this action to the tool in order to use key bindings
|
||||
Tool tool = winMgr.getTool();
|
||||
tool.addLocalAction(provider, closeAction);
|
||||
tool.addLocalAction(provider, closeLastProviderAction);
|
||||
tool.addLocalAction(provider, dropDownAction);
|
||||
}
|
||||
|
||||
|
@ -219,45 +216,6 @@ class DockableToolBarManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An action to close the provider on Escape if the provider is the last in the window. This
|
||||
* allows users to close transient providers (like search results) easily.
|
||||
*/
|
||||
private class CloseLastProviderAction extends DockingAction {
|
||||
|
||||
CloseLastProviderAction(String owner) {
|
||||
super("Close Window for Last Provider", owner, KeyBindingType.SHARED);
|
||||
setKeyBindingData(new KeyBindingData("ESCAPE"));
|
||||
setDescription("Close the window if this provider is the last provider in the window");
|
||||
markHelpUnnecessary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionContext context) {
|
||||
ComponentPlaceholder placeholder = dockableComponent.getComponentWindowingPlaceholder();
|
||||
if (placeholder != null) {
|
||||
placeholder.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledForContext(ActionContext context) {
|
||||
DockingWindowManager dwm = DockingWindowManager.getActiveInstance();
|
||||
if (dwm == null) {
|
||||
return false; // this can happen sometimes in test environments
|
||||
}
|
||||
ComponentProvider provider = context.getComponentProvider();
|
||||
if (provider == null) {
|
||||
// Some context providers do not specify the provider when creating a contexts
|
||||
provider = dwm.getActiveComponentProvider();
|
||||
}
|
||||
if (provider != dockableComponent.getComponentProvider()) {
|
||||
return false; // not my provider
|
||||
}
|
||||
return dwm.isLastProviderInDetachedWindow(provider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions added to toolbar for displaying the drop-down menu.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue