Package org.eclipse.jface.fieldassist
Class ContentProposalAdapter
java.lang.Object
org.eclipse.jface.fieldassist.ContentProposalAdapter
- Direct Known Subclasses:
- ContentAssistCommandAdapter
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.
 
A number of configurable options are provided to determine how the control content is altered when a proposal is chosen, how the content proposal popup is activated, and whether any filtering should be done on the proposals as the user types characters.
This class provides some overridable methods to allow clients to manually control the popup. However, most of the implementation remains private.
- Since:
- 3.2
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final booleanFlag that controls the printing of debug info.static final intIndicates that a single character filter applies as keys are typed in the popup.static final intDeprecated.static final intIndicates that there should be no filter applied as keys are typed in the popup.static final intIndicates that the contents of the control should not be modified when a proposal is chosen.static final intIndicates that a chosen proposal should be inserted into the field.static final intIndicates that a chosen proposal should replace the entire contents of the field.
- 
Constructor SummaryConstructorsConstructorDescriptionContentProposalAdapter(Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke) Construct a content proposal adapter that can assist the user with choosing content for the field.ContentProposalAdapter(Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters) Construct a content proposal adapter that can assist the user with choosing content for the field.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd the specified listener to the list of content proposal listeners that are notified when content proposals are chosen.voidAdd the specified listener to the list of content proposal listeners that are notified when a content proposal popup is opened or closed.voidClose the proposal popup without accepting a proposal.char[]Return the array of characters on which the popup is autoactivated.intSet the delay, in milliseconds, used before any autoactivation is triggered.Return the proposal provider that provides content proposals given the current content of the field.Get the control on which the content proposal adapter is installed.Return the content adapter that can get or retrieve the text contents from the adapter's control.intReturn the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.Get the label provider that is used to show proposals.Return the size, in pixels, of the content proposal popup.booleanGet the boolean that indicates whether key events (including auto-activation characters) received by the content proposal popup should also be propagated to the adapted control when the proposal popup is open.intGet the integer style that indicates how an accepted proposal affects the control's content.booleanReturns whether the content proposal popup has the focus.booleanReturn a boolean indicating whether the receiver is enabled.booleanAnswers a boolean indicating whether the main proposal popup is open.voidOpen the proposal popup and display the proposals provided by the proposal provider.voidrefresh()Reloads the proposals from the content provider and fills them into the proposal pop-up, if the pop-up is currently open.voidRemoves the specified listener from the list of content proposal listeners that are notified when content proposals are chosen.voidRemove the specified listener from the list of content proposal listeners that are notified when a content proposal popup is opened or closed.voidsetAutoActivationCharacters(char[] autoActivationCharacters) Set the array of characters that will trigger autoactivation of the popup.voidsetAutoActivationDelay(int delay) Set the delay, in milliseconds, used before autoactivation is triggered.voidsetContentProposalProvider(IContentProposalProvider proposalProvider) Set the content proposal provider that is used to show proposals.voidsetEnabled(boolean enabled) Set the boolean flag that determines whether the adapter is enabled.voidsetFilterStyle(int filterStyle) Set the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.voidsetLabelProvider(ILabelProvider labelProvider) Set the label provider that is used to show proposals.voidsetPopupSize(Point size) Set the size, in pixels, of the content proposal popup.voidsetPropagateKeys(boolean propagateKeys) Set the boolean that indicates whether key events (including auto-activation characters) received by the content proposal popup should also be propagated to the adapted control when the proposal popup is open.voidsetProposalAcceptanceStyle(int acceptance) Set the integer style that indicates how an accepted proposal affects the control's content.voidSets focus to the proposal popup.
- 
Field Details- 
DEBUGpublic static final boolean DEBUGFlag that controls the printing of debug info.- See Also:
 
- 
PROPOSAL_INSERTpublic static final int PROPOSAL_INSERTIndicates that a chosen proposal should be inserted into the field.- See Also:
 
- 
PROPOSAL_REPLACEpublic static final int PROPOSAL_REPLACEIndicates that a chosen proposal should replace the entire contents of the field.- See Also:
 
- 
PROPOSAL_IGNOREpublic static final int PROPOSAL_IGNOREIndicates that the contents of the control should not be modified when a proposal is chosen. This is typically used when a client needs more specialized behavior when a proposal is chosen. In this case, clients typically register an IContentProposalListener so that they are notified when a proposal is chosen.- See Also:
 
- 
FILTER_NONEpublic static final int FILTER_NONEIndicates that there should be no filter applied as keys are typed in the popup.- See Also:
 
