Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

oracle.javatools.controls.completionfield
Class CompletionPopupHandler

java.lang.Object
  extended by oracle.javatools.controls.completionfield.CompletionPopupHandler

public class CompletionPopupHandler
extends java.lang.Object

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 FieldInsightProvider 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 FieldInsightProviders with a CompletionPopupHandler. Each provider will be queried in turn whenever a character is typed into the field.


Field Summary
static java.lang.String SHOW_INSIGHT_ACTION_NAME
          The action to trigger display of insight in the ActionMap of this component.
 
Constructor Summary
CompletionPopupHandler(javax.swing.text.JTextComponent textComponent)
           
 
Method Summary
 void acquireInsightLock()
          Acquire a lock on the insight popup.
 java.awt.Color getCompletionBackground()
          Returns the background color for the completion popup list.
 java.awt.Component getInsightList()
           
 javax.swing.text.JTextComponent getTextComponent()
          Get the text component this handler is handling.
protected  int getVerticalPopupOffset(java.awt.Component component)
          Get the vertical offset (from the top of the component) of the popup window.
 int getVisibleRowCount()
          Get the visible row count of the list in the popup.
 boolean isAlignWithField()
          Get whether the insight popup of the component should be left aligned with the text component.
 boolean isInsightVisible()
          Determine whether the insight list is currently visible.
 boolean isRegisteredInsightProvider(FieldInsightProvider provider)
          Ask whether a given insight provider is registered.
 boolean isWidthConstrained()
          Get whether the width of the popup for the component should be constrained to the component width,
 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.
 void registerInsightProvider(FieldInsightProvider provider)
          Register an insight provider with this field.
 void setAlignWithField(boolean isAlignWithField)
          Set whether the insight popup of the component should be left aligned with the text component.
 void setCompletionBackground(java.awt.Color insightBackground)
          Sets the background color for the completion popup list.
 void setInsightVisible(boolean isVisible)
          Programmatically show or hide the insight list.
 void setVisibleRowCount(int visibleRowCount)
          Set the visible row count of the list in the popup.
 void setWidthConstrained(boolean isWidthConstrained)
          Set whether the width of the popup for the component should be constrained to the component width,
 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.
 void unregisterInsightProvider(FieldInsightProvider provider)
          Unregister an insight provider from the field.
 void yieldInsightLock()
          Release a lock on the insight popup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_INSIGHT_ACTION_NAME

public static final java.lang.String SHOW_INSIGHT_ACTION_NAME
The action to trigger display of insight in the ActionMap of this component. You can override the default keybinding for this action using code like this:
   CompletionTextField field = new CompletionTextField();
   field.getInputMap().put( KeyStroke.getKeyStroke( "control pressed SPACE" ),
     CompletionPopupHandler.SHOW_INSIGHT_ACTION_NAME );
 

See Also:
Constant Field Values
Constructor Detail

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 java.awt.Component 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.

setVisibleRowCount

public final void setVisibleRowCount(int visibleRowCount)
Set the visible row count of the list in the popup.

Parameters:
visibleRowCount - the row count value.

getVisibleRowCount

public final int getVisibleRowCount()
Get the visible row count of the list in the popup.

Returns:
the row count value.

registerInsightProvider

public final void registerInsightProvider(FieldInsightProvider provider)
Register an insight provider with this field.

Parameters:
provider - the insight provider to register with the field.

unregisterInsightProvider

public final void unregisterInsightProvider(FieldInsightProvider provider)
Unregister an insight provider from the field.

Parameters:
provider - the provider to unregister.

isRegisteredInsightProvider

public final boolean isRegisteredInsightProvider(FieldInsightProvider provider)
Ask whether a given insight provider is registered.

Parameters:
provider - the provider.
Returns:
a verdict on whether the provider is registered.

setInsightVisible

public final void setInsightVisible(boolean isVisible)
Programmatically show or hide the insight list.

Parameters:
isVisible - param isVisible whether the insight list should be visible

isInsightVisible

public final boolean isInsightVisible()
Determine whether the insight list is currently visible.

Returns:
true if the insight list is currently visible.

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.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.