public abstract class CallHierarchyViewPart
extends org.eclipse.ui.part.ViewPart
Modifier and Type | Class and Description |
---|---|
protected class |
CallHierarchyViewPart.FocusOnSelectionAction
Default implementation of the 'focus on selection' action.
|
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 |
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 |
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 CallHierarchyViewPart.FocusOnSelectionAction |
createFocusOnSelectionAction()
Creates and returns a 'focus on selection' action for this view.
|
protected abstract ICallHierarchy |
createHierarchy()
Returns a new call hierarchy object based on the input elements and
current hierarchy kind for this view.
|
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 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. |
protected void |
fillHierarchyViewerMenu(org.eclipse.jface.action.IMenuManager manager)
Fills the pop-menu for the hierarchy viewer using the menu groups
created in
createHierarchyViewerMenuGroups(IMenuManager) . |
protected void |
fillLocationViewerMenu(org.eclipse.jface.action.IMenuManager manager)
Fills the pop-menu for the location viewer using the menu groups
created in
createLocationViewerMenuGroups(IMenuManager) . |
protected EditorOpener |
getEditorOpener()
Returns the editor opener used by this view.
|
protected CallHierarchyViewPart.FocusOnSelectionAction |
getFocusOnSelectionAction()
Returns the 'focus on selection' action used by this view.
|
protected org.eclipse.jface.viewers.ViewerComparator |
getHierarchyComparator(ICallHierarchy hierarchy)
Given a call hierarchy, returns a comparator for the hierarchy viewer.
|
CallHierarchyKind |
getHierarchyKind()
Returns the current hierarchy kind for this view.
|
protected org.eclipse.jface.viewers.TreeViewer |
getHierarchyViewer()
Returns the hierarchy tree viewer.
|
java.lang.Object[] |
getInputElements()
Returns the input elements that have been set 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.swt.custom.SashForm |
getSashForm()
Returns the parent
SashForm for the hierarchy and location
viewers. |
protected void |
hierarchySelectionChanged(org.eclipse.jface.viewers.ISelection selection)
This method is called on each selection change in the hierarchy viewer.
|
void |
init(org.eclipse.ui.IViewSite site,
org.eclipse.ui.IMemento memento) |
protected void |
locationSelectionChanged(org.eclipse.jface.viewers.ISelection selection)
This method is called on each selection change in the location viewer.
|
void |
refresh()
Performs a full refresh of the content of this view.
|
protected void |
revealInEditor(java.lang.Object element,
boolean activate,
boolean mayOpenNewEditor)
Reveals the given element in an editor on a best effort basis.
|
void |
saveState(org.eclipse.ui.IMemento memento) |
void |
setFocus() |
protected void |
setHierarchy(ICallHierarchy hierarchy)
Sets the call hierarchy to be shown by this view.
|
void |
setHierarchyKind(CallHierarchyKind kind)
Sets the current hierarchy kind for this view.
|
void |
setInputElements(java.lang.Object[] elements)
Sets the input elements for this view.
|
boolean |
supportsHierarchyKind(CallHierarchyKind kind)
Returns whether this view supports the given hierarchy kind.
|
checkSite, getViewSite, init, setContentDescription, setInitializationData, setPartName
addPartPropertyListener, addPropertyListener, dispose, 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 void setInputElements(java.lang.Object[] elements)
Subclasses may impose additional restrictions on what elements
may be used as the input elements. Default implementation invokes
refresh()
after the input elements have been set.
elements
- not null
, must not contain null elementsjava.lang.IllegalArgumentException
- if some property of an element
prevents it from being used as an input elementpublic final java.lang.Object[] getInputElements()
null
if the input elements
have not been setsetInputElements(Object[])
public final CallHierarchyKind getHierarchyKind()
null
)setHierarchyKind(CallHierarchyKind)
public void setHierarchyKind(CallHierarchyKind kind)
Default implementation invokes refresh()
if the current
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 refresh()
Default implementation does nothing if the input elements have not
been set for this view or if the view has been disposed. Otherwise,
it invokes createHierarchy()
followed by setHierarchy(ICallHierarchy)
.
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 setFocus()
setFocus
in interface org.eclipse.ui.IWorkbenchPart
setFocus
in class org.eclipse.ui.part.WorkbenchPart
protected abstract ICallHierarchy createHierarchy()
null
)getInputElements()
,
getHierarchyKind()
protected void setHierarchy(ICallHierarchy hierarchy)
An implementation of this method should initialize the view content accordingly.
hierarchy
- the call hierarchy to show (never null
)protected org.eclipse.jface.viewers.ViewerComparator getHierarchyComparator(ICallHierarchy hierarchy)
Default implementation returns a LabelComparator
if the
hierarchy's kind is CallHierarchyKind.CALLER
, and null
otherwise.
hierarchy
- never null
ViewerComparator
, or null
for no sortingprotected 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 appends the 'focus on selection' action to the focus group. 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. 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. 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).
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 opening the new editor failedprotected 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 CallHierarchyViewPart.FocusOnSelectionAction getFocusOnSelectionAction()
null
if it has yet to be createdcreateFocusOnSelectionAction()
protected CallHierarchyViewPart.FocusOnSelectionAction createFocusOnSelectionAction()
Subclasses need to override this method if they extend
CallHierarchyViewPart.FocusOnSelectionAction
.
null
)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
)Copyright (c) 2014, 2018 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0