GT-3485 fixed issue where some global listing and navigation actions

were not enabled when providers other than the listing had focus.  This
was unintentionally broken with the original ticket
This commit is contained in:
ghidravore 2020-03-09 15:43:07 -04:00
parent 83e0ce4091
commit 641745c6e0
36 changed files with 541 additions and 552 deletions

View file

@ -118,12 +118,8 @@ public class WindowActionManager {
return;
}
ComponentProvider provider = placeHolderForScheduledActionUpdate == null ? null
: placeHolderForScheduledActionUpdate.getProvider();
ActionContext localContext = provider == null ? null : provider.getActionContext(null);
if (localContext == null) {
localContext = new ActionContext();
}
ActionContext localContext = getContext();
ActionContext globalContext = winMgr.getGlobalActionContext();
// Update actions - make a copy so that we don't get concurrent modification exceptions
List<DockingActionIf> list = new ArrayList<>(actionToProxyMap.values());
@ -131,6 +127,9 @@ public class WindowActionManager {
if (action.isValidContext(localContext)) {
action.setEnabled(action.isEnabledForContext(localContext));
}
else if (isValidGlobalContext(action, globalContext)) {
action.setEnabled(action.isEnabledForContext(globalContext));
}
else {
action.setEnabled(false);
}
@ -138,4 +137,21 @@ public class WindowActionManager {
// Notify listeners if the context provider is the focused provider
winMgr.notifyContextListeners(placeHolderForScheduledActionUpdate, localContext);
}
private boolean isValidGlobalContext(DockingActionIf action, ActionContext globalContext) {
return action.shouldFallbackToGlobalContext() &&
action.isValidContext(globalContext);
}
private ActionContext getContext() {
ComponentProvider provider = placeHolderForScheduledActionUpdate == null ? null
: placeHolderForScheduledActionUpdate.getProvider();
ActionContext context = provider == null ? null : provider.getActionContext(null);
if (context == null) {
context = new ActionContext();
}
return context;
}
}