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.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JComponentprotected intprotected Data[]protected static final AddressSetViewprotected static final Borderprotected Function[]protected static final intprotected Stringprotected static final intprotected static final Borderprotected Stringprotected Program[]protected static final intprotected Stringprotected TitledPanel[]protected PluginToolprotected JComponentFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCodeComparisonPanel(String owner, PluginTool tool) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TCreates a new FieldPanelCoordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.abstract voiddispose()Cleans up resources when this panel is no longer neededvoidabstract ActionContextgetActionContext(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 JComponentThe GUI component for this CodeComparisonPanelprotected TGets the current field panel coordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.abstract AddressSetViewGets the addresses loaded in the left side of this panel.Gets the data loaded in the left side of this panel.abstract FieldPanelGets 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 AddressSetViewGets the addresses loaded in the right side of this panel.Gets the data loaded in the right side of this panel.abstract FieldPanelGets 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.booleanabstract StringgetTitle()The title for this code comparison panelfinal booleanDetermines if the layouts of the views are synchronized with respect to scrolling and location.abstract booleanDetermines if the left code panel currently has focus.abstract voidloadAddresses(Program leftProgram, Program rightProgram, AddressSetView leftAddresses, AddressSetView rightAddresses) Displays program information for a particular set of addresses in the two programs being comparedabstract voidDisplays a comparison of two program's data itemsabstract voidloadFunctions(Function leftFunction, Function rightFunction) Displays a comparison of two program's functionsabstract voidprogramRestored(Program program) Called when the indicated program has been restored because of an Undo/Redo.abstract voidRefreshes the left side of this panel.abstract voidRefreshes the right side of this panel.voidsetFieldPanelCoordinator(T fieldPanelCoordinator) Sets the coordinator for the two views within this code comparison panel.abstract voidsetMouseNavigationEnabled(boolean enabled) Enable/disable navigation in this panel using the mouseprotected abstract voidsetPrograms(Program leftProgram, Program rightProgram) Specifies the two programs to be compared by this panelvoidsetScrollingSyncState(boolean syncScrolling) Sets whether or not scrolling is synchronized.voidsetShowTitles(boolean showTitles) abstract voidsetTitlePrefixes(String leftTitlePrefix, String rightTitlePrefix) A CodeComparisonPanel should provide a title based on what the code comparison panel is displaying.abstract voidUpdates the enablement for any actions created by this code comparison panel.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, updateMethods 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, validateTreeMethods 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, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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) -
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:
focusLostin 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.
-