GP-2663 - Removed deprecated methods

This commit is contained in:
dragonmacher
2022-10-07 15:06:59 -04:00
parent fa09ee612a
commit a2a5a6e354
72 changed files with 255 additions and 916 deletions
@@ -55,7 +55,7 @@ import ghidra.util.bean.opteditor.OptionsVetoException;
//@formatter:on
/**
* A {@link ProgramPlugin} for training a model on the starts of known functions in a
* A {@link ProgramPlugin} for training a model on the starts of known functions in a
* program and then using that model to look for more functions (in the source program or
* another program selected by the user).
*/
@@ -85,7 +85,7 @@ public class RandomForestFunctionFinderPlugin extends ProgramPlugin
* @param tool tool for plugin
*/
public RandomForestFunctionFinderPlugin(PluginTool tool) {
super(tool, false, true);
super(tool);
programsToProviders = new HashMap<>();
}
@@ -122,7 +122,7 @@ public class RandomForestFunctionFinderPlugin extends ProgramPlugin
}
/**
* Record the existence of a {@link ProgramAssociatedComponentProviderAdapter} so that it can
* Record the existence of a {@link ProgramAssociatedComponentProviderAdapter} so that it can
* be closed if its associated program is closed
* @param provider provider
*/
@@ -175,7 +175,7 @@ public class RandomForestFunctionFinderPlugin extends ProgramPlugin
@Override
protected void programClosed(Program p) {
//ProgramAssociatedComponentProviderAdapter.closeComponent modifies values of
//ProgramAssociatedComponentProviderAdapter.closeComponent modifies values of
//programsToProviders, so make a copy to avoid a ConcurrentModificationException
List<ProgramAssociatedComponentProviderAdapter> providersToClose =
Lists.copyOf(programsToProviders.getOrDefault(p, Collections.emptyList()));
@@ -43,7 +43,7 @@ public class SampleTablePlugin extends ProgramPlugin {
private Function currentFunction;
public SampleTablePlugin(PluginTool tool) {
super(tool, true /*location changes*/, true/*selection changes*/);
super(tool);
provider = new SampleTableProvider(this);
provider.addToTool();
@@ -40,7 +40,7 @@ public class SampleSearchTablePlugin extends ProgramPlugin {
private SampleSearchTableProvider provider;
public SampleSearchTablePlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
createActions();
}
@@ -65,7 +65,7 @@ public class KitchenSinkPlugin extends ProgramPlugin {
*/
public KitchenSinkPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
// set up list of services.
setupServices();
@@ -60,7 +60,7 @@ public class SampleProgramTreePlugin extends ProgramPlugin {
* @param tool tool that will contain this plugin
*/
public SampleProgramTreePlugin(PluginTool tool) {
super(tool, false, false); // we consume neither location nor selection events
super(tool);
createActions();
}
@@ -42,7 +42,7 @@ public class ShowInfoPlugin extends ProgramPlugin {
private ShowInfoComponentProvider provider;
public ShowInfoPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
provider = new ShowInfoComponentProvider(tool, getName());
}
@@ -1,226 +0,0 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.examples;
import ghidra.app.context.ListingActionContext;
import ghidra.app.events.ProgramActivatedPluginEvent;
import ghidra.app.services.ProgramManager;
import ghidra.framework.plugintool.*;
import ghidra.program.model.listing.Program;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.MenuData;
/*******************************************************************
*
* Here's an example of a plugin for a GHIDRA tool.
*
*******************************************************************/
/**
* NOTE: this example class is abstract so that it does not appear in the
* list of valid plugins. Real plugins should not be abstract.
*/
public abstract class Template extends Plugin {
private DockingAction function_1Action;
private DockingAction function_2Action;
private DockingAction function_3Action;
/*******************************************************************
*
* Standard Plugin Constructor
*
*******************************************************************/
public Template(PluginTool tool) {
super(tool);
// set up list of actions.
setupActions();
}
/*******************************************************************
********************************************************************
**
**
** Function 1
**
**
********************************************************************
*******************************************************************/
private void Function_1() {
} // Function_1
/*******************************************************************
********************************************************************
**
**
** Function 2
**
**
********************************************************************
*******************************************************************/
private void Function_2() {
} // Function_2
/*******************************************************************
********************************************************************
**
**
** Function 3
**
**
********************************************************************
*******************************************************************/
private void Function_3() {
} // Function_3
/*******************************************************************
********************************************************************
**
**
** User Plugin Utilities
**
**
********************************************************************
*******************************************************************/
/**
* Get the current program
*/
private Program getProgram() {
ProgramManager pm = tool.getService(ProgramManager.class);
if (pm != null) {
return pm.getCurrentProgram();
}
return null;
}
/*******************************************************************
********************************************************************
**
**
** Required Plugin Routines
**
**
********************************************************************
*******************************************************************/
/**
* Set up Actions
*/
private void setupActions() {
DockingAction action;
//
// Function 1
//
action = new DockingAction( "Function 1 Code", getName() ) {
@Override
public void actionPerformed(ActionContext e) {
Function_1();
}
@Override
public boolean isAddToPopup( ActionContext context ) {
if ( !(context.getContextObject() instanceof ListingActionContext) ) {
return false;
}
return super.isAddToPopup( context );
}
};
action.setMenuBarData( new MenuData(
new String[] { "Misc", "Menu", "menu item 1" }, null, null ) );
if (getProgram() == null) {
action.setEnabled(false);
}
tool.addAction(action);
function_1Action = action;
//
// Function 2
//
action =new DockingAction("Function 2 Code", getName() ) {
@Override
public void actionPerformed(ActionContext e) {
Function_2();
}
@Override
public boolean isValidContext(ActionContext context) {
return context instanceof ListingActionContext;
}
};
action.setMenuBarData( new MenuData(
new String[] { "Misc", "Menu", "Menu item 2" }, null, null ) );
if (getProgram() == null) {
action.setEnabled(false);
}
tool.addAction(action);
// remember this action so I can enable/disable it later
function_2Action = action;
//
// Function 3
//
action =
new DockingAction("Function 3 Code", getName() ) {
@Override
public void actionPerformed(ActionContext e) {
Function_3();
}
@Override
public boolean isValidContext( ActionContext context ) {
return context instanceof ListingActionContext;
}
};
action.setMenuBarData( new MenuData(
new String[] { "Misc", "Menu", "Menu item 3" }, null, null ) );
if (getProgram() == null) {
action.setEnabled(false);
}
tool.addAction(action);
// remember this action so I can enable/disable it later
function_3Action = action;
}
/**
* Put event processing code here.
*/
@Override
public void processEvent(PluginEvent event) {
if (event instanceof ProgramActivatedPluginEvent) {
Program p = ((ProgramActivatedPluginEvent)event).getActiveProgram();
function_1Action.setEnabled(p!=null);
function_2Action.setEnabled(p!=null);
function_3Action.setEnabled(p!=null);
}
}
}
@@ -1,147 +0,0 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.examples;
import docking.ActionContext;
import docking.action.DockingAction;
import docking.action.MenuData;
import ghidra.app.ExamplesPluginPackage;
import ghidra.app.context.ListingActionContext;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.services.ProgramManager;
import ghidra.framework.model.*;
import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.listing.Program;
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
* allows the derived class to be very simple.
*/
//@formatter:off
@PluginInfo(
status = PluginStatus.RELEASED,
packageName = ExamplesPluginPackage.NAME,
category = PluginCategoryNames.EXAMPLES,
shortDescription = "Plugin starter template",
description = "Copy this plugin and use as a template for creating a new plugin.",
servicesRequired = { ProgramManager.class /* list of service classes that this plugin requires */ },
servicesProvided = { /* list of service classes that this plugin registers with Plugin.registerServiceProvided() */ }
)
//@formatter:on
public class TemplateProgramPlugin extends ProgramPlugin implements DomainObjectListener {
private DockingAction action;
/*******************************************************************
*
* 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
// set up list of actions.
setupActions();
}
/**
* 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...
// ...
}
}
}
/**
* 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);
}
/*******************************************************************
********************************************************************
**
**
** Function 1
**
**
********************************************************************
*******************************************************************/
private void Function_1() {
// do something with a program location
Msg.info(this, getPluginDescription().getName() + ": Program Location==> " +
currentLocation.getAddress());
}
/**
* Set up Actions
*/
private void setupActions() {
//
// 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);
action.setMenuBarData(
new MenuData(new String[] { "Misc", "Menu", "Menu item 1" }, null, null));
action.setHelpLocation(
new HelpLocation("SampleHelpTopic", "TemplateProgramPlugin_Anchor_Name"));
tool.addAction(action);
}
}
@@ -15,44 +15,31 @@
*/
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.*;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.*;
import ghidra.program.model.listing.CodeUnit;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
import ghidra.program.util.ProgramSelection;
/**
* Base class to handle common program events: Program Open/Close,
* Program Location, Program Selection, and Program Highlight.
* Base class to handle common program events: Program Open/Close, Program Activated,
* Program Location, Program Selection, and Program Highlight. This class has fields related to
* these events: {@code currentProgram}, {@code currentLocation}, {@code currentSelection} and
* {@code currentHighlight}.
* <p>
* Subclasses should override the following methods if they are interested
* in the corresponding events:
* Subclasses should override the following methods if they are interested in the corresponding
* events:
* <ul>
* <LI> <code>programOpened(Program)</code>
* <LI> <code>programClosed(Program)</code>
* <LI> <code>locationChanged(ProgramLocation)</code>
* <LI> <code>selectionChanged(ProgramSelection) </code>
* <LI> <code>highlightChanged(ProgramSelection) </code>
* </LI>
* <LI> {@link #programOpened(Program)}
* <LI> {@link #programClosed(Program)}
* <LI> {@link #locationChanged(ProgramLocation)}
* <LI> {@link #selectionChanged(ProgramSelection)}
* <LI> {@link #highlightChanged(ProgramSelection)}
* </ul>
* <br>
* This class will handle the enablement and add to popup state for
* plugin actions when subclasses call any of the following methods:
* <ul>
* <LI><code>enableOnHighlight(PluginAction)</code>
* <LI><code>enableOnLocation(PluginAction)</code>
* <LI><code>enableOnProgram(PluginAction)</code>
* <LI><code>enableOnSelection(PluginAction)</code>
* </LI>
* </ul>
*
*/
public abstract class ProgramPlugin extends Plugin {
@@ -60,53 +47,58 @@ public abstract class ProgramPlugin extends Plugin {
protected ProgramLocation currentLocation;
protected ProgramSelection currentSelection;
protected ProgramSelection currentHighlight;
private ArrayList<DockingAction> programActionList;
private ArrayList<DockingAction> locationActionList;
private ArrayList<DockingAction> selectionActionList;
private ArrayList<DockingAction> highlightActionList;
/**
* Constructs a new program plugin
* @param plugintool tool the parent tool for this plugin
* @param consumeLocationChange true if this plugin should consume ProgramLocation events
* @param consumeSelectionChange true if this plugin should consume ProgramSelection events
* @param consumeHighlightChange true if this plugin should consume ProgramHighlight events
*/
public ProgramPlugin(PluginTool plugintool, boolean consumeLocationChange,
boolean consumeSelectionChange, boolean consumeHighlightChange) {
public ProgramPlugin(PluginTool plugintool) {
super(plugintool);
registerEventConsumed(ProgramActivatedPluginEvent.class);
if (consumeLocationChange) {
//register most derived class
registerEventConsumed(ProgramLocationPluginEvent.class);
}
if (consumeSelectionChange) {
registerEventConsumed(ProgramSelectionPluginEvent.class);
}
if (consumeHighlightChange) {
registerEventConsumed(ProgramHighlightPluginEvent.class);
}
registerEventConsumed(ProgramOpenedPluginEvent.class);
registerEventConsumed(ProgramClosedPluginEvent.class);
programActionList = new ArrayList<>(3);
locationActionList = new ArrayList<>(3);
selectionActionList = new ArrayList<>(3);
highlightActionList = new ArrayList<>(3);
internalRegisterEventConsumed(ProgramActivatedPluginEvent.class);
internalRegisterEventConsumed(ProgramLocationPluginEvent.class);
internalRegisterEventConsumed(ProgramSelectionPluginEvent.class);
internalRegisterEventConsumed(ProgramHighlightPluginEvent.class);
internalRegisterEventConsumed(ProgramOpenedPluginEvent.class);
internalRegisterEventConsumed(ProgramClosedPluginEvent.class);
}
public ProgramPlugin(PluginTool tool, boolean consumeLocationChange,
/**
* Calling this constructor is works the same as calling {@link ProgramPlugin}.
*
* @deprecated call {@link #ProgramPlugin(PluginTool)} instead
* @param plugintool the tool
* @param consumeLocationChange not used
* @param consumeSelectionChange not used
*/
@Deprecated(forRemoval = true, since = "10.2")
public ProgramPlugin(PluginTool plugintool, boolean consumeLocationChange,
boolean consumeSelectionChange) {
this(tool, consumeLocationChange, consumeSelectionChange, false);
this(plugintool);
}
/**
* Calling this constructor is works the same as calling {@link ProgramPlugin}.
*
* @deprecated call {@link #ProgramPlugin(PluginTool)} instead
* @param plugintool the tool
* @param consumeLocationChange not used
* @param consumeSelectionChange not used
* @param consumeHighlightChange not used
*/
@Deprecated(forRemoval = true, since = "10.2")
public ProgramPlugin(PluginTool plugintool, boolean consumeLocationChange,
boolean consumeSelectionChange, boolean consumeHighlightChange) {
this(plugintool);
}
/**
* Process the plugin event.
* When a program closed event or focus changed event comes in,
* the locationChanged() and selectionChanged() methods are called
* with null arguments; currentProgram and currentLocation are cleared.
* <p>Note: if the subclass overrides processEvent(), it should call
* super.processEvent().
* <p>
* When a program closed event or focus changed event comes in, the locationChanged() and
* selectionChanged() methods are called with null arguments; currentProgram and
* currentLocation are cleared.
* <p>
* Note: if the subclass overrides processEvent(), it should call super.processEvent().
*/
@Override
public void processEvent(PluginEvent event) {
@@ -130,14 +122,10 @@ public abstract class ProgramPlugin extends Plugin {
locationChanged(null);
selectionChanged(null);
highlightChanged(null);
enableActions(locationActionList, false);
enableActions(selectionActionList, false);
enableActions(highlightActionList, false);
}
if (currentProgram != null) {
programActivated(currentProgram);
}
enableActions(programActionList, currentProgram != null);
}
else if (event instanceof ProgramLocationPluginEvent) {
@@ -147,27 +135,11 @@ public abstract class ProgramPlugin extends Plugin {
if (currentLocation != null && currentLocation.getAddress() == null ||
(currentProgram == null && ev.getProgram() == null)) {
currentLocation = null;
// disable actions, but don't remove from popup
enableActions(locationActionList, false);
}
else if (currentLocation == null) {
// disable actions and remove from popup
enableActions(locationActionList, false);
// remove selection actions
}
else {
// enable actions
enableActions(locationActionList, true);
// add selection actions
}
if (currentProgram == null) {
// currentProgram is null because we haven't gotten the
// open program event yet (a plugin is firing location change
// in response to open program that we haven't gotten yet),
// so just pull it out of the
// location event...
//currentProgram = ev.getProgram();
//programOpened(currentProgram);
// currentProgram is null because we haven't gotten the open program event yet (a
// plugin is firing location change in response to open program that we haven't
// gotten yet)
return;
}
locationChanged(currentLocation);
@@ -175,11 +147,7 @@ public abstract class ProgramPlugin extends Plugin {
else if (event instanceof ProgramSelectionPluginEvent) {
ProgramSelectionPluginEvent ev = (ProgramSelectionPluginEvent) event;
currentSelection = ev.getSelection();
if (currentSelection != null && !currentSelection.isEmpty()) {
enableActions(selectionActionList, true);
}
else {
enableActions(selectionActionList, false);
if (currentSelection != null && currentSelection.isEmpty()) {
currentSelection = null;
}
selectionChanged(currentSelection);
@@ -187,159 +155,65 @@ public abstract class ProgramPlugin extends Plugin {
else if (event instanceof ProgramHighlightPluginEvent) {
ProgramHighlightPluginEvent ev = (ProgramHighlightPluginEvent) event;
currentHighlight = ev.getHighlight();
if (currentHighlight != null && !currentHighlight.isEmpty()) {
enableActions(highlightActionList, true);
}
else {
enableActions(highlightActionList, false);
if (currentHighlight != null && currentHighlight.isEmpty()) {
currentHighlight = null;
}
highlightChanged(currentHighlight);
}
}
/**
* Enable the action when the program is opened; disable it when
* 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");
}
if (selectionActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to selection action list");
}
if (highlightActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to highlight action list");
}
programActionList.add(action);
action.setEnabled(currentProgram != null);
}
/**
* Enable the action when a program location event comes in; disable it
* if either the location is null, or if the address in the location
* 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");
}
if (selectionActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to selection action list");
}
if (highlightActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to highlight action list");
}
locationActionList.add(action);
action.setEnabled(currentLocation != null);
}
/**
* Enable the action when a selection event comes in; disable it if
* 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");
}
if (locationActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to location action list");
}
if (highlightActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to highlight action list");
}
selectionActionList.add(action);
action.setEnabled(currentSelection != null);
}
/**
* Enable the action when a highlight event comes in; disable it if
* 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");
}
if (locationActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to location action list");
}
if (selectionActionList.contains(action)) {
throw new IllegalArgumentException("Action already added to selection action list");
}
highlightActionList.add(action);
action.setEnabled(currentHighlight != null);
}
/**
* Subclass should override this method if it is interested when programs become active.
* Note: this method is called in response to a ProgramActivatedPluginEvent.
*
* At the time this method is called,
* Note: this method is called in response to a ProgramActivatedPluginEvent.
*
* At the time this method is called,
* the "currentProgram" variable will be set the new active program.
*
*
* @param program the new program going active.
*/
protected void programActivated(Program program) {
// override
}
/**
* Subclasses should override this method if it is interested when a program is closed.
*
*
* This event has no affect on the "current Program". A "programDeactivated" call will
* occur that affects the active program.
*
*
* @param program the program being closed.
*/
protected void programClosed(Program program) {
// override
}
/**
* Subclasses should override this method if it is interested when a program is opened.
*
*
* This event has no affect on the "current Program". A "programActivated" call will
* occur that affects the active program.
*
*
* @param program the program being opened.
*/
protected void programOpened(Program program) {
// override
}
/**
* Subclass should override this method if it is interested when programs become inactive.
* Note: this method is called in response to a ProgramActivatedPluginEvent and there is
* Note: this method is called in response to a ProgramActivatedPluginEvent and there is
* a currently active program.
*
* At the time this method is called,
* the "currentProgram" variable will be set the
*
* At the time this method is called,
* the "currentProgram" variable will be set the
* new active program or null if there is no new active program.
*
*
* @param program the old program going inactive.
*/
protected void programDeactivated(Program program) {
// override
}
/**
@@ -348,6 +222,7 @@ public abstract class ProgramPlugin extends Plugin {
* @param loc location could be null
*/
protected void locationChanged(ProgramLocation loc) {
// override
}
/**
@@ -356,6 +231,7 @@ public abstract class ProgramPlugin extends Plugin {
* @param sel selection could be null
*/
protected void selectionChanged(ProgramSelection sel) {
// override
}
/**
@@ -364,10 +240,13 @@ public abstract class ProgramPlugin extends Plugin {
* @param hl highlight could be null
*/
protected void highlightChanged(ProgramSelection hl) {
// override
}
/**
* Convenience method to go to the specified address.
* @param addr the address to go to
* @return true if successful
*/
protected boolean goTo(Address addr) {
GoToService service = tool.getService(GoToService.class);
@@ -396,45 +275,6 @@ public abstract class ProgramPlugin extends Plugin {
new ProgramSelectionPluginEvent(getName(), new ProgramSelection(set), currentProgram));
}
/**
* Convenience method to set a bookmark;
* @param addr address of where the bookmark will be placed
* @param type type of bookmark: BookMarkType.NOTE, BookmarkType.INFO,
* BookmarkType.ANALYSIS, or BookmarkType.ERROR.
* @param category category for the bookmark
* @param comment bookmark comment
*/
protected void setBookmark(Address addr, String type, String category, String comment) {
if (currentProgram == null) {
return;
}
BookmarkManager mgr = currentProgram.getBookmarkManager();
int transactionID = currentProgram.startTransaction("Set Bookmark");
try {
mgr.setBookmark(addr, type, category, comment);
}
finally {
currentProgram.endTransaction(transactionID, true);
}
}
////////////////////////////////////////////////////////////////////
/**
* Enable actions in the list according to the enabled param.
* @param enabled true means to enable the action AND set the
* add to popup as true; false means disable the action and set
* add to popup according to the removeFromPopup
* @param removeFromPopup only used if enabled is false
*/
private void enableActions(ArrayList<DockingAction> list, boolean enabled) {
for (int i = 0; i < list.size(); i++) {
DockingAction a = list.get(i);
a.setEnabled(enabled);
}
}
public ProgramLocation getProgramLocation() {
return currentLocation;
}
@@ -60,7 +60,7 @@ public class ModuleAlgorithmPlugin extends ProgramPlugin implements BlockModelSe
private BlockModelService blockModelService;
public ModuleAlgorithmPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
@Override
@@ -59,7 +59,7 @@ public class AssemblerPlugin extends ProgramPlugin {
/*test*/ PatchDataAction patchDataAction;
public AssemblerPlugin(PluginTool tool) {
super(tool, false, false, false);
super(tool);
createActions();
}
@@ -83,7 +83,7 @@ public class BlockModelServicePlugin extends ProgramPlugin
public BlockModelServicePlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
// Add standard simple block model
BlockModelInfo info = new BlockModelInfo(SimpleBlockModel.NAME, SimpleBlockModel.class);
@@ -85,7 +85,7 @@ public class BookmarkPlugin extends ProgramPlugin
private NavUpdater navUpdater;
public BookmarkPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
provider = new BookmarkProvider(tool, this);
provider.addToTool();
@@ -67,7 +67,7 @@ public class CallTreePlugin extends ProgramPlugin {
private CallTreeProvider primaryProvider;
public CallTreePlugin(PluginTool tool) {
super(tool, true, false, false);
super(tool);
createActions();
primaryProvider = new CallTreeProvider(this, true);
@@ -51,7 +51,7 @@ public class ComputeChecksumsPlugin extends ProgramPlugin {
* @param tool
*/
public ComputeChecksumsPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
createActions();
provider = new ComputeChecksumsProvider(this);
@@ -78,7 +78,7 @@ public class ClipboardPlugin extends ProgramPlugin implements ClipboardOwner, Cl
private boolean isClipboardOwner;
public ClipboardPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override
@@ -40,7 +40,7 @@ public class DataTypeListingHoverPlugin extends ProgramPlugin {
private DataTypeListingHover hoverService;
public DataTypeListingHoverPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
hoverService = new DataTypeListingHover(tool);
registerServiceProvided(ListingHoverService.class, hoverService);
}
@@ -88,7 +88,7 @@ public class ColorizingPlugin extends ProgramPlugin implements DomainObjectListe
});
public ColorizingPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
service = new ColorizingServiceProvider(tool);
registerServiceProvided(ColorizingService.class, service);
@@ -55,7 +55,7 @@ public class CommentWindowPlugin extends ProgramPlugin implements DomainObjectLi
private SwingUpdateManager reloadUpdateMgr;
public CommentWindowPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
reloadUpdateMgr = new SwingUpdateManager(1000, 60000, () -> doReload());
}
@@ -20,10 +20,10 @@ import ghidra.app.events.ProgramLocationPluginEvent;
import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.ProgramPlugin;
import ghidra.app.services.ConsoleService;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.PluginInfo;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.listing.Program;
import ghidra.program.util.ProgramLocation;
//@formatter:off
@PluginInfo(
@@ -41,7 +41,7 @@ public class ConsolePlugin extends ProgramPlugin {
private ConsoleComponentProvider provider;
public ConsolePlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
provider = new ConsoleComponentProvider(tool, getName());
registerServiceProvided(ConsoleService.class, provider);
}
@@ -67,15 +67,4 @@ public class ConsolePlugin extends ProgramPlugin {
protected void programDeactivated(Program program) {
provider.setCurrentProgram(null);
}
@Override
public void processEvent(PluginEvent event) {
super.processEvent(event);
if (event instanceof ProgramLocationPluginEvent) {
ProgramLocationPluginEvent plpe = (ProgramLocationPluginEvent) event;
ProgramLocation pl = plpe.getLocation();
provider.setCurrentAddress(pl.getAddress());
}
}
}
@@ -66,7 +66,7 @@ public class CParserPlugin extends ProgramPlugin {
"Parse C and C Header files, extracting data definitions and function signatures.";
public CParserPlugin(PluginTool plugintool) {
super(plugintool, false, false);
super(plugintool);
createActions();
setUserProfileDir(USER_PROFILES_DIR);
}
@@ -105,7 +105,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
private DataTypePropertyManager dataTypePropertyManager;
public DataTypeManagerPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override
@@ -79,7 +79,7 @@ public class DataTypePreviewPlugin extends ProgramPlugin {
private SwingUpdateManager updateManager = new SwingUpdateManager(650, () -> updatePreview());
public DataTypePreviewPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
DTPPTableModel getTableModel() {
@@ -65,7 +65,7 @@ public class DataWindowPlugin extends ProgramPlugin implements DomainObjectListe
private boolean resetTypesNeeded;
public DataWindowPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
resetUpdateMgr = new SwingUpdateManager(100, 60000, () -> doReset());
@@ -67,7 +67,7 @@ public class AutoTableDisassemblerPlugin extends ProgramPlugin implements Domain
final static String SEARCH_ACTION_NAME = "Search for Address Tables";
public AutoTableDisassemblerPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override
@@ -111,7 +111,7 @@ public class DisassembledViewPlugin extends ProgramPlugin implements DomainObjec
// events and selection changed events. The first type we get from
// our parent, the other two we get by passing true to our parent's
// constructor
super(plugintool, true, true);
super(plugintool);
}
/**
@@ -58,7 +58,7 @@ public class EclipseIntegrationPlugin extends ProgramPlugin implements EclipseIn
private ToolOptions options;
public EclipseIntegrationPlugin(PluginTool tool) {
super(tool, true, true, true);
super(tool);
}
@Override
@@ -47,7 +47,7 @@ public class TextEditorManagerPlugin extends ProgramPlugin implements TextEditor
private List<TextEditorComponentProvider> editors = new ArrayList<>();
public TextEditorManagerPlugin(PluginTool tool) {
super(tool, true, true, true);
super(tool);
}
@Override
@@ -52,7 +52,7 @@ public class EquateTablePlugin extends ProgramPlugin implements DomainObjectList
private SwingUpdateManager updateMgr;
public EquateTablePlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
updateMgr = new SwingUpdateManager(1000, 3000, () -> provider.updateEquates());
@@ -50,7 +50,7 @@ public class FunctionTagPlugin extends ProgramPlugin {
private FunctionTagProvider provider;
public FunctionTagPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
provider = new FunctionTagProvider(this, getCurrentProgram());
createActions();
}
@@ -70,7 +70,7 @@ public class FunctionComparisonPlugin extends ProgramPlugin
* @param tool the tool that owns this plugin
*/
public FunctionComparisonPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
functionComparisonManager = new FunctionComparisonProviderManager(this);
}
@@ -59,7 +59,7 @@ public class FunctionWindowPlugin extends ProgramPlugin implements DomainObjectL
private FunctionComparisonService functionComparisonService;
public FunctionWindowPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
swingMgr = new SwingUpdateManager(1000, () -> provider.reload());
}
@@ -62,7 +62,7 @@ public final class GoToServicePlugin extends ProgramPlugin {
* @param tool the tool
*/
public GoToServicePlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
Options opt = tool.getOptions(PluginConstants.SEARCH_OPTION_NAME);
@@ -88,7 +88,7 @@ public class InstructionSearchPlugin extends ProgramPlugin {
* @param tool the plugin tool
*/
public InstructionSearchPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
// Creates the menu actions used with this plugin.
createActions();
@@ -59,7 +59,7 @@ public class MemoryMapPlugin extends ProgramPlugin implements DomainObjectListen
private MemoryMapManager memManager;
public MemoryMapPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
memManager = new MemoryMapManager(this);
provider = new MemoryMapProvider(this);
@@ -99,7 +99,7 @@ public class MyProgramChangesDisplayPlugin extends ProgramPlugin implements Doma
public MyProgramChangesDisplayPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
folderListener = new ProgramFolderListener();
transactionListener = new ProgramTransactionListener();
@@ -79,7 +79,7 @@ public class AutoRenamePlugin extends ProgramPlugin {
* Constructor.
*/
public AutoRenamePlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
createActions();
}
@@ -77,7 +77,7 @@ public class ModuleSortPlugin extends ProgramPlugin {
private ModuleSortAction sortByNameAction;
public ModuleSortPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
createActions();
}
@@ -62,7 +62,7 @@ public class OverviewColorPlugin extends ProgramPlugin {
private MultiActionDockingAction multiAction;
public OverviewColorPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
@Override
@@ -66,7 +66,7 @@ public class PrintingPlugin extends ProgramPlugin {
private PageFormat format;
public PrintingPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
setupActions();
}
@@ -83,7 +83,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
public ShowInstructionInfoPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
createStatusPanels();
createActions();
@@ -57,7 +57,7 @@ import docking.action.MenuData;
public class ProgramTreeModularizationPlugin extends ProgramPlugin {
public ProgramTreeModularizationPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
@Override
@@ -107,7 +107,7 @@ public class ProgramTreePlugin extends ProgramPlugin
private boolean isReplaceViewMode = true;
public ProgramTreePlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
viewProvider = new ViewManagerComponentProvider(tool, getName());
registerServiceProvided(ViewManagerService.class, viewProvider);
@@ -332,11 +332,7 @@ public class ProgramTreePlugin extends ProgramPlugin
@Override
public void processEvent(PluginEvent event) {
super.processEvent(event);
if (event instanceof ProgramActivatedPluginEvent) {
ProgramActivatedPluginEvent ev = (ProgramActivatedPluginEvent) event;
viewProvider.setCurrentProgram(ev.getActiveProgram());
}
if (event instanceof TreeSelectionPluginEvent) {
TreeSelectionPluginEvent ev = (TreeSelectionPluginEvent) event;
String treeName = ev.getTreeName();
@@ -346,6 +342,16 @@ public class ProgramTreePlugin extends ProgramPlugin
}
provider.setGroupSelection(ev.getGroupPaths());
}
else {
super.processEvent(event);
}
}
@Override
protected void programActivated(Program program) {
program.addListener(programListener);
setProgram(program);
viewProvider.setCurrentProgram(program);
}
private void removeStaleProviders(ArrayList<TreeViewProvider> providerList) {
@@ -384,12 +390,6 @@ public class ProgramTreePlugin extends ProgramPlugin
setProgram(null);
}
@Override
protected void programActivated(Program program) {
program.addListener(programListener);
setProgram(program);
}
@Override
protected void locationChanged(ProgramLocation loc) {
// select fragment that corresponds to the location
@@ -479,7 +479,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Close the view if we are not trying to close the last view.
*
*
* @param treeViewProvider
* @return true if the view can be closed
*/
@@ -496,7 +496,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Notification that the view is deleted
*
*
* @param treeViewProvider the deleted provider
* @return true if the view can be deleted
*/
@@ -516,7 +516,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Method renameView.
*
*
* @param treeViewProvider
* @param newName
* @return boolean
@@ -561,7 +561,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Method called by the program change listener when a tree is removed.
*
*
* @param treeName name of tree that was removed
*/
void treeRemoved(String treeName) {
@@ -581,7 +581,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Get the program tree for the given tree name.
*
*
* @param treeName name of tree in the program (also the name of the view)
* @return ProgramDnDTree tree, or null if there is no provider for the
* given name
@@ -596,7 +596,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Method getCurrentProvider.
*
*
* @return TreeViewProvider
*/
TreeViewProvider getCurrentProvider() {
@@ -622,9 +622,9 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* The program was restored from an Undo/Redo operation so reload it
*
* @param checkRoot if true, only rebuild the tree if the root node is invalid; if false,
* force a rebuild of the tree
*
* @param checkRoot if true, only rebuild the tree if the root node is invalid; if false,
* force a rebuild of the tree
*/
void reloadProgram(boolean checkRoot) {
if (currentProgram == null) {
@@ -696,17 +696,15 @@ public class ProgramTreePlugin extends ProgramPlugin
}
tree.reload();
for (int i = 0; i < selectList.size(); i++) {
GroupPath gp = (GroupPath) selectList.get(i);
for (Object element : selectList) {
GroupPath gp = (GroupPath) element;
tree.addGroupSelectionPath(gp);
}
for (int i = 0; i < expandList.size(); i++) {
GroupPath gp = expandList.get(i);
for (GroupPath gp : expandList) {
tree.expand(gp);
}
for (int i = 0; i < newViewList.size(); i++) {
GroupPath gp = newViewList.get(i);
for (GroupPath gp : newViewList) {
tree.addGroupViewPath(gp);
}
if (newViewList.size() > 0 && tree.getViewList().size() == 0) {
@@ -756,7 +754,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Return true if a tree with the given name exists in the program. If
* program is null and if the tree name is the default name, return true.
*
*
* @param treeName tree name to look for
* @return boolean
*/
@@ -779,7 +777,7 @@ public class ProgramTreePlugin extends ProgramPlugin
/**
* Set the program on each of the providers.
*
*
* @param p program that is being opened; if p is null, then program is
* being closed.
*/
@@ -907,7 +905,7 @@ public class ProgramTreePlugin extends ProgramPlugin
* Open an existing view in the program. If a provider already exists for
* the given tree name, make this the current view provider in the view
* manager service.
*
*
* @param treeName name of tree
*/
private void openView(String treeName) {
@@ -968,8 +966,8 @@ public class ProgramTreePlugin extends ProgramPlugin
selectionToggleAction.setDescription(
HTMLUtilities.toHTML("Toggle <b>On</b> means to select the fragment(s)\n" +
"that corresponds to the current location."));
selectionToggleAction.setHelpLocation(
new HelpLocation(getName(), selectionToggleAction.getName()));
selectionToggleAction
.setHelpLocation(new HelpLocation(getName(), selectionToggleAction.getName()));
}
private void selectFragments() {
@@ -57,7 +57,7 @@ public class FunctionReachabilityPlugin extends ProgramPlugin {
new ArrayList<>();
public FunctionReachabilityPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
createActions();
}
@@ -69,7 +69,7 @@ public class RegisterPlugin extends ProgramPlugin {
private RegisterTransitionFieldMouseHandler fieldMouseHandler;
public RegisterPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override
@@ -45,7 +45,7 @@ public class RelocationFixupPlugin extends ProgramPlugin implements DomainObject
new ArrayList<RelocationFixupHandler>();
public RelocationFixupPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
initializeRelocationHandlers();
@@ -61,7 +61,7 @@ public class ScalarSearchPlugin extends ProgramPlugin implements DomainObjectLis
private Set<ScalarSearchProvider> providers = new HashSet<>();
public ScalarSearchPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
reloadUpdateMgr =
new SwingUpdateManager(1000, 60000, () -> providers.forEach(p -> p.reload()));
@@ -58,7 +58,7 @@ public class GhidraScriptMgrPlugin extends ProgramPlugin implements GhidraScript
* @param tool the tool this plugin is added to
*/
public GhidraScriptMgrPlugin(PluginTool tool) {
super(tool, true, true, true);
super(tool);
// Each tool starts a new script manager plugin, but we only ever want one bundle host.
// GhidraScriptUtil (creates and) manages one instance.
@@ -115,7 +115,7 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList
* @param plugintool The tool required by this plugin.
*/
public SearchTextPlugin(PluginTool plugintool) {
super(plugintool, true, false);
super(plugintool);
createActions();
initializeOptions();
tool.addContextListener(this);
@@ -56,7 +56,7 @@ public class RestoreSelectionPlugin extends ProgramPlugin {
private Map<Program, SelectionState> programToSelectionMap = new HashMap<Program, SelectionState>();
public RestoreSelectionPlugin( PluginTool tool ) {
super( tool, false, true );
super( tool );
}
@Override

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