org.eclipse.xtext.ui.compare
Class DefaultMergeViewer

java.lang.Object
  extended by org.eclipse.jface.viewers.Viewer
      extended by org.eclipse.jface.viewers.ContentViewer
          extended by org.eclipse.compare.contentmergeviewer.ContentMergeViewer
              extended by org.eclipse.compare.contentmergeviewer.TextMergeViewer
                  extended by org.eclipse.xtext.ui.compare.DefaultMergeViewer
All Implemented Interfaces:
org.eclipse.compare.contentmergeviewer.IFlushable, org.eclipse.compare.internal.IFlushable2, org.eclipse.compare.IPropertyChangeNotifier, org.eclipse.core.runtime.IAdaptable, org.eclipse.jface.viewers.IInputProvider, org.eclipse.jface.viewers.IInputSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider

public class DefaultMergeViewer
extends org.eclipse.compare.contentmergeviewer.TextMergeViewer

Author:
Michael Clay - Initial contribution and API

Field Summary
protected  org.eclipse.ui.texteditor.IDocumentProvider documentProvider
           
protected  com.google.inject.Provider<XtextSourceViewerConfiguration> sourceViewerConfigurationProvider
           
protected  java.util.Map<org.eclipse.jface.text.source.ISourceViewer,DefaultMergeEditor> sourceViewerEditorMap
           
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Constructor Summary
DefaultMergeViewer(org.eclipse.swt.widgets.Composite parent, int styles, org.eclipse.compare.CompareConfiguration compareConfiguration, org.eclipse.ui.texteditor.IDocumentProvider documentProvider)
           
DefaultMergeViewer(org.eclipse.swt.widgets.Composite parent, int styles, org.eclipse.compare.CompareConfiguration compareConfiguration, StreamContentDocumentProvider documentProvider, com.google.inject.Provider<XtextSourceViewerConfiguration> sourceViewerConfigurationProvider)
           
 
Method Summary
protected  void configureSourceViewer(org.eclipse.jface.text.source.SourceViewer sourceViewer)
           
protected  void configureTextViewer(org.eclipse.jface.text.TextViewer textViewer)
          Configures the passed text viewer.
protected  DefaultMergeEditor createMergeEditor()
           
protected  org.eclipse.compare.IResourceProvider createResourceProvider(java.lang.Object object)
           
protected  org.eclipse.jface.text.source.SourceViewer createSourceViewer(org.eclipse.swt.widgets.Composite parent, int textOrientation)
          Creates a new source viewer.
protected  org.eclipse.jface.text.source.SourceViewerConfiguration createSourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewer sourceViewer, org.eclipse.ui.IEditorInput editorInput)
           
protected  void disconnectDocuments()
           
protected  void disposeEditors()
           
protected  DefaultMergeEditor getEditor(org.eclipse.jface.text.source.ISourceViewer sourceViewer)
           
protected  org.eclipse.ui.IEditorInput getEditorInput(org.eclipse.jface.text.source.ISourceViewer sourceViewer)
          Returns an editor input for the given source viewer.
protected  org.eclipse.ui.IWorkbenchPartSite getSite()
           
protected  void handleDispose(org.eclipse.swt.events.DisposeEvent event)
          Called on the viewer disposal.
protected  boolean isEditorBacked(org.eclipse.jface.text.ITextViewer textViewer)
          Tells whether the given text viewer is backed by an editor.
protected  void setActionsActivated(org.eclipse.jface.text.source.SourceViewer sourceViewer, boolean state)
          Activates or deactivates actions of the given source viewer.
protected  void setEditable(org.eclipse.jface.text.source.ISourceViewer sourceViewer, boolean state)
          Sets the editable state of the given source viewer.
protected  java.lang.Object updateAsDocument(java.lang.Object object)
           
protected  void updateContent(java.lang.Object ancestor, java.lang.Object left, java.lang.Object right)
          Initializes the controls of the three content areas with the given input objects.
 
Methods inherited from class org.eclipse.compare.contentmergeviewer.TextMergeViewer
copy, createCenterControl, createControls, createTokenComparator, createToolItems, doSave, findInsertionPosition, flushContent, getAdapter, getCenterWidth, getContents, getDocumentPartitioner, getDocumentPartitioning, handleCompareInputChange, handlePropertyChangeEvent, handleResizeAncestor, handleResizeLeftRight, handleSetFocus, invalidateTextPresentation, setBackgroundColor, setForegroundColor, setupDocument, updateHeader, updateToolItems
 
Methods inherited from class org.eclipse.compare.contentmergeviewer.ContentMergeViewer
addPropertyChangeListener, buildControl, flush, flushLeft, flushRight, getCenterControl, getCompareConfiguration, getControl, getResourceBundle, getSelection, getTitle, getToolBarManager, inputChanged, internalIsLeftDirty, internalIsRightDirty, isAncestorVisible, isLeftDirty, isRightDirty, isThreeWay, 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
 

Field Detail

documentProvider

protected org.eclipse.ui.texteditor.IDocumentProvider documentProvider

sourceViewerEditorMap

