## org.eclipse.emf.compare.ui.viewer.content
Class ModelContentMergeViewer

    java.lang.Object
      org.eclipse.jface.viewers.Viewer
          org.eclipse.jface.viewers.ContentViewer
              org.eclipse.compare.contentmergeviewer.ContentMergeViewer
                  org.eclipse.emf.compare.ui.viewer.content.ModelContentMergeViewer

All Implemented Interfaces:
  org.eclipse.compare.contentmergeviewer.IFlushable, org.eclipse.compare.IPropertyChangeNotifier, org.eclipse.jface.viewers.IInputProvider, org.eclipse.jface.viewers.IInputSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider

    public class ModelContentMergeViewer

extends org.eclipse.compare.contentmergeviewer.ContentMergeViewer

Compare and merge viewer with two side-by-side content areas and an optional content area for the ancestor.

Field Summary
`protected int` `activeTabIndex` Keeps track of the currently selected tab for this viewer part.
`protected ModelContentMergeTabFolder` `ancestorPart` Ancestor part of the three possible parts of this content viewer.
`static java.lang.String` `BUNDLE_NAME` Name of the bundle resources property file.
`static int` `CENTER_WIDTH` Width to affect to the center area.
`protected org.eclipse.compare.CompareConfiguration` `configuration` `CompareConfiguration` controls various aspect of the GUI elements.
`protected java.util.List<DiffElement>` `currentSelection` Keeps track of the current diff Selection.
`protected boolean` `isThreeWay` Indicates that this is a three-way comparison.
`protected ModelContentMergeTabFolder` `leftPart` Left of the three possible parts of this content viewer.
`protected ModelContentMergeTabFolder` `rightPart` Right of the three possible parts of this content viewer.

Fields inherited from class org.eclipse.jface.viewers.Viewer
`WIDGET_DATA_KEY`

Constructor Summary
`ModelContentMergeViewer(org.eclipse.swt.widgets.Composite parent, org.eclipse.compare.CompareConfiguration config)` Creates a new model content merge viewer and initializes it.

Method Summary
`protected void` `copy(boolean leftToRight)`
`protected void` `copy(java.util.List<DiffElement> diffs, boolean leftToRight)` Copies a list of `DiffElement`s or `DiffGroup`s in the given direction, then updates the toolbar items states as well as the dirty state of both the left and the right models.
`protected void` `copyDiffLeftToRight()` Undoes the changes implied by the currently selected `diff`.
`protected void` `copyDiffRightToLeft()` Applies the changes implied by the currently selected `diff`.
`protected void` `createControls(org.eclipse.swt.widgets.Composite composite)`
`protected org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider` `createMergeViewerContentProvider()` Creates and return our content provider.
`protected ModelCompareInput` `createModelCompareInput(ICompareInputDetailsProvider provider, ComparisonSnapshot snapshot)` Creates the `ModelCompareInput` for this particular viewer.
`protected ModelContentMergeTabFolder` `createModelContentMergeTabFolder(org.eclipse.swt.widgets.Composite composite, int side)` Creates a new `tab folder` for the specified `side` (left, right or ancestor).
`protected void` `createToolItems(org.eclipse.jface.action.ToolBarManager tbm)`
`protected void` `fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)`
`org.eclipse.swt.widgets.Canvas` `getCenterPart()` Returns the center `Canvas` appearing between the viewer parts.
`static org.eclipse.swt.graphics.RGB` `getColor(java.lang.String key)` Returns the color identified by the given key in `colors`.
`org.eclipse.compare.CompareConfiguration` `getConfiguration()` Returns the compare configuration of this viewer.
`protected byte[]` `getContents(boolean left)`
`protected java.util.List<DiffElement>` `getVisibleDiffs()` This will minimize the list of differences to the visible differences.
`protected void` `handleDispose(org.eclipse.swt.events.DisposeEvent event)`
`protected void` `handleResizeAncestor(int x, int y, int width, int height)`
`protected void` `handleResizeLeftRight(int x, int y, int leftWidth, int centerWidth, int rightWidth, int height)`
`protected void` `navigate(boolean down)` Selects the next or previous `DiffElement` as compared to the currently selected one.
`void` `setInput(java.lang.Object input)`
`void` `setSelection(DiffElement diff)` Sets the parts' tree selection given the `DiffElement` to select.
`void` `setSelection(java.util.List<DiffElement> diffs)` Sets the parts' tree selection given the list of `DiffElement`s to select.
`static boolean` `shouldDrawDiffMarkers()` Returns `True` if the trees and center have to draw markers over the differences.
`protected void` `switchCopyState(boolean enabled)` This will enable or disable the toolbar's copy actions according to the given `boolean`.
`void` `update()` Redraws this viewer.
`void` `updateCenter()` Redraws the center Control.
`protected void` `updateContent(java.lang.Object ancestor, java.lang.Object left, java.lang.Object right)`
`protected void` `updatePreferences()` Updates the values of all the variables using preferences values.
`protected void` `updateToolItems()`

