Package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer

# Class EMFCompareStructureMergeViewerContentProvider

java.lang.Object
org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider
org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider

All Implemented Interfaces:
  `org.eclipse.core.runtime.jobs.IJobChangeListener`, `INotifyChangedListener`, `org.eclipse.jface.viewers.IContentProvider`, `org.eclipse.jface.viewers.IStructuredContentProvider`, `org.eclipse.jface.viewers.ITreeContentProvider`, `org.eclipse.ui.views.properties.IPropertySourceProvider`

public class EMFCompareStructureMergeViewerContentProvider extends AdapterFactoryContentProvider implements org.eclipse.core.runtime.jobs.IJobChangeListener
Specialized AdapterFactoryContentProvider for the emf compare structure merge viewer.

This class is not intended to be used outside of its package. It has been set to public for testing purpose only.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`EMFCompareStructureMergeViewerContentProvider.CallbackType`
Enum used for better readability of the method `runWhenReady(CallbackType, Runnable)`.

## Nested classes/interfaces inherited from class org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider

`AdapterFactoryContentProvider.ViewerRefresh`

## Field Summary

### Fields inherited from class org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider

`adapterFactory, viewer, viewerRefresh`

## Constructor Summary

Constructors
Constructor
Description
`EMFCompareStructureMergeViewerContentProvider(AdapterFactory adapterFactory, org.eclipse.jface.viewers.AbstractTreeViewer viewer)`
Constructs the content provider with the appropriate adapter factory.

## Method Summary

Modifier and Type
Method
Description
`void`
`aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent event)`
`protected Object[]`
`adaptElementsToCompareInput(Object[] elements)`
Adapt all of the given elements that are not instances of `PendingUpdateAdapter` into `ICompareInput` for the emf compare viewers when possible.
`boolean`
`addFetchingListener(org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.FetchListener listener)`
Adds a listener to this content provider.
`void`
`awake(org.eclipse.core.runtime.jobs.IJobChangeEvent event)`
`void`
`dispose()`
`void`
`done(org.eclipse.core.runtime.jobs.IJobChangeEvent event)`
`Object[]`
`getChildren(Object element)`
`Object[]`
`getElements(Object element)`
`Object`
`getParent(Object element)`
`protected Object[]`
`getRawChildren(Object element)`
Returns the raw list of children for the given element.
`boolean`
`hasChildren(Object element)`
`void`
`notifyChanged(Notification notification)`
This implementation specializes the EMF implementation to ensure that if more than 30 notifications arrive, the viewer is simply refreshed rather than processing each update separately.
`boolean`
`removeFetchingListener(org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.FetchListener listener)`
Removes a listener to this content provider.
`void`
`running(org.eclipse.core.runtime.jobs.IJobChangeEvent event)`
`void`
`runWhenReady(EMFCompareStructureMergeViewerContentProvider.CallbackType type, Runnable runnable)`
Run the given runnable in the specified thread when then content provider is ready.
`void`
`scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent event)`
`void`
`sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent event)`

### Methods inherited from class org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider

`createPropertySource, getAdapterFactory, getPropertySource, getViewerRefreshDelay, getViewerRefreshTheshold, inputChanged, setAdapterFactory`

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

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

## Constructor Details

### EMFCompareStructureMergeViewerContentProvider

public EMFCompareStructureMergeViewerContentProvider(AdapterFactory adapterFactory, org.eclipse.jface.viewers.AbstractTreeViewer viewer)
Constructs the content provider with the appropriate adapter factory.

Parameters:
  `adapterFactory` - The adapter factory used to construct the content provider.

## Method Details

### getParent

public Object getParent(Object element)

Specified by:
  `getParent` in interface `org.eclipse.jface.viewers.ITreeContentProvider`
Overrides:
  `getParent` in class `AdapterFactoryContentProvider`
See Also:
  - `AdapterFactoryContentProvider.getParent(Object object)`

### runWhenReady

public void runWhenReady(EMFCompareStructureMergeViewerContentProvider.CallbackType type, Runnable runnable)
Run the given runnable in the specified thread when then content provider is ready. It can be run directly if the content provider is not fecthing or during a callback when the content provider is done fetching.

Parameters:
  `type` - of thread to run the `Runnable` inside.
  `runnable` - to run

### addFetchingListener