- 
FILTER_CHARACTERpublic static final int FILTER_CHARACTERIndicates that a single character filter applies as keys are typed in the popup.- See Also:
 
- 
FILTER_CUMULATIVEDeprecated.As of 3.4, filtering that is sensitive to changes in the control content should be performed by the suppliedIContentProposalProvider, such as that performed bySimpleContentProposalProviderIndicates that a cumulative filter applies as keys are typed in the popup. That is, each character typed will be added to the filter.- See Also:
 
 
- 
- 
Constructor Details- 
ContentProposalAdapterpublic ContentProposalAdapter(Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke) Construct a content proposal adapter that can assist the user with choosing content for the field. Use this constructor if you want to specify akeyStrokeand still want the content assist to be triggered by any modification to the content.- Parameters:
- control- the control for which the adapter is providing content assist. May not be- null.
- controlContentAdapter- the- IControlContentAdapterused to obtain and update the control's contents as proposals are accepted. May not be- null.
- proposalProvider- the- IContentProposalProviderused to obtain content proposals for this control, or- nullif no content proposal is available.
- keyStroke- the keystroke that will invoke the content proposal popup. The content proposal popup will additionally be triggered by all modifications to the content.
- Since:
- 3.23
 
- 
ContentProposalAdapterpublic ContentProposalAdapter(Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters) 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- IControlContentAdapterused to obtain and update the control's contents as proposals are accepted. May not be- null.
- proposalProvider- the- IContentProposalProviderused to obtain content proposals for this control, or- nullif no content proposal is available.
- keyStroke- the keystroke that will invoke the content proposal popup. If this value is- null, then proposals will still be activated when any of the auto activation characters are typed.
- autoActivationCharacters- An array of characters that trigger auto-activation of content proposal. If specified, these characters will trigger auto-activation of the proposal popup, regardless of whether an explicit invocation keyStroke was specified. If this parameter is- null, then only a specified keyStroke will invoke content proposal. If this parameter is- nulland the keyStroke parameter is- null, then all modifications to the content will auto-activate content proposal.
 
 
- 
- 
Method Details- 
getControlGet the control on which the content proposal adapter is installed.- Returns:
- the control on which the proposal adapter is installed.
 
- 
getLabelProviderGet the label provider that is used to show proposals.- Returns:
- the ILabelProviderused to show proposals, ornullif one has not been installed.
 
- 
isEnabledpublic boolean isEnabled()Return a boolean indicating whether the receiver is enabled.- Returns:
- trueif the adapter is enabled, and- falseif it is not.
 
- 
setLabelProviderSet 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- ILabelProviderused to show proposals.
 
- 
getContentProposalProviderReturn 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.
 
- 
setContentProposalProviderSet the content proposal provider that is used to show proposals.- Parameters:
- proposalProvider- the- IContentProposalProviderused to show proposals
 
- 
getAutoActivationCharacterspublic char[] getAutoActivationCharacters()Return the array of characters on which the popup is autoactivated.- Returns:
- An array of characters that trigger auto-activation of content
         proposal. If specified, these characters will trigger
         auto-activation of the proposal popup, regardless of whether an
         explicit invocation keyStroke was specified. If this parameter is
         null, then only a specified keyStroke will invoke content proposal. If this value isnulland the keyStroke value isnull, then all alphanumeric characters will auto-activate content proposal.
 
- 
setAutoActivationCharacterspublic void setAutoActivationCharacters(char[] autoActivationCharacters) Set the array of characters that will trigger autoactivation of the popup.- Parameters:
- autoActivationCharacters- An array of characters that trigger auto-activation of content proposal. If specified, these characters will trigger auto-activation of the proposal popup, regardless of whether an explicit invocation keyStroke was specified. If this parameter is- null, then only a specified keyStroke will invoke content proposal. If this parameter is- nulland the keyStroke value is- null, then all alphanumeric characters will auto-activate content proposal.
 
- 
getAutoActivationDelaypublic int getAutoActivationDelay()Set the delay, in milliseconds, used before any autoactivation is triggered.- Returns:
- the time in milliseconds that will pass before a popup is automatically opened
 
- 
setAutoActivationDelaypublic void setAutoActivationDelay(int delay) Set the delay, in milliseconds, used before autoactivation is triggered.- Parameters:
- delay- the time in milliseconds that will pass before a popup is automatically opened
 
- 
getProposalAcceptanceStylepublic int getProposalAcceptanceStyle()Get the integer style that indicates how an accepted proposal affects the control's content.- Returns:
- a constant indicating how an accepted proposal should affect the
         control's content. Should be one of PROPOSAL_INSERT,PROPOSAL_REPLACE, orPROPOSAL_IGNORE. (Default isPROPOSAL_INSERT).
 
