Merge branch 'master' of

https://github.com/NationalSecurityAgency/ghidra into spell
This commit is contained in:
Benjamin Levy 2020-01-27 16:15:47 -05:00 committed by dragonmacher
commit 74fae2f644
142 changed files with 1242 additions and 1568 deletions

View file

@ -377,7 +377,6 @@ src/main/help/help/topics/FunctionComparison/images/ListingCodeComparisonOptions
src/main/help/help/topics/FunctionComparison/images/MultiFunctionComparisonWindow.png||GHIDRA||||END|
src/main/help/help/topics/FunctionComparison/images/NavNextIcon.png||GHIDRA||||END|
src/main/help/help/topics/FunctionComparison/images/NavPreviousIcon.png||GHIDRA||||END|
src/main/help/help/topics/FunctionComparison/images/NavSelectedIcon.png||GHIDRA||||END|
src/main/help/help/topics/FunctionComparison/images/RemoveFromComparisonIcon.png||GHIDRA||||END|
src/main/help/help/topics/FunctionComparison/images/binaryData.gif||GHIDRA||||END|
src/main/help/help/topics/FunctionComparison/images/class.png||GHIDRA||||END|
@ -725,7 +724,7 @@ src/main/help/help/topics/ShowInstructionInfoPlugin/images/ProcessorManualOption
src/main/help/help/topics/ShowInstructionInfoPlugin/images/RawInstructionDisplay.png||GHIDRA||||END|
src/main/help/help/topics/ShowInstructionInfoPlugin/images/ShowInstructionInfo.png||GHIDRA||||END|
src/main/help/help/topics/ShowInstructionInfoPlugin/images/UnableToLaunch.png||GHIDRA||||END|
src/main/help/help/topics/Snapshots/Snapshots.html||GHIDRA||reviewed||END|
src/main/help/help/topics/Snapshots/Snapshots.html||GHIDRA||||END|
src/main/help/help/topics/Snapshots/images/camera-photo.png||Tango Icons - Public Domain|||tango|END|
src/main/help/help/topics/StackEditor/StackEditor.html||GHIDRA||||END|
src/main/help/help/topics/StackEditor/images/Array.png||GHIDRA||||END|

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -17,9 +17,11 @@ package ghidra.app.context;
import java.util.Set;
import docking.ActionContext;
import docking.*;
import docking.action.DockingAction;
import docking.action.KeyBindingType;
import ghidra.app.nav.Navigatable;
import ghidra.app.services.GoToService;
public abstract class NavigatableContextAction extends DockingAction {
@ -33,23 +35,61 @@ public abstract class NavigatableContextAction extends DockingAction {
@Override
public boolean isEnabledForContext(ActionContext context) {
if (!(context instanceof NavigatableActionContext)) {
NavigatableActionContext appropriateContext = getAppropriateContext(context);
if (appropriateContext == null) {
return false;
}
return isEnabledForContext((NavigatableActionContext) context);
return isEnabledForContext(appropriateContext);
}
@Override
public void actionPerformed(ActionContext context) {
actionPerformed((NavigatableActionContext) context);
actionPerformed(getAppropriateContext(context));
}
private NavigatableActionContext getAppropriateContext(ActionContext context) {
if (context instanceof NavigatableActionContext &&
isValidNavigationContext((NavigatableActionContext) context)) {
return (NavigatableActionContext) context;
}
return getGlobalNavigationContext(context);
}
@Override
public boolean isValidContext(ActionContext context) {
if (!(context instanceof NavigatableActionContext)) {
return false;
public final boolean isValidContext(ActionContext context) {
return true;
}
protected boolean isValidNavigationContext(NavigatableActionContext context) {
return true;
}
private NavigatableActionContext getGlobalNavigationContext(ActionContext context) {
Tool tool = getTool(context.getComponentProvider());
if (tool == null) {
return null;
}
return isValidContext((NavigatableActionContext) context);
GoToService service = tool.getService(GoToService.class);
if (service == null) {
return null;
}
Navigatable defaultNavigatable = service.getDefaultNavigatable();
if (defaultNavigatable.getProgram() == null) {
return null;
}
return new NavigatableActionContext(null, defaultNavigatable);
}
private Tool getTool(ComponentProvider provider) {
if (provider != null) {
return provider.getTool();
}
DockingWindowManager manager = DockingWindowManager.getActiveInstance();
if (manager != null) {
return manager.getTool();
}
return null;
}
@Override
@ -60,10 +100,6 @@ public abstract class NavigatableContextAction extends DockingAction {
return isAddToPopup((NavigatableActionContext) context);
}
protected boolean isValidContext(NavigatableActionContext context) {
return true;
}
protected boolean isEnabledForContext(NavigatableActionContext context) {
return true;
}

View file

@ -55,7 +55,7 @@ public class ListingMergePanelProvider extends ComponentProviderAdapter
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool dt, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool dt, ActionContext context) {
ListingPanel resultPanel = mergePanel.getResultPanel();
if (resultPanel != null) {
return resultPanel.getHeaderActions(getName());

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,16 +15,16 @@
*/
package ghidra.app.nav;
import ghidra.framework.model.Tool;
import java.util.*;
import ghidra.framework.plugintool.PluginTool;
public class NavigatableRegistry {
private static Map<Long, Navigatable> navigatableMap = new HashMap<Long, Navigatable>();
private static Map<Tool, List<Navigatable>> toolMap = new HashMap<Tool, List<Navigatable>>();
private static Map<PluginTool, List<Navigatable>> toolMap =
new HashMap<PluginTool, List<Navigatable>>();
public static void registerNavigatable(Tool tool, Navigatable navigatable) {
public static void registerNavigatable(PluginTool tool, Navigatable navigatable) {
navigatableMap.put(navigatable.getInstanceID(), navigatable);
List<Navigatable> list = toolMap.get(tool);
if (list == null) {
@ -35,7 +34,7 @@ public class NavigatableRegistry {
list.add(navigatable);
}
public static void unregisterNavigatable(Tool tool, Navigatable navigatable) {
public static void unregisterNavigatable(PluginTool tool, Navigatable navigatable) {
navigatableMap.remove(navigatable.getInstanceID());
List<Navigatable> list = toolMap.get(tool);
if (list == null) {
@ -46,13 +45,15 @@ public class NavigatableRegistry {
toolMap.remove(tool);
}
}
public static List<Navigatable> getRegisteredNavigatables(Tool tool) {
public static List<Navigatable> getRegisteredNavigatables(PluginTool tool) {
List<Navigatable> list = toolMap.get(tool);
if (list == null) {
list = new ArrayList<Navigatable>(navigatableMap.values());
}
return list;
}
public static Navigatable getNavigatable(long navigationID) {
return navigatableMap.get(navigationID);
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,8 @@
*/
package ghidra.app.nav;
import java.util.Set;
import ghidra.app.context.*;
import ghidra.app.plugin.core.navigation.NavigationOptions;
import ghidra.app.services.GoToService;
@ -24,8 +25,6 @@ import ghidra.program.model.address.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.util.ProgramSelection;
import java.util.Set;
public abstract class NextRangeAction extends NavigatableContextAction {
private PluginTool tool;
@ -39,7 +38,7 @@ public abstract class NextRangeAction extends NavigatableContextAction {
}
@Override
protected boolean isValidContext(NavigatableActionContext context) {
protected boolean isValidNavigationContext(NavigatableActionContext context) {
//
// We want the nav actions to work in the current view that supports this, which right
// now is the ListingActionContext. If the current context does not support that, then
@ -51,13 +50,12 @@ public abstract class NextRangeAction extends NavigatableContextAction {
@Override
public boolean isEnabledForContext(NavigatableActionContext context) {
Address currentAddress = context.getAddress();
ListingActionContext listingContext = (ListingActionContext) context;
ProgramSelection selection = getSelection(listingContext);
ProgramSelection selection = getSelection(context);
if (selection == null || selection.isEmpty() || currentAddress == null) {
return false;
}
CodeUnit cu = listingContext.getProgram().getListing().getCodeUnitAt(currentAddress);
CodeUnit cu = context.getProgram().getListing().getCodeUnitAt(currentAddress);
if (cu != null) {
currentAddress = cu.getMaxAddress();
}
@ -71,13 +69,10 @@ public abstract class NextRangeAction extends NavigatableContextAction {
@Override
public void actionPerformed(NavigatableActionContext context) {
// Note: we verified above that the context we are grabbing here is the correct type
ListingActionContext listingContext = (ListingActionContext) context;
Address goToAddress = getGoToAddress(listingContext);
Address goToAddress = getGoToAddress(context);
GoToService service = tool.getService(GoToService.class);
if (service != null) {
service.goTo(listingContext.getNavigatable(), goToAddress);
service.goTo(context.getNavigatable(), goToAddress);
}
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +15,8 @@
*/
package ghidra.app.nav;
import java.util.Set;
import ghidra.app.context.*;
import ghidra.app.plugin.core.navigation.NavigationOptions;
import ghidra.app.services.GoToService;
@ -23,8 +24,6 @@ import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.*;
import ghidra.program.util.ProgramSelection;
import java.util.Set;
public abstract class PreviousRangeAction extends NavigatableContextAction {
private PluginTool tool;
@ -39,7 +38,7 @@ public abstract class PreviousRangeAction extends NavigatableContextAction {
}
@Override
protected boolean isValidContext(NavigatableActionContext context) {
protected boolean isValidNavigationContext(NavigatableActionContext context) {
//
// We want the nav actions to work in the current view that supports this, which right
// now is the ListingActionContext. If the current context does not support that, then
@ -58,9 +57,8 @@ public abstract class PreviousRangeAction extends NavigatableContextAction {
}
private Address getGoToAddress(NavigatableActionContext context) {
ListingActionContext listingContext = (ListingActionContext) context;
ProgramSelection selection = getSelection(listingContext);
Address currentAddress = listingContext.getAddress();
ProgramSelection selection = getSelection(context);
Address currentAddress = context.getAddress();
AddressRangeIterator it = selection.getAddressRanges(currentAddress, false);
if (!it.hasNext()) {
@ -94,8 +92,7 @@ public abstract class PreviousRangeAction extends NavigatableContextAction {
@Override
public boolean isEnabledForContext(NavigatableActionContext context) {
Address currentAddress = context.getAddress();
ListingActionContext listingContext = (ListingActionContext) context;
ProgramSelection selection = getSelection(listingContext);
ProgramSelection selection = getSelection(context);
if (selection == null || selection.isEmpty() || currentAddress == null) {
return false;
}

View file

@ -22,7 +22,7 @@ import javax.swing.Icon;
import javax.swing.SwingUtilities;
import docking.ActionContext;
import docking.DockingTool;
import docking.Tool;
import docking.action.*;
import docking.actions.PopupActionProvider;
import docking.widgets.table.GTable;
@ -362,10 +362,6 @@ public class BookmarkPlugin extends ProgramPlugin
getBookmarkNavigator(bookmarkMgr.getBookmarkType(type));
}
/**
* Bookmark has been changed.
* @param bookmark
*/
private void bookmarkChanged(Bookmark bookmark) {
if (bookmark == null) {
scheduleUpdate(null);
@ -378,10 +374,6 @@ public class BookmarkPlugin extends ProgramPlugin
provider.bookmarkChanged(bookmark);
}
/**
* Bookmark has been added.
* @param bookmark
*/
private void bookmarkAdded(Bookmark bookmark) {
if (bookmark == null) {
scheduleUpdate(null);
@ -496,7 +488,7 @@ public class BookmarkPlugin extends ProgramPlugin
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool activeTool, ActionContext context) {
Object contextObject = context.getContextObject();
if (!(contextObject instanceof MarkerLocation)) {
return null;

View file

@ -26,7 +26,7 @@ import ghidra.app.context.ListingContextAction;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.framework.cmd.Command;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.*;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSet;
import ghidra.program.model.data.*;
@ -264,12 +264,6 @@ public class ClearPlugin extends Plugin {
}
return false;
}
@Override
public boolean isValidGlobalContext(ActionContext context) {
// it's too dangerous to let the clear action work globally
return false;
}
};
int menuOrdinal = 1;

View file

@ -952,7 +952,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool dt, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool dt, ActionContext context) {
if (context.getComponentProvider() == this) {
return listingPanel.getHeaderActions(getName());
}

View file

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.comments;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.*;
import ghidra.app.CorePluginPackage;
import ghidra.app.cmd.comments.SetCommentCmd;
@ -187,11 +186,6 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
getPopupMenuData().setMenuPath(new String[] { "Comments", "Delete" });
return false;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
};
deleteAction.setPopupMenuData(new MenuData(DELETE_MENUPATH, null, "comments"));
deleteAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));

View file

@ -27,7 +27,7 @@ import javax.swing.SwingUtilities;
import javax.swing.tree.TreePath;
import docking.ActionContext;
import docking.DockingTool;
import docking.Tool;
import docking.action.*;
import docking.actions.PopupActionProvider;
import docking.widgets.tree.GTreeNode;
@ -678,7 +678,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool dockingTool, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool dockingTool, ActionContext context) {
if (!(context instanceof DataTypesActionContext)) {
return null;
}

View file

@ -22,8 +22,8 @@ import javax.swing.ComboBoxModel;
import javax.swing.JPanel;
import docking.ComponentProvider;
import docking.actions.DockingToolActions;
import docking.actions.SharedDockingActionPlaceholder;
import docking.actions.ToolActions;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.label.GLabel;
@ -163,7 +163,7 @@ public class DataTypeEditorManager
}
private void registerAction(String name) {
ToolActions toolActions = plugin.getTool().getToolActions();
DockingToolActions toolActions = plugin.getTool().getToolActions();
toolActions.registerSharedActionPlaceholder(new DtSharedActionPlaceholder(name));
}

View file

@ -19,7 +19,6 @@ import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import docking.ActionContext;
import docking.action.*;
import docking.widgets.OptionDialog;
import ghidra.app.CorePluginPackage;
@ -374,8 +373,8 @@ public class EquatePlugin extends Plugin {
Program program = context.getProgram();
List<Integer> opIndices = getInstructionMatches(program, inst, equate);
Address addr = inst.getAddress();
for (int i = 0; i < opIndices.size(); i++) {
bgCmd.add(createRenameCmd(oldName, newName, addr, opIndices.get(i)));
for (Integer opIndice : opIndices) {
bgCmd.add(createRenameCmd(oldName, newName, addr, opIndice));
}
}
else if (cu instanceof Data) {
@ -429,9 +428,9 @@ public class EquatePlugin extends Plugin {
Program program = context.getProgram();
List<Integer> opIndexes = getInstructionMatches(program, instr, equate);
for (int i = 0; i < opIndexes.size(); i++) {
for (Integer opIndexe : opIndexes) {
bckCmd.add(
new ClearEquateCmd(equate.getName(), instr.getAddress(), opIndexes.get(i)));
new ClearEquateCmd(equate.getName(), instr.getAddress(), opIndexe));
}
}
else if (cu instanceof Data) {
@ -728,12 +727,6 @@ public class EquatePlugin extends Plugin {
protected boolean isEnabledForContext(ListingActionContext context) {
return getEquate(context) != null;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
};
removeAction.setPopupMenuData(new MenuData(REMOVE_MENUPATH, null, GROUP_NAME));
removeAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));

View file

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.cmd.function.DeleteFunctionCmd;
@ -71,9 +70,4 @@ class DeleteFunctionAction extends ListingContextAction {
return false;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
}

View file

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.cmd.function.CallDepthChangeInfo;
@ -73,9 +72,4 @@ class RemoveStackDepthChangeAction extends ListingContextAction {
context.getAddress()) != null;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
}

View file

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.KeyBindingType;
import ghidra.app.cmd.function.SetVariableCommentCmd;
@ -89,8 +88,4 @@ class VariableCommentDeleteAction extends ListingContextAction {
return (loc instanceof VariableCommentFieldLocation);
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
}

View file

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.function;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.cmd.function.DeleteVariableCmd;
@ -105,9 +104,4 @@ class VariableDeleteAction extends ListingContextAction {
}
return null;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
}

View file

@ -19,7 +19,7 @@ import java.awt.event.MouseEvent;
import java.util.*;
import docking.ActionContext;
import docking.DockingTool;
import docking.Tool;
import docking.action.DockingAction;
import docking.action.DockingActionIf;
import docking.actions.PopupActionProvider;
@ -130,7 +130,7 @@ public class FunctionComparisonProvider extends ComponentProviderAdapter
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context) {
if (context.getComponentProvider() == this) {
ListingCodeComparisonPanel dualListingPanel =
functionComparisonPanel.getDualListingPanel();

View file

@ -60,7 +60,7 @@ public final class GoToServicePlugin extends ProgramPlugin {
* Creates a new instance of the <CODE>GoToServicePlugin</CODE>
*/
public GoToServicePlugin(PluginTool plugintool) {
super(plugintool, true, false);
super(plugintool, true, true);
gotoService = new GoToServiceImpl(this, new DefaultNavigatable());

View file

@ -245,7 +245,7 @@ public class InstructionSearchPlugin extends ProgramPlugin {
}
@Override
protected boolean isValidContext(NavigatableActionContext context) {
protected boolean isValidNavigationContext(NavigatableActionContext context) {
return !(context instanceof RestrictedAddressSetContext);
}
};

View file

@ -19,7 +19,6 @@ import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
@ -66,11 +65,6 @@ class RemoveLabelAction extends ListingContextAction {
return !plugin.isOnExternalReference(context) && isOnSymbol(context);
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
boolean isOnSymbol(ListingActionContext context) {
Symbol s = plugin.getSymbol(context);
return ((s instanceof CodeSymbol) && !s.isDynamic()) ||

View file

@ -316,16 +316,6 @@ public class NextPrevAddressPlugin extends Plugin {
setDescription(isNext ? "Go to next location" : "Go to previous location");
}
@Override
public boolean isValidContext(ActionContext context) {
return false;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return (globalContext instanceof NavigatableActionContext);
}
@Override
public boolean isEnabledForContext(ActionContext context) {
Navigatable navigatable = getNavigatable(context);
@ -426,16 +416,6 @@ public class NextPrevAddressPlugin extends Plugin {
setMenuBarData(menuData);
}
@Override
public boolean isValidContext(ActionContext context) {
return false;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return (globalContext instanceof NavigatableActionContext);
}
@Override
public boolean isEnabledForContext(ActionContext context) {
Navigatable navigatable = getNavigatable(context);

View file

@ -326,7 +326,7 @@ public final class LanguageProviderPlugin extends Plugin implements FrontEndable
SwingUtilities.invokeAndWait(() -> {
ToolServices toolServices = tool.getToolServices();
String defaultToolName = toolServices.getDefaultToolTemplate(file).getName();
for (Tool t : toolServices.getRunningTools()) {
for (PluginTool t : toolServices.getRunningTools()) {
if (t.getName().equals(defaultToolName)) {
openTool = (PluginTool) t;
break;

View file

@ -17,7 +17,6 @@ package ghidra.app.plugin.core.references;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.cmd.refs.RemoveAllReferencesCmd;
@ -116,10 +115,4 @@ public class DeleteReferencesAction extends ListingContextAction {
}
return actionOK;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
}

View file

@ -167,11 +167,6 @@ public class RegisterPlugin extends ProgramPlugin {
}
return false;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
return false; // only work on active provider context.
}
};
deleteRegisterRangeAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));

View file

@ -145,7 +145,7 @@ public class ScalarSearchPlugin extends ProgramPlugin implements DomainObjectLis
}
@Override
protected boolean isValidContext(NavigatableActionContext context) {
protected boolean isValidNavigationContext(NavigatableActionContext context) {
return !(context instanceof RestrictedAddressSetContext);
}
};

View file

@ -350,7 +350,7 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
}
@Override
protected boolean isValidContext(NavigatableActionContext context) {
protected boolean isValidNavigationContext(NavigatableActionContext context) {
return !(context instanceof RestrictedAddressSetContext);
}
};
@ -374,7 +374,7 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,
}
@Override
protected boolean isValidContext(NavigatableActionContext context) {
protected boolean isValidNavigationContext(NavigatableActionContext context) {
return !(context instanceof RestrictedAddressSetContext);
}
};

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -95,6 +95,7 @@ public class BinaryLoader extends AbstractProgramLoader {
long length = 0;
long fileOffset = 0;
long origFileLength;
boolean isOverlay = false;
try {
origFileLength = provider.length();
}
@ -174,6 +175,7 @@ public class BinaryLoader extends AbstractProgramLoader {
if (!Boolean.class.isAssignableFrom(option.getValueClass())) {
return OPTION_NAME_IS_OVERLAY + " must be a boolean";
}
isOverlay = (boolean) option.getValue();
}
}
catch (Exception e) {
@ -194,7 +196,7 @@ public class BinaryLoader extends AbstractProgramLoader {
return "Invalid length specified";
}
if (program != null) {
if (program.getMemory().intersects(baseAddr, baseAddr.add(length - 1))) {
if (program.getMemory().intersects(baseAddr, baseAddr.add(length - 1)) && !isOverlay) {
return "Memory Conflict: Use <Options...> to change the base address!";
}
}
@ -340,7 +342,7 @@ public class BinaryLoader extends AbstractProgramLoader {
FileBytes fileBytes, long length, MessageLog log)
throws AddressOverflowException, IOException {
if (prog.getMemory().intersects(baseAddr, baseAddr.add(length - 1))) {
if (prog.getMemory().intersects(baseAddr, baseAddr.add(length - 1)) && !isOverlay) {
throw new IOException("Can't load " + length + " bytes at address " + baseAddr +
" since it conflicts with existing memory blocks!");
}

View file

@ -166,7 +166,8 @@ class FunctionsXmlMgr {
String regularComment = getElementText(parser, "REGULAR_CMT");
func.setComment(regularComment);
getElementText(parser, "REPEATABLE_CMT");
String repeatableComment = getElementText(parser, "REPEATABLE_CMT");
func.setRepeatableComment(repeatableComment);
String typeInfoComment = getElementText(parser, "TYPEINFO_CMT");
List<Variable> stackParams = new ArrayList<>();
List<Variable> stackVariables = new ArrayList<>();
@ -533,6 +534,7 @@ class FunctionsXmlMgr {
writeReturnType(writer, func);
writeAddressRange(writer, func);
writeRegularComment(writer, func.getComment());
writeRepeatableComment(writer, func.getRepeatableComment());
if (func.getSignatureSource() != SourceType.DEFAULT) {
writeTypeInfoComment(writer, func);
}
@ -602,6 +604,12 @@ class FunctionsXmlMgr {
}
}
private void writeRepeatableComment(XmlWriter writer, String comment) {
if (comment != null && comment.length() > 0) {
writer.writeElement("REPEATABLE_CMT", null, comment);
}
}
private void writeStackFrame(XmlWriter writer, Function func) {
StackFrame frame = func.getStackFrame();

View file

@ -22,7 +22,6 @@ import docking.ActionContext;
import docking.widgets.tree.GTreeNode;
import ghidra.app.services.ProgramManager;
import ghidra.formats.gfilesystem.*;
import ghidra.framework.model.Tool;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.Msg;
@ -60,7 +59,7 @@ public class FSBUtils {
}
public static FSBRootNode getNodesRoot(FSBNode node) {
GTreeNode tmp = (GTreeNode) node;
GTreeNode tmp = node;
while (tmp != null && !(tmp instanceof FSBRootNode)) {
tmp = tmp.getParent();
}
@ -102,13 +101,11 @@ public class FSBUtils {
public static List<PluginTool> getRunningProgramManagerTools(PluginTool tool) {
List<PluginTool> pluginTools = new ArrayList<>();
for (Tool runningTool : tool.getToolServices().getRunningTools()) {
if (runningTool instanceof PluginTool) {
PluginTool pt = (PluginTool) runningTool;
ProgramManager pmService = pt.getService(ProgramManager.class);
if (pmService != null) {
pluginTools.add(pt);
}
for (PluginTool runningTool : tool.getToolServices().getRunningTools()) {
PluginTool pt = runningTool;
ProgramManager pmService = pt.getService(ProgramManager.class);
if (pmService != null) {
pluginTools.add(pt);
}
}
return pluginTools;

View file

@ -22,6 +22,7 @@ import java.util.*;
import generic.test.AbstractGenericTest;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.LockException;
import ghidra.program.database.ProgramDB;
import ghidra.program.model.lang.*;
@ -155,18 +156,18 @@ public class ProjectTestUtils {
return dir.delete();
}
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
for (File file : files) {
if (file.isDirectory()) {
// use a dummy monitor as not to ruin our progress
if (!deleteDir(files[i])) {
Msg.debug(ProjectTestUtils.class, "Unable to delete directory: " + files[i]);
if (!deleteDir(file)) {
Msg.debug(ProjectTestUtils.class, "Unable to delete directory: " + file);
return false;
}
}
else {
if (!files[i].delete()) {
if (!ignoredDeleteNames.contains(files[i].getName())) {
Msg.debug(ProjectTestUtils.class, "Unable to delete file: " + files[i]);
if (!file.delete()) {
if (!ignoredDeleteNames.contains(file.getName())) {
Msg.debug(ProjectTestUtils.class, "Unable to delete file: " + file);
return false;
}
@ -186,6 +187,10 @@ public class ProjectTestUtils {
* @param folder domain folder within the specified project which the
* user has permission to write. If null, the root data folder will be used.
* @return new domain file.
* @throws InvalidNameException if the filename is invalid
* @throws CancelledException if the opening is cancelled
* @throws LanguageNotFoundException if the language cannot be found
* @throws IOException if there is an exception creating the program or domain file
*/
public static DomainFile createProgramFile(Project proj, String progName, Language language,
CompilerSpec compilerSpec, DomainFolder folder) throws InvalidNameException,
@ -210,8 +215,9 @@ public class ProjectTestUtils {
* @param project the project to which the tool belongs
* @param toolName name of the tool to get from the active workspace.
* If null, launch a new empty tool in the active workspace.
* @return the tool
*/
public static Tool getTool(Project project, String toolName) {
public static PluginTool getTool(Project project, String toolName) {
ToolManager tm = project.getToolManager();
@ -222,7 +228,7 @@ public class ProjectTestUtils {
// use the first one for the testing
Workspace activeWorkspace = workspaces[0];
Tool tool = null;
PluginTool tool = null;
if (toolName == null) {
// create a new empty tool
tool = activeWorkspace.createTool();
@ -244,7 +250,7 @@ public class ProjectTestUtils {
* @param tool The tool to be saved
* @return The tool template for the given tool.
*/
public static ToolTemplate saveTool(Project project, Tool tool) {
public static ToolTemplate saveTool(Project project, PluginTool tool) {
// save the tool to the project tool chest
ToolChest toolChest = project.getLocalToolChest();
ToolTemplate toolTemplate = tool.saveToolToToolTemplate();
@ -254,8 +260,8 @@ public class ProjectTestUtils {
/**
* Remove the specified tool if it exists.
* @param project
* @param toolName
* @param project the project
* @param toolName the tool name
* @return true if it existed and was removed from the local tool chest.
*/
public static boolean deleteTool(Project project, String toolName) {

View file

@ -640,7 +640,7 @@ public class TestEnv {
* NOTE: This array will not contain any of the TestTools!
* @return an array of tools spawned by the Ghidra environment
*/
public Tool[] getGhidraCreatedTools() {
public PluginTool[] getGhidraCreatedTools() {
return gp.getProject().getToolManager().getRunningTools();
}

View file

@ -20,7 +20,6 @@ import java.util.List;
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
import ghidra.app.services.DataTypeQueryService;
import ghidra.app.services.DataTypeManagerService;
import ghidra.program.database.data.DataTypeUtilities;
import ghidra.program.database.data.ProgramDataTypeManager;
import ghidra.program.model.data.*;
@ -440,8 +439,21 @@ public class DataTypeParser {
private static String getBaseString(String dataTypeString) {
int nextIndex = 0;
int templateCount = 0;
while (nextIndex < dataTypeString.length()) {
char c = dataTypeString.charAt(nextIndex);
if (c == '<') {
templateCount++;
}
else if (c == '>') {
templateCount--;
}
if (templateCount != 0) {
++nextIndex;
continue;
}
if (c == '*' || c == '[' || c == ':' || c == '{') {
return dataTypeString.substring(0, nextIndex).trim();
}

View file

@ -610,7 +610,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
}
private void performLaunchKeyStrokeDialogAction() {
ToolActions toolActions = ((AbstractDockingTool) tool).getToolActions();
ToolActions toolActions = (ToolActions) ((AbstractDockingTool) tool).getToolActions();
Action action = toolActions.getAction(KeyStroke.getKeyStroke("F4"));
assertNotNull(action);
runSwing(() -> action.actionPerformed(new ActionEvent(this, 0, "")), false);
@ -624,7 +624,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
private JComponent component = new JTextField("Hey!");
TestActionsComponentProvider(DockingTool tool) {
TestActionsComponentProvider(Tool tool) {
super(tool, PROVIDER_NAME, "Fooberry Plugin");
}
@ -637,7 +637,7 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
private class HasDefaultKeyBindingComponentProvider extends ComponentProvider {
private JComponent component = new JTextField("Hey!");
HasDefaultKeyBindingComponentProvider(DockingTool tool) {
HasDefaultKeyBindingComponentProvider(Tool tool) {
super(tool, HasDefaultKeyBindingComponentProvider.class.getSimpleName(),
"Fooberry Plugin");

View file

@ -36,7 +36,7 @@ import ghidra.test.DummyTool;
public class DockingWindowManagerTest extends AbstractDockingTest {
private DockingTool tool = new DummyTool();
private Tool tool = new DummyTool();
@Test
public void testDefaultGroupWindowPosition() {

View file

@ -25,8 +25,8 @@ import javax.swing.*;
import org.junit.*;
import docking.*;
import docking.actions.DockingToolActions;
import docking.actions.KeyEntryDialog;
import docking.actions.ToolActions;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.navigation.GoToAddressLabelPlugin;
import ghidra.framework.plugintool.PluginTool;
@ -197,7 +197,7 @@ public class KeyEntryDialogTest extends AbstractGhidraHeadedIntegrationTest {
public DockingAction getKeyBindingAction() {
ToolActions toolActions = tool.getToolActions();
DockingToolActions toolActions = tool.getToolActions();
KeyBindingsManager kbm =
(KeyBindingsManager) getInstanceField("keyBindingsManager", toolActions);
@SuppressWarnings("unchecked")

View file

@ -28,8 +28,7 @@ import org.junit.Test;
import docking.DockingUtils;
import docking.action.DockingActionIf;
import docking.actions.KeyBindingUtils;
import docking.actions.ToolActions;
import docking.actions.*;
public class GhidraScriptMgrPlugin1Test extends AbstractGhidraScriptMgrPluginTest {
@ -147,7 +146,7 @@ public class GhidraScriptMgrPlugin1Test extends AbstractGhidraScriptMgrPluginTes
KeyStroke actionKs = toolAction.getKeyBinding();
assertEquals(newKs, actionKs);
ToolActions toolActions = plugin.getTool().getToolActions();
ToolActions toolActions = (ToolActions) plugin.getTool().getToolActions();
Action toolActionByKeyStroke = toolActions.getAction(newKs);
assertNotNull(toolActionByKeyStroke);
}

View file

@ -15,11 +15,12 @@
*/
package ghidra.framework.project;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import org.junit.*;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.protocol.ghidra.GhidraURL;
import ghidra.program.database.ProgramBuilder;
import ghidra.program.model.listing.Program;
@ -73,7 +74,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
// test 1 create a program and add it to a project
Program program1 = createProgram(project, "Prog1", this);
Tool consumer2 = new DummyTool();
PluginTool consumer2 = new DummyTool();
Program program2 = null;
try {
// test 2 - get the object from the project and make sure it is the
@ -213,7 +214,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
private static void createProgramReadOnly(Project proj, String progName) throws Exception {
Tool t = new DummyTool();
PluginTool t = new DummyTool();
Program p = createDefaultProgram(progName, ProgramBuilder._TOY, t);
try {
@ -295,7 +296,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
DomainFolder f3 = f.createFolder("Y");
DomainFolder f4 = f.createFolder("Z");
Tool t = new DummyTool("Tool1");
PluginTool t = new DummyTool("Tool1");
Program p1 = null;
Program p2 = null;
@ -344,7 +345,7 @@ public class CreateDomainObjectTest extends AbstractGhidraHeadedIntegrationTest
DomainFolder f3 = f.getFolder("Y");
DomainFolder f4 = f.getFolder("Z");
Tool t = new DummyTool("Tool1");
PluginTool t = new DummyTool("Tool1");
if ((f.getFile("AAA") == null) || (f.getFile("BBB") == null) ||
(f2.getFile("CCC") == null) || (f3.getFile("DDD") == null) ||

View file

@ -200,9 +200,9 @@ public abstract class AbstractToolSavingTest extends AbstractGhidraHeadedIntegra
protected List<PluginTool> findOpenTools() {
ToolManager tm = testEnv.getProject().getToolManager();
Workspace activeWorkspace = tm.getActiveWorkspace();
Tool[] tools = activeWorkspace.getTools();
PluginTool[] tools = activeWorkspace.getTools();
List<PluginTool> pluginToolList = new ArrayList<>(tools.length);
for (Tool tool : tools) {
for (PluginTool tool : tools) {
pluginToolList.add((PluginTool) tool);
}
return pluginToolList;

View file

@ -17,8 +17,10 @@ package ghidra.framework.project.tool;
import org.junit.*;
import generic.test.AbstractGenericTest;
import ghidra.framework.model.*;
import generic.test.AbstractGTest;
import ghidra.framework.model.DomainFile;
import ghidra.framework.model.Project;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.database.ProgramBuilder;
import ghidra.test.*;
@ -30,20 +32,12 @@ import ghidra.test.*;
*/
public class ChangeToolDataTest extends AbstractGhidraHeadedIntegrationTest {
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
private final static String DATA_NAME_1 = "TestData1";
private final static String DATA_NAME_2 = "TestData2";
private Project project;
/**
* Constructor
* @param arg0
*/
public ChangeToolDataTest() {
super();
}
@Before
public void setUp() throws Exception {
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
@ -56,8 +50,8 @@ public class ChangeToolDataTest extends AbstractGhidraHeadedIntegrationTest {
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
}
/**
* This doTest() routine tests the following requirements:
/*
* Tests the following requirements:
* (1) connect two running tools by one or more specified events
* (2) disconnect one or more specified events between two connected tools
* @param args same as args to main()
@ -72,7 +66,7 @@ public class ChangeToolDataTest extends AbstractGhidraHeadedIntegrationTest {
//
// setup the running tool
//
Tool runningTool = new DummyTool();
PluginTool runningTool = new DummyTool();
//
// TEST 1: set the data for a tool running without data

View file

@ -53,10 +53,8 @@ public class CloseToolTest extends AbstractGhidraHeadedIntegrationTest {
@After
public void tearDown() throws Exception {
executeOnSwingWithoutBlocking(() -> env.dispose());
env.dispose();
closeAllWindows();
}
@Test

View file

@ -17,8 +17,9 @@ package ghidra.framework.project.tool;
import org.junit.*;
import generic.test.AbstractGenericTest;
import generic.test.AbstractGTest;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.test.*;
/**
@ -30,18 +31,10 @@ import ghidra.test.*;
public class ConnectToolsTest extends AbstractGhidraHeadedIntegrationTest {
private final static String BAD_EVENT_NAME = "TEST_CONNECT_FOR_BAD_EVENT";
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
private Project project;
/**
* Constructor
* @param arg0
*/
public ConnectToolsTest() {
super();
}
@Before
public void setUp() throws Exception {
@ -56,16 +49,16 @@ public class ConnectToolsTest extends AbstractGhidraHeadedIntegrationTest {
}
/**
* This doTest() routine tests the following requirements:
/*
* Tests the following requirements:
* (1) connect two running tools by one or more specified events
* (2) disconnect one or more specified events between two connected tools
*/
@Test
public void testConnectTools() throws Exception {
Tool producer = new DummyTool("ProducerTool");
Tool consumer = new DummyTool("ConsumerTool");
PluginTool producer = new DummyTool("ProducerTool");
PluginTool consumer = new DummyTool("ConsumerTool");
ToolConnection tc;
String eventName = null;

View file

@ -17,8 +17,10 @@ package ghidra.framework.project.tool;
import org.junit.*;
import generic.test.AbstractGenericTest;
import ghidra.framework.model.*;
import generic.test.AbstractGTest;
import ghidra.framework.model.Project;
import ghidra.framework.model.ToolManager;
import ghidra.framework.plugintool.PluginTool;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.ProjectTestUtils;
@ -29,20 +31,10 @@ import ghidra.test.ProjectTestUtils;
*/
public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
private Project project;
// private Workspace activeWorkspace;
private Tool tool;
/**
* Constructor
* @param arg0
*/
public CreateToolTest() {
super();
}
private PluginTool tool;
@Before
public void setUp() throws Exception {
@ -56,7 +48,7 @@ public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
}
private void closeTool(final Tool theTool) {
private void closeTool(final PluginTool theTool) {
executeOnSwingWithoutBlocking(new Runnable() {
@Override
public void run() {
@ -65,10 +57,10 @@ public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
});
// this handles the save changes dialog and potential analysis dialogs
closeAllWindowsAndFrames();
closeAllWindows();
}
/**
/*
* Do the test.
* This doTest() routine tests the following requirements:
* (1) create (launch) an empty tool in the active workspace
@ -92,7 +84,7 @@ public class CreateToolTest extends AbstractGhidraHeadedIntegrationTest {
try {
// verify the tool is actually running before declaring success
ToolManager tm = project.getToolManager();
Tool[] runningTools = tm.getRunningTools();
PluginTool[] runningTools = tm.getRunningTools();
for (int t = 0; !verified && t < runningTools.length; t++) {
if (runningTools[t].equals(tool)) {
verified = true;

View file

@ -15,7 +15,7 @@
*/
package ghidra.framework.project.tool;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import java.io.IOException;
@ -23,6 +23,7 @@ import org.junit.*;
import generic.test.AbstractGenericTest;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.LockException;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.ProjectTestUtils;
@ -138,7 +139,7 @@ public class CreateWorkspaceTest extends AbstractGhidraHeadedIntegrationTest {
}
});
Tool[] runningTools = wspaces[0].getTools();
PluginTool[] runningTools = wspaces[0].getTools();
assertEquals(1, runningTools.length);
setWorkspaceActive(wspaces[1]);

View file

@ -17,8 +17,9 @@ package ghidra.framework.project.tool;
import org.junit.*;
import generic.test.AbstractGenericTest;
import generic.test.AbstractGTest;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.ProjectTestUtils;
@ -30,20 +31,12 @@ import ghidra.test.ProjectTestUtils;
*/
public class DeleteToolTest extends AbstractGhidraHeadedIntegrationTest {
private final static String PROJECT_DIRECTORY = AbstractGenericTest.getTestDirectoryPath();
private final static String PROJECT_DIRECTORY = AbstractGTest.getTestDirectoryPath();
private final static String TOOL_NAME = "TestTool";
private Tool runningTool;
private PluginTool runningTool;
private Project project;
/**
* Constructor
* @param arg0
*/
public DeleteToolTest() {
super();
}
@Before
public void setUp() throws Exception {
ProjectTestUtils.deleteProject(PROJECT_DIRECTORY, PROJECT_NAME);
@ -56,8 +49,8 @@ public class DeleteToolTest extends AbstractGhidraHeadedIntegrationTest {
ProjectTestUtils.deleteProject(PROJECT_DIRECTORY, PROJECT_NAME);
}
/**
* This doTest() routine tests the following requirements:
/*
* Tsts the following requirements:
* (1) delete a non-running tool from the user's project space
* (2) delete a running tool from the user's project space
*

View file

@ -15,16 +15,13 @@
*/
package ghidra.framework.project.tool;
import static org.junit.Assert.assertNotNull;
import java.beans.PropertyVetoException;
import javax.swing.SwingUtilities;
import static org.junit.Assert.*;
import org.junit.*;
import generic.test.AbstractGenericTest;
import generic.test.AbstractGTest;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.ProjectTestUtils;
@ -36,20 +33,12 @@ import ghidra.test.ProjectTestUtils;
*/
public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
private final static String TOOL_NAME = "TestTool";
private Project project;
private Tool runningTool;
private Tool tool;
/**
* Constructor
* @param arg0
*/
public RunToolTest() {
super();
}
private PluginTool runningTool;
private PluginTool tool;
@Before
public void setUp() throws Exception {
@ -59,7 +48,7 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
@After
public void tearDown() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
runSwing(new Runnable() {
@Override
public void run() {
project.save();
@ -69,7 +58,7 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
}
/**
/*
* Do the test.
* This doTest() routine tests the following requirements:
* (1) Run Project Tool Without Data
@ -84,22 +73,18 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
ProjectTestUtils.deleteTool(project, TOOL_NAME);
// Create tool and save tool config
SwingUtilities.invokeAndWait(new Runnable() {
runSwing(new Runnable() {
@Override
public void run() {
tool = ProjectTestUtils.getTool(project, null);
try {
tool.setToolName(TOOL_NAME);
}
catch (PropertyVetoException e) {
}
tool.setToolName(TOOL_NAME);
}
});
try {
final ToolTemplate toolConfig = ProjectTestUtils.saveTool(project, tool);
SwingUtilities.invokeAndWait(new Runnable() {
runSwing(new Runnable() {
@Override
public void run() {
tool.close();
@ -118,14 +103,14 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
// use the first one for the test
final Workspace activeWorkspace = workspaces[0];
SwingUtilities.invokeAndWait(new Runnable() {
runSwing(new Runnable() {
@Override
public void run() {
runningTool = activeWorkspace.runTool(toolConfig);
}
});
assertNotNull(runningTool);
SwingUtilities.invokeAndWait(new Runnable() {
runSwing(new Runnable() {
@Override
public void run() {
runningTool.close();
@ -135,7 +120,7 @@ public class RunToolTest extends AbstractGhidraHeadedIntegrationTest {
}
finally {
// Don't leave the tool in the tool chest
SwingUtilities.invokeAndWait(new Runnable() {
runSwing(new Runnable() {
@Override
public void run() {
ProjectTestUtils.deleteTool(project, TOOL_NAME);

View file

@ -15,12 +15,13 @@
*/
package ghidra.framework.project.tool;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import org.junit.*;
import generic.test.AbstractGenericTest;
import generic.test.AbstractGTest;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.ProjectTestUtils;
@ -29,20 +30,12 @@ import ghidra.test.ProjectTestUtils;
*/
public class SaveToolTest extends AbstractGhidraHeadedIntegrationTest {
private final static String DIRECTORY_NAME = AbstractGenericTest.getTestDirectoryPath();
private final static String DIRECTORY_NAME = AbstractGTest.getTestDirectoryPath();
private final static String TOOL_NAME = "TestTool";
private Tool runningTool;
private PluginTool runningTool;
private Project project;
/**
* Constructor
* @param name The name of the test to run.
*/
public SaveToolTest() {
super();
}
@Before
public void setUp() throws Exception {
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
@ -55,7 +48,7 @@ public class SaveToolTest extends AbstractGhidraHeadedIntegrationTest {
ProjectTestUtils.deleteProject(DIRECTORY_NAME, PROJECT_NAME);
}
/**
/*
* This tests the following requirements:
* (1) create an empty tool in the active workspace, and
* (2) that duplicate project names do not throw exceptions.

View file

@ -69,6 +69,45 @@ public class DataTypeParserTest extends AbstractEditorTest {
super.tearDown();
}
@Test
public void testParse_NameWithTemplate() throws Exception {
String typeName = "templated_name<int, void*, custom_type>";
StructureDataType structure = new StructureDataType(typeName, 0);
tx(program, () -> {
programDTM.resolve(structure, null);
});
DataTypeParser parser = new DataTypeParser(dtmService, AllowedDataTypes.ALL);
DataType dt = parser.parse(typeName);
assertNotNull(dt);
assertTrue(dt.isEquivalent(structure));
}
@Test
public void testParse_PointerToNameWithTemplate() throws Exception {
//
// Attempt to resolve a pointer to an existing type when that pointer does not already
// exist.
//
String typeName = "templated_name<int, void*, custom_type>";
StructureDataType structure = new StructureDataType(typeName, 0);
PointerDataType pointer = new PointerDataType(structure);
String pointerName = pointer.getName();
tx(program, () -> {
programDTM.resolve(structure, null);
});
DataTypeParser parser = new DataTypeParser(dtmService, AllowedDataTypes.ALL);
DataType dt = parser.parse(pointerName);
assertNotNull(dt);
assertTrue(dt.isEquivalent(pointer));
}
@Test
public void testValidDataTypeSyntax() {
checkValidDt("byte");

View file

@ -97,7 +97,7 @@ public class FcgProvider
private ToggleDockingAction navigateIncomingToggleAction;
public FcgProvider(DockingTool tool, FunctionCallGraphPlugin plugin) {
public FcgProvider(Tool tool, FunctionCallGraphPlugin plugin) {
super(tool, NAME, plugin.getName());
this.plugin = plugin;

View file

@ -174,7 +174,7 @@ public class VTSubToolManager implements VTControllerListener, OptionsChangeList
return newTool;
}
private DockingActionIf getToolAction(Tool tool, String actionName) {
private DockingActionIf getToolAction(PluginTool tool, String actionName) {
Set<DockingActionIf> actions = tool.getDockingActionsByOwnerName(ToolConstants.TOOL_OWNER);
for (DockingActionIf action : actions) {
if (action.getName().equals(actionName)) {

View file

@ -219,7 +219,7 @@ public class VTFunctionAssociationProvider extends ComponentProviderAdapter
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context) {
if (context.getComponentProvider() == this) {
ListingCodeComparisonPanel dualListingPanel =
functionComparisonPanel.getDualListingPanel();

View file

@ -452,7 +452,7 @@ public class VTMarkupItemsTableProvider extends ComponentProviderAdapter
}
@Override
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context) {
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context) {
ListingCodeComparisonPanel dualListingPanel = functionComparisonPanel.getDualListingPanel();
if (context.getComponentProvider() == this && dualListingPanel != null) {
ListingPanel sourcePanel = dualListingPanel.getLeftPanel();

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -21,16 +21,15 @@ import java.util.*;
import javax.swing.JFrame;
import docking.action.DockingActionIf;
import docking.actions.PopupActionProvider;
import docking.actions.ToolActions;
import docking.actions.*;
import ghidra.framework.options.ToolOptions;
import ghidra.util.Swing;
/**
* A partial implementation of {@link DockingTool} that serves as a place to share common
* A partial implementation of {@link Tool} that serves as a place to share common
* functionality
*/
public abstract class AbstractDockingTool implements DockingTool {
public abstract class AbstractDockingTool implements Tool {
protected DockingWindowManager winMgr;
protected ToolActions toolActions;
@ -209,11 +208,6 @@ public abstract class AbstractDockingTool implements DockingTool {
winMgr.contextChanged(provider);
}
@Override
public ActionContext getGlobalContext() {
return winMgr.getGlobalContext();
}
@Override
public void addContextListener(DockingContextListener listener) {
winMgr.addContextListener(listener);
@ -240,7 +234,7 @@ public abstract class AbstractDockingTool implements DockingTool {
}
@Override
public ToolActions getToolActions() {
public DockingToolActions getToolActions() {
return toolActions;
}
}

View file

@ -85,7 +85,7 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
// maps for mapping old provider names and owner to new names and/or owner
private static Map<String, String> oldOwnerMap = new HashMap<>();
private static Map<String, String> oldNameMap = new HashMap<>();
protected DockingTool dockingTool;
protected Tool dockingTool;
private String name;
private final String owner;
private String title;
@ -121,7 +121,7 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
* the same window.
* @param owner The owner of this provider, usually a plugin name.
*/
public ComponentProvider(DockingTool tool, String name, String owner) {
public ComponentProvider(Tool tool, String name, String owner) {
this(tool, name, owner, null);
}
@ -134,7 +134,7 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
* @param contextType the type of context supported by this provider; may be null (see
* {@link #getContextType()}
*/
public ComponentProvider(DockingTool tool, String name, String owner, Class<?> contextType) {
public ComponentProvider(Tool tool, String name, String owner, Class<?> contextType) {
this.dockingTool = tool;
this.name = name;
this.owner = owner;
@ -744,7 +744,7 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
return this;
}
public DockingTool getTool() {
public Tool getTool() {
return dockingTool;
}

View file

@ -74,7 +74,7 @@ class DockableToolBarManager {
String owner = provider.getOwner();
ToolBarCloseAction closeAction = new ToolBarCloseAction(owner);
closeButtonManager = new ToolBarItemManager(closeAction, winMgr);
DockingTool tool = winMgr.getTool();
Tool tool = winMgr.getTool();
// we need to add this action to the tool in order to use key bindings
tool.addLocalAction(provider, closeAction);
@ -166,7 +166,7 @@ class DockableToolBarManager {
// this will be null for non-standard use cases
if (dockableComponent != null) {
DockingWindowManager dwm = dockableComponent.getDockingWindowManager();
DockingTool tool = dwm.getTool();
Tool tool = dwm.getTool();
ComponentProvider provider = dockableComponent.getComponentProvider();
tool.removeLocalAction(provider, closeButtonManager.getAction());
}

View file

@ -117,11 +117,6 @@ public class DockingActionProxy
return dockingAction.isValidContext(context);
}
@Override
public boolean isValidGlobalContext(ActionContext context) {
return dockingAction.isValidGlobalContext(context);
}
@Override
public void removePropertyChangeListener(PropertyChangeListener listener) {
propertyListeners.remove(listener);

View file

@ -32,9 +32,9 @@ public abstract class DockingKeyBindingAction extends AbstractAction {
private DockingActionIf docakbleAction;
protected final KeyStroke keyStroke;
protected final DockingTool tool;
protected final Tool tool;
public DockingKeyBindingAction(DockingTool tool, DockingActionIf action, KeyStroke keyStroke) {
public DockingKeyBindingAction(Tool tool, DockingActionIf action, KeyStroke keyStroke) {
super(KeyBindingUtils.parseKeyStroke(keyStroke));
this.tool = tool;
this.docakbleAction = action;

View file

@ -79,7 +79,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
// we use a list to maintain order
private static List<DockingWindowManager> instances = new ArrayList<>();
private DockingTool tool;
private Tool tool;
private RootNode root;
private PlaceholderManager placeholderManager;
@ -116,7 +116,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
* @param tool the tool
* @param images the images to use for windows in this window manager
*/
public DockingWindowManager(DockingTool tool, List<Image> images) {
public DockingWindowManager(Tool tool, List<Image> images) {
this(tool, images, false, true, true, null);
}
@ -131,7 +131,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
* @param hasStatusBar if true a status bar will be created for the main window
* @param factory the drop target factory
*/
public DockingWindowManager(DockingTool tool, List<Image> images, boolean modal,
public DockingWindowManager(Tool tool, List<Image> images, boolean modal,
boolean isDocking, boolean hasStatusBar, DropTargetFactory factory) {
KeyBindingOverrideKeyEventDispatcher.install();
@ -330,7 +330,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
* Returns the tool that owns this manager
* @return the tool
*/
public DockingTool getTool() {
public Tool getTool() {
return tool;
}
@ -353,23 +353,6 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
defaultProvider = provider;
}
/**
* Returns this tool's notion of the current action context, which is based upon the active
* {@link ComponentProvider}. If there is not active provider, then a generic context will
* be returned.
*
* @return the context
*/
public ActionContext getGlobalContext() {
if (defaultProvider != null) {
ActionContext actionContext = defaultProvider.getActionContext(null);
if (actionContext != null) {
return actionContext;
}
}
return new ActionContext();
}
/**
* Get the window which contains the specified Provider's component.
* @param provider component provider

View file

@ -47,36 +47,20 @@ public class MenuBarMenuHandler extends MenuHandler {
DockingWindowManager.clearMouseOverHelp();
ComponentProvider provider = windowManager.getActiveComponentProvider();
ActionContext context = provider == null ? null : provider.getActionContext(null);
ActionContext localContext = context == null ? new ActionContext() : context;
ActionContext globalContext = windowManager.getGlobalContext();
ActionContext providerContext = provider == null ? null : provider.getActionContext(null);
ActionContext context = providerContext == null ? new ActionContext() : providerContext;
ActionContext tempContext = null;
if (action.isValidContext(localContext)) {
tempContext = localContext; // we prefer the local over the global context if valid
}
else if (action.isValidGlobalContext(globalContext)) {
tempContext = globalContext;
}
else {
return; // context is not valid, nothing to do
}
tempContext.setSourceObject(event.getSource());
final ActionContext finalContext = tempContext;
context.setSourceObject(event.getSource());
// this gives the UI some time to repaint before executing the action
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
windowManager.setStatusText("");
if (action.isEnabledForContext(finalContext)) {
if (action instanceof ToggleDockingActionIf) {
ToggleDockingActionIf toggleAction = ((ToggleDockingActionIf) action);
toggleAction.setSelected(!toggleAction.isSelected());
}
action.actionPerformed(finalContext);
SwingUtilities.invokeLater(() -> {
windowManager.setStatusText("");
if (action.isValidContext(context) && action.isEnabledForContext(context)) {
if (action instanceof ToggleDockingActionIf) {
ToggleDockingActionIf toggleAction = ((ToggleDockingActionIf) action);
toggleAction.setSelected(!toggleAction.isSelected());
}
action.actionPerformed(context);
}
});
}

View file

@ -24,12 +24,13 @@ import docking.action.DockingActionIf;
import docking.actions.DockingToolActions;
import docking.actions.PopupActionProvider;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ServiceProvider;
/**
* Generic tool interface for managing {@link ComponentProvider}s and
* {@link DockingActionIf actions}
*/
public interface DockingTool {
public interface Tool extends ServiceProvider {
/**
* Returns a combination of the tool name and the instance name of the form
@ -247,15 +248,6 @@ public interface DockingTool {
*/
public void contextChanged(ComponentProvider provider);
/**
* Returns this tool's notion of the current action context, which is based upon the active
* {@link ComponentProvider}. If there is not active provider, then a generic context will
* be returned.
*
* @return the context
*/
public ActionContext getGlobalContext();
/**
* Adds the given context listener to this tool
* @param listener the listener to add

View file

@ -121,7 +121,6 @@ public class WindowActionManager {
ComponentProvider provider = placeHolderForScheduledActionUpdate == null ? null
: placeHolderForScheduledActionUpdate.getProvider();
ActionContext localContext = provider == null ? null : provider.getActionContext(null);
ActionContext globalContext = winMgr.getGlobalContext();
if (localContext == null) {
localContext = new ActionContext();
}
@ -132,9 +131,6 @@ public class WindowActionManager {
if (action.isValidContext(localContext)) {
action.setEnabled(action.isEnabledForContext(localContext));
}
else if (action.isValidGlobalContext(globalContext)) {
action.setEnabled(action.isEnabledForContext(globalContext));
}
else {
action.setEnabled(false);
}

View file

@ -76,7 +76,6 @@ public abstract class DockingAction implements DockingActionIf {
private Predicate<ActionContext> enabledPredicate;
private Predicate<ActionContext> popupPredicate;
private Predicate<ActionContext> validContextPredicate;
private Predicate<ActionContext> validGlobalContextPredicate;
public DockingAction(String name, String owner) {
this.name = name;
@ -184,14 +183,6 @@ public abstract class DockingAction implements DockingActionIf {
return true;
}
@Override
public boolean isValidGlobalContext(ActionContext globalContext) {
if (validGlobalContextPredicate != null) {
return validGlobalContextPredicate.test(globalContext);
}
return isValidContext(globalContext);
}
/**
* Default behavior is to add to main window;
*/
@ -572,17 +563,6 @@ public abstract class DockingAction implements DockingActionIf {
validContextPredicate = predicate;
}
/**
* Sets a predicate for dynamically determining if this action is valid for the current global
* {@link ActionContext}. See {@link DockingActionIf#isValidGlobalContext(ActionContext)}
*
* @param predicate the predicate that will be used to dynamically determine an action's
* validity for a given global {@link ActionContext}
*/
public void validGlobalContextWhen(Predicate<ActionContext> predicate) {
validGlobalContextPredicate = predicate;
}
//==================================================================================================
// Non-public methods
//==================================================================================================

View file

@ -193,19 +193,6 @@ public interface DockingActionIf extends HelpDescriptor {
*/
public boolean isValidContext(ActionContext context);
/**
* Method that actions implement to indicate if this action is valid (knows how to work with, is
* appropriate for) for the given global context. This method is just like the isValidContext
* and in fact calls that method by default. Many actions will work with either the active
* provider context or the global (the main listing) context if the local context is not valid.
* If you want a global action to only work on the global context, then override this method
* and return false.
*
* @param globalContext the global {@link ActionContext} from the active provider.
* @return true if this action is appropriate for the given context.
*/
public boolean isValidGlobalContext(ActionContext globalContext);
/**
* Method used to determine if this action should be enabled for the given context.
* <p>

View file

@ -17,7 +17,7 @@ package docking.action;
import java.util.List;
import docking.DockingTool;
import docking.Tool;
/**
* An interface for objects (really Components) to implement that signals they provide actions
@ -29,7 +29,7 @@ import docking.DockingTool;
* actions. Further, in this example, the actions given will be inserted into the popup menu
* that is shown.
*
* @deprecated use {@link DockingTool}
* @deprecated use {@link Tool}
*/
// Note: this API is not likely used by forward-facing clients and can be removed in the next release
@Deprecated(since = "9.1", forRemoval = true)

View file

@ -38,9 +38,9 @@ public class KeyBindingsManager implements PropertyChangeListener {
// this map exists to update the MultiKeyBindingAction when the key binding changes
private Map<DockingActionIf, ComponentProvider> actionToProviderMap;
private Map<KeyStroke, DockingKeyBindingAction> dockingKeyMap;
private DockingTool tool;
private Tool tool;
public KeyBindingsManager(DockingTool tool) {
public KeyBindingsManager(Tool tool) {
this.tool = tool;
dockingKeyMap = new HashMap<>();
actionToProviderMap = new HashMap<>();

View file

@ -40,7 +40,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
* @param action action that will be added to the list of actions bound to a keystroke
* @param keyStroke the keystroke, if any, associated with the action
*/
public MultipleKeyAction(DockingTool tool, ComponentProvider provider, DockingActionIf action,
public MultipleKeyAction(Tool tool, ComponentProvider provider, DockingActionIf action,
KeyStroke keyStroke) {
super(tool, action, keyStroke);
addAction(provider, action);
@ -121,8 +121,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
ActionContext localContext = getLocalContext(localProvider);
localContext.setSourceObject(event.getSource());
ActionContext globalContext = tool.getGlobalContext();
List<ExecutableKeyActionAdapter> list = getValidContextActions(localContext, globalContext);
List<ExecutableKeyActionAdapter> list = getValidContextActions(localContext);
// If menu active, disable all key bindings
if (ignoreActionWhileMenuShowing()) {
@ -164,8 +163,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
return menuManager.getSelectedPath().length != 0;
}
private List<ExecutableKeyActionAdapter> getValidContextActions(ActionContext localContext,
ActionContext globalContext) {
private List<ExecutableKeyActionAdapter> getValidContextActions(ActionContext localContext) {
List<ExecutableKeyActionAdapter> list = new ArrayList<>();
boolean hasLocalActionsForKeyBinding = false;
@ -222,9 +220,6 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
if (isValidAndEnabled(actionData, localContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, localContext));
}
else if (isValidAndEnabledGlobally(actionData, globalContext)) {
list.add(new ExecutableKeyActionAdapter(actionData.action, globalContext));
}
}
}
return list;
@ -235,11 +230,6 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
return a.isValidContext(localContext) && a.isEnabledForContext(localContext);
}
private boolean isValidAndEnabledGlobally(ActionData actionData, ActionContext globalContext) {
DockingActionIf a = actionData.action;
return a.isValidGlobalContext(globalContext) && a.isEnabledForContext(globalContext);
}
@Override
public boolean isReservedKeybindingPrecedence() {
return false; // MultipleKeyActions can never be reserved
@ -249,9 +239,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
public KeyBindingPrecedence getKeyBindingPrecedence() {
ComponentProvider localProvider = tool.getActiveComponentProvider();
ActionContext localContext = getLocalContext(localProvider);
ActionContext globalContext = tool.getGlobalContext();
List<ExecutableKeyActionAdapter> validActions =
getValidContextActions(localContext, globalContext);
List<ExecutableKeyActionAdapter> validActions = getValidContextActions(localContext);
if (validActions.isEmpty()) {
return null; // a signal that no actions are valid for the current context

View file

@ -21,7 +21,7 @@ import docking.*;
class ReservedKeyBindingAction extends DockingKeyBindingAction {
ReservedKeyBindingAction(DockingTool tool, DockingActionIf action, KeyStroke keyStroke) {
ReservedKeyBindingAction(Tool tool, DockingActionIf action, KeyStroke keyStroke) {
super(tool, action, keyStroke);
}

View file

@ -19,10 +19,12 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.*;
import docking.action.*;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import resources.ResourceManager;
/**
@ -137,6 +139,11 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
*/
private String toolBarSubGroup;
/**
* The key binding to assign to the action
*/
private KeyStroke keyBinding;
/**
* Predicate for determining if an action is enabled for a given context
*/
@ -152,11 +159,6 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
*/
private Predicate<ActionContext> validContextPredicate;
/**
* Predicate for determining if an action is applicable for a given global context
*/
private Predicate<ActionContext> validGlobalContextPredicate;
/**
* Builder constructor
* @param name the name of the action to be built
@ -175,7 +177,7 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
/**
* Builds the action. To build and install the action in one step, use
* {@link #buildAndInstall(DockingTool)} or {@link #buildAndInstallLocal(ComponentProvider)}.
* {@link #buildAndInstall(Tool)} or {@link #buildAndInstallLocal(ComponentProvider)}.
*
* @return the newly build action
*/
@ -189,7 +191,7 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
* @see #build()
* @see #buildAndInstallLocal(ComponentProvider)
*/
public T buildAndInstall(DockingTool tool) {
public T buildAndInstall(Tool tool) {
T action = build();
tool.addAction(action);
return action;
@ -201,7 +203,7 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
* @param provider the provider to add the action to
* @return the newly created action
* @see #build()
* @see #buildAndInstall(DockingTool)
* @see #buildAndInstall(Tool)
*/
public T buildAndInstallLocal(ComponentProvider provider) {
T action = build();
@ -448,6 +450,32 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
return self();
}
/**
* Sets the key binding for this action
*
* @param keyStroke the KeyStroke to bind to this action
* @return this builder (for chaining)
*/
public B keyBinding(KeyStroke keyStroke) {
this.keyBinding = keyStroke;
return self();
}
/**
* Sets the key binding for this action
*
* @param keyStrokeString the string to parse as a KeyStroke. See
* {@link KeyStroke#getKeyStroke(String)} for the format of the string.
* @return this builder (for chaining)
*/
public B keyBinding(String keyStrokeString) {
this.keyBinding = KeyStroke.getKeyStroke(keyStrokeString);
if (keyBinding == null && keyStrokeString != null) {
Msg.warn(this, "Can't parse KeyStroke: " + keyStrokeString);
}
return self();
}
/**
* Sets the primary callback to be executed when this action is invoked. This builder will
* throw an {@link IllegalStateException} if one of the build methods is called without
@ -517,22 +545,6 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
return self();
}
/**
* Sets a predicate for dynamically determining if this action is valid for the current global
* {@link ActionContext}. See {@link DockingActionIf#isValidGlobalContext(ActionContext)}.
*
* <p>Note: most actions will not use this method, but rely instead on
* {@link #enabledWhen(Predicate)}.
*
* @param predicate the predicate that will be used to dynamically determine an action's
* validity for a given global {@link ActionContext}
* @return this builder (for chaining)
*/
public B validGlobalContextWhen(Predicate<ActionContext> predicate) {
validGlobalContextPredicate = predicate;
return self();
}
protected void validate() {
if (actionCallback == null) {
throw new IllegalStateException(
@ -547,6 +559,7 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
setMenuData(action);
setToolbarData(action);
setPopupMenuData(action);
setKeyBindingData(action);
if (helpLocation != null) {
action.setHelpLocation(helpLocation);
@ -558,9 +571,6 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
if (validContextPredicate != null) {
action.validContextWhen(validContextPredicate);
}
if (validGlobalContextPredicate != null) {
action.validGlobalContextWhen(validGlobalContextPredicate);
}
if (popupPredicate != null) {
action.popupWhen(enabledPredicate);
}
@ -578,6 +588,10 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
return menuPath != null;
}
protected boolean isKeyBindingAction() {
return keyBinding != null;
}
private void setPopupMenuData(DockingAction action) {
if (isPopupAction()) {
action.setPopupMenuData(new MenuData(popupPath, popupIcon, popupGroup,
@ -598,4 +612,9 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, B extends
}
}
private void setKeyBindingData(DockingAction action) {
if (isKeyBindingAction()) {
action.setKeyBindingData(new KeyBindingData(keyBinding));
}
}
}

View file

@ -91,4 +91,16 @@ public interface DockingToolActions {
* @return the actions
*/
public Set<DockingActionIf> getAllActions();
/**
* Allows clients to register an action by using a placeholder. This is useful when
* an API wishes to have a central object (like a plugin) register actions for transient
* providers, that may not be loaded until needed.
*
* <p>This method may be called multiple times with the same conceptual placeholder--the
* placeholder will only be added once.
*
* @param placeholder the placeholder containing information related to the action it represents
*/
public void registerSharedActionPlaceholder(SharedDockingActionPlaceholder placeholder);
}

View file

@ -33,7 +33,7 @@ import org.jdom.*;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import docking.DockingTool;
import docking.Tool;
import docking.DockingUtils;
import docking.action.*;
import docking.widgets.filechooser.GhidraFileChooser;
@ -465,7 +465,7 @@ public class KeyBindingUtils {
* @param tool the tool containing the actions
* @return the actions mapped by their full name (e.g., 'Name (OwnerName)')
*/
public static Map<String, List<DockingActionIf>> getAllActionsByFullName(DockingTool tool) {
public static Map<String, List<DockingActionIf>> getAllActionsByFullName(Tool tool) {
Map<String, List<DockingActionIf>> result =
LazyMap.lazyMap(new HashMap<>(), s -> new LinkedList<>());
@ -493,7 +493,7 @@ public class KeyBindingUtils {
* @param owner the action owner name
* @return the actions
*/
public static Set<DockingActionIf> getKeyBindingActionsForOwner(DockingTool tool,
public static Set<DockingActionIf> getKeyBindingActionsForOwner(Tool tool,
String owner) {
Map<String, DockingActionIf> deduper = new HashMap<>();

View file

@ -18,13 +18,13 @@ package docking.actions;
import java.util.List;
import docking.ActionContext;
import docking.DockingTool;
import docking.Tool;
import docking.action.DockingActionIf;
/**
* Provides notification when the popup action menu is displayed. This interface allows
* temporary/transient actions (those not registered with the tool via
* {@link DockingTool#addAction(DockingActionIf)}) to be used in the popup context menu.
* {@link Tool#addAction(DockingActionIf)}) to be used in the popup context menu.
*
* <p>
* Most clients will register actions directly with the tool. However, clients that have numerous
@ -32,7 +32,7 @@ import docking.action.DockingActionIf;
* on demand as the popup is about to be shown, and only if their context is active. This
* mechanism can reduce the tool's action management overhead. Once you have created an
* implementation of this class, you must register it with
* {@link DockingTool#addPopupActionProvider(PopupActionProvider)}.
* {@link Tool#addPopupActionProvider(PopupActionProvider)}.
*/
public interface PopupActionProvider {
@ -46,5 +46,5 @@ public interface PopupActionProvider {
* @param context the ActionContext
* @return list of temporary popup actions; return null if there are no popup actions
*/
public List<DockingActionIf> getPopupActions(DockingTool tool, ActionContext context);
public List<DockingActionIf> getPopupActions(Tool tool, ActionContext context);
}

View file

@ -15,7 +15,7 @@
*/
package docking.actions;
import docking.DockingTool;
import docking.Tool;
import docking.action.DockingActionIf;
import docking.tool.ToolConstants;
import docking.widgets.table.GTable;
@ -33,7 +33,7 @@ public class SharedActionRegistry {
* @param tool the tool
* @param toolActions the tool action manager
*/
public static void installSharedActions(DockingTool tool, ToolActions toolActions) {
public static void installSharedActions(Tool tool, ToolActions toolActions) {
GTable.createSharedActions(tool, toolActions, ToolConstants.SHARED_OWNER);
}
}

View file

@ -55,7 +55,7 @@ public class ToolActions implements DockingToolActions, PropertyChangeListener {
private Map<String, SharedStubKeyBindingAction> sharedActionMap = new HashMap<>();
private ToolOptions keyBindingOptions;
private DockingTool dockingTool;
private Tool dockingTool;
private KeyBindingsManager keyBindingsManager;
/**
@ -64,7 +64,7 @@ public class ToolActions implements DockingToolActions, PropertyChangeListener {
* @param tool tool using this ActionManager
* @param actionToGuiHelper the class that takes actions and maps them to GUI widgets
*/
public ToolActions(DockingTool tool, ActionToGuiHelper actionToGuiHelper) {
public ToolActions(Tool tool, ActionToGuiHelper actionToGuiHelper) {
this.dockingTool = tool;
this.actionGuiHelper = actionToGuiHelper;
this.keyBindingsManager = new KeyBindingsManager(tool);

View file

@ -150,8 +150,7 @@ public abstract class MultiStateDockingAction<T> extends DockingAction {
DockingWindowManager manager = DockingWindowManager.getActiveInstance();
ComponentProvider provider = manager.getActiveComponentProvider();
ActionContext localContext = provider == null ? null : provider.getActionContext(null);
final ActionContext actionContext =
localContext == null ? manager.getGlobalContext() : localContext;
ActionContext actionContext = localContext == null ? new ActionContext() : localContext;
return actionContext;
}

View file

@ -189,33 +189,23 @@ public class ToolBarItemManager implements PropertyChangeListener, ActionListene
@Override
public void actionPerformed(ActionEvent event) {
DockingWindowManager.clearMouseOverHelp();
ActionContext localContext = getActionContext();
ActionContext globalContext = null;
if (windowManager != null) {
globalContext = windowManager.getGlobalContext();
ActionContext context = getActionContext();
if (!toolBarAction.isValidContext(context)) {
return;
}
ActionContext tempContext = null;
if (toolBarAction.isValidContext(localContext)) {
tempContext = localContext; // we prefer the local over the global context if valid
}
else if (toolBarAction.isValidGlobalContext(globalContext)) {
tempContext = globalContext;
}
else {
return; // context is not valid, nothing to do
}
tempContext.setSourceObject(event.getSource());
final ActionContext finalContext = tempContext;
context.setSourceObject(event.getSource());
// this gives the UI some time to repaint before executing the action
SwingUtilities.invokeLater(() -> {
if (toolBarAction.isEnabledForContext(finalContext)) {
if (toolBarAction.isValidContext(context) &&
toolBarAction.isEnabledForContext(context)) {
if (toolBarAction instanceof ToggleDockingActionIf) {
ToggleDockingActionIf toggleAction = (ToggleDockingActionIf) toolBarAction;
toggleAction.setSelected(!toggleAction.isSelected());
}
toolBarAction.actionPerformed(finalContext);
toolBarAction.actionPerformed(context);
}
});
}

View file

@ -1098,7 +1098,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @param name the name to match
* @return the matching actions; empty list if no matches
*/
public static Set<DockingActionIf> getActionsByName(DockingTool tool, String name) {
public static Set<DockingActionIf> getActionsByName(Tool tool, String name) {
Set<DockingActionIf> result = new HashSet<>();
@ -1119,7 +1119,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @param name the owner's name to match
* @return the matching actions; empty list if no matches
*/
public static Set<DockingActionIf> getActionsByOwner(DockingTool tool, String name) {
public static Set<DockingActionIf> getActionsByOwner(Tool tool, String name) {
return tool.getDockingActionsByOwnerName(name);
}
@ -1132,7 +1132,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @param name the owner's name to match
* @return the matching actions; empty list if no matches
*/
public static Set<DockingActionIf> getActionsByOwnerAndName(DockingTool tool, String owner,
public static Set<DockingActionIf> getActionsByOwnerAndName(Tool tool, String owner,
String name) {
Set<DockingActionIf> ownerActions = tool.getDockingActionsByOwnerName(owner);
return ownerActions.stream()
@ -1143,7 +1143,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
/**
* Finds the singular tool action by the given name. If more than one action exists with
* that name, then an exception is thrown. If you want more than one matching action,
* the call {@link #getActionsByName(DockingTool, String)} instead.
* the call {@link #getActionsByName(Tool, String)} instead.
*
* <P>Note: more specific test case subclasses provide other methods for finding actions
* when you have an owner name (which is usually the plugin name).
@ -1152,7 +1152,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @param name the name to match
* @return the matching action; null if no matching action can be found
*/
public static DockingActionIf getAction(DockingTool tool, String name) {
public static DockingActionIf getAction(Tool tool, String name) {
Set<DockingActionIf> actions = getActionsByName(tool, name);
if (actions.isEmpty()) {
@ -1169,7 +1169,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
/**
* Finds the action by the given owner name and action name.
* If you do not know the owner name, then use
* the call {@link #getActionsByName(DockingTool, String)} instead (this will not include
* the call {@link #getActionsByName(Tool, String)} instead (this will not include
* reserved system actions).
*
* <P>Note: more specific test case subclasses provide other methods for finding actions
@ -1180,7 +1180,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @param name the name to match
* @return the matching action; null if no matching action can be found
*/
public static DockingActionIf getAction(DockingTool tool, String owner, String name) {
public static DockingActionIf getAction(Tool tool, String owner, String name) {
Set<DockingActionIf> actions = getActionsByOwnerAndName(tool, owner, name);
if (actions.isEmpty()) {
return null;
@ -1203,7 +1203,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @return the action
*/
public static DockingActionIf getLocalAction(ComponentProvider provider, String actionName) {
DockingTool tool = provider.getTool();
Tool tool = provider.getTool();
DockingToolActions toolActions = tool.getToolActions();
DockingActionIf action = toolActions.getLocalAction(provider, actionName);
return action;
@ -1862,7 +1862,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
* @param name the name of the provider to show
* @return the newly shown provider
*/
public ComponentProvider showProvider(DockingTool tool, String name) {
public ComponentProvider showProvider(Tool tool, String name) {
ComponentProvider provider = tool.getComponentProvider(name);
tool.showComponentProvider(provider, true);
return provider;
@ -1870,7 +1870,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
/**
* Closes the given provider. You could just call
* {@link DockingTool#removeComponentProvider(ComponentProvider)}, but some providers have extra
* {@link Tool#removeComponentProvider(ComponentProvider)}, but some providers have extra
* logic that happens when {@link ComponentProvider#closeComponent()} is called. This will
* likely change in the future.
*

View file

@ -15,10 +15,10 @@
*/
package docking.tool.util;
import docking.DockingTool;
import docking.Tool;
/**
* An interface to house constants used by the {@link DockingTool}
* An interface to house constants used by the {@link Tool}
*/
public interface DockingToolConstants {

View file

@ -1203,7 +1203,7 @@ public class GTable extends JTable {
GTableToCSV.writeCSVUsingColunns(file, GTable.this, columnList);
}
public static void createSharedActions(DockingTool tool, ToolActions toolActions,
public static void createSharedActions(Tool tool, ToolActions toolActions,
String owner) {
String actionMenuGroup = "zzzTableGroup";

View file

@ -54,7 +54,7 @@ public class SharedKeyBindingDockingActionTest extends AbstractDockingTest {
private SpyErrorLogger spyLogger = new SpyErrorLogger();
private DockingTool tool;
private Tool tool;
@Before
public void setUp() {

View file

@ -23,9 +23,10 @@ import javax.swing.ImageIcon;
import docking.actions.ToolActions;
import docking.framework.ApplicationInformationDisplayFactory;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.util.ServiceListener;
/**
* A Test Double of the {@link DockingTool} that provides minimal tool functionality, such
* A Test Double of the {@link Tool} that provides minimal tool functionality, such
* as the {@link DockingWindowManager}
*/
public class FakeDockingTool extends AbstractDockingTool {
@ -62,4 +63,19 @@ public class FakeDockingTool extends AbstractDockingTool {
public void close() {
// stub
}
@Override
public <T> T getService(Class<T> serviceClass) {
return null;
}
@Override
public void addServiceListener(ServiceListener listener) {
// stub
}
@Override
public void removeServiceListener(ServiceListener listener) {
// stub
}
}

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -59,11 +59,11 @@ public abstract class VisualGraphComponentProvider<V extends VisualVertex,
private List<VisualGraphFeaturette<V, E, G>> subFeatures = new ArrayList<>();
protected VisualGraphComponentProvider(DockingTool tool, String name, String owner) {
protected VisualGraphComponentProvider(Tool tool, String name, String owner) {
super(tool, name, owner);
}
protected VisualGraphComponentProvider(DockingTool tool, String name, String owner,
protected VisualGraphComponentProvider(Tool tool, String name, String owner,
Class<?> contextType) {
super(tool, name, owner, contextType);
}

View file

@ -60,7 +60,7 @@ public class VgSatelliteFeaturette<V extends VisualVertex,
private ToggleDockingAction toggleSatelliteAction;
private ToggleDockingAction dockSatelliteAction;
private DockingTool tool;
private Tool tool;
private VisualGraphView<?, ?, ?> view;
private String owner;
private String providerName;
@ -229,7 +229,7 @@ public class VgSatelliteFeaturette<V extends VisualVertex,
private JComponent satelliteComponent;
public VgUndockedSatelliteProvider(DockingTool tool, JComponent component, String name,
public VgUndockedSatelliteProvider(Tool tool, JComponent component, String name,
String owner, String windowGroup) {
super(tool, name, owner);

View file

@ -185,7 +185,7 @@ public class VisualGraphComponentProviderTest extends AbstractVisualGraphTest {
}
private void setSatelliteVisible(boolean visible) {
DockingTool tool = provider.getTool();
Tool tool = provider.getTool();
String name = "Display Satellite View";
DockingActionIf action = getAction(tool, name);
assertNotNull(name + " not in tool", action);
@ -195,7 +195,7 @@ public class VisualGraphComponentProviderTest extends AbstractVisualGraphTest {
}
private void setSatelliteDocked(boolean docked) {
DockingTool tool = provider.getTool();
Tool tool = provider.getTool();
String name = "Dock Satellite View";
DockingActionIf action = getAction(tool, name);
assertNotNull(name + " not in tool", action);
@ -216,7 +216,7 @@ public class VisualGraphComponentProviderTest extends AbstractVisualGraphTest {
private JComponent component;
protected TestProvider(DockingTool tool) {
protected TestProvider(Tool tool) {
super(tool, "Test VG Provider", "Test Owner");
component = new JPanel();

View file

@ -33,6 +33,7 @@ import ghidra.framework.client.ClientUtil;
import ghidra.framework.client.RepositoryAdapter;
import ghidra.framework.model.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.store.LockException;
import ghidra.util.*;
import ghidra.util.exception.NotFoundException;
@ -274,6 +275,8 @@ class FileActionManager {
/**
* Opens the given project in a task that will show a dialog to block input while opening
* the project in the swing thread.
* @param projectLocator the project locator
* @return true if the project was opened
*/
final boolean openProject(ProjectLocator projectLocator) {
OpenTaskRunnable openRunnable = new OpenTaskRunnable(projectLocator);
@ -285,6 +288,8 @@ class FileActionManager {
/**
* Open an existing project, using a file chooser to specify where the
* existing project folder is stored.
* @param projectLocator the project locator
* @return true if the project was opened
*/
final boolean doOpenProject(ProjectLocator projectLocator) {
String status = "Opened project: " + projectLocator.getName();
@ -346,7 +351,7 @@ class FileActionManager {
/**
* Obtain domain objects from files and lock. If unable to lock
* one or more of the files, none are locked and null is returned.
* @param files
* @param files the files
* @return locked domain objects, or null if unable to lock
* all domain objects.
*/
@ -414,8 +419,6 @@ class FileActionManager {
* This method will always save the FrontEndTool and project, but not the data unless
* <tt>confirmClose</tt> is called.
*
* @param confirmClose true if the confirmation dialog should be
* displayed
* @param isExiting true if we are closing the project because
* Ghidra is exiting
* @return false if user cancels the close operation
@ -428,9 +431,9 @@ class FileActionManager {
}
// check for any changes since last saved
Tool[] runningTools = activeProject.getToolManager().getRunningTools();
for (int i = 0; i < runningTools.length; i++) {
if (!runningTools[i].canClose(isExiting)) {
PluginTool[] runningTools = activeProject.getToolManager().getRunningTools();
for (PluginTool runningTool : runningTools) {
if (!runningTool.canClose(isExiting)) {
return false;
}
}
@ -655,7 +658,7 @@ class FileActionManager {
/**
* Checks the list for read-only files; if any are found, pops up
* a dialog for whether to save now or lose changes.
* @param files list of files which correspond to modified
* @param objs list of files which correspond to modified
* domain objects.
* @return true if there are no read only files OR if the user
* wants to lose his changes; false if the user wants to save the

View file

@ -660,9 +660,9 @@ public class FrontEndPlugin extends Plugin
private ToolTemplate getUpToDateTemplate(ToolTemplate template) {
ToolManager toolManager = activeProject.getToolManager();
Tool[] runningTools = toolManager.getRunningTools();
PluginTool[] runningTools = toolManager.getRunningTools();
String templateName = template.getName();
for (Tool runningTool : runningTools) {
for (PluginTool runningTool : runningTools) {
if (runningTool.getName().equals(templateName)) {
return runningTool.getToolTemplate(true);
}
@ -960,8 +960,8 @@ public class FrontEndPlugin extends Plugin
private boolean isToolRunning(ToolTemplate template) {
ToolManager toolManager = activeProject.getToolManager();
Tool[] runningTools = toolManager.getRunningTools();
for (Tool runningTool : runningTools) {
PluginTool[] runningTools = toolManager.getRunningTools();
for (PluginTool runningTool : runningTools) {
if (runningTool.getToolName().equals(template.getName())) {
return true;
}

View file

@ -745,8 +745,8 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
@Override
public boolean canCloseDomainFile(DomainFile df) {
Tool[] tools = getProject().getToolManager().getRunningTools();
for (Tool tool : tools) {
PluginTool[] tools = getProject().getToolManager().getRunningTools();
for (PluginTool tool : tools) {
DomainFile[] files = tool.getDomainFiles();
for (DomainFile domainFile : files) {
if (df == domainFile) {

View file

@ -34,6 +34,7 @@ import ghidra.app.util.GenericHelpTopics;
import ghidra.framework.client.*;
import ghidra.framework.data.ConvertFileSystem;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.remote.User;
import ghidra.framework.store.local.*;
import ghidra.util.*;
@ -456,10 +457,10 @@ public class ProjectInfoDialog extends DialogComponentProvider {
}
private boolean filesAreOpen() {
Tool[] tools = project.getToolManager().getRunningTools();
PluginTool[] tools = project.getToolManager().getRunningTools();
if (tools.length > 0) {
for (Tool tool : tools) {
for (PluginTool tool : tools) {
if (tool.getDomainFiles().length > 0) {
return true;
}

View file

@ -23,12 +23,14 @@ import java.util.Map;
import javax.swing.*;
import docking.DockingUtils;
import ghidra.framework.model.*;
import ghidra.framework.model.ToolTemplate;
import ghidra.framework.model.Workspace;
import ghidra.framework.plugintool.PluginTool;
class RunningToolsPanel extends JPanel {
private JToolBar runningToolbar;
private FrontEndPlugin plugin;
private Map<Tool, ToolButton> runningTools;
private Map<PluginTool, ToolButton> runningTools;
RunningToolsPanel(FrontEndPlugin plugin, Workspace ws) {
super(new BorderLayout(0, 0));
@ -55,12 +57,13 @@ class RunningToolsPanel extends JPanel {
// remove the default etched border
add(runningToolbar, BorderLayout.CENTER);
runningTools = new HashMap<Tool, ToolButton>(WorkspacePanel.TYPICAL_NUM_RUNNING_TOOLS);
runningTools =
new HashMap<PluginTool, ToolButton>(WorkspacePanel.TYPICAL_NUM_RUNNING_TOOLS);
// populate the toolbar if the workspace has running tools
if (ws != null) {
Tool[] tools = ws.getTools();
for (Tool element : tools) {
PluginTool[] tools = ws.getTools();
for (PluginTool element : tools) {
addTool(element);
}
}
@ -73,7 +76,7 @@ class RunningToolsPanel extends JPanel {
return runningToolbar.getPreferredSize();
}
void addTool(Tool runningTool) {
void addTool(PluginTool runningTool) {
ToolButton toolButton =
new ToolButton(plugin, runningTool, runningTool.getToolTemplate(true));
runningToolbar.add(toolButton);
@ -83,7 +86,7 @@ class RunningToolsPanel extends JPanel {
repaint();
}
void removeTool(Tool tool) {
void removeTool(PluginTool tool) {
ToolButton button = runningTools.get(tool);
if (button == null) {
return;
@ -97,13 +100,13 @@ class RunningToolsPanel extends JPanel {
}
// parameter not used
void toolNameChanged(Tool changedTool) {
void toolNameChanged(PluginTool changedTool) {
}
/**
* Update the tool template for the tool button.
*/
void updateToolButton(Tool tool, ToolTemplate template, Icon icon) {
void updateToolButton(PluginTool tool, ToolTemplate template, Icon icon) {
ToolButton button = runningTools.get(tool);
if (button != null) {

View file

@ -307,7 +307,7 @@ class ToolActionManager implements ToolChestChangeListener {
}
// only enable if project has more than 1 running tool
ToolManager tm = project.getToolManager();
Tool[] runningTools = tm.getRunningTools();
PluginTool[] runningTools = tm.getRunningTools();
connectToolsAction.setEnabled(runningTools.length > 1);
}

View file

@ -65,7 +65,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
private FrontEndPlugin plugin;
private ToolTemplate template;
private Tool associatedRunningTool;
private PluginTool associatedRunningTool;
private DefaultToolChangeListener toolChangeListener;
private ToolServices toolServices;
@ -83,7 +83,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
* Construct a tool label that represents a running tool, using the
* default RUNNING_TOOL icon.
*/
ToolButton(FrontEndPlugin plugin, Tool tool, ToolTemplate template) {
ToolButton(FrontEndPlugin plugin, PluginTool tool, ToolTemplate template) {
this(plugin, tool, template, tool.getIconURL());
setHelpLocation("Run_Tool");
}
@ -91,7 +91,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
/**
* Construct a tool label that represents a running tool.
*/
private ToolButton(FrontEndPlugin plugin, Tool tool, ToolTemplate template,
private ToolButton(FrontEndPlugin plugin, PluginTool tool, ToolTemplate template,
ToolIconURL iconURL) {
super(iconURL.getIcon());
this.plugin = plugin;
@ -298,9 +298,9 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
private void addFromToolButton(ToolButton toolButton) {
plugin.setToolButtonTransferable(null);
Tool tool = null;
PluginTool tool = null;
if (associatedRunningTool != null && toolButton.associatedRunningTool != null) {
final Tool t2 = toolButton.associatedRunningTool;
final PluginTool t2 = toolButton.associatedRunningTool;
SwingUtilities.invokeLater(() -> connectTools(associatedRunningTool, t2));
return;
}
@ -309,14 +309,14 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
if (toolButton.associatedRunningTool == null) {
tool = plugin.getActiveWorkspace().runTool(toolButton.template);
accepted = tool.acceptDomainFiles(associatedRunningTool.getDomainFiles());
final Tool t = tool;
final PluginTool t = tool;
SwingUtilities.invokeLater(() -> connectTools(t, associatedRunningTool));
}
else {
tool = plugin.getActiveWorkspace().runTool(template);
accepted = tool.acceptDomainFiles(toolButton.associatedRunningTool.getDomainFiles());
final Tool t = tool;
final Tool t2 = toolButton.associatedRunningTool;
final PluginTool t = tool;
final PluginTool t2 = toolButton.associatedRunningTool;
SwingUtilities.invokeLater(() -> connectTools(t, t2));
}
@ -328,7 +328,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
/**
* Connect the tools in both directions.
*/
private void connectTools(Tool t1, Tool t2) {
private void connectTools(PluginTool t1, PluginTool t2) {
ToolManager tm = plugin.getActiveProject().getToolManager();
ToolConnection tc = tm.getConnection(t1, t2);
connectAll(tc);
@ -514,7 +514,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
associatedRunningTool.close();
}
Tool getRunningTool() {
PluginTool getRunningTool() {
return associatedRunningTool;
}
@ -570,7 +570,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
Msg.debug(this, "Found root frame without a GhidraGlassPane registered!");
// try to recover without animation
Tool newTool = plugin.getActiveWorkspace().runTool(template);
PluginTool newTool = plugin.getActiveWorkspace().runTool(template);
openDomainFiles(newTool, domainFiles);
finishedCallback.run();
return;
@ -621,7 +621,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
try {
// cleanup any residual painting effects
toolGlassPane.paintImmediately(toolGlassPane.getBounds());
Tool newTool = plugin.getActiveWorkspace().runTool(template);
PluginTool newTool = plugin.getActiveWorkspace().runTool(template);
openDomainFiles(newTool, domainFiles);
}
finally {
@ -640,7 +640,7 @@ class ToolButton extends EmptyBorderButton implements Draggable, Droppable {
zoomRunner.run();
}
private void openDomainFiles(Tool tool, DomainFile[] domainFiles) {
private void openDomainFiles(PluginTool tool, DomainFile[] domainFiles) {
if (domainFiles == null) {
return;
}

Some files were not shown because too many files have changed in this diff Show more