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

View File

@ -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()));

View File

@ -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();

View File

@ -40,7 +40,7 @@ public class SampleSearchTablePlugin extends ProgramPlugin {
private SampleSearchTableProvider provider;
public SampleSearchTablePlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
createActions();
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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());
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -59,7 +59,7 @@ public class AssemblerPlugin extends ProgramPlugin {
/*test*/ PatchDataAction patchDataAction;
public AssemblerPlugin(PluginTool tool) {
super(tool, false, false, false);
super(tool);
createActions();
}

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);
}

View File

@ -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);

View File

@ -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());
}

View File

@ -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());
}
}
}

View File

@ -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);
}

View File

@ -105,7 +105,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin
private DataTypePropertyManager dataTypePropertyManager;
public DataTypeManagerPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override

View File

@ -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() {

View File

@ -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());

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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

View File

@ -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

View File

@ -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());

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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);

View File

@ -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();

View File

@ -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);

View File

@ -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();

View File

@ -79,7 +79,7 @@ public class AutoRenamePlugin extends ProgramPlugin {
* Constructor.
*/
public AutoRenamePlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
createActions();
}

View File

@ -77,7 +77,7 @@ public class ModuleSortPlugin extends ProgramPlugin {
private ModuleSortAction sortByNameAction;
public ModuleSortPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
createActions();
}

View File

