JIDE 3.5.15

com.jidesoft.diff
Class TableDiffPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jidesoft.diff.AbstractDiffPane
                      extended by com.jidesoft.diff.BasicDiffPane<Object>
                          extended by com.jidesoft.diff.TableDiffPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class TableDiffPane
extends BasicDiffPane<Object>

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
protected  DiffTableStyleProvider _fromTableStyleProvider
           
protected  DiffTableStyleProvider _toTableStyleProvider
           
 
Fields inherited from class com.jidesoft.diff.BasicDiffPane
_diffed, _differences, _fromComponent, _fromDiffLineNumberMargin, _fromDiffMargin, _fromMarginArea, _fromMarkerArea, _fromRowMarginSupport, _fromScrollPane, _fromTitle, _fromToDivider, _toComponent, _toDiffLineNumberMargin, _toDiffMargin, _toMarginArea, _toMarkerArea, _toRowMarginSupport, _toScrollPane, _toTitle, GAP_TITLE_PANE, POSITION_AFTER_LAST, POSITION_BEFORE_FIRST, POSITION_IN_THE_MIDDLE, POSITION_ON_FIRST, POSITION_ON_FIRST_AND_LAST, POSITION_ON_LAST
 
Fields inherited from class com.jidesoft.diff.AbstractDiffPane
_actions, _changedColor, _deletedColor, _insertedColor, COMMAND_FIRST, COMMAND_LAST, COMMAND_NEXT, COMMAND_PREVIOUS
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
TableDiffPane()
           
TableDiffPane(Object... items)
          Creates TableDiffPane.
 
Method Summary
protected  void adjustDividerOffset(DiffDivider divider, int index)
          Adjusts the DiffDivider's left and right offset.
 void clearHighlights()
           
protected  Object[] createArrayFromTableModel(TableModel tableModel)
          Creates the array from the table model.
 JComponent createComponent(Object item, int index)
          Creates a CellStyleTable so that it can use the cell style feature to show the difference highlights.
protected  Diff<?> createLinesDiff(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset)
          Creates multiple lines diff.
protected  MarkerSupport createMarkerSupport(JComponent component)
           
protected  RowMarginSupport createRowMarginSupport(JComponent component, JScrollPane scrollPane)
           
protected  void customizePane(JComponent component, int index)
          Customizes the pane.
protected  void customizePanes(JComponent[] panes)
          Customizes the components after the panes are created.
 boolean delete(int toLine, int toNumberOfLines, boolean runDiffAfterward)
          Deletes number of lines from the specified started line in the toEditor.
 void flip()
          Flips the from to the to and vice versa.
 Object[] getFromItems()
          Gets the from items that is used for Diff to compare the lines.
protected  List<Object> getFromItems(int startRow, int endRow)
          Gets the from items for line difference to compare.
protected  int getSelectedIndex(int paneIndex)
           
protected  Object getTableRowData(TableModel tableModel, int rowIndex)
          Creates the table row data.
 Object[] getToItems()
          Gets the to items that is used for Diff to compare the lines.
