Package org.eclipse.ease.ui.help.hovers
Class ContentProposalModifier
java.lang.Object
org.eclipse.jface.fieldassist.ContentProposalAdapter
org.eclipse.ease.ui.help.hovers.ContentProposalModifier
public class ContentProposalModifier
extends org.eclipse.jface.fieldassist.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.
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
Flag that controls the printing of debug info.static final int
Indicates that a single character filter applies as keys are typed in the popup.static final int
Deprecated.static final int
Indicates that there should be no filter applied as keys are typed in the popup.static final int
Indicates that the contents of the control should not be modified when a proposal is chosen.static final int
Indicates that a chosen proposal should be inserted into the field.static final int
Indicates that a chosen proposal should replace the entire contents of the field. -
Constructor Summary
ConstructorsConstructorDescriptionContentProposalModifier
(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, char[] autoActivationCharacters) Construct a content proposal adapter that can assist the user with choosing content for the field. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
addContentProposalListener
(org.eclipse.jface.fieldassist.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.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.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.int
Return the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.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
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
Get the integer style that indicates how an accepted proposal affects the control's content.boolean
Returns whether the content proposal popup has the focus.boolean
Return a boolean indicating whether the receiver is enabled.boolean
Answers a boolean indicating whether the main proposal popup is open.void
Open the proposal popup and display the proposals provided by the proposal provider.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
removeContentProposalListener
(org.eclipse.jface.fieldassist.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
(org.eclipse.jface.fieldassist.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
(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
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
Sets focus to the proposal popup.Methods inherited from class org.eclipse.jface.fieldassist.ContentProposalAdapter
refresh
-
Field Details
-
DEBUG
public static final boolean DEBUGFlag that controls the printing of debug info.- See Also:
-
PROPOSAL_INSERT
public static final int PROPOSAL_INSERTIndicates that a chosen proposal should be inserted into the field.- See Also:
-
PROPOSAL_REPLACE
public static final int PROPOSAL_REPLACEIndicates that a chosen proposal should replace the entire contents of the field.- See Also:
-
PROPOSAL_IGNORE
public 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_NONE
public static final int FILTER_NONEIndicates that there should be no filter applied as keys are typed in the popup.- See Also:
-
FILTER_CHARACTER
public static final int FILTER_CHARACTERIndicates that a single character filter applies as keys are typed in the popup.- See Also:
-
FILTER_CUMULATIVE
Deprecated.As of 3.4, filtering that is sensitive to changes in the control content should be performed by the suppliedIContentProposalProvider
, such as that performed bySimpleContentProposalProvider
Indicates 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
-
ContentProposalModifier
public ContentProposalModifier(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, 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
- theIContentProposalProvider
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
-
getControl
public org.eclipse.swt.widgets.Control getControl()Get the control on which the content proposal adapter is installed.- Overrides:
getControl
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
getLabelProvider
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Returns:
- the
ILabelProvider
used to show proposals, ornull
if one has not been installed.
-
isEnabled
public boolean isEnabled()Return a boolean indicating whether the receiver is enabled.- Overrides:
isEnabled
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Returns:
true
if the adapter is enabled, andfalse
if it is not.
-
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.- Overrides:
setLabelProvider
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
labelProvider
- theILabelProvider
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 ofnull
indicates that there are no content proposals available for the field.- Overrides:
getContentProposalProvider
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Returns:
- the
IContentProposalProvider
used 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.- Overrides:
setContentProposalProvider
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
proposalProvider
- theIContentProposalProvider
used to show proposals
-
getAutoActivationCharacters
public char[] getAutoActivationCharacters()Return the array of characters on which the popup is autoactivated.- Overrides:
getAutoActivationCharacters
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
setAutoActivationCharacters
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
getAutoActivationDelay
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
setAutoActivationDelay
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
delay
- the time in milliseconds that will pass before a popup is automatically opened
-
getProposalAcceptanceStyle
public int getProposalAcceptanceStyle()Get the integer style that indicates how an accepted proposal affects the control's content.- Overrides:
getProposalAcceptanceStyle
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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
).
-
setProposalAcceptanceStyle
public void setProposalAcceptanceStyle(int acceptance) Set the integer style that indicates how an accepted proposal affects the control's content.- Overrides:
setProposalAcceptanceStyle
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
acceptance
- a constant indicating how an accepted proposal should affect the control's content. Should be one ofPROPOSAL_INSERT
,PROPOSAL_REPLACE
, orPROPOSAL_IGNORE
-
getFilterStyle
public int getFilterStyle()Return the integer style that indicates how keystrokes affect the content of the proposal popup while it is open.- Overrides:
getFilterStyle
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Returns:
- a constant indicating how keystrokes in the proposal popup affect filtering of the proposals shown.
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 isFILTER_NONE
.
-
setFilterStyle
public 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
.- Overrides:
setFilterStyle
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
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.
-
getPopupSize
public org.eclipse.swt.graphics.Point getPopupSize()Return the size, in pixels, of the content proposal popup.- Overrides:
getPopupSize
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
setPopupSize
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
size
- a Point specifying the desired width and height, in pixels, of the content proposal popup.
-
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.- Overrides:
getPropagateKeys
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
setPropagateKeys
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.
-
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.- Overrides:
getControlContentAdapter
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Returns:
- the
IControlContentAdapter
which can update the control text.
-
setEnabled
public void setEnabled(boolean enabled) Set the boolean flag that determines whether the adapter is enabled.- Overrides:
setEnabled
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Parameters:
enabled
-true
if the adapter is enabled and responding to user input,false
if it is ignoring user input.
-
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.- Overrides:
addContentProposalListener
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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:
-
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.- Overrides:
removeContentProposalListener
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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:
-
IContentProposalListener
-
addContentProposalListener
public void addContentProposalListener(org.eclipse.jface.fieldassist.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.- Overrides:
addContentProposalListener
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Since:
- 3.3
- See Also:
-
IContentProposalListener2
-
removeContentProposalListener
public void removeContentProposalListener(org.eclipse.jface.fieldassist.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.- Overrides:
removeContentProposalListener
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Since:
- 3.3
- See Also:
-
IContentProposalListener2
-
openProposalPopup
public 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.- Overrides:
openProposalPopup
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
-
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.- Overrides:
closeProposalPopup
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
hasProposalPopupFocus
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- 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.- Overrides:
setProposalPopupFocus
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Since:
- 3.6
-
isProposalPopupOpen
public boolean isProposalPopupOpen()Answers a boolean indicating whether the main proposal popup is open.- Overrides:
isProposalPopupOpen
in classorg.eclipse.jface.fieldassist.ContentProposalAdapter
- Returns:
true
if the proposal popup is open, andfalse
if it is not.- Since:
- 3.6
-
IContentProposalProvider
, such as that performed bySimpleContentProposalProvider