public class SourceElementLinkingHelper extends OutlineLinkingHelper
ISourceElements.| Modifier and Type | Field and Description |
|---|---|
protected IInputElementProvider |
inputElementProvider
The input element provider for this linking helper.
|
| Constructor and Description |
|---|
SourceElementLinkingHelper(ICommonOutlinePage outlinePage,
IInputElementProvider inputElementProvider)
Creates a new source element linking helper for the given outline page
with the given input element provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose() |
protected IContentAdapter |
getContentAdapter()
Returns the installed content adapter, or a
NullContentAdapter
if none. |
protected org.eclipse.jface.viewers.IStructuredSelection |
getLinkedSelection(org.eclipse.jface.viewers.ISelection selection,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the outline selection corresponding to the given selection
in the editor.
|
protected org.eclipse.jface.viewers.IStructuredSelection |
getLinkedSelection(org.eclipse.jface.text.ITextSelection selection,
org.eclipse.core.runtime.IProgressMonitor monitor)
Returns the outline selection corresponding to the given text selection
in the editor.
|
protected org.eclipse.ui.IEditorPart |
getTargetEditor()
Returns the editor the outline should be linked to.
|
protected boolean |
isInEditor(IElement element,
org.eclipse.ui.IEditorPart editor)
Returns whether the given element is contained in the given editor.
|
protected void |
linkToEditor(org.eclipse.jface.viewers.ISelection selection)
Tells to link the given outline selection to the editor.
|
protected void |
linkToEditor(org.eclipse.ui.texteditor.ITextEditor editor,
org.eclipse.jface.viewers.IStructuredSelection selection)
Tells to link the given outline selection to the given text editor.
|
protected void |
linkToOutline(org.eclipse.jface.viewers.ISelection selection)
Tells to link the given editor selection to the outline.
|
activate, getOutlinePage, open, setLinkWithEditorprotected final IInputElementProvider inputElementProvider
public SourceElementLinkingHelper(ICommonOutlinePage outlinePage, IInputElementProvider inputElementProvider)
outlinePage - not nullinputElementProvider - an input element providerpublic void dispose()
dispose in class OutlineLinkingHelperprotected final void linkToOutline(org.eclipse.jface.viewers.ISelection selection)
This implementation does nothing if the given selection is null
or empty. Otherwise, it schedules a background job to compute and set
the new outline selection. The selection is computed using getLinkedSelection(ISelection, IProgressMonitor).
linkToOutline in class OutlineLinkingHelperselection - the editor selection
(may be null or empty)protected void linkToEditor(org.eclipse.jface.viewers.ISelection selection)
This implementation does nothing if the given selection is null
or empty. Otherwise, it calls getTargetEditor() to determine
the editor that the outline should be linked to. It then delegates to
linkToEditor(ITextEditor, IStructuredSelection) if the
target editor is a text editor. Otherwise, it simply passes the
given selection to the editor's selection provider.
linkToEditor in class OutlineLinkingHelperselection - the outline selection
(may be null or empty)protected void linkToEditor(org.eclipse.ui.texteditor.ITextEditor editor,
org.eclipse.jface.viewers.IStructuredSelection selection)
This implementation attempts to adapt the selection's first element to an
IElement through the content adapter.
If the adapter element is an ISourceElement and is contained in
the given editor as computed by isInEditor(IElement, IEditorPart),
the identifying range of the source element is selected and revealed
in the text editor.
editor - the text editor (never null)selection - the outline selection (never null,
never empty)protected org.eclipse.jface.viewers.IStructuredSelection getLinkedSelection(org.eclipse.jface.viewers.ISelection selection,
org.eclipse.core.runtime.IProgressMonitor monitor)
This implementation delegates to getLinkedSelection(ITextSelection,
IProgressMonitor) if the given selection is a text selection. If the
given selection is a structured selection, it is returned unchanged.
Otherwise, null is returned.
selection - the selection in the editor
(never null, never empty)monitor - a progress monitor (never null).
The caller must not rely on IProgressMonitor.done()
having been called by the receivernullorg.eclipse.core.runtime.OperationCanceledException - if this method is canceledprotected org.eclipse.jface.viewers.IStructuredSelection getLinkedSelection(org.eclipse.jface.text.ITextSelection selection,
org.eclipse.core.runtime.IProgressMonitor monitor)
This implementation finds the smallest ISourceElement that
includes the offset of the given selection and returns a selection
containing a single outline element corresponding to the found
source element, as determined by the content adapter.
selection - the text selection in the editor
(never null, never empty)monitor - a progress monitor (never null).
The caller must not rely on IProgressMonitor.done()
having been called by the receivernullorg.eclipse.core.runtime.OperationCanceledException - if this method is canceledprotected org.eclipse.ui.IEditorPart getTargetEditor()
This implementation returns the editor that created the outline page or, if that editor is a multi-page editor, the currently selected editor page.
nullprotected boolean isInEditor(IElement element, org.eclipse.ui.IEditorPart editor)
This implementation uses the input element provider to obtain an IElement corresponding to
the editor input. It then checks whether the IElement
contains the given
element and returns the result.
element - may be nulleditor - not nulltrue if the element is contained in the editor,
and false otherwiseprotected IContentAdapter getContentAdapter()
NullContentAdapter
if none.
This implementation returns the content adapter provided by the
outline page, if the outline page is an IContentAdapterProvider.
IContentAdapter (never null)Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0