de.matthiasmann.twl
Class EditFieldAutoCompletionWindow

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.Container
          extended by de.matthiasmann.twl.InfoWindow
              extended by de.matthiasmann.twl.EditFieldAutoCompletionWindow

public class EditFieldAutoCompletionWindow
extends InfoWindow


Nested Class Summary
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
EditFieldAutoCompletionWindow(EditField editField)
          Creates an EditFieldAutoCompletionWindow associated with the specified EditField.
EditFieldAutoCompletionWindow(EditField editField, AutoCompletionDataSource dataSource)
          Creates an EditFieldAutoCompletionWindow associated with the specified EditField.
EditFieldAutoCompletionWindow(EditField editField, AutoCompletionDataSource dataSource, java.util.concurrent.ExecutorService executorService)
          Creates an EditFieldAutoCompletionWindow associated with the specified EditField.
 
Method Summary
 AutoCompletionDataSource getDataSource()
          Returns the current data source
 EditField getEditField()
          Returns the EditField to which this EditFieldAutoCompletionWindow is attached
 java.util.concurrent.ExecutorService getExecutorService()
          Returns the current ExecutorService
protected  boolean handleEvent(Event evt)
          Called when an event occurred that this widget could be interested in.
protected  void infoWindowClosed()
          Called after the info window has been closed
 boolean isUseInvokeAsync()
          Returns true if GUI.invokeAsync(java.util.concurrent.Callable, de.matthiasmann.twl.GUI.AsyncCompletionListener) is used
protected  void reportQueryException(java.lang.Throwable ex)
           
 void setDataSource(AutoCompletionDataSource dataSource)
          Sets a new data source.
 void setExecutorService(java.util.concurrent.ExecutorService executorService)
          Sets the ExecutorService which is used to perform async queries on the AutoCompletionDataSource.
 void setUseInvokeAsync(boolean useInvokeAsync)
          Perform async queries on the AutoCompletionDataSource using GUI.invokeAsync(java.util.concurrent.Callable, de.matthiasmann.twl.GUI.AsyncCompletionListener) This will set executorService to null.
 void stopAutoCompletion()
          Stops the auto completion.
 void updateAutoCompletion()
          This will update the auto completion and open the info window when results are available
protected  void updateAutoCompletion(AutoCompletionResult results)
           
 
Methods inherited from class de.matthiasmann.twl.InfoWindow
closeInfo, getOwner, isOpen, openInfo
 
Methods inherited from class de.matthiasmann.twl.Container
getMinHeight, getMinWidth, getPreferredInnerHeight, getPreferredInnerWidth, layout
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, afterAddToGUI, allChildrenRemoved, applyTheme, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, beforeRemoveFromGUI, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, destroy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredHeight, getPreferredWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, paintWidget, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, sizeChanged, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditFieldAutoCompletionWindow

public EditFieldAutoCompletionWindow(EditField editField)
Creates an EditFieldAutoCompletionWindow associated with the specified EditField. Auto completion will start to work once a data source is set

Parameters:
editField - the EditField to which auto completion should be applied

EditFieldAutoCompletionWindow

public EditFieldAutoCompletionWindow(EditField editField,
                                     AutoCompletionDataSource dataSource)
Creates an EditFieldAutoCompletionWindow associated with the specified EditField. Auto completion is operational with the given data source (when it's not null)

Parameters:
editField - the EditField to which auto completion should be applied
dataSource - the data source used for auto completion - can be null

EditFieldAutoCompletionWindow

public EditFieldAutoCompletionWindow(EditField editField,
                                     AutoCompletionDataSource dataSource,
                                     java.util.concurrent.ExecutorService executorService)
Creates an EditFieldAutoCompletionWindow associated with the specified EditField. Auto completion is operational with the given data source (when it's not null)

Parameters:
editField - the EditField to which auto completion should be applied
dataSource - the data source used for auto completion - can be null
executorService - the executorService used to execute the data source queries
See Also:
setExecutorService(java.util.concurrent.ExecutorService)
Method Detail

getEditField

public final EditField getEditField()
Returns the EditField to which this EditFieldAutoCompletionWindow is attached

Returns:
the EditField

getExecutorService

public java.util.concurrent.ExecutorService getExecutorService()
Returns the current ExecutorService

Returns:
the current ExecutorService

isUseInvokeAsync

public boolean isUseInvokeAsync()
Returns true if GUI.invokeAsync(java.util.concurrent.Callable, de.matthiasmann.twl.GUI.AsyncCompletionListener) is used

Returns:
true if GUI.invokeAsync is used

setExecutorService

public void setExecutorService(java.util.concurrent.ExecutorService executorService)
Sets the ExecutorService which is used to perform async queries on the AutoCompletionDataSource. This will disable the use of GUI.invokeAsync(java.util.concurrent.Callable, de.matthiasmann.twl.GUI.AsyncCompletionListener) If it is null then all queries are done synchronously from the EditField callback. This is good as long as data source is very fast (eg small in memory tables). When the data source quries take too long they will impact the UI responsiveness. To prevent that the queries can be executed in another thread. This requires the data source and results to be thread save.

Parameters:
executorService - the ExecutorService or null
See Also:
setUseInvokeAsync(boolean)

setUseInvokeAsync

public void setUseInvokeAsync(boolean useInvokeAsync)
Perform async queries on the AutoCompletionDataSource using GUI.invokeAsync(java.util.concurrent.Callable, de.matthiasmann.twl.GUI.AsyncCompletionListener) This will set executorService to null. If it is false then all queries are done synchronously from the EditField callback. This is good as long as data source is very fast (eg small in memory tables). When the data source quries take too long they will impact the UI responsiveness. To prevent that the queries can be executed in another thread. This requires the data source and results to be thread save.

Parameters:
useInvokeAsync - true if invokeAsync should be used
See Also:
setExecutorService(java.util.concurrent.ExecutorService)

getDataSource

public AutoCompletionDataSource getDataSource()
Returns the current data source

Returns:
the current data source

setDataSource

public void setDataSource(AutoCompletionDataSource dataSource)
Sets a new data source. If the info window is currently open, then the displayed auto completion will be refreshed. If you also need to change the ExecutorService then it's adviced to do that first.

Parameters:
dataSource - the new AutoCompletionDataSource - can be null

updateAutoCompletion

public void updateAutoCompletion()
This will update the auto completion and open the info window when results are available


stopAutoCompletion

public void stopAutoCompletion()
Stops the auto completion. Closes the infow window and discards the collected results.


infoWindowClosed

protected void infoWindowClosed()
Description copied from class: InfoWindow
Called after the info window has been closed

Overrides:
infoWindowClosed in class InfoWindow

updateAutoCompletion

protected void updateAutoCompletion(AutoCompletionResult results)

reportQueryException

protected void reportQueryException(java.lang.Throwable ex)

handleEvent

protected boolean handleEvent(Event evt)
Description copied from class: Widget
Called when an event occurred that this widget could be interested in.

The default implementation handles only keyboard events and delegates them to the child widget which has keyboard focus. If focusKey handling is enabled then this widget cycles the keyboard focus through it's children. If the key was not consumed by a child or focusKey and an inputMap is specified then the event is translated by the InputMap and handleKeyStrokeAction is called when a mapping was found.

If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.

Overrides:
handleEvent in class Widget
Parameters:
evt - The event - do not store this object - it may be reused
Returns:
true if the widget handled this event
See Also:
Widget.setFocusKeyEnabled(boolean), Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event), Widget.setInputMap(de.matthiasmann.twl.InputMap)