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