本文整理汇总了Java中com.google.gwt.user.client.ui.SuggestOracle.Suggestion方法的典型用法代码示例。如果您正苦于以下问题:Java SuggestOracle.Suggestion方法的具体用法?Java SuggestOracle.Suggestion怎么用?Java SuggestOracle.Suggestion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.user.client.ui.SuggestOracle
的用法示例。
在下文中一共展示了SuggestOracle.Suggestion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSuggestions
import com.google.gwt.user.client.ui.SuggestOracle; //导入方法依赖的package包/类
private void findSuggestions(String query, final AsyncCallback<List<SuggestOracle.Suggestion>> callback) {
if (!termsContext.isEnabled()) {
callback.onSuccess(new ArrayList<SuggestOracle.Suggestion>());
return;
}
String[] terms = query.trim().split("\\s");
String lastTerm = terms[terms.length - 1];
termsContext.setPrefix(lastTerm);
termsManager.getTerms(new Callback<TermsResult>() {
public void onSuccess(TermsResult termsResult) {
List<SuggestOracle.Suggestion> suggestions = new ArrayList<SuggestOracle.Suggestion>();
for (TermResult termResult : termsResult.getTermResultByFieldName().values()) {
for (TermEntry termEntry : termResult.getEntries()) {
suggestions.add(new TermSuggestion(termEntry));
}
}
callback.onSuccess(suggestions);
}
});
}
示例2: getSelectedUsers
import com.google.gwt.user.client.ui.SuggestOracle; //导入方法依赖的package包/类
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;
}
示例3: wrapSuggestions
import com.google.gwt.user.client.ui.SuggestOracle; //导入方法依赖的package包/类
private List<SuggestOracle.Suggestion> wrapSuggestions(
List<SuggestFieldSuggestion> in) {
List<SuggestOracle.Suggestion> out = new ArrayList<SuggestOracle.Suggestion>();
for (final SuggestFieldSuggestion wrappedSuggestion : in) {
out.add(new OracleSuggestionImpl(wrappedSuggestion));
}
return out;
}
示例4: AriaSuggestBox
import com.google.gwt.user.client.ui.SuggestOracle; //导入方法依赖的package包/类
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()));
}