Package ghidra.app.plugin
Class ProgramPlugin
- java.lang.Object
-
- ghidra.framework.plugintool.Plugin
-
- ghidra.app.plugin.ProgramPlugin
-
- All Implemented Interfaces:
PluginEventListener,ServiceListener,ExtensionPoint
- Direct Known Subclasses:
PropertyManagerPlugin,PythonPlugin,ScreenshotPlugin
public abstract class ProgramPlugin extends Plugin
Base class to handle common program events: Program Open/Close, Program Location, Program Selection, and Program Highlight.Subclasses should override the following methods if they are interested in the corresponding events:
-
programOpened(Program) -
programClosed(Program) -
locationChanged(ProgramLocation) -
selectionChanged(ProgramSelection) -
highlightChanged(ProgramSelection)
This class will handle the enablement and add to popup state for plugin actions when subclasses call any of the following methods:enableOnHighlight(PluginAction)enableOnLocation(PluginAction)enableOnProgram(PluginAction)enableOnSelection(PluginAction)
-
-
Field Summary
Fields Modifier and Type Field Description protected ProgramSelectioncurrentHighlightprotected ProgramLocationcurrentLocationprotected ProgramcurrentProgramprotected ProgramSelectioncurrentSelection-
Fields inherited from class ghidra.framework.plugintool.Plugin
name, pluginDescription, tool
-
-
Constructor Summary
Constructors Constructor Description ProgramPlugin(PluginTool tool, boolean consumeLocationChange, boolean consumeSelectionChange)ProgramPlugin(PluginTool plugintool, boolean consumeLocationChange, boolean consumeSelectionChange, boolean consumeHighlightChange)Constructs a new program plugin
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidenableOnHighlight(DockingAction action)Deprecated.ActionContextis now used for action enablement.protected voidenableOnLocation(DockingAction action)Deprecated.ActionContextis now used for action enablement.protected voidenableOnProgram(DockingAction action)Deprecated.ActionContextis now used for action enablement.protected voidenableOnSelection(DockingAction action)Deprecated.ActionContextis now used for action enablement.ProgramgetCurrentProgram()ProgramSelectiongetProgramHighlight()ProgramLocationgetProgramLocation()ProgramSelectiongetProgramSelection()protected booleangoTo(Address addr)Convenience method to go to the specified address.protected booleangoTo(CodeUnit cu)protected voidhighlightChanged(ProgramSelection hl)Subclass should override this method if it is interested in program highlight events.protected voidlocationChanged(ProgramLocation loc)Subclass should override this method if it is interested in program location events.voidprocessEvent(PluginEvent event)Process the plugin event.protected voidprogramActivated(Program program)Subclass should override this method if it is interested when programs become active.protected voidprogramClosed(Program program)Subclasses should override this method if it is interested when a program is closed.protected voidprogramDeactivated(Program program)Subclass should override this method if it is interested when programs become inactive.protected voidprogramOpened(Program program)Subclasses should override this method if it is interested when a program is opened.protected voidselectionChanged(ProgramSelection sel)Subclass should override this method if it is interested in program selection events.protected voidsetBookmark(Address addr, java.lang.String type, java.lang.String category, java.lang.String comment)Convenience method to set a bookmark;protected voidsetSelection(AddressSetView set)Convenience method to fire a program selection event.-
Methods inherited from class ghidra.framework.plugintool.Plugin
acceptData, canClose, canCloseDomainObject, cleanup, close, dataStateRestoreCompleted, dependsUpon, deregisterService, dispose, equals, eventSent, firePluginEvent, getData, getMissingRequiredServices, getName, getPluginDescription, getPluginName, getServicesRequired, getSupportedDataTypes, getTool, getTransientState, getUndoRedoState, hashCode, hasMissingRequiredService, hasUnsaveData, init, isDisposed, prepareToSave, readConfigState, readDataState, registerDynamicEventConsumed, registerDynamicServiceProvided, registerEventConsumed, registerEventProduced, registerServiceProvided, registerServiceUsed, restoreTransientState, restoreUndoRedoState, saveData, serviceAdded, serviceRemoved, writeConfigState, writeDataState
-
-
-
-
Field Detail
-
currentProgram
protected Program currentProgram
-
currentLocation
protected ProgramLocation currentLocation
-
currentSelection
protected ProgramSelection currentSelection
-
currentHighlight
protected ProgramSelection currentHighlight
-
-
Constructor Detail
-
ProgramPlugin
public ProgramPlugin(PluginTool plugintool, boolean consumeLocationChange, boolean consumeSelectionChange, boolean consumeHighlightChange)
Constructs a new program plugin- Parameters:
plugintool- tool the parent tool for this pluginconsumeLocationChange- true if this plugin should consume ProgramLocation eventsconsumeSelectionChange- true if this plugin should consume ProgramSelection eventsconsumeHighlightChange- true if this plugin should consume ProgramHighlight events
-
ProgramPlugin
public ProgramPlugin(PluginTool tool, boolean consumeLocationChange, boolean consumeSelectionChange)
-
-
Method Detail
-
processEvent
public void processEvent(PluginEvent event)
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.Note: if the subclass overrides processEvent(), it should call super.processEvent().
- Overrides:
processEventin classPlugin- Parameters:
event- plugin to process
-
enableOnProgram
@Deprecated protected void enableOnProgram(DockingAction action)
Deprecated.ActionContextis now used for action enablement. Deprecated in 9.1; to be removed no sooner than two versions after that.Enable the action when the program is opened; disable it when the program is closed.- Throws:
java.lang.IllegalArgumentException- if this action was called for another enableOnXXX(PlugAction) method.
-
enableOnLocation
@Deprecated protected void enableOnLocation(DockingAction action)
Deprecated.ActionContextis now used for action enablement. Deprecated in 9.1; to be removed no sooner than two versions after that.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:
java.lang.IllegalArgumentException- if this action was called for another enableOnXXX(PlugAction) method.
-
enableOnSelection
@Deprecated protected void enableOnSelection(DockingAction action)
Deprecated.ActionContextis now used for action enablement. Deprecated in 9.1; to be removed no sooner than two versions after that.Enable the action when a selection event comes in; disable it if the selection is null or empty.- Throws:
java.lang.IllegalArgumentException- if this action was called for another enableOnXXX(PlugAction) method.
-
enableOnHighlight
@Deprecated protected void enableOnHighlight(DockingAction action)
Deprecated.ActionContextis now used for action enablement. Deprecated in 9.1; to be removed no sooner than two versions after that.Enable the action when a highlight event comes in; disable it if the highlight is null or empty.- Throws:
java.lang.IllegalArgumentException- if this action was called for another enableOnXXX(PlugAction) method.
-
programActivated
protected void programActivated(Program program)
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, the "currentProgram" variable will be set the new active program.- Parameters:
program- the new program going active.
-
programClosed
protected void programClosed(Program program)
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.- Parameters:
program- the program being closed.
-
programOpened
protected void programOpened(Program program)
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.- Parameters:
program- the program being opened.
-
programDeactivated
protected void programDeactivated(Program program)
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 a currently active program. 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.- Parameters:
program- the old program going inactive.
-
locationChanged
protected void locationChanged(ProgramLocation loc)
Subclass should override this method if it is interested in program location events.- Parameters:
loc- location could be null
-
selectionChanged
protected void selectionChanged(ProgramSelection sel)
Subclass should override this method if it is interested in program selection events.- Parameters:
sel- selection could be null
-
highlightChanged
protected void highlightChanged(ProgramSelection hl)
Subclass should override this method if it is interested in program highlight events.- Parameters:
hl- highlight could be null
-
goTo
protected boolean goTo(Address addr)
Convenience method to go to the specified address.
-
goTo
protected boolean goTo(CodeUnit cu)
-
setSelection
protected void setSelection(AddressSetView set)
Convenience method to fire a program selection event.- Parameters:
set- address set for the selection.
-
setBookmark
protected void setBookmark(Address addr, java.lang.String type, java.lang.String category, java.lang.String comment)
Convenience method to set a bookmark;- Parameters:
addr- address of where the bookmark will be placedtype- type of bookmark: BookMarkType.NOTE, BookmarkType.INFO, BookmarkType.ANALYSIS, or BookmarkType.ERROR.category- category for the bookmarkcomment- bookmark comment
-
getProgramLocation
public ProgramLocation getProgramLocation()
-
getCurrentProgram
public Program getCurrentProgram()
-
getProgramSelection
public ProgramSelection getProgramSelection()
-
getProgramHighlight
public ProgramSelection getProgramHighlight()
-
-