Class ContentAssistant
- All Implemented Interfaces:
- IContentAssistant,- IContentAssistantExtension,- IContentAssistantExtension2,- IContentAssistantExtension3,- IContentAssistantExtension4,- ITextViewerLifecycle,- IWidgetTokenKeeper,- IWidgetTokenKeeperExtension
- Direct Known Subclasses:
- SubjectControlContentAssistant
IContentAssistant interface. Usually, clients
 instantiate this class and configure it before using it.
 Since 3.12, it can compute and display the proposals asynchronously when invoking
 ContentAssistant(boolean) with true.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classAn implementation ofIContentAssistListener, this class is used to monitor key events in support of automatic activation of the content assistant.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringContent assist command identifier for 'select next proposal'.static final StringContent assist command identifier for 'select previous proposal'.static final StringDialog store constant for the x-size of the context selector pop-upstatic final StringDialog store constant for the y-size of the context selector pop-upstatic final StringDialog store constant for the x-size of the completion proposal pop-upstatic final StringDialog store constant for the y-size of the completion proposal pop-upstatic final intThe popup priority: > linked position proposals and hover pop-ups.Fields inherited from interface org.eclipse.jface.text.contentassist.IContentAssistantCONTEXT_INFO_ABOVE, CONTEXT_INFO_BELOW, PROPOSAL_OVERLAY, PROPOSAL_REMOVE, PROPOSAL_STACKED
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new content assistant.ContentAssistant(boolean asynchronous) Creates a new content assistant.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddCompletionListener(ICompletionListener listener) Adds a completion listener that will be informed before proposals are computed.voidaddContentAssistProcessor(IContentAssistProcessor processor, String contentType) Registers a given content assist processor for a particular content type.Inserts the common prefix of the available completions.protected voidCallback to signal this content assistant that the presentation of the context information has been stopped.protected ContentAssistant.AutoAssistListenerThis method allows subclasses to provide their ownContentAssistant.AutoAssistListener.final voidenableAutoActivateCompletionOnType(boolean enable) Sets whether this completion list is shown on each valid character which is either a letter or digit.voidenableAutoActivation(boolean enabled) Enables the content assistant's auto activation mode.voidenableAutoInsert(boolean enabled) Enables the content assistant's auto insertion mode.voidenableColoredLabels(boolean isEnabled) Enables the support for colored labels in the proposal popup.voidenableCompletionProposalTriggerChars(boolean enable) Set whether completion trigger chars are enabled.voidenablePrefixCompletion(boolean enabled) Sets the prefix completion property.intGets the delay after which the content assistant is automatically invoked if the cursor is behind an auto activation character.getContentAssistProcessor(String contentType) Returns the content assist processor to be used for the given content type.Returns the document partitioning this content assistant is using.final IHandlergetHandler(String commandId) Returns the handler for the given command identifier.booleanReturns whether the content assistant proposal popup has the focus.protected voidhide()Hides any open pop-ups.protected voidinstall()protected voidinstall(IContentAssistSubjectControl contentAssistSubjectControl) voidinstall(ITextViewer textViewer) Installs content assist support on the given text viewer.booleanReturns whether completion trigger char are enabled.protected booleanReturns whether the context information popup is active.protected booleanReturns whether proposal popup is active.protected voidCallback to signal this content assistant that the presentation of the possible completions has been stopped.protected final voidregisterHandler(String commandId, IHandler handler) Registers the given handler under the given command identifier.voidremoveCompletionListener(ICompletionListener listener) Removes a completion listener.voidremoves the given processor from all content types in thisContentAssistantbooleanThe given widget token owner requests the widget token from this token keeper.booleanrequestWidgetToken(IWidgetTokenOwner owner, int priority) The given widget token owner requests the widget token from this token keeper.protected PointRestores the content assist's proposal pop-up size.protected PointRestores the content assist's context selector pop-up size.voidsetAutoActivationDelay(int delay) Sets the delay after which the content assistant is automatically invoked if the cursor is behind an auto activation character.voidsetContentAssistProcessor(IContentAssistProcessor processor, String contentType) Registers a given content assist processor for a particular content type.voidsetContextInformationPopupBackground(Color background) Sets the context information popup's background color.voidsetContextInformationPopupForeground(Color foreground) Sets the context information popup's foreground color.voidsetContextInformationPopupOrientation(int orientation) Sets the context information popup's orientation.voidsetContextSelectorBackground(Color background) Sets the context selector's background color.voidsetContextSelectorForeground(Color foreground) Sets the context selector's foreground color.voidsetDocumentPartitioning(String partitioning) Sets the document partitioning this content assistant is using.voidsetEmptyMessage(String message) Sets the text to be shown if no proposals are available andempty listsare displayed.booleansetFocus(IWidgetTokenOwner owner) Requests the receiver to give focus to its popup shell, hover, or similar.voidSets the information control creator for the additional information control.voidsetProposalPopupOrientation(int orientation) Sets the proposal pop-ups' orientation.voidsetProposalSelectorBackground(Color background) Sets the proposal selector's background color.voidsetProposalSelectorForeground(Color foreground) Sets the proposal's foreground color.voidsetRepeatedInvocationMode(boolean cycling) Enables repeated invocation mode, which will trigger re-computation of the proposals when code assist is executed repeatedly.voidsetRepeatedInvocationTrigger(KeySequence sequence) Sets the key sequence to listen for in repeated invocation mode.voidsetRestoreCompletionProposalSize(IDialogSettings dialogSettings) Tells this information control manager to open the information control with the values contained in the given dialog settings and to store the control's last valid size in the given dialog settings.voidsetShowEmptyList(boolean showEmpty) Enables displaying an empty completion proposal pop-up.voidsetSorter(ICompletionProposalSorter sorter) Sets the proposal sorter.voidsetStatusLineVisible(boolean show) Enables displaying a status line below the proposal popup.voidsetStatusMessage(String message) Sets the caption message displayed at the bottom of the completion proposal popup.Shows context information for the content at the viewer's cursor position.Shows all possible completions of the content at the viewer's cursor position.protected voidStores the content assist's proposal pop-up size.protected voidStores the content assist's context selector pop-up size.voidUninstalls content assist support from the text viewer it has previously be installed on.
- 
Field Details- 
SELECT_NEXT_PROPOSAL_COMMAND_IDContent assist command identifier for 'select next proposal'.- Since:
- 3.4
- See Also:
 
