Class 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)
    • 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 plugin
        consumeLocationChange - true if this plugin should consume ProgramLocation events
        consumeSelectionChange - true if this plugin should consume ProgramSelection events
        consumeHighlightChange - 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:
        processEvent in class Plugin
        Parameters:
        event - plugin to process
      • enableOnProgram

        @Deprecated
        protected void enableOnProgram​(DockingAction action)
        Deprecated.
        ActionContext is 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.
        ActionContext is 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.
        ActionContext is 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.
        ActionContext is 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 placed
        type - type of bookmark: BookMarkType.NOTE, BookmarkType.INFO, BookmarkType.ANALYSIS, or BookmarkType.ERROR.
        category - category for the bookmark
        comment - bookmark comment
      • getCurrentProgram

        public Program getCurrentProgram()