- 
setProposalAcceptanceStylepublic void setProposalAcceptanceStyle(int acceptance) Set the integer style that indicates how an accepted proposal affects the control's content.- Parameters:
- acceptance- a constant indicating how an accepted proposal should affect the control's content. Should be one of- PROPOSAL_INSERT,- PROPOSAL_REPLACE, or- PROPOSAL_IGNORE
 
- 
getFilterStylepublic int getFilterStyle()Return the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.- Returns:
- a constant indicating how keystrokes in the proposal popup affect
         filtering of the proposals shown. FILTER_NONEspecifies that no filtering will occur in the content proposal list as keys are typed.FILTER_CHARACTERspecifies the content of the popup will be filtered by the most recently typed character.FILTER_CUMULATIVEis deprecated and no longer recommended. It specifies that the content of the popup will be filtered by a string containing all the characters typed since the popup has been open. The default isFILTER_NONE.
 
- 
setFilterStylepublic void setFilterStyle(int filterStyle) Set the integer style that indicates how keystrokes affect the content of the proposal popup while it is open. Popup-based filtering is useful for narrowing and navigating the list of proposals provided once the popup is open. Filtering of the proposals will occur even when the control content is not affected by user typing. Note that automatic filtering is not used to achieve content-sensitive filtering such as auto-completion. Filtering that is sensitive to changes in the control content should be performed by the suppliedIContentProposalProvider.- Parameters:
- filterStyle- a constant indicating how keystrokes received in the proposal popup affect filtering of the proposals shown.- FILTER_NONEspecifies that no automatic filtering of the content proposal list will occur as keys are typed in the popup.- FILTER_CHARACTERspecifies that the content of the popup will be filtered by the most recently typed character.- FILTER_CUMULATIVEis deprecated and no longer recommended. It specifies that the content of the popup will be filtered by a string containing all the characters typed since the popup has been open.
 
- 
getPopupSizeReturn 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.
 
- 
setPopupSizeSet 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.
 
- 
getPropagateKeyspublic boolean getPropagateKeys()Get the boolean that indicates whether key events (including auto-activation characters) received by the content proposal popup should also be propagated to the adapted control when the proposal popup is open.- Returns:
- a boolean that indicates whether key events (including
         auto-activation characters) should be propagated to the adapted
         control when the proposal popup is open. Default value is
         true.
 
- 
setPropagateKeyspublic void setPropagateKeys(boolean propagateKeys) Set the boolean that indicates whether key events (including auto-activation characters) received by the content proposal popup should also be propagated to the adapted control when the proposal popup is open.- Parameters:
- propagateKeys- a boolean that indicates whether key events (including auto-activation characters) should be propagated to the adapted control when the proposal popup is open.
 
- 
getControlContentAdapterReturn 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.
 
- 
setEnabledpublic void setEnabled(boolean enabled) Set the boolean flag that determines whether the adapter is enabled.- Parameters:
- enabled-- trueif the adapter is enabled and responding to user input,- falseif it is ignoring user input.
 
- 
addContentProposalListenerAdd 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:
 
- 
removeContentProposalListenerRemoves 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:
 
- 
addContentProposalListenerAdd the specified listener to the list of content proposal listeners that are notified when a content proposal popup is opened or closed.- Parameters:
- listener- the IContentProposalListener2 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.
- Since:
- 3.3
- See Also:
 
- 
removeContentProposalListenerRemove the specified listener from the list of content proposal listeners that are notified when a content proposal popup is opened or closed.- Parameters:
- listener- the IContentProposalListener2 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:
 
- 
openProposalPopuppublic void openProposalPopup()Open the proposal popup and display the proposals provided by the proposal provider. This method returns immediately. That is, it does not wait for a proposal to be selected. This method is used to explicitly invoke the opening of the popup. If there are no proposals to show, the popup will not open and a beep will be sounded.- Since:
- 3.22
 
- 
closeProposalPopuppublic 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.22
 
- 
hasProposalPopupFocuspublic 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
 
- 
setProposalPopupFocuspublic 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
 
- 
isProposalPopupOpenpublic boolean isProposalPopupOpen()Answers a boolean indicating whether the main proposal popup is open.- Returns:
- trueif the proposal popup is open, and- falseif it is not.
- Since:
- 3.6
 
- 
refreshpublic void refresh()Reloads the proposals from the content provider and fills them into the proposal pop-up, if the pop-up is currently open.- Since:
- 3.15
 
 
- 
IContentProposalProvider, such as that performed bySimpleContentProposalProvider