Package org.eclipse.handly.ui.quickoutline

# Class OutlinePopup

java.lang.Object
org.eclipse.jface.window.Window
org.eclipse.jface.dialogs.PopupDialog
org.eclipse.handly.ui.quickoutline.OutlinePopup

All Implemented Interfaces:
  `org.eclipse.jface.window.IShellProvider`

Direct Known Subclasses:
  `FilteringOutlinePopup`

public abstract class OutlinePopup extends org.eclipse.jface.dialogs.PopupDialog
An abstract base implementation of an outline popup.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `OutlinePopup.OutlineTreeViewer`
  A tree viewer for the `OutlinePopup`.

  ## Nested classes/interfaces inherited from class org.eclipse.jface.window.Window

  `org.eclipse.jface.window.Window.IExceptionHandler`

- ## Field Summary

  ### Fields inherited from class org.eclipse.jface.dialogs.PopupDialog

  `HOVER_SHELLSTYLE, INFOPOPUP_SHELLSTYLE, INFOPOPUPRESIZE_SHELLSTYLE, POPUP_HORIZONTALSPACING, POPUP_IMG_MENU, POPUP_IMG_MENU_DISABLED, POPUP_MARGINHEIGHT, POPUP_MARGINWIDTH, POPUP_VERTICALSPACING`

  ### Fields inherited from class org.eclipse.jface.window.Window

  `CANCEL, OK, resizeHasOccurred`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OutlinePopup()`
  Creates a new outline popup.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `changeOutlineMode()`
  Changes the mode of this outline popup.
  `protected Object`
  `computeInitialSelection()`
  Computes the element to be selected initially in the outline popup's tree viewer.
  `protected abstract Object`
  `computeInput()`
  Computes the input element for the outline popup's tree viewer.
  `protected org.eclipse.swt.widgets.Control`
  `createDialogArea(org.eclipse.swt.widgets.Composite parent)`
  `protected org.eclipse.jface.viewers.TreeViewer`
  `createTreeViewer(org.eclipse.swt.widgets.Composite parent)`
  Creates a tree viewer for this outline popup.
  `protected abstract org.eclipse.jface.viewers.ITreeContentProvider`
  `getContentProvider()`
  Returns the content provider that is to be used by the outline popup's tree viewer.
  `protected abstract Object`
  `getCorrespondingElement(org.eclipse.jface.viewers.ISelection hostSelection)`
  Returns the outline element corresponding to the given host selection.
  `protected org.eclipse.swt.graphics.Point`
  `getDefaultLocation(org.eclipse.swt.graphics.Point initialSize)`
  `protected org.eclipse.jface.dialogs.IDialogSettings`
  `getDialogSettings()`
  `protected org.eclipse.swt.widgets.Control`
  `getFocusControl()`
  `protected final IOutlinePopupHost`
  `getHost()`
  Returns the host of this outline popup.
  `protected final Object`
  `getInitialSelection()`
  Returns the initially selected outline element.
  `protected final org.eclipse.swt.events.KeyListener`
  `getInvokingKeyListener()`
  Returns the invoking key listener.
  `protected final org.eclipse.jface.bindings.keys.KeyStroke`
  `getInvokingKeyStroke()`
  Returns the keystroke for invoking this outline popup.
  `protected abstract org.eclipse.jface.viewers.IBaseLabelProvider`
  `getLabelProvider()`
  Returns the label provider that is to be used by the outline popup's tree viewer.
  `protected final Object`
  `getSelectedElement()`
  Returns the currently selected outline element.
  `protected final org.eclipse.jface.viewers.TreeViewer`
  `getTreeViewer()`
  Returns the tree viewer of this outline popup.
  `protected void`
  `gotoSelectedElement()`
  Attempts to reveal the currently selected outline element in the outline popup's host.
  `void`
  `init(IOutlinePopupHost host, org.eclipse.jface.bindings.keys.KeyStroke invokingKeyStroke)`
  Initializes this outline popup with the given host and, optionally, invoking keystroke.
  `protected void`
  `initDecorationContext(org.eclipse.jface.viewers.DecorationContext context)`
  Hook to initialize decoration context.
  `protected boolean`
  `isAutoExpandable(org.eclipse.swt.widgets.TreeItem item)`
  Returns whether the given tree item is auto-expandable.
  `protected abstract boolean`
  `revealInHost(Object outlineElement)`
  Attempts to reveal the given outline element in the outline popup's host.
  `protected void`
  `setTabOrder(org.eclipse.swt.widgets.Composite composite)`
  `protected boolean`
  `shouldUseHashlookup()`
  Returns whether the outline popup's tree viewer should use hash lookup.
  `protected void`
  `updateInfoText()`
  Updates the text to be shown in the popup's info area.

  ### Methods inherited from class org.eclipse.jface.dialogs.PopupDialog

  `adjustBounds, applyBackgroundColor, applyForegroundColor, close, configureShell, createContents, createInfoTextArea, createTitleControl, createTitleMenuArea, fillDialogMenu, getBackground, getBackgroundColorExclusions, getDefaultSize, getForeground, getForegroundColorExclusions, getInitialLocation, getInitialSize, getPersistLocation, getPersistSize, hasInfoArea, hasTitleArea, open, saveDialogBounds, setInfoText, setTitleText, showDialogMenu`

  ### Methods inherited from class org.eclipse.jface.window.Window

  `canHandleShellCloseEvent, constrainShellSize, create, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getLayout, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### OutlinePopup

    public OutlinePopup()
    Creates a new outline popup.

    Note: The parent shell will be set when this outline popup is initialized with its host.

    See Also:
      - `init(IOutlinePopupHost, KeyStroke)`

