Class HandlyOutlinePopup

java.lang.Object
org.eclipse.jface.window.Window
org.eclipse.jface.dialogs.PopupDialog
All Implemented Interfaces:
IContentAdapterProvider, org.eclipse.jface.window.IShellProvider
Direct Known Subclasses:
HandlyXtextOutlinePopup

public abstract class HandlyOutlinePopup extends FilteringOutlinePopup implements IContentAdapterProvider
A partial implementation of Handly-based outline popup. This class is intended to be used with a text-based host such as a text editor.
  • Constructor Details

    • HandlyOutlinePopup

      public HandlyOutlinePopup()
  • Method Details

    • getContentAdapter

      public IContentAdapter getContentAdapter()
      Returns the content adapter that defines a mapping between elements of a Handly-based model and the outline's content.

      Default implementation returns a NullContentAdapter. Subclasses may override.

      Specified by:
      getContentAdapter in interface IContentAdapterProvider
      Returns:
      an IContentAdapter (never null)
    • computeInput

      protected 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.

      This implementation uses the input element provider to obtain an IElement corresponding to the editor input for the outline popup's host and returns an outline element corresponding to the IElement, as determined by the content adapter.

      Specified by:
      computeInput in class OutlinePopup
      Returns:
      the input element (may be null)
    • getCorrespondingElement

      protected Object getCorrespondingElement(org.eclipse.jface.viewers.ISelection hostSelection)
      Returns the outline element corresponding to the given host selection.

      If the given selection is a text selection, this implementation finds the smallest ISourceElement that includes the offset of the text selection and returns an outline element corresponding to the found source element, as determined by the content adapter.

      Specified by:
      getCorrespondingElement in class OutlinePopup
      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 boolean revealInHost(Object outlineElement)
      Attempts to reveal the given outline element in the outline popup's host.

      This implementation attempts to adapt the given outline element to an IElement through the content adapter. If the adapter element is an ISourceElement and is contained in the host as computed by isInHost(IElement), the identifying range of the source element is selected in the outline popup's host.

      Specified by:
      revealInHost in class OutlinePopup
      Parameters:
      outlineElement - the outline element (never null)
      Returns:
      true if the element was successfully revealed; false otherwise
    • isInHost

      protected boolean isInHost(IElement element)
      Returns whether the given element is contained in the host of this outline popup.

      This implementation uses the input element provider to obtain an IElement corresponding to the editor input for the host. It then checks whether the IElement contains the given element and returns the result.

      Parameters:
      element - may be null
      Returns:
      true if the element is contained in the host; false otherwise
    • getInputElementProvider

      protected abstract IInputElementProvider getInputElementProvider()
      Returns the input element provider for this outline popup.
      Returns:
      the input element provider for this outline popup