List of usage examples for com.google.gwt.user.client.ui NotificationPopupPanel cancel
public static void cancel()
From source file:uk.ac.ebi.fg.annotare.prototype.datagrid.client.cell.EditSuggestCell.java
License:Apache License
private void editEvent(Context context, Element parent, String value, ViewData viewData, NativeEvent event, ValueUpdater<String> valueUpdater) { String type = event.getType(); int keyCode = event.getKeyCode(); if (KEYDOWN.equals(type)) { NotificationPopupPanel.cancel(); if (KeyCodes.KEY_TAB == keyCode) { event.stopPropagation();/*from ww w. j a va 2s . c o m*/ event.preventDefault(); } else if (null != display && display.isSuggestionListShowing() && handleSuggestionKeyDown(context, parent, event, valueUpdater)) return; if (KeyCodes.KEY_ESCAPE == keyCode) { // Cancel edit mode. cancel(context, parent, viewData); } else { updateViewData(parent, viewData, true); } } else if (KEYUP.equals(type)) { if (KeyCodes.KEY_TAB == keyCode) { if (null != display && display.isSuggestionListShowing()) { Suggestion suggestion = display.getCurrentSelection(); if (null == suggestion) { display.hideSuggestions(); } else { setNewSelection(context, parent, suggestion, valueUpdater, false); } } event.stopPropagation(); event.preventDefault(); } else if (KeyCodes.KEY_ENTER == keyCode) { if (null != display && display.isSuggestionListShowing()) { Suggestion suggestion = display.getCurrentSelection(); if (null == suggestion) { display.hideSuggestions(); } else { setNewSelection(context, parent, suggestion, valueUpdater, true); } } else { if (sctrictlySuggestions && null != display) { if (display.isValidSuggestion(viewData.getText())) { commit(context, parent, viewData, valueUpdater); } else { NotificationPopupPanel.error( "Value '" + viewData.getText() + "' is not permitted. Please select one of the suggestions provided.", false); } } else { commit(context, parent, viewData, valueUpdater); } } } else { String oldText = viewData.getText(); String curText = updateViewData(parent, viewData, true); if (null != display && !oldText.equals(curText)) { showSuggestions(context, parent, curText, valueUpdater); } } } else if (BLUR.equals(type)) { if (null == display || !display.isSuggestionListShowing()) { // cancel the change EventTarget eventTarget = event.getEventTarget(); if (Element.is(eventTarget)) { Element target = Element.as(eventTarget); if ("input".equals(target.getTagName().toLowerCase())) { // Cancel edit mode. cancel(context, parent, viewData); } } } } }