protected java.util.Map<org.eclipse.jface.text.source.ISourceViewer,DefaultMergeEditor> sourceViewerEditorMap

sourceViewerConfigurationProvider

protected com.google.inject.Provider<XtextSourceViewerConfiguration> sourceViewerConfigurationProvider
Constructor Detail

DefaultMergeViewer

public DefaultMergeViewer(org.eclipse.swt.widgets.Composite parent,
                          int styles,
                          org.eclipse.compare.CompareConfiguration compareConfiguration,
                          org.eclipse.ui.texteditor.IDocumentProvider documentProvider)

DefaultMergeViewer

public DefaultMergeViewer(org.eclipse.swt.widgets.Composite parent,
                          int styles,
                          org.eclipse.compare.CompareConfiguration compareConfiguration,
                          StreamContentDocumentProvider documentProvider,
                          com.google.inject.Provider<XtextSourceViewerConfiguration> sourceViewerConfigurationProvider)
Method Detail

updateContent

protected void updateContent(java.lang.Object ancestor,
                             java.lang.Object left,
                             java.lang.Object right)
Description copied from class: org.eclipse.compare.contentmergeviewer.ContentMergeViewer
Initializes the controls of the three content areas with the given input objects.

Overrides:
updateContent in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
ancestor - the input for the ancestor area
left - the input for the left area
right - the input for the right area

updateAsDocument

protected java.lang.Object updateAsDocument(java.lang.Object object)

createResourceProvider

protected org.eclipse.compare.IResourceProvider createResourceProvider(java.lang.Object object)

handleDispose

protected void handleDispose(org.eclipse.swt.events.DisposeEvent event)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Called on the viewer disposal. Unregisters from the compare configuration. Clients may extend if they have to do additional cleanup.

Overrides:
handleDispose in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
event - a dispose event
See Also:
ContentViewer.handleDispose(org.eclipse.swt.events.DisposeEvent)

disposeEditors

protected void disposeEditors()

disconnectDocuments

protected void disconnectDocuments()

configureTextViewer

protected void configureTextViewer(org.eclipse.jface.text.TextViewer textViewer)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Configures the passed text viewer. This method is called after the three text viewers have been created for the content areas. The TextMergeViewer implementation of this method will configure the viewer with a SourceViewerConfiguration. Subclasses may reimplement to provide a specific configuration for the text viewer.

Overrides:
configureTextViewer in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
textViewer - the text viewer to configure

configureSourceViewer

protected void configureSourceViewer(org.eclipse.jface.text.source.SourceViewer sourceViewer)

createSourceViewerConfiguration

protected org.eclipse.jface.text.source.SourceViewerConfiguration createSourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewer sourceViewer,
                                                                                                  org.eclipse.ui.IEditorInput editorInput)

setEditable

protected void setEditable(org.eclipse.jface.text.source.ISourceViewer sourceViewer,
                           boolean state)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Sets the editable state of the given source viewer.

Overrides:
setEditable in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
sourceViewer - the source viewer
state - the state

setActionsActivated

protected void setActionsActivated(org.eclipse.jface.text.source.SourceViewer sourceViewer,
                                   boolean state)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Activates or deactivates actions of the given source viewer.

The default implementation does nothing, but clients should override to properly react to viewers switching.

Overrides:
setActionsActivated in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
sourceViewer - the source viewer
state - true if activated

getEditorInput

protected org.eclipse.ui.IEditorInput getEditorInput(org.eclipse.jface.text.source.ISourceViewer sourceViewer)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Returns an editor input for the given source viewer. The method returns null when no input is available, for example when the input for the merge viewer has not been set yet.

Overrides:
getEditorInput in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
sourceViewer - the source viewer to get input for
Returns:
input for the given viewer or null when no input is available

createSourceViewer

protected org.eclipse.jface.text.source.SourceViewer createSourceViewer(org.eclipse.swt.widgets.Composite parent,
                                                                        int textOrientation)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Creates a new source viewer. This method is called when creating and initializing the content areas of the merge viewer (see TextMergeViewer.createControls(Composite)). It is called three times for each text part of the comparison: ancestor, left, right. Clients may implement to provide their own type of source viewers. The viewer is not expected to be configured with a source viewer configuration.

Overrides:
createSourceViewer in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
parent - the parent of the viewer's control
textOrientation - style constant bit for text orientation
Returns:
Default implementation returns an instance of SourceViewer.

createMergeEditor

protected DefaultMergeEditor createMergeEditor()

getSite

protected org.eclipse.ui.IWorkbenchPartSite getSite()

isEditorBacked

protected boolean isEditorBacked(org.eclipse.jface.text.ITextViewer textViewer)
Description copied from class: org.eclipse.compare.contentmergeviewer.TextMergeViewer
Tells whether the given text viewer is backed by an editor.

Overrides:
isEditorBacked in class org.eclipse.compare.contentmergeviewer.TextMergeViewer
Parameters:
textViewer - the text viewer to check
Returns:
true if the viewer is backed by an editor

getEditor

protected DefaultMergeEditor getEditor(org.eclipse.jface.text.source.ISourceViewer sourceViewer)