@ -62,7 +62,7 @@ public class OverviewColorPlugin extends ProgramPlugin {
private MultiActionDockingAction multiAction;
public OverviewColorPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
@Override

View File

@ -66,7 +66,7 @@ public class PrintingPlugin extends ProgramPlugin {
private PageFormat format;
public PrintingPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
setupActions();
}

View File

@ -83,7 +83,7 @@ public class ShowInstructionInfoPlugin extends ProgramPlugin {
public ShowInstructionInfoPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
createStatusPanels();
createActions();

View File

@ -57,7 +57,7 @@ import docking.action.MenuData;
public class ProgramTreeModularizationPlugin extends ProgramPlugin {
public ProgramTreeModularizationPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
@Override

View File

@ -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() {

View File

@ -57,7 +57,7 @@ public class FunctionReachabilityPlugin extends ProgramPlugin {
new ArrayList<>();
public FunctionReachabilityPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
createActions();
}

View File

@ -69,7 +69,7 @@ public class RegisterPlugin extends ProgramPlugin {
private RegisterTransitionFieldMouseHandler fieldMouseHandler;
public RegisterPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override

View File

@ -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();

View File

@ -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()));

View File

@ -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.

View File

@ -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);

View File

@ -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

View File

@ -64,7 +64,7 @@ import ghidra.util.task.TaskMonitorAdapter;
//@formatter:on
public class SelectByScopedFlowPlugin extends ProgramPlugin {
public SelectByScopedFlowPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
createActions();
}

View File

@ -55,7 +55,7 @@ public class ProgramTreeSelectionPlugin extends ProgramPlugin {
private TreeSelectAction selectModuleAction;
public ProgramTreeSelectionPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
createActions();
}

View File

@ -51,7 +51,7 @@ public class StringTablePlugin extends ProgramPlugin {
private List<StringTableProvider> transientProviders = new ArrayList<>();
public StringTablePlugin(PluginTool tool) {
super(tool, false, true);
super(tool);
}
@Override

View File

@ -69,7 +69,7 @@ public class ViewStringsPlugin extends ProgramPlugin implements DomainObjectList
private SwingUpdateManager reloadUpdateMgr;
public ViewStringsPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
void doReload() {

View File

@ -20,7 +20,6 @@ import java.util.*;
import javax.swing.ImageIcon;
import docking.ComponentProvider;
import ghidra.app.CorePluginPackage;
import ghidra.app.events.ProgramClosedPluginEvent;
import ghidra.app.nav.Navigatable;
@ -33,7 +32,8 @@ import ghidra.app.tablechooser.TableChooserExecutor;
import ghidra.app.util.query.TableService;
import ghidra.framework.model.DomainObjectChangedEvent;
import ghidra.framework.model.DomainObjectListener;
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.util.Swing;
@ -62,7 +62,7 @@ public class TableServicePlugin extends ProgramPlugin
private Map<Program, List<TableChooserDialog>> programToDialogMap = new HashMap<>();
public TableServicePlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
updateMgr = new SwingUpdateManager(1000, () -> updateProviders());
@ -88,14 +88,8 @@ public class TableServicePlugin extends ProgramPlugin
}
@Override
public void processEvent(PluginEvent event) {
if (event instanceof ProgramClosedPluginEvent) {
Program p = ((ProgramClosedPluginEvent) event).getProgram();
closeAllQueries(p);
}
else {
super.processEvent(event);
}
protected void programClosed(Program program) {
closeAllQueries(program);
}
@Override
@ -120,8 +114,7 @@ public class TableServicePlugin extends ProgramPlugin
}
// make a copy of the list because the provider updates the list
List<TableComponentProvider<?>> list = new ArrayList<>(plist);
for (int i = 0; i < list.size(); i++) {
ComponentProvider provider = list.get(i);
for (TableComponentProvider<?> provider : list) {
provider.closeComponent();
}
programMap.remove(program);
@ -134,8 +127,7 @@ public class TableServicePlugin extends ProgramPlugin
}
// make a copy of the list because the dialog updates the list
List<TableChooserDialog> list = new ArrayList<>(dlist);
for (int i = 0; i < list.size(); i++) {
TableChooserDialog dialog = list.get(i);
for (TableChooserDialog dialog : list) {
dialog.close();
}
programMap.remove(program);
@ -243,8 +235,7 @@ public class TableServicePlugin extends ProgramPlugin
private void updateProviders() {
List<TableComponentProvider<?>> list = getProviders();
for (int i = 0; i < list.size(); i++) {
TableComponentProvider<?> provider = list.get(i);
for (TableComponentProvider<?> provider : list) {
provider.refresh();
}
}

View File

@ -67,7 +67,7 @@ public class PropertyManagerPlugin extends ProgramPlugin implements DomainObject
private Timer updateTimer;
public PropertyManagerPlugin(PluginTool tool) {
super(tool, false, true);
super(tool);
propertyViewProvider = new PropertyManagerProvider(this);
}

View File

@ -53,7 +53,7 @@ public class ScreenshotPlugin extends ProgramPlugin {
private JFileChooser fileChooser;
public ScreenshotPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
this.tool = tool;
setupActions();

View File

@ -58,6 +58,11 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
private DockingActionIf showReferencesAction;
private CodeBrowserPlugin codeBrowser;
@After
public void tearDown() throws Exception {
cleanupGhidraWithNotepad();
}
/*
* Test method for 'setVisible(TableColumn, boolean)' and 'isVisible(TableColumn)'
*/
@ -91,11 +96,6 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
}
}
@After
public void tearDown() throws Exception {
cleanupGhidraWithNotepad();
}
/*
* Test method for 'addColumn(TableColumn)', 'removeColumn(TableColumn)', 'getColumnCount()',
* 'getColumn(int)', 'getColumnIndex(Object)', 'getAllColumns()', and 'getColumns()'
@ -106,7 +106,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
GhidraTable table = new GhidraTable(tableModel);
// NOTE: we have to make the table visible for the full persistence mechanism to work. So,
// perform the tests *before* the table is visible, and then perform them after it has
// perform the tests *before* the table is visible, and then perform them after it has
// been made visible
shakeupTable(table);
@ -131,8 +131,8 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
// we need a tool in order to get the DockingWindowManager
loadGhidraWithNotepad();
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
Address address = getAddress(program, 0x010039fe);
int column = 3;
assertTrue(codeBrowser.goToField(address, "Label", 0, 0, column));
@ -158,7 +158,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
String preferenceKey = (String) invokeInstanceMethod("getPreferenceKey", columnModelState);
PreferenceState preferenceState = dockingWindowManager.getPreferenceState(preferenceKey);
// test moving
// test moving
// moveColumn() triggers a saveState()
int columnIndex = 0;
int newColumnIndex = 1;
@ -166,7 +166,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
moveColumn(columnModel, columnIndex, newColumnIndex);
waitForSwing();
// get the updated preference state data
// get the updated preference state data
preferenceState = dockingWindowManager.getPreferenceState(preferenceKey);
List<TableColumn> newColumnList =
getTableColumnsFromPreferencesState(table, preferenceState, columnModelState);
@ -191,8 +191,8 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
// we need a tool in order to get the DockingWindowManager
loadGhidraWithNotepad();
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
Address address = getAddress(program, 0x010039fe);
int column = 3;
assertTrue(codeBrowser.goToField(address, "Label", 0, 0, column));
@ -221,7 +221,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
PreferenceState preferenceState =
getSavedSortStatePreference(preferenceKey, dockingWindowManager);
// test moving
// test moving
// moveColumn() triggers a saveState()
int columnZero = 0;
int columnOne = 1;
@ -307,8 +307,8 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
// we need a tool in order to get the DockingWindowManager
loadGhidraWithNotepad();
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
Address address = getAddress(program, 0x010039fe);
int column = 3;
assertTrue(codeBrowser.goToField(address, "Label", 0, 0, column));
@ -317,7 +317,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
// given location
performAction(showReferencesAction, codeBrowser.getProvider(), true);
// launch the
// launch the
LocationReferencesProvider provider = findProvider();
GhidraTable table = getTable(provider);
waitForTable(table);
@ -366,8 +366,8 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
// we need a tool in order to get the DockingWindowManager
loadGhidraWithNotepad();
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
// NOTE: must make sure that the table is visible, or the persistence will not be activated
// 010039fe - LAB_010039fe
Address address = getAddress(program, 0x010039fe);
int column = 3;
assertTrue(codeBrowser.goToField(address, "Label", 0, 0, column));
@ -376,7 +376,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
// given location
performAction(showReferencesAction, codeBrowser.getProvider(), true);
// launch the
// launch the
LocationReferencesProvider provider = findProvider();
GhidraTable table = getTable(provider);
@ -419,7 +419,7 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
//==================================================================================================
// Private methods
//==================================================================================================
//==================================================================================================
private void waitForTable(GhidraTable table) {
int maxWait = 50;
@ -569,10 +569,8 @@ public class GhidraTableColumnModelTest extends AbstractGhidraHeadedIntegrationT
return;
}
executeOnSwingWithoutBlocking(() -> {
env.dispose();
env = null;
});
env.dispose();
env = null;
// this handles the save changes dialog and potential analysis dialogs
closeAllWindows();

View File

@ -25,6 +25,7 @@ import docking.ComponentProvider;
import docking.DialogComponentProvider;
import docking.action.DockingActionIf;
import ghidra.app.cmd.data.CreateStructureCmd;
import ghidra.app.context.ListingActionContext;
import ghidra.app.events.ProgramLocationPluginEvent;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.table.TableComponentProvider;
@ -224,7 +225,8 @@ public class XrefViewerTest extends AbstractGhidraHeadedIntegrationTest {
// go to new function
DockingActionIf thunkAction = getAction(tool, "Set Thunked Function");
performAction(thunkAction, false);
performAction(thunkAction, new ListingActionContext(cb.getProvider(), cb.getProvider()),
false);
// get dialog
DialogComponentProvider dialog =

View File

@ -49,7 +49,7 @@ public class FunctionBitPatternsExplorerPlugin extends ProgramPlugin {
* @param tool tool
*/
public FunctionBitPatternsExplorerPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
provider = new FunctionBitPatternsMainProvider(this);
patterns = new HashSet<>();
}

View File

@ -86,7 +86,7 @@ public class FunctionGraphPlugin extends ProgramPlugin implements OptionsChangeL
private List<FGLayoutProvider> layoutProviders;
public FunctionGraphPlugin(PluginTool tool) {
super(tool, true, true, true);
super(tool);
colorProvider = new IndependentColorProvider(tool);
}

View File

@ -80,7 +80,7 @@ public class FidDebugPlugin extends ProgramPlugin implements ChangeListener {
private DockingAction createRawFileAction;
public FidDebugPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override

View File

@ -74,7 +74,7 @@ public class FidPlugin extends ProgramPlugin implements ChangeListener {
private DockingAction populateAction;
public FidPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
}
@Override

View File

@ -64,7 +64,7 @@ public class FunctionCallGraphPlugin extends ProgramPlugin implements OptionsCha
});
public FunctionCallGraphPlugin(PluginTool tool) {
super(tool, true, false);
super(tool);
}
@Override

View File

@ -150,11 +150,11 @@ public class ProgramDiffPlugin extends ProgramPlugin
/**
* Creates the plugin for indicating program differences to the user.
*
*
* @param tool the tool that owns this plugin.
*/
public ProgramDiffPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
markerManager = new MarkerManager(this);
@ -232,10 +232,8 @@ public class ProgramDiffPlugin extends ProgramPlugin
@Override
public void processEvent(PluginEvent event) {
if (event instanceof ProgramClosedPluginEvent) {
programClosed(((ProgramClosedPluginEvent) event).getProgram());
}
else if (event instanceof ViewChangedPluginEvent) {
if (event instanceof ViewChangedPluginEvent) {
AddressSet set = ((ViewChangedPluginEvent) event).getView();
// If we are doing a Diff on the entire program then use the combined addresses for both programs.
if (primaryProgram != null && showingSecondProgram) {
@ -267,6 +265,17 @@ public class ProgramDiffPlugin extends ProgramPlugin
}
}
@Override
protected void programClosed(Program program) {
if (primaryProgram == program) {
primaryProgram.removeListener(this);
if (secondaryDiffProgram != null) {
closeProgram2();
}
actionManager.programClosed(program);
}
}
private void viewChanged(AddressSetView p1AddressSet) {
if (primaryProgram != null && !showingSecondProgram) {
return;
@ -478,23 +487,6 @@ public class ProgramDiffPlugin extends ProgramPlugin
}
}
/**
* Called when a program gets closed. If the closed program is the first program of the Diff
* then we need to close the second program.
*
* @param program
*/
@Override
protected void programClosed(Program program) {
if (primaryProgram == program) {
primaryProgram.removeListener(this);
if (secondaryDiffProgram != null) {
closeProgram2();
}
actionManager.programClosed(program);
}
}
void setOpenDiffProgramDialog(OpenVersionedFileDialog dialog) {
this.openProgramDialog = dialog;
}
@ -844,8 +836,6 @@ public class ProgramDiffPlugin extends ProgramPlugin
/**
* Set the highlight based on the current program differences, but do not set the highlight for
* set of addresses to be ignored.
*
* @param ignoreAddressSet the set of addresses to ignore.
*/
private void setDiffHighlight() {
if (diffControl == null) {
@ -955,7 +945,7 @@ public class ProgramDiffPlugin extends ProgramPlugin
/**
* Computes the differences between program1 and program2 that are displayed in the browser. It
* allows the user to specify the Diff settings to use.
*
*
* @param p1LimitSet an address set to use to limit the extent of the Diff.
*/
void diff(AddressSetView p1LimitSet) {
@ -1178,7 +1168,7 @@ public class ProgramDiffPlugin extends ProgramPlugin
/**
* Get the first program for the current Diff. <br>
* <b>Note</b>: This may not be the currently active program.
*
*
* @return the Diff's first program or null if don't currently have a second program associated
* for a Diff.
*/
@ -1188,7 +1178,7 @@ public class ProgramDiffPlugin extends ProgramPlugin
/**
* Get the second program for the current Diff.
*
*
* @return the Diff's second program or null if don't currently have a second program associated
* for a Diff.
*/
@ -1245,7 +1235,7 @@ public class ProgramDiffPlugin extends ProgramPlugin
* Gets the address set where detailed differences will be determined for details at the
* indicated address. An address set is returned since the indicated address may be in different
* sized code units in each of the two programs.
*
*
* @param p1Address the current address from program1 where details are desired.
* @return the address set for code units containing that address within the programs being
* compared to determine differences. Otherwise null if a diff of two programs isn't
@ -1600,9 +1590,8 @@ public class ProgramDiffPlugin extends ProgramPlugin
FieldPanel fp = diffListingPanel.getFieldPanel();
showSecondView();
AddressIndexMap indexMap = diffListingPanel.getAddressIndexMap();
fp.setBackgroundColorModel(
new MarkerServiceBackgroundColorModel(markerManager, secondaryDiffProgram,
indexMap));
fp.setBackgroundColorModel(new MarkerServiceBackgroundColorModel(markerManager,
secondaryDiffProgram, indexMap));
}
finally {
settingLocation = false;
@ -1852,28 +1841,28 @@ public class ProgramDiffPlugin extends ProgramPlugin
}
@Override
public void run(TaskMonitor taskMonitor) {
this.monitor = taskMonitor;
public void run(TaskMonitor tm) {
this.monitor = tm;
try {
try {
monitor.setMessage("Waiting on program file...");
diffProgram =
(Program) domainFile.getImmutableDomainObject(ProgramDiffPlugin.this,
DomainFile.DEFAULT_VERSION, taskMonitor);
DomainFile.DEFAULT_VERSION, monitor);
}
catch (VersionException e) {
if (e.isUpgradable()) {
try {
diffProgram =
(Program) domainFile.getReadOnlyDomainObject(ProgramDiffPlugin.this,
DomainFile.DEFAULT_VERSION, taskMonitor);
DomainFile.DEFAULT_VERSION, monitor);
}
catch (VersionException exc) {
Msg.showError(this, null, "Error Getting Diff Program",
"Getting read only file failed");
}
catch (IOException exc) {
if (!taskMonitor.isCancelled()) {
if (!monitor.isCancelled()) {
Msg.showError(this, null, "Error Getting Diff Program",
"Getting read only file failed", exc);
}

View File

@ -105,7 +105,7 @@ public class ProgramGraphPlugin extends ProgramPlugin
private GraphDisplayProvider defaultGraphService;
public ProgramGraphPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
intializeOptions();
registerProgramFlowGraphDisplayOptionsWithTool();
}

View File

@ -80,7 +80,7 @@ public class PythonPlugin extends ProgramPlugin
* @param tool The tool associated with this plugin.
*/
public PythonPlugin(PluginTool tool) {
super(tool, true, true, true);
super(tool);
}
/**

View File

@ -61,7 +61,7 @@ public class SourceCodeLookupPlugin extends ProgramPlugin {
private DockingAction lookupSourceCodeAction;
public SourceCodeLookupPlugin(PluginTool tool) {
super(tool, false, false);
super(tool);
}
@Override

View File

@ -1255,14 +1255,18 @@ public abstract class AbstractGenericTest extends AbstractGTest {
try {
doRun(swingExceptionCatcher);
}
catch (InterruptedException | InvocationTargetException e) {
// Assume that if we have an exception reported by our catcher, then that is
// the root cause of this exception and do not report this one. The typical
// exception here is an InterrruptedException that is caused by our test
// harness when it is interrupting the test thread after a previous Swing
// exception that we have detected--we don't care to report the
// InterruptedException, as we caused it. The InvocationTargetException should
// be handled by our runnable above.
catch (InterruptedException e) {
// Typically, this InterrruptedException that is caused by our test harness when it
// is interrupting the test thread after a previous Swing exception that we have
// detected--we don't care to throw the InterruptedException, as we caused it.
// Log a message to signal that unusual things may happen when in this state.
Msg.debug(this, "\n>>>>>>>>>>>>>>>> Test thread interrupted. Unusual/unexpected " +
"errors may follow.\n\n");
}
catch (InvocationTargetException e) {
// Assume that if we have an exception reported by our catcher above, then that is
// the root cause of this exception and do not report this one. This should not
// happen, as we are catching the exception above.
}
}

View File

@ -204,15 +204,6 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
protected final PluginDescription pluginDescription =
PluginDescription.getPluginDescription(getClass());
/**
* Temporary compatibility for Plugins that have not been updated to new PluginInfo API.
* <p>
* Contains the list of service classes that this plugin registered as being required.
* <p>
* Ignored if the PluginDescription has values for requiredServices.
*/
private List<Class<?>> legacyRequiredServices = new ArrayList<>();
private List<Class<? extends PluginEvent>> eventsProduced = new ArrayList<>();
private List<Class<? extends PluginEvent>> eventsConsumed = new ArrayList<>();
private List<ServiceInterfaceImplementationPair> services = new ArrayList<>();
@ -239,19 +230,6 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
registerStaticEvents();
}
/**
* Construct a new Plugin.
* <p>
* Deprecated, use {@link Plugin#Plugin(PluginTool)} instead.
*
* @param pluginName name of plugin - not used.
* @param tool tool that will contain this plugin
*/
@Deprecated
protected Plugin(String pluginName, PluginTool tool) {
this(tool);
}
/**
* Auto-registers any services directly implemented by this Plugin instance (i.e.,
* the MyService in "class MyPlugin extends Plugin implements MyService { }" )
@ -278,22 +256,6 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
}
}
/**
* Returns plugin name or null if given class does not extend {@link Plugin}
* <p>
* Deprecated, use {@link PluginUtils#getPluginNameFromClass(Class)}
* <p>
* @param pluginClass the plugin class
* @return the plugin name
*/
@Deprecated
public static String getPluginName(Class<?> pluginClass) {
if (pluginClass != Plugin.class && Plugin.class.isAssignableFrom(pluginClass)) {
return pluginClass.getSimpleName();
}
return null;
}
protected void cleanup() {
if (!disposed) {
Throwable thr = null;
@ -305,7 +267,6 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
thr = t;
}
tool.removeServiceListener(this);
legacyRequiredServices.clear();
unregisterServices();
unregisterEvents();
tool.removeAll(getName());
@ -527,8 +488,7 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
* @return true if this plugin depends on the given plugin
*/
public boolean dependsUpon(Plugin plugin) {
for (Class<?> c : getList(pluginDescription.getServicesRequired(),
legacyRequiredServices)) {
for (Class<?> c : pluginDescription.getServicesRequired()) {
// If one of our required services is provided by a single Plugin,
// then we depend on that Plugin. If multiple provide, we are not dependent.
if (plugin.isOnlyProviderOfService(c)) {
@ -540,8 +500,7 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
public List<Class<?>> getMissingRequiredServices() {
List<Class<?>> missingServices = new ArrayList<>();
for (Class<?> requiredServiceClass : getList(pluginDescription.getServicesRequired(),
legacyRequiredServices)) {
for (Class<?> requiredServiceClass : pluginDescription.getServicesRequired()) {
if (tool.getService(requiredServiceClass) == null) {
missingServices.add(requiredServiceClass);
}
@ -555,8 +514,7 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
* @return boolean true if a required service isn't available via the PluginTool.
*/
public boolean hasMissingRequiredService() {
for (Class<?> depClass : getList(pluginDescription.getServicesRequired(),
legacyRequiredServices)) {
for (Class<?> depClass : pluginDescription.getServicesRequired()) {
if (tool.getService(depClass) == null) {
return true;
}
@ -564,31 +522,6 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
return false;
}
/**
* Used to choose between lists to support the old Plugin ABI backward compatible lists
*
* @param l1 the new list from the static PluginDescription config - preferred if it has any elements
* @param l2 the old list - only returned if l1 is empty
* @return either l1 or l2, depending on which one has elements.
*/
private static <T> List<T> getList(List<T> l1, List<T> l2) {
return !l1.isEmpty() ? l1 : l2;
}
/**
* Register event that this plugin produces.
* <p>
* Deprecated, use {@link PluginInfo @PluginInfo.eventsProduced} instead.
* <p>
* @param eventClass Class of the produced event; class is required to force it
* to be loaded
*/
@Deprecated
protected final void registerEventProduced(Class<? extends PluginEvent> eventClass) {
eventsProduced.add(eventClass);
tool.registerEventProduced(eventClass);
}
private void unregisterEvents() {
for (Class<? extends PluginEvent> c : eventsConsumed) {
tool.removeEventListener(c, this);
@ -601,23 +534,11 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
/**
* Register event that this plugin consumes.
* <p>
* Deprecated, use {@link PluginInfo @PluginInfo.eventsConsumed} instead.
* <p>
* @param eventClass Class for the event; class is required to force it
* to be loaded
* This method is for internal use. If plugins wish to manage events consumed, then they should
* use the {@link PluginInfo} annotation to do so.
* @param eventClass Class for the event; class is required to force it to be loaded
*/
@Deprecated
protected final void registerEventConsumed(Class<? extends PluginEvent> eventClass) {
registerDynamicEventConsumed(eventClass);
}
/**
* Register event that this plugin consumes.
* <p>
* @param eventClass Class for the event; class is required to force it
* to be loaded
*/
protected final void registerDynamicEventConsumed(Class<? extends PluginEvent> eventClass) {
protected final void internalRegisterEventConsumed(Class<? extends PluginEvent> eventClass) {
eventsConsumed.add(eventClass);
tool.addEventListener(eventClass, this);
}
@ -710,7 +631,7 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
protected final List<Class<?>> getServicesRequired() {
// return either the new PluginDescription servicesRequired or the old
// deprecated legacyRequiredServices.
return getList(pluginDescription.getServicesRequired(), legacyRequiredServices);
return pluginDescription.getServicesRequired();
}
private void unregisterServices() {
@ -719,26 +640,6 @@ public abstract class Plugin implements ExtensionPoint, PluginEventListener, Ser
}
}
/**
* Registers a dependency on a service interface Class.
* <p>
* This method is deprecated. Use {@link PluginInfo#servicesRequired() @PluginInfo.servicesRequired}
* instead.
* <p>
* @param interfaceClass interface class that this plugin depends on
* @param isDependency boolean flag, if true this plugin will not work without the
* specified service, if false this service can work without it. If false, this
* method is a no-op as non-dependency registration information is now discarded.
*/
@Deprecated
protected final void registerServiceUsed(Class<?> interfaceClass, boolean isDependency) {
if (isDependency) {
legacyRequiredServices.add(interfaceClass);
}
// information about non-dependency used-services is discarded. Only
// required services are retained.
}
protected final void deregisterService(Class<?> interfaceClass, Object service) {
for (int i = 0; i < services.size(); i++) {

View File

@ -107,7 +107,7 @@ public @interface PluginInfo {
/**
* List of PluginEvent (classes) that this Plugin produces.
*
* @return PluginEvent class list, defaults to emtpy.
* @return PluginEvent class list, defaults to empty.
*/
Class<? extends PluginEvent>[] eventsProduced() default {};

View File

@ -54,7 +54,7 @@ public class SkeletonPlugin extends ProgramPlugin {
* @param tool The plugin tool that this plugin is added to.
*/
public SkeletonPlugin(PluginTool tool) {
super(tool, true, true);
super(tool);
// TODO: Customize provider (or remove if a provider is not desired)
String pluginName = getName();