Package gda.rcp.views

Class ContentProposalAdapter

java.lang.Object
gda.rcp.views.ContentProposalAdapter

public class ContentProposalAdapter extends Object
ContentProposalAdapter can be used to attach content proposal behavior to a control. This behavior includes obtaining proposals, opening a popup dialog, managing the content of the control relative to the selections in the popup, and optionally opening up a secondary popup to further describe proposals.

This class provides some overridable methods to allow clients to manually control the popup. However, most of the implementation remains private.

Since:
3.2 * @author rsr31645 - R Somayaji - Had to copy this class from jface because there was no way to control the display of infopopup. Once GDA requirement have sorted out the need to use the info popup (the tooltip that appears next to the content assist) then GDA can delete this class and use the org.eclipse.jface.fieldassist.ContentProposalAdapter directly instead.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ContentProposalAdapter(org.eclipse.swt.widgets.Control control, org.eclipse.jface.fieldassist.IControlContentAdapter controlContentAdapter, org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider, org.eclipse.jface.bindings.keys.KeyStroke keyStroke, Set<Character> acceptKeys)
    Construct a content proposal adapter that can assist the user with choosing content for the field.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener listener)
    Add the specified listener to the list of content proposal listeners that are notified when content proposals are chosen.
    void
    Close the proposal popup without accepting a proposal.
    org.eclipse.jface.fieldassist.IContentProposalProvider
    Return the proposal provider that provides content proposals given the current content of the field.
    org.eclipse.swt.widgets.Control
    Get the control on which the content proposal adapter is installed.
    org.eclipse.jface.fieldassist.IControlContentAdapter
    Return the content adapter that can get or retrieve the text contents from the adapter's control.
    org.eclipse.jface.viewers.ILabelProvider
    Get the label provider that is used to show proposals.
    org.eclipse.swt.graphics.Point
    Return the size, in pixels, of the content proposal popup.
    boolean
    Returns whether the content proposal popup has the focus.
    boolean
    Answers a boolean indicating whether the main proposal popup is open.
    void
    removeContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener listener)
    Removes the specified listener from the list of content proposal listeners that are notified when content proposals are chosen.
    void
    setContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider)
    Set the content proposal provider that is used to show proposals.
    void
    setLabelProvider(org.eclipse.jface.viewers.ILabelProvider labelProvider)
    Set the label provider that is used to show proposals.
    void
    setPopupSize(org.eclipse.swt.graphics.Point size)
    Set the size, in pixels, of the content proposal popup.
    void
    Sets focus to the proposal popup.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContentProposalAdapter

      public ContentProposalAdapter(org.eclipse.swt.widgets.Control control, org.eclipse.jface.fieldassist.IControlContentAdapter controlContentAdapter, org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider, org.eclipse.jface.bindings.keys.KeyStroke keyStroke, Set<Character> acceptKeys)
      Construct a content proposal adapter that can assist the user with choosing content for the field.
      Parameters:
      control - the control for which the adapter is providing content assist. May not be null.
      controlContentAdapter - the IControlContentAdapter used to obtain and update the control's contents as proposals are accepted. May not be null.
      proposalProvider - the IContentProposalProvider used to obtain content proposals for this control, or null if no content proposal is available.
      keyStroke - the keystroke that will invoke the content proposal popup.
  • Method Details

    • getControl

      public org.eclipse.swt.widgets.Control getControl()
      Get the control on which the content proposal adapter is installed.
      Returns:
      the control on which the proposal adapter is installed.
    • getLabelProvider

      public org.eclipse.jface.viewers.ILabelProvider getLabelProvider()
      Get the label provider that is used to show proposals.
      Returns:
      the ILabelProvider used to show proposals, or null if one has not been installed.
    • setLabelProvider

      public void setLabelProvider(org.eclipse.jface.viewers.ILabelProvider labelProvider)
      Set the label provider that is used to show proposals. The lifecycle of the specified label provider is not managed by this adapter. Clients must dispose the label provider when it is no longer needed.
      Parameters:
      labelProvider - the (@link ILabelProvider} used to show proposals.
    • getContentProposalProvider

      public org.eclipse.jface.fieldassist.IContentProposalProvider getContentProposalProvider()
      Return the proposal provider that provides content proposals given the current content of the field. A value of null indicates that there are no content proposals available for the field.
      Returns:
      the IContentProposalProvider used to show proposals. May be null.
    • setContentProposalProvider

      public void setContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider)
      Set the content proposal provider that is used to show proposals.
      Parameters:
      proposalProvider - the IContentProposalProvider used to show proposals
    • getPopupSize

      public org.eclipse.swt.graphics.Point getPopupSize()
      Return the size, in pixels, of the content proposal popup.
      Returns:
      a Point specifying the last width and height, in pixels, of the content proposal popup.
    • setPopupSize

      public void setPopupSize(org.eclipse.swt.graphics.Point size)
      Set the size, in pixels, of the content proposal popup. This size will be used the next time the content proposal popup is opened.
      Parameters:
      size - a Point specifying the desired width and height, in pixels, of the content proposal popup.
    • getControlContentAdapter

      public org.eclipse.jface.fieldassist.IControlContentAdapter getControlContentAdapter()
      Return the content adapter that can get or retrieve the text contents from the adapter's control. This method is used when a client, such as a content proposal listener, needs to update the control's contents manually.
      Returns:
      the IControlContentAdapter which can update the control text.
    • addContentProposalListener

      public void addContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener listener)
      Add the specified listener to the list of content proposal listeners that are notified when content proposals are chosen.

      Parameters:
      listener - the IContentProposalListener to be added as a listener. Must not be null. If an attempt is made to register an instance which is already registered with this instance, this method has no effect.
      See Also:
      • IContentProposalListener
    • removeContentProposalListener

      public void removeContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener listener)
      Removes the specified listener from the list of content proposal listeners that are notified when content proposals are chosen.

      Parameters:
      listener - the IContentProposalListener to be removed as a listener. Must not be null. If the listener has not already been registered, this method has no effect.
      Since:
      3.3
      See Also:
      • IContentProposalListener
    • closeProposalPopup

      public void closeProposalPopup()
      Close the proposal popup without accepting a proposal. This method returns immediately, and has no effect if the proposal popup was not open. This method is used by subclasses to explicitly close the popup based on additional logic.
      Since:
      3.3
    • hasProposalPopupFocus

      public boolean hasProposalPopupFocus()
      Returns whether the content proposal popup has the focus. This includes both the primary popup and any secondary info popup that may have focus.
      Returns:
      true if the proposal popup or its secondary info popup has the focus
      Since:
      3.4
    • setProposalPopupFocus

      public void setProposalPopupFocus()
      Sets focus to the proposal popup. If the proposal popup is not opened, this method is ignored. If the secondary popup has focus, focus is returned to the main proposal popup.
      Since:
      3.6
    • isProposalPopupOpen

      public boolean isProposalPopupOpen()
      Answers a boolean indicating whether the main proposal popup is open.
      Returns:
      true if the proposal popup is open, and false if it is not.
      Since:
      3.6