public class SourceElementLinkingHelper extends OutlineLinkingHelper
ISourceElement
.Modifier and Type | Field and Description |
---|---|
protected IInputElementProvider |
inputElementProvider |
Constructor and Description |
---|
SourceElementLinkingHelper(ICommonOutlinePage outlinePage,
IInputElementProvider inputElementProvider)
Creates a new linking helper for the given outline page
that is based on
ISourceElement . |
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) |
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, setLinkWithEditor
protected final IInputElementProvider inputElementProvider
public SourceElementLinkingHelper(ICommonOutlinePage outlinePage, IInputElementProvider inputElementProvider)
ISourceElement
.outlinePage
- not null
inputElementProvider
- the input element providerpublic void dispose()
dispose
in class OutlineLinkingHelper
protected final void linkToOutline(org.eclipse.jface.viewers.ISelection selection)
OutlineLinkingHelper
linkToOutline
in class OutlineLinkingHelper
selection
- the editor selection
(may be null
or empty)protected void linkToEditor(org.eclipse.jface.viewers.ISelection selection)
linkToEditor
in class org.eclipse.ui.OpenAndLinkWithEditorHelper
protected void linkToEditor(org.eclipse.ui.texteditor.ITextEditor editor, org.eclipse.jface.viewers.IStructuredSelection selection)
Default implementation selects and reveals the identifying range of
the selection's first element in the text editor. Does nothing
if the first element is not an ISourceElement
contained
in the given editor or if the identifying range is not set.
If the content adapter
is installed,
the element is first adapted to IElement
.
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)
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 receivernull
org.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)
Default implementation returns the selection consisting of the smallest
ISourceElement
that includes the offset of the given selection,
or null
if none. If the content adapter
is installed, it will be used to adapt the element
before it is returned in the selection.
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 receivernull
org.eclipse.core.runtime.OperationCanceledException
- if this method is canceledprotected org.eclipse.ui.IEditorPart getTargetEditor()
Default implementation returns the editor that created the outline page or, if that editor is a multi-page editor, the currently selected editor page.
protected boolean isInEditor(IElement element, org.eclipse.ui.IEditorPart editor)
Default implementation checks whether the element corresponding to the input for the given editor contains the given element.
element
- may be null
editor
- not null
true
if the element is contained in the editor;
false
otherwiseprotected IContentAdapter getContentAdapter()
NullContentAdapter
if none.IContentAdapter
(never null
)