public boolean addFetchingListener(org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.FetchListener listener)
Adds a listener to this content provider.

Parameters:
  `listener` - to add
Returns:

### removeFetchingListener

public boolean removeFetchingListener(org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.FetchListener listener)
Removes a listener to this content provider.

Parameters:
  `listener` - to remove
Returns:

### hasChildren

public boolean hasChildren(Object element)

Specified by:
  `hasChildren` in interface `org.eclipse.jface.viewers.ITreeContentProvider`
Overrides:
  `hasChildren` in class `AdapterFactoryContentProvider`
See Also:
  - `AdapterFactoryContentProvider.hasChildren(Object object)`

### getChildren

public Object[] getChildren(Object element)

Specified by:
  `getChildren` in interface `org.eclipse.jface.viewers.ITreeContentProvider`
Overrides:
  `getChildren` in class `AdapterFactoryContentProvider`
See Also:
  - `AdapterFactoryContentProvider.getChildren(java.lang.Object)`

### getRawChildren

protected Object[] getRawChildren(Object element)
Returns the raw list of children for the given element. This array will not be useable by the EMF Compare viewers without prior going through `adaptElementsToCompareInput(Object[])`.

Parameters:
  `element` - The element which children we need.
Returns:
  The children of this element.

### adaptElementsToCompareInput

protected Object[] adaptElementsToCompareInput(Object[] elements)
Adapt all of the given elements that are not instances of `PendingUpdateAdapter` into `ICompareInput` for the emf compare viewers when possible.

Parameters:
  `elements` - The elements to adapt.
Returns:
  The array of adapted elements.

### getElements

public Object[] getElements(Object element)

Specified by:
  `getElements` in interface `org.eclipse.jface.viewers.IStructuredContentProvider`
Specified by:
  `getElements` in interface `org.eclipse.jface.viewers.ITreeContentProvider`
Overrides:
  `getElements` in class `AdapterFactoryContentProvider`
See Also:
  - `AdapterFactoryContentProvider.getElements(Object object)`

### dispose

public void dispose()

Specified by:
  `dispose` in interface `org.eclipse.jface.viewers.IContentProvider`
Overrides:
  `dispose` in class `AdapterFactoryContentProvider`
See Also:
  - `IContentProvider.dispose()`

### notifyChanged

public void notifyChanged(Notification notification)
This implementation specializes the EMF implementation to ensure that if more than 30 notifications arrive, the viewer is simply refreshed rather than processing each update separately. This is especially important for when undo is invoked in editor and there are many things to be undone.

Specified by:
  `notifyChanged` in interface `INotifyChangedListener`
Overrides:
  `notifyChanged` in class `AdapterFactoryContentProvider`
See Also:
  - `IContentProvider.dispose()`

### aboutToRun

public void aboutToRun(org.eclipse.core.runtime.jobs.IJobChangeEvent event)

Specified by:
  `aboutToRun` in interface `org.eclipse.core.runtime.jobs.IJobChangeListener`

### awake

public void awake(org.eclipse.core.runtime.jobs.IJobChangeEvent event)

Specified by:
  `awake` in interface `org.eclipse.core.runtime.jobs.IJobChangeListener`
See Also:
  - `IJobChangeListener.awake(IJobChangeEvent)`

### done

public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event)

Specified by:
  `done` in interface `org.eclipse.core.runtime.jobs.IJobChangeListener`
See Also:
  - `IJobChangeListener.done(IJobChangeEvent)`

### running

public void running(org.eclipse.core.runtime.jobs.IJobChangeEvent event)

Specified by:
  `running` in interface `org.eclipse.core.runtime.jobs.IJobChangeListener`
See Also:
  - `IJobChangeListener.running(IJobChangeEvent)`

### scheduled

public void scheduled(org.eclipse.core.runtime.jobs.IJobChangeEvent event)

Specified by:
  `scheduled` in interface `org.eclipse.core.runtime.jobs.IJobChangeListener`
See Also:
  - `IJobChangeListener.scheduled(IJobChangeEvent)`

### sleeping

public void sleeping(org.eclipse.core.runtime.jobs.IJobChangeEvent event)

Specified by:
  `sleeping` in interface `org.eclipse.core.runtime.jobs.IJobChangeListener`
See Also:
  - `IJobChangeListener.sleeping(IJobChangeEvent)`