Package ghidra.features.base.codecompare.panel

# Class CodeComparisonView

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ghidra.features.base.codecompare.panel.CodeComparisonView

All Implemented Interfaces:
  `ExtensionPoint`, `ImageObserver`, `MenuContainer`, `Serializable`, `Accessible`

Direct Known Subclasses:
  `ListingCodeComparisonView`

public abstract class CodeComparisonView extends JPanel implements ExtensionPoint
The `CodeComparisonView` 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 CodeComparisonView CLASSES MUST END IN `CodeComparisonView` so they are discoverable by the `ClassSearcher`

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class javax.swing.JPanel

  `JPanel.AccessibleJPanel`

  ## Nested classes/interfaces inherited from class javax.swing.JComponent

  `JComponent.AccessibleJComponent`

  ## Nested classes/interfaces inherited from class java.awt.Container

  `Container.AccessibleAWTContainer`

  ## Nested classes/interfaces inherited from class java.awt.Component

  `Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Duo.Side`
  `activeSide`
  `protected Duo<ComparisonData>`
  `comparisonData`
  `static final String`
  `HELP_TOPIC`
  `protected String`
  `owner`
  `protected PluginTool`
  `tool`

  ### Fields inherited from class javax.swing.JComponent

  `listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

  ### Fields inherited from class java.awt.Component

  `accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

  ### Fields inherited from interface java.awt.image.ImageObserver

  `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `CodeComparisonView(String owner, PluginTool tool)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addMouseAndFocusListeners(Duo.Side side)`
  `protected final void`
  `buildPanel()`
  `void`
  `clearComparisons()`
  Clears out the current comparisonDatas
  `protected abstract void`
  `comparisonDataChanged()`
  Notification to subclasses that the comparison data has changed
  `abstract void`
  `dispose()`
  Cleans up resources when this panel is no longer needed
  `abstract ActionContext`
  `getActionContext(ComponentProvider componentProvider, MouseEvent event)`
  Returns the context object which corresponds to the area of focus within this view's component.
  `List<DockingAction>`
  `getActions()`
  Returns the actions for this panel
  `Duo.Side`
  `getActiveSide()`
  Returns the `Duo.Side` that is currently active
  `AddressSetView`
  `getAddresses(Duo.Side side)`
  Returns the addresses being shown in the given side.
  `abstract JComponent`
  `getComparisonComponent(Duo.Side side)`
  Returns the Component for the given `Duo.Side`
  `Function`
  `getFunction(Duo.Side side)`
  Returns the function being shown in the given side.
  `abstract String`
  `getName()`
  Force subclasses to supply a descriptive name.
  `Program`
  `getProgram(Duo.Side side)`
  Returns the program being shown in the given side.
  `PluginTool`
  `getTool()`
  `boolean`
  `isSideBySide()`
  Returns true if dual panels are displayed horizontally, false if displayed vertically.
  `void`
  `loadComparisons(ComparisonData left, ComparisonData right)`
  Displays a comparison of two ComparisonData objects
  `void`
  `programClosed(Program program)`
  Called when a program is closed.
  `void`
  `programRestored(Program program)`
  Called when the indicated program has been restored because of an Undo/Redo.
  `protected void`
  `setActiveSide(Duo.Side side)`
  `void`
  `setOrientationChangedCallback(Callback callback)`
  `void`
  `setSaveState(SaveState saveState)`
  `void`
  `setShowDataTitles(boolean showTitles)`
  Toggles whether or not to display data titles for each side.
  `void`
  `setSideBySide(boolean b)`
  Sets the orientation for the dual panels.
  `abstract void`
  `setSynchronizedScrolling(boolean b)`
  Sets whether or not scrolling is synchronized.
  `void`
  `setTitlePrefixes(String leftTitlePrefix, String rightTitlePrefix)`
  A CodeComparisonPanel should provide a title based on what the code comparison panel is displaying.
  `void`
  `setTopComponent(JComponent component)`
  Sets the component displayed in the top of this panel.
  `abstract void`
  `updateActionEnablement()`
  Updates the enablement for any actions created by this code comparison panel.

  ### Methods inherited from class javax.swing.JPanel

  `getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI`

  ### Methods inherited from class javax.swing.JComponent

  `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

  ### Methods inherited from class java.awt.Container

  `add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree`

  ### Methods inherited from class java.awt.Component

  `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### HELP_TOPIC

    public static final String HELP_TOPIC
    See Also:
      - Constant Field Values

  - ### owner

    protected String owner

  - ### tool

    protected PluginTool tool

  - ### comparisonData

    protected Duo<ComparisonData> comparisonData

  - ### activeSide

    protected Duo.Side activeSide

- ## Constructor Details

  - ### CodeComparisonView

    protected CodeComparisonView(String owner, PluginTool tool)
    Constructor
    Parameters:
      `owner` - the name of the owner of this component
      `tool` - the tool that contains the component

- ## Method Details

  - ### getTool

    public PluginTool getTool()

  - ### setSaveState

    public void setSaveState(SaveState saveState)

  - ### 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 view'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

  - ### setOrientationChangedCallback

    public void setOrientationChangedCallback(Callback callback)

  - ### buildPanel

    protected final void buildPanel()

  - ### addMouseAndFocusListeners

    protected void addMouseAndFocusListeners(Duo.Side side)

  - ### setActiveSide

    protected void setActiveSide(Duo.Side side)