com.vaadin.terminal.gwt.client.ui.combobox
Class VFilterSelect

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by com.vaadin.terminal.gwt.client.ui.combobox.VFilterSelect
All Implemented Interfaces:
com.google.gwt.event.dom.client.BlurHandler, com.google.gwt.event.dom.client.ClickHandler, com.google.gwt.event.dom.client.FocusHandler, com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.KeyUpHandler, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.EventHandler, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.IsRenderable, com.google.gwt.user.client.ui.IsWidget, Focusable, Field, SubPartAware

public class VFilterSelect
extends com.google.gwt.user.client.ui.Composite
implements Field, com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.KeyUpHandler, com.google.gwt.event.dom.client.ClickHandler, com.google.gwt.event.dom.client.FocusHandler, com.google.gwt.event.dom.client.BlurHandler, Focusable, SubPartAware

Client side implementation of the Select component. TODO needs major refactoring (to be extensible etc)


Nested Class Summary
 class VFilterSelect.FilterSelectSuggestion
          Represents a suggestion in the suggestion popup box
protected static class VFilterSelect.Select
           
 class VFilterSelect.SuggestionMenu
          The menu where the suggestions are rendered
 class VFilterSelect.SuggestionPopup
          Represents the popup box with the selection options.
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  boolean allowNewItem
           
protected static String ATTR_INPUTPROMPT
           
static String ATTR_NO_TEXT_INPUT
           
protected  ApplicationConnection client
           
protected  int currentPage
           
protected  VFilterSelect.FilterSelectSuggestion currentSuggestion
          The current suggestion selected from the dropdown.
protected  List<VFilterSelect.FilterSelectSuggestion> currentSuggestions
          A collection of available suggestions (options) as received from the server.
protected  boolean enabled
           
protected  int filteringmode
           
static int FILTERINGMODE_CONTAINS
           
static int FILTERINGMODE_OFF
           
static int FILTERINGMODE_STARTSWITH
           
protected  boolean focused
           
protected  boolean immediate
           
protected  boolean initDone
           
protected  String inputPrompt
           
protected  String lastFilter
           
protected  String lastNewItemString
           
protected  boolean nullSelectionAllowed
           
protected  boolean nullSelectItem
           
protected  int pageLength
           
protected  String paintableId
           
protected  boolean popupOpenerClicked
           
protected  boolean prompting
           
protected  boolean readonly
           
protected  String selectedOptionKey
           
protected  VFilterSelect.Select selectPopupItemWhenResponseIsReceived
           
protected  VFilterSelect.SuggestionPopup suggestionPopup
           
protected  int suggestionPopupMinWidth
           
protected  com.google.gwt.user.client.ui.TextBox tb
          The text box where the filter is written
protected  int totalMatches
           
protected  boolean updateSelectionWhenReponseIsReceived
           
protected  boolean waitingForFilteringResponse
           
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
VFilterSelect()
          Default constructor
 
Method Summary
 void filterOptions(int page)
          Filters the options at a certain page.
 void filterOptions(int page, String filter)
          Filters the options at certain page using the given filter
 void focus()
          Sets focus to this widget.
 com.google.gwt.user.client.Element getSubPartElement(String subPart)
          Locates an element inside a component using the identifier provided in subPart.
 String getSubPartName(com.google.gwt.user.client.Element subElement)
          Provides an identifier that identifies the element within the component.
 boolean hasNextPage()
          Does the Select have more pages?
protected  int minWidth(String captions)
          Calculate minimum width for FilterSelect textarea
 void onBlur(com.google.gwt.event.dom.client.BlurEvent event)
           
 void onClick(com.google.gwt.event.dom.client.ClickEvent event)
          Listener for popupopener
protected  void onDetach()
           
 void onFocus(com.google.gwt.event.dom.client.FocusEvent event)
           
 void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
           
 void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event)
          Triggered when a key was depressed
 void onSuggestionSelected(VFilterSelect.FilterSelectSuggestion suggestion)
          Triggered when a suggestion is selected
protected  void setPromptingOff(String text)
          Turns prompting off.
protected  void setPromptingOn()
          Turns prompting on.
protected  void setSelectedItemIcon(String iconUri)
          Sets the icon URI of the selected item.
protected  void setTextboxText(String text)
          Sets the text in the text box.
protected  void setTextInputEnabled(boolean textInputEnabled)
           
 void setWidth(String width)
           
protected  void updateReadOnly()
           
protected  void updateRootWidth()
          Calculates the width of the select if the select has undefined width.
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, render, render, resolvePotentialElement, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILTERINGMODE_OFF

public static final int FILTERINGMODE_OFF
See Also:
Constant Field Values

FILTERINGMODE_STARTSWITH

public static final int FILTERINGMODE_STARTSWITH
See Also:
Constant Field Values

FILTERINGMODE_CONTAINS

public static final int FILTERINGMODE_CONTAINS
See Also:
Constant Field Values

pageLength

protected int pageLength

tb

protected final com.google.gwt.user.client.ui.TextBox tb
The text box where the filter is written


suggestionPopup

protected final VFilterSelect.SuggestionPopup suggestionPopup

client

protected ApplicationConnection client

paintableId

protected String paintableId

currentPage

protected int currentPage

currentSuggestions

protected final List<VFilterSelect.FilterSelectSuggestion> currentSuggestions
A collection of available suggestions (options) as received from the server.


immediate

protected boolean immediate

selectedOptionKey

protected String selectedOptionKey

waitingForFilteringResponse

protected boolean waitingForFilteringResponse

updateSelectionWhenReponseIsReceived

