public class ContentAssistant extends Object implements IContentAssistant, IContentAssistantExtension, IContentAssistantExtension2, IContentAssistantExtension3, IContentAssistantExtension4, IWidgetTokenKeeper, IWidgetTokenKeeperExtension
IContentAssistant
interface. Usually, clients
instantiate this class and configure it before using it.Modifier and Type | Class and Description |
---|---|
protected class |
ContentAssistant.AutoAssistListener
An implementation of
IContentAssistListener , this class is used to monitor
key events in support of automatic activation of the content assistant. |
Modifier and Type | Field and Description |
---|---|
static String |
SELECT_NEXT_PROPOSAL_COMMAND_ID
Content assist command identifier for 'select next proposal'.
|
static String |
SELECT_PREVIOUS_PROPOSAL_COMMAND_ID
Content assist command identifier for 'select previous proposal'.
|
static String |
STORE_CONTEXT_SELECTOR_POPUP_SIZE_X
Dialog store constant for the x-size of the context selector pop-up
|
static String |
STORE_CONTEXT_SELECTOR_POPUP_SIZE_Y
Dialog store constant for the y-size of the context selector pop-up
|
static String |
STORE_SIZE_X
Dialog store constant for the x-size of the completion proposal pop-up
|
static String |
STORE_SIZE_Y
Dialog store constant for the y-size of the completion proposal pop-up
|
static int |
WIDGET_PRIORITY
The popup priority: > linked position proposals and hover pop-ups.
|
CONTEXT_INFO_ABOVE, CONTEXT_INFO_BELOW, PROPOSAL_OVERLAY, PROPOSAL_REMOVE, PROPOSAL_STACKED
Constructor and Description |
---|
ContentAssistant()
Creates a new content assistant.
|
Modifier and Type | Method and Description |
---|---|
void |
addCompletionListener(ICompletionListener listener)
Adds a completion listener that will be informed before proposals are computed.
|
String |
completePrefix()
Inserts the common prefix of the available completions.
|
protected void |
contextInformationClosed()
Callback to signal this content assistant that the presentation of the context information
has been stopped.
|
protected ContentAssistant.AutoAssistListener |
createAutoAssistListener()
This method allows subclasses to provide their own
ContentAssistant.AutoAssistListener . |
void |
enableAutoActivation(boolean enabled)
Enables the content assistant's auto activation mode.
|
void |
enableAutoInsert(boolean enabled)
Enables the content assistant's auto insertion mode.
|
void |
enableColoredLabels(boolean isEnabled)
Enables the support for colored labels in the proposal popup.
|
void |
enablePrefixCompletion(boolean enabled)
Sets the prefix completion property.
|
int |
getAutoActivationDelay()
Gets the delay after which the content assistant is automatically invoked if the cursor is
behind an auto activation character.
|
IContentAssistProcessor |
getContentAssistProcessor(String contentType)
Returns the content assist processor to be used for the given content type.
|
String |
getDocumentPartitioning()
Returns the document partitioning this content assistant is using.
|
IHandler |
getHandler(String commandId)
Returns the handler for the given command identifier.
|
boolean |
hasProposalPopupFocus()
Returns whether the content assistant proposal popup has the focus.
|
protected void |
hide()
Hides any open pop-ups.
|
protected void |
install() |
protected void |
install(IContentAssistSubjectControl contentAssistSubjectControl) |
void |
install(ITextViewer textViewer)
Installs content assist support on the given text viewer.
|
protected boolean |
isContextInfoPopupActive()
Returns whether the context information popup is active.
|
protected boolean |
isProposalPopupActive()
Returns whether proposal popup is active.
|
protected void |
possibleCompletionsClosed()
Callback to signal this content assistant that the presentation of the possible completions
has been stopped.
|
protected void |
registerHandler(String commandId,
IHandler handler)
Registers the given handler under the given command identifier.
|
void |
removeCompletionListener(ICompletionListener listener)
Removes a completion listener.
|
boolean |
requestWidgetToken(IWidgetTokenOwner owner)
The given widget token owner requests the widget token from this token
keeper.
|
boolean |
requestWidgetToken(IWidgetTokenOwner owner,
int priority)
The given widget token owner requests the widget token from
this token keeper.
|
protected Point |
restoreCompletionProposalPopupSize()
Restores the content assist's proposal pop-up size.
|
protected Point |
restoreContextSelectorPopupSize()
Restores the content assist's context selector pop-up size.
|
void |
setAutoActivationDelay(int delay)
Sets the delay after which the content assistant is automatically invoked if the cursor is
behind an auto activation character.
|
void |
setContentAssistProcessor(IContentAssistProcessor processor,
String contentType)
Registers a given content assist processor for a particular content type.
|
void |
setContextInformationPopupBackground(Color background)
Sets the context information popup's background color.
|
void |
setContextInformationPopupForeground(Color foreground)
Sets the context information popup's foreground color.
|
void |
setContextInformationPopupOrientation(int orientation)
Sets the context information popup's orientation.
|
void |
setContextSelectorBackground(Color background)
Sets the context selector's background color.
|
void |
setContextSelectorForeground(Color foreground)
Sets the context selector's foreground color.
|
void |
setDocumentPartitioning(String partitioning)
Sets the document partitioning this content assistant is using.
|
void |
setEmptyMessage(String message)
Sets the text to be shown if no proposals are available and
empty lists are displayed. |
boolean |
setFocus(IWidgetTokenOwner owner)
Requests the receiver to give focus to its popup shell, hover, or similar.
|
void |
setInformationControlCreator(IInformationControlCreator creator)
Sets the information control creator for the additional information control.
|
void |
setProposalPopupOrientation(int orientation)
Sets the proposal pop-ups' orientation.
|
void |
setProposalSelectorBackground(Color background)
Sets the proposal selector's background color.
|
void |
setProposalSelectorForeground(Color foreground)
Sets the proposal's foreground color.
|
void |
setRepeatedInvocationMode(boolean cycling)
Enables repeated invocation mode, which will trigger re-computation of the proposals when
code assist is executed repeatedly.
|
void |
setRepeatedInvocationTrigger(KeySequence sequence)
Sets the key sequence to listen for in repeated invocation mode.
|
void |
setRestoreCompletionProposalSize(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.
|
void |
setShowEmptyList(boolean showEmpty)
Enables displaying an empty completion proposal pop-up.
|
void |
setSorter(ICompletionProposalSorter sorter)
Sets the proposal sorter.
|
void |
setStatusLineVisible(boolean show)
Enables displaying a status line below the proposal popup.
|
void |
setStatusMessage(String message)
Sets the caption message displayed at the bottom of the completion proposal popup.
|
String |
showContextInformation()
Shows context information for the content at the viewer's cursor position.
|
String |
showPossibleCompletions()
Shows all possible completions of the content at the viewer's cursor position.
|
protected void |
storeCompletionProposalPopupSize()
Stores the content assist's proposal pop-up size.
|
protected void |
storeContextSelectorPopupSize()
Stores the content assist's context selector pop-up size.
|
void |
uninstall()
Uninstalls content assist support from the text viewer it has
previously be installed on.
|
public static final String SELECT_NEXT_PROPOSAL_COMMAND_ID
public static final String SELECT_PREVIOUS_PROPOSAL_COMMAND_ID
public static final String STORE_SIZE_X
public static final String STORE_SIZE_Y
public static final String STORE_CONTEXT_SELECTOR_POPUP_SIZE_X
public static final String STORE_CONTEXT_SELECTOR_POPUP_SIZE_Y
public static final int WIDGET_PRIORITY
20
;public ContentAssistant()
public void setDocumentPartitioning(String partitioning)
partitioning
- the document partitioning for this content assistantpublic String getDocumentPartitioning()
IContentAssistantExtension
getDocumentPartitioning
in interface IContentAssistantExtension
public void setContentAssistProcessor(IContentAssistProcessor processor, String contentType)
processor
- the content assist processor to register, or null
to remove
an existing onecontentType
- the content type under which to registerpublic IContentAssistProcessor getContentAssistProcessor(String contentType)
IContentAssistant
getContentAssistProcessor
in interface IContentAssistant
contentType
- the type of the content for which this
content assistant is to be requestednull
if none exists for the specified content typepublic void enableAutoActivation(boolean enabled)
enabled
- indicates whether auto activation is enabled or notpublic void enableAutoInsert(boolean enabled)
enabled
- indicates whether auto insertion is enabled or notprotected ContentAssistant.AutoAssistListener createAutoAssistListener()
ContentAssistant.AutoAssistListener
.public void setAutoActivationDelay(int delay)
delay
- the auto activation delay (as of 3.6 a negative argument will be set to 0)public int getAutoActivationDelay()
public void setProposalPopupOrientation(int orientation)
proposal popup windows should overlay each other
any currently shown proposal popup should be closed
proposal popup windows should be vertical stacked, with no overlap, beneath the line containing the current cursor location
orientation
- the popup's orientationpublic void setContextInformationPopupOrientation(int orientation)
context information popup should always appear above the line containing the current cursor location
context information popup should always appear below the line containing the current cursor location
orientation
- the popup's orientationpublic void setContextInformationPopupBackground(Color background)
background
- the background colorpublic void setContextInformationPopupForeground(Color foreground)
foreground
- the foreground colorpublic void setProposalSelectorBackground(Color background)
Note: As of 3.4, you should only call this
method if you want to override the JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR
.
background
- the background colorpublic void setProposalSelectorForeground(Color foreground)
Note: As of 3.4, you should only call this
method if you want to override the JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR
.
foreground
- the foreground colorpublic void setContextSelectorBackground(Color background)
background
- the background colorpublic void setContextSelectorForeground(Color foreground)
foreground
- the foreground colorpublic void setInformationControlCreator(IInformationControlCreator creator)
creator
- the information control creator for the additional information controlprotected void install(IContentAssistSubjectControl contentAssistSubjectControl)
public void install(ITextViewer textViewer)
IContentAssistant
install
in interface IContentAssistant
textViewer
- the text viewer on which content assist will workprotected void install()
public void uninstall()
IContentAssistant
uninstall
in interface IContentAssistant
public String showPossibleCompletions()
IContentAssistant
showPossibleCompletions
in interface IContentAssistant
public String completePrefix()
IContentAssistantExtension
IContentAssistant.showPossibleCompletions()
.completePrefix
in interface IContentAssistantExtension
protected void possibleCompletionsClosed()
public String showContextInformation()
IContentAssistant
showContextInformation
in interface IContentAssistant
protected void contextInformationClosed()
public boolean requestWidgetToken(IWidgetTokenOwner owner)
IWidgetTokenKeeper
true
if the token is released by this
token keeper. Note, the keeper must not call
releaseWidgetToken(IWidgetTokenKeeper)
explicitly.
Replaced by
IWidgetTokenKeeperExtension.requestWidgetToken(IWidgetTokenOwner, int)
.
requestWidgetToken
in interface IWidgetTokenKeeper
owner
- the token ownertrue
if token has been released false
otherwisepublic boolean requestWidgetToken(IWidgetTokenOwner owner, int priority)
IWidgetTokenKeeperExtension
true
if the token is released
by this token keeper. Note, the keeper must not call
releaseWidgetToken(IWidgetTokenKeeper)
explicitly.
The general contract is that the receiver should release the token
if priority
exceeds the receiver's priority.
requestWidgetToken
in interface IWidgetTokenKeeperExtension
owner
- the token ownerpriority
- the priority of the requesttrue
if token has been released false
otherwisepublic boolean setFocus(IWidgetTokenOwner owner)
IWidgetTokenKeeperExtension
setFocus
in interface IWidgetTokenKeeperExtension
owner
- the token ownertrue
if the receiver tried to take focus, false
if it did not.protected void hide()
public void setRestoreCompletionProposalSize(IDialogSettings dialogSettings)
Note: This API is only valid if the information control implements
IInformationControlExtension3
. Not following this restriction
will later result in an UnsupportedOperationException
.
The constants used to store the values are:
dialogSettings
- the dialog settingsprotected void storeCompletionProposalPopupSize()
protected void storeContextSelectorPopupSize()
protected Point restoreCompletionProposalPopupSize()
null
if noneprotected Point restoreContextSelectorPopupSize()
null
if nonepublic void enablePrefixCompletion(boolean enabled)
enabled
- true
to enable prefix completion, false
to
disablepublic boolean hasProposalPopupFocus()
true
if the proposal popup has the focuspublic void addCompletionListener(ICompletionListener listener)
IContentAssistantExtension2
addCompletionListener
in interface IContentAssistantExtension2
listener
- the listenerpublic void removeCompletionListener(ICompletionListener listener)
IContentAssistantExtension2
removeCompletionListener
in interface IContentAssistantExtension2
listener
- the listener to removepublic void setRepeatedInvocationMode(boolean cycling)
IContentAssistantExtension2
false
.setRepeatedInvocationMode
in interface IContentAssistantExtension2
cycling
- true
to enable repetition mode, false
to disablepublic void setShowEmptyList(boolean showEmpty)
IContentAssistantExtension2
setShowEmptyList
in interface IContentAssistantExtension2
showEmpty
- true
to show empty listspublic void setStatusLineVisible(boolean show)
IContentAssistantExtension2
IContentAssistantExtension2.setStatusMessage(String)
.setStatusLineVisible
in interface IContentAssistantExtension2
show
- true
to show a message line, false
to not show one.public void setStatusMessage(String message)
IContentAssistantExtension2
setStatusMessage
in interface IContentAssistantExtension2
message
- the messagepublic void setEmptyMessage(String message)
IContentAssistantExtension2
empty lists
are displayed.setEmptyMessage
in interface IContentAssistantExtension2
message
- the text for the empty listpublic void setRepeatedInvocationTrigger(KeySequence sequence)
IContentAssistantExtension3
setRepeatedInvocationTrigger
in interface IContentAssistantExtension3
sequence
- the key sequence used for the repeated invocation mode or null
if noneprotected boolean isProposalPopupActive()
true
if the proposal popup is active, false
otherwiseprotected boolean isContextInfoPopupActive()
true
if the context information popup is active, false
otherwisepublic final IHandler getHandler(String commandId)
The same handler instance will be returned when called a more than once with the same command identifier.
getHandler
in interface IContentAssistantExtension4
commandId
- the command identifierprotected final void registerHandler(String commandId, IHandler handler)
commandId
- the command identifierhandler
- the handlerpublic void enableColoredLabels(boolean isEnabled)
Completion proposals can implement ICompletionProposalExtension6
to provide colored proposal labels.
isEnabled
- if true
the support for colored labels is enabled in the proposal popuppublic void setSorter(ICompletionProposalSorter sorter)
sorter
- the sorter to be used, or null
if no sorting is requested
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.