Java 类com.google.gwt.user.client.ui.SuggestOracle.Request 实例源码

项目:unitimes    文件:AriaSuggestBox.java   
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()));
}
项目:unitimes    文件:AriaSuggestBox.java   
public void showSuggestions(String text) {
    if (text.isEmpty())
        iOracle.requestDefaultSuggestions(new Request(null), iOracleCallback);
    else
        iOracle.requestSuggestions(new Request(text), iOracleCallback);
}
项目:unitimes    文件:CourseSelectionSuggestBox.java   
public SuggestCallback(Request request, Callback callback) {
    iRequest = request;
    iCallback = callback;
}
项目:unitimes    文件:SectioningStatusPage.java   
public SuggestCallback(Request request, Callback callback) {
    iRequest = request;
    iCallback = callback;
}
项目:unitime    文件:AriaSuggestBox.java   
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()));
}
项目:unitime    文件:AriaSuggestBox.java   
public void showSuggestions(String text) {
    if (text.isEmpty())
        iOracle.requestDefaultSuggestions(new Request(null), iOracleCallback);
    else
        iOracle.requestSuggestions(new Request(text), iOracleCallback);
}
项目:unitime    文件:CourseSelectionSuggestBox.java   
public SuggestCallback(Request request, Callback callback) {
    iRequest = request;
    iCallback = callback;
}
项目:unitime    文件:SectioningStatusPage.java   
public SuggestCallback(Request request, Callback callback) {
    iRequest = request;
    iCallback = callback;
}
项目:gwtutil    文件:DTOSuggestBox.java   
public void requestRemoteSuggestions(Request request, AsyncCallback<List<T>> callback);