Package adams.gui.visualization.debug
Class SideBySideDiffPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.debug.SideBySideDiffPanel
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class SideBySideDiffPanel extends BasePanel
Panel for displaying side-by-side diff.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- 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 boolean
m_IgnoreViewportChangesLeft
whether to ignore viewport changes for the left panel.protected boolean
m_IgnoreViewportChangesRight
whether to ignore viewport changes for the right panel.protected JLabel
m_LabelLeft
the label for the left content.protected JLabel
m_LabelRight
the label for the right content.protected String
m_LabelTextLeft
the text for the left content.protected String
m_LabelTextRight
the text for the right content.protected File
m_LastFileLeft
the last left file.protected File
m_LastFileRight
the last right file.protected BaseSplitPane
m_PanelAll
for the two sides of a diff.protected BasePanel
m_PanelLeft
the panel for the left content.protected BasePanel
m_PanelRight
the panel for the right content.protected BaseScrollPane
m_ScrollPaneLeft
the scroll pane for the left content.protected BaseScrollPane
m_ScrollPaneRight
the scroll pane for the right content.protected DiffTextPane
m_TextLeft
the left content.protected DiffTextPane
m_TextRight
the right content.static int
MAX_LABEL_LENGTH
the max length for label text.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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 Constructor Description SideBySideDiffPanel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
anyDifference(File file1, File file2)
Checks whether the two files are the same.boolean
anyDifference(String[] list1, String[] list2)
Checks whether the two array are the same.boolean
anyDifference(List<String> list1, List<String> list2)
Checks whether the two lists are the same.void
clear()
Clears the display.void
compare(File file1, File file2)
Displays the diff of the two files.void
compare(String[] list1, String[] list2)
Displays the diff of the two arrays.void
compare(List<String> list1, List<String> list2)
Displays the diff of the two lists.void
display(DiffUtils.SideBySideDiff diff)
Updates the display with the given diff data.protected void
finishInit()
finishes the initialization.DiffUtils.SideBySideDiff
getCurrent()
Returns the currently displayed diff.DiffTextPane
getDiffTextPane(boolean left)
Returns the underlying diff pane.String
getLabelText(boolean left)
Returns the text of the label.BasePanel
getPanel(boolean left)
Returns the underlying panel.protected void
initGUI()
Initializes the widgets.protected void
initialize()
Initializes the members.protected void
resetLastFiles()
Resets the files last used.void
setLabelText(boolean left, String text)
Sets the text of the label.void
setLastFileLeft(File file)
Sets the last left file - does not update.void
setLastFileRight(File file)
Sets the last right file - does not update.protected void
showTextLabelPopupMenu(MouseEvent e, boolean left)
Shows popup menu for text labels showing the filename.void
updateLeft(File file)
Updates the left file.void
updateRight(File file)
Updates the right file.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
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, 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
-
MAX_LABEL_LENGTH
public static final int MAX_LABEL_LENGTH
the max length for label text.- See Also:
- Constant Field Values
-
m_TextLeft
protected DiffTextPane m_TextLeft
the left content.
-
m_ScrollPaneLeft
protected BaseScrollPane m_ScrollPaneLeft
the scroll pane for the left content.
-
m_PanelLeft
protected BasePanel m_PanelLeft
the panel for the left content.
-
m_LabelLeft
protected JLabel m_LabelLeft
the label for the left content.
-
m_LabelTextLeft
protected String m_LabelTextLeft
the text for the left content.
-
m_TextRight
protected DiffTextPane m_TextRight
the right content.
-
m_ScrollPaneRight
protected BaseScrollPane m_ScrollPaneRight
the scroll pane for the right content.
-
m_PanelRight
protected BasePanel m_PanelRight
the panel for the right content.
-
m_LabelRight
protected JLabel m_LabelRight
the label for the right content.
-
m_LabelTextRight
protected String m_LabelTextRight
the text for the right content.
-
m_PanelAll
protected BaseSplitPane m_PanelAll
for the two sides of a diff.
-
m_IgnoreViewportChangesLeft
protected boolean m_IgnoreViewportChangesLeft
whether to ignore viewport changes for the left panel.
-
m_IgnoreViewportChangesRight
protected boolean m_IgnoreViewportChangesRight
whether to ignore viewport changes for the right panel.
-
m_LastFileLeft
protected File m_LastFileLeft
the last left file.
-
m_LastFileRight
protected File m_LastFileRight
the last right file.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
finishInit
protected void finishInit()
Description copied from class:BasePanel
finishes the initialization.- Overrides:
finishInit
in classBasePanel
-
resetLastFiles
protected void resetLastFiles()
Resets the files last used.
-
getPanel
public BasePanel getPanel(boolean left)
Returns the underlying panel.- Parameters:
left
- if true the panel with the left content is returned otherwise the right one
-
getDiffTextPane
public DiffTextPane getDiffTextPane(boolean left)
Returns the underlying diff pane.- Parameters:
left
- if true the pane with the left content is returned otherwise the right one
-
setLabelText
public void setLabelText(boolean left, String text)
Sets the text of the label.- Parameters:
left
- whether to set the label of the left content or the right onetext
- the text to set
-
getLabelText
public String getLabelText(boolean left)
Returns the text of the label.- Parameters:
left
- whether to get the label of the left content or the right one- Returns:
- the current label text
-
showTextLabelPopupMenu
protected void showTextLabelPopupMenu(MouseEvent e, boolean left)
Shows popup menu for text labels showing the filename.- Parameters:
e
- the mouse eventleft
- whether left or right label
-
anyDifference
public boolean anyDifference(File file1, File file2)
Checks whether the two files are the same.- Parameters:
file1
- the left filefile2
- the right file- Returns:
- true if the same
-
anyDifference
public boolean anyDifference(String[] list1, String[] list2)
Checks whether the two array are the same.- Parameters:
list1
- the left arraylist2
- the right array- Returns:
- true if the same
-
anyDifference
public boolean anyDifference(List<String> list1, List<String> list2)
Checks whether the two lists are the same.- Parameters:
list1
- the left listlist2
- the right list- Returns:
- true if the same
-
compare
public void compare(File file1, File file2)
Displays the diff of the two files.- Parameters:
file1
- the left filefile2
- the right file
-
compare
public void compare(String[] list1, String[] list2)
Displays the diff of the two arrays.- Parameters:
list1
- the left arraylist2
- the right array
-
compare
public void compare(List<String> list1, List<String> list2)
Displays the diff of the two lists.- Parameters:
list1
- the left listlist2
- the right list
-
setLastFileLeft
public void setLastFileLeft(File file)
Sets the last left file - does not update.- Parameters:
file
- the new left file, null to reset
-
updateLeft
public void updateLeft(File file)
Updates the left file.- Parameters:
file
- the new left file
-
setLastFileRight
public void setLastFileRight(File file)
Sets the last right file - does not update.- Parameters:
file
- the new left file, null to reset
-
updateRight
public void updateRight(File file)
Updates the right file.- Parameters:
file
- the new right file
-
clear
public void clear()
Clears the display.
-
display
public void display(DiffUtils.SideBySideDiff diff)
Updates the display with the given diff data.- Parameters:
diff
- the diff data to display
-
getCurrent
public DiffUtils.SideBySideDiff getCurrent()
Returns the currently displayed diff.- Returns:
- the diff information
-
-