JIDE 3.5.15

com.jidesoft.diff
Class BasicDiffPane<T>

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<T>
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
CodeEditorDiffPane, TableDiffPane

public abstract class BasicDiffPane<T>
extends AbstractDiffPane

BasicDiffPane is a diff pane to compare two components that are using JScrollPane. It can be used to compare two JLists, two JTables or two JTrees.

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  boolean _diffed
           
protected  List<Difference> _differences
           
protected  JComponent _fromComponent
           
protected  AbstractMargin _fromDiffLineNumberMargin
           
protected  AbstractMargin _fromDiffMargin
           
protected  MarginArea _fromMarginArea
           
protected  MarkerArea _fromMarkerArea
           
protected  RowMarginSupport _fromRowMarginSupport
           
protected  JScrollPane _fromScrollPane
           
protected  JComponent _fromTitle
           
protected  DiffDivider _fromToDivider
           
protected  JComponent _toComponent
           
protected  AbstractMargin _toDiffLineNumberMargin
           
protected  AbstractMargin _toDiffMargin
           
protected  MarginArea _toMarginArea
           
protected  MarkerArea _toMarkerArea
           
protected  RowMarginSupport _toRowMarginSupport
           
protected  JScrollPane _toScrollPane
           
protected  JComponent _toTitle
           
protected  int GAP_TITLE_PANE
           
protected static int POSITION_AFTER_LAST
           
protected static int POSITION_BEFORE_FIRST
           
protected static int POSITION_IN_THE_MIDDLE
           
protected static int POSITION_ON_FIRST
           
protected static int POSITION_ON_FIRST_AND_LAST
           
protected static int 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
BasicDiffPane()
           
BasicDiffPane(Object... items)
           
 
Method Summary
protected  List<Difference> acceptDifference(List<Difference> differences, Difference c)
          Accepts the specified Difference and return a new list of Differences.
protected  void adjustDividerOffset(DiffDivider divider, int index)
          Adjusts the DiffDivider's left and right offset.
protected static int binarySearchAdded(List<Difference> differences, int line)
           
protected static int binarySearchDeleted(List<Difference> differences, int line)
           
 void clearDiff()
           
 void clearHighlights()
           
abstract  JComponent createComponent(Object item, int index)
          Creates the component to display the content for the diff.
protected  Diff<T> createDiff(T[] from, T[] to)
          Creates the Diff instance.
protected  AbstractMargin createDiffMargin(RowMarginSupport rowMarginSupport, boolean original)
          Creates the DiffMargin.
 DiffDivider createDivider(int index)
          Subclass implements it to create a DiffDivider that appears between the panes.
protected  DiffDivider.RowConverter createFromRowConverter()
           
protected  JComponent createFromTitle()
           
 Diff<?> createLineDiff(int toOffset, int fromOffset)
          Deprecated. replaced by createLinesDiff(int, int, int, int)
protected  Diff<?> createLinesDiff(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset)
          Creates multiple lines diff.
protected abstract  MarkerSupport createMarkerSupport(JComponent component)
           
 JComponent createPane(Object item, int index)
          Subclass implements it to use a different component to display the objects to be compared.
protected abstract  RowMarginSupport createRowMarginSupport(JComponent component, JScrollPane scrollPane)
           
protected  DiffDivider.RowConverter createToRowConverter()
           
protected  JComponent createToTitle()
           
protected  void customizeDivider(DiffDivider divider, int i)
          Customizes the newly created DiffDivider.
protected  List<Difference> customizeLinesDiff(Diff diff, List<Difference> linesDiff)
          Customizes the line diff.
abstract  boolean delete(int toLine, int toNumberOfLines, boolean runDiffAfterward)
          Deletes number of lines from the specified started line in the toEditor.
 List<Difference> diff()
          Runs the diff algorithm and displays the differences on this diff pane.
protected  List<Difference> diff(T[] from, T[] to)
          Runs the different algorithm and returns the list of Differences.
protected  void differencesUpdated(List<Difference> diffs)
          Updates the difference to UI.
 void endHighlights()
           
 void firstChange()
          Goes to the first change.
 void flip()
          Flips the from to the to and vice versa.
