Package ghidra.app.util.viewer.util
Class CodeComparisonPanel<T extends FieldPanelCoordinator>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ghidra.app.util.viewer.util.CodeComparisonPanel<T>
- Type Parameters:
T
- the type
- All Implemented Interfaces:
ExtensionPoint
,FocusListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
- Direct Known Subclasses:
DecompilerCodeComparisonPanel
,ListingCodeComparisonPanel
public abstract class CodeComparisonPanel<T extends FieldPanelCoordinator>
extends JPanel
implements ExtensionPoint, FocusListener
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:
-
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
FieldsModifier and TypeFieldDescriptionprotected JComponent
protected int
protected Data[]
protected static final AddressSetView
protected static final Border
protected Function[]
protected static final int
protected String
protected static final int
protected static final Border
protected String
protected Program[]
protected static final int
protected String
protected TitledPanel[]
protected PluginTool
protected JComponent
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
ConstructorsModifierConstructorDescriptionprotected
CodeComparisonPanel
(String owner, PluginTool tool) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
Creates a new FieldPanelCoordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.abstract void
dispose()
Cleans up resources when this panel is no longer neededvoid
abstract ActionContext
getActionContext
(ComponentProvider componentProvider, MouseEvent event) Returns the context object which corresponds to the area of focus within this provider's component.Returns the actions for this panelabstract JComponent
The GUI component for this CodeComparisonPanelprotected T
Gets the current field panel coordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.abstract AddressSetView
Gets the addresses loaded in the left side of this panel.Gets the data loaded in the left side of this panel.abstract FieldPanel
Gets the left field panel for this CodeComparisonPanel.Gets the function loaded in the left side of this panel.Gets the program being viewed in the left side of this panel.abstract Class<? extends CodeComparisonPanel<T>>
Determines if this panel is intended to take the place of another and if so it returns the class of the panel to be superseded.abstract AddressSetView
Gets the addresses loaded in the right side of this panel.Gets the data loaded in the right side of this panel.abstract FieldPanel
Gets the right field panel for this CodeComparisonPanel.Gets the function loaded in the right side of this panel.Gets the program being viewed in the right side of this panel.boolean
abstract String
getTitle()
The title for this code comparison panelfinal boolean
Determines if the layouts of the views are synchronized with respect to scrolling and location.abstract boolean
Determines if the left code panel currently has focus.abstract void
loadAddresses
(Program leftProgram, Program rightProgram, AddressSetView leftAddresses, AddressSetView rightAddresses) Displays program information for a particular set of addresses in the two programs being comparedabstract void
Displays a comparison of two program's data itemsabstract void
loadFunctions
(Function leftFunction, Function rightFunction) Displays a comparison of two program's functionsabstract void
programRestored
(Program program) Called when the indicated program has been restored because of an Undo/Redo.abstract void
Refreshes the left side of this panel.abstract void
Refreshes the right side of this panel.void
setFieldPanelCoordinator
(T fieldPanelCoordinator) Sets the coordinator for the two views within this code comparison panel.abstract void
setMouseNavigationEnabled
(boolean enabled) Enable/disable navigation in this panel using the mouseprotected abstract void
setPrograms
(Program leftProgram, Program rightProgram) Specifies the two programs to be compared by this panelvoid
setScrollingSyncState
(boolean syncScrolling) Sets whether or not scrolling is synchronized.void
setShowTitles
(boolean showTitles) abstract void
setTitlePrefixes
(String leftTitlePrefix, String rightTitlePrefix) A CodeComparisonPanel should provide a title based on what the code comparison panel is displaying.abstract void
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, getName, 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
Methods inherited from interface java.awt.event.FocusListener
focusGained
-
Field Details
-
MINIMUM_PANEL_WIDTH
protected static final int MINIMUM_PANEL_WIDTH- See Also:
-
LEFT
protected static final int LEFT- See Also:
-
RIGHT
protected static final int RIGHT- See Also:
-
FOCUS_BORDER
-
NON_FOCUS_BORDER
-
EMPTY_ADDRESS_SET
-
owner
-
tool
-
topComp
-
bottomComp
-
titlePanels
-
leftTitlePrefix
-
rightTitlePrefix
-
currProgramIndex
protected int currProgramIndex -
programs
-
functions
-
data
-
-
Constructor Details
-
CodeComparisonPanel
Constructor- Parameters:
owner
- the name of the owner of this componenttool
- the tool that contains the component
-
-
Method Details
-
getComponent
The GUI component for this CodeComparisonPanel- Returns:
- the component
-
getTitle
The title for this code comparison panel- Returns:
- the title
-
setPrograms
Specifies the two programs to be compared by this panel- Parameters:
leftProgram
- the program for the left siderightProgram
- the program for the right side
-
loadFunctions
Displays a comparison of two program's functions- Parameters:
leftFunction
- the function to show in the left side of the code comparison viewrightFunction
- the function to show in the right side of the code comparison view
-
loadData
Displays a comparison of two program's data items- Parameters:
leftData
- the data item to show in the left side of the code comparison viewrightData
- the data item to show in the right side of the code comparison view
-
loadAddresses
public abstract void loadAddresses(Program leftProgram, Program rightProgram, AddressSetView leftAddresses, AddressSetView rightAddresses) Displays program information for a particular set of addresses in the two programs being compared- Parameters:
leftProgram
- the program in the left side of the code comparison viewrightProgram
- the program in the right side of the code comparison viewleftAddresses
- the addresses of the program info to show in the left siderightAddresses
- the addresses of the program info to show in the right side
-
dispose
public abstract void dispose()Cleans up resources when this panel is no longer needed -
getActions
Returns the actions for this panel- Returns:
- an array of docking actions
-
getShowTitles
public boolean getShowTitles() -
setShowTitles
public void setShowTitles(boolean showTitles) -
getPanelThisSupersedes
Determines if this panel is intended to take the place of another and if so it returns the class of the panel to be superseded.- Returns:
- the class for the CodeComparisonPanel that this one supersedes or null if it doesn't supersede another panel.
-
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
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.
-
leftPanelHasFocus
public abstract boolean leftPanelHasFocus()Determines if the left code panel currently has focus.- Returns:
- true if the left side of the code comparison has focus.
-
setTitlePrefixes
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.
-
getLeftProgram
Gets the program being viewed in the left side of this panel.- Returns:
- the program or null
-
getRightProgram
Gets the program being viewed in the right side of this panel.- Returns:
- the program or null
-
getLeftFunction
Gets the function loaded in the left side of this panel.- Returns:
- the function or null
-
getRightFunction
Gets the function loaded in the right side of this panel.- Returns:
- the function or null
-
getLeftData
Gets the data loaded in the left side of this panel.- Returns:
- the data or null
-
getRightData
Gets the data loaded in the right side of this panel.- Returns:
- the data or null
-
getLeftAddresses
Gets the addresses loaded in the left side of this panel.- Returns:
- the addresses or an empty set
-
getRightAddresses
Gets the addresses loaded in the right side of this panel.- Returns:
- the addresses or an empty set
-
refreshLeftPanel
public abstract void refreshLeftPanel()Refreshes the left side of this panel. -
refreshRightPanel
public abstract void refreshRightPanel()Refreshes the right side of this panel. -
focusLost
- Specified by:
focusLost
in interfaceFocusListener
-
updateActionEnablement
public abstract void updateActionEnablement()Updates the enablement for any actions created by this code comparison panel. -
setFieldPanelCoordinator
Sets the coordinator for the two views within this code comparison panel. It coordinates their scrolling and location synchronization.- Parameters:
fieldPanelCoordinator
- the coordinator for the two views
-
getFieldPanelCoordinator
Gets the current field panel coordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.- Returns:
- the current FieldPanelCoordinator. Otherwise, null if scrolling is not currently synchronized.
-
createFieldPanelCoordinator
Creates a new FieldPanelCoordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.- Returns:
- a new FieldPanelCoordinator
-
getLeftFieldPanel
Gets the left field panel for this CodeComparisonPanel.- Returns:
- the left FieldPanel.
-
getRightFieldPanel
Gets the right field panel for this CodeComparisonPanel.- Returns:
- the right FieldPanel.
-
isScrollingSynced
public final boolean isScrollingSynced()Determines if the layouts of the views are synchronized with respect to scrolling and location.- Returns:
- true if scrolling is synchronized between the two views.
-
setScrollingSyncState
public void setScrollingSyncState(boolean syncScrolling) Sets whether or not scrolling is synchronized.- Parameters:
syncScrolling
- true means synchronize scrolling and location between the two views.
-