public abstract class CallHierarchyViewPart
extends org.eclipse.ui.part.ViewPart
Modifier and Type | Class and Description |
---|---|
protected static class |
CallHierarchyViewPart.HistoryEntry
Represents an entry of the call hierarchy view history list.
|
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
GROUP_FOCUS
Pop-up menu: name of group for focus actions (value
"group.focus" ). |
Constructor and Description |
---|
CallHierarchyViewPart()
Constructs a call hierarchy view that supports all of the
call hierarchy kinds.
|
CallHierarchyViewPart(java.util.EnumSet<CallHierarchyKind> supportedHierarchyKinds)
Constructs a call hierarchy view that supports the given
call hierarchy kinds.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addHistoryDropDownAction(org.eclipse.jface.action.IAction action)
Contributes the 'show history list' action to this view.
|
protected void |
addPinAction(org.eclipse.jface.action.IAction action)
Contributes the 'pin' action to this view.
|
protected void |
addRefreshAction(org.eclipse.jface.action.IAction action)
Contributes the 'refresh' action to this view.
|
protected void |
addSetHierarchyKindAction(org.eclipse.jface.action.IAction action,
CallHierarchyKind kind)
Contributes a 'set hierarchy kind' action to this view.
|
protected void |
addSetOrientationAction(org.eclipse.jface.action.IAction action,
int orientation)
Contributes a 'set orientation' action to this view.
|
boolean |
arePossibleInputElements(java.lang.Object[] elements)
Returns whether the given elements are possible input elements for this view.
|
protected abstract java.lang.String |
computeContentDescription()
Computes the content description for this view.
|
protected void |
configureHierarchyViewer(org.eclipse.jface.viewers.TreeViewer viewer)
Configures the newly created hierarchy viewer.
|
protected void |
configureLocationViewer(org.eclipse.jface.viewers.TableViewer viewer)
Configures the newly created location viewer.
|
protected EditorOpener |
createEditorOpener()
Creates and returns an editor opener for this view.
|
protected abstract ICallHierarchyNode[] |
createHierarchyRoots(java.lang.Object[] inputElements)
Creates and returns the root nodes for a call hierarchy based on the
given input elements and the current hierarchy kind.
|
protected org.eclipse.jface.viewers.TreeViewer |
createHierarchyViewer(org.eclipse.swt.widgets.Composite parent)
Creates and returns a tree viewer control that will be used for
displaying the call hierarchy.
|
protected void |
createHierarchyViewerMenuGroups(org.eclipse.jface.action.IMenuManager manager)
Creates the menu groups for the hierarchy viewer's pop-up menu.
|
protected HistoryDropDownAction<CallHierarchyViewPart.HistoryEntry> |
createHistoryDropDownAction(HistoryDropDownAction.History<CallHierarchyViewPart.HistoryEntry> history)
Creates and returns a 'show history list' action for this view.
|
protected abstract CallHierarchyViewPart.HistoryEntry |
createHistoryEntry(java.lang.Object[] inputElements)
Creates and returns a history entry for the given input elements.
|
protected void |
createLocationColumns(org.eclipse.swt.widgets.Table table)
Creates the table columns in the location viewer.
|
protected org.eclipse.jface.viewers.TableViewer |
createLocationViewer(org.eclipse.swt.widgets.Composite parent)
Creates and returns a table viewer control that will be used for
displaying the call locations.
|
protected void |
createLocationViewerMenuGroups(org.eclipse.jface.action.IMenuManager manager)
Creates the menu groups for the location viewer's pop-up menu.
|
protected org.eclipse.swt.widgets.Control |
createNoHierarchyPage(org.eclipse.swt.widgets.Composite parent)
Creates and returns a control for the 'no hierarchy' page.
|
void |
createPartControl(org.eclipse.swt.widgets.Composite parent) |
protected org.eclipse.swt.custom.SashForm |
createSashForm(org.eclipse.swt.widgets.Composite parent)
Creates and returns a
SashForm that will be used as the parent
control for the hierarchy and location viewers. |
void |
dispose() |
protected void |
doRefresh(IContext context)
Refreshes the content of this view according to options specified in
the given context.
|
protected void |
fillHierarchyViewerMenu(org.eclipse.jface.action.IMenuManager manager)
Fills the pop-menu for the hierarchy viewer using the menu groups
created by
createHierarchyViewerMenuGroups(IMenuManager) . |
protected void |
fillLocationViewerMenu(org.eclipse.jface.action.IMenuManager manager)
Fills the pop-menu for the location viewer using the menu groups
created by
createLocationViewerMenuGroups(IMenuManager) . |
protected EditorOpener |
getEditorOpener()
Returns the editor opener used by this view.
|
protected org.eclipse.jface.action.IAction |
getFocusOnSelectionAction()
Returns the 'focus on selection' action used by this view.
|
protected org.eclipse.jface.viewers.ViewerComparator |
getHierarchyComparator()
Returns a comparator for the hierarchy viewer.
|
CallHierarchyKind |
getHierarchyKind()
Returns the current hierarchy kind for this view.
|
protected ICallHierarchyNode[] |
getHierarchyRoots()
Returns the root nodes for the current call hierarchy.
|
protected org.eclipse.jface.viewers.TreeViewer |
getHierarchyViewer()
Returns the hierarchy tree viewer.
|
protected java.util.List<CallHierarchyViewPart.HistoryEntry> |
getHistory()
Returns the history used by this view; the history is represented by
a "live" list of history entries.
|
java.lang.Object[] |
getInputElements()
Returns the current input elements for this view.
|
protected ColumnDescription[] |
getLocationColumnDescriptions()
Returns the column descriptions for the call location table.
|
protected org.eclipse.jface.viewers.TableViewer |
getLocationViewer()
Returns the location table viewer.
|
protected org.eclipse.jface.action.IAction |
getRefreshElementAction()
Returns the 'refresh element' action used by this view.
|
protected org.eclipse.jface.action.IAction |
getRemoveFromViewAction()
Returns the 'remove from view' action used by this view.
|
protected org.eclipse.swt.custom.SashForm |
getSashForm()
Returns the parent
SashForm for the hierarchy and location
viewers. |
protected abstract CallHierarchyViewManager |
getViewManager()
Returns a
CallHierarchyViewManager for this view. |
protected void |
handleCannotRevealCallLocation(org.eclipse.ui.IEditorPart editor,
ICallLocation callLocation,
IContext context)
Handles the case when a call location cannot be revealed in the editor.
|
protected void |
hierarchySelectionChanged(org.eclipse.jface.viewers.ISelection selection)
This method is called on each selection change in the hierarchy viewer.
|
protected void |
historyUpdated()
A callback that is invoked when the history has been updated.
|
void |
init(org.eclipse.ui.IViewSite site,
org.eclipse.ui.IMemento memento) |
boolean |
isPinned()
Returns whether this view is pinned.
|
protected abstract boolean |
isPossibleInputElement(java.lang.Object element)
Returns whether the given element is a possible input element for this view.
|
protected void |
locationSelectionChanged(org.eclipse.jface.viewers.ISelection selection)
This method is called on each selection change in the location viewer.
|
protected void |
notifyHistoryUpdated()
Notifies that the history has been updated by this view.
|
void |
refresh()
Performs a full refresh of the content of this view.
|
protected void |
refresh(IContext context)
Performs a refresh of the content of this view according to options
specified in the given context.
|
protected void |
revealCallLocation(org.eclipse.ui.IEditorPart editor,
ICallLocation callLocation,
IContext context)
Attempts to reveal the given call location in the given editor.
|
protected void |
revealInEditor(java.lang.Object element,
boolean activate,
boolean mayOpenNewEditor)
Reveals the given element in an appropriate editor on a best effort basis.
|
void |
saveState(org.eclipse.ui.IMemento memento) |
void |
setFocus() |
void |
setHierarchyKind(CallHierarchyKind kind)
Sets the current hierarchy kind for this view.
|
void |
setInputElements(java.lang.Object[] elements)
Sets the current input elements for this view.
|
void |
setOrientation(int orientation)
Sets the orientation of this view, which may be one of the constants
SWT.HORIZONTAL or SWT.VERTICAL ; this method may also
be called with SWT.HORIZONTAL|SWT.VERTICAL for automatic
orientation. |
void |
setPinned(boolean pinned)
Marks this view as pinned.
|
boolean |
supportsHierarchyKind(CallHierarchyKind kind)
Returns whether this view supports the given hierarchy kind.
|
protected void |
updateStatusLine(org.eclipse.jface.action.IStatusLineManager manager,
org.eclipse.jface.viewers.IStructuredSelection selection)
Updates the status line based on the given selection in this view.
|
checkSite, getViewSite, init, setContentDescription, setInitializationData, setPartName
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected static final java.lang.String GROUP_FOCUS
"group.focus"
).public CallHierarchyViewPart()
CallHierarchyKind
,
CallHierarchyViewPart(EnumSet)
public CallHierarchyViewPart(java.util.EnumSet<CallHierarchyKind> supportedHierarchyKinds)
supportedHierarchyKinds
- not null
and not emptypublic final boolean arePossibleInputElements(java.lang.Object[] elements)
isPossibleInputElement(Object)
for each of
the given elements until false
is returned for an element
(in which case this method will return false
) or all elements
have been checked (in which case it will return true
).elements
- may be null
or may contain null elements,
in which case false
will be returned; may be empty,
in which case true
will be returnedtrue
if the given elements are possible input elements
for this view, and false
otherwiseprotected abstract boolean isPossibleInputElement(java.lang.Object element)
element
- may be null
, in which case false
will be returnedtrue
if the given element is a possible input element
for this view, and false
otherwisearePossibleInputElements(Object[])
public void setInputElements(java.lang.Object[] elements)
Default implementation invokes refresh()
after the input elements
have been set.
elements
- not null
, must not contain null elements;
may be emptyjava.lang.IllegalArgumentException
- if arePossibleInputElements(Object[])
returns false
for the given elementspublic final java.lang.Object[] getInputElements()
null
,
may be empty). Clients must not modify the returned array.public final CallHierarchyKind getHierarchyKind()
null
)setHierarchyKind(CallHierarchyKind)
public void setHierarchyKind(CallHierarchyKind kind)
Default implementation invokes refresh()
if the view
hierarchy kind has changed; it also adjusts the checked state of the
'set hierarchy kind' actions accordingly.
kind
- not null
java.lang.IllegalArgumentException
- if the given kind is not supported
by this viewpublic final boolean supportsHierarchyKind(CallHierarchyKind kind)
kind
- may be null
, in which case false
will be returnedtrue
if this view supports the given kind,
and false
otherwisepublic void setOrientation(int orientation)
SWT.HORIZONTAL
or SWT.VERTICAL
; this method may also
be called with SWT.HORIZONTAL|SWT.VERTICAL
for automatic
orientation.orientation
- new orientationjava.lang.IllegalArgumentException
- if the value of orientation is invalidpublic void setPinned(boolean pinned)
pinned
- whether the view is pinnedpublic final boolean isPinned()
true
if the view is pinned,
and false
otherwisepublic final void refresh()
refresh(IContext)
with an empty context.protected final void refresh(IContext context)
doRefresh(IContext)
.context
- the operation context (never null
)public void init(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento) throws org.eclipse.ui.PartInitException
init
in interface org.eclipse.ui.IViewPart
init
in class org.eclipse.ui.part.ViewPart
org.eclipse.ui.PartInitException
public void saveState(org.eclipse.ui.IMemento memento)
saveState
in interface org.eclipse.ui.IPersistable
saveState
in interface org.eclipse.ui.IViewPart
saveState
in class org.eclipse.ui.part.ViewPart
public void createPartControl(org.eclipse.swt.widgets.Composite parent)
createPartControl
in interface org.eclipse.ui.IWorkbenchPart
createPartControl
in class org.eclipse.ui.part.WorkbenchPart
public void dispose()
dispose
in interface org.eclipse.ui.IWorkbenchPart
dispose
in class org.eclipse.ui.part.WorkbenchPart
public void setFocus()
setFocus
in interface org.eclipse.ui.IWorkbenchPart
setFocus
in class org.eclipse.ui.part.WorkbenchPart
protected abstract CallHierarchyViewManager getViewManager()
CallHierarchyViewManager
for this view.
The same manager instance is returned for each call.null
)protected ICallHierarchyNode[] getHierarchyRoots()
Default implementation invokes createHierarchyRoots(Object[])
with the current input elements.
null
, may be empty)protected abstract ICallHierarchyNode[] createHierarchyRoots(java.lang.Object[] inputElements)
inputElements
- never null
, may be emptynull
, may be empty)protected org.eclipse.jface.viewers.ViewerComparator getHierarchyComparator()
Default implementation returns a LabelComparator
if the current
hierarchy kind is CallHierarchyKind.CALLER
, and null
otherwise.
ViewerComparator
, or null
for no sortingprotected abstract java.lang.String computeContentDescription()
null
)WorkbenchPart.getContentDescription()
protected void updateStatusLine(org.eclipse.jface.action.IStatusLineManager manager, org.eclipse.jface.viewers.IStructuredSelection selection)
Default implementation clears the status line message if the selection is empty or if exactly one element is selected; sets a generic message of the form "(x) items selected" otherwise. It always clears the error message.
manager
- the status line manager (never null
)selection
- the current selection (never null
)protected void doRefresh(IContext context)
context
- the operation context (never null
)protected org.eclipse.swt.widgets.Control createNoHierarchyPage(org.eclipse.swt.widgets.Composite parent)
Default implementation returns a Label
telling,
in general terms, that there is no call hierarchy to display.
Subclasses may override this method (e.g., to give details
on what the user needs to do to display a call hierarchy).
parent
- the parent composite (never null
)null
)protected final org.eclipse.swt.custom.SashForm getSashForm()
SashForm
for the hierarchy and location
viewers.SashForm
,
or null
if it has yet to be createdcreateSashForm(Composite)
protected org.eclipse.swt.custom.SashForm createSashForm(org.eclipse.swt.widgets.Composite parent)
SashForm
that will be used as the parent
control for the hierarchy and location viewers. This method only creates
the control; it does not configure it. This method is called once,
when the part's control is created.parent
- the parent composite (never null
)null
)protected final org.eclipse.jface.viewers.TreeViewer getHierarchyViewer()
null
if it has yet to be createdcreateHierarchyViewer(Composite)
protected org.eclipse.jface.viewers.TreeViewer createHierarchyViewer(org.eclipse.swt.widgets.Composite parent)
parent
- the parent composite (never null
)null
)configureHierarchyViewer(TreeViewer)
protected void configureHierarchyViewer(org.eclipse.jface.viewers.TreeViewer viewer)
Default implementation sets a CallHierarchyContentProvider
as the content provider, and a CallHierarchyLabelProvider
backed by a WorkbenchLabelProvider
as the label provider.
Subclasses usually need to extend this method and replace the default
label provider; they may also override this method completely, but
there is usually no need to.
viewer
- the viewer to configure (never null
)protected void createHierarchyViewerMenuGroups(org.eclipse.jface.action.IMenuManager manager)
fillHierarchyViewerMenu(IMenuManager)
is called.
Default implementation adds groups named GROUP_FOCUS
and
IWorkbenchActionConstants.MB_ADDITIONS
. Subclasses may extend
or override this method, but should usually keep the default groups.
manager
- the menu manager (never null
)protected void fillHierarchyViewerMenu(org.eclipse.jface.action.IMenuManager manager)
createHierarchyViewerMenuGroups(IMenuManager)
.
This method is called each time the pop-up menu is about to show.
Default implementation adds generic actions such as 'focus on selection', 'refresh element', and 'remove from view'. Subclasses may extend or override this method.
manager
- the menu manager (never null
)protected void hierarchySelectionChanged(org.eclipse.jface.viewers.ISelection selection)
Default implementation changes the input of the location viewer
accordingly and tries to reveal the selected hierarchy node in an
open editor with revealInEditor
. Subclasses may extend or even override this method,
but there is usually no need to.
selection
- the new selection (never null
)protected final org.eclipse.jface.viewers.TableViewer getLocationViewer()
null
if it has yet to be createdcreateLocationViewer(Composite)
protected org.eclipse.jface.viewers.TableViewer createLocationViewer(org.eclipse.swt.widgets.Composite parent)
parent
- the parent composite (never null
)null
)configureLocationViewer(TableViewer)
protected void configureLocationViewer(org.eclipse.jface.viewers.TableViewer viewer)
Default implementation sets an ArrayContentProvider
as the
content provider, and a LocationTableLabelProvider
as the
label provider. Also, it invokes createLocationColumns(Table)
.
Subclasses may extend or even override this method, but there is
usually no need to.
viewer
- the viewer to configure (never null
)protected void createLocationColumns(org.eclipse.swt.widgets.Table table)
Default implementation creates the columns based on descriptions
returned by getLocationColumnDescriptions()
. Subclasses
may override this method, but there is usually no need to.
table
- the table to create columns in (never null
)protected ColumnDescription[] getLocationColumnDescriptions()
Default implementation returns descriptions for the 'icon' column, the 'line number' column, and the 'call info' column. Subclasses may override this method, but there is usually no need to.
null
)protected void createLocationViewerMenuGroups(org.eclipse.jface.action.IMenuManager manager)
fillLocationViewerMenu(IMenuManager)
is called.
Default implementation adds a group named IWorkbenchActionConstants.MB_ADDITIONS
. Subclasses may extend
or override this method.
manager
- the menu manager (never null
)protected void fillLocationViewerMenu(org.eclipse.jface.action.IMenuManager manager)
createLocationViewerMenuGroups(IMenuManager)
.
This method is called each time the pop-up menu is about to show.
Default implementation does nothing. Subclasses may extend or override this method.
manager
- the menu manager (never null
)protected void locationSelectionChanged(org.eclipse.jface.viewers.ISelection selection)
Default implementation tries to reveal the selected call location in an
open editor with revealInEditor
. Subclasses may extend or even override this method,
but there is usually no need to.
selection
- the new selection (never null
)protected void revealInEditor(java.lang.Object element, boolean activate, boolean mayOpenNewEditor) throws org.eclipse.ui.PartInitException
Default implementation uses the editor opener
and specifically supports revealing an ICallLocation
and an ICallHierarchyNode
(other elements
are handled generically). To reveal a call location in an open
editor, it invokes revealCallLocation
.
element
- not null
activate
- whether to activate the editormayOpenNewEditor
- whether a new editor may be opened
when the element cannot be revealed in an existing editororg.eclipse.ui.PartInitException
- if a new editor could not be created
or initializedprotected void revealCallLocation(org.eclipse.ui.IEditorPart editor, ICallLocation callLocation, IContext context)
Default implementation uses the editor utility
of the editor opener
for revealing the call range in the given editor and invokes handleCannotRevealCallLocation
if the call location cannot be revealed
for whatever reason.
editor
- never null
callLocation
- never null
context
- never null
protected void handleCannotRevealCallLocation(org.eclipse.ui.IEditorPart editor, ICallLocation callLocation, IContext context)
Default implementation displays a generic error message on the status line and attempts to reveal the caller element in the given editor.
editor
- never null
callLocation
- never null
context
- never null
protected final EditorOpener getEditorOpener()
null
if it has yet to be createdcreateEditorOpener()
protected EditorOpener createEditorOpener()
Subclasses may override this method if they require a specific editor opener.
null
)protected final org.eclipse.jface.action.IAction getFocusOnSelectionAction()
protected final org.eclipse.jface.action.IAction getRefreshElementAction()
protected final org.eclipse.jface.action.IAction getRemoveFromViewAction()
protected void addRefreshAction(org.eclipse.jface.action.IAction action)
Default implementation adds the given action to the view tool bar. Subclasses may extend or override this method.
action
- the 'refresh' action (never null
)protected void addSetHierarchyKindAction(org.eclipse.jface.action.IAction action, CallHierarchyKind kind)
Default implementation adds the given action to the view tool bar as well as to the view menu. Subclasses may extend or override this method.
action
- a 'set hierarchy kind' action
(never null
)kind
- the hierarchy kind set by the given action
(never null
)protected void addSetOrientationAction(org.eclipse.jface.action.IAction action, int orientation)
Default implementation adds the given action to the 'Layout' sub-menu of the view menu. The sub-menu is created if necessary. Subclasses may extend or override this method.
action
- a 'set orientation' action
(never null
)orientation
- the orientation set by the given actionprotected HistoryDropDownAction<CallHierarchyViewPart.HistoryEntry> createHistoryDropDownAction(HistoryDropDownAction.History<CallHierarchyViewPart.HistoryEntry> history)
Subclasses need to override this method if they extend
HistoryDropDownAction
.
history
- never null
null
)protected void addHistoryDropDownAction(org.eclipse.jface.action.IAction action)
Default implementation adds the given action to the view tool bar. Subclasses may extend or override this method.
action
- the 'show history list' action (never null
)protected void addPinAction(org.eclipse.jface.action.IAction action)
Default implementation adds the given action to the view tool bar. Subclasses may extend or override this method.
action
- the 'pin' action (never null
)protected java.util.List<CallHierarchyViewPart.HistoryEntry> getHistory()
Default implementation returns a history that is shared between all
views managed by the same view manager
.
null
)protected abstract CallHierarchyViewPart.HistoryEntry createHistoryEntry(java.lang.Object[] inputElements)
inputElements
- never null
; never emptynull
)protected void notifyHistoryUpdated()
Default implementation calls historyUpdated()
for each view
managed by the same view manager
.
getHistory()
protected void historyUpdated()
Default implementation sets the enabled state of the 'show history list' action according to whether the history is empty and, if the history is empty, clears the view input.
getHistory()
,
notifyHistoryUpdated()
Copyright (c) 2014, 2019 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0