protected  int getCaretPosition(int paneIndex, int firstIndex, int lastIndex)
           
 List<Difference> getDifferences()
          Gets the existing difference list.
 List<Difference> getDifferencesForDiff()
          Gets the Difference list for actual UI update.
 JComponent getFromComponent()
          Gets the from component.
abstract  T[] getFromItems()
           
protected  int getFromMatchingRow(int toRow)
           
 String getFromTitle()
           
protected abstract  int getSelectedIndex(int paneIndex)
           
 JComponent getToComponent()
          Gets the to component.
abstract  T[] getToItems()
           
protected  int getToMatchingRow(int fromRow)
           
 String getToTitle()
           
 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)
           
abstract  boolean insert(int toLine, int fromLine, int fromNumberOfLines, boolean runDiffAfterward)
          Inserts some lines from the fromEditor to the toEditor.
protected  void installListeners()
          Installs the listeners.
 boolean isHighlightExactChange()
          Checks if the highlightExactChange flag is on.
 boolean isReadOnly()
          Checks if the diff pane is read only.
 boolean isSelectOnNavigation()
          Gets the flag indicating if BasicDiffPane should select the difference on clicking navigation buttons.
 void lastChange()
          Goes to the last change.
 void nextChange()
          Goes to the next change.
 void previousChange()
          Goes to the previous change.
 boolean replace(int toLine, int toNumberOfLines, int fromLine, int fromNumberOfLines, boolean runDiffAfterward)
          Replaces number of lines from the specified started line in the toEditor with some lines from the fromEditor.
 void runDiff()
           
protected  void scrollTo(boolean isFromComponent, int start, int end)
          Scrolls when navigating between differences.
 void setChangedColor(Color changedColor)
           
 void setDeletedColor(Color deletedColor)
           
 void setFromTitle(String title)
           
 void setHighlightExactChange(boolean highlightExactChange)
          Sets the highlightExactChange flag.
 void setInsertedColor(Color insertedColor)
           
 void setReadOnly(boolean readOnly)
          Sets the read only flag.
 void setSelectOnNavigation(boolean selectOnNavigation)
          Sets the flag indicating if BasicDiffPane should select the difference on clicking navigation buttons.
 void setToTitle(String title)
           
 void startHighlights()
           
protected  void synchronizeViewport(DiffDivider diffDivider, boolean startFrom, boolean vertically)
           
protected  void uninstallListeners()
          Uninstalls the listeners.
protected  void updateActions(int index)
          Updates the enable/disable states of the actions on the toolbar buttons.
 
Methods inherited from class com.jidesoft.diff.AbstractDiffPane
createActions, createButton, createContentArea, createLegendBar, createStatusBar, createToolBar, customizeAction, customizePane, customizePanes, 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

GAP_TITLE_PANE

protected final int GAP_TITLE_PANE
See Also:
Constant Field Values

_fromComponent

protected JComponent _fromComponent

_toComponent

protected JComponent _toComponent

_fromScrollPane

protected JScrollPane _fromScrollPane

_toScrollPane

protected JScrollPane _toScrollPane

_fromToDivider

protected DiffDivider _fromToDivider

_fromDiffMargin

protected AbstractMargin _fromDiffMargin

_toDiffMargin

protected AbstractMargin _toDiffMargin

_fromTitle

protected JComponent _fromTitle

_toTitle

protected JComponent _toTitle

_fromMarginArea

protected MarginArea _fromMarginArea

_toMarginArea

protected MarginArea _toMarginArea

_fromDiffLineNumberMargin

protected AbstractMargin _fromDiffLineNumberMargin

_toDiffLineNumberMargin

protected AbstractMargin _toDiffLineNumberMargin

_fromMarkerArea

protected MarkerArea _fromMarkerArea

_toMarkerArea

protected MarkerArea _toMarkerArea

_fromRowMarginSupport

protected RowMarginSupport _fromRowMarginSupport

_toRowMarginSupport

protected RowMarginSupport _toRowMarginSupport

_differences

protected List<Difference> _differences

POSITION_BEFORE_FIRST

protected static final int POSITION_BEFORE_FIRST
See Also:
Constant Field Values

POSITION_ON_FIRST