protected boolean updateSelectionWhenReponseIsReceived

initDone

protected boolean initDone

lastFilter

protected String lastFilter

selectPopupItemWhenResponseIsReceived

protected VFilterSelect.Select selectPopupItemWhenResponseIsReceived

currentSuggestion

protected VFilterSelect.FilterSelectSuggestion currentSuggestion
The current suggestion selected from the dropdown. This is one of the values in currentSuggestions except when filtering, in this case currentSuggestion might not be in currentSuggestions.


totalMatches

protected int totalMatches

allowNewItem

protected boolean allowNewItem

nullSelectionAllowed

protected boolean nullSelectionAllowed

nullSelectItem

protected boolean nullSelectItem

enabled

protected boolean enabled

readonly

protected boolean readonly

filteringmode

protected int filteringmode

ATTR_INPUTPROMPT

protected static final String ATTR_INPUTPROMPT
See Also:
Constant Field Values

ATTR_NO_TEXT_INPUT

public static final String ATTR_NO_TEXT_INPUT
See Also:
Constant Field Values

inputPrompt

protected String inputPrompt

prompting

protected boolean prompting

popupOpenerClicked

protected boolean popupOpenerClicked

suggestionPopupMinWidth

protected int suggestionPopupMinWidth

lastNewItemString

protected String lastNewItemString

focused

protected boolean focused
Constructor Detail

VFilterSelect

public VFilterSelect()
Default constructor

Method Detail

hasNextPage

public boolean hasNextPage()
Does the Select have more pages?

Returns:
true if a next page exists, else false if the current page is the last page

filterOptions

public void filterOptions(int page)
Filters the options at a certain page. Uses the text box input as a filter

Parameters:
page - The page which items are to be filtered

filterOptions

public void filterOptions(int page,
                          String filter)
Filters the options at certain page using the given filter

Parameters:
page - The page to filter
filter - The filter to apply to the components

updateReadOnly

protected void updateReadOnly()

setTextInputEnabled

protected void setTextInputEnabled(boolean textInputEnabled)

setTextboxText

protected void setTextboxText(String text)
Sets the text in the text box.

Parameters:
text - the text to set in the text box

setPromptingOn

protected void setPromptingOn()
Turns prompting on. When prompting is turned on a command prompt is shown in the text box if nothing has been entered.


setPromptingOff

protected void setPromptingOff(String text)
Turns prompting off. When prompting is turned on a command prompt is shown in the text box if nothing has been entered.

Parameters:
text - The text the text box should contain.

onSuggestionSelected

public void onSuggestionSelected(VFilterSelect.FilterSelectSuggestion suggestion)
Triggered when a suggestion is selected

Parameters:
suggestion - The suggestion that just got selected.

setSelectedItemIcon

protected void setSelectedItemIcon(String iconUri)
Sets the icon URI of the selected item. The icon is shown on the left side of the item caption text. Set the URI to null to remove the icon.

Parameters:
iconUri - The URI of the icon

onKeyDown

public void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent event)
Specified by:
onKeyDown in interface com.google.gwt.event.dom.client.KeyDownHandler

onKeyUp

public void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event)
Triggered when a key was depressed

Specified by:
onKeyUp in interface com.google.gwt.event.dom.client.KeyUpHandler
Parameters:
event - The KeyUpEvent of the key depressed

onClick

public void onClick(com.google.gwt.event.dom.client.ClickEvent event)
Listener for popupopener

Specified by:
onClick in interface com.google.gwt.event.dom.client.ClickHandler

minWidth

protected int minWidth(String captions)
Calculate minimum width for FilterSelect textarea


onFocus

public void onFocus(com.google.gwt.event.dom.client.FocusEvent event)
Specified by:
onFocus in interface com.google.gwt.event.dom.client.FocusHandler

onBlur

public void onBlur(com.google.gwt.event.dom.client.BlurEvent event)
Specified by:
onBlur in interface com.google.gwt.event.dom.client.BlurHandler

focus

public void focus()
Description copied from interface: Focusable
Sets focus to this widget.

Specified by:
focus in interface Focusable

updateRootWidth

protected void updateRootWidth()
Calculates the width of the select if the select has undefined width. Should be called when the width changes or when the icon changes.


setWidth

public void setWidth(String width)
Overrides:
setWidth in class com.google.gwt.user.client.ui.UIObject

onDetach

protected void onDetach()
Overrides:
onDetach in class com.google.gwt.user.client.ui.Composite

getSubPartElement

public com.google.gwt.user.client.Element getSubPartElement(String subPart)
Description copied from interface: SubPartAware
Locates an element inside a component using the identifier provided in subPart. The subPart identifier is component specific and may be any string of characters, numbers, space characters and brackets.

Specified by:
getSubPartElement in interface SubPartAware
Parameters:
subPart - The identifier for the element inside the component
Returns:
The element identified by subPart or null if the element could not be found.

getSubPartName

public String getSubPartName(com.google.gwt.user.client.Element subElement)
Description copied from interface: SubPartAware
Provides an identifier that identifies the element within the component. The subElement is a part of the component and must never be null.

Note! getSubPartElement(getSubPartName(element)) == element is not always true. A component can choose to provide a more generic identifier for any given element if the results of all interactions with subElement are the same as interactions with the element identified by the return value. For example a button can return an identifier for the root element even though a DIV inside the button was passed as subElement because interactions with the DIV and the root button element produce the same result.

Specified by:
getSubPartName in interface SubPartAware
Parameters:
subElement - The element the identifier string should uniquely identify
Returns:
An identifier that uniquely identifies subElement or null if no identifier could be provided.


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.