Class ParameterizedCompletionContext
java.lang.Object
org.fife.ui.autocomplete.ParameterizedCompletionContext
Manages UI and state specific to parameterized completions - the parameter
description tool tip, the parameter completion choices list, the actual
highlights in the editor, etc. This component installs new key bindings
when appropriate to allow the user to cycle through the parameters of the
completion, and optionally cycle through completion choices for those
parameters.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classCalled when the user types the character marking the closing of the parameter list, such as ')'.private classCalled when the user presses Enter while entering parameters.private classAction performed when the user hits the escape key.private classListens for various events in the text component while this tool tip is visible.private classAction performed when the user presses the up or down arrow keys and the parameter completion choices popup is visible.private classAction performed when the user hits the tab key.private static classInformation about a parameter.private classAction performed when the user hits shift+tab. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AutoCompletionThe parent AutoCompletion instance.private booleanWhether parameterized completion assistance is active.private Positionprivate Highlighter.HighlightPainterprivate booleanprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate intThe currently "selected" parameter in the displayed text.Listens for events in the text component while this window is visible.private PositionThe maximum offset into the document that the caret can move to before this tool tip disappears.private intThe minimum offset into the document that the caret can move to before this tool tip disappears.private Actionprivate Objectprivate Actionprivate Objectprivate Actionprivate Objectprivate Actionprivate Objectprivate Actionprivate Objectprivate Actionprivate Objectprivate Actionprivate Objectprivate Highlighter.HighlightPainterThe painter to paint borders around the variables.A small popup window giving likely choices for parameterized completions.private Highlighter.HighlightPainterprivate StringThe text before the caret for the current parameter.private WindowThe parent window.private ParameterizedCompletionThe completion being described.The tags for the highlights around parameters.A tool tip displaying the currently edited parameter name and type. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activates parameter completion support.Creates the completion window offering suggestions for parameters.voidHides any popup windows and terminates parameterized completion assistance.getArgumentText(int offs) Returns the text inserted for the parameter containing the specified offset.private Highlighter.HighlightReturns the highlight of the current parameter.private intprivate intReturns the starting offset of the current parameter.private static intgetFirstHighlight(List<Highlighter.Highlight> highlights) Returns the highlight from a list that comes "first" in a list.private static intgetLastHighlight(List<Highlighter.Highlight> highlights) Returns the highlight from a list that comes "last" in that list.(package private) booleanInserts the choice selected in the parameter choices window.private voidInstalls key bindings on the text component that facilitate the user editing this completion's parameters.private voidMoves to and selects the next parameter.private voidMoves to and selects the previous parameter.private voidprivate voidUpdates the optional window listing likely completion choices.private voidRemoves the bounding boxes around parameters.private Highlighter.HighlightreplaceHighlightedText(Document doc, Highlighter.Highlight h, String replacement) Replaces highlighted text with new text.private voidRemoves the key bindings we installed.private StringUpdates the text in the tool tip to have the current parameter displayed in bold.private voidupdateToolTipText(int selectedParam) voidupdateUI()Updates theLookAndFeelof all popup windows this context manages.
-
Field Details
-
parentWindow
The parent window. -
ac
The parent AutoCompletion instance. -
pc
The completion being described. -
active
private boolean activeWhether parameterized completion assistance is active. -
tip
A tool tip displaying the currently edited parameter name and type. -
p
The painter to paint borders around the variables. -
endingP
-
paramCopyP
-
tags
-
paramCopyInfos
-
ignoringDocumentEvents
private transient boolean ignoringDocumentEvents -
listener
Listens for events in the text component while this window is visible. -
minPos
private int minPosThe minimum offset into the document that the caret can move to before this tool tip disappears. -
maxPos
The maximum offset into the document that the caret can move to before this tool tip disappears. -
defaultEndOffs
-
lastSelectedParam
private int lastSelectedParamThe currently "selected" parameter in the displayed text. -
paramChoicesWindow
A small popup window giving likely choices for parameterized completions. -
paramPrefix
The text before the caret for the current parameter. IfparamChoicesWindowis non-null, this is used to determine what parameter choices to actually show. -
oldTabKey
-
oldTabAction
-
oldShiftTabKey
-
oldShiftTabAction
-
oldUpKey
-
oldUpAction
-
oldDownKey
-
oldDownAction
-
oldEnterKey
-
oldEnterAction
-
oldEscapeKey
-
oldEscapeAction
-
oldClosingKey
-
oldClosingAction
-
IM_KEY_TAB
- See Also:
-
IM_KEY_SHIFT_TAB
- See Also:
-
IM_KEY_UP
- See Also:
-
IM_KEY_DOWN
- See Also:
-
IM_KEY_ESCAPE
- See Also:
-
IM_KEY_ENTER
- See Also:
-
IM_KEY_CLOSING
- See Also:
-
-
Constructor Details
-
ParameterizedCompletionContext
ParameterizedCompletionContext(Window owner, AutoCompletion ac, ParameterizedCompletion pc) Constructor.
-
-
Method Details
-
activate
public void activate()Activates parameter completion support.- See Also:
-
createParamChoicesWindow
Creates the completion window offering suggestions for parameters.- Returns:
- The window.
-
deactivate
public void deactivate()Hides any popup windows and terminates parameterized completion assistance.- See Also:
-
getArgumentText
Returns the text inserted for the parameter containing the specified offset.- Parameters:
offs- The offset into the document.- Returns:
- The text of the parameter containing the offset, or
nullif the offset is not in a parameter.
-
getCurrentParameterHighlight
Returns the highlight of the current parameter.- Returns:
- The current parameter's highlight, or
nullif the caret is not in a parameter's bounds. - See Also:
-
getCurrentParameterIndex
private int getCurrentParameterIndex() -
getCurrentParameterStartOffset
private int getCurrentParameterStartOffset()Returns the starting offset of the current parameter.- Returns:
- The current parameter's starting offset, or
-1if the caret is not in a parameter's bounds. - See Also:
-
getFirstHighlight
Returns the highlight from a list that comes "first" in a list. Even though most parameter highlights are ordered, sometimes they aren't (e.g. the "cursor" parameter in a template completion is always last, even though it can be anywhere in the template).- Parameters:
highlights- The list of highlights. Assumed to be non-empty.- Returns:
- The highlight that comes first in the document.
- See Also:
-
getLastHighlight
Returns the highlight from a list that comes "last" in that list. Even though most parameter highlights are ordered, sometimes they aren't (e.g. the "cursor" parameter in a template completion is always last, even though it can be anywhere in the template).- Parameters:
highlights- The list of highlights. Assumed to be non-empty.- Returns:
- The highlight that comes last in the document.
- See Also:
-
getParameterHighlights
-
insertSelectedChoice
boolean insertSelectedChoice()Inserts the choice selected in the parameter choices window.- Returns:
- Whether the choice was inserted. This will be
falseif the window is not visible, or no choice is selected.
-
installKeyBindings
private void installKeyBindings()Installs key bindings on the text component that facilitate the user editing this completion's parameters.- See Also:
-
moveToNextParam
private void moveToNextParam()Moves to and selects the next parameter.- See Also:
-
moveToPreviousParam
private void moveToPreviousParam()Moves to and selects the previous parameter.- See Also:
-
possiblyUpdateParamCopies
-
prepareParamChoicesWindow
private void prepareParamChoicesWindow()Updates the optional window listing likely completion choices. -
removeParameterHighlights
private void removeParameterHighlights()Removes the bounding boxes around parameters. -
replaceHighlightedText
private Highlighter.Highlight replaceHighlightedText(Document doc, Highlighter.Highlight h, String replacement) Replaces highlighted text with new text. Takes special care so that the highlight stays just around the newly-highlighted text, since Swing'sHighlightclasses are funny about insertions at their start offsets.- Parameters:
doc- The document.h- The highlight whose text to change.replacement- The new text to be in the highlight.- Returns:
- The replacement highlight for
h.
-
uninstallKeyBindings
private void uninstallKeyBindings()Removes the key bindings we installed.- See Also:
-
updateToolTipText
Updates the text in the tool tip to have the current parameter displayed in bold. The "current parameter" is determined from the current caret position.- Returns:
- The "prefix" of text in the caret's parameter before the caret.
-
updateToolTipText
private void updateToolTipText(int selectedParam) -
updateUI
public void updateUI()Updates theLookAndFeelof all popup windows this context manages.
-