Package org.fife.ui.autocomplete
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 class
Called when the user types the character marking the closing of the parameter list, such as ')
'.private class
Called when the user presses Enter while entering parameters.private class
Action performed when the user hits the escape key.private class
Listens for various events in the text component while this tool tip is visible.private class
Action performed when the user presses the up or down arrow keys and the parameter completion choices popup is visible.private class
Action performed when the user hits the tab key.private static class
Information about a parameter.private class
Action performed when the user hits shift+tab. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AutoCompletion
The parent AutoCompletion instance.private boolean
Whether parameterized completion assistance is active.private Position
private Highlighter.HighlightPainter
private boolean
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private int
The currently "selected" parameter in the displayed text.Listens for events in the text component while this window is visible.private Position
The maximum offset into the document that the caret can move to before this tool tip disappears.private int
The minimum offset into the document that the caret can move to before this tool tip disappears.private Action
private Object
private Action
private Object
private Action
private Object
private Action
private Object
private Action
private Object
private Action
private Object
private Action
private Object
private Highlighter.HighlightPainter
The painter to paint borders around the variables.A small popup window giving likely choices for parameterized completions.private Highlighter.HighlightPainter
private String
The text before the caret for the current parameter.private Window
The parent window.private ParameterizedCompletion
The 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 TypeMethodDescriptionvoid
activate()
Activates parameter completion support.Creates the completion window offering suggestions for parameters.void
Hides any popup windows and terminates parameterized completion assistance.getArgumentText
(int offs) Returns the text inserted for the parameter containing the specified offset.private Highlighter.Highlight
Returns the highlight of the current parameter.private int
private int
Returns the starting offset of the current parameter.private static int
getFirstHighlight
(List<Highlighter.Highlight> highlights) Returns the highlight from a list that comes "first" in a list.private static int
getLastHighlight
(List<Highlighter.Highlight> highlights) Returns the highlight from a list that comes "last" in that list.(package private) boolean
Inserts the choice selected in the parameter choices window.private void
Installs key bindings on the text component that facilitate the user editing this completion's parameters.private void
Moves to and selects the next parameter.private void
Moves to and selects the previous parameter.private void
private void
Updates the optional window listing likely completion choices.private void
Removes the bounding boxes around parameters.private Highlighter.Highlight
replaceHighlightedText
(Document doc, Highlighter.Highlight h, String replacement) Replaces highlighted text with new text.private void
Removes the key bindings we installed.private String
Updates the text in the tool tip to have the current parameter displayed in bold.private void
updateToolTipText
(int selectedParam) void
updateUI()
Updates theLookAndFeel
of 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
The tags for the highlights around parameters. -
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. IfparamChoicesWindow
is 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
null
if the offset is not in a parameter.
-
getCurrentParameterHighlight
Returns the highlight of the current parameter.- Returns:
- The current parameter's highlight, or
null
if 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
-1
if 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
false
if 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'sHighlight
classes 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 theLookAndFeel
of all popup windows this context manages.
-