Class SuggestBoxNewEditor
- All Implemented Interfaces:
com.google.gwt.event.dom.client.HasAllKeyHandlers,com.google.gwt.event.dom.client.HasKeyDownHandlers,com.google.gwt.event.dom.client.HasKeyPressHandlers,com.google.gwt.event.dom.client.HasKeyUpHandlers,com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.logical.shared.HasSelectionHandlers<com.google.gwt.user.client.ui.SuggestOracle.Suggestion>,com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.TakesValue<String>,com.google.gwt.user.client.ui.Focusable,com.google.gwt.user.client.ui.HasAnimation,com.google.gwt.user.client.ui.HasEnabled,com.google.gwt.user.client.ui.HasText,com.google.gwt.user.client.ui.HasValue<String>,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.IsRenderable,com.google.gwt.user.client.ui.IsWidget,org.gwtproject.editor.client.IsEditor<org.gwtproject.editor.client.LeafValueEditor<String>>,org.gwtproject.editor.client.TakesValue<String>
- Direct Known Subclasses:
SuggestBoxWithEditorErrors
SuggestBoxNewEditor is a text box or text area which displays a pre-configured set of
selections that match the user's input.
Each SuggestBoxNewEditor is associated with a single SuggestOracle. The
SuggestOracle is used to provide a set of selections given a specific query string.
By default, the SuggestBoxNewEditor uses a MultiWordSuggestOracle as its oracle.
Below we show how a MultiWordSuggestOracle can be configured:
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
oracle.add("Cat");
oracle.add("Dog");
oracle.add("Horse");
oracle.add("Canary");
SuggestBoxNewEditor box = new SuggestBoxNewEditor(oracle);
Using the example above, if the user types "C" into the text widget, the oracle will configure
the suggestions with the "Cat" and "Canary" suggestions. Specifically, whenever the user types a
key into the text widget, the value is submitted to the MultiWordSuggestOracle.
Note that there is no method to retrieve the "currently selected suggestion" in a
SuggestBoxNewEditor, because there are points in time where the currently selected suggestion is
not defined. For example, if the user types in some text that does not match any of the
SuggestBoxNewEditor's suggestions, then the SuggestBoxNewEditor will not have a currently
selected suggestion. It is more useful to know when a suggestion has been chosen from the
SuggestBoxNewEditor's list of suggestions. A SuggestBoxNewEditor fires SelectionEvents whenever a suggestion is chosen, and handlers for these events can be added
using the AbstractSuggestBoxNewEditor.addSelectionHandler(SelectionHandler) method.
CSS Style Rules
- .gwt-SuggestBox
- the suggest box itself
- See Also:
-
SuggestOracleMultiWordSuggestOracleValueBoxBaseWithEditorErrors
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.AbstractSuggestBoxNewEditor
AbstractSuggestBoxNewEditor.DefaultSuggestionDisplay, AbstractSuggestBoxNewEditor.SuggestionCallback, AbstractSuggestBoxNewEditor.SuggestionDisplayNested 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
Fields inherited from class com.google.gwt.user.client.ui.AbstractSuggestBoxNewEditor
callback, currentText, display, limit, oracle, selectsFirstItem, STYLENAME_DEFAULTFields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionConstructor forSuggestBoxNewEditor.SuggestBoxNewEditor(com.google.gwt.user.client.ui.SuggestOracle oracle) Constructor forSuggestBoxNewEditor.SuggestBoxNewEditor(com.google.gwt.user.client.ui.SuggestOracle oracle, ValueBoxBaseWithEditorErrors<String> box) Constructor forSuggestBoxNewEditor.SuggestBoxNewEditor(com.google.gwt.user.client.ui.SuggestOracle oracle, ValueBoxBaseWithEditorErrors<String> box, AbstractSuggestBoxNewEditor.SuggestionDisplay suggestDisplay) Constructor forSuggestBoxNewEditor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddEventsToTextBox(com.google.gwt.event.shared.EventHandler events) org.gwtproject.editor.client.LeafValueEditor<String>asEditor()Returns aTakesValueEditorbacked by the SuggestBoxNewEditor.protected com.google.gwt.user.client.ui.FocusWidgetintgetText()getValue()Get the ValueBoxBaseWithEditorErrors associated with this suggest box.booleanGets whether this widget is enabled.voidsetAccessKey(char key) voidsetEnabled(boolean enabled) Sets whether this widget is enabled.voidsetFocus(boolean focused) voidsetTabIndex(int index) voidvoidvoidstatic SuggestBoxNewEditorwrap(com.google.gwt.user.client.ui.SuggestOracle oracle, com.google.gwt.dom.client.Element element) Creates aSuggestBoxNewEditorwidget that wraps an existing <input type='text'> element.Methods inherited from class com.google.gwt.user.client.ui.AbstractSuggestBoxNewEditor
addEventsToTextBox, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addSelectionHandler, addValueChangeHandler, getLimit, getSuggestionDisplay, getSuggestOracle, hideSuggestionList, isAnimationEnabled, isAutoSelectEnabled, isSuggestionListShowing, onEnsureDebugId, refreshSuggestionList, setAnimationEnabled, setAutoSelectEnabled, setLimit, setOracle, setPopupStyleName, showSuggestionListMethods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidgetMethods 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, unsinkEventsMethods 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, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Constructor Details
-
SuggestBoxNewEditor
public SuggestBoxNewEditor()Constructor forSuggestBoxNewEditor. Creates aMultiWordSuggestOracleandTextBoxto use with thisSuggestBoxNewEditor. -
SuggestBoxNewEditor
public SuggestBoxNewEditor(com.google.gwt.user.client.ui.SuggestOracle oracle) - Parameters:
oracle- the oracle for thisSuggestBoxNewEditor
-
SuggestBoxNewEditor
public SuggestBoxNewEditor(com.google.gwt.user.client.ui.SuggestOracle oracle, ValueBoxBaseWithEditorErrors<String> box) Constructor forSuggestBoxNewEditor. The text box will be removed from it's current location and wrapped by theSuggestBoxNewEditor.- Parameters:
oracle- supplies suggestions based upon the current contents of the text widgetbox- the text widget
-
SuggestBoxNewEditor
public SuggestBoxNewEditor(com.google.gwt.user.client.ui.SuggestOracle oracle, ValueBoxBaseWithEditorErrors<String> box, AbstractSuggestBoxNewEditor.SuggestionDisplay suggestDisplay) Constructor forSuggestBoxNewEditor. The text box will be removed from it's current location and wrapped by theSuggestBoxNewEditor.- Parameters:
oracle- supplies suggestions based upon the current contents of the text widgetbox- the text widgetsuggestDisplay- the class used to display suggestions
-
-
Method Details
-
wrap
public static SuggestBoxNewEditor wrap(com.google.gwt.user.client.ui.SuggestOracle oracle, com.google.gwt.dom.client.Element element) Creates aSuggestBoxNewEditorwidget that wraps an existing <input type='text'> element.This element must already be attached to the document. If the element is removed from the document, you must call
RootPanel.detachNow(Widget).- Parameters:
oracle- the suggest box oracle to useelement- the element to be wrapped
-
getBoxAsFoucsWidget
protected com.google.gwt.user.client.ui.FocusWidget getBoxAsFoucsWidget()- Specified by:
getBoxAsFoucsWidgetin classAbstractSuggestBoxNewEditor
-
asEditor
Returns aTakesValueEditorbacked by the SuggestBoxNewEditor.- Specified by:
asEditorin interfaceorg.gwtproject.editor.client.IsEditor<org.gwtproject.editor.client.LeafValueEditor<String>>
-
getTabIndex
public int getTabIndex()- Specified by:
getTabIndexin interfacecom.google.gwt.user.client.ui.Focusable- Specified by:
getTabIndexin classAbstractSuggestBoxNewEditor
-
getText
- Specified by:
getTextin interfacecom.google.gwt.user.client.ui.HasText- Specified by:
getTextin classAbstractSuggestBoxNewEditor
-
getValue
- Specified by:
getValuein interfacecom.google.gwt.user.client.ui.HasValue<String>- Specified by:
getValuein interfacecom.google.gwt.user.client.TakesValue<String>- Specified by:
getValuein interfaceorg.gwtproject.editor.client.TakesValue<String>- Specified by:
getValuein classAbstractSuggestBoxNewEditor
-
getValueBox
Get the ValueBoxBaseWithEditorErrors associated with this suggest box.- Returns:
- this suggest box's value box
-
isEnabled
public boolean isEnabled()Gets whether this widget is enabled.- Specified by:
isEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled- Returns:
trueif the widget is enabled
-
setAccessKey
public void setAccessKey(char key) - Specified by:
setAccessKeyin interfacecom.google.gwt.user.client.ui.Focusable- Specified by:
setAccessKeyin classAbstractSuggestBoxNewEditor
-
setEnabled
public void setEnabled(boolean enabled) Sets whether this widget is enabled.- Specified by:
setEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled- Overrides:
setEnabledin classAbstractSuggestBoxNewEditor- Parameters:
enabled-trueto enable the widget,falseto disable it
-
setFocus
public void setFocus(boolean focused) - Specified by:
setFocusin interfacecom.google.gwt.user.client.ui.Focusable- Specified by:
setFocusin classAbstractSuggestBoxNewEditor
-
setTabIndex
public void setTabIndex(int index) - Specified by:
setTabIndexin interfacecom.google.gwt.user.client.ui.Focusable
-
setText
- Specified by:
setTextin interfacecom.google.gwt.user.client.ui.HasText
-
setValue
-
setValue
- Specified by:
setValuein interfacecom.google.gwt.user.client.ui.HasValue<String>
-