use of com.google.gwt.user.client.ui.SuggestOracle.Suggestion in project ovirt-engine by oVirt.
the class EnterIgnoringNativePreviewHandler method onPreviewNativeEvent.
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (nativeEvent.getKeyCode() == KeyCodes.KEY_ENTER && event.getTypeInt() == Event.ONKEYPRESS && !event.isCanceled()) {
// swallow the enter key otherwise the whole dialog would get submitted
nativeEvent.preventDefault();
nativeEvent.stopPropagation();
event.cancel();
// process the event here directly
Suggestion currentSelection = listModelTypeAheadListBox.getCurrentSelection();
if (currentSelection != null) {
String replacementString = currentSelection.getReplacementString();
try {
listModelTypeAheadListBox.setValue(listModelTypeAheadListBox.asEntity(replacementString), true);
} catch (IllegalArgumentException e) {
// do not set the value if it is not a correct one
}
}
listModelTypeAheadListBox.hideSuggestions();
}
}
use of com.google.gwt.user.client.ui.SuggestOracle.Suggestion in project opennms by OpenNMS.
the class FilterPanel method onApplicationSelect.
/**
* <p>onApplicationSelect</p>
*
* @param event a {@link com.google.gwt.event.logical.shared.SelectionEvent} object.
*/
@UiHandler("applicationNameSuggestBox")
public void onApplicationSelect(final SelectionEvent<Suggestion> event) {
Suggestion item = event.getSelectedItem();
m_eventBus.fireEvent(new ApplicationSelectedEvent(item.getReplacementString()));
}
use of com.google.gwt.user.client.ui.SuggestOracle.Suggestion in project perun by CESNET.
the class SuggestBox method addEventsToTextBox.
private void addEventsToTextBox() {
class TextBoxEvents extends HandlesAllKeyEvents implements ValueChangeHandler<String> {
public void onKeyDown(KeyDownEvent event) {
switch(event.getNativeKeyCode()) {
case KeyCodes.KEY_DOWN:
display.moveSelectionDown();
break;
case KeyCodes.KEY_UP:
display.moveSelectionUp();
break;
case KeyCodes.KEY_ENTER:
case KeyCodes.KEY_TAB:
Suggestion suggestion = display.getCurrentSelection();
if (suggestion == null) {
display.hideSuggestions();
} else {
setNewSelection(suggestion);
}
break;
}
delegateEvent(SuggestBox.this, event);
}
public void onKeyPress(KeyPressEvent event) {
delegateEvent(SuggestBox.this, event);
}
public void onKeyUp(KeyUpEvent event) {
// After every user key input, refresh the popup's suggestions.
refreshSuggestions();
delegateEvent(SuggestBox.this, event);
}
public void onValueChange(ValueChangeEvent<String> event) {
delegateEvent(SuggestBox.this, event);
}
}
TextBoxEvents events = new TextBoxEvents();
events.addKeyHandlersTo(box);
box.addValueChangeHandler(events);
}
Aggregations