Class ContentProposalAdapter
java.lang.Object
org.yamcs.studio.autocomplete.ui.content.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.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Flag that controls the printing of debug info. -
Constructor Summary
ConstructorDescriptionContentProposalAdapter
(Control control, IControlContentAdapter controlContentAdapter, IAutoCompleteProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters) Construct a content proposal adapter that can assist the user with choosing content for the field. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the specified listener to the list of content proposal listeners that are notified when content proposals are chosen.void
Add the specified listener to the list of content proposal listeners that are notified when a content proposal popup is opened or closed.protected void
Close the proposal popup without accepting a proposal.char[]
Return the array of characters on which the popup is autoactivated.int
Set the delay, in milliseconds, used before any autoactivation is triggered.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.Get the label provider that is used to show proposals.Return the size, in pixels, of the content proposal popup.boolean
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.void
getProposals
(IContentProposalSearchHandler listener) Get the proposals from the proposal provider.void
handleTooltipData
(List<TooltipData> tooltips) void
handleTopProposals
(ContentProposalList proposalList) Handle hightlight of the appended control contents.boolean
Returns whether the content proposal popup has the focus.boolean
Check if the control content is completed by a top proposal.boolean
Return a boolean indicating whether the receiver is enabled.boolean
boolean
Answers a boolean indicating whether the main proposal popup is open.void
protected void
Open the proposal popup and display the proposals provided by the proposal provider.void
proposalAccepted
(Proposal proposal, boolean addToHistory) A content proposal has been accepted.void
proposalSelected
(Proposal proposal) A content proposal has been selected.protected void
void
Removes the specified listener from the list of content proposal listeners that are notified when content proposals are chosen.void
Remove the specified listener from the list of content proposal listeners that are notified when a content proposal popup is opened or closed.void
setAutoActivationCharacters
(char[] autoActivationCharacters) Set the array of characters that will trigger autoactivation of the popup.void
setAutoActivationDelay
(int delay) Set the delay, in milliseconds, used before autoactivation is triggered.void
setEnabled
(boolean enabled) Set the boolean flag that determines whether the adapter is enabled.void
setLabelProvider
(ILabelProvider labelProvider) Set the label provider that is used to show proposals.void
setPopupSize
(Point size) Set the size, in pixels, of the content proposal popup.void
setPreventTopProposalSelection
(boolean preventTopProposalSelection) 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.void
Sets focus to the proposal popup.
-
Field Details
-
DEBUG
public static final boolean DEBUGFlag that controls the printing of debug info.- See Also:
-
-
Constructor Details
-
ContentProposalAdapter
public ContentProposalAdapter(Control control, IControlContentAdapter controlContentAdapter, IAutoCompleteProposalProvider 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 benull
.controlContentAdapter
- theIControlContentAdapter
used to obtain and update the control's contents as proposals are accepted. May not benull
.proposalProvider
- theIAutoCompleteProposalProvider
used to obtain content proposals for this control, ornull
if no content proposal is available.keyStroke
- the keystroke that will invoke the content proposal popup. If this value isnull
, then proposals will be activated automatically 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 isnull
, then only a specified keyStroke will invoke content proposal. If this parameter isnull
and the keyStroke parameter isnull
, then all alphanumeric characters will auto-activate content proposal.
-
-
Method Details
-
refreshHelper
protected void refreshHelper() -
handleTooltipData
-
openProposalPopup
protected 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 by subclasses 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. -
closeProposalPopup
protected 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. -
getProposals
Get the proposals from the proposal provider. -
handleTopProposals
Handle hightlight of the appended control contents.- Parameters:
proposalList
- the list of proposals.
-
hasSelectedTopProposal
public boolean hasSelectedTopProposal()Check if the control content is completed by a top proposal.- Returns:
true
if the control content is completed by a top proposal.
-
getSelectedTopProposal
-
isPreventTopProposalSelection
public boolean isPreventTopProposalSelection() -
setPreventTopProposalSelection
public void setPreventTopProposalSelection(boolean preventTopProposalSelection) -
proposalAccepted
A content proposal has been accepted. Update the control contents accordingly and notify any listeners.- Parameters:
proposal
- the accepted proposal
-
proposalSelected
A content proposal has been selected. Update the control contents accordingly without notify listeners.- Parameters:
proposal
- the selected proposal
-
notifyPopupClosed
public void notifyPopupClosed() -
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
-
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. -
isProposalPopupOpen
public boolean isProposalPopupOpen()Answers a boolean indicating whether the main proposal popup is open.- Returns:
true
if the proposal popup is open, andfalse
if it is not.
-
isEnabled
public boolean isEnabled()Return a boolean indicating whether the receiver is enabled.- Returns:
true
if the adapter is enabled, andfalse
if it is not.
-
setEnabled
public void setEnabled(boolean enabled) Set the boolean flag that determines whether the adapter is enabled.- Parameters:
enabled
-true
if the adapter is enabled and responding to user input,false
if it is ignoring user input.
-
getControl
Get the control on which the content proposal adapter is installed.- Returns:
- the control on which the proposal adapter is installed.
-
getLabelProvider
Get the label provider that is used to show proposals.- Returns:
- the
ILabelProvider
used to show proposals, ornull
if one has not been installed.
-
setLabelProvider
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.
-
getAutoActivationCharacters
public 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 isnull
and the keyStroke value isnull
, then all alphanumeric characters will auto-activate content proposal.
-
setAutoActivationCharacters
public 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 isnull
, then only a specified keyStroke will invoke content proposal. If this parameter isnull
and the keyStroke value isnull
, then all alphanumeric characters will auto-activate content proposal.
-
getAutoActivationDelay
public 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
-
setAutoActivationDelay
public 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
-
getPropagateKeys
public 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
.
-
setPropagateKeys
public 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.
-
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
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
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
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.
-
removeContentProposalListener
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.
-
addContentProposalListener
Add 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 benull
. If an attempt is made to register an instance which is already registered with this instance, this method has no effect.
-
removeContentProposalListener
Remove 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 benull
. If the listener has not already been registered, this method has no effect.
-
getHistory
-
getHelper
-