Eclipse Platform
Release 3.0

org.eclipse.jface.text.contentassist
Class ContentAssistant

java.lang.Object
  extended byorg.eclipse.jface.text.contentassist.ContentAssistant
All Implemented Interfaces:
IContentAssistant, IContentAssistantExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension
Direct Known Subclasses:
SubjectControlContentAssistant

public class ContentAssistant
extends Object
implements IContentAssistant, IContentAssistantExtension, IWidgetTokenKeeper, IWidgetTokenKeeperExtension

The standard implementation of the IContentAssistant interface. Usually, clients instantiate this class and configure it before using it.


Field Summary
static String STORE_SIZE_X
          Dialog store constants.
static String STORE_SIZE_Y
           
static int WIDGET_PRIORITY
          The popup priority: > linked position proposals and hover pop-ups.
 
Fields inherited from interface org.eclipse.jface.text.contentassist.IContentAssistant
CONTEXT_INFO_ABOVE, CONTEXT_INFO_BELOW, PROPOSAL_OVERLAY, PROPOSAL_REMOVE, PROPOSAL_STACKED
 
Constructor Summary
ContentAssistant()
          Creates a new content assistant.
 
Method Summary
 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.
 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 enablePrefixCompletion(boolean enabled)
          Sets the prefix completion property.
 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.
 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  void possibleCompletionsClosed()
          Callback to signal this content assistant that the presentation of the possible completions has been stopped.
 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 pop-up's 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.
 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 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.
 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 pop-up's size.
 void uninstall()
          Uninstalls content assist support from the text viewer it has previously be installed on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORE_SIZE_X

public static final String STORE_SIZE_X
Dialog store constants.

Since:
3.0
See Also:
Constant Field Values

STORE_SIZE_Y

public static final String STORE_SIZE_Y
See Also:
Constant Field Values

WIDGET_PRIORITY

public static final int WIDGET_PRIORITY
The popup priority: > linked position proposals and hover pop-ups. Default value: 20;

Since:
3.0
See Also:
Constant Field Values
Constructor Detail

ContentAssistant

public 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 milli-seconds delay. It uses the default partitioning.

Method Detail

setDocumentPartitioning

public void setDocumentPartitioning(String partitioning)
Sets the document partitioning this content assistant is using.

Parameters:
partitioning - the document partitioning for this content assistant
Since:
3.0

getDocumentPartitioning

public String getDocumentPartitioning()
Description copied from interface: IContentAssistantExtension
Returns the document partitioning this content assistant is using.

Specified by:
getDocumentPartitioning in interface IContentAssistantExtension
Returns:
the document partitioning this content assistant is using

setContentAssistProcessor

public void setContentAssistProcessor(IContentAssistProcessor processor,
                                      String contentType)
Registers 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 null to remove an existing one
contentType - the content type under which to register

getContentAssistProcessor

public IContentAssistProcessor getContentAssistProcessor(String contentType)
Description copied from interface: IContentAssistant
Returns the content assist processor to be used for the given content type.

Specified by:
getContentAssistProcessor in 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 null if none exists for the specified content type

enableAutoActivation

public void enableAutoActivation(boolean enabled)
Enables the content assistant's auto activation mode.

Parameters:
enabled - indicates whether auto activation is enabled or not

enableAutoInsert

public 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

setAutoActivationDelay

public 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

setProposalPopupOrientation

public void setProposalPopupOrientation(int orientation)
Sets the proposal pop-ups' orientation. The following values may be used:

Parameters:
orientation - the popup's orientation

setContextInformationPopupOrientation

public void setContextInformationPopupOrientation(int orientation)
Sets the context information popup's orientation. The following values may be used:

Parameters:
orientation - the popup's orientation

setContextInformationPopupBackground

public void setContextInformationPopupBackground(Color background)
Sets the context information popup's background color.

Parameters:
background - the background color

setContextInformationPopupForeground

public void setContextInformationPopupForeground(Color foreground)
Sets the context information popup's foreground color.

Parameters:
foreground - the foreground color
Since:
2.0

setProposalSelectorBackground

public void setProposalSelectorBackground(Color background)
Sets the proposal selector's background color.

Parameters:
background - the background color
Since:
2.0

setProposalSelectorForeground

public void setProposalSelectorForeground(Color foreground)
Sets the proposal's foreground color.

