|
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<CharSequence> com.jidesoft.diff.CodeEditorDiffPane
public class CodeEditorDiffPane
CodeEditorDiffPane
is a diff pane based on CodeEditor
component in JIDE Code Editor
product. It can be used to compare two block of multiple line texts. The text will be displayed in a
CodeEditor
to have syntax coloring. It also uses the highlight features provided by
CodeEditor
to make it easy to see the differences.
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 CodeEditor |
_fromEditor
|
protected CodeEditor |
_toEditor
|
protected static char[] |
separators
|
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 | |
---|---|
CodeEditorDiffPane()
Creates a CodeEditorDiffPane. |
|
CodeEditorDiffPane(CharSequence fromText,
CharSequence toText)
|
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. |
void |
clearHighlights()
|
JComponent |
createComponent(Object item,
int index)
Creates the component to display the content for the diff. |
protected CodeEditor |
createEditor()
|
protected CodeEditor |
createEditor(int index)
Creates the code editor. |
Diff<?> |
createLinesDiff(int fromStartOffset,
int fromEndOffset,
int toStartOffset,
int toEndOffset)
Creates multiple lines diff. |
protected 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 RowMarginSupport |
createRowMarginSupport(JComponent component,
JScrollPane scrollPane)
|
protected void |
customizeEditor(CodeEditor editor,
int index)
|
protected void |
customizePane(JComponent pane,
int index)
Customizes the pane. |
boolean |
delete(int toLine,
int toNumberOfLines,
boolean runDiffAfterward)
Deletes number of lines from the specified started line in the toEditor. |
void |
endHighlights()
|
protected DiffTokens |
getDiffTokens(Segment text)
|
CharSequence[] |
getFromItems()
Gets the from items that is used for Diff to compare the lines. |
protected Segment |
getFromSegment(int startLineIndex,
int endLineIndex)
|
String |
getFromText()
|
protected Character[] |
getFromText(int startLineIndex,
int endLineIndex)
Gets the from text for line difference to compare. |
protected CharSequence |
getLineCharSequence(CodeEditor editor,
int lineIndex)
Creates the line char sequence for the code editor in the designated line. |
protected Segment |
getSegment(CodeEditor editor,
int startLineIndex,
int endLineIndex)
|
protected int |
getSelectedIndex(int paneIndex)
|
CharSequence[] |
getToItems()
Gets the to items that is used for Diff to compare the lines. |
protected Segment |
getToSegment(int startLineIndex,
int endLineIndex)
|
String |
getToText()
|
protected Character[] |
getToText(int startLineIndex,
int endLineIndex)
Gets the from text 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 fromStartLine,
int fromEndLine,
int toStartLine,
int toEndLine,
Color c,
Color separatorColor,
String changeToolTip)
|
void |
highlightDeleted(int fromStartLine,
int fromEndLine,
int toStartLine,
Color c,
Color separatorColor,
String changeToolTip)
|
void |
highlightInserted(int fromStartLine,
int toStartLine,
int toEndLine,
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. |
protected void |
installListeners()
Installs the listeners. |
boolean |
is_caseSensitive()
|
boolean |
isIgnoreLeadingTrailingSpaces()
Deprecated. replaced by isIgnoreWhitespaces() |
boolean |
isIgnoreWhitespaces()
|
void |
set_caseSensitive(boolean caseSensitive)
|
void |
setFromText(String fromText)
Sets the text for the from editor. |
void |
setIgnoreLeadingTrailingSpaces(boolean ignoreLeadingTrailingSpaces)
Deprecated. replaced by setIgnoreWhitespaces(boolean) |
void |
setIgnoreWhitespaces(boolean ignoreWhitespaces)
|
void |
setReadOnly(boolean readOnly)
Sets the read only flag. |
void |
setToText(String toText)
Sets the text for the to editor. |
protected String[] |
splitString(String string,
String lineBreak)
Deprecated. replaced by getLineCharSequence(com.jidesoft.editor.CodeEditor, int) . |
void |
startHighlights()
|
protected void |
synchronizeViewport(DiffDivider diffDivider,
boolean startFrom)
|
protected void |
uninstallListeners()
Uninstalls the listeners. |
Methods inherited from class com.jidesoft.diff.AbstractDiffPane |
---|
createActions, createButton, createContentArea, createLegendBar, createStatusBar, createToolBar, customizeAction, 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 CodeEditor _fromEditor
protected CodeEditor _toEditor
protected static char[] separators
Constructor Detail |
---|
public CodeEditorDiffPane()
setFromText(String)
and setToText(String)
methods.
public CodeEditorDiffPane(CharSequence fromText, CharSequence toText)
Method Detail |
---|
public JComponent createComponent(Object item, int index)
BasicDiffPane
createComponent
in class BasicDiffPane<CharSequence>
item
- the content to be displayed in the component.index
- the index of the component.
public JComponent createPane(Object item, int index)
AbstractDiffPane
createPane
in class BasicDiffPane<CharSequence>
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 void customizePane(JComponent pane, int index)
AbstractDiffPane
AbstractDiffPane.customizePanes(JComponent[])
.
customizePane
in class AbstractDiffPane
pane
- the pane.index
- the index of the pane.protected MarkerSupport createMarkerSupport(JComponent component)
createMarkerSupport
in class BasicDiffPane<CharSequence>
protected RowMarginSupport createRowMarginSupport(JComponent component, JScrollPane scrollPane)
createRowMarginSupport
in class BasicDiffPane<CharSequence>
protected void adjustDividerOffset(DiffDivider divider, int index)
AbstractDiffPane
adjustDividerOffset
in class BasicDiffPane<CharSequence>
divider
- the DiffDivider.index
- the index of the DiffDivider.protected CodeEditor createEditor(int index)
createEditor()
to create a CodeEditor instance.
index
- the code editor index
protected CodeEditor createEditor()
protected void customizeEditor(CodeEditor editor, int index)
public CharSequence[] getFromItems()
getFromText(int, int)
is used.
getFromItems
in class BasicDiffPane<CharSequence>
getFromText(int, int)
public CharSequence[] getToItems()
getToText(int, int)
is used.
getToItems
in class BasicDiffPane<CharSequence>
getToText(int, int)
protected CharSequence getLineCharSequence(CodeEditor editor, int lineIndex)
editor
- the code editorlineIndex
- the line number
protected Segment getFromSegment(int startLineIndex, int endLineIndex)
protected Segment getToSegment(int startLineIndex, int endLineIndex)
protected Segment getSegment(CodeEditor editor, int startLineIndex, int endLineIndex)
public boolean isIgnoreWhitespaces()
public void setIgnoreWhitespaces(boolean ignoreWhitespaces)
public boolean is_caseSensitive()
public void set_caseSensitive(boolean caseSensitive)
public void setFromText(String fromText)
fromText
- the new text for the from editor.public String getFromText()
public Diff<?> createLinesDiff(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset)
highlightChangedExactly(java.util.List, int, int, int, int, java.awt.Color, java.awt.Color, String)
will consider the offset and get the correct position
createLinesDiff
in class BasicDiffPane<CharSequence>
fromStartOffset
- from start offsetfromEndOffset
- from end offsettoStartOffset
- to start offsettoEndOffset
- to end offset
protected Character[] getFromText(int startLineIndex, int endLineIndex)
startLineIndex
- the start line indexendLineIndex
- the end line index
protected Character[] getToText(int startLineIndex, int endLineIndex)
startLineIndex
- the start line indexendLineIndex
- the end line index
public void setToText(String toText)
toText
- the new text for the to editor.public String getToText()
protected void synchronizeViewport(DiffDivider diffDivider, boolean startFrom)
protected int getSelectedIndex(int paneIndex)
getSelectedIndex
in class BasicDiffPane<CharSequence>
protected void installListeners()
AbstractDiffPane
installListeners
in class BasicDiffPane<CharSequence>
protected void uninstallListeners()
AbstractDiffPane
AbstractDiffPane.installListeners()
uninstallListeners
in class BasicDiffPane<CharSequence>
@Deprecated protected String[] splitString(String string, String lineBreak)
getLineCharSequence(com.jidesoft.editor.CodeEditor, int)
.
string
- the stringlineBreak
- the line breakpublic void setReadOnly(boolean readOnly)
setReadOnly
in class BasicDiffPane<CharSequence>
readOnly
- the new read only flag.public void clearHighlights()
clearHighlights
in class BasicDiffPane<CharSequence>
public void startHighlights()
startHighlights
in class BasicDiffPane<CharSequence>
public void endHighlights()
endHighlights
in class BasicDiffPane<CharSequence>
public void highlightChangedExactly(List<Difference> lineDiff, int fromStartLine, int fromEndLine, int toStartLine, int toEndLine, Color c, Color separatorColor, String changeToolTip)
highlightChangedExactly
in class BasicDiffPane<CharSequence>
protected DiffTokens getDiffTokens(Segment text)
public void highlightChanged(int fromStartOffset, int fromEndOffset, int toStartOffset, int toEndOffset, Color c, Color separatorColor, String changeToolTip)
highlightChanged
in class BasicDiffPane<CharSequence>
public void highlightInserted(int fromStartLine, int toStartLine, int toEndLine, Color c, Color separatorColor, String changeToolTip)
highlightInserted
in class BasicDiffPane<CharSequence>
public void highlightDeleted(int fromStartLine, int fromEndLine, int toStartLine, Color c, Color separatorColor, String changeToolTip)
highlightDeleted
in class BasicDiffPane<CharSequence>
protected List<Difference> acceptDifference(List<Difference> differences, Difference c)
acceptDifference
in class BasicDiffPane<CharSequence>
differences
- the list of Differences.c
- the Difference to be accepted.
public boolean delete(int toLine, int toNumberOfLines, boolean runDiffAfterward)
delete
in class BasicDiffPane<CharSequence>
toLine
- the starting linetoNumberOfLines
- the number of lines to be deleted.runDiffAfterward
- true of run the diff() again after deleting the lines.
public boolean insert(int toLine, int fromLine, int fromNumberOfLines, boolean runDiffAfterward)
insert
in class BasicDiffPane<CharSequence>
toLine
- the insersion 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.
@Deprecated public boolean isIgnoreLeadingTrailingSpaces()
isIgnoreWhitespaces()
setIgnoreLeadingTrailingSpaces(boolean)
@Deprecated public void setIgnoreLeadingTrailingSpaces(boolean ignoreLeadingTrailingSpaces)
setIgnoreWhitespaces(boolean)
ignoreLeadingTrailingSpaces
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |