public class AutoCompletion
extends java.lang.Object
Depending on the CompletionProvider
installed, the following
auto-completion features may be enabled:
构造器和说明 |
---|
AutoCompletion(CompletionProvider provider)
Constructor.
|
限定符和类型 | 方法和说明 |
---|---|
void |
doCompletion()
Displays the popup window.
|
int |
getAutoActivationDelay()
Returns the delay between when the user types a character and when the
code completion popup should automatically appear (if applicable).
|
CompletionProvider |
getCompletionProvider()
Returns the completion provider.
|
static javax.swing.KeyStroke |
getDefaultTriggerKey()
Returns the default auto-complete "trigger key" for this OS.
|
ExternalURLHandler |
getExternalURLHandler()
Returns the handler to use when an external URL is clicked in the
description window.
|
static LinkRedirector |
getLinkRedirector()
Returns the link redirector, if any.
|
javax.swing.ListCellRenderer |
getListCellRenderer()
Returns the default list cell renderer used when a completion provider
does not supply its own.
|
javax.swing.ListCellRenderer |
getParamChoicesRenderer()
Returns the renderer to use for
Completion s in the optional
parameter choices popup window (displayed when a
ParameterizedCompletion is code-completed). |
protected java.lang.String |
getReplacementText(Completion c,
javax.swing.text.Document doc,
int start,
int len)
Returns the text to replace with in the document.
|
static AutoCompletionStyleContext |
getStyleContext()
Returns the style context describing how auto-completion related
highlights in the editor are rendered.
|
javax.swing.text.JTextComponent |
getTextComponent()
Returns the text component for which auto-completion is enabled.
|
javax.swing.KeyStroke |
getTriggerKey()
Returns the "trigger key" used for auto-complete.
|
boolean |
hideChildWindows()
Hides any child windows being displayed by the auto-completion system.
|
protected void |
insertCompletion(Completion c)
Inserts a completion.
|
protected void |
insertCompletion(Completion c,
boolean typedParamListStartChar)
Inserts a completion.
|
void |
install(javax.swing.text.JTextComponent c)
Installs this auto-completion on a text component.
|
boolean |
isAutoActivationEnabled()
Returns whether auto-activation is enabled (that is, whether the
completion popup will automatically appear after a delay when the user
types an appropriate character).
|
boolean |
isAutoCompleteEnabled()
Returns whether auto-completion is enabled.
|
boolean |
isAutoCompleteSingleChoices()
Returns whether, if a single auto-complete choice is available, it
should be automatically inserted, without displaying the popup menu.
|
boolean |
isParameterAssistanceEnabled()
Returns whether parameter assistance is enabled.
|
boolean |
isPopupVisible()
Returns whether the completion popup window is visible.
|
boolean |
isShowDescWindow()
Returns whether the "description window" should be shown alongside
the completion window.
|
protected int |
refreshPopupWindow()
Refreshes the popup window.
|
void |
setAutoActivationDelay(int ms)
Sets the delay between when the user types a character and when the
code completion popup should automatically appear (if applicable).
|
void |
setAutoActivationEnabled(boolean enabled)
Toggles whether auto-activation is enabled.
|
void |
setAutoCompleteEnabled(boolean enabled)
Sets whether auto-completion is enabled.
|
void |
setAutoCompleteSingleChoices(boolean autoComplete)
Sets whether, if a single auto-complete choice is available, it should
be automatically inserted, without displaying the popup menu.
|
void |
setChoicesWindowSize(int w,
int h)
Sets the size of the completion choices window.
|
void |
setCompletionProvider(CompletionProvider provider)
Sets the completion provider being used.
|
void |
setDescriptionWindowSize(int w,
int h)
Sets the size of the description window.
|
void |
setExternalURLHandler(ExternalURLHandler handler)
Sets the handler to use when an external URL is clicked in the
description window.
|
static void |
setLinkRedirector(LinkRedirector linkRedirector)
Sets the redirector for external URL's found in code completion
documentation.
|
void |
setListCellRenderer(javax.swing.ListCellRenderer renderer)
Sets the default list cell renderer to use when a completion provider
does not supply its own.
|
void |
setParamChoicesRenderer(javax.swing.ListCellRenderer r)
Sets the renderer to use for
Completion s in the optional
parameter choices popup window (displayed when a
ParameterizedCompletion is code-completed). |
void |
setParameterAssistanceEnabled(boolean enabled)
Sets whether parameter assistance is enabled.
|
void |
setShowDescWindow(boolean show)
Sets whether the "description window" should be shown beside the
completion window.
|
void |
setTriggerKey(javax.swing.KeyStroke ks)
Sets the keystroke that should be used to trigger the auto-complete
popup window.
|
void |
uninstall()
Uninstalls this auto-completion from its text component.
|
public AutoCompletion(CompletionProvider provider)
provider
- The completion provider. This cannot be
null
.public void doCompletion()
public int getAutoActivationDelay()
setAutoActivationDelay(int)
public boolean isAutoCompleteSingleChoices()
setAutoCompleteSingleChoices(boolean)
public CompletionProvider getCompletionProvider()
public static javax.swing.KeyStroke getDefaultTriggerKey()
public ExternalURLHandler getExternalURLHandler()
setExternalURLHandler(ExternalURLHandler)
,
getLinkRedirector()
public static LinkRedirector getLinkRedirector()
null
if none.setLinkRedirector(LinkRedirector)
public javax.swing.ListCellRenderer getListCellRenderer()
setListCellRenderer(ListCellRenderer)
public javax.swing.ListCellRenderer getParamChoicesRenderer()
Completion
s in the optional
parameter choices popup window (displayed when a
ParameterizedCompletion
is code-completed). If this returns
null
, a default renderer is used.setParamChoicesRenderer(ListCellRenderer)
,
isParameterAssistanceEnabled()
protected java.lang.String getReplacementText(Completion c, javax.swing.text.Document doc, int start, int len)
c
- The completion being inserted.doc
- The document being modified.start
- The start of the text being replaced.len
- The length of the text being replaced.public boolean isShowDescWindow()
setShowDescWindow(boolean)
public static AutoCompletionStyleContext getStyleContext()
public javax.swing.text.JTextComponent getTextComponent()
null
if this
AutoCompletion
is not installed on any text component.install(JTextComponent)
public javax.swing.KeyStroke getTriggerKey()
setTriggerKey(KeyStroke)
public boolean hideChildWindows()
protected final void insertCompletion(Completion c)
c
- A completion to insert. This cannot be null
.protected void insertCompletion(Completion c, boolean typedParamListStartChar)
c
- A completion to insert. This cannot be null
.typedParamListStartChar
- Whether the parameterized completion
start character was typed (typically '('
).public void install(javax.swing.text.JTextComponent c)
AutoCompletion
is already installed on another text component,
it is uninstalled first.c
- The text component.uninstall()
public boolean isAutoActivationEnabled()
setAutoActivationEnabled(boolean)
,
getAutoActivationDelay()
,
isAutoCompleteEnabled()
public boolean isAutoCompleteEnabled()
setAutoCompleteEnabled(boolean)
public boolean isParameterAssistanceEnabled()
setParameterAssistanceEnabled(boolean)
public boolean isPopupVisible()
protected int refreshPopupWindow()
public void setAutoActivationDelay(int ms)
ms
- The delay, in milliseconds. This should be greater than zero.getAutoActivationDelay()
public void setAutoActivationEnabled(boolean enabled)
enabled
- Whether auto-activation is enabled.isAutoActivationEnabled()
,
setAutoActivationDelay(int)
public void setAutoCompleteEnabled(boolean enabled)
enabled
- Whether auto-completion is enabled.isAutoCompleteEnabled()
public void setAutoCompleteSingleChoices(boolean autoComplete)
autoComplete
- Whether to auto-complete single choices.isAutoCompleteSingleChoices()
public void setCompletionProvider(CompletionProvider provider)
provider
- The new completion provider. This cannot be
null
.java.lang.IllegalArgumentException
- If provider
is
null
.public void setChoicesWindowSize(int w, int h)
w
- The new width.h
- The new height.setDescriptionWindowSize(int, int)
public void setDescriptionWindowSize(int w, int h)
w
- The new width.h
- The new height.setChoicesWindowSize(int, int)
public void setExternalURLHandler(ExternalURLHandler handler)
handler
- The new handler.getExternalURLHandler()
public static void setLinkRedirector(LinkRedirector linkRedirector)
linkRedirector
- The link redirector, or null
for
none.getLinkRedirector()
public void setListCellRenderer(javax.swing.ListCellRenderer renderer)
renderer
- The renderer to use. If this is null
,
a default renderer is used.getListCellRenderer()
public void setParamChoicesRenderer(javax.swing.ListCellRenderer r)
Completion
s in the optional
parameter choices popup window (displayed when a
ParameterizedCompletion
is code-completed). If this isn't set,
a default renderer is used.r
- The renderer to use.getParamChoicesRenderer()
,
setParameterAssistanceEnabled(boolean)
public void setParameterAssistanceEnabled(boolean enabled)
enabled
- Whether parameter assistance should be enabled.isParameterAssistanceEnabled()
public void setShowDescWindow(boolean show)
show
- Whether to show the description window.isShowDescWindow()
public void setTriggerKey(javax.swing.KeyStroke ks)
ks
- The keystroke.java.lang.IllegalArgumentException
- If ks
is null
.getTriggerKey()
public void uninstall()