Methods inherited from class org.eclipse.compare.contentmergeviewer.ContentMergeViewer

`addPropertyChangeListener, buildControl, createCenterControl, doSave, flush, flushContent, getCenterControl, getCenterWidth, getCompareConfiguration, getControl, getResourceBundle, getSelection, getTitle, getToolBarManager, handleCompareInputChange, handlePropertyChangeEvent, handleSetFocus, inputChanged, isAncestorVisible, isLeftDirty, isRightDirty, isThreeWay, refresh, removePropertyChangeListener, save, setConfirmSave, setContentProvider, setLeftDirty, setRightDirty, setSelection, updateHeader`

Methods inherited from class org.eclipse.jface.viewers.ContentViewer
`getContentProvider, getInput, getLabelProvider, handleLabelProviderChanged, hookControl, labelProviderChanged, setLabelProvider`

Methods inherited from class org.eclipse.jface.viewers.Viewer
`addHelpListener, addSelectionChangedListener, fireHelpRequested, 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`

Field Detail

### BUNDLE_NAME

    public static final java.lang.String BUNDLE_NAME

  Name of the bundle resources property file.

  See Also:
    Constant Field Values

### CENTER_WIDTH

    public static final int CENTER_WIDTH

  Width to affect to the center area.

  See Also:
    Constant Field Values

### activeTabIndex

    protected int activeTabIndex

  Keeps track of the currently selected tab for this viewer part.

### ancestorPart

    protected ModelContentMergeTabFolder ancestorPart

  Ancestor part of the three possible parts of this content viewer.

### currentSelection

    protected final java.util.List<DiffElement> currentSelection

  Keeps track of the current diff Selection.

### leftPart

    protected ModelContentMergeTabFolder leftPart

  Left of the three possible parts of this content viewer.

### rightPart

    protected ModelContentMergeTabFolder rightPart

  Right of the three possible parts of this content viewer.

### configuration

    protected final org.eclipse.compare.CompareConfiguration configuration

  `CompareConfiguration` controls various aspect of the GUI elements. This will keep track of the one used to created this compare editor.

  Since:
    1.1

### isThreeWay

    protected boolean isThreeWay

  Indicates that this is a three-way comparison.

  Since:
    1.1

Constructor Detail

### ModelContentMergeViewer

    public ModelContentMergeViewer(org.eclipse.swt.widgets.Composite parent,
                                   org.eclipse.compare.CompareConfiguration config)

  Creates a new model content merge viewer and initializes it.

  Parameters:
    `parent` - Parent composite for this viewer.
    `config` - The configuration object.

Method Detail

### getColor

    public static final org.eclipse.swt.graphics.RGB getColor(java.lang.String key)

  Returns the color identified by the given key in `colors`.

  Parameters:
    `key` - Key of the color to return.
  Returns:
    The color identified by the given key in the map.

### shouldDrawDiffMarkers

    public static boolean shouldDrawDiffMarkers()

  Returns `True` if the trees and center have to draw markers over the differences.

  Returns:
    `True` if the trees and center have to draw markers over the differences, `False` otherwise.

### getCenterPart

    public org.eclipse.swt.widgets.Canvas getCenterPart()

  Returns the center `Canvas` appearing between the viewer parts.

  Returns:
    The center `Canvas`.

### getConfiguration

    public org.eclipse.compare.CompareConfiguration getConfiguration()

  Returns the compare configuration of this viewer.

  Returns:
    The compare configuration of this viewer.

### setInput

    public void setInput(java.lang.Object input)

  Overrides:
    `setInput` in class `org.eclipse.jface.viewers.ContentViewer`

### createModelCompareInput

    protected ModelCompareInput createModelCompareInput(ICompareInputDetailsProvider provider,
                                                        ComparisonSnapshot snapshot)

  Creates the `ModelCompareInput` for this particular viewer.

  Parameters:
    `provider` - The input provider instance that is in charge of this comparison.
    `snapshot` - Snapshot describing the current comparison.
  Returns:
    The prepared `ModelCompareInput` for this particular viewer.
  Since:
    1.1

### setSelection

    public void setSelection(DiffElement diff)

  Sets the parts' tree selection given the `DiffElement` to select.

  Parameters:
    `diff` - `DiffElement` backing the current selection.

