public class ContentProposalModifier extends ContentProposalAdapter
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.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG
Flag that controls the printing of debug info.
|
static int |
FILTER_CHARACTER
Indicates that a single character filter applies as keys are typed in the popup.
|
static int |
FILTER_CUMULATIVE
Deprecated.
As of 3.4, filtering that is sensitive to changes in the control content should be performed by the supplied
IContentProposalProvider
, such as that performed by SimpleContentProposalProvider |
static int |
FILTER_NONE
Indicates that there should be no filter applied as keys are typed in the popup.
|
static int |
PROPOSAL_IGNORE
Indicates that the contents of the control should not be modified when a proposal is chosen.
|
static int |
PROPOSAL_INSERT
Indicates that a chosen proposal should be inserted into the field.
|
static int |
PROPOSAL_REPLACE
Indicates that a chosen proposal should replace the entire contents of the field.
|
Constructor and Description |
---|
ContentProposalModifier(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.
|
Modifier and Type | Method and Description |
---|---|
void |
addContentProposalListener(IContentProposalListener listener)
Add the specified listener to the list of content proposal listeners that are notified when content proposals are chosen.
|
void |
addContentProposalListener(IContentProposalListener2 listener)
Add the specified listener to the list of content proposal listeners that are notified when a content proposal popup is opened or closed.
|
char[] |
getAutoActivationCharacters()
Return the array of characters on which the popup is autoactivated.
|
int |
getAutoActivationDelay()
Set the delay, in milliseconds, used before any autoactivation is triggered.
|
IContentProposalProvider |
getContentProposalProvider()
Return the proposal provider that provides content proposals given the current content of the field.
|
Control |
getControl()
Get the control on which the content proposal adapter is installed.
|
IControlContentAdapter |
getControlContentAdapter()
Return the content adapter that can get or retrieve the text contents from the adapter's control.
|
int |
getFilterStyle()
Return the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.
|
ILabelProvider |
getLabelProvider()
Get the label provider that is used to show proposals.
|
Point |
getPopupSize()
Return the size, in pixels, of the content proposal popup.
|
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.
|
int |
getProposalAcceptanceStyle()
Get the integer style that indicates how an accepted proposal affects the control's content.
|
boolean |
hasProposalPopupFocus()
Returns whether the content proposal popup has the focus.
|
boolean |
isEnabled()
Return a boolean indicating whether the receiver is enabled.
|
boolean |
isProposalPopupOpen()
Answers a boolean indicating whether the main proposal popup is open.
|
void |
removeContentProposalListener(IContentProposalListener listener)
Removes the specified listener from the list of content proposal listeners that are notified when content proposals are chosen.
|
void |
removeContentProposalListener(IContentProposalListener2 listener)
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 |
setContentProposalProvider(IContentProposalProvider proposalProvider)
Set the content proposal provider that is used to show proposals.
|
void |
setEnabled(boolean enabled)
Set the boolean flag that determines whether the adapter is enabled.
|
void |
setFilterStyle(int filterStyle)
Set the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.
|
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 |
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 |
setProposalAcceptanceStyle(int acceptance)
Set the integer style that indicates how an accepted proposal affects the control's content.
|
void |
setProposalPopupFocus()
Sets focus to the proposal popup.
|
refresh
public static final boolean DEBUG
public static final int PROPOSAL_INSERT
public static final int PROPOSAL_REPLACE
public static final int PROPOSAL_IGNORE
public static final int FILTER_NONE
public static final int FILTER_CHARACTER
@Deprecated public static final int FILTER_CUMULATIVE
IContentProposalProvider
, such as that performed by SimpleContentProposalProvider
public ContentProposalModifier(Control control, IControlContentAdapter controlContentAdapter, IContentProposalProvider proposalProvider, KeyStroke keyStroke, char[] autoActivationCharacters)
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. If this value is null
, 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 is null
, then only a
specified keyStroke will invoke content proposal. If this parameter is null
and the keyStroke parameter is null
,
then all alphanumeric characters will auto-activate content proposal.public Control getControl()
getControl
in class ContentProposalAdapter
public ILabelProvider getLabelProvider()
getLabelProvider
in class ContentProposalAdapter
ILabelProvider
used to show proposals, or null
if one has not been installed.public boolean isEnabled()
isEnabled
in class ContentProposalAdapter
true
if the adapter is enabled, and false
if it is not.public void setLabelProvider(ILabelProvider labelProvider)
setLabelProvider
in class ContentProposalAdapter
labelProvider
- the ILabelProvider
used to show proposals.public IContentProposalProvider getContentProposalProvider()
null
indicates that there
are no content proposals available for the field.getContentProposalProvider
in class ContentProposalAdapter
IContentProposalProvider
used to show proposals. May be null
.public void setContentProposalProvider(IContentProposalProvider proposalProvider)
setContentProposalProvider
in class ContentProposalAdapter
proposalProvider
- the IContentProposalProvider
used to show proposalspublic char[] getAutoActivationCharacters()
getAutoActivationCharacters
in class ContentProposalAdapter
null
, then only a
specified keyStroke will invoke content proposal. If this value is null
and the keyStroke value is null
, then all
alphanumeric characters will auto-activate content proposal.public void setAutoActivationCharacters(char[] autoActivationCharacters)
setAutoActivationCharacters
in class ContentProposalAdapter
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 null
and the keyStroke value is null
, then
all alphanumeric characters will auto-activate content proposal.public int getAutoActivationDelay()
getAutoActivationDelay
in class ContentProposalAdapter
public void setAutoActivationDelay(int delay)
setAutoActivationDelay
in class ContentProposalAdapter
delay
- the time in milliseconds that will pass before a popup is automatically openedpublic int getProposalAcceptanceStyle()
getProposalAcceptanceStyle
in class ContentProposalAdapter
PROPOSAL_INSERT
,
PROPOSAL_REPLACE
, or PROPOSAL_IGNORE
. (Default is PROPOSAL_INSERT
).public void setProposalAcceptanceStyle(int acceptance)
setProposalAcceptanceStyle
in class ContentProposalAdapter
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
public int getFilterStyle()
getFilterStyle
in class ContentProposalAdapter
FILTER_NONE
specifies that no
filtering will occur in the content proposal list as keys are typed. FILTER_CHARACTER
specifies the content of the popup will be
filtered by the most recently typed character. FILTER_CUMULATIVE
is 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 is
FILTER_NONE
.public void setFilterStyle(int filterStyle)
IContentProposalProvider
.setFilterStyle
in class ContentProposalAdapter
filterStyle
- a constant indicating how keystrokes received in the proposal popup affect filtering of the proposals shown. FILTER_NONE
specifies that no automatic filtering of the content proposal list will occur as keys are typed in the popup. FILTER_CHARACTER
specifies that the content of the popup will be filtered by the most recently typed character. FILTER_CUMULATIVE
is 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.public Point getPopupSize()
getPopupSize
in class ContentProposalAdapter
public void setPopupSize(Point size)
setPopupSize
in class ContentProposalAdapter
size
- a Point specifying the desired width and height, in pixels, of the content proposal popup.public boolean getPropagateKeys()
getPropagateKeys
in class ContentProposalAdapter
true
.public void setPropagateKeys(boolean propagateKeys)
setPropagateKeys
in class ContentProposalAdapter
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.public IControlContentAdapter getControlContentAdapter()
getControlContentAdapter
in class ContentProposalAdapter
IControlContentAdapter
which can update the control text.public void setEnabled(boolean enabled)
setEnabled
in class ContentProposalAdapter
enabled
- true
if the adapter is enabled and responding to user input, false
if it is ignoring user input.public void addContentProposalListener(IContentProposalListener listener)
addContentProposalListener
in class ContentProposalAdapter
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.IContentProposalListener
public void removeContentProposalListener(IContentProposalListener listener)
removeContentProposalListener
in class ContentProposalAdapter
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.IContentProposalListener
public void addContentProposalListener(IContentProposalListener2 listener)
addContentProposalListener
in class ContentProposalAdapter
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.IContentProposalListener2
public void removeContentProposalListener(IContentProposalListener2 listener)
removeContentProposalListener
in class ContentProposalAdapter
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.IContentProposalListener2
public boolean hasProposalPopupFocus()
hasProposalPopupFocus
in class ContentProposalAdapter
true
if the proposal popup or its secondary info popup has the focuspublic void setProposalPopupFocus()
setProposalPopupFocus
in class ContentProposalAdapter
public boolean isProposalPopupOpen()
isProposalPopupOpen
in class ContentProposalAdapter
true
if the proposal popup is open, and false
if it is not.