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>
-
- All Implemented Interfaces:
ExtensionPoint,java.awt.event.FocusListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible
- Direct Known Subclasses:
DecompilerCodeComparisonPanel,ListingCodeComparisonPanel
public abstract class CodeComparisonPanel<T extends FieldPanelCoordinator> extends javax.swing.JPanel implements ExtensionPoint, java.awt.event.FocusListener
The CodeComparisonPanel class should be extended by any class that is to be discovered by theFunctionComparisonPanelclass and included as a form of comparing two sections of code within the same or different programsNOTE: ALL CodeComparisonPanel CLASSES MUST END IN
CodeComparisonPanelso they are discoverable by theClassSearcher- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.JComponentbottomCompprotected intcurrProgramIndexprotected Data[]dataprotected static AddressSetViewEMPTY_ADDRESS_SETprotected static javax.swing.border.BorderFOCUS_BORDERprotected Function[]functionsprotected static intLEFTprotected java.lang.StringleftTitlePrefixprotected static intMINIMUM_PANEL_WIDTHprotected static javax.swing.border.BorderNON_FOCUS_BORDERprotected java.lang.Stringownerprotected Program[]programsprotected static intRIGHTprotected java.lang.StringrightTitlePrefixprotected TitledPanel[]titlePanelsprotected PluginTooltoolprotected javax.swing.JComponenttopComp-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCodeComparisonPanel(java.lang.String owner, PluginTool tool)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TcreateFieldPanelCoordinator()Creates 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 neededvoidfocusLost(java.awt.event.FocusEvent e)abstract ActionContextgetActionContext(ComponentProvider componentProvider, java.awt.event.MouseEvent event)Returns the context object which corresponds to the area of focus within this provider's component.DockingAction[]getActions()Returns the actions for this panelabstract javax.swing.JComponentgetComponent()The GUI component for this CodeComparisonPanelprotected TgetFieldPanelCoordinator()Gets the current field panel coordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.abstract AddressSetViewgetLeftAddresses()Gets the addresses loaded in the left side of this panel.DatagetLeftData()Gets the data loaded in the left side of this panel.abstract FieldPanelgetLeftFieldPanel()Gets the left field panel for this CodeComparisonPanel.FunctiongetLeftFunction()Gets the function loaded in the left side of this panel.ProgramgetLeftProgram()Gets the program being viewed in the left side of this panel.abstract java.lang.Class<? extends CodeComparisonPanel<T>>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.abstract AddressSetViewgetRightAddresses()Gets the addresses loaded in the right side of this panel.DatagetRightData()Gets the data loaded in the right side of this panel.abstract FieldPanelgetRightFieldPanel()Gets the right field panel for this CodeComparisonPanel.FunctiongetRightFunction()Gets the function loaded in the right side of this panel.ProgramgetRightProgram()Gets the program being viewed in the right side of this panel.booleangetShowTitles()abstract java.lang.StringgetTitle()The title for this code comparison panelbooleanisScrollingSynced()Determines if the layouts of the views are synchronized with respect to scrolling and location.abstract booleanleftPanelHasFocus()Determines 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 voidloadData(Data leftData, Data rightData)Displays 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 voidrefreshLeftPanel()Refreshes the left side of this panel.abstract voidrefreshRightPanel()Refreshes 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(java.lang.String leftTitlePrefix, java.lang.String rightTitlePrefix)A CodeComparisonPanel should provide a title based on what the code comparison panel is displaying.abstract voidupdateActionEnablement()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
-
-
-
-
Field Detail
-
MINIMUM_PANEL_WIDTH
protected static final int MINIMUM_PANEL_WIDTH
- See Also:
- Constant Field Values
-
LEFT
protected static final int LEFT
- See Also:
- Constant Field Values
-
RIGHT
protected static final int RIGHT
- See Also:
- Constant Field Values
-
FOCUS_BORDER
protected static final javax.swing.border.Border FOCUS_BORDER
-
NON_FOCUS_BORDER
protected static final javax.swing.border.Border NON_FOCUS_BORDER
-
EMPTY_ADDRESS_SET
protected static final AddressSetView EMPTY_ADDRESS_SET
-
owner
protected java.lang.String owner
-
tool
protected PluginTool tool
-
topComp
protected javax.swing.JComponent topComp
-
bottomComp
protected javax.swing.JComponent bottomComp
-
titlePanels
protected TitledPanel[] titlePanels
-
leftTitlePrefix
protected java.lang.String leftTitlePrefix
-
rightTitlePrefix
protected java.lang.String rightTitlePrefix
-
currProgramIndex
protected int currProgramIndex
-
programs
protected Program[] programs
-
functions
protected Function[] functions
-
data
protected Data[] data
-
-
Constructor Detail
-
CodeComparisonPanel
protected CodeComparisonPanel(java.lang.String owner, PluginTool tool)Constructor- Parameters:
owner- the name of the owner of this componenttool- the tool that contains the component
-
-
Method Detail
-
getComponent
public abstract javax.swing.JComponent getComponent()
The GUI component for this CodeComparisonPanel- Returns:
- the component
-
getTitle
public abstract java.lang.String getTitle()
The title for this code comparison panel- Returns:
- the title
-
setPrograms
protected abstract void setPrograms(Program leftProgram, Program rightProgram)
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
public abstract void loadFunctions(Function leftFunction, Function rightFunction)
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
public abstract void loadData(Data leftData, Data rightData)
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
-
setMouseNavigationEnabled
public abstract void setMouseNavigationEnabled(boolean enabled)
Enable/disable navigation in this panel using the mouse- Parameters:
enabled- false disables mouse navigation
-
getActions
public DockingAction[] getActions()
Returns the actions for this panel- Returns:
- an array of docking actions
-
getShowTitles
public boolean getShowTitles()
-
setShowTitles
public void setShowTitles(boolean showTitles)
-
getPanelThisSupersedes
public abstract java.lang.Class<? extends CodeComparisonPanel<T>> 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, java.awt.event.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 abstract 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.
-
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
public abstract void setTitlePrefixes(java.lang.String leftTitlePrefix, java.lang.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.
-
getLeftProgram
public Program getLeftProgram()
Gets the program being viewed in the left side of this panel.- Returns:
- the program or null
-
getRightProgram
public Program getRightProgram()
Gets the program being viewed in the right side of this panel.- Returns:
- the program or null
-
getLeftFunction
public Function getLeftFunction()
Gets the function loaded in the left side of this panel.- Returns:
- the function or null
-
getRightFunction
public Function getRightFunction()
Gets the function loaded in the right side of this panel.- Returns:
- the function or null
-
getLeftData
public Data getLeftData()
Gets the data loaded in the left side of this panel.- Returns:
- the data or null
-
getRightData
public Data getRightData()
Gets the data loaded in the right side of this panel.- Returns:
- the data or null
-
getLeftAddresses
public abstract AddressSetView getLeftAddresses()
Gets the addresses loaded in the left side of this panel.- Returns:
- the addresses or an empty set
-
getRightAddresses
public abstract AddressSetView 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
public void focusLost(java.awt.event.FocusEvent e)
- Specified by:
focusLostin interfacejava.awt.event.FocusListener
-
updateActionEnablement
public abstract void updateActionEnablement()
Updates the enablement for any actions created by this code comparison panel.
-
setFieldPanelCoordinator
public void setFieldPanelCoordinator(T fieldPanelCoordinator)
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
protected T 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
protected abstract T createFieldPanelCoordinator()
Creates a new FieldPanelCoordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.- Returns:
- a new FieldPanelCoordinator
-
getLeftFieldPanel
public abstract FieldPanel getLeftFieldPanel()
Gets the left field panel for this CodeComparisonPanel.- Returns:
- the left FieldPanel.
-
getRightFieldPanel
public abstract 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.
-
-