### setSelection

    public void setSelection(java.util.List<DiffElement> diffs)

  Sets the parts' tree selection given the list of `DiffElement`s to select.

  Parameters:
    `diffs` - `DiffElement` backing the current selection.

### update

    public void update()

  Redraws this viewer.

### updateCenter

    public void updateCenter()

  Redraws the center Control.

### copy

    protected void copy(boolean leftToRight)

  Specified by:
    `copy` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.copy(boolean)`

### copy

    protected void copy(java.util.List<DiffElement> diffs,
                        boolean leftToRight)

  Copies a list of `DiffElement`s or `DiffGroup`s in the given direction, then updates the toolbar items states as well as the dirty state of both the left and the right models.

  Parameters:
    `diffs` - `Element`s to copy.
    `leftToRight` - Direction of the copy.
  See Also:
    `ModelCompareInput.copy(List, boolean)`

### copyDiffLeftToRight

    protected void copyDiffLeftToRight()

  Undoes the changes implied by the currently selected `diff`.

### copyDiffRightToLeft

    protected void copyDiffRightToLeft()

  Applies the changes implied by the currently selected `diff`.

### createControls

    protected void createControls(org.eclipse.swt.widgets.Composite composite)

  Specified by:
    `createControls` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.createControls(Composite)`

### createMergeViewerContentProvider

    protected org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider createMergeViewerContentProvider()

  Creates and return our content provider.

  Returns:
    The `content provider` for this merge viewer.
  Since:
    1.1

### createModelContentMergeTabFolder

    protected ModelContentMergeTabFolder createModelContentMergeTabFolder(org.eclipse.swt.widgets.Composite composite,
                                                                          int side)

  Creates a new `tab folder` for the specified `side` (left, right or ancestor). Clients may override this method in order to create their custom part.

  Parameters:
    `composite` - The parent `Composite` of the part to create.
    `side` - The side where the created part is going to be displayed.
  Returns:
    The created tab folder.
  Since:
    1.1

### createToolItems

    protected void createToolItems(org.eclipse.jface.action.ToolBarManager tbm)

  Overrides:
    `createToolItems` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.createToolItems(ToolBarManager)`

### fireSelectionChanged

    protected void fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)

  Overrides:
    `fireSelectionChanged` in class `org.eclipse.jface.viewers.Viewer`
  See Also:
    `Viewer.fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)`

### getContents

    protected byte[] getContents(boolean left)

  Specified by:
    `getContents` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.getContents(boolean)`

### getVisibleDiffs

    protected java.util.List<DiffElement> getVisibleDiffs()

  This will minimize the list of differences to the visible differences. Differences are considered "visible" if `DiffAdapterFactory.shouldBeHidden(org.eclipse.emf.ecore.EObject)` returns false on it.

  Returns:
    `List` of the visible differences for this comparison.

### handleDispose

    protected void handleDispose(org.eclipse.swt.events.DisposeEvent event)

  Overrides:
    `handleDispose` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.handleDispose(org.eclipse.swt.events.DisposeEvent)`

### handleResizeAncestor

    protected void handleResizeAncestor(int x,
                                        int y,
                                        int width,
                                        int height)

  Specified by:
    `handleResizeAncestor` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.handleResizeAncestor(int, int, int, int)`

### handleResizeLeftRight

    protected void handleResizeLeftRight(int x,
                                         int y,
                                         int leftWidth,
                                         int centerWidth,
                                         int rightWidth,
                                         int height)

  Specified by:
    `handleResizeLeftRight` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer#handleResizeLeftRight(int, int, int, int)`

### navigate

    protected void navigate(boolean down)

  Selects the next or previous `DiffElement` as compared to the currently selected one.

  Parameters:
    `down` - `True` if we seek the next `DiffElement`, `False` for the previous.

### switchCopyState

    protected void switchCopyState(boolean enabled)

  This will enable or disable the toolbar's copy actions according to the given `boolean`. The "copy diff left to right" action will be enabled if `enable` is `True`, but the "copy diff right to left" action will only be activated if `enable` is `True` AND the left model isn't a remote model.

  Parameters:
    `enabled` - `True` if we seek to enable the actions, `False` otherwise.

### updateContent

    protected void updateContent(java.lang.Object ancestor,
                                 java.lang.Object left,
                                 java.lang.Object right)

  Specified by:
    `updateContent` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.updateContent(Object, Object, Object)`

### updatePreferences

    protected void updatePreferences()

  Updates the values of all the variables using preferences values.

### updateToolItems

    protected void updateToolItems()

  Overrides:
    `updateToolItems` in class `org.eclipse.compare.contentmergeviewer.ContentMergeViewer`
  See Also:
    `ContentMergeViewer.updateToolItems()`

Copyright 2006 IBM Corporation and others. All Rights Reserved.