protected static final int POSITION_ON_FIRST
See Also:
Constant Field Values

POSITION_IN_THE_MIDDLE

protected static final int POSITION_IN_THE_MIDDLE
See Also:
Constant Field Values

POSITION_ON_LAST

protected static final int POSITION_ON_LAST
See Also:
Constant Field Values

POSITION_AFTER_LAST

protected static final int POSITION_AFTER_LAST
See Also:
Constant Field Values

POSITION_ON_FIRST_AND_LAST

protected static final int POSITION_ON_FIRST_AND_LAST
See Also:
Constant Field Values

_diffed

protected boolean _diffed
Constructor Detail

BasicDiffPane

public BasicDiffPane()

BasicDiffPane

public BasicDiffPane(Object... items)
Method Detail

flip

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

Overrides:
flip in class AbstractDiffPane

createDiffMargin

protected AbstractMargin createDiffMargin(RowMarginSupport rowMarginSupport,
                                          boolean original)
Creates the DiffMargin.

Parameters:
rowMarginSupport - the row margin support
original - if it's the original margin
Returns:
the DiffMargin instance.
Since:
3.4.3

createPane

public JComponent createPane(Object item,
                             int index)
Description copied from class: AbstractDiffPane
Subclass implements it to use a different component to display the objects to be compared.

Specified by:
createPane in class AbstractDiffPane
Parameters:
item - item to be compared. The component should be able to display the item.
index - the index of the pane. For example, for a type diff pane to compare two items before and after modification, the index 0 will be the original item before modification, the index 1 will be the item after modification.
Returns:
the component to display the item to be compared.

createMarkerSupport

protected abstract MarkerSupport createMarkerSupport(JComponent component)

createRowMarginSupport

protected abstract RowMarginSupport createRowMarginSupport(JComponent component,
                                                           JScrollPane scrollPane)

createDivider

public DiffDivider createDivider(int index)
Description copied from class: AbstractDiffPane
Subclass implements it to create a DiffDivider that appears between the panes.

Specified by:
createDivider in class AbstractDiffPane
Parameters:
index - the index of the DiffDivider
Returns:
the DiffDivider.

customizeDivider

protected void customizeDivider(DiffDivider divider,
                                int i)
Description copied from class: AbstractDiffPane
Customizes the newly created DiffDivider.

Overrides:
customizeDivider in class AbstractDiffPane
Parameters:
divider - the diff divider
i - the index of the diff divider

setChangedColor

public void setChangedColor(Color changedColor)
Overrides:
setChangedColor in class AbstractDiffPane

setInsertedColor

public void setInsertedColor(Color insertedColor)
Overrides:
setInsertedColor in class AbstractDiffPane

setDeletedColor

public void setDeletedColor(Color deletedColor)
Overrides:
setDeletedColor in class AbstractDiffPane

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 AbstractDiffPane
Parameters:
divider - the DiffDivider.
index - the index of the DiffDivider.

createFromTitle

protected JComponent createFromTitle()

createToTitle

protected JComponent createToTitle()

getFromTitle

public String getFromTitle()

setFromTitle

public void setFromTitle(String title)

getToTitle

public String getToTitle()

setToTitle

public void setToTitle(String title)

createComponent

public abstract JComponent createComponent(Object item,
                                           int index)
Creates the component to display the content for the diff.

Parameters:
item - the content to be displayed in the component.
index - the index of the component.
Returns:
the component.

createFromRowConverter

protected DiffDivider.RowConverter createFromRowConverter()

getFromItems

public abstract T[] getFromItems()

getToItems

public abstract T[] getToItems()

getFromComponent

public JComponent getFromComponent()
Gets the from component.

Returns:
the from component.
Since:
3.4.1

getToComponent

public JComponent getToComponent()
Gets the to component.

Returns:
the to component.
Since:
3.4.1

createToRowConverter

protected DiffDivider.RowConverter createToRowConverter()

synchronizeViewport

protected void synchronizeViewport(DiffDivider diffDivider,
                                   boolean startFrom,
                                   boolean vertically)

updateActions

protected void updateActions(int index)
Description copied from class: AbstractDiffPane
Updates the enable/disable states of the actions on the toolbar buttons.

Overrides:
updateActions in class AbstractDiffPane
Parameters:
index - the pane index. This is the pane that triggers the update.

getSelectedIndex

protected abstract int getSelectedIndex(int paneIndex)

getCaretPosition

protected int getCaretPosition(int paneIndex,
                               int firstIndex,
                               int lastIndex)
Parameters:
paneIndex - the index of the pane. It could be either 0 or 1 in the case of a diff pane or 0, 1, 2 in the case of a merge pane.
firstIndex - the first diff index
lastIndex - the last diff index
Returns:
one of the six values. They are defined as constants beginning "POSITION_".

firstChange

public void firstChange()
Description copied from class: AbstractDiffPane
Goes to the first change.

Overrides:
firstChange in class AbstractDiffPane

previousChange

public void previousChange()
Description copied from class: AbstractDiffPane
Goes to the previous change.

Overrides:
previousChange in class AbstractDiffPane

nextChange

public void nextChange()
Description copied from class: AbstractDiffPane
Goes to the next change.

Overrides:
nextChange in class AbstractDiffPane

lastChange

public void lastChange()
Description copied from class: AbstractDiffPane
Goes to the last change.

Overrides:
lastChange in class AbstractDiffPane

scrollTo

protected void scrollTo(boolean isFromComponent,
                        int start,
                        int end)
Scrolls when navigating between differences.

Parameters:
isFromComponent - if the start/end row index is for the from component or the to component
start - the start row index
end - the end row index
Since:
3.5.0

installListeners

protected void installListeners()
Description copied from class: AbstractDiffPane
Installs the listeners. Subclass can override this method to install the necessary listeners. This method is called only in the constructor.

Overrides:
installListeners in class AbstractDiffPane

uninstallListeners

protected void uninstallListeners()
Description copied from class: AbstractDiffPane
Uninstalls the listeners. Subclass can override this method to uninstall the necessary listeners. This method has to be invoked explicitly by customers to uninstall all the listeners installed by AbstractDiffPane.installListeners()

Overrides:
uninstallListeners in class AbstractDiffPane

getDifferencesForDiff

public List<Difference> getDifferencesForDiff()
Gets the Difference list for actual UI update.

This method is to prepare Difference list for the method diff(). In most cases, this method will return a Difference instance each time you invoke it.

This method will first invoke diff(Object[], Object[]) to get the difference list. It would then check the method isHighlightExactChange() to determine if the line difference will be calculated.

Returns:
the Difference list.
Since:
3.4.8

getDifferences

public List<Difference> getDifferences()
Gets the existing difference list.

This method always returns the Difference list that updated by last invocation to diff().

Returns:
the existing difference list.

diff

protected List<Difference> diff(T[] from,
                                T[] to)
Runs the different algorithm and returns the list of Differences.

To have line difference further, it will return a DifferenceList instance by default.

Parameters:
from - the fromText.
to - the toText
Returns:
the list of Differences.

createDiff

protected Diff<T> createDiff(T[] from,
                             T[] to)
Creates the Diff instance.

Diff is the major class that implements the comparing algorithm. You could override this method to customize the comparing algorithm if necessary.

By default, it simply returns new Diff(from, to).

Parameters:
from - the from items
to - the to items
Returns:
the created Diff instance.
Since:
3.4.1

diff

public List<Difference> diff()
Runs the diff algorithm and displays the differences on this diff pane.

By default, the implementation of this method is

_diffed = true; List differences = getDifferencesForDiff(); differencesUpdated(differences); return differences;

Returns:
the list of Differences.

runDiff

public void runDiff()

clearDiff

public void clearDiff()

isHighlightExactChange

public boolean isHighlightExactChange()
Checks if the highlightExactChange flag is on. If on, we will display what changed exactly if one line in the fromEditor is changed in the toEditor if and only if there is just one change between the two lines. Otherwise, the whole line will be highlighted.

Returns:
true or false.

isReadOnly

public boolean isReadOnly()
Checks if the diff pane is read only. A read only diff pane will not show the buttons to apply changes.

Returns:
true or false.

setReadOnly

public void setReadOnly(boolean readOnly)
Sets the read only flag. A read only diff pane will not show the buttons to apply changes.

