LPEX
4.4.0

com.ibm.lpex.alef.contentassist
Class ContentAssistant

java.lang.Object
  extended by com.ibm.lpex.alef.contentassist.ContentAssistant
All Implemented Interfaces:
IContentAssistant

public class ContentAssistant
extends Object
implements IContentAssistant

An LPEX-based implementation of the IContentAssistant interface. Usually, clients instantiate this class and configure it before using it.


Field Summary
static int LAYOUT_CONTEXT_INFO_POPUP
          The presentation type for the context information hover .
static int LAYOUT_CONTEXT_SELECTOR
          The presentation type for the context selection popup.
static int LAYOUT_PROPOSAL_SELECTOR
          The presentation type for the proposal selection popup.
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 popups.
 
Fields inherited from interface com.ibm.lpex.alef.contentassist.IContentAssistant
CONTEXT_INFO_ABOVE, CONTEXT_INFO_BELOW, PROPOSAL_OVERLAY, PROPOSAL_REMOVE, PROPOSAL_STACKED
 
Constructor Summary
ContentAssistant()
          Create a new content assistant.
 
Method Summary
protected  void contextInformationClosed()
          Callback to signal this content assistant that the presentation of the context information has been stopped.
 void disposeLpexView(LpexView lpexView)
          Called when a view on the document of our viewer is being disposed.
 void enableAutoActivation(boolean enabled)
          Enable the content assistant's auto activation mode.
 void enableAutoInsert(boolean enabled)
          Enable the content assistant's auto insertion mode.
 IContentAssistProcessor getContentAssistProcessor(String contentType)
          Return the content assist processor which was registered 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 popups.
 void install(ITextViewer textViewer)
          Install content-assist support on the given LpexTextViewer.
 void newLpexView(LpexView lpexView)
          Called when a new view was opened on the document of our viewer.
 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.
 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)
          Register a given content assist processor for a particular content type.
 void setContextInformationPopupBackground(Color background)
          Set the context information popup's background color.
 void setContextInformationPopupForeground(Color foreground)
          Set the context information popup's foreground color.
 void setContextInformationPopupOrientation(int orientation)
          Set the context information popup's orientation.
 void setContextSelectorBackground(Color background)
          Set the context selector's background color.
 void setContextSelectorForeground(Color foreground)
          Set the context selector's foreground color.
 void setDocumentPartitioning(String partitioning)
          Sets the document partitioning this content assistant is using.
 void setInformationControlCreator(IInformationControlCreator creator)
          Set the information control creator for the additional information control.
 void setProposalPopupOrientation(int orientation)
          Set the proposal popups' orientation.
 void setProposalSelectorBackground(Color background)
          Set the proposal selector's background color.
 void setProposalSelectorForeground(Color foreground)
          Set the proposal's foreground color.
 String showContextInformation()
          Show context information for the content at the viewer's cursor position.
 String showPossibleCompletions()
          Show all possible completions of the content at the viewer's cursor position.
 String showProposals(boolean autoActivated)
          Bring up the proposals window.
 void uninstall()
          Uninstall content-assist support from the text viewer it was previously 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.

See Also:
Constant Field Values

STORE_SIZE_Y

public static final String STORE_SIZE_Y
See Also:
Constant Field Values

LAYOUT_PROPOSAL_SELECTOR

public static final int LAYOUT_PROPOSAL_SELECTOR
The presentation type for the proposal selection popup.

See Also:
Constant Field Values

LAYOUT_CONTEXT_SELECTOR

public static final int LAYOUT_CONTEXT_SELECTOR
The presentation type for the context selection popup.

See Also:
Constant Field Values

LAYOUT_CONTEXT_INFO_POPUP

public static final int LAYOUT_CONTEXT_INFO_POPUP
The presentation type for the context information hover .

See Also:
Constant Field Values

WIDGET_PRIORITY

public static final int WIDGET_PRIORITY
The popup priority: > linked position proposals and hover popups. Default value: 20.

See Also:
Constant Field Values
Constructor Detail