- 
SELECT_PREVIOUS_PROPOSAL_COMMAND_IDContent assist command identifier for 'select previous proposal'.- Since:
- 3.4
- See Also:
 
- 
STORE_SIZE_XDialog store constant for the x-size of the completion proposal pop-up- Since:
- 3.0
- See Also:
 
- 
STORE_SIZE_YDialog store constant for the y-size of the completion proposal pop-up- Since:
- 3.0
- See Also:
 
- 
STORE_CONTEXT_SELECTOR_POPUP_SIZE_XDialog store constant for the x-size of the context selector pop-up- Since:
- 3.9
- See Also:
 
- 
STORE_CONTEXT_SELECTOR_POPUP_SIZE_YDialog store constant for the y-size of the context selector pop-up- Since:
- 3.9
- See Also:
 
- 
WIDGET_PRIORITYpublic static final int WIDGET_PRIORITYThe popup priority: > linked position proposals and hover pop-ups. Default value:20;- Since:
- 3.0
- See Also:
 
 
- 
- 
Constructor Details- 
ContentAssistantpublic ContentAssistant()Creates a new content assistant. The content assistant is not automatically activated, overlays the completion proposals with context information list if necessary, and shows the context information above the location at which it was activated. If auto activation will be enabled, without further configuration steps, this content assistant is activated after a 500 milliseconds delay. It uses the default partitioning.
- 
ContentAssistantpublic ContentAssistant(boolean asynchronous) Creates a new content assistant. The content assistant is not automatically activated, overlays the completion proposals with context information list if necessary, and shows the context information above the location at which it was activated. If auto activation will be enabled, without further configuration steps, this content assistant is activated after a 500 milliseconds delay. It uses the default partitioning.- Parameters:
- asynchronous-- trueif this content assistant should present the proposals asynchronously,- falseotherwise
- Since:
- 3.12
 
 
- 
- 
Method Details- 
setDocumentPartitioningSets the document partitioning this content assistant is using.- Parameters:
- partitioning- the document partitioning for this content assistant
- Since:
- 3.0
 
- 
getDocumentPartitioningDescription copied from interface:IContentAssistantExtensionReturns the document partitioning this content assistant is using.- Specified by:
- getDocumentPartitioningin interface- IContentAssistantExtension
- Returns:
- the document partitioning this content assistant is using
 
- 
setContentAssistProcessorRegisters a given content assist processor for a particular content type. If there is already a processor registered for this type, the new processor is registered instead of the old one.- Parameters:
- processor- the content assist processor to register, or- nullto remove an existing one
- contentType- the content type under which to register
 
- 
addContentAssistProcessorRegisters a given content assist processor for a particular content type. If there is already a processor registered for this type, it is kept and the new processor is appended to the list of processors for given content-type.- Parameters:
- processor- The content-assist process to add
- contentType- Document token content-type it applies to
- Since:
- 3.12
 