protected  List<Object> getToItems(int startRow, int endRow)
          Gets the to items for line difference to compare.
 void highlightChanged(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
           
 void highlightChangedExactly(List<Difference> lineDiff, int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
           
 void highlightDeleted(int fromStartOffset, int fromEndOffset, int toStartOffset, Color c, Color separatorColor, String changeToolTip)
           
 void highlightInserted(int fromStartOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
           
 boolean insert(int toLine, int fromLine, int fromNumberOfLines, boolean runDiffAfterward)
          Inserts some lines from the fromEditor to the toEditor.
 void setChangedColor(Color changedColor)
           
 void setDeletedColor(Color deletedColor)
           
 void setInsertedColor(Color insertedColor)
           
 
Methods inherited from class com.jidesoft.diff.BasicDiffPane
acceptDifference, binarySearchAdded, binarySearchDeleted, clearDiff, createDiff, createDiffMargin, createDivider, createFromRowConverter, createFromTitle, createLineDiff, createPane, createToRowConverter, createToTitle, customizeDivider, customizeLinesDiff, diff, diff, differencesUpdated, endHighlights, firstChange, getCaretPosition, getDifferences, getDifferencesForDiff, getFromComponent, getFromMatchingRow, getFromTitle, getToComponent, getToMatchingRow, getToTitle, installListeners, isHighlightExactChange, isReadOnly, isSelectOnNavigation, lastChange, nextChange, previousChange, replace, runDiff, scrollTo, setFromTitle, setHighlightExactChange, setReadOnly, setSelectOnNavigation, setToTitle, startHighlights, synchronizeViewport, uninstallListeners, updateActions
 
Methods inherited from class com.jidesoft.diff.AbstractDiffPane
createActions, createButton, createContentArea, createLegendBar, createStatusBar, createToolBar, customizeAction, customizeToolBar, getChangedColor, getDeletedColor, getInsertedColor, getMessage, getResourceString, initLayout, setMessage
 
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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_fromTableStyleProvider

protected DiffTableStyleProvider _fromTableStyleProvider

_toTableStyleProvider

protected DiffTableStyleProvider _toTableStyleProvider
Constructor Detail

TableDiffPane

public TableDiffPane()

TableDiffPane

public TableDiffPane(Object... items)
Creates TableDiffPane. The items should two TableModels.

Parameters:
items - two table models.
Method Detail

flip

public void flip()
Description copied from class: AbstractDiffPane
Flips the from to the to and vice versa.

Overrides:
flip in class BasicDiffPane<Object>

createArrayFromTableModel

protected Object[] createArrayFromTableModel(TableModel tableModel)
Creates the array from the table model.

Since 3.4.1, the contents of the array are changed. In earlier releases, it was an array of String. Now, it's an instance of LazyLoadTableRowData. You could override getTableRowData(javax.swing.table.TableModel, int) to change the behavior.

Parameters:
tableModel - the table model
Returns:
the array for diff

getTableRowData

protected Object getTableRowData(TableModel tableModel,
                                 int rowIndex)
Creates the table row data.

Parameters:
tableModel - the table model
rowIndex - the row index
Returns:
the LazyLoadTableRowData instance by default.
Since:
3.4.1

customizePane

protected void customizePane(JComponent component,
                             int index)
Description copied from class: AbstractDiffPane
Customizes the pane. The index will tell you which pane to customize. Subclass can override this method to customize the pane. Please limit the customization to this pane only because at this point, depending on the order, other panes may not be created yet. If a customization involves several panes, please do it in the overridden AbstractDiffPane.customizePanes(JComponent[]).

Overrides:
customizePane in class AbstractDiffPane
Parameters:
component - the pane.
index - the index of the pane.

customizePanes

protected void customizePanes(JComponent[] panes)
Description copied from class: AbstractDiffPane
Customizes the components after the panes are created. You can override this method to do customization that involves all the panes.

Overrides:
customizePanes in class AbstractDiffPane
Parameters:
panes - the panes.

createMarkerSupport

protected MarkerSupport createMarkerSupport(JComponent component)
Specified by:
createMarkerSupport in class BasicDiffPane<Object>

createRowMarginSupport

protected RowMarginSupport createRowMarginSupport(JComponent component,
                                                  JScrollPane scrollPane)
Specified by:
createRowMarginSupport in class BasicDiffPane<Object>

createComponent

public JComponent createComponent(Object item,
                                  int index)
Creates a CellStyleTable so that it can use the cell style feature to show the difference highlights.

Specified by:
createComponent in class BasicDiffPane<Object>
Parameters:
item - the content to be displayed in the component.
index - the index of the component.
Returns:
a CellStyleTable.

adjustDividerOffset

protected void adjustDividerOffset(DiffDivider divider,
                                   int index)
Description copied from class: AbstractDiffPane
Adjusts the DiffDivider's left and right offset.

Overrides:
adjustDividerOffset in class BasicDiffPane<Object>
Parameters:
divider - the DiffDivider.
index - the index of the DiffDivider.

getFromItems

public Object[] getFromItems()
Gets the from items that is used for Diff to compare the lines.

If the line difference is to be highlighted, this method is not invoked. Instead, getFromItems(int, int) is used.

Specified by:
getFromItems in class BasicDiffPane<Object>
Returns:
the Object array.
See Also:
getFromItems(int, int)

getToItems

public Object[] getToItems()
Gets the to items that is used for Diff to compare the lines.

If the line difference is to be highlighted, this method is not invoked. Instead, getToItems(int, int) is used.

Specified by:
getToItems in class BasicDiffPane<Object>
Returns:
the Object array.
See Also:
getToItems(int, int)

getFromItems

protected List<Object> getFromItems(int startRow,
                                    int endRow)
Gets the from items for line difference to compare.

Parameters:
startRow - the start row index
endRow - the end row index
Returns:
the list of Object for diff.
Since:
3.4.1

getToItems

protected List<Object> getToItems(int startRow,
                                  int endRow)
Gets the to items for line difference to compare.

Parameters:
startRow - the start row index
endRow - the end row index
Returns:
the list of Object for diff.
Since:
3.4.1

getSelectedIndex

protected int getSelectedIndex(int paneIndex)
Specified by:
getSelectedIndex in class BasicDiffPane<Object>

createLinesDiff

protected Diff<?> createLinesDiff(int fromStartOffset,
                                  int fromEndOffset,
                                  int toStartOffset,
                                  int toEndOffset)
Creates multiple lines diff.

The cell value array inside the diff instance is only the values in the related rows. The method highlightChangedExactly(java.util.List, int, int, int, int, java.awt.Color, java.awt.Color, String) will consider the offset and get the correct position

Overrides:
createLinesDiff in class BasicDiffPane<Object>
Parameters:
fromStartOffset - from start offset
fromEndOffset - from end offset
toStartOffset - to start offset
toEndOffset - to end offset
Returns:
the Diff instance.
Since:
3.4.0

highlightChangedExactly

public void highlightChangedExactly(List<Difference> lineDiff,
                                    int fromStartOffset,
                                    int fromEndOffset,
                                    int toStartOffset,
                                    int toEndOffset,
                                    Color c,
                                    Color separatorColor,
                                    String changeToolTip)
Overrides:
highlightChangedExactly in class BasicDiffPane<Object>

highlightChanged

public void highlightChanged(int fromStartOffset,
                             int fromEndOffset,
                             int toStartOffset,
                             int toEndOffset,
                             Color c,
                             Color separatorColor,
                             String changeToolTip)
Overrides:
highlightChanged in class BasicDiffPane<Object>

highlightInserted

public void highlightInserted(int fromStartOffset,
                              int toStartOffset,
                              int toEndOffset,
                              Color c,
                              Color separatorColor,
                              String changeToolTip)
Overrides:
highlightInserted in class BasicDiffPane<Object>

highlightDeleted

public void highlightDeleted(int fromStartOffset,
                             int fromEndOffset,
                             int toStartOffset,
                             Color c,
                             Color separatorColor,
                             String changeToolTip)
Overrides:
highlightDeleted in class BasicDiffPane<Object>

clearHighlights

public void clearHighlights()
Overrides:
clearHighlights in class BasicDiffPane<Object>

delete

public boolean delete(int toLine,
                      int toNumberOfLines,
                      boolean runDiffAfterward)
Description copied from class: BasicDiffPane
Deletes number of lines from the specified started line in the toEditor.

Specified by:
delete in class BasicDiffPane<Object>
Parameters:
toLine - the starting line
toNumberOfLines - the number of lines to be deleted.
runDiffAfterward - true of run the diff() again after deleting the lines.
Returns:
true or false. True means the operation is successful.

insert

public boolean insert(int toLine,
                      int fromLine,
                      int fromNumberOfLines,
                      boolean runDiffAfterward)
Description copied from class: BasicDiffPane
Inserts some lines from the fromEditor to the toEditor.

Specified by:
insert in class BasicDiffPane<Object>
Parameters:
toLine - the insertion line in the toEditor
fromLine - the starting line in the fromEditor
fromNumberOfLines - the number of lines in the fromEditor to be inserted to the toEditor.
runDiffAfterward - true of run the diff() again after inserting the lines.
Returns:
true or false. True means the operation is successful.

setChangedColor

public void setChangedColor(Color changedColor)
Overrides:
setChangedColor in class BasicDiffPane<Object>

setInsertedColor

public void setInsertedColor(Color insertedColor)
Overrides:
setInsertedColor in class BasicDiffPane<Object>

setDeletedColor

public void setDeletedColor(Color deletedColor)
Overrides:
setDeletedColor in class BasicDiffPane<Object>

JIDE 3.5.15