ContentAssistant

public ContentAssistant()
Create 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 500ms 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

getDocumentPartitioning

public String getDocumentPartitioning()
Returns the document partitioning this content assistant is using.

Returns:
the document partitioning this content assistant is using
See Also:
IContentAssistantExtension

setContentAssistProcessor

public void setContentAssistProcessor(IContentAssistProcessor processor,
                                      String contentType)
Register 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. Use the document-parser language, as defined in LpexCommonParser.getLanguage(LpexDocumentLocation), as content type.

Parameters:
processor - the content assist processor to register, or null to remove an existing one
contentType - the document content type under which to register

getContentAssistProcessor

public IContentAssistProcessor getContentAssistProcessor(String contentType)
Return the content assist processor which was registered 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
See Also:
setContentAssistProcessor(com.ibm.lpex.alef.contentassist.IContentAssistProcessor, java.lang.String)

enableAutoActivation

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

Parameters:
enabled - indicates whether auto activation should be enabled or not

enableAutoInsert

public void enableAutoInsert(boolean enabled)
Enable 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 should be enabled or not

newLpexView

public void newLpexView(LpexView lpexView)
Called when a new view was opened on the document of our viewer. Add our autoactivation key listener to it.


disposeLpexView

public void disposeLpexView(LpexView lpexView)
Called when a view on the document of our viewer is being disposed. Remove our autoactivation key listener from it.


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 (as of 3.6 a negative argument will be set to 0)

setProposalPopupOrientation

public void setProposalPopupOrientation(int orientation)
Set the proposal popups' orientation. The following values may be used:

Parameters:
orientation - the popup's orientation

setContextInformationPopupOrientation

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

Parameters:
orientation - the popup's orientation

setContextInformationPopupBackground

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


setContextInformationPopupForeground

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


setProposalSelectorBackground

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


setProposalSelectorForeground

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


setContextSelectorBackground

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


setContextSelectorForeground

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


setInformationControlCreator

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


install

public void install(ITextViewer textViewer)
Description copied from interface: IContentAssistant
Install content-assist support on the given LpexTextViewer.

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

uninstall

public void uninstall()
Description copied from interface: IContentAssistant
Uninstall content-assist support from the text viewer it was previously installed on.

Specified by:
uninstall in interface IContentAssistant

showPossibleCompletions

public String showPossibleCompletions()
Show all possible completions of the content at the viewer's cursor position. Called by LpexSourceViewer#doOperation() on the registered ContentAssistant, when an action defined with the operation code ISourceViewer.CONTENTASSIST_PROPOSALS is explicitly selected by the user.

The implementation of this method calls showProposals(false).

Specified by:
showPossibleCompletions in interface IContentAssistant
Returns:
an optional error message if no proposals can be computed
See Also:
IContentAssistant.showPossibleCompletions()

showProposals

public String showProposals(boolean autoActivated)
Bring up the proposals window. Shows all the possible completions of the content at the viewer's cursor position.

Called:

Since:
LPEX 3.0.0

contextInformationClosed

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


showContextInformation

public String showContextInformation()
Show context information for the content at the viewer's cursor position. Called by LpexSourceViewer#doOperation() on the registered ContentAssistant, when an action defined with the operation code ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION is selected.

Specified by:
showContextInformation in interface IContentAssistant
Returns:
an optional error message if no context information can be computed
See Also:
IContentAssistant.showContextInformation()

requestWidgetToken

public boolean requestWidgetToken(IWidgetTokenOwner owner)
The given widget token owner requests the widget token from this token keeper. The default implementation of this method does nothing except return false (the token has not been released).

See Also:
IWidgetTokenKeeper

requestWidgetToken

public boolean requestWidgetToken(IWidgetTokenOwner owner,
                                  int priority)
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.

See Also:
IWidgetTokenKeeperExtension

hide

protected void hide()
Hides any open popups.


hasProposalPopupFocus

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

Returns:
true if the proposal popup has the focus

LPEX
4.4.0

Copyright � 2016 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.