- 
removeContentAssistProcessorremoves the given processor from all content types in thisContentAssistant- Parameters:
- processor- The content-assist process to remove
- Since:
- 3.17
 
- 
getContentAssistProcessorDescription copied from interface:IContentAssistantReturns the content assist processor to be used for the given content type.- Specified by:
- getContentAssistProcessorin interface- IContentAssistant
- Parameters:
- contentType- the type of the content for which this content assistant is to be requested
- Returns:
- an instance content assist processor or
         nullif none exists for the specified content type
 
- 
enableAutoActivationpublic void enableAutoActivation(boolean enabled) Enables the content assistant's auto activation mode.- Parameters:
- enabled- indicates whether auto activation is enabled or not
 
- 
enableAutoInsertpublic void enableAutoInsert(boolean enabled) Enables the content assistant's auto insertion mode. If enabled, the content assistant inserts a proposal automatically if it is the only proposal. In the case of ambiguities, the user must make the choice.- Parameters:
- enabled- indicates whether auto insertion is enabled or not
- Since:
- 2.0
 
- 
createAutoAssistListenerThis method allows subclasses to provide their ownContentAssistant.AutoAssistListener.- Returns:
- a new auto assist listener
- Since:
- 3.4
 
- 
setAutoActivationDelaypublic void setAutoActivationDelay(int delay) Sets the delay after which the content assistant is automatically invoked if the cursor is behind an auto activation character.- Parameters:
- delay- the auto activation delay (as of 3.6 a negative argument will be set to 0)
 
- 
getAutoActivationDelaypublic int getAutoActivationDelay()Gets the delay after which the content assistant is automatically invoked if the cursor is behind an auto activation character.- Returns:
- the auto activation delay (will not be negative)
- Since:
- 3.4
 
- 
setProposalPopupOrientationpublic void setProposalPopupOrientation(int orientation) Sets the proposal pop-ups' orientation. The following values may be used:- PROPOSAL_OVERLAYproposal popup windows should overlay each other 
- PROPOSAL_REMOVEany currently shown proposal popup should be closed 
- PROPOSAL_STACKEDproposal popup windows should be vertical stacked, with no overlap, beneath the line containing the current cursor location 
 - Parameters:
- orientation- the popup's orientation
 
- PROPOSAL_OVERLAY
- 
setContextInformationPopupOrientationpublic void setContextInformationPopupOrientation(int orientation) Sets the context information popup's orientation. The following values may be used:- CONTEXT_ABOVEcontext information popup should always appear above the line containing the current cursor location 
- CONTEXT_BELOWcontext information popup should always appear below the line containing the current cursor location 
 - Parameters:
- orientation- the popup's orientation
 
- CONTEXT_ABOVE
- 
setContextInformationPopupBackgroundSets the context information popup's background color.- Parameters:
- background- the background color
 
- 
setContextInformationPopupForegroundSets the context information popup's foreground color.- Parameters:
- foreground- the foreground color
- Since:
- 2.0
 
- 
setProposalSelectorBackgroundSets the proposal selector's background color.Note: As of 3.4, you should only call this method if you want to override the JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR.- Parameters:
- background- the background color
- Since:
- 2.0
 
- 
setProposalSelectorForegroundSets the proposal's foreground color.Note: As of 3.4, you should only call this method if you want to override the JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR.- Parameters:
- foreground- the foreground color
- Since:
- 2.0
 
- 
setContextSelectorBackgroundSets the context selector's background color.- Parameters:
- background- the background color
- Since:
- 2.0
 
- 
setContextSelectorForegroundSets the context selector's foreground color.- Parameters:
- foreground- the foreground color
- Since:
- 2.0
 
- 
setInformationControlCreatorSets the information control creator for the additional information control.- Parameters:
- creator- the information control creator for the additional information control
- Since:
- 2.0
 
- 
install
- 
installDescription copied from interface:IContentAssistantInstalls content assist support on the given text viewer.- Specified by:
- installin interface- IContentAssistant
- Specified by:
- installin interface- ITextViewerLifecycle
- Parameters:
- textViewer- the text viewer on which content assist will work
 
- 
installprotected void install()
- 
uninstallpublic void uninstall()Description copied from interface:IContentAssistantUninstalls content assist support from the text viewer it has previously be installed on.- Specified by:
- uninstallin interface- IContentAssistant
- Specified by:
- uninstallin interface- ITextViewerLifecycle
 
- 
showPossibleCompletionsDescription copied from interface:IContentAssistantShows all possible completions of the content at the viewer's cursor position.- Specified by:
- showPossibleCompletionsin interface- IContentAssistant
- Returns:
- an optional error message if no proposals can be computed
 
