Class SourceElementLinkingHelper
ISourceElements.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final IInputElementProviderThe input element provider for this linking helper. -
Constructor Summary
ConstructorsConstructorDescriptionSourceElementLinkingHelper(ICommonOutlinePage outlinePage, IInputElementProvider inputElementProvider) Creates a new source element linking helper for the given outline page with the given input element provider. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()protected IContentAdapterReturns the installed content adapter, or aNullContentAdapterif none.protected org.eclipse.jface.viewers.IStructuredSelectiongetLinkedSelection(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.jface.viewers.IStructuredSelectiongetLinkedSelection(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.ui.IEditorPartReturns the editor the outline should be linked to.protected booleanisInEditor(IElement element, org.eclipse.ui.IEditorPart editor) Returns whether the given element is contained in the given editor.protected voidlinkToEditor(org.eclipse.jface.viewers.ISelection selection) Tells to link the given outline selection to the editor.protected voidlinkToEditor(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 final voidlinkToOutline(org.eclipse.jface.viewers.ISelection selection) Tells to link the given editor selection to the outline.Methods inherited from class org.eclipse.handly.ui.outline.OutlineLinkingHelper
activate, getOutlinePage, open, setLinkWithEditor
-
Field Details
-
inputElementProvider
The input element provider for this linking helper.
-
-
Constructor Details
-
SourceElementLinkingHelper
public SourceElementLinkingHelper(ICommonOutlinePage outlinePage, IInputElementProvider inputElementProvider) Creates a new source element linking helper for the given outline page with the given input element provider.- Parameters:
outlinePage- notnullinputElementProvider- an input element provider
-
-
Method Details
-
dispose
public void dispose()- Overrides:
disposein classOutlineLinkingHelper
-
linkToOutline
protected final void linkToOutline(org.eclipse.jface.viewers.ISelection selection) Tells to link the given editor selection to the outline.This implementation does nothing if the given selection is
nullor empty. Otherwise, it schedules a background job to compute and set the new outline selection. The selection is computed usinggetLinkedSelection(ISelection, IProgressMonitor).- Specified by:
linkToOutlinein classOutlineLinkingHelper- Parameters:
selection- the editor selection (may benullor empty)
-
linkToEditor
protected void linkToEditor(org.eclipse.jface.viewers.ISelection selection) Tells to link the given outline selection to the editor.This implementation does nothing if the given selection is
nullor empty. Otherwise, it callsgetTargetEditor()to determine the editor that the outline should be linked to. It then delegates tolinkToEditor(ITextEditor, IStructuredSelection)if the target editor is a text editor. Otherwise, it simply passes the given selection to the editor's selection provider.- Specified by:
linkToEditorin classOutlineLinkingHelper- Parameters:
selection- the outline selection (may benullor empty)
-
linkToEditor
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.This implementation attempts to adapt the selection's first element to an
IElementthrough thecontent adapter. If the adapter element is anISourceElementand is contained in the given editor as computed byisInEditor(IElement, IEditorPart), the identifying range of the source element is selected and revealed in the text editor.- Parameters:
editor- the text editor (nevernull)selection- the outline selection (nevernull, never empty)
-
getLinkedSelection
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.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,nullis returned.- Parameters:
selection- the selection in the editor (nevernull, never empty)monitor- a progress monitor (nevernull). The caller must not rely onIProgressMonitor.done()having been called by the receiver- Returns:
- the outline selection corresponding to the given selection
in the editor, or
null - Throws:
org.eclipse.core.runtime.OperationCanceledException- if this method is canceled
-
getLinkedSelection
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.This implementation finds the smallest
ISourceElementthat 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 thecontent adapter.- Parameters:
selection- the text selection in the editor (nevernull, never empty)monitor- a progress monitor (nevernull). The caller must not rely onIProgressMonitor.done()having been called by the receiver- Returns:
- the outline selection corresponding to the given selection
in the editor, or
null - Throws:
org.eclipse.core.runtime.OperationCanceledException- if this method is canceled
-
getTargetEditor
protected org.eclipse.ui.IEditorPart getTargetEditor()Returns the editor the outline should be linked to.This implementation returns the editor that created the outline page or, if that editor is a multi-page editor, the currently selected editor page.
- Returns:
- the editor the outline should be linked to, or
null
-
isInEditor
Returns whether the given element is contained in the given editor.This implementation uses the
input element providerto obtain anIElementcorresponding to the editor input. It then checks whether theIElementcontainsthe given element and returns the result.- Parameters:
element- may benulleditor- notnull- Returns:
trueif the element is contained in the editor, andfalseotherwise
-
getContentAdapter
Returns the installed content adapter, or aNullContentAdapterif none.This implementation returns the content adapter provided by the outline page, if the outline page is an
IContentAdapterProvider.- Returns:
- an
IContentAdapter(nevernull)
-