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
Nested ClassesModifier and TypeClassDescriptionprotected static classRepresents an entry of the type hierarchy view history list.protected classHelper for opening editors on the viewer's selection. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringPop-up menu: name of group for focus actions (value"group.focus").Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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 voidaddHistoryDropDownAction(org.eclipse.jface.action.IAction action) Contributes the 'show history list' action to this view.protected voidaddRefreshAction(org.eclipse.jface.action.IAction action) Contributes the 'refresh' action to this view.protected voidaddSetHierarchyKindAction(org.eclipse.jface.action.IAction action, TypeHierarchyKind kind) Contributes a 'set hierarchy kind' action to this view.protected voidaddSetLayoutModeAction(org.eclipse.jface.action.IAction action, int layoutMode) Contributes a 'set layout mode' action to this view.booleanarePossibleInputElements(Object[] elements) Returns whether the given elements are possible input elements for this view.protected abstract StringComputes the content description for this view.protected abstract voidconfigureHierarchyViewer(org.eclipse.jface.viewers.TreeViewer viewer, TypeHierarchyKind kind) Configures the newly created hierarchy viewer for the given hierarchy kind.protected EditorOpenerCreates and returns an editor opener for this view.protected org.eclipse.jface.viewers.TreeViewercreateHierarchyViewer(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 voidcreateHierarchyViewerMenuGroups(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.HistoryEntrycreateHistoryEntry(Object[] inputElements) Creates and returns a history entry for the given input elements.protected org.eclipse.swt.widgets.ControlcreateNoHierarchyPage(org.eclipse.swt.widgets.Composite parent) Creates and returns a control for the 'no hierarchy' page.voidcreatePartControl(org.eclipse.swt.widgets.Composite parent) voiddispose()protected voidfillHierarchyViewerMenu(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 EditorOpenerReturns the editor opener used by this view.protected final org.eclipse.jface.action.IActionReturns the 'focus on selection' action used by this view.final TypeHierarchyKindReturns the current hierarchy kind for this view.protected final org.eclipse.jface.viewers.TreeViewerReturns 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 intReturns the current layout mode for this view.protected final org.eclipse.swt.custom.SashFormReturns theSashFormcreated for this view.protected final Set<TypeHierarchyKind> Returns a set of the supported hierarchy kinds for this view.voidinit(org.eclipse.ui.IViewSite site, org.eclipse.ui.IMemento memento) final booleanReturns whether the given hierarchy kind is currently enabled for this view.protected final booleanisOpen()Returns whether the view has already been opened and has not yet been closed.protected abstract booleanisPossibleInputElement(Object element) Returns whether the given element is a possible input element for this view.protected voidonEnabledHierarchyKindsChanged(Set<TypeHierarchyKind> oldKinds, Set<TypeHierarchyKind> newKinds) A callback that is invoked when the set of enabled hierarchy kinds changes.protected voidonHierarchyKindChanged(TypeHierarchyKind oldKind, TypeHierarchyKind newKind) A callback that is invoked when the current hierarchy kind changes.protected voidonHierarchySelectionChanged(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 voidA callback that is invoked when the history has been updated.protected voidonInputElementsChanged(Object[] oldInputElements, Object[] newInputElements) A callback that is invoked when the view input elements change.protected voidonLayoutModeChanged(int oldLayoutMode, int newLayoutMode) A callback that is invoked when the view layout mode changes.final voidrefresh()Performs a full refresh of the content of this view.protected voidPerforms a refresh of the content of this view according to options specified in the given context.protected voidrevealInEditor(Object element, boolean activate, boolean mayOpenNewEditor) Reveals the given element in an appropriate editor on a best effort basis.voidsaveState(org.eclipse.ui.IMemento memento) protected voidSets the enabled hierarchy kinds for this view.voidsetFocus()voidSets the current hierarchy kind for this view.protected voidsetHierarchyViewerInput(org.eclipse.jface.viewers.TreeViewer viewer, TypeHierarchyKind kind) Sets the input for the hierarchy viewer for the given hierarchy kind.voidsetInputElements(Object[] elements) Sets the current input elements for this view.voidsetLayoutMode(int layoutMode) Sets layout mode for this view, which may be one of the constantsSWT.HORIZONTALorSWT.VERTICAL; this method may also be called withSWT.HORIZONTAL|SWT.VERTICALfor automatic layout orSWT.NONEfor hierarchy-only layout.booleansupportsLayoutMode(int layoutMode) Returnstrueif the given value represents a supported layout mode for this view, andfalseotherwise.protected voidEnsures that the appropriate hierarchy page is shown by this view.protected voidupdateStatusLine(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, setPartNameMethods 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, showBusyMethods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapterMethods 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- notnulland 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 untilfalseis 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 benullor may contain null elements, in which casefalsewill be returned; may be empty, in which casetruewill be returned- Returns:
trueif the given elements are possible input elements for this view, andfalseotherwise
-
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[])returnsfalsefor 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 casefalsewill be returned- Returns:
trueif the given kind is currently enabled, andfalseotherwise
-
setHierarchyKind
Sets the current hierarchy kind for this view.- Parameters:
kind- notnull- Throws:
IllegalArgumentException- if the given kind is not currentlyenabledfor 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.HORIZONTALorSWT.VERTICAL; this method may also be called withSWT.HORIZONTAL|SWT.VERTICALfor automatic layout orSWT.NONEfor hierarchy-only layout.Note that only a subset of the allowed values for layout mode may be
supportedby the view.- Parameters:
layoutMode- the given layout mode- Throws:
IllegalArgumentException- if the given layout mode is notsupportedby 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) Returnstrueif the given value represents a supported layout mode for this view, andfalseotherwise. 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:
trueif the given value represents a supported layout mode for this view, andfalseotherwise
-
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:
initin interfaceorg.eclipse.ui.IViewPart- Overrides:
initin classorg.eclipse.ui.part.ViewPart- Throws:
org.eclipse.ui.PartInitException
-
saveState
public void saveState(org.eclipse.ui.IMemento memento) - Specified by:
saveStatein interfaceorg.eclipse.ui.IPersistable- Specified by:
saveStatein interfaceorg.eclipse.ui.IViewPart- Overrides:
saveStatein classorg.eclipse.ui.part.ViewPart
-
createPartControl
public void createPartControl(org.eclipse.swt.widgets.Composite parent) - Specified by:
createPartControlin interfaceorg.eclipse.ui.IWorkbenchPart- Specified by:
createPartControlin classorg.eclipse.ui.part.WorkbenchPart
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.eclipse.ui.IWorkbenchPart- Overrides:
disposein classorg.eclipse.ui.part.WorkbenchPart
-
setFocus
public void setFocus()- Specified by:
setFocusin interfaceorg.eclipse.ui.IWorkbenchPart- Specified by:
setFocusin 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 casefalsewill be returned- Returns:
trueif the given element is a possible input element for this view, andfalseotherwise- 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:
-
isOpen
protected final boolean isOpen()Returns whether the view has already been opened and has not yet been closed.- Returns:
trueif the view is currently open, andfalseotherwise
-
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- nevernullnewInputElements- nevernull
-
onHierarchyKindChanged
A callback that is invoked when the current hierarchy kind changes.- Parameters:
oldKind- nevernullnewKind- 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- notnulland 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- nevernullnewKinds- 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
Labeltelling, 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 theSashFormcreated for this view.- Returns:
- the
SashForm, ornullif 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
nullif 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_FOCUSandIWorkbenchActionConstants.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- notnullactivate- 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
nullif 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:
-