|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.viewers.Viewer
org.eclipse.jface.viewers.ContentViewer
org.eclipse.compare.contentmergeviewer.ContentMergeViewer
org.eclipse.compare.contentmergeviewer.TextMergeViewer
A text merge viewer uses the RangeDifferencer to perform a textual, line-by-line comparison of two (or three) input documents. It is based on the ContentMergeViewer and uses TextViewers to implement the ancestor, left, and right content areas.
In the three-way compare case ranges of differing lines are highlighted and framed with different colors to show whether the difference is an incoming, outgoing, or conflicting change. The TextMergeViewer supports the notion of a current "differing range" and provides toolbar buttons to navigate from one range to the next (or previous).
If there is a current "differing range" and the underlying document is editable the TextMergeViewer enables actions in context menu and toolbar to copy a range from one side to the other side, thereby performing a merge operation.
In addition to a line-by-line comparison the TextMergeViewer uses a token based compare on differing lines. The token compare is activated when navigating into a range of differing lines. At first the lines are selected as a block. When navigating into this block the token compare shows for every line the differing token by selecting them.
The TextMergeViewer's default token compare works on characters separated by whitespace. If a different strategy is needed (for example, Java tokens in a Java-aware merge viewer), clients can create their own token comparators by implementing the ITokenComparator interface and overriding the TextMergeViewer.createTokenComparator factory method).
Access to the TextMergeViewer's model is by means of an
IMergeViewerContentProvider. Its get
A TextMergeViewer can be used as is. However clients may subclass to customize the behavior. For example a MergeTextViewer for Java would override the configureTextViewer method to configure the TextViewer for Java source code, the createTokenComparator method to create a Java specific tokenizer.
Field Summary |
Fields inherited from class org.eclipse.jface.viewers.Viewer |
WIDGET_DATA_KEY |
Constructor Summary | |
TextMergeViewer(Composite parent,
CompareConfiguration configuration)
Creates a text merge viewer under the given parent control. | |
TextMergeViewer(Composite parent,
int style,
CompareConfiguration configuration)
Creates a text merge viewer under the given parent control. |
Method Summary | |
protected void | configureTextViewer(TextViewer textViewer)
Configures the passed text viewer. |
protected void | copy(boolean leftToRight)
Copies the content of one side to the other side. |
protected void | createControls(Composite composite)
Creates the specific SWT controls for the content areas. |
protected ITokenComparator | createTokenComparator(String s)
Creates an ITokenComparator which is used to show the intra line differences. |
protected void | createToolItems(ToolBarManager tbm)
Creates the two items for copying a difference range from one side to the other and adds them to the given toolbar manager. |
protected boolean | doSave(Object newInput,
Object oldInput)
Overridden to prevent save confirmation if new input is sub document of current input. |
protected int | findInsertionPosition(char type,
ICompareInput input)
This method is called if a range of text on one side is copied into an empty subdocument on the other side. |
protected byte[] | getContents(boolean left)
Returns the contents of the underlying document as an array of bytes using the current workbench encoding. |
protected IDocumentPartitioner | getDocumentPartitioner()
Returns a document partitioner which is suitable for the underlying content type. |
protected void | handleDispose(DisposeEvent event)
Called on the viewer disposal. |
protected void | handleResizeAncestor(int x,
int y,
int width,
int height)
Lays out the ancestor area of the compare viewer. |
protected void | handleResizeLeftRight(int x,
int y,
int width1,
int centerWidth,
int width2,
int height)
Lays out everything. |
void | invalidateTextPresentation()
Invalidates the current presentation by invalidating the three text viewers. |
void | setBackgroundColor(RGB background)
Sets the viewer's background color to the given RGB value. |
void | setForegroundColor(RGB foreground)
Sets the viewer's foreground color to the given RGB value. |
protected void | updateContent(Object ancestor,
Object left,
Object right)
Initializes the text viewers of the three content areas with the given input objects. |
protected void | updateHeader()
Updates the headers of the three areas by querying the content provider for a name and image for the three sides of the input object. |
protected void | updateToolItems()
Updates the enabled state of the toolbar items. |
Methods inherited from class org.eclipse.compare.contentmergeviewer.ContentMergeViewer |
addPropertyChangeListener, buildControl, getCompareConfiguration, getControl, getResourceBundle, getSelection, getTitle, inputChanged, refresh, removePropertyChangeListener, save, setConfirmSave, setContentProvider, setLeftDirty, setRightDirty, setSelection |
Methods inherited from class org.eclipse.jface.viewers.ContentViewer |
getContentProvider, getInput, getLabelProvider, handleLabelProviderChanged, hookControl, labelProviderChanged, setInput, setLabelProvider |
Methods inherited from class org.eclipse.jface.viewers.Viewer |
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TextMergeViewer(Composite parent, CompareConfiguration configuration)
public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration)
Method Detail |
public void setBackgroundColor(RGB background)
public void setForegroundColor(RGB foreground)
public void invalidateTextPresentation()
protected void configureTextViewer(TextViewer textViewer)
protected ITokenComparator createTokenComparator(String s)
protected IDocumentPartitioner getDocumentPartitioner()
The TextMergeViewer implementation of this method returns null. Subclasses may reimplement to create a partitioner for a specific content type.
protected void handleDispose(DisposeEvent event)
protected void createControls(Composite composite)
protected boolean doSave(Object newInput, Object oldInput)
protected void updateContent(Object ancestor, Object left, Object right)
protected int findInsertionPosition(char type, ICompareInput input)
protected byte[] getContents(boolean left)
protected final void handleResizeAncestor(int x, int y, int width, int height)
protected final void handleResizeLeftRight(int x, int y, int width1, int centerWidth, int width2, int height)
protected void updateHeader()
This method is called whenever the header must be updated.
Subclasses may extend this method, although this is generally not required.
protected void createToolItems(ToolBarManager tbm)
protected void updateToolItems()
This method is called whenever the state of the items needs updating.
Subclasses may extend this method, although this is generally not required.
protected void copy(boolean leftToRight)
|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.