Class CodeComparisonPanel

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ghidra.features.base.codecompare.panel.CodeComparisonPanel
All Implemented Interfaces:
ExtensionPoint, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
ListingCodeComparisonPanel

public abstract class CodeComparisonPanel extends JPanel implements ExtensionPoint
The CodeComparisonPanel class should be extended by any class that is to be discovered by the FunctionComparisonPanel class and included as a form of comparing two sections of code within the same or different programs

NOTE: ALL CodeComparisonPanel CLASSES MUST END IN CodeComparisonPanel so they are discoverable by the ClassSearcher

See Also:
  • Field Details

  • Constructor Details

    • CodeComparisonPanel

      protected CodeComparisonPanel(String owner, PluginTool tool)
      Constructor
      Parameters:
      owner - the name of the owner of this component
      tool - the tool that contains the component
  • Method Details

    • loadComparisons

      public void loadComparisons(ComparisonData left, ComparisonData right)
      Displays a comparison of two ComparisonData objects
      Parameters:
      left - the comparisonData for the left side
      right - the comparisonData for the right side
    • clearComparisons

      public void clearComparisons()
      Clears out the current comparisonDatas
    • getActions

      public List<DockingAction> getActions()
      Returns the actions for this panel
      Returns:
      an array of docking actions
    • setShowDataTitles

      public void setShowDataTitles(boolean showTitles)
      Toggles whether or not to display data titles for each side.
      Parameters:
      showTitles - true to show data titles
    • isSideBySide

      public boolean isSideBySide()
      Returns true if dual panels are displayed horizontally, false if displayed vertically.
      Returns:
      true if dual panels are displayed horizontally, false if displayed vertically
    • setSideBySide

      public void setSideBySide(boolean b)
      Sets the orientation for the dual panels.
      Parameters:
      b - if true, panels will be display horizontally, otherwise vertically
    • getName

      public abstract String getName()
      Force subclasses to supply a descriptive name.
      Overrides:
      getName in class Component
      Returns:
      a descriptive name for this panel type
    • dispose

      public abstract void dispose()
      Cleans up resources when this panel is no longer needed
    • getActionContext

      public abstract ActionContext getActionContext(ComponentProvider componentProvider, MouseEvent event)
      Returns the context object which corresponds to the area of focus within this provider's component. Null is returned when there is no context.
      Parameters:
      componentProvider - the provider that includes this code comparison component.
      event - mouse event which corresponds to this request. May be null for key-stroke or other non-mouse event.
      Returns:
      the action context for the area of focus in this component.
    • programRestored

      public void programRestored(Program program)
      Called when the indicated program has been restored because of an Undo/Redo. This method allows this CodeComparisonPanel to take an appropriate action (such as refreshing itself) to respond to the program changing.
      Parameters:
      program - the program that was restored.
    • programClosed

      public void programClosed(Program program)
      Called when a program is closed.
      Parameters:
      program - the closed program
    • getActiveSide

      public Duo.Side getActiveSide()
      Returns the Duo.Side that is currently active
      Returns:
      the Duo.Side that is currently active
    • setTopComponent

      public void setTopComponent(JComponent component)
      Sets the component displayed in the top of this panel.
      Parameters:
      component - the component.
    • setTitlePrefixes

      public void setTitlePrefixes(String leftTitlePrefix, String rightTitlePrefix)
      A CodeComparisonPanel should provide a title based on what the code comparison panel is displaying. This method sets a prefix string that should be prepended to each of the code comparison panel's titles.
      Parameters:
      leftTitlePrefix - the prefix string to prepend to the left panel's title.
      rightTitlePrefix - the prefix string to prepend to the right panel's title.
    • getProgram

      public Program getProgram(Duo.Side side)
      Returns the program being shown in the given side.
      Parameters:
      side - the Duo.Side to get the program for
      Returns:
      the program for the given side.
    • getFunction

      public Function getFunction(Duo.Side side)
      Returns the function being shown in the given side.
      Parameters:
      side - the Duo.Side to get the function for
      Returns:
      the function for the given side.
    • getAddresses

      public AddressSetView getAddresses(Duo.Side side)
      Returns the addresses being shown in the given side.
      Parameters:
      side - the Duo.Side to get the program for
      Returns:
      the address set for the given side
    • updateActionEnablement

      public abstract void updateActionEnablement()
      Updates the enablement for any actions created by this code comparison panel.
    • setSynchronizedScrolling

      public abstract void setSynchronizedScrolling(boolean b)
      Sets whether or not scrolling is synchronized.
      Parameters:
      b - true means synchronize scrolling between the two views.
    • getComparisonComponent

      public abstract JComponent getComparisonComponent(Duo.Side side)
      Returns the Component for the given Duo.Side
      Parameters:
      side - the Side to its component
      Returns:
      the Component for the given Duo.Side
    • comparisonDataChanged

      protected abstract void comparisonDataChanged()
      Notification to subclasses that the comparison data has changed
    • buildPanel

      protected final void buildPanel()
    • setActiveSide

      protected void setActiveSide(Duo.Side side)