Class CodeComparisonPanel<T extends FieldPanelCoordinator>

  • 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 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". If not, the ClassSearcher will not find them.
    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
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.swing.JComponent bottomComp  
      protected int currProgramIndex  
      protected Data[] data  
      protected static AddressSetView EMPTY_ADDRESS_SET  
      protected static javax.swing.border.Border FOCUS_BORDER  
      protected Function[] functions  
      protected static int LEFT  
      protected java.lang.String leftTitlePrefix  
      protected static int MINIMUM_PANEL_WIDTH  
      protected static javax.swing.border.Border NON_FOCUS_BORDER  
      protected java.lang.String owner  
      protected Program[] programs  
      protected static int RIGHT  
      protected java.lang.String rightTitlePrefix  
      protected TitledPanel[] titlePanels  
      protected PluginTool tool  
      protected javax.swing.JComponent topComp  
      • 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 CodeComparisonPanel​(java.lang.String owner, PluginTool tool)
      Base constructor
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract T createFieldPanelCoordinator()
      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 needed.
      void focusLost​(java.awt.event.FocusEvent e)  
      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.
      DockingAction[] getActions()
      Get the actions for this CodeComparisonPanel.
      abstract javax.swing.JComponent getComponent()
      The GUI component for this CodeComparisonPanel.
      protected T getFieldPanelCoordinator()
      Gets the current field panel coordinator used to synchronize scrolling between the left and right view for this CodeComparisonPanel.
      abstract AddressSetView getLeftAddresses()
      Gets the addresses loaded in the left side of this panel.
      Data getLeftData()
      Gets the data loaded in the left side of this panel.
      protected abstract FieldPanel getLeftFieldPanel()
      Gets the left field panel for this CodeComparisonPanel.
      Function getLeftFunction()
      Gets the function loaded in the left side of this panel.
      Program getLeftProgram()
      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 AddressSetView getRightAddresses()
      Gets the addresses loaded in the right side of this panel.
      Data getRightData()
      Gets the data loaded in the right side of this panel.
      protected abstract FieldPanel getRightFieldPanel()
      Gets the right field panel for this CodeComparisonPanel.
      Function getRightFunction()
      Gets the function loaded in the right side of this panel.
      Program getRightProgram()
      Gets the program being viewed in the right side of this panel.
      abstract java.lang.String getTitle()
      The title for this code comparison component.
      boolean isScrollingSynced()
      Determines if the layouts of the views are synchronized with respect to scrolling and location.
      abstract boolean leftPanelHasFocus()
      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 compared.
      abstract void loadData​(Data leftData, Data rightData)
      Displays a comparison of two program's data items.
      abstract void loadFunctions​(Function leftFunction, Function rightFunction)
      Displays a comparison of two program's functions.
      abstract void programRestored​(Program program)
      Called when the indicated program has been restored because of an Undo/Redo.
      abstract void refreshLeftPanel()
      Refreshes the left side of this panel.
      abstract void refreshRightPanel()
      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 mouse.
      protected abstract void setPrograms​(Program leftProgram, Program rightProgram)
      Specifies the two programs to be compared by this panel.
      void setScrollingSyncState​(boolean syncScrolling)
      Sets whether or not scrolling is synchronized.
      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.
      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, 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 Detail

      • 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
      • topComp

        protected javax.swing.JComponent topComp
      • bottomComp

        protected javax.swing.JComponent bottomComp
      • 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)
        Base constructor
        Parameters:
        owner - the name of the owner of this component (typically the name of the plugin that owns this panel.)
        tool - the tool that contains the component.
    • Method Detail

      • getComponent

        public abstract javax.swing.JComponent getComponent()
        The GUI component for this CodeComparisonPanel. A CodeComparisonPanel provides a dual display with a left and right side for comparing some part of the code for two programs.
        Returns:
        the component.
      • getTitle

        public abstract java.lang.String getTitle()
        The title for this code comparison component.
        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 side.
        rightProgram - 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 view
        rightFunction - 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 view
        rightData - 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 view
        rightProgram - the program in the right side of the code comparison view
        leftAddresses - the addresses of the program info to show in the left side
        rightAddresses - 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()
        Get the actions for this CodeComparisonPanel.
        Returns:
        an array containing the actions
      • 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:
        focusLost in interface java.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

        protected abstract FieldPanel getLeftFieldPanel()
        Gets the left field panel for this CodeComparisonPanel.
        Returns:
        the left FieldPanel.
      • getRightFieldPanel

        protected 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.