com.google.gwt.user.client.ui.SuggestOracle Java Examples
The following examples show how to use
com.google.gwt.user.client.ui.SuggestOracle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditorHarness.java From swellrt with Apache License 2.0 | 6 votes |
void initContentOracle() { contentOracle = new MultiWordSuggestOracle(); contentSuggestBox = new SuggestBox(contentOracle); contentSuggestBox.getElement().setId("content-box"); // Some initial content xml strings contentOracle.add(""); contentOracle.add("abcd"); contentSuggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() { @Override public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) { setFromContentBox(); } }); String[] extra = extendSampleContent(); if (extra != null) { for (String content : extra) { contentOracle.add(content); } } }
Example #2
Source File: EditorHarness.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
void initContentOracle() { contentOracle = new MultiWordSuggestOracle(); contentSuggestBox = new SuggestBox(contentOracle); contentSuggestBox.getElement().setId("content-box"); // Some initial content xml strings contentOracle.add(""); contentOracle.add("abcd"); contentSuggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() { @Override public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) { setFromContentBox(); } }); String[] extra = extendSampleContent(); if (extra != null) { for (String content : extra) { contentOracle.add(content); } } }
Example #3
Source File: AutoCompleteView.java From gwt-material-demo with Apache License 2.0 | 5 votes |
public List<User> getSelectedUsers() { List<? extends SuggestOracle.Suggestion> values = acList.getValue(); List<User> users = new ArrayList<>(values.size()); for(SuggestOracle.Suggestion value : values){ if(value instanceof UserSuggestion){ UserSuggestion us = (UserSuggestion) value; User user = us.getUser(); users.add(user); } } return users; }
Example #4
Source File: JMXPresenter.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void requestSuggestions(final SuggestOracle.Request request, final SuggestOracle.Callback callback) { LoadSocketBindingsCmd cmd = new LoadSocketBindingsCmd(dispatcher, factory, metaData); cmd.execute("full-ha-sockets", new SimpleCallback<List<SocketBinding>>() { @Override public void onSuccess(List<SocketBinding> result) { List<SimpleSuggestion> suggestions = new ArrayList<SimpleSuggestion>(); for (SocketBinding binding : result) { if (binding.getName().startsWith(request.getQuery())) { SimpleSuggestion suggestion = new SimpleSuggestion( binding.getName(), binding.getName() ); suggestions.add(suggestion); } } SuggestOracle.Response response = new SuggestOracle.Response(); response.setSuggestions(suggestions); response.setMoreSuggestionsCount(suggestions.size()); callback.onSuggestionsReady(request, response); } }); }
Example #5
Source File: AriaSuggestBox.java From unitime with Apache License 2.0 | 4 votes |
public AriaSuggestBox(SuggestOracle oracle) { this(new AriaTextBox(), oracle); }
Example #6
Source File: AriaSuggestBox.java From unitime with Apache License 2.0 | 4 votes |
public AriaSuggestBox(AriaTextBox box, SuggestOracle oracle) { iOracle = oracle; iText = box; iText.setStyleName("gwt-SuggestBox"); initWidget(iText); addEventsToTextBox(); iSuggestionMenu = new SuggestionMenu(); iPopupScroll = new ScrollPanel(iSuggestionMenu); iPopupScroll.addStyleName("scroll"); iSuggestionPopup = new PopupPanel(true, false); iSuggestionPopup.setPreviewingAllNativeEvents(true); iSuggestionPopup.setStyleName("unitime-SuggestBoxPopup"); iSuggestionPopup.setWidget(iPopupScroll); iSuggestionPopup.addAutoHidePartner(getElement()); iSuggestionCallback = new SuggestionCallback() { @Override public void onSuggestionSelected(Suggestion suggestion) { if (!suggestion.getReplacementString().isEmpty()) { setStatus(ARIA.suggestionSelected(status(suggestion))); } iCurrentText = suggestion.getReplacementString(); setText(suggestion.getReplacementString()); hideSuggestionList(); fireSuggestionEvent(suggestion); } }; iOracleCallback = new SuggestOracle.Callback() { @Override public void onSuggestionsReady(Request request, Response response) { if (response.getSuggestions() == null || response.getSuggestions().isEmpty()) { if (iSuggestionPopup.isShowing()) iSuggestionPopup.hide(); } else { iSuggestionMenu.clearItems(); SuggestOracle.Suggestion first = null; for (SuggestOracle.Suggestion suggestion: response.getSuggestions()) { iSuggestionMenu.addItem(new SuggestionMenuItem(suggestion)); if (first == null) first = suggestion; } iSuggestionMenu.selectItem(0); ToolBox.setMinWidth(iSuggestionMenu.getElement().getStyle(), (iText.getElement().getClientWidth() - 4) + "px"); iSuggestionPopup.showRelativeTo(iText); iSuggestionMenu.scrollToView(); if (response.getSuggestions().size() == 1) { if (first.getReplacementString().isEmpty()) setStatus(status(first)); else setStatus(ARIA.showingOneSuggestion(status(first))); } else { setStatus(ARIA.showingMultipleSuggestions(response.getSuggestions().size(), request.getQuery(), status(first))); } } } }; Roles.getTextboxRole().setAriaAutocompleteProperty(iText.getElement(), AutocompleteValue.NONE); iSuggestionPopup.getElement().setAttribute("id", DOM.createUniqueId()); Roles.getTextboxRole().setAriaOwnsProperty(iText.getElement(), Id.of(iSuggestionPopup.getElement())); }
Example #7
Source File: SuggestionManagement.java From core with GNU Lesser General Public License v2.1 | votes |
void requestSuggestions(SuggestOracle.Request request, SuggestOracle.Callback callback);