- 
completePrefixDescription copied from interface:IContentAssistantExtensionInserts the common prefix of the available completions. If no common prefix can be computed it is identical toIContentAssistant.showPossibleCompletions().- Specified by:
- completePrefixin interface- IContentAssistantExtension
- Returns:
- an optional error message if no proposals can be computed
 
- 
possibleCompletionsClosedprotected void possibleCompletionsClosed()Callback to signal this content assistant that the presentation of the possible completions has been stopped.- Since:
- 2.1
 
- 
showContextInformationDescription copied from interface:IContentAssistantShows context information for the content at the viewer's cursor position.- Specified by:
- showContextInformationin interface- IContentAssistant
- Returns:
- an optional error message if no context information can be computed
 
- 
contextInformationClosedprotected void contextInformationClosed()Callback to signal this content assistant that the presentation of the context information has been stopped.- Since:
- 2.1
 
- 
requestWidgetTokenDescription copied from interface:IWidgetTokenKeeperThe given widget token owner requests the widget token from this token keeper. Returnstrueif the token is released by this token keeper. Note, the keeper must not callreleaseWidgetToken(IWidgetTokenKeeper)explicitly.Replaced by IWidgetTokenKeeperExtension.requestWidgetToken(IWidgetTokenOwner, int).- Specified by:
- requestWidgetTokenin interface- IWidgetTokenKeeper
- Parameters:
- owner- the token owner
- Returns:
- trueif token has been released- falseotherwise
 
- 
requestWidgetTokenDescription copied from interface:IWidgetTokenKeeperExtensionThe given widget token owner requests the widget token from this token keeper. Returnstrueif the token is released by this token keeper. Note, the keeper must not callreleaseWidgetToken(IWidgetTokenKeeper)explicitly.The general contract is that the receiver should release the token if priorityexceeds the receiver's priority.- Specified by:
- requestWidgetTokenin interface- IWidgetTokenKeeperExtension
- Parameters:
- owner- the token owner
- priority- the priority of the request
- Returns:
- trueif token has been released- falseotherwise
 
- 
setFocusDescription copied from interface:IWidgetTokenKeeperExtensionRequests the receiver to give focus to its popup shell, hover, or similar. There is no assumption made whether the receiver actually succeeded in taking the focus. The return value gives a hint whether the receiver tried to take focus.- Specified by:
- setFocusin interface- IWidgetTokenKeeperExtension
- Parameters:
- owner- the token owner
- Returns:
- trueif the receiver tried to take focus,- falseif it did not.
 
- 
hideprotected void hide()Hides any open pop-ups.- Since:
- 3.0
 
- 
setRestoreCompletionProposalSizeTells this information control manager to open the information control with the values contained in the given dialog settings and to store the control's last valid size in the given dialog settings.Note: This API is only valid if the information control implements IInformationControlExtension3. Not following this restriction will later result in anUnsupportedOperationException.The constants used to store the values are: - Parameters:
- dialogSettings- the dialog settings
- Since:
- 3.0
 
- 
storeCompletionProposalPopupSizeprotected void storeCompletionProposalPopupSize()Stores the content assist's proposal pop-up size.
- 
storeContextSelectorPopupSizeprotected void storeContextSelectorPopupSize()Stores the content assist's context selector pop-up size.- Since:
- 3.9
 
- 
restoreCompletionProposalPopupSizeRestores the content assist's proposal pop-up size.- Returns:
- the stored size or nullif none
- Since:
- 3.0
 
- 
restoreContextSelectorPopupSizeRestores the content assist's context selector pop-up size.- Returns:
- the stored size or nullif none
- Since:
- 3.9
 
- 
enablePrefixCompletionpublic void enablePrefixCompletion(boolean enabled) Sets the prefix completion property. If enabled, content assist delegates completion to prefix completion.- Parameters:
- enabled-- trueto enable prefix completion,- falseto disable
 
- 
hasProposalPopupFocuspublic boolean hasProposalPopupFocus()Returns whether the content assistant proposal popup has the focus.- Returns:
- trueif the proposal popup has the focus
- Since:
- 3.0
 
- 
addCompletionListenerDescription copied from interface:IContentAssistantExtension2Adds a completion listener that will be informed before proposals are computed.- Specified by:
- addCompletionListenerin interface- IContentAssistantExtension2
- Parameters:
- listener- the listener
 
- 
removeCompletionListenerDescription copied from interface:IContentAssistantExtension2Removes a completion listener.- Specified by:
- removeCompletionListenerin interface- IContentAssistantExtension2
- Parameters:
- listener- the listener to remove
 
