oracle.javatools.ui.completion
Class CompletionPopupHandler

CompletionPopupHandler is a general class providing the ability to display a completion list over a text component. In many ways, this behaves like the code insight support provided by the code editor

The completion provided by the field is configured via one or more pluggable CompletionProvider instances. Each insight provider describes when to trigger insight, which items appear in the insight list for a given position in the field, how to complete insight when requested by the user, and how items in the insight list should appear.

It's acceptible to register multiple CompletionProviders with a CompletionPopupHandler. Each provider will be queried in turn whenever a character is typed into the field.

CompletionPopupHandler

public CompletionPopupHandler(javax.swing.text.JTextComponent textComponent)

Method Detail

getTextComponent

public final javax.swing.text.JTextComponent getTextComponent()

Get the text component this handler is handling.

Returns:

the text component this handler is handling.

getInsightList

public javax.swing.JComponent getInsightList()

acquireInsightLock

public final void acquireInsightLock()

Acquire a lock on the insight popup. While the lock is held, the popup will not be displayed.

yieldInsightLock

public final void yieldInsightLock()

Release a lock on the insight popup.

getCompletionBackground

public final java.awt.Color getCompletionBackground()

Returns the background color for the completion popup list.

setCompletionBackground

public final void setCompletionBackground(java.awt.Color insightBackground)

Sets the background color for the completion popup list.

setAlignWithField

public final void setAlignWithField(boolean isAlignWithField)

Set whether the insight popup of the component should be left aligned with the text component. The default value of this property is false, and the insight popup will appear in a location close to the caret.

Parameters:

isAlignWithField - if true, the popup will be left aligned with the text component.

isAlignWithField

public final boolean isAlignWithField()

Get whether the insight popup of the component should be left aligned with the text component. The default value of this property is false, and the insight popup will appear in a location close to the caret.

Returns:

true if the popup is left aligned with the text component.

setWidthOfField

public final void setWidthOfField(boolean isWidthOfField)

Set whether the drop down list for the component will be automatically adjusted so that it is at least as wide as the text component. If set false, the drop down list will always use its preferred width regardless of the width of the text component.

Parameters:

isWidthOfField - if true, the drop down list width will always be at least the width of the component.

isWidthOfField

public final boolean isWidthOfField()

Get whether the drop down list for the component will be automatically adjusted so that it is at least as wide as the text component. If set false, the drop down list will always use its preferred width regardless of the width of the text component.

Returns:

if true, the drop down list width will always be at least the width of the component.

setWidthConstrained

public final void setWidthConstrained(boolean isWidthConstrained)

Set whether the width of the popup for the component should be constrained to the component width,

Parameters:

isWidthConstrained - if true, the drop down list width will always be no wider than the component.

isWidthConstrained

public final boolean isWidthConstrained()

Get whether the width of the popup for the component should be constrained to the component width,

Returns:

if true, the drop down list width will always be no wider than the component.

isInsightVisible

getVerticalPopupOffset

protected int getVerticalPopupOffset(java.awt.Component component)

Get the vertical offset (from the top of the component) of the popup window. This implementation returns component.getHeight(), which causes the popup to appear underneath the component. Subclasses may override this to change the vertical position of the popup.

Parameters:

component - the component the popup is appearing for. If the component is in a scroll pane, this may be the scrollpane viewport.

Returns:

the vertical location of the top of the popup. 0 would align the top of the popup with the top of the component.