mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-5777 - Fix for dialog action context
This commit is contained in:
parent
a7e64844fb
commit
6b7064b1f4
2 changed files with 33 additions and 10 deletions
|
@ -2580,7 +2580,12 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
*/
|
*/
|
||||||
void doContextChanged(ActionContext context) {
|
void notifyContextListeners(ActionContext context) {
|
||||||
|
|
||||||
|
if (context == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (DockingContextListener listener : contextListeners) {
|
for (DockingContextListener listener : contextListeners) {
|
||||||
listener.contextChanged(context);
|
listener.contextChanged(context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package docking;
|
package docking;
|
||||||
|
|
||||||
|
import java.awt.KeyboardFocusManager;
|
||||||
|
import java.awt.Window;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
|
@ -184,24 +186,40 @@ public class GlobalMenuAndToolBarManager implements DockingWindowListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowActionManager actionManager = windowToActionManagerMap.get(windowNode);
|
WindowActionManager actionManager = windowToActionManagerMap.get(windowNode);
|
||||||
ActionContext localContext = getContext(windowNode);
|
ActionContext localContext = getComponentProviderContext(windowNode);
|
||||||
actionManager.contextChanged(defaultContextMap, localContext, focusedWindowActions);
|
actionManager.contextChanged(defaultContextMap, localContext, focusedWindowActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now update the focused window's actions
|
// now update the focused window's actions
|
||||||
|
updateFocusedWindowActions(focusedWindowNode, defaultContextMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateFocusedWindowActions(WindowNode focusedWindowNode,
|
||||||
|
Map<Class<? extends ActionContext>, ActionContext> defaultContextMap) {
|
||||||
|
|
||||||
|
ActionContext focusedContext = getFocusedWindowContext(focusedWindowNode);
|
||||||
WindowActionManager actionManager = windowToActionManagerMap.get(focusedWindowNode);
|
WindowActionManager actionManager = windowToActionManagerMap.get(focusedWindowNode);
|
||||||
ActionContext focusedContext = getContext(focusedWindowNode);
|
|
||||||
if (actionManager != null) {
|
if (actionManager != null) {
|
||||||
actionManager.contextChanged(defaultContextMap, focusedContext, Collections.emptySet());
|
actionManager.contextChanged(defaultContextMap, focusedContext, Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the docking window manager ; no focused context when no window is focused
|
// this is for non-action listeners that wish to do work when the context changes
|
||||||
if (focusedContext != null) {
|
windowManager.notifyContextListeners(focusedContext);
|
||||||
windowManager.doContextChanged(focusedContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionContext getContext(WindowNode windowNode) {
|
private ActionContext getFocusedWindowContext(WindowNode focusedWindowNode) {
|
||||||
|
|
||||||
|
KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||||
|
Window w = kfm.getFocusedWindow();
|
||||||
|
if (w instanceof DockingDialog dialog) {
|
||||||
|
DialogComponentProvider provider = dialog.getDialogComponent();
|
||||||
|
return provider.getActionContext(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getComponentProviderContext(focusedWindowNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionContext getComponentProviderContext(WindowNode windowNode) {
|
||||||
if (windowNode == null) {
|
if (windowNode == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue