|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.jidesoft.diff.AbstractDiffPane com.jidesoft.diff.BasicDiffPane<T>
public abstract class BasicDiffPane<T>
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.
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 |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final int GAP_TITLE_PANE
protected JComponent _fromComponent
protected JComponent _toComponent
protected JScrollPane _fromScrollPane
protected JScrollPane _toScrollPane
protected DiffDivider _fromToDivider
protected AbstractMargin _fromDiffMargin
protected AbstractMargin _toDiffMargin
protected JComponent _fromTitle
protected JComponent _toTitle
protected MarginArea _fromMarginArea
protected MarginArea _toMarginArea
protected AbstractMargin _fromDiffLineNumberMargin
protected AbstractMargin _toDiffLineNumberMargin
protected MarkerArea _fromMarkerArea
protected MarkerArea _toMarkerArea
protected RowMarginSupport _fromRowMarginSupport
protected RowMarginSupport _toRowMarginSupport
protected List<Difference> _differences
protected static final int POSITION_BEFORE_FIRST
protected static final int POSITION_ON_FIRST
protected static final int POSITION_IN_THE_MIDDLE
protected static final int POSITION_ON_LAST
protected static final int POSITION_AFTER_LAST
protected static final int POSITION_ON_FIRST_AND_LAST
protected boolean _diffed
Constructor Detail |
---|
public BasicDiffPane()
public BasicDiffPane(Object... items)
Method Detail |
---|
public void flip()
AbstractDiffPane
flip
in class AbstractDiffPane
protected AbstractMargin createDiffMargin(RowMarginSupport rowMarginSupport, boolean original)
rowMarginSupport
- the row margin supportoriginal
- if it's the original margin
public JComponent createPane(Object item, int index)
AbstractDiffPane
createPane
in class AbstractDiffPane
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.
protected abstract MarkerSupport createMarkerSupport(JComponent component)
protected abstract RowMarginSupport createRowMarginSupport(JComponent component, JScrollPane scrollPane)
public DiffDivider createDivider(int index)
AbstractDiffPane
createDivider
in class AbstractDiffPane
index
- the index of the DiffDivider
protected void customizeDivider(DiffDivider divider, int i)
AbstractDiffPane
customizeDivider
in class AbstractDiffPane
divider
- the diff divideri
- the index of the diff dividerpublic void setChangedColor(Color changedColor)
setChangedColor
in class AbstractDiffPane
public void setInsertedColor(Color insertedColor)
setInsertedColor
in class AbstractDiffPane
public void setDeletedColor(Color deletedColor)
setDeletedColor
in class AbstractDiffPane
protected void adjustDividerOffset(DiffDivider divider, int index)
AbstractDiffPane
adjustDividerOffset
in class AbstractDiffPane
divider
- the DiffDivider.index
- the index of the DiffDivider.protected JComponent createFromTitle()
protected JComponent createToTitle()
public String getFromTitle()
public void setFromTitle(String title)
public String getToTitle()
public void setToTitle(String title)
public abstract JComponent createComponent(Object item, int index)
item
- the content to be displayed in the component.index
- the index of the component.
protected DiffDivider.RowConverter createFromRowConverter()
public abstract T[] getFromItems()
public abstract T[] getToItems()
public JComponent getFromComponent()
public JComponent getToComponent()
protected DiffDivider.RowConverter createToRowConverter()
protected void synchronizeViewport(DiffDivider diffDivider, boolean startFrom, boolean vertically)
protected void updateActions(int index)
AbstractDiffPane
updateActions
in class AbstractDiffPane
index
- the pane index. This is the pane that triggers the update.protected abstract int getSelectedIndex(int paneIndex)
protected int getCaretPosition(int paneIndex, int firstIndex, int lastIndex)
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 indexlastIndex
- the last diff index
public void firstChange()
AbstractDiffPane
firstChange
in class AbstractDiffPane
public void previousChange()
AbstractDiffPane
previousChange
in class AbstractDiffPane
public void nextChange()
AbstractDiffPane
nextChange
in class AbstractDiffPane
public void lastChange()
AbstractDiffPane
lastChange
in class AbstractDiffPane
protected void scrollTo(boolean isFromComponent, int start, int end)
isFromComponent
- if the start/end row index is for the from component or the to componentstart
- the start row indexend
- the end row indexprotected void installListeners()
AbstractDiffPane
installListeners
in class AbstractDiffPane
protected void uninstallListeners()
AbstractDiffPane
AbstractDiffPane.installListeners()
uninstallListeners
in class AbstractDiffPane
public List<Difference> getDifferencesForDiff()
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.
public List<Difference> getDifferences()
diff()
.
protected List<Difference> diff(T[] from, T[] to)
DifferenceList
instance by default.
from
- the fromText.to
- the toText
protected Diff<T> createDiff(T[] from, T[] to)
from
- the from itemsto
- the to items
public List<Difference> diff()
_diffed = true; List differences = getDifferencesForDiff();
differencesUpdated(differences); return differences;
public void runDiff()
public void clearDiff()
public boolean isHighlightExactChange()
public boolean isReadOnly()
public void setReadOnly(boolean readOnly)
readOnly
- the new read only flag.public void setHighlightExactChange(boolean highlightExactChange)
highlightExactChange
- true or false.protected void differencesUpdated(List<Difference> diffs)
diffs
- the list of the differences.protected List<Difference> customizeLinesDiff(Diff diff, List<Difference> linesDiff)
Diff
, please override this method to
pass in your own diff.
By default, this method simply returns the linesDiff passed in.
linesDiff
- the default line diff
protected static int binarySearchAdded(List<Difference> differences, int line)
protected static int binarySearchDeleted(List<Difference> differences, int line)
protected int getToMatchingRow(int fromRow)
protected int getFromMatchingRow(int toRow)
public void clearHighlights()
public void startHighlights()
public void endHighlights()
@Deprecated public Diff<?> createLineDiff(int toOffset, int fromOffset)
createLinesDiff(int, int, int, int)
toOffset
- to offsetfromOffset
- from offset
protected Diff<?> createLinesDiff(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset)
fromStartOffset
- from start offsetfromEndOffset
- from end offsettoStartOffset
- to start offsettoEndOffset
- to end offset
public void highlightChangedExactly(List<Difference> lineDiff, int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
public void highlightChanged(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
public void highlightInserted(int fromStartOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
public void highlightDeleted(int fromStartOffset, int fromEndOffset, int toStartOffset, Color c, Color separatorColor, String changeToolTip)
protected List<Difference> acceptDifference(List<Difference> differences, Difference c)
differences
- the list of Differences.c
- the Difference to be accepted.
public abstract boolean delete(int toLine, int toNumberOfLines, boolean runDiffAfterward)
toLine
- the starting linetoNumberOfLines
- the number of lines to be deleted.runDiffAfterward
- true of run the diff() again after deleting the lines.
public abstract boolean insert(int toLine, int fromLine, int fromNumberOfLines, boolean runDiffAfterward)
toLine
- the insertion line in the toEditorfromLine
- the starting line in the fromEditorfromNumberOfLines
- the number of lines in the fromEditor to be inserted to the toEditor.runDiffAfterward
- true of run the diff() again after inserting the lines.
public boolean replace(int toLine, int toNumberOfLines, int fromLine, int fromNumberOfLines, boolean runDiffAfterward)
toLine
- the starting line in the toEditortoNumberOfLines
- the number of lines to be replaced from the toEditor.fromLine
- the starting line in the fromEditorfromNumberOfLines
- the number of lines in the fromEditor to be copied to the toEditor.runDiffAfterward
- true of run the diff() again after replacing the lines.
public boolean isSelectOnNavigation()
setSelectOnNavigation(boolean)
public void setSelectOnNavigation(boolean selectOnNavigation)
selectOnNavigation
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |