Package gda.rcp.views
Class ContentProposalAdapter
java.lang.Object
gda.rcp.views.ContentProposalAdapter
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
ConstructorsConstructorDescriptionContentProposalAdapter(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 TypeMethodDescriptionvoidaddContentProposalListener(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.voidClose the proposal popup without accepting a proposal.org.eclipse.jface.fieldassist.IContentProposalProviderReturn the proposal provider that provides content proposals given the current content of the field.org.eclipse.swt.widgets.ControlGet the control on which the content proposal adapter is installed.org.eclipse.jface.fieldassist.IControlContentAdapterReturn the content adapter that can get or retrieve the text contents from the adapter's control.org.eclipse.jface.viewers.ILabelProviderGet the label provider that is used to show proposals.org.eclipse.swt.graphics.PointReturn the size, in pixels, of the content proposal popup.booleanReturns whether the content proposal popup has the focus.booleanAnswers a boolean indicating whether the main proposal popup is open.voidremoveContentProposalListener(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.voidsetContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider) Set the content proposal provider that is used to show proposals.voidsetLabelProvider(org.eclipse.jface.viewers.ILabelProvider labelProvider) Set the label provider that is used to show proposals.voidsetPopupSize(org.eclipse.swt.graphics.Point size) Set the size, in pixels, of the content proposal popup.voidSets focus to the proposal popup.
-
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 benull.controlContentAdapter- theIControlContentAdapterused to obtain and update the control's contents as proposals are accepted. May not benull.proposalProvider- theIContentProposalProviderused to obtain content proposals for this control, ornullif 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
ILabelProviderused to show proposals, ornullif 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 ofnullindicates that there are no content proposals available for the field.- Returns:
- the
IContentProposalProviderused to show proposals. May benull.
-
setContentProposalProvider
public void setContentProposalProvider(org.eclipse.jface.fieldassist.IContentProposalProvider proposalProvider) Set the content proposal provider that is used to show proposals.- Parameters:
proposalProvider- theIContentProposalProviderused 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
IControlContentAdapterwhich 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 benull. If an attempt is made to register an instance which is already registered with this instance, this method has no effect.- See Also:
-
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 benull. If the listener has not already been registered, this method has no effect.- Since:
- 3.3
- See Also:
-
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:
trueif 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:
trueif the proposal popup is open, andfalseif it is not.- Since:
- 3.6
-