Class TypeHierarchyViewPart
- All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable
,org.eclipse.core.runtime.IExecutableExtension
,org.eclipse.ui.IPersistable
,org.eclipse.ui.IViewPart
,org.eclipse.ui.IWorkbenchPart
,org.eclipse.ui.IWorkbenchPart2
,org.eclipse.ui.IWorkbenchPart3
,org.eclipse.ui.part.IWorkbenchPartOrientation
- Since:
- 1.6
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Represents an entry of the type hierarchy view history list.protected class
Helper for opening editors on the viewer's selection. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Pop-up menu: name of group for focus actions (value"group.focus"
).Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
-
Constructor Summary
ConstructorDescriptionConstructs a type hierarchy view that supports all of the type hierarchy kinds.TypeHierarchyViewPart
(Set<TypeHierarchyKind> supportedHierarchyKinds) Constructs a type hierarchy view that supports the given type hierarchy kinds. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addHistoryDropDownAction
(org.eclipse.jface.action.IAction action) Contributes the 'show history list' 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, TypeHierarchyKind kind) Contributes a 'set hierarchy kind' action to this view.protected void
addSetLayoutModeAction
(org.eclipse.jface.action.IAction action, int layoutMode) Contributes a 'set layout mode' action to this view.boolean
arePossibleInputElements
(Object[] elements) Returns whether the given elements are possible input elements for this view.protected abstract String
Computes the content description for this view.protected abstract void
configureHierarchyViewer
(org.eclipse.jface.viewers.TreeViewer viewer, TypeHierarchyKind kind) Configures the newly created hierarchy viewer for the given hierarchy kind.protected EditorOpener
Creates and returns an editor opener for this view.protected org.eclipse.jface.viewers.TreeViewer
createHierarchyViewer
(org.eclipse.swt.widgets.Composite parent, TypeHierarchyKind kind) Creates and returns a tree viewer that will be used for displaying the type hierarchy of the given kind.protected void
createHierarchyViewerMenuGroups
(org.eclipse.jface.action.IMenuManager manager, TypeHierarchyKind kind) Creates the menu groups for the pop-up menu of the hierarchy viewer of the given hierarchy kind.createHistoryDropDownAction
(HistoryDropDownAction.History<TypeHierarchyViewPart.HistoryEntry> history) Creates and returns a 'show history list' action for this view.protected abstract TypeHierarchyViewPart.HistoryEntry
createHistoryEntry
(Object[] inputElements) Creates and returns a history entry for the given input elements.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) void
dispose()
protected void
fillHierarchyViewerMenu
(org.eclipse.jface.action.IMenuManager manager, TypeHierarchyKind kind) Fills the pop-menu for the hierarchy viewer for the given hierarchy kind using the menu groups created bycreateHierarchyViewerMenuGroups(org.eclipse.jface.action.IMenuManager, org.eclipse.handly.ui.typehierarchy.TypeHierarchyKind)
.protected final EditorOpener
Returns the editor opener used by this view.protected final org.eclipse.jface.action.IAction
Returns the 'focus on selection' action used by this view.final TypeHierarchyKind
Returns the current hierarchy kind for this view.protected final org.eclipse.jface.viewers.TreeViewer
Returns the hierarchy tree viewer for the given hierarchy kind.protected List<TypeHierarchyViewPart.HistoryEntry>
Returns the history used by this view; the history is represented by a "live" list of history entries.final Object[]
Returns the current input elements for this view.final int
Returns the current layout mode for this view.protected final org.eclipse.swt.custom.SashForm
Returns theSashForm
created for this view.protected final Set<TypeHierarchyKind>
Returns a set of the supported hierarchy kinds for this view.void
init
(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento) final boolean
Returns whether the given hierarchy kind is currently enabled for this view.protected final boolean
isOpen()
Returns whether the view has already been opened and has not yet been closed.protected abstract boolean
isPossibleInputElement
(Object element) Returns whether the given element is a possible input element for this view.protected void
onEnabledHierarchyKindsChanged
(Set<TypeHierarchyKind> oldKinds, Set<TypeHierarchyKind> newKinds) A callback that is invoked when the set of enabled hierarchy kinds changes.protected void
onHierarchyKindChanged
(TypeHierarchyKind oldKind, TypeHierarchyKind newKind) A callback that is invoked when the current hierarchy kind changes.protected void
onHierarchySelectionChanged
(org.eclipse.jface.viewers.ISelection selection, TypeHierarchyKind kind) A callback that is invoked when selection changes in the hierarchy viewer for the given hierarchy kind.protected void
A callback that is invoked when the history has been updated.protected void
onInputElementsChanged
(Object[] oldInputElements, Object[] newInputElements) A callback that is invoked when the view input elements change.protected void
onLayoutModeChanged
(int oldLayoutMode, int newLayoutMode) A callback that is invoked when the view layout mode changes.final void
refresh()
Performs a full refresh of the content of this view.protected void
Performs a refresh of the content of this view according to options specified in the given context.protected void
revealInEditor
(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) protected void
Sets the enabled hierarchy kinds for this view.void
setFocus()
void
Sets the current hierarchy kind for this view.protected void
setHierarchyViewerInput
(org.eclipse.jface.viewers.TreeViewer viewer, TypeHierarchyKind kind) Sets the input for the hierarchy viewer for the given hierarchy kind.void
setInputElements
(Object[] elements) Sets the current input elements for this view.void
setLayoutMode
(int layoutMode) Sets layout mode for this view, which may be one of the constantsSWT.HORIZONTAL
orSWT.VERTICAL
; this method may also be called withSWT.HORIZONTAL|SWT.VERTICAL
for automatic layout orSWT.NONE
for hierarchy-only layout.boolean
supportsLayoutMode
(int layoutMode) Returnstrue
if the given value represents a supported layout mode for this view, andfalse
otherwise.protected void
Ensures that the appropriate hierarchy page is shown by this view.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.Methods inherited from class org.eclipse.ui.part.ViewPart
checkSite, getViewSite, init, setContentDescription, setInitializationData, setPartName
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
-
Field Details
-
GROUP_FOCUS
Pop-up menu: name of group for focus actions (value"group.focus"
).- See Also:
-
-
Constructor Details
-
TypeHierarchyViewPart
public TypeHierarchyViewPart()Constructs a type hierarchy view that supports all of the type hierarchy kinds.- See Also:
-
TypeHierarchyViewPart
Constructs a type hierarchy view that supports the given type hierarchy kinds. Clients must not modify the given set afterwards.- Parameters:
supportedHierarchyKinds
- notnull
and not empty
-
-
Method Details
-
arePossibleInputElements
Returns whether the given elements are possible input elements for this view.Default implementation invokes
isPossibleInputElement(Object)
for each of the given elements untilfalse
is returned for an element (in which case this method will returnfalse
) or all elements have been checked (in which case it will returntrue
).- Parameters:
elements
- may benull
or may contain null elements, in which casefalse
will be returned; may be empty, in which casetrue
will be returned- Returns:
true
if the given elements are possible input elements for this view, andfalse
otherwise
-
setInputElements
Sets the current input elements for this view. Clients must not modify the given array afterwards.- Parameters:
elements
- notnull
, must not contain null elements; may be empty- Throws:
IllegalArgumentException
- ifarePossibleInputElements(Object[])
returnsfalse
for the given elements
-
getInputElements
Returns the current input elements for this view.- Returns:
- the current input elements (never
null
, may be empty). Clients must not modify the returned array.
-
isEnabledHierarchyKind
Returns whether the given hierarchy kind is currently enabled for this view.- Parameters:
kind
- may benull
, in which casefalse
will be returned- Returns:
true
if the given kind is currently enabled, andfalse
otherwise
-
setHierarchyKind
Sets the current hierarchy kind for this view.- Parameters:
kind
- notnull
- Throws:
IllegalArgumentException
- if the given kind is not currentlyenabled
for this view
-
getHierarchyKind
Returns the current hierarchy kind for this view.- Returns:
- the current hierarchy kind (never
null
) - See Also:
-
setLayoutMode
public void setLayoutMode(int layoutMode) Sets layout mode for this view, which may be one of the constantsSWT.HORIZONTAL
orSWT.VERTICAL
; this method may also be called withSWT.HORIZONTAL|SWT.VERTICAL
for automatic layout orSWT.NONE
for hierarchy-only layout.Note that only a subset of the allowed values for layout mode may be
supported
by the view.- Parameters:
layoutMode
- the given layout mode- Throws:
IllegalArgumentException
- if the given layout mode is notsupported
by the view
-
getLayoutMode
public final int getLayoutMode()Returns the current layout mode for this view.- Returns:
- the current layout mode
- See Also:
-
supportsLayoutMode
public boolean supportsLayoutMode(int layoutMode) Returnstrue
if the given value represents a supported layout mode for this view, andfalse
otherwise. The set of the supported layout mode values does not change over the lifetime of the view and is never empty.Default implementation only supports
SWT.NONE
, which represents hierarchy-only layout.- Parameters:
layoutMode
- the layout mode to check- Returns:
true
if the given value represents a supported layout mode for this view, andfalse
otherwise
-
refresh
public final void refresh()Performs a full refresh of the content of this view. -
init
public void init(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento) throws org.eclipse.ui.PartInitException - Specified by:
init
in interfaceorg.eclipse.ui.IViewPart
- Overrides:
init
in classorg.eclipse.ui.part.ViewPart
- Throws:
org.eclipse.ui.PartInitException
-
saveState
public void saveState(org.eclipse.ui.IMemento memento) - Specified by:
saveState
in interfaceorg.eclipse.ui.IPersistable
- Specified by:
saveState
in interfaceorg.eclipse.ui.IViewPart
- Overrides:
saveState
in classorg.eclipse.ui.part.ViewPart
-
createPartControl
public void createPartControl(org.eclipse.swt.widgets.Composite parent) - Specified by:
createPartControl
in interfaceorg.eclipse.ui.IWorkbenchPart
- Specified by:
createPartControl
in classorg.eclipse.ui.part.WorkbenchPart
-
dispose
public void dispose()- Specified by:
dispose
in interfaceorg.eclipse.ui.IWorkbenchPart
- Overrides:
dispose
in classorg.eclipse.ui.part.WorkbenchPart
-
setFocus
public void setFocus()- Specified by:
setFocus
in interfaceorg.eclipse.ui.IWorkbenchPart
- Specified by:
setFocus
in classorg.eclipse.ui.part.WorkbenchPart
-
isPossibleInputElement
Returns whether the given element is a possible input element for this view.- Parameters:
element
- may benull
, in which casefalse
will be returned- Returns:
true
if the given element is a possible input element for this view, andfalse
otherwise- See Also:
-
createHistoryEntry
Creates and returns a history entry for the given input elements.- Parameters:
inputElements
- nevernull
; never empty- Returns:
- the created history entry (not
null
)
-
computeContentDescription
Computes the content description for this view.- Returns:
- the computed content description (not
null
) - See Also:
-
WorkbenchPart.getContentDescription()
-
isOpen
protected final boolean isOpen()Returns whether the view has already been opened and has not yet been closed.- Returns:
true
if the view is currently open, andfalse
otherwise
-
refresh
Performs a refresh of the content of this view according to options specified in the given context.- Parameters:
context
- the operation context (nevernull
)
-
updateHierarchyPage
protected void updateHierarchyPage()Ensures that the appropriate hierarchy page is shown by this view.This method may only be called after the SWT controls for this view have been created and before they have been disposed.
-
onInputElementsChanged
A callback that is invoked when the view input elements change.- Parameters:
oldInputElements
- nevernull
newInputElements
- nevernull
-
onHierarchyKindChanged
A callback that is invoked when the current hierarchy kind changes.- Parameters:
oldKind
- nevernull
newKind
- nevernull
-
getSupportedHierarchyKinds
Returns a set of the supported hierarchy kinds for this view.- Returns:
- the supported hierarchy kinds (never
null
, never empty)
-
setEnabledHierarchyKinds
Sets the enabled hierarchy kinds for this view. Note that at least one hierarchy kind must be enabled. Clients must not modify the given set afterwards.- Parameters:
kinds
- notnull
and not empty
-
onEnabledHierarchyKindsChanged
protected void onEnabledHierarchyKindsChanged(Set<TypeHierarchyKind> oldKinds, Set<TypeHierarchyKind> newKinds) A callback that is invoked when the set of enabled hierarchy kinds changes.- Parameters:
oldKinds
- nevernull
newKinds
- nevernull
-
onLayoutModeChanged
protected void onLayoutModeChanged(int oldLayoutMode, int newLayoutMode) A callback that is invoked when the view layout mode changes.- Parameters:
oldLayoutMode
- the old layout modenewLayoutMode
- the new layout mode
-
updateStatusLine
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.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.
- Parameters:
manager
- the status line manager (nevernull
)selection
- the current selection (nevernull
)
-
createNoHierarchyPage
protected org.eclipse.swt.widgets.Control createNoHierarchyPage(org.eclipse.swt.widgets.Composite parent) Creates and returns a control for the 'no hierarchy' page. This method is called once, when the part's control is created.Default implementation returns a
Label
telling, in general terms, that there is no type hierarchy to display. Subclasses may override this method (e.g., to give details on what the user needs to do to display a type hierarchy).- Parameters:
parent
- the parent composite (nevernull
)- Returns:
- the created control (not
null
)
-
getSashForm
protected final org.eclipse.swt.custom.SashForm getSashForm()Returns theSashForm
created for this view.- Returns:
- the
SashForm
, ornull
if it has yet to be created
-
getHierarchyViewer
Returns the hierarchy tree viewer for the given hierarchy kind.- Parameters:
kind
- the type hierarchy kind (nevernull
)- Returns:
- the hierarchy tree viewer,
or
null
if it has yet to be created - See Also:
-
createHierarchyViewer
protected org.eclipse.jface.viewers.TreeViewer createHierarchyViewer(org.eclipse.swt.widgets.Composite parent, TypeHierarchyKind kind) Creates and returns a tree viewer that will be used for displaying the type hierarchy of the given kind. This method only creates the viewer; it does not configure it. This method is called once, when the part's control is created.- Parameters:
parent
- the parent composite (nevernull
)kind
- the type hierarchy kind (nevernull
)- Returns:
- the created viewer (not
null
) - See Also:
-
configureHierarchyViewer
protected abstract void configureHierarchyViewer(org.eclipse.jface.viewers.TreeViewer viewer, TypeHierarchyKind kind) Configures the newly created hierarchy viewer for the given hierarchy kind. This method has to set as least a content provider and a label provider. This method is called once, just after the viewer is created.- Parameters:
viewer
- the viewer to configure (nevernull
)kind
- the type hierarchy kind (nevernull
)
-
setHierarchyViewerInput
protected void setHierarchyViewerInput(org.eclipse.jface.viewers.TreeViewer viewer, TypeHierarchyKind kind) Sets the input for the hierarchy viewer for the given hierarchy kind.- Parameters:
viewer
- the viewer to set the input for (nevernull
)kind
- the type hierarchy kind (nevernull
)
-
createHierarchyViewerMenuGroups
protected void createHierarchyViewerMenuGroups(org.eclipse.jface.action.IMenuManager manager, TypeHierarchyKind kind) Creates the menu groups for the pop-up menu of the hierarchy viewer of the given hierarchy kind. This method is called each time the pop-up menu is about to show, just beforefillHierarchyViewerMenu(org.eclipse.jface.action.IMenuManager, org.eclipse.handly.ui.typehierarchy.TypeHierarchyKind)
is called.Default implementation adds groups named
GROUP_FOCUS
andIWorkbenchActionConstants.MB_ADDITIONS
. Subclasses may extend or override this method, but should usually keep the default groups.- Parameters:
manager
- the menu manager (nevernull
)kind
- the type hierarchy kind (nevernull
)
-
fillHierarchyViewerMenu
protected void fillHierarchyViewerMenu(org.eclipse.jface.action.IMenuManager manager, TypeHierarchyKind kind) Fills the pop-menu for the hierarchy viewer for the given hierarchy kind using the menu groups created bycreateHierarchyViewerMenuGroups(org.eclipse.jface.action.IMenuManager, org.eclipse.handly.ui.typehierarchy.TypeHierarchyKind)
. This method is called each time the pop-up menu is about to show.Default implementation adds generic actions such as 'focus on selection'. Subclasses may extend or override this method.
- Parameters:
manager
- the menu manager (nevernull
)kind
- the type hierarchy kind (nevernull
)
-
onHierarchySelectionChanged
protected void onHierarchySelectionChanged(org.eclipse.jface.viewers.ISelection selection, TypeHierarchyKind kind) A callback that is invoked when selection changes in the hierarchy viewer for the given hierarchy kind.Default implementation tries to reveal the selected hierarchy node in an open editor with
revealInEditor
.- Parameters:
selection
- the new selection (nevernull
)kind
- the type hierarchy kind (nevernull
)
-
revealInEditor
protected void revealInEditor(Object element, boolean activate, boolean mayOpenNewEditor) throws org.eclipse.ui.PartInitException Reveals the given element in an appropriate editor on a best effort basis.Default implementation uses the
editor opener
.- Parameters:
element
- notnull
activate
- whether to activate the editormayOpenNewEditor
- whether a new editor may be opened when the element cannot be revealed in an existing editor- Throws:
org.eclipse.ui.PartInitException
- if a new editor could not be created or initialized
-
getEditorOpener
Returns the editor opener used by this view.- Returns:
- the editor opener,
or
null
if it has yet to be created - See Also:
-
createEditorOpener
Creates and returns an editor opener for this view. This method is called once, when the part's control is created.Subclasses may override this method if they require a specific editor opener.
- Returns:
- the created editor opener (not
null
)
-
getFocusOnSelectionAction
protected final org.eclipse.jface.action.IAction getFocusOnSelectionAction()Returns the 'focus on selection' action used by this view.- Returns:
- the 'focus on selection' action
-
addRefreshAction
protected void addRefreshAction(org.eclipse.jface.action.IAction action) Contributes the 'refresh' action to this view. This method is called once, when the part's control is created.Default implementation adds the given action to the view tool bar. Subclasses may extend or override this method.
- Parameters:
action
- the 'refresh' action (nevernull
)
-
addSetHierarchyKindAction
protected void addSetHierarchyKindAction(org.eclipse.jface.action.IAction action, TypeHierarchyKind kind) Contributes a 'set hierarchy kind' action to this view. This method is called once for each of the 'set hierarchy kind' actions, when the part's control is created. If this view supports only one hierarchy kind, no 'set hierarchy kind' action is created and this method is not called.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.
- Parameters:
action
- a 'set hierarchy kind' action (nevernull
)kind
- the hierarchy kind set by the given action (nevernull
)- See Also:
-
addSetLayoutModeAction
protected void addSetLayoutModeAction(org.eclipse.jface.action.IAction action, int layoutMode) Contributes a 'set layout mode' action to this view. This method is called once for each of the 'set layout mode' actions, when the part's control is created. If this view supports only one layout mode, no 'set layout mode' action is created and this method is not called.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.
- Parameters:
action
- a 'set layout mode' action (nevernull
)layoutMode
- the layout mode set by the given action- See Also:
-
createHistoryDropDownAction
protected HistoryDropDownAction<TypeHierarchyViewPart.HistoryEntry> createHistoryDropDownAction(HistoryDropDownAction.History<TypeHierarchyViewPart.HistoryEntry> history) Creates and returns a 'show history list' action for this view. This method is called once, when the part's control is created.Subclasses need to override this method if they extend
HistoryDropDownAction
.- Parameters:
history
- nevernull
- Returns:
- the created action (not
null
)
-
addHistoryDropDownAction
protected void addHistoryDropDownAction(org.eclipse.jface.action.IAction action) Contributes the 'show history list' action to this view. This method is called once, when the part's control is created.Default implementation adds the given action to the view tool bar. Subclasses may extend or override this method.
- Parameters:
action
- the 'show history list' action (nevernull
)
-
getHistory
Returns the history used by this view; the history is represented by a "live" list of history entries.- Returns:
- the view history (never
null
)
-
onHistoryChanged
protected void onHistoryChanged()A callback that is invoked when the history has been updated.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.
- See Also:
-