Parameters:
foreground - the foreground color
Since:
2.0

setContextSelectorBackground

public void setContextSelectorBackground(Color background)
Sets the context selector's background color.

Parameters:
background - the background color
Since:
2.0

setContextSelectorForeground

public void setContextSelectorForeground(Color foreground)
Sets the context selector's foreground color.

Parameters:
foreground - the foreground color
Since:
2.0

setInformationControlCreator

public void setInformationControlCreator(IInformationControlCreator creator)
Sets the information control creator for the additional information control.

Parameters:
creator - the information control creator for the additional information control
Since:
2.0

install

protected void install(IContentAssistSubjectControl contentAssistSubjectControl)

install

public void install(ITextViewer textViewer)
Description copied from interface: IContentAssistant
Installs content assist support on the given text viewer.

Specified by:
install in interface IContentAssistant
Parameters:
textViewer - the text viewer on which content assist will work

install

protected void install()

uninstall

public void uninstall()
Description copied from interface: IContentAssistant
Uninstalls content assist support from the text viewer it has previously be installed on.

Specified by:
uninstall in interface IContentAssistant

showPossibleCompletions

public String showPossibleCompletions()
Description copied from interface: IContentAssistant
Shows all possible completions of the content at the viewer's cursor position.

Specified by:
showPossibleCompletions in interface IContentAssistant
Returns:
an optional error message if no proposals can be computed

completePrefix

public String completePrefix()
Description copied from interface: IContentAssistantExtension
Inserts the common prefix of the available completions. If no common prefix can be computed it is identical to IContentAssistant.showPossibleCompletions().

Specified by:
completePrefix in interface IContentAssistantExtension
Returns:
an optional error message if no proposals can be computed

possibleCompletionsClosed

protected void possibleCompletionsClosed()
Callback to signal this content assistant that the presentation of the possible completions has been stopped.

Since:
2.1

showContextInformation

public String showContextInformation()
Description copied from interface: IContentAssistant
Shows context information for the content at the viewer's cursor position.

Specified by:
showContextInformation in interface IContentAssistant
Returns:
an optional error message if no context information can be computed

contextInformationClosed

protected void contextInformationClosed()
Callback to signal this content assistant that the presentation of the context information has been stopped.

Since:
2.1

requestWidgetToken

public boolean requestWidgetToken(IWidgetTokenOwner owner)
Description copied from interface: IWidgetTokenKeeper
The given widget token owner requests the widget token from this token keeper. Returns 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).

Specified by:
requestWidgetToken in interface IWidgetTokenKeeper
Parameters:
owner - the token owner
Returns:
true if token has been released false otherwise

requestWidgetToken

public boolean requestWidgetToken(IWidgetTokenOwner owner,
                                  int priority)
Description copied from interface: IWidgetTokenKeeperExtension
The given widget token owner requests the widget token from this token keeper. Returns 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.

Specified by:
requestWidgetToken in interface IWidgetTokenKeeperExtension
Parameters:
owner - the token owner
priority - the priority of the request
Returns:
true if token has been released false otherwise

setFocus

public boolean setFocus(IWidgetTokenOwner owner)
Description copied from interface: IWidgetTokenKeeperExtension
Requests 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:
setFocus in interface IWidgetTokenKeeperExtension
Parameters:
owner - the token owner
Returns:
true if the receiver tried to take focus, false if it did not.

hide

protected void hide()
Hides any open pop-ups.

Since:
3.0

setRestoreCompletionProposalSize

public 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.

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:

Parameters:
dialogSettings -
Since:
3.0

storeCompletionProposalPopupSize

protected void storeCompletionProposalPopupSize()
Stores the content assist pop-up's size.


restoreCompletionProposalPopupSize

protected Point restoreCompletionProposalPopupSize()
Restores the content assist pop-up's size.

Returns:
the stored size
Since:
3.0

enablePrefixCompletion

public void enablePrefixCompletion(boolean enabled)
Sets the prefix completion property. If enabled, content assist delegates completion to prefix completion.

Parameters:
enabled - true to enable prefix completion, false to disable

hasProposalPopupFocus

public boolean hasProposalPopupFocus()
Returns whether the content assistant proposal popup has the focus.

Returns:
true if the proposal popup has the focus
Since:
3.0

Eclipse Platform
Release 3.0

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.