mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GT-2960 - Docking Actions - review fixes
This commit is contained in:
parent
154fa39cc2
commit
d8c234d5d0
27 changed files with 200 additions and 169 deletions
|
@ -24,10 +24,11 @@ import java.util.*;
|
|||
import javax.swing.JPopupMenu;
|
||||
|
||||
import docking.action.*;
|
||||
import docking.actions.PopupActionProvider;
|
||||
import docking.menu.*;
|
||||
|
||||
public class PopupActionManager implements PropertyChangeListener {
|
||||
private List<DockingActionIf> popupActions = new ArrayList<DockingActionIf>();
|
||||
private List<DockingActionIf> popupActions = new ArrayList<>();
|
||||
private DockingWindowManager windowManager;
|
||||
private MenuGroupMap menuGroupMap;
|
||||
|
||||
|
@ -94,23 +95,11 @@ public class PopupActionManager implements PropertyChangeListener {
|
|||
popupMenu.show(c, e.getX(), e.getY());
|
||||
}
|
||||
|
||||
private void populatePopupMenuActions(ComponentPlaceholder info,
|
||||
ActionContext actionContext, MenuManager menuMgr) {
|
||||
private void populatePopupMenuActions(ComponentPlaceholder info, ActionContext actionContext,
|
||||
MenuManager menuMgr) {
|
||||
|
||||
// Include unregistered actions
|
||||
Object source = actionContext.getSourceObject();
|
||||
if (source instanceof DockingActionProviderIf) {
|
||||
DockingActionProviderIf actionProvider = (DockingActionProviderIf) source;
|
||||
List<DockingActionIf> dockingActions = actionProvider.getDockingActions();
|
||||
for (DockingActionIf action : dockingActions) {
|
||||
MenuData popupMenuData = action.getPopupMenuData();
|
||||
if (popupMenuData != null && action.isValidContext(actionContext) &&
|
||||
action.isAddToPopup(actionContext)) {
|
||||
action.setEnabled(action.isEnabledForContext(actionContext));
|
||||
menuMgr.addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Unregistered actions are those used by special-needs components, on-the-fly
|
||||
addUnregisteredActions(actionContext, menuMgr);
|
||||
|
||||
// Include temporary actions
|
||||
List<DockingActionIf> tempActions = windowManager.getTemporaryPopupActions(actionContext);
|
||||
|
@ -133,7 +122,7 @@ public class PopupActionManager implements PropertyChangeListener {
|
|||
MenuData popupMenuData = action.getPopupMenuData();
|
||||
if (popupMenuData != null && action.isValidContext(actionContext) &&
|
||||
action.isAddToPopup(actionContext)) {
|
||||
|
||||
|
||||
boolean isEnabled = action.isEnabledForContext(actionContext);
|
||||
action.setEnabled(isEnabled);
|
||||
menuMgr.addAction(action);
|
||||
|
@ -152,6 +141,42 @@ public class PopupActionManager implements PropertyChangeListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void addUnregisteredActions(ActionContext actionContext, MenuManager menuMgr) {
|
||||
|
||||
Object source = actionContext.getSourceObject();
|
||||
|
||||
// this interface is deprecated in favor of the next block
|
||||
if (source instanceof DockingActionProviderIf) {
|
||||
DockingActionProviderIf actionProvider = (DockingActionProviderIf) source;
|
||||
List<DockingActionIf> dockingActions = actionProvider.getDockingActions();
|
||||
for (DockingActionIf action : dockingActions) {
|
||||
MenuData popupMenuData = action.getPopupMenuData();
|
||||
if (popupMenuData != null && action.isValidContext(actionContext) &&
|
||||
action.isAddToPopup(actionContext)) {
|
||||
action.setEnabled(action.isEnabledForContext(actionContext));
|
||||
menuMgr.addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// note: this is temporary; there is only one client that needs this. This will be
|
||||
// removed in a future ticket when that client uses the standard tool action system
|
||||
if (source instanceof PopupActionProvider) {
|
||||
PopupActionProvider actionProvider = (PopupActionProvider) source;
|
||||
DockingTool tool = windowManager.getTool();
|
||||
List<DockingActionIf> dockingActions =
|
||||
actionProvider.getPopupActions(tool, actionContext);
|
||||
for (DockingActionIf action : dockingActions) {
|
||||
MenuData popupMenuData = action.getPopupMenuData();
|
||||
if (popupMenuData != null && action.isValidContext(actionContext) &&
|
||||
action.isAddToPopup(actionContext)) {
|
||||
action.setEnabled(action.isEnabledForContext(actionContext));
|
||||
menuMgr.addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRemovingFromPopup(MenuData oldData, MenuData newData) {
|
||||
return oldData != null && newData == null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue