Merge remote-tracking branch 'origin/GT-2925-dragonmacher-window-menu-key-bindings'

This commit is contained in:
Ryan Kurtz
2019-07-15 16:12:09 -04:00
200 changed files with 3955 additions and 3195 deletions
@@ -73,14 +73,15 @@ public class SampleProgramTreePlugin extends ProgramPlugin {
public void actionPerformed(ActionContext context) {
modularize();
}
@Override
public boolean isEnabledForContext(ActionContext context) {
return currentProgram != null;
}
};
action.setMenuBarData(
new MenuData(new String[] { "Misc", "Create Sample Tree" }, null, null));
action.setEnabled(false);
action.setDescription("Plugin to create a program tree and modularize accordingly");
enableOnProgram(action);
tool.addAction(action);
}// end of createActions()
@@ -32,7 +32,6 @@ import ghidra.program.util.ProgramChangeRecord;
import ghidra.util.HelpLocation;
import ghidra.util.Msg;
/**
* Sample plugin for dealing with Programs. The base class handles
* the event processing and enabling/disabling of actions. This
@@ -51,107 +50,98 @@ import ghidra.util.Msg;
//@formatter:on
public class TemplateProgramPlugin extends ProgramPlugin implements DomainObjectListener {
private DockingAction action;
private DockingAction action;
/*******************************************************************
*
* Standard Plugin Constructor
*
*******************************************************************/
public TemplateProgramPlugin(PluginTool tool) {
/*******************************************************************
*
* Standard Plugin Constructor
*
*******************************************************************/
public TemplateProgramPlugin(PluginTool tool) {
super(tool,
true, // true means this plugin consumes ProgramLocation events
false); // false means this plugin does not consume
// ProgramSelection events
// the base class ProgramPlugin handles all the event registering
super(tool, true, // true means this plugin consumes ProgramLocation events
false); // false means this plugin does not consume
// ProgramSelection events
// the base class ProgramPlugin handles all the event registering
// set up list of actions.
setupActions();
}
/**
* This is the callback method for DomainObjectChangedEvents.
*/
public void domainObjectChanged(DomainObjectChangedEvent ev) {
for (int i=0; i< ev.numRecords(); i++) {
DomainObjectChangeRecord record = ev.getChangeRecord(i);
if (record instanceof ProgramChangeRecord) {
@SuppressWarnings("unused")
ProgramChangeRecord r = (ProgramChangeRecord)record;
// code for processing the record...
// ...
}
}
}
// set up list of actions.
setupActions();
}
/**
* Called when the program is opened.
*/
@Override
protected void programActivated(Program program) {
program.addListener(this);
}
/**
* Called when the program is closed.
*/
@Override
protected void programDeactivated(Program program) {
program.removeListener(this);
}
/**
* This is the callback method for DomainObjectChangedEvents.
*/
@Override
public void domainObjectChanged(DomainObjectChangedEvent ev) {
for (int i = 0; i < ev.numRecords(); i++) {
DomainObjectChangeRecord record = ev.getChangeRecord(i);
if (record instanceof ProgramChangeRecord) {
@SuppressWarnings("unused")
ProgramChangeRecord r = (ProgramChangeRecord) record;
// code for processing the record...
// ...
}
}
}
/*******************************************************************
********************************************************************
**
**
** Function 1
**
**
********************************************************************
*******************************************************************/
private void Function_1 () {
// do something with a program location
Msg.info(this, getPluginDescription().getName()
+ ": Program Location==> " + currentLocation.getAddress());
}
/**
* Called when the program is opened.
*/
@Override
protected void programActivated(Program program) {
program.addListener(this);
}
/**
* Called when the program is closed.
*/
@Override
protected void programDeactivated(Program program) {
program.removeListener(this);
}
/**
* Set up Actions
*/
private void setupActions() {
/*******************************************************************
********************************************************************
**
**
** Function 1
**
**
********************************************************************
*******************************************************************/
private void Function_1() {
// do something with a program location
Msg.info(this, getPluginDescription().getName() + ": Program Location==> " +
currentLocation.getAddress());
}
//
// Function 1
//
action = new DockingAction("Function 1 Code", getName() ) {
@Override
public void actionPerformed(ActionContext e) {
Function_1();
}
@Override
public boolean isValidContext( ActionContext context ) {
return context instanceof ListingActionContext;
}
};
action.setEnabled( false );
/**
* Set up Actions
*/
private void setupActions() {
//
// Function 1
//
action = new DockingAction("Function 1 Code", getName()) {
@Override
public void actionPerformed(ActionContext e) {
Function_1();
}
action.setMenuBarData( new MenuData(
new String[]{"Misc", "Menu","Menu item 1"}, null, null ) );
// call method in base class to enable this action when a
// program location event comes in; disable it when focus is
// lost; it will be disable when the program is closed
enableOnLocation(action);
action.setHelpLocation(new HelpLocation("SampleHelpTopic",
"TemplateProgramPlugin_Anchor_Name"));
tool.addAction(action);
}
@Override
public boolean isValidContext(ActionContext context) {
return context instanceof ListingActionContext;
}
};
action.setEnabled(false);
action.setMenuBarData(
new MenuData(new String[] { "Misc", "Menu", "Menu item 1" }, null, null));
action.setHelpLocation(
new HelpLocation("SampleHelpTopic", "TemplateProgramPlugin_Anchor_Name"));
tool.addAction(action);
}
}
@@ -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.
@@ -23,20 +22,18 @@ import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.FunctionIterator;
public class DeleteFunctionDefaultPlates extends GhidraScript {
public class DeleteFunctionDefaultPlatesScript extends GhidraScript {
private static String DEFAULT_PLATE = " FUNCTION";
/* (non-Javadoc)
* @see ghidra.app.script.GhidraScript#run()
*/
@Override
public void run() throws Exception {
public void run() throws Exception {
AddressSetView set = currentProgram.getMemory();
if (currentSelection != null && !currentSelection.isEmpty()) {
set = currentSelection;
}
int updateCount=0;
int updateCount = 0;
FunctionIterator iter = currentProgram.getFunctionManager().getFunctions(set, true);
while (iter.hasNext()) {
Function function = iter.next();
@@ -47,7 +44,7 @@ public class DeleteFunctionDefaultPlates extends GhidraScript {
}
}
if (updateCount > 0) {
String cmt = updateCount > 1? "comments" : "comment";
String cmt = updateCount > 1 ? "comments" : "comment";
println("Removed " + updateCount + " default plate " + cmt + ".");
}
else {
@@ -13,7 +13,7 @@
</HEAD>
<BODY>
<H1><A name="Code_Browser"></A>Listing View</H1>
<H1><A name="Code_Browser"></A><A name="Listing"></A>Listing View</H1>
<P>The Listing View is the main windows for displaying and working with a program's instruction
and data.</P>
@@ -476,6 +476,17 @@
<P class="providedbyplugin">Provided by: <I>Go To Next-Previous Code Unit</I> plugin</P>
</BLOCKQUOTE>
<!--
This file is different than most, since it has multiple plugins contributing to the
content. Add some space at the bottom of the file to separate this last contribution
-->
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<H2><A name="Next_Previous_Function"></A>Next/Previous Function</H2>
@@ -497,8 +508,21 @@
<P> This action navigates the cursor to the closest function entry point that is at an
address less than the current address. The default keybinding is <TT><B>Control-Up&nbsp;Arrow</B></TT>.</P>
</BLOCKQUOTE>
</BLOCKQUOTE>
<P class="providedbyplugin">Provided by: <I>CodeBrowser</I> plugin</P>
<P class="providedbyplugin">Provided by: <I>CodeBrowser</I> plugin</P>
</BLOCKQUOTE>
<!--
This file is different than most, since it has multiple plugins contributing to the
content. Add some space at the bottom of the file to separate this last contribution
-->
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<H2><A name="Navigation_History"></A>Navigation History</H2>
@@ -554,9 +578,54 @@
<P>After clearing the history, the <IMG src="images/left.png" border="0">&nbsp;and <IMG
src="images/right.png" border="0"> buttons are disabled</P>
</BLOCKQUOTE>
</BLOCKQUOTE>
<P class="providedbyplugin">Provided by: <I>Next/Previous</I> plugin</P>
</BLOCKQUOTE>
<!--
This file is different than most, since it has multiple plugins contributing to the
content. Add some space at the bottom of the file to separate this contribution.
-->
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<H2>Component Provider Navigation</H2>
<BLOCKQUOTE>
<P>
This section lists actions that allow the user to navigate between component providers.
</P>
<H3><A name="Navigation_Previous_Provider"></A>Go To Last Active Component</H3>
<BLOCKQUOTE>
<P>
Allows the user to switch focus back to the previously focused component provider.
</P>
</BLOCKQUOTE>
<P class="providedbyplugin">Provided by: <I>ProviderNavigation</I> plugin</P>
</BLOCKQUOTE>
<!--
This file is different than most, since it has multiple plugins contributing to the
content. Add some space at the bottom of the file to separate this contribution.
-->
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<P class="providedbyplugin">Provided by: <I>Next/Previous</I> plugin</P>
<P class="relatedtopic">Related Topics:</P>
@@ -30,7 +30,7 @@
completely different instruction sets. To disassemble properly, the mode register must be set
at the address where the disassembly begins.</P>
<H2><A name="RegisterManager"></A>Register Manager</H2>
<H2><A name="Register_Manager"></A>Register Manager</H2>
<BLOCKQUOTE>
<P>The <I>Register Manager</I> displays the assigned values of registers at addresses within
@@ -22,7 +22,6 @@ import javax.swing.ToolTipManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import docking.DockingWindowManager;
import docking.framework.SplashScreen;
import ghidra.base.help.GhidraHelpService;
import ghidra.framework.Application;
@@ -86,7 +85,6 @@ public class GhidraRun implements GhidraLaunchable {
updateSplashScreenStatusMessage("Populating Ghidra help...");
GhidraHelpService.install();
DockingWindowManager.enableDiagnosticActions(SystemUtilities.isInDevelopmentMode());
ExtensionUtils.cleanupUninstalledExtensions();
// Allows handling of old content which did not have a content type property
@@ -22,8 +22,7 @@ import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import docking.action.*;
import ghidra.app.plugin.core.navigation.FindAppliedDataTypesService;
import ghidra.app.plugin.core.navigation.locationreferences.ReferenceUtils;
import ghidra.framework.plugintool.PluginTool;
@@ -44,7 +43,7 @@ public abstract class AbstractFindReferencesDataTypeAction extends DockingAction
protected AbstractFindReferencesDataTypeAction(PluginTool tool, String name, String owner,
KeyStroke defaultKeyStroke) {
super(name, owner);
super(name, owner, KeyBindingType.SHARED);
this.tool = tool;
setHelpLocation(new HelpLocation("LocationReferencesPlugin", "Data_Types"));
@@ -69,11 +68,6 @@ public abstract class AbstractFindReferencesDataTypeAction extends DockingAction
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
@Override
public boolean isEnabledForContext(ActionContext context) {
DataType dataType = getDataType(context);
@@ -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,28 +15,28 @@
*/
package ghidra.app.context;
import java.util.Set;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.KeyBindingType;
public abstract class ListingContextAction extends DockingAction {
public ListingContextAction(String name, String owner) {
this(name, owner, true);
}
public ListingContextAction(String name, String owner, boolean isKeyBindingManaged) {
super(name, owner, isKeyBindingManaged);
public ListingContextAction(String name, String owner) {
super(name, owner);
}
public ListingContextAction(String name, String owner, KeyBindingType kbType) {
super(name, owner, kbType);
}
@Override
public boolean isEnabledForContext(ActionContext context) {
if (!(context instanceof ListingActionContext)) {
return false;
}
return isEnabledForContext((ListingActionContext)context);
return isEnabledForContext((ListingActionContext) context);
}
@Override
@@ -45,38 +44,38 @@ public abstract class ListingContextAction extends DockingAction {
if (!(context instanceof ListingActionContext)) {
return false;
}
return isValidContext((ListingActionContext)context);
return isValidContext((ListingActionContext) context);
}
@Override
public boolean isAddToPopup(ActionContext context) {
if (!(context instanceof ListingActionContext)) {
return false;
}
return isAddToPopup((ListingActionContext)context);
return isAddToPopup((ListingActionContext) context);
}
@Override
public void actionPerformed(ActionContext context) {
actionPerformed((ListingActionContext)context);
actionPerformed((ListingActionContext) context);
}
protected boolean isAddToPopup(ListingActionContext context) {
return isEnabledForContext( context );
return isEnabledForContext(context);
}
protected boolean isValidContext(ListingActionContext context) {
return true;
}
protected boolean isEnabledForContext(ListingActionContext context) {
return true;
}
protected void actionPerformed(ListingActionContext context) {
// clients need to override this method
}
@Override
public boolean shouldAddToWindow(boolean isMainWindow, Set<Class<?>> contextTypes) {
for (Class<?> class1 : contextTypes) {
@@ -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,10 @@
*/
package ghidra.app.plugin;
import java.util.ArrayList;
import docking.ActionContext;
import docking.action.DockingAction;
import ghidra.app.events.*;
import ghidra.app.services.GoToService;
import ghidra.framework.plugintool.*;
@@ -25,10 +28,6 @@ import ghidra.program.model.listing.*;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
import java.util.ArrayList;
import docking.action.DockingAction;
/**
* Base class to handle common program events: Program Open/Close,
* Program Location, Program Selection, and Program Highlight.
@@ -87,10 +86,10 @@ public abstract class ProgramPlugin extends Plugin {
}
registerEventConsumed(ProgramOpenedPluginEvent.class);
registerEventConsumed(ProgramClosedPluginEvent.class);
programActionList = new ArrayList<DockingAction>(3);
locationActionList = new ArrayList<DockingAction>(3);
selectionActionList = new ArrayList<DockingAction>(3);
highlightActionList = new ArrayList<DockingAction>(3);
programActionList = new ArrayList<>(3);
locationActionList = new ArrayList<>(3);
selectionActionList = new ArrayList<>(3);
highlightActionList = new ArrayList<>(3);
}
public ProgramPlugin(PluginTool tool, boolean consumeLocationChange,
@@ -201,7 +200,10 @@ public abstract class ProgramPlugin extends Plugin {
* the program is closed.
* @throws IllegalArgumentException if this action was called for
* another enableOnXXX(PlugAction) method.
* @deprecated {@link ActionContext} is now used for action enablement. Deprecated in 9.1; to
* be removed no sooner than two versions after that.
*/
@Deprecated
protected void enableOnProgram(DockingAction action) {
if (locationActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to location action list");
@@ -222,7 +224,10 @@ public abstract class ProgramPlugin extends Plugin {
* is null.
* @throws IllegalArgumentException if this action was called for
* another enableOnXXX(PlugAction) method.
* @deprecated {@link ActionContext} is now used for action enablement. Deprecated in 9.1; to
* be removed no sooner than two versions after that.
*/
@Deprecated
protected void enableOnLocation(DockingAction action) {
if (programActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to program action list");
@@ -243,7 +248,10 @@ public abstract class ProgramPlugin extends Plugin {
* the selection is null or empty.
* @throws IllegalArgumentException if this action was called for
* another enableOnXXX(PlugAction) method.
* @deprecated {@link ActionContext} is now used for action enablement. Deprecated in 9.1; to
* be removed no sooner than two versions after that.
*/
@Deprecated
protected void enableOnSelection(DockingAction action) {
if (programActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to program action list");
@@ -263,7 +271,10 @@ public abstract class ProgramPlugin extends Plugin {
* the highlight is null or empty.
* @throws IllegalArgumentException if this action was called for
* another enableOnXXX(PlugAction) method.
* @deprecated {@link ActionContext} is now used for action enablement. Deprecated in 9.1; to
* be removed no sooner than two versions after that.
*/
@Deprecated
protected void enableOnHighlight(DockingAction action) {
if (programActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to program action list");
@@ -378,8 +389,8 @@ public abstract class ProgramPlugin extends Plugin {
if (currentProgram == null) {
return;
}
firePluginEvent(new ProgramSelectionPluginEvent(getName(), new ProgramSelection(set),
currentProgram));
firePluginEvent(
new ProgramSelectionPluginEvent(getName(), new ProgramSelection(set), currentProgram));
}
/**
@@ -22,7 +22,6 @@ import javax.swing.Icon;
import javax.swing.SwingUtilities;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.widgets.table.GTable;
import ghidra.app.CorePluginPackage;
@@ -72,7 +71,6 @@ public class BookmarkPlugin extends ProgramPlugin
private BookmarkProvider provider;
private DockingAction addAction;
private DockingAction showAction;
private DockingAction deleteAction;
private CreateBookmarkDialog createDialog;
private GoToService goToService;
@@ -113,19 +111,6 @@ public class BookmarkPlugin extends ProgramPlugin
addAction.setEnabled(true);
tool.addAction(addAction);
showAction = new DockingAction("Show Bookmarks", getName()) {
@Override
public void actionPerformed(ActionContext context) {
tool.showComponentProvider(provider, true);
}
};
showAction.setKeyBindingData(
new KeyBindingData(KeyEvent.VK_B, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
showAction.setToolBarData(new ToolBarData(BookmarkNavigator.NOTE_ICON, "View"));
showAction.setDescription("Display All Bookmarks");
tool.addAction(showAction);
MultiIconBuilder builder = new MultiIconBuilder(Icons.CONFIGURE_FILTER_ICON);
builder.addLowerRightIcon(ResourceManager.loadImage("images/check.png"));
Icon filterTypesChanged = builder.build();
@@ -213,10 +198,6 @@ public class BookmarkPlugin extends ProgramPlugin
addAction.dispose();
addAction = null;
}
if (showAction != null) {
showAction.dispose();
showAction = null;
}
if (provider != null) {
provider.dispose();
provider = null;
@@ -17,6 +17,7 @@ package ghidra.app.plugin.core.bookmark;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.*;
@@ -24,8 +25,8 @@ import javax.swing.*;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumn;
import docking.ActionContext;
import docking.WindowPosition;
import docking.*;
import docking.action.KeyBindingData;
import docking.widgets.combobox.GhidraComboBox;
import docking.widgets.table.GTable;
import ghidra.app.context.ProgramActionContext;
@@ -58,6 +59,9 @@ public class BookmarkProvider extends ComponentProviderAdapter {
super(tool, "Bookmarks", plugin.getName(), ProgramActionContext.class);
setIcon(BookmarkNavigator.NOTE_ICON);
addToToolbar();
setKeyBinding(new KeyBindingData(KeyEvent.VK_B, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
model = new BookmarkTableModel(tool, null);
threadedTablePanel = new GhidraThreadedTablePanel<>(model);
@@ -62,12 +62,14 @@ public class CallTreePlugin extends ProgramPlugin {
ResourceManager.loadImage("images/arrow_rotate_clockwise.png");
private List<CallTreeProvider> providers = new ArrayList<>();
private DockingAction showProviderAction;
private DockingAction showCallTreeFromMenuAction;
private CallTreeProvider primaryProvider;
public CallTreePlugin(PluginTool tool) {
super(tool, true, false, false);
createActions();
primaryProvider = new CallTreeProvider(this, true);
}
@Override
@@ -116,32 +118,44 @@ public class CallTreePlugin extends ProgramPlugin {
}
private void createActions() {
showProviderAction = new DockingAction("Show Function Call Trees", getName()) {
@Override
public void actionPerformed(ActionContext context) {
showOrCreateNewCallTree(currentLocation);
}
// use the name of the provider so that the shared key binding data will get used
String actionName = CallTreeProvider.TITLE;
showCallTreeFromMenuAction =
new DockingAction(actionName, getName(), KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
showOrCreateNewCallTree(currentLocation);
}
@Override
public boolean isAddToPopup(ActionContext context) {
return (context instanceof ListingActionContext);
}
};
showProviderAction.setPopupMenuData(new MenuData(
@Override
public boolean isAddToPopup(ActionContext context) {
return (context instanceof ListingActionContext);
}
};
showCallTreeFromMenuAction.setPopupMenuData(new MenuData(
new String[] { "References", "Show Call Trees" }, PROVIDER_ICON, "ShowReferencesTo"));
showProviderAction.setToolBarData(new ToolBarData(PROVIDER_ICON, "View"));
showProviderAction.setHelpLocation(new HelpLocation("CallTreePlugin", "Call_Tree_Plugin"));
tool.addAction(showProviderAction);
showCallTreeFromMenuAction.setHelpLocation(
new HelpLocation("CallTreePlugin", "Call_Tree_Plugin"));
tool.addAction(showCallTreeFromMenuAction);
}
private void creatAndShowProvider() {
CallTreeProvider provider = new CallTreeProvider(this);
CallTreeProvider provider = new CallTreeProvider(this, false);
providers.add(provider);
provider.initialize(currentProgram, currentLocation);
tool.showComponentProvider(provider, true);
}
CallTreeProvider getPrimaryProvider() {
return primaryProvider;
}
DockingAction getShowCallTreeFromMenuAction() {
return showCallTreeFromMenuAction;
}
ProgramLocation getCurrentLocation() {
return currentLocation;
}
@@ -57,7 +57,7 @@ import resources.ResourceManager;
public class CallTreeProvider extends ComponentProviderAdapter implements DomainObjectListener {
static final String EXPAND_ACTION_NAME = "Fully Expand Selected Nodes";
private static final String TITLE = "Function Call Trees";
static final String TITLE = "Function Call Trees";
private static final Icon EMPTY_ICON = ResourceManager.loadImage("images/EmptyIcon16.gif");
private static final Icon EXPAND_ICON = Icons.EXPAND_ALL_ICON;
private static final Icon COLLAPSE_ICON = Icons.COLLAPSE_ALL_ICON;
@@ -74,6 +74,7 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
private JSplitPane splitPane;
private GTree incomingTree;
private GTree outgoingTree;
private boolean isPrimary;
private SwingUpdateManager reloadUpdateManager = new SwingUpdateManager(500, () -> doUpdate());
@@ -93,20 +94,21 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
private AtomicInteger recurseDepth = new AtomicInteger();
private NumberIcon recurseIcon;
public CallTreeProvider(CallTreePlugin plugin) {
public CallTreeProvider(CallTreePlugin plugin, boolean isPrimary) {
super(plugin.getTool(), TITLE, plugin.getName());
this.plugin = plugin;
this.isPrimary = isPrimary;
component = buildComponent();
// try to give the trees a suitable amount of space by default
component.setPreferredSize(new Dimension(800, 400));
setTransient();
setWindowMenuGroup(TITLE);
setDefaultWindowPosition(WindowPosition.BOTTOM);
setIcon(CallTreePlugin.PROVIDER_ICON);
addToToolbar();
setHelpLocation(new HelpLocation(plugin.getName(), "Call_Tree_Plugin"));
addToTool();
@@ -430,7 +432,11 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
}
}
};
navigateIncomingToggleAction.setSelected(false);
// note: the default state is to follow navigation events for the primary provider;
// non-primary providers will function like snapshots of the function with
// which they were activated.
navigateIncomingToggleAction.setSelected(isPrimary);
navigateIncomingToggleAction.setToolBarData(new ToolBarData(
Icons.NAVIGATE_ON_INCOMING_EVENT_ICON, navigationOptionsToolbarGroup, "2"));
navigateIncomingToggleAction.setDescription(HTMLUtilities.toHTML("Incoming Navigation" +
@@ -818,7 +824,9 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
@Override
public void componentHidden() {
plugin.removeProvider(this);
if (!isPrimary) {
plugin.removeProvider(this);
}
}
private void reload() {
@@ -869,6 +877,7 @@ public class CallTreeProvider extends ComponentProviderAdapter implements Domain
// changes, which means we will get here while setting the location, but our program
// will have been null'ed out.
currentProgram = plugin.getCurrentProgram();
currentProgram.addListener(this);
}
Function function = plugin.getFunction(location);
@@ -915,18 +915,13 @@ public class CodeBrowserPlugin extends Plugin
}
};
// note: this action gets added later when the TableService is added
tableFromSelectionAction.setEnabled(false);
tableFromSelectionAction.setMenuBarData(new MenuData(
new String[] { ToolConstants.MENU_SELECTION, "Create Table From Selection" }, null,
"SelectUtils"));
tableFromSelectionAction
.setHelpLocation(new HelpLocation("CodeBrowserPlugin", "Selection_Table"));
// don't add the actions initially if the service isn't there
TableService tableService = tool.getService(TableService.class);
if (tableService != null) {
tool.addAction(tableFromSelectionAction);
}
tableFromSelectionAction.setHelpLocation(
new HelpLocation("CodeBrowserPlugin", "Selection_Table"));
}
private GhidraProgramTableModel<Address> createTableModel(CodeUnitIterator iterator,
@@ -1001,8 +996,8 @@ public class CodeBrowserPlugin extends Plugin
public boolean goToField(Address a, String fieldName, int occurrence, int row, int col,
boolean scroll) {
boolean result = SystemUtilities
.runSwingNow(() -> doGoToField(a, fieldName, occurrence, row, col, scroll));
boolean result = SystemUtilities.runSwingNow(
() -> doGoToField(a, fieldName, occurrence, row, col, scroll));
return result;
}
@@ -36,7 +36,6 @@ import docking.widgets.fieldpanel.FieldPanel;
import docking.widgets.fieldpanel.HoverHandler;
import docking.widgets.fieldpanel.internal.FieldPanelCoordinator;
import docking.widgets.fieldpanel.support.*;
import ghidra.GhidraOptions;
import ghidra.app.nav.*;
import ghidra.app.plugin.core.clipboard.CodeBrowserClipboardProvider;
import ghidra.app.plugin.core.codebrowser.actions.*;
@@ -54,6 +53,7 @@ import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.util.*;
import ghidra.util.HelpLocation;
import ghidra.util.Swing;
import resources.ResourceManager;
public class CodeViewerProvider extends NavigatableComponentProviderAdapter
@@ -62,8 +62,6 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
private static final String TITLE = "Listing: ";
private static final String OPERAND_OPTIONS_PREFIX = GhidraOptions.OPERAND_GROUP_TITLE + ".";
private static final Icon LISTING_FORMAT_EXPAND_ICON =
ResourceManager.loadImage("images/field.header.down.png");
private static final Icon LISTING_FORMAT_COLLAPSE_ICON =
@@ -92,9 +90,6 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
private ProgramDropProvider curDropProvider;
private ToggleDockingAction toggleHoverAction;
//TODO - Need to improve CodeUnit.getRepresentation format options interface before adding this
//TODO private ToggleOperandMarkupAction[] toggleOperandMarkupActions;
private ProgramLocation currentLocation;
private ListingPanel otherPanel;
@@ -117,17 +112,26 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
private MultiListingLayoutModel multiModel;
public CodeViewerProvider(CodeBrowserPluginInterface plugin, FormatManager formatMgr,
boolean connected) {
super(plugin.getTool(), plugin.getName(), plugin.getName(), CodeViewerActionContext.class);
boolean isConnected) {
super(plugin.getTool(), "Listing", plugin.getName(), CodeViewerActionContext.class);
this.plugin = plugin;
this.formatMgr = formatMgr;
setConnected(connected);
setConnected(isConnected);
setIcon(ResourceManager.loadImage("images/Browser.gif"));
if (!isConnected) {
setTransient();
}
else {
addToToolbar();
}
setHelpLocation(new HelpLocation("CodeBrowserPlugin", "Code_Browser"));
setDefaultWindowPosition(WindowPosition.RIGHT);
setIcon(ResourceManager.loadImage("images/Browser.gif"));
listingPanel = new ListingPanel(formatMgr);
listingPanel.enablePropertyBasedColorModel(true);
decorationPanel = new ListingPanelContainer(listingPanel, connected);
decorationPanel = new ListingPanelContainer(listingPanel, isConnected);
ListingHighlightProvider listingHighlighter =
createListingHighlighter(listingPanel, tool, decorationPanel);
highlighterAdapter = new ProgramHighlighterProvider(listingHighlighter);
@@ -136,7 +140,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
setWindowMenuGroup("Listing");
setIntraGroupPosition(WindowPosition.RIGHT);
setTitle(connected ? TITLE : "[" + TITLE + "]");
setTitle(isConnected ? TITLE : "[" + TITLE + "]");
fieldNavigator = new FieldNavigator(tool, this);
listingPanel.addButtonPressedListener(fieldNavigator);
addToTool();
@@ -150,6 +154,12 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
tool.addPopupListener(this);
}
@Override
public boolean isSnapshot() {
// we are a snapshot when we are 'disconnected'
return !isConnected();
}
/**
* @return true if this listing is backed by a dynamic data source (e.g., debugger)
*/
@@ -399,9 +409,9 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
}
void updateTitle() {
String subTitle = program == null ? "" : program.getDomainFile().getName();
String newTitle = isConnected() ? TITLE : "[" + TITLE + "]";
setTitle(newTitle + subTitle);
String subTitle = program == null ? "" : ' ' + program.getDomainFile().getName();
String newTitle = isConnected() ? TITLE : "[" + TITLE + subTitle + "]";
setTitle(newTitle);
}
@Override
@@ -882,7 +892,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
final ViewerPosition vp = listingPanel.getFieldPanel().getViewerPosition();
// invoke later to give the window manage a chance to create the new window
// (its done in an invoke later)
SwingUtilities.invokeLater(() -> {
Swing.runLater(() -> {
newProvider.doSetProgram(program);
newProvider.listingPanel.getFieldPanel().setViewerPosition(vp.getIndex(),
vp.getXOffset(), vp.getYOffset());
@@ -949,7 +959,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
class ToggleHeaderAction extends ToggleDockingAction {
ToggleHeaderAction() {
super("Toggle Header", CodeViewerProvider.this.getName());
super("Toggle Header", plugin.getName());
setEnabled(true);
setToolBarData(new ToolBarData(LISTING_FORMAT_EXPAND_ICON, "zzz"));
@@ -960,14 +970,14 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
public void actionPerformed(ActionContext context) {
boolean show = !listingPanel.isHeaderShowing();
listingPanel.showHeader(show);
getToolBarData()
.setIcon(show ? LISTING_FORMAT_COLLAPSE_ICON : LISTING_FORMAT_EXPAND_ICON);
getToolBarData().setIcon(
show ? LISTING_FORMAT_COLLAPSE_ICON : LISTING_FORMAT_EXPAND_ICON);
}
}
class ToggleHoverAction extends ToggleDockingAction {
private class ToggleHoverAction extends ToggleDockingAction {
ToggleHoverAction() {
super("Toggle Mouse Hover Popups", CodeViewerProvider.this.getName());
super("Toggle Mouse Hover Popups", CodeViewerProvider.this.getOwner());
setEnabled(true);
setToolBarData(new ToolBarData(HOVER_ON_ICON, "yyyz"));
setSelected(true);
@@ -987,31 +997,6 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
}
}
class ToggleOperandMarkupAction extends ToggleDockingAction {
final String optionName;
ToggleOperandMarkupAction(String operandOption) {
super(operandOption, CodeViewerProvider.this.getName());
this.optionName = OPERAND_OPTIONS_PREFIX + operandOption;
boolean state =
tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS).getBoolean(optionName, true);
setMenuBarData(new MenuData(new String[] { operandOption }));
setSelected(state);
setEnabled(true);
setHelpLocation(new HelpLocation("CodeBrowserPlugin", "Operands_Field"));
}
public Object getOptionName() {
return optionName;
}
@Override
public void actionPerformed(ActionContext context) {
boolean state = isSelected();
tool.getOptions(GhidraOptions.CATEGORY_BROWSER_FIELDS).setBoolean(optionName, state);
}
}
/**
* A class that allows clients to install transient highlighters while keeping the
* middle-mouse highlighting on at the same time.
@@ -15,8 +15,6 @@
*/
package ghidra.app.plugin.core.codebrowser.actions;
import java.util.Set;
import docking.ActionContext;
@@ -24,21 +22,17 @@ import docking.action.DockingAction;
import ghidra.app.plugin.core.codebrowser.CodeViewerActionContext;
public abstract class CodeViewerContextAction extends DockingAction {
public CodeViewerContextAction(String name, String owner) {
this(name, owner, true);
}
public CodeViewerContextAction(String name, String owner, boolean isKeyBindingManaged) {
super(name, owner, isKeyBindingManaged);
public CodeViewerContextAction(String name, String owner) {
super(name, owner);
}
@Override
public boolean isEnabledForContext(ActionContext context) {
if (!(context instanceof CodeViewerActionContext)) {
return false;
}
return isEnabledForContext((CodeViewerActionContext)context);
return isEnabledForContext((CodeViewerActionContext) context);
}
@Override
@@ -46,26 +40,25 @@ public abstract class CodeViewerContextAction extends DockingAction {
if (!(context instanceof CodeViewerActionContext)) {
return false;
}
return isValidContext((CodeViewerActionContext)context);
return isValidContext((CodeViewerActionContext) context);
}
@Override
public boolean isAddToPopup(ActionContext context) {
if (!(context instanceof CodeViewerActionContext)) {
return false;
}
return isAddToPopup((CodeViewerActionContext)context);
return isAddToPopup((CodeViewerActionContext) context);
}
@Override
public void actionPerformed(ActionContext context) {
actionPerformed((CodeViewerActionContext)context);
actionPerformed((CodeViewerActionContext) context);
}
protected boolean isAddToPopup(CodeViewerActionContext context) {
return isEnabledForContext( context );
return isEnabledForContext(context);
}
protected boolean isValidContext(CodeViewerActionContext context) {
return true;
@@ -76,9 +69,9 @@ public abstract class CodeViewerContextAction extends DockingAction {
}
protected void actionPerformed(CodeViewerActionContext context) {
}
@Override
public boolean shouldAddToWindow(boolean isMainWindow, Set<Class<?>> contextTypes) {
for (Class<?> class1 : contextTypes) {
@@ -39,7 +39,7 @@ public class CollapseAllDataAction extends ProgramLocationContextAction {
private CodeViewerProvider provider;
public CollapseAllDataAction(CodeViewerProvider provider) {
super("Collapse All Data", provider.getName());
super("Collapse All Data", provider.getOwner());
this.provider = provider;
setPopupMenuData(new MenuData(new String[] { "Collapse All Data" }, null, "Structure"));
@@ -95,8 +95,7 @@ public class CollapseAllDataAction extends ProgramLocationContextAction {
ProgramLocation location = context.getLocation();
Data data = getTopLevelComponentData(location);
TaskLauncher.launchModal("Collapse Data",
monitor -> model.closeAllData(data, monitor));
TaskLauncher.launchModal("Collapse Data", monitor -> model.closeAllData(data, monitor));
}
private ListingModel getModel() {
@@ -36,7 +36,7 @@ public class ExpandAllDataAction extends ProgramLocationContextAction {
private CodeViewerProvider provider;
public ExpandAllDataAction(CodeViewerProvider provider) {
super("Expand All Data", provider.getName());
super("Expand All Data", provider.getOwner());
this.provider = provider;
setPopupMenuData(new MenuData(new String[] { "Expand All Data" }, null, "Structure"));
@@ -39,7 +39,7 @@ public class ToggleExpandCollapseDataAction extends ProgramLocationContextAction
private CodeViewerProvider provider;
public ToggleExpandCollapseDataAction(CodeViewerProvider provider) {
super("Toggle Expand/Collapse Data", provider.getName());
super("Toggle Expand/Collapse Data", provider.getOwner());
this.provider = provider;
setPopupMenuData(
@@ -15,7 +15,6 @@
*/
package ghidra.app.plugin.core.commentwindow;
import docking.ActionContext;
import docking.action.DockingAction;
import ghidra.app.CorePluginPackage;
import ghidra.app.events.ProgramSelectionPluginEvent;
@@ -186,13 +185,7 @@ public class CommentWindowPlugin extends ProgramPlugin implements DomainObjectLi
private void createActions() {
selectAction = new MakeProgramSelectionAction(getName(), provider.getTable()) {
@Override
protected void makeSelection(ActionContext context) {
selectComment(provider.selectComment());
}
};
selectAction = new MakeProgramSelectionAction(this, provider.getTable());
tool.addLocalAction(provider, selectAction);
DockingAction selectionAction = new SelectionNavigationAction(this, provider.getTable());
@@ -15,15 +15,14 @@
*/
package ghidra.app.plugin.core.compositeeditor;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
import java.awt.event.ActionListener;
import javax.swing.*;
import docking.action.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
/**
* CompositeEditorAction is an abstract class that should be extended for any
@@ -45,13 +44,14 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
public static final String EDIT_ACTION_PREFIX = "Editor: ";
/**
* Defines an <code>Action</code> object with the specified
* description string and a the specified icon.
*/
public CompositeEditorTableAction(CompositeEditorProvider provider, String name, String group,
String[] popupPath, String[] menuPath, ImageIcon icon) {
super(name, provider.plugin.getName());
this(provider, name, group, popupPath, menuPath, icon, KeyBindingType.INDIVIDUAL);
}
public CompositeEditorTableAction(CompositeEditorProvider provider, String name, String group,
String[] popupPath, String[] menuPath, ImageIcon icon, KeyBindingType kbType) {
super(name, provider.plugin.getName(), kbType);
this.provider = provider;
model = provider.getModel();
if (menuPath != null) {
@@ -70,9 +70,6 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
setHelpLocation(new HelpLocation(provider.getHelpTopic(), helpAnchor));
}
/* (non-Javadoc)
* @see ghidra.framework.plugintool.PluginAction#dispose()
*/
@Override
public void dispose() {
model.removeCompositeEditorModelListener(this);
@@ -93,64 +90,53 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
}
}
@Override
abstract public void adjustEnablement();
public String getHelpName() {
String actionName = getName();
if (actionName.startsWith(CompositeEditorTableAction.EDIT_ACTION_PREFIX)) {
actionName = actionName.substring(CompositeEditorTableAction.EDIT_ACTION_PREFIX.length());
actionName =
actionName.substring(CompositeEditorTableAction.EDIT_ACTION_PREFIX.length());
}
return actionName;
}
/* (non-Javadoc)
* @see ghidra.app.plugin.stackeditor.EditorModelListener#selectionChanged()
*/
@Override
public void selectionChanged() {
adjustEnablement();
}
/* (non-Javadoc)
* @see ghidra.app.plugin.stackeditor.EditorModelListener#editStateChanged(int)
*/
public void editStateChanged(int i) {
adjustEnablement();
}
/* (non-Javadoc)
* @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#compositeEditStateChanged(int)
*/
@Override
public void compositeEditStateChanged(int type) {
adjustEnablement();
}
/* (non-Javadoc)
* @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#endFieldEditing()
*/
@Override
public void endFieldEditing() {
adjustEnablement();
}
/* (non-Javadoc)
* @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#componentDataChanged()
*/
@Override
public void componentDataChanged() {
adjustEnablement();
}
/* (non-Javadoc)
* @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#compositeInfoChanged()
*/
@Override
public void compositeInfoChanged() {
adjustEnablement();
}
/* (non-Javadoc)
* @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#statusChanged(java.lang.String, boolean)
*/
@Override
public void statusChanged(String message, boolean beep) {
// we are an action; don't care about status messages
}
@Override
public void showUndefinedStateChanged(boolean showUndefinedBytes) {
adjustEnablement();
}
@@ -19,6 +19,7 @@ import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.KeyBindingData;
import docking.action.KeyBindingType;
import ghidra.program.model.data.CycleGroup;
/**
@@ -32,7 +33,7 @@ public class CycleGroupAction extends CompositeEditorTableAction {
public CycleGroupAction(CompositeEditorProvider provider, CycleGroup cycleGroup) {
super(provider, cycleGroup.getName(), GROUP_NAME,
new String[] { "Cycle", cycleGroup.getName() },
new String[] { "Cycle", cycleGroup.getName() }, null);
new String[] { "Cycle", cycleGroup.getName() }, null, KeyBindingType.SHARED);
this.cycleGroup = cycleGroup;
initKeyStroke(cycleGroup.getDefaultKeyStroke());
@@ -46,11 +47,6 @@ public class CycleGroupAction extends CompositeEditorTableAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
public CycleGroup getCycleGroup() {
return cycleGroup;
}
@@ -64,11 +64,11 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
private PrintWriter stdin;
private Program currentProgram;
public ConsoleComponentProvider(PluginTool tool, String name) {
super(tool, name, name);
public ConsoleComponentProvider(PluginTool tool, String owner) {
super(tool, "Console", owner);
setDefaultWindowPosition(WindowPosition.BOTTOM);
setHelpLocation(new HelpLocation(getName(), "console"));
setHelpLocation(new HelpLocation(owner, owner));
setIcon(ResourceManager.loadImage(CONSOLE_GIF));
setWindowMenuGroup("Console");
setSubTitle("Scripting");
@@ -94,7 +94,7 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
private void createOptions() {
ToolOptions options = tool.getOptions("Console");
HelpLocation help = new HelpLocation(getName(), "ConsolePlugin");
HelpLocation help = new HelpLocation(getOwner(), getOwner());
options.registerOption(FONT_OPTION_LABEL, DEFAULT_FONT, help, FONT_DESCRIPTION);
options.setOptionsHelpLocation(help);
font = options.getFont(FONT_OPTION_LABEL, DEFAULT_FONT);
@@ -260,7 +260,7 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
}
private void createActions() {
clearAction = new DockingAction("Clear Console", getName()) {
clearAction = new DockingAction("Clear Console", getOwner()) {
@Override
public void actionPerformed(ActionContext context) {
@@ -273,7 +273,7 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter
clearAction.setEnabled(true);
scrollAction = new ToggleDockingAction("Scroll Lock", getName()) {
scrollAction = new ToggleDockingAction("Scroll Lock", getOwner()) {
@Override
public void actionPerformed(ActionContext context) {
textPane.setScrollLock(isSelected());
@@ -20,8 +20,7 @@ import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.util.datatype.DataTypeSelectionDialog;
import ghidra.framework.plugintool.PluginTool;
@@ -43,7 +42,7 @@ public class ChooseDataTypeAction extends DockingAction {
private final static String ACTION_NAME = "Choose Data Type";
public ChooseDataTypeAction(DataPlugin plugin) {
super(ACTION_NAME, plugin.getName(), false);
super(ACTION_NAME, plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
initKeyStroke(KEY_BINDING);
@@ -57,11 +56,6 @@ public class ChooseDataTypeAction extends DockingAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
@Override
public void actionPerformed(ActionContext context) {
ListingActionContext programActionContext =
@@ -44,7 +44,7 @@ class CreateArrayAction extends DockingAction {
private DataPlugin plugin;
public CreateArrayAction(DataPlugin plugin) {
super("Define Array", plugin.getName(), false);
super("Define Array", plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
setPopupMenuData(new MenuData(CREATE_ARRAY_POPUP_MENU, "BasicData"));
@@ -61,11 +61,6 @@ class CreateArrayAction extends DockingAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
@Override
public void actionPerformed(ActionContext context) {
ListingActionContext programActionContext =
@@ -18,8 +18,7 @@ package ghidra.app.plugin.core.data;
import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import docking.action.*;
import ghidra.app.cmd.data.*;
import ghidra.app.context.ListingActionContext;
import ghidra.framework.cmd.BackgroundCommand;
@@ -41,7 +40,7 @@ public class CycleGroupAction extends DockingAction {
private CycleGroup cycleGroup;
CycleGroupAction(CycleGroup group, DataPlugin plugin) {
super(group.getName(), plugin.getName(), false);
super(group.getName(), plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
this.cycleGroup = group;
@@ -56,11 +55,6 @@ public class CycleGroupAction extends DockingAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
@Override
public void dispose() {
cycleGroup = null;
@@ -17,8 +17,7 @@ package ghidra.app.plugin.core.data;
import javax.swing.KeyStroke;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
import ghidra.program.model.data.*;
@@ -45,7 +44,7 @@ class DataAction extends ListingContextAction {
* @param plugin the plugin that owns this action
*/
public DataAction(String name, String group, DataType dataType, DataPlugin plugin) {
super(name, plugin.getName(), false);
super(name, plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
this.dataType = dataType;
@@ -54,11 +53,6 @@ class DataAction extends ListingContextAction {
initKeyStroke(getDefaultKeyStroke());
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
protected KeyStroke getDefaultKeyStroke() {
return null; // we have no default, but our subclasses may
}
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import javax.swing.tree.TreePath;
@@ -60,7 +59,6 @@ import ghidra.util.HelpLocation;
import ghidra.util.Msg;
import ghidra.util.datastruct.LRUMap;
import ghidra.util.task.TaskLauncher;
import resources.ResourceManager;
/**
* Plugin to pop up the dialog to manage data types in the program
@@ -82,14 +80,12 @@ import resources.ResourceManager;
public class DataTypeManagerPlugin extends ProgramPlugin
implements DomainObjectListener, DataTypeManagerService, PopupListener {
final static String DATA_TYPES_ICON = "images/dataTypes.png";
private static final String SEACH_PROVIDER_NAME = "Search DataTypes Provider";
private static final int RECENTLY_USED_CACHE_SIZE = 10;
private static final String STANDARD_ARCHIVE_MENU = "Standard Archive";
private static final String RECENTLY_OPENED_MENU = "Recently Opened Archive";
private DockingAction manageDataAction;
private DataTypeManagerHandler dataTypeManagerHandler;
private DataTypesProvider provider;
private OpenVersionedFileDialog openDialog;
@@ -126,12 +122,10 @@ public class DataTypeManagerPlugin extends ProgramPlugin
@Override
public void archiveClosed(Archive archive) {
if (archive instanceof ProjectArchive) {
// Program is handled by deactivation event
((ProjectArchive) archive).getDomainObject().removeListener(
DataTypeManagerPlugin.this);
}
// Program is handled by deactivation.
// Otherwise, don't care.
}
@Override
@@ -467,21 +461,6 @@ public class DataTypeManagerPlugin extends ProgramPlugin
* Create the actions for the menu on the tool.
*/
private void createActions() {
// create action
manageDataAction = new DockingAction("Data Type Manager", getName()) {
@Override
public void actionPerformed(ActionContext context) {
tool.showComponentProvider(provider, true);
}
};
ImageIcon dtIcon = ResourceManager.loadImage(DATA_TYPES_ICON);
manageDataAction.setToolBarData(new ToolBarData(dtIcon, "View"));
manageDataAction.setDescription("Display Data Types");
manageDataAction.setHelpLocation(provider.getHelpLocation());
tool.addAction(manageDataAction);
createStandardArchivesMenu();
}
@@ -57,6 +57,8 @@ import resources.ResourceManager;
import util.HistoryList;
public class DataTypesProvider extends ComponentProviderAdapter {
private static final String DATA_TYPES_ICON = "images/dataTypes.png";
private static final String TITLE = "Data Type Manager";
private static final String POINTER_FILTER_STATE = "PointerFilterState";
private static final String ARRAY_FILTER_STATE = "ArrayFilterState";
@@ -95,9 +97,12 @@ public class DataTypesProvider extends ComponentProviderAdapter {
public DataTypesProvider(DataTypeManagerPlugin plugin, String providerName) {
super(plugin.getTool(), providerName, plugin.getName(), DataTypesActionContext.class);
setTitle(TITLE);
this.plugin = plugin;
setTitle(TITLE);
setIcon(ResourceManager.loadImage(DATA_TYPES_ICON));
addToToolbar();
navigationHistory.setAllowDuplicates(true);
buildComponent();
@@ -106,11 +111,6 @@ public class DataTypesProvider extends ComponentProviderAdapter {
createLocalActions();
}
@Override
public ImageIcon getIcon() {
return ResourceManager.loadImage(DataTypeManagerPlugin.DATA_TYPES_ICON);
}
/**
* This creates all the actions for opening/creating data type archives.
* It also creates the action for refreshing the built-in data types
@@ -123,7 +123,7 @@ class NextPreviousDataTypeAction extends MultiActionDockingAction {
private class NavigationAction extends DockingAction {
private NavigationAction(DataType dt) {
super("DataTypeNavigationAction_" + ++navigationActionIdCount, owner, false);
super("DataTypeNavigationAction_" + ++navigationActionIdCount, owner);
setMenuBarData(new MenuData(new String[] { dt.getDisplayName() }));
setEnabled(true);
@@ -18,7 +18,6 @@ package ghidra.app.plugin.core.datawindow;
import java.util.ArrayList;
import java.util.Iterator;
import docking.ActionContext;
import docking.action.DockingAction;
import ghidra.app.CorePluginPackage;
import ghidra.app.events.ProgramSelectionPluginEvent;
@@ -180,13 +179,7 @@ public class DataWindowPlugin extends ProgramPlugin implements DomainObjectListe
*/
private void createActions() {
selectAction = new MakeProgramSelectionAction(getName(), provider.getTable()) {
@Override
protected void makeSelection(ActionContext context) {
selectData(provider.selectData());
}
};
selectAction = new MakeProgramSelectionAction(this, provider.getTable());
tool.addLocalAction(provider, selectAction);
filterAction = new FilterAction(this);
@@ -23,6 +23,8 @@ import java.util.Map.Entry;
import javax.swing.*;
import org.apache.commons.lang3.StringUtils;
import docking.*;
import docking.action.ToggleDockingAction;
import docking.action.ToolBarData;
@@ -34,7 +36,6 @@ import docking.widgets.filter.FilterTextField;
import docking.widgets.label.GLabel;
import ghidra.program.model.listing.Program;
import ghidra.util.HelpLocation;
import ghidra.util.StringUtilities;
import ghidra.util.task.SwingUpdateManager;
import resources.Icons;
@@ -351,7 +352,7 @@ class FilterAction extends ToggleDockingAction {
String curType = itr.next();
Boolean lEnabled = typeEnabledMap.get(curType);
StringBuffer buildMetaCurTypeBuff = new StringBuffer(curType);
int firstIndex = StringUtilities.indexOfIgnoreCase(curType, filteredText, 0);
int firstIndex = StringUtils.indexOfIgnoreCase(curType, filteredText, 0);
int lastIndex = firstIndex + filteredText.length();
buildMetaCurTypeBuff.insert(lastIndex, "</b>");//THIS MUST ALWAYS COME BEFORE FIRST INDEX (FOR NO MATH on INDEX)
buildMetaCurTypeBuff.insert(firstIndex, "<b>");
@@ -409,7 +410,7 @@ class FilterAction extends ToggleDockingAction {
while (iteratorIndex.hasNext()) {
Entry<String, Boolean> entry = iteratorIndex.next();
String checkboxName = entry.getKey();
if (StringUtilities.containsIgnoreCase(checkboxName, filteredText)) {
if (StringUtils.containsIgnoreCase(checkboxName, filteredText)) {
checkboxNameList.add(checkboxName);
}
}
@@ -25,7 +25,7 @@ import javax.swing.event.DocumentListener;
import docking.ActionContext;
import docking.DialogComponentProvider;
import docking.action.*;
import docking.action.DockingAction;
import docking.widgets.checkbox.GCheckBox;
import docking.widgets.label.GDLabel;
import docking.widgets.label.GLabel;
@@ -40,11 +40,13 @@ import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.util.ProgramSelection;
import ghidra.util.HelpLocation;
import ghidra.util.table.*;
import ghidra.util.table.actions.MakeProgramSelectionAction;
import ghidra.util.task.Task;
import resources.ResourceManager;
public class AddressTableDialog extends DialogComponentProvider {
static final int DEFAULT_MINIMUM_TABLE_SIZE = 3;
private static final int DEFAULT_MINIMUM_TABLE_SIZE = 3;
private static final String DIALOG_NAME = "Search For Address Tables";
private JPanel mainPanel;
private String[] blockData;
private AutoTableDisassemblerPlugin plugin;
@@ -67,7 +69,7 @@ public class AddressTableDialog extends DialogComponentProvider {
private GhidraThreadedTablePanel<AddressTable> resultsTablePanel;
public AddressTableDialog(AutoTableDisassemblerPlugin plugin) {
super("Search For Address Tables", false, true, true, true);
super(DIALOG_NAME, false, true, true, true);
setHelpLocation(
new HelpLocation(HelpTopics.SEARCH, AutoTableDisassemblerPlugin.SEARCH_ACTION_NAME));
this.plugin = plugin;
@@ -125,8 +127,7 @@ public class AddressTableDialog extends DialogComponentProvider {
JPanel makeTablePanel = new JPanel(new FlowLayout());
makeTableButton = new JButton("Make Table");
makeTableButton.setToolTipText(
"Make a table of addresses at the selected location(s).");
makeTableButton.setToolTipText("Make a table of addresses at the selected location(s).");
makeTablePanel.add(makeTableButton);
makeTableButton.setEnabled(false);
makeTableButton.addActionListener(e -> plugin.makeTable(resultsTable.getSelectedRows()));
@@ -175,8 +176,7 @@ public class AddressTableDialog extends DialogComponentProvider {
skipLabel = new GDLabel("Skip Length: ");
skipField = new JTextField(5);
skipField.setName("Skip");
skipLabel.setToolTipText(
"Number of bytes to skip between found addresses in a table.");
skipLabel.setToolTipText("Number of bytes to skip between found addresses in a table.");
skipField.setText("0");
JPanel alignPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
@@ -194,8 +194,7 @@ public class AddressTableDialog extends DialogComponentProvider {
selectionButton = new GCheckBox("Search Selection");
selectionButton.setSelected(false);
selectionButton.setToolTipText(
"If checked, search only the current selection.");
selectionButton.setToolTipText("If checked, search only the current selection.");
JPanel searchOptionsWestPanel = new JPanel(new GridLayout(2, 1));
searchOptionsWestPanel.add(selectionButton);
@@ -233,8 +232,7 @@ public class AddressTableDialog extends DialogComponentProvider {
"Label the top of the address table and all members of the table.");
offsetLabel = new GDLabel("Offset: ");
offsetLabel.setToolTipText(
"Offset from the beginning of the selected table(s)");
offsetLabel.setToolTipText("Offset from the beginning of the selected table(s)");
offsetLabel.setEnabled(false);
JLabel viewOffsetLabel = new GDLabel(" ");
@@ -242,8 +240,7 @@ public class AddressTableDialog extends DialogComponentProvider {
viewOffset = new HintTextField(20);
viewOffset.setName("viewOffset");
viewOffset.setToolTipText(
"Address of the selected table starting at the given offset");
viewOffset.setToolTipText("Address of the selected table starting at the given offset");
viewOffset.setHintText("table start address");
viewOffset.showHint();
@@ -526,20 +523,31 @@ public class AddressTableDialog extends DialogComponentProvider {
}
private void createAction() {
DockingAction selectAction =
new DockingAction("Make Selection", "AsciiFinderDialog", false) {
@Override
public void actionPerformed(ActionContext context) {
makeSelection();
DockingAction selectAction = new MakeProgramSelectionAction(plugin, resultsTable) {
@Override
protected ProgramSelection makeSelection(ActionContext context) {
Program program = plugin.getProgram();
AddressSet set = new AddressSet();
AutoTableDisassemblerModel model = plugin.getModel();
int[] selectedRows = resultsTable.getSelectedRows();
for (int selectedRow : selectedRows) {
Address selectedAddress = model.getAddress(selectedRow);
AddressTable addrTab = model.get(selectedAddress);
if (addrTab != null) {
set.addRange(selectedAddress,
selectedAddress.add(addrTab.getByteLength() - 1));
}
}
};
selectAction.setDescription("Make a selection using selected rows");
selectAction.setEnabled(true);
Icon icon = ResourceManager.loadImage("images/text_align_justify.png");
selectAction.setPopupMenuData(new MenuData(new String[] { "Make Selection" }, icon));
selectAction.setToolBarData(new ToolBarData(icon));
selectAction.setHelpLocation(
new HelpLocation(HelpTopics.SEARCH, "Search_Make_Selection_Address_Tables"));
ProgramSelection selection = new ProgramSelection(set);
if (!set.isEmpty()) {
plugin.firePluginEvent(
new ProgramSelectionPluginEvent(plugin.getName(), selection, program));
}
return selection;
}
};
selectionNavigationAction = new SelectionNavigationAction(plugin, resultsTable);
selectionNavigationAction.setHelpLocation(
@@ -548,7 +556,7 @@ public class AddressTableDialog extends DialogComponentProvider {
addAction(selectAction);
}
private void makeSelection() {
private void doMakeSelection() {
Program program = plugin.getProgram();
AddressSet set = new AddressSet();
AutoTableDisassemblerModel model = plugin.getModel();
@@ -140,15 +140,19 @@ public class AutoTableDisassemblerPlugin extends ProgramPlugin implements Domain
public void actionPerformed(ActionContext context) {
startDialog();
}
@Override
public boolean isEnabledForContext(ActionContext context) {
return currentProgram != null;
}
};
findTableAction.setHelpLocation(
new HelpLocation(HelpTopics.SEARCH, findTableAction.getName()));
findTableAction.setMenuBarData(
new MenuData(new String[] { ToolConstants.MENU_SEARCH, "For Address Tables..." }, null,
"search for"));
findTableAction.setDescription(getPluginDescription().getDescription());
enableOnLocation(findTableAction);
tool.addAction(findTableAction);
} // end of createActions()
@@ -54,12 +54,7 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
public EquateTablePlugin(PluginTool tool) {
super(tool, true, false);
updateMgr = new SwingUpdateManager(1000, 3000, new Runnable() {
@Override
public void run() {
provider.updateEquates();
}
});
updateMgr = new SwingUpdateManager(1000, 3000, () -> provider.updateEquates());
provider = new EquateTableProvider(this);
}
@@ -131,10 +126,10 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
ev.containsEvent(ChangeManager.DOCR_CODE_ADDED) ||
ev.containsEvent(ChangeManager.DOCR_CODE_MOVED) ||
ev.containsEvent(ChangeManager.DOCR_CODE_REMOVED) ||
ev.containsEvent(ChangeManager.DOCR_CODE_REMOVED) ||
ev.containsEvent(ChangeManager.DOCR_DATA_TYPE_CHANGED)) {
updateMgr.update();
}
@@ -154,9 +149,6 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
provider.programClosed();
}
/**
* Delete the list of equates.
*/
void deleteEquates(List<Equate> equates) {
if (equates.isEmpty()) {
return;
@@ -173,13 +165,11 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
}
}
String title = "Delete Equate" + (equates.size() > 1 ? "s" : "") + "?";
String msg =
"Do you really want to delete the equate" + (equates.size() > 1 ? "s" : "") + ": " +
equates + " ?" + "\n\n NOTE: All references will be removed.";
String msg = "Do you really want to delete the equate" + (equates.size() > 1 ? "s" : "") +
": " + equates + " ?" + "\n\n NOTE: All references will be removed.";
int option =
OptionDialog.showOptionDialog(provider.getComponent(), title, msg, "Delete",
OptionDialog.QUESTION_MESSAGE);
int option = OptionDialog.showOptionDialog(provider.getComponent(), title, msg, "Delete",
OptionDialog.QUESTION_MESSAGE);
if (option != OptionDialog.CANCEL_OPTION) {
tool.execute(new RemoveEquateCmd(equateNames, getTool()), currentProgram);
@@ -236,26 +226,24 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
}
/**
* If the equate exists, checks to make sure the value matches the
* current scalar value.
* If the equate exists, checks to make sure the value matches the current scalar value
*
* @param dialog the dialog whose status area should be set with any error messages.
* @param equateStr the candidate equate name for the set or rename operation.
* @param equate the equate to check
* @param equateStr the candidate equate name for the set or rename operation
* @return true if valid
*/
boolean isValid(Equate equate, String equateStr) {
// these are valid in the sense that they represent a clear or remove operation.
// these are valid in the sense that they represent a clear or remove operation
if (equateStr == null || equateStr.length() <= 0) {
return false;
}
// look up the new equate string
EquateTable equateTable = currentProgram.getEquateTable();
Equate newEquate = equateTable.getEquate(equateStr);
if (newEquate != null && !newEquate.equals(equate)) {
Msg.showInfo(getClass(), provider.getComponent(), "Rename Equate Failed!", "Equate " +
equateStr + " exists with value 0x" + Long.toHexString(newEquate.getValue()) +
" (" + newEquate.getValue() + ")");
Msg.showInfo(getClass(), provider.getComponent(), "Rename Equate Failed!",
"Equate " + equateStr + " exists with value 0x" +
Long.toHexString(newEquate.getValue()) + " (" + newEquate.getValue() + ")");
return false;
}
return true;
@@ -41,7 +41,7 @@ public class ChooseDataTypeAction extends DockingAction {
private FunctionPlugin plugin;
public ChooseDataTypeAction(FunctionPlugin plugin) {
super(ACTION_NAME, plugin.getName(), false);
super(ACTION_NAME, plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
setHelpLocation(new HelpLocation("DataTypeEditors", "DataTypeSelectionDialog"));
@@ -57,11 +57,6 @@ public class ChooseDataTypeAction extends DockingAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
@Override
public void actionPerformed(ActionContext actionContext) {
ListingActionContext context = (ListingActionContext) actionContext.getContextObject();
@@ -19,8 +19,7 @@ import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.action.*;
import docking.widgets.dialogs.NumberInputDialog;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
@@ -37,7 +36,7 @@ class CreateArrayAction extends ListingContextAction {
private FunctionPlugin plugin;
public CreateArrayAction(FunctionPlugin plugin) {
super("Define Array", plugin.getName(), false);
super("Define Array", plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
setPopupMenu(plugin.getDataActionMenuName(null));
@@ -54,11 +53,6 @@ class CreateArrayAction extends ListingContextAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
private void setPopupMenu(String name) {
setPopupMenuData(new MenuData(
new String[] { FunctionPlugin.SET_DATA_TYPE_PULLRIGHT, "Array..." }, null, "Array"));
@@ -17,8 +17,7 @@ package ghidra.app.plugin.core.function;
import javax.swing.KeyStroke;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
import ghidra.app.util.HelpTopics;
@@ -38,7 +37,7 @@ public class CycleGroupAction extends ListingContextAction {
private CycleGroup cycleGroup;
CycleGroupAction(CycleGroup group, FunctionPlugin plugin) {
super(group.getName(), plugin.getName(), false);
super(group.getName(), plugin.getName(), KeyBindingType.SHARED);
this.plugin = plugin;
this.cycleGroup = group;
@@ -56,11 +55,6 @@ public class CycleGroupAction extends ListingContextAction {
setKeyBindingData(new KeyBindingData(keyStroke));
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
private void setPopupMenu(String name, boolean isSignatureAction) {
setPopupMenuData(new MenuData(
new String[] { FunctionPlugin.SET_DATA_TYPE_PULLRIGHT, "Cycle", cycleGroup.getName() },
@@ -17,8 +17,7 @@ package ghidra.app.plugin.core.function;
import javax.swing.KeyStroke;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
import ghidra.program.model.data.DataType;
@@ -41,7 +40,7 @@ class DataAction extends ListingContextAction {
}
public DataAction(String name, String group, DataType dataType, FunctionPlugin plugin) {
super(name, plugin.getName(), false);
super(name, plugin.getName(), KeyBindingType.SHARED);
this.group = group;
this.plugin = plugin;
this.dataType = dataType;
@@ -52,11 +51,6 @@ class DataAction extends ListingContextAction {
initKeyStroke(getDefaultKeyStroke());
}
@Override
public boolean usesSharedKeyBinding() {
return true;
}
protected KeyStroke getDefaultKeyStroke() {
return null; // we have no default, but our subclasses may
}
@@ -15,6 +15,11 @@
*/
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;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
@@ -22,26 +27,19 @@ import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Variable;
import ghidra.program.util.*;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.action.KeyBindingData;
/**
* <CODE>VariableCommentDeleteAction</CODE> allows the user to delete a function variable comment.
*/
class VariableCommentDeleteAction extends ListingContextAction {
/** the plugin associated with this action. */
FunctionPlugin funcPlugin;
/**
* Creates a new action with the given name and associated to the given plugin.
* @param plugin
* the plugin this action is associated with.
*/
* Creates a new action with the given name and associated to the given plugin.
* @param plugin the plugin this action is associated with.
*/
VariableCommentDeleteAction(FunctionPlugin plugin) {
super("Delete Function Variable Comment", plugin.getName(), false);
super("Delete Function Variable Comment", plugin.getName(), KeyBindingType.SHARED);
this.funcPlugin = plugin;
setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));
}
@@ -65,7 +63,6 @@ class VariableCommentDeleteAction extends ListingContextAction {
}
}
// ///////////////////////////////////////////////////////////
/**
* Get a variable using the current location.
*
@@ -43,19 +43,19 @@ class VariableDeleteAction extends ListingContextAction {
* @param plugin the plugin this action is associated with.
*/
VariableDeleteAction(FunctionPlugin plugin) {
super("Delete Function Variable", plugin.getName(), true);
super("Delete Function Variable", plugin.getName());
this.funcPlugin = plugin;
setPopupMenuPath(false);
setKeyBindingData(new KeyBindingData(KeyEvent.VK_DELETE, 0));
}
private void setPopupMenuPath(boolean isParameter) {
setPopupMenuData(new MenuData(new String[] { FunctionPlugin.VARIABLE_MENU_PULLRIGHT,
"Delete " + (isParameter ? "Parameter" : "Local Variable") }, null,
FunctionPlugin.VARIABLE_MENU_SUBGROUP));
setPopupMenuData(new MenuData(
new String[] { FunctionPlugin.VARIABLE_MENU_PULLRIGHT,
"Delete " + (isParameter ? "Parameter" : "Local Variable") },
null, FunctionPlugin.VARIABLE_MENU_SUBGROUP));
}
@Override
@@ -190,18 +190,12 @@ public class FunctionWindowPlugin extends ProgramPlugin implements DomainObjectL
private void addSelectAction() {
selectAction = new MakeProgramSelectionAction(getName(), provider.getTable()) {
@Override
protected void makeSelection(ActionContext context) {
selectFunctions(provider.selectFunctions());
}
};
selectAction = new MakeProgramSelectionAction(this, provider.getTable());
tool.addLocalAction(provider, selectAction);
}
private void addCompareAction() {
compareAction = new DockingAction("Compare Selected Functions", getName(), false) {
compareAction = new DockingAction("Compare Selected Functions", getName()) {
@Override
public void actionPerformed(ActionContext context) {
compareSelectedFunctions();
@@ -16,13 +16,10 @@
package ghidra.app.plugin.core.instructionsearch.ui;
import java.awt.Font;
import java.util.List;
import javax.swing.JToolBar;
import javax.swing.table.TableCellRenderer;
import docking.ActionContext;
import docking.action.DockingActionIf;
import docking.widgets.table.GTable;
import ghidra.app.plugin.core.instructionsearch.model.*;
import ghidra.util.table.GhidraTable;
@@ -109,17 +106,6 @@ public abstract class AbstractInstructionTable extends GhidraTable {
return (InstructionTableDataObject) getModel().getValueAt(row, col);
}
/**
* Must invoke the parent implementation of this to have the context menu
* created.
*
*/
@Override
public List<DockingActionIf> getDockingActions(ActionContext context) {
List<DockingActionIf> list = super.getDockingActions(context);
return list;
}
/**
* Must override so it doesn't return an instance of the base
* {@link TableCellRenderer}, which will override our changes in the
@@ -22,7 +22,6 @@ import java.util.List;
import javax.swing.*;
import docking.ActionContext;
import docking.DockingWindowManager;
import docking.action.DockingActionIf;
import docking.widgets.EmptyBorderButton;
@@ -102,7 +101,7 @@ public class InstructionTable extends AbstractInstructionTable {
* (which is all of them).
*/
@Override
public List<DockingActionIf> getDockingActions(ActionContext context) {
public List<DockingActionIf> getDockingActions() {
return new ArrayList<>();
}
@@ -134,14 +134,12 @@ public class PreviewTable extends AbstractInstructionTable {
/**
* Adds custom context-sensitive menus to the table. This does NOT modify
* any existing menus; it simply adds to them.
*
* @param context the action context
*/
@Override
public List<DockingActionIf> getDockingActions(ActionContext context) {
public List<DockingActionIf> getDockingActions() {
// Invoke the base class method to add default menu options.
List<DockingActionIf> list = super.getDockingActions(context);
List<DockingActionIf> list = super.getDockingActions();
// And now add our own.
addCustomMenuItems(list);
@@ -489,7 +487,7 @@ public class PreviewTable extends AbstractInstructionTable {
*/
private void createCopyInstructionWithCommentsAction(String owner) {
copyInstructionWithCommentsAction =
new DockingAction("Selected Instructions (with comments)", owner, false) {
new DockingAction("Selected Instructions (with comments)", owner) {
@Override
public void actionPerformed(ActionContext context) {
int[] selectedRows = PreviewTable.this.getSelectedRows();
@@ -520,7 +518,7 @@ public class PreviewTable extends AbstractInstructionTable {
* as shown in the table.
*/
private void createCopyInstructionAction(String owner) {
copyInstructionAction = new DockingAction("Selected Instructions", owner, false) {
copyInstructionAction = new DockingAction("Selected Instructions", owner) {
@Override
public void actionPerformed(ActionContext context) {
int[] selectedRows = PreviewTable.this.getSelectedRows();
@@ -541,7 +539,7 @@ public class PreviewTable extends AbstractInstructionTable {
* rows, as shown in the table, with no spaces.
*/
private void createCopyNoSpacesAction(String owner) {
copyNoSpacesAction = new DockingAction("Selected instructions (no spaces)", owner, false) {
copyNoSpacesAction = new DockingAction("Selected instructions (no spaces)", owner) {
@Override
public void actionPerformed(ActionContext context) {
int[] selectedRows = PreviewTable.this.getSelectedRows();
@@ -19,7 +19,8 @@ import java.io.*;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JComponent;
import docking.ActionContext;
import docking.action.DockingAction;
@@ -33,12 +34,12 @@ import utility.function.Callback;
public class InterpreterComponentProvider extends ComponentProviderAdapter
implements InterpreterConsole {
private static final String CONSOLE_GIF = "images/monitor.png";
private static final String CLEAR_GIF = "images/erase16.png";
private InterpreterPanel panel;
private InterpreterConnection interpreter;
private ImageIcon icon;
private List<Callback> firstActivationCallbacks;
public InterpreterComponentProvider(InterpreterPanelPlugin plugin,
@@ -54,9 +55,9 @@ public class InterpreterComponentProvider extends ComponentProviderAdapter
addToTool();
createActions();
icon = interpreter.getIcon();
Icon icon = interpreter.getIcon();
if (icon == null) {
ResourceManager.loadImage(CONSOLE_GIF);
icon = ResourceManager.loadImage(CONSOLE_GIF);
}
setIcon(icon);
@@ -107,11 +108,6 @@ public class InterpreterComponentProvider extends ComponentProviderAdapter
addLocalAction(disposeAction);
}
@Override
public Icon getIcon() {
return icon;
}
@Override
public String getWindowSubMenuName() {
return interpreter.getTitle();
@@ -15,6 +15,8 @@
*/
package ghidra.app.plugin.core.memory;
import java.awt.Cursor;
import ghidra.app.CorePluginPackage;
import ghidra.app.events.ProgramLocationPluginEvent;
import ghidra.app.plugin.PluginCategoryNames;
@@ -31,15 +33,6 @@ import ghidra.program.model.mem.MemoryBlock;
import ghidra.program.util.ChangeManager;
import ghidra.program.util.ProgramLocation;
import java.awt.Cursor;
import javax.swing.ImageIcon;
import resources.ResourceManager;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.ToolBarData;
/**
* <CODE>MemoryMapPlugin</CODE> displays a memory map of all blocks in
* the current program's memory. Options for Adding, Editing, and Deleting
@@ -61,20 +54,15 @@ public class MemoryMapPlugin extends ProgramPlugin implements DomainObjectListen
final static Cursor WAIT_CURSOR = new Cursor(Cursor.WAIT_CURSOR);
final static Cursor NORM_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
private DockingAction memViewAction;
private MemoryMapProvider provider;
private GoToService goToService;
private MemoryMapManager memManager;
/**
* Constructor
*/
public MemoryMapPlugin(PluginTool tool) {
super(tool, true, false);
memManager = new MemoryMapManager(this);
provider = new MemoryMapProvider(this);
createActions();
}
/**
@@ -83,9 +71,6 @@ public class MemoryMapPlugin extends ProgramPlugin implements DomainObjectListen
*/
@Override
public void dispose() {
if (memViewAction != null) {
memViewAction.dispose();
}
if (provider != null) {
provider.dispose();
provider = null;
@@ -122,8 +107,9 @@ public class MemoryMapPlugin extends ProgramPlugin implements DomainObjectListen
@Override
protected void init() {
goToService = tool.getService(GoToService.class);
if (currentProgram != null)
if (currentProgram != null) {
programActivated(currentProgram);
}
}
/**
@@ -168,29 +154,4 @@ public class MemoryMapPlugin extends ProgramPlugin implements DomainObjectListen
ProgramLocation loc = new ProgramLocation(currentProgram, addr);
goToService.goTo(loc);
}
/**
* Create the action for toolbar.
*/
private void createActions() {
memViewAction = new DockingAction("View Memory Map", getName()) {
@Override
public void actionPerformed(ActionContext context) {
showMemory();
}
};
ImageIcon tableImage = ResourceManager.loadImage(MemoryMapProvider.MEMORY_IMAGE);
memViewAction.setToolBarData(new ToolBarData(tableImage, "View"));
memViewAction.setDescription("Display Memory Map");
tool.addAction(memViewAction);
}
/**
* Callback for the View memory Action
*/
private void showMemory() {
tool.showComponentProvider(provider, true);
}
}
@@ -81,9 +81,11 @@ class MemoryMapProvider extends ComponentProviderAdapter {
MemoryMapProvider(MemoryMapPlugin plugin) {
super(plugin.getTool(), "Memory Map", plugin.getName(), ProgramActionContext.class);
this.plugin = plugin;
setHelpLocation(new HelpLocation(plugin.getName(), getName()));
memManager = plugin.getMemoryMapManager();
setIcon(ResourceManager.loadImage(MEMORY_IMAGE));
addToToolbar();
mainPanel = buildMainPanel();
addToTool();
addLocalActions();
@@ -107,9 +109,6 @@ class MemoryMapProvider extends ComponentProviderAdapter {
return new ProgramActionContext(this, program);
}
/**
* Set the status text on this dialog.
*/
void setStatusText(String msg) {
tool.setStatusInfo(msg);
}
@@ -367,9 +366,6 @@ class MemoryMapProvider extends ComponentProviderAdapter {
}
}
/**
* @return
*/
JTable getTable() {
return memTable;
}
@@ -462,7 +458,8 @@ class MemoryMapProvider extends ComponentProviderAdapter {
public void mousePressed(MouseEvent e) {
setStatusText("");
if (!e.isPopupTrigger()) {
if ((e.getModifiers() & (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)) == 0) {
if ((e.getModifiersEx() &
(InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)) == 0) {
selectAddress();
}
}
@@ -368,7 +368,7 @@ public class NextPrevAddressPlugin extends Plugin {
private NavigationAction(Navigatable navigatable, LocationMemento location, boolean isNext,
NavigationHistoryService service, CodeUnitFormat formatter) {
super("NavigationAction: " + ++idCount, NextPrevAddressPlugin.this.getName(), false);
super("NavigationAction: " + ++idCount, NextPrevAddressPlugin.this.getName());
this.location = location;
this.isNext = isNext;
this.service = service;

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