- 
setRepeatedInvocationModepublic void setRepeatedInvocationMode(boolean cycling) Description copied from interface:IContentAssistantExtension2Enables repeated invocation mode, which will trigger re-computation of the proposals when code assist is executed repeatedly. The default is nofalse.- Specified by:
- setRepeatedInvocationModein interface- IContentAssistantExtension2
- Parameters:
- cycling-- trueto enable repetition mode,- falseto disable
 
- 
setShowEmptyListpublic void setShowEmptyList(boolean showEmpty) Description copied from interface:IContentAssistantExtension2Enables displaying an empty completion proposal pop-up. The default is not to show an empty list.- Specified by:
- setShowEmptyListin interface- IContentAssistantExtension2
- Parameters:
- showEmpty-- trueto show empty lists
 
- 
setStatusLineVisiblepublic void setStatusLineVisible(boolean show) Description copied from interface:IContentAssistantExtension2Enables displaying a status line below the proposal popup. The default is not to show the status line. The contents of the status line may be set viaIContentAssistantExtension2.setStatusMessage(String).- Specified by:
- setStatusLineVisiblein interface- IContentAssistantExtension2
- Parameters:
- show-- trueto show a message line,- falseto not show one.
 
- 
setStatusMessageDescription copied from interface:IContentAssistantExtension2Sets the caption message displayed at the bottom of the completion proposal popup.- Specified by:
- setStatusMessagein interface- IContentAssistantExtension2
- Parameters:
- message- the message
 
- 
setEmptyMessageDescription copied from interface:IContentAssistantExtension2Sets the text to be shown if no proposals are available andempty listsare displayed.- Specified by:
- setEmptyMessagein interface- IContentAssistantExtension2
- Parameters:
- message- the text for the empty list
 
- 
setRepeatedInvocationTriggerDescription copied from interface:IContentAssistantExtension3Sets the key sequence to listen for in repeated invocation mode. If the key sequence is encountered, a step in the repetition iteration is triggered.- Specified by:
- setRepeatedInvocationTriggerin interface- IContentAssistantExtension3
- Parameters:
- sequence- the key sequence used for the repeated invocation mode or- nullif none
 
- 
isProposalPopupActiveprotected boolean isProposalPopupActive()Returns whether proposal popup is active.- Returns:
- trueif the proposal popup is active,- falseotherwise
- Since:
- 3.4
 
- 
isContextInfoPopupActiveprotected boolean isContextInfoPopupActive()Returns whether the context information popup is active.- Returns:
- trueif the context information popup is active,- falseotherwise
- Since:
- 3.4
 
- 
getHandlerReturns the handler for the given command identifier.The same handler instance will be returned when called a more than once with the same command identifier. - Specified by:
- getHandlerin interface- IContentAssistantExtension4
- Parameters:
- commandId- the command identifier
- Returns:
- the handler for the given command identifier
- Since:
- 3.4
 
- 
registerHandlerRegisters the given handler under the given command identifier.- Parameters:
- commandId- the command identifier
- handler- the handler
- Since:
- 3.4
 
- 
enableColoredLabelspublic void enableColoredLabels(boolean isEnabled) Enables the support for colored labels in the proposal popup.Completion proposals can implement ICompletionProposalExtension6to provide colored proposal labels.- Parameters:
- isEnabled- if- truethe support for colored labels is enabled in the proposal popup
- Since:
- 3.4
 
- 
setSorterSets the proposal sorter.- Parameters:
- sorter- the sorter to be used, or- nullif no sorting is requested
- Since:
- 3.8
 
- 
isCompletionProposalTriggerCharsEnabledpublic boolean isCompletionProposalTriggerCharsEnabled()Returns whether completion trigger char are enabled. If false, completion proposal trigger chars are ignored and only Enter key can be used to select a proposal.- Returns:
- whether completion trigger char are enabled.
- Since:
- 3.15
- See Also:
 
- 
enableCompletionProposalTriggerCharspublic void enableCompletionProposalTriggerChars(boolean enable) Set whether completion trigger chars are enabled. If set to false, completion proposal trigger chars are ignored and only Enter key can be used to select a proposal.- Parameters:
- enable- whether current content assistant should consider completion trigger chars.
- Since:
- 3.15
- See Also:
 
- 
enableAutoActivateCompletionOnTypepublic final void enableAutoActivateCompletionOnType(boolean enable) Sets whether this completion list is shown on each valid character which is either a letter or digit. This works conjunction withfAsynchronous- Parameters:
- enable- whether or not to enable this feature
- Since:
- 3.21
 
 
-