Package org.eclipse.compare.internal

# Class MergeSourceViewer

java.lang.Object
org.eclipse.compare.internal.MergeSourceViewer

All Implemented Interfaces:
  `IOperationHistoryListener`, `IAdaptable`, `IMenuListener`, `ITextListener`, `ISelectionChangedListener`

public class MergeSourceViewer extends Object implements ISelectionChangedListener, ITextListener, IMenuListener, IOperationHistoryListener, IAdaptable
Wraps a JFace SourceViewer and add some convenience methods.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`CHANGE_ENCODING_ID`
`static final String`
`COPY_ID`
`static final String`
`CUT_ID`
`static final String`
`DELETE_ID`
`static final String`
`FIND_ID`
`static final String`
`GOTO_LINE_ID`
`static final String`
`PASTE_ID`
`static final String`
`REDO_ID`
`static final String`
`SELECT_ALL_ID`
`static final String`
`UNDO_ID`

## Constructor Summary

Constructors
Constructor
Description
`MergeSourceViewer(SourceViewer sourceViewer, ResourceBundle bundle, ICompareContainer container)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addAction(String actionId, MergeViewerAction action)`
`void`
`addAction(String id, IAction action)`
`void`
`addTextAction(IAction textEditorPropertyAction)`
`void`
`configure(SourceViewerConfiguration configuration)`
`protected IAction`
`createAction(String actionId)`
`void`
`dispose()`
The viewer is no longer part of the UI, it's a wrapper only.
`IAction`
`getAction(String actionId)`
`<T> T`
`getAdapter(Class<T> adapter)`
Returns an object which is an instance of the given class associated with this object.
`int`
`getDocumentRegionOffset()`
`boolean`
`getEnabled()`
`int`
`getLineCount()`
`Point`
`getLineRange(Position p, Point region)`
`Position`
`getRegion()`
`IDocument`
`getRememberedDocument()`
`SourceViewer`
`getSourceViewer()`
`int`
`getVerticalScrollOffset()`
`int`
`getViewportHeight()`
`int`
`getViewportLines()`
`protected void`
`handlePropertyChangeEvent(PropertyChangeEvent event)`
handle show/hide line numbers from editor preferences
`void`
`hideSaveAction()`
`void`
`historyNotification(OperationHistoryEvent event)`
Something of note has happened in the IOperationHistory.
`boolean`
`isControlOkToUse()`
`void`
`menuAboutToShow(IMenuManager menu)`
Notifies this listener that the menu is about to be shown by the given menu manager.
`void`
`rememberDocument(IDocument doc)`
`boolean`
`removeTextAction(IAction textEditorPropertyAction)`
`void`
`resetLineBackground()`
`void`
`selectionChanged(SelectionChangedEvent event)`
Notifies that the selection has changed.
`void`
`setBackgroundColor(Color color)`
`void`
`setBounds(int x, int y, int width, int height)`
specific implementation to support a vertical ruler
`void`
`setEnabled(boolean enabled)`
`void`
`setFont(Font font)`
`void`
`setForegroundColor(Color color)`
`void`
`setLineBackground(Position position, Color c)`
`void`
`setRegion(Position region)`
`void`
`setSelection(Position position)`
`void`
`textChanged(TextEvent event)`
The visual representation of a text viewer this listener is registered with has been changed.
`void`
`updateActions()`
update all actions independent of their type
`void`
`vscroll(int line)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### UNDO_ID

public static final String UNDO_ID

See Also:
  - Constant Field Values

### REDO_ID

public static final String REDO_ID

See Also:
  - Constant Field Values

### CUT_ID

public static final String CUT_ID

See Also:
  - Constant Field Values

### COPY_ID

public static final String COPY_ID

See Also:
  - Constant Field Values

### PASTE_ID

public static final String PASTE_ID

See Also:
  - Constant Field Values

### DELETE_ID

public static final String DELETE_ID

See Also:
  - Constant Field Values

### SELECT_ALL_ID

public static final String SELECT_ALL_ID

See Also:
  - Constant Field Values

### FIND_ID

public static final String FIND_ID

See Also:
  - Constant Field Values

### GOTO_LINE_ID

public static final String GOTO_LINE_ID

See Also:
  - Constant Field Values

### CHANGE_ENCODING_ID

public static final String CHANGE_ENCODING_ID

See Also:
  - Constant Field Values

## Constructor Details

### MergeSourceViewer

public MergeSourceViewer(SourceViewer sourceViewer, ResourceBundle bundle, ICompareContainer container)

## Method Details

### rememberDocument

public void rememberDocument(IDocument doc)

### getRememberedDocument

public IDocument getRememberedDocument()

### hideSaveAction

public void hideSaveAction()

### setFont

public void setFont(Font font)

### setBackgroundColor

public void setBackgroundColor(Color color)

### setForegroundColor

public void setForegroundColor(Color color)

### setEnabled

public void setEnabled(boolean enabled)

### getEnabled

public boolean getEnabled()

### setRegion

public void setRegion(Position region)

### getRegion

public Position getRegion()

### isControlOkToUse

public boolean isControlOkToUse()

### setSelection

public void setSelection(Position position)

### setLineBackground

public void setLineBackground(Position position, Color c)

### resetLineBackground

public void resetLineBackground()

### getLineCount

public int getLineCount()

### getViewportLines

public int getViewportLines()

### getViewportHeight

public int getViewportHeight()

### getDocumentRegionOffset

public int getDocumentRegionOffset()

### getVerticalScrollOffset

public int getVerticalScrollOffset()

### getLineRange

public Point getLineRange(Position p, Point region)

### vscroll

public void vscroll(int line)

### addAction

public void addAction(String actionId, MergeViewerAction action)

### getAction

public IAction getAction(String actionId)

### createAction

protected IAction createAction(String actionId)

### selectionChanged

public void selectionChanged(SelectionChangedEvent event)
Description copied from interface: `ISelectionChangedListener`
Notifies that the selection has changed.

Specified by:
  `selectionChanged` in interface `ISelectionChangedListener`
Parameters:
  `event` - event object describing the change

### textChanged

public void textChanged(TextEvent event)
Description copied from interface: `ITextListener`
The visual representation of a text viewer this listener is registered with has been changed.

Specified by:
  `textChanged` in interface `ITextListener`
Parameters:
  `event` - the description of the change

### menuAboutToShow

public void menuAboutToShow(IMenuManager menu)
Description copied from interface: `IMenuListener`
Notifies this listener that the menu is about to be shown by the given menu manager.

Specified by:
  `menuAboutToShow` in interface `IMenuListener`
Parameters:
  `menu` - the menu manager

### dispose

public void dispose()
The viewer is no longer part of the UI, it's a wrapper only. The disposal doesn't take place while releasing the editor pane's children. The method have to be called it manually. The wrapped viewer is disposed as a regular viewer, while disposing the UI.

### updateActions

public void updateActions()
update all actions independent of their type

### configure

public void configure(SourceViewerConfiguration configuration)

### setBounds

public void setBounds(int x, int y, int width, int height)
specific implementation to support a vertical ruler

### handlePropertyChangeEvent

protected void handlePropertyChangeEvent(PropertyChangeEvent event)
handle show/hide line numbers from editor preferences

### addTextAction

public void addTextAction(IAction textEditorPropertyAction)

### removeTextAction

public boolean removeTextAction(IAction textEditorPropertyAction)

### addAction

public void addAction(String id, IAction action)

### historyNotification

public void historyNotification(OperationHistoryEvent event)
Description copied from interface: `IOperationHistoryListener`
Something of note has happened in the IOperationHistory. Listeners should check the supplied event for details.

Specified by:
  `historyNotification` in interface `IOperationHistoryListener`
Parameters:
  `event` - the OperationHistoryEvent that describes the particular notification.

### getSourceViewer

public SourceViewer getSourceViewer()

Returns:
  the wrapped viewer

### getAdapter

public <T> T getAdapter(Class<T> adapter)
Description copied from interface: `IAdaptable`
Returns an object which is an instance of the given class associated with this object. Returns `null` if no such object can be found.

Clients may implement this method but should generally call `Adapters.adapt(Object, Class, boolean)` rather than invoking it directly.

Specified by:
  `getAdapter` in interface `IAdaptable`
Type Parameters:
  `T` - the class type
Parameters:
  `adapter` - the adapter class to look up
Returns:
  a object of the given class, or `null` if this object does not have an adapter for the given class