- ## Method Details

  - ### init

    public void init(IOutlinePopupHost host, org.eclipse.jface.bindings.keys.KeyStroke invokingKeyStroke)
    Initializes this outline popup with the given host and, optionally, invoking keystroke. This method must be called by clients before attempting to `open` the outline popup.

    This method may be extended by subclasses. Subclasses must call the superclass implementation.

    `OutlinePopup` implementation of this method sets the parent shell to the shell of the SWT control of the given host, creates all controls of the outline popup, including the `tree viewer`, initializes the tree viewer with the `content`- and `label` providers as well as the `input`, and sets the `initial selection` in the tree viewer and the `text` in the popup's info area.

    Parameters:
      `host` - the host of this outline popup (not `null`)
      `invokingKeyStroke` - the keystroke for invoking this outline popup, or `null` if none

  - ### getHost

    protected final IOutlinePopupHost getHost()
    Returns the host of this outline popup.
    Returns:
      the host of this outline popup, or `null` if it has not been set yet

  - ### getInvokingKeyStroke

    protected final org.eclipse.jface.bindings.keys.KeyStroke getInvokingKeyStroke()
    Returns the keystroke for invoking this outline popup.
    Returns:
      the keystroke for invoking this outline popup, or `null` if none

  - ### getTreeViewer

    protected final org.eclipse.jface.viewers.TreeViewer getTreeViewer()
    Returns the tree viewer of this outline popup.
    Returns:
      the tree viewer of this outline popup, or `null` if it has not been created yet

  - ### getInitialSelection

    protected final Object getInitialSelection()
    Returns the initially selected outline element.
    Returns:
      the initially selected outline element, or `null` if none

  - ### getSelectedElement

    protected final Object getSelectedElement()
    Returns the currently selected outline element.
    Returns:
      the currently selected outline element, or `null` if none

  - ### getFocusControl

    protected org.eclipse.swt.widgets.Control getFocusControl()
    Overrides:
      `getFocusControl` in class `org.eclipse.jface.dialogs.PopupDialog`

  - ### setTabOrder

    protected void setTabOrder(org.eclipse.swt.widgets.Composite composite)
    Overrides:
      `setTabOrder` in class `org.eclipse.jface.dialogs.PopupDialog`

  - ### getDefaultLocation

    protected org.eclipse.swt.graphics.Point getDefaultLocation(org.eclipse.swt.graphics.Point initialSize)
    Overrides:
      `getDefaultLocation` in class `org.eclipse.jface.dialogs.PopupDialog`

  - ### getDialogSettings

    protected org.eclipse.jface.dialogs.IDialogSettings getDialogSettings()
    Overrides:
      `getDialogSettings` in class `org.eclipse.jface.dialogs.PopupDialog`

  - ### createDialogArea

    protected org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
    Overrides:
      `createDialogArea` in class `org.eclipse.jface.dialogs.PopupDialog`

  - ### createTreeViewer

    protected org.eclipse.jface.viewers.TreeViewer createTreeViewer(org.eclipse.swt.widgets.Composite parent)
    Creates a tree viewer for this outline popup. The viewer has no input, no content provider, a default label provider, no sorter, and no filters. This method is called once, when the popup's control is created.

    This implementation returns a new instance of `OutlinePopup.OutlineTreeViewer`.

    Parameters:
      `parent` - the parent composite (never `null`)
    Returns:
      the created tree viewer (not `null`)

  - ### updateInfoText

    protected void updateInfoText()
    Updates the text to be shown in the popup's info area.

    This implementation sets a default text. Subclasses may override.

  - ### gotoSelectedElement

    protected void gotoSelectedElement()
    Attempts to reveal the currently selected outline element in the outline popup's host. If successful, closes this outline popup.

    This implementation uses `revealInHost(Object)` for revealing the currently selected outline element.

  - ### changeOutlineMode

    protected void changeOutlineMode()
    Changes the mode of this outline popup. This method is called when the invoking keystroke is pressed.

    Default implementation does nothing. Subclasses may override.

  - ### shouldUseHashlookup

    protected boolean shouldUseHashlookup()
    Returns whether the outline popup's tree viewer should use hash lookup. This method is called once, when the popup's control is created.

    Default implementation returns `true`. Subclasses may override.

    See Also:
      - `StructuredViewer.setUseHashlookup(boolean)`

  - ### getContentProvider

    protected abstract org.eclipse.jface.viewers.ITreeContentProvider getContentProvider()
    Returns the content provider that is to be used by the outline popup's tree viewer. This method is called once, when the popup's control is created.
    Returns:
      the content provider (not `null`)

  - ### getLabelProvider

    protected abstract org.eclipse.jface.viewers.IBaseLabelProvider getLabelProvider()
    Returns the label provider that is to be used by the outline popup's tree viewer. This method is called once, when the popup's control is created.
    Returns:
      the label provider (not `null`)

  - ### computeInput

    protected abstract Object computeInput()
    Computes the input element for the outline popup's tree viewer. This method is called once, when the popup's control is created.
    Returns:
      the input element (may be `null`)

  - ### computeInitialSelection

    protected Object computeInitialSelection()
    Computes the element to be selected initially in the outline popup's tree viewer. This method is called once, when the popup's control is created.

    This implementation obtains the current selection in the outline popup's host and delegates to `getCorrespondingElement(ISelection)` if the selection is not `null` or empty.

    Returns:
      the element to be selected initially in this outline popup, or `null` if none

  - ### getCorrespondingElement

    protected abstract Object getCorrespondingElement(org.eclipse.jface.viewers.ISelection hostSelection)
    Returns the outline element corresponding to the given host selection.
    Parameters:
      `hostSelection` - the host selection (never `null`, never empty)
    Returns:
      the outline element corresponding to the host selection, or `null` if there is no such element

  - ### revealInHost

    protected abstract boolean revealInHost(Object outlineElement)
    Attempts to reveal the given outline element in the outline popup's host.
    Parameters:
      `outlineElement` - the outline element (never `null`)
    Returns:
      `true` if the element was successfully revealed; `false` otherwise

  - ### isAutoExpandable

    protected boolean isAutoExpandable(org.eclipse.swt.widgets.TreeItem item)
    Returns whether the given tree item is auto-expandable. This method should be consulted by the tree viewer's `expandXXX` methods. If it returns `false`, the item is to be collapsed rather than expanded.

    Default implementation returns `true` for the root item and `false` for all other items. Subclasses may override.

    Parameters:
      `item` - the tree item (never `null`)
    Returns:
      `true` if the given item is auto-expandable; `false` otherwise

  - ### initDecorationContext

    protected void initDecorationContext(org.eclipse.jface.viewers.DecorationContext context)
    Hook to initialize decoration context. Subclasses may extend.

    If this outline popup implements `IContentAdapterProvider`, default implementation registers this outline popup in the given context under the name `IContentAdapterProvider.class.getName()`.

    Parameters:
      `context` - the decoration context (never `null`)

  - ### getInvokingKeyListener

    protected final org.eclipse.swt.events.KeyListener getInvokingKeyListener()
    Returns the invoking key listener. When the `invoking key` is pressed, this listener `changes` the mode of the outline popup and `updates` the text in the popup's info area.
    Returns:
      the invoking key listener (never `null`)