Parameters:
readOnly - the new read only flag.

setHighlightExactChange

public void setHighlightExactChange(boolean highlightExactChange)
Sets the highlightExactChange flag.

Parameters:
highlightExactChange - true or false.

differencesUpdated

protected void differencesUpdated(List<Difference> diffs)
Updates the difference to UI.

Parameters:
diffs - the list of the differences.
Since:
3.4.2

customizeLinesDiff

protected List<Difference> customizeLinesDiff(Diff diff,
                                              List<Difference> linesDiff)
Customizes the line diff.

This method is invoked before highlighting the line diff after the default line diff is generated. If you don't feel good about the default line diff generated by the algorithm of Diff, please override this method to pass in your own diff.

By default, this method simply returns the linesDiff passed in.

Parameters:
linesDiff - the default line diff
Returns:
the line diff after customized.
Since:
3.4.0

binarySearchAdded

protected static int binarySearchAdded(List<Difference> differences,
                                       int line)

binarySearchDeleted

protected static int binarySearchDeleted(List<Difference> differences,
                                         int line)

getToMatchingRow

protected int getToMatchingRow(int fromRow)

getFromMatchingRow

protected int getFromMatchingRow(int toRow)

clearHighlights

public void clearHighlights()

startHighlights

public void startHighlights()

endHighlights

public void endHighlights()

createLineDiff

@Deprecated
public Diff<?> createLineDiff(int toOffset,
                                         int fromOffset)
Deprecated. replaced by createLinesDiff(int, int, int, int)

Creates single line diff.

Parameters:
toOffset - to offset
fromOffset - from offset
Returns:
the Diff instance.

createLinesDiff

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

This method is not implemented by default. You will need put your multiple line difference logic here.

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)

highlightChanged

public void highlightChanged(int fromStartOffset,
                             int fromEndOffset,
                             int toStartOffset,
                             int toEndOffset,
                             Color c,
                             Color separatorColor,
                             String changeToolTip)

highlightInserted

public void highlightInserted(int fromStartOffset,
                              int toStartOffset,
                              int toEndOffset,
                              Color c,
                              Color separatorColor,
                              String changeToolTip)

highlightDeleted

public void highlightDeleted(int fromStartOffset,
                             int fromEndOffset,
                             int toStartOffset,
                             Color c,
                             Color separatorColor,
                             String changeToolTip)

acceptDifference

protected List<Difference> acceptDifference(List<Difference> differences,
                                            Difference c)
Accepts the specified Difference and return a new list of Differences.

Parameters:
differences - the list of Differences.
c - the Difference to be accepted.
Returns:
a new list of Differences.

delete

public abstract boolean delete(int toLine,
                               int toNumberOfLines,
                               boolean runDiffAfterward)
Deletes number of lines from the specified started line in the toEditor.

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 abstract boolean insert(int toLine,
                               int fromLine,
                               int fromNumberOfLines,
                               boolean runDiffAfterward)
Inserts some lines from the fromEditor to the toEditor.

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.

replace

public boolean replace(int toLine,
                       int toNumberOfLines,
                       int fromLine,
                       int fromNumberOfLines,
                       boolean runDiffAfterward)
Replaces number of lines from the specified started line in the toEditor with some lines from the fromEditor.

Parameters:
toLine - the starting line in the toEditor
toNumberOfLines - the number of lines to be replaced from the toEditor.
fromLine - the starting line in the fromEditor
fromNumberOfLines - the number of lines in the fromEditor to be copied to the toEditor.
runDiffAfterward - true of run the diff() again after replacing the lines.
Returns:
true or false. True means the operation is successful.

isSelectOnNavigation

public boolean isSelectOnNavigation()
Gets the flag indicating if BasicDiffPane should select the difference on clicking navigation buttons.

Returns:
true if the difference should be selected. Otherwise false.
Since:
3.4.0
See Also:
setSelectOnNavigation(boolean)

setSelectOnNavigation

public void setSelectOnNavigation(boolean selectOnNavigation)
Sets the flag indicating if BasicDiffPane should select the difference on clicking navigation buttons.

By default, the flag is true.

Parameters:
selectOnNavigation - the flag
Since:
3.4.0

JIDE 3.5.15