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

项目:RedQueryBuilder    文件:GwtTestBasics.java   
@Test
public void testAsyncOptionSelectedFromBootstrap() throws Exception {
    CapturingConfiguration config = new CapturingConfiguration();

    Session sess = createSession(config);

    List<Object> args = new ArrayList<Object>();
    args.add("M");
    CommandBuilder cb = new CommandBuilder(sess, "SELECT x.id FROM Person x WHERE sex = ?", args);
    RootPanel.get().add(cb);
    Select s = cb.getSelect();

    // only now give them the enumeration
    Collection<Suggestion> s2 = new ArrayList();
    s2.add(new MultiWordSuggestion("M", "M"));
    s2.add(new MultiWordSuggestion("F", "F"));

    config.getEnumerateCallback().onSuccess(new Response(s2));

    Comparison c = (Comparison) s.getCondition();
    Parameter p = (Parameter) c.getRight();
    SelectEditorWidget sew = (SelectEditorWidget) p.getEditorWidget();
    assertEquals("M", sew.getValue());
}
项目:unitimes    文件:CourseSelectionSuggestBox.java   
public void onFailure(final Throwable caught) {
    iValidCourseNames.clear();
    final ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    if (iFreeTimeParser != null) {
        iFreeTimeParser.getData(iRequest.getQuery(), new AsyncCallback<List<FreeTime>>() {
            @Override
            public void onFailure(Throwable e) {
                if (iRequest.getQuery().toLowerCase().startsWith(CONSTANTS.freePrefix().toLowerCase())) {
                    suggestions.add(new SimpleSuggestion(e));
                    // setStatus(e.getMessage());
                } else {
                    suggestions.add(new SimpleSuggestion(caught));
                    // setStatus(caught.getMessage());
                }
            }

            @Override
            public void onSuccess(List<FreeTime> freeTimes) {
                suggestions.add(new SimpleSuggestion(freeTimes));
            }
        });
    } else {
        suggestions.add(new SimpleSuggestion(caught));
        // setStatus(caught.getMessage());
    }
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
}
项目:unitimes    文件:CourseSelectionSuggestBox.java   
public void onSuccess(Collection<ClassAssignmentInterface.CourseAssignment> result) {
    ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    iValidCourseNames.clear();
    for (ClassAssignmentInterface.CourseAssignment course: result) {
        SimpleSuggestion suggestion = new SimpleSuggestion(course, iShowCourses);
        suggestions.add(suggestion);
        iValidCourseNames.put(suggestion.getReplacementString().toLowerCase(), suggestion.getRequestedCourse());
    }
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
}
项目:unitimes    文件:SectioningStatusPage.java   
public void onSuccess(List<String[]> result) {
    ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    for (String[] suggestion: result) {
        suggestions.add(new SimpleSuggestion(suggestion[1], suggestion[0]));
    }
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
}
项目:unitime    文件:CourseSelectionSuggestBox.java   
public void onFailure(final Throwable caught) {
    iValidCourseNames.clear();
    final ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    if (iFreeTimeParser != null) {
        iFreeTimeParser.getData(iRequest.getQuery(), new AsyncCallback<List<FreeTime>>() {
            @Override
            public void onFailure(Throwable e) {
                if (iRequest.getQuery().toLowerCase().startsWith(CONSTANTS.freePrefix().toLowerCase())) {
                    suggestions.add(new SimpleSuggestion(e));
                    // setStatus(e.getMessage());
                } else {
                    suggestions.add(new SimpleSuggestion(caught));
                    // setStatus(caught.getMessage());
                }
            }

            @Override
            public void onSuccess(List<FreeTime> freeTimes) {
                suggestions.add(new SimpleSuggestion(freeTimes));
            }
        });
    } else {
        suggestions.add(new SimpleSuggestion(caught));
        // setStatus(caught.getMessage());
    }
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
}
项目:unitime    文件:CourseSelectionSuggestBox.java   
public void onSuccess(Collection<ClassAssignmentInterface.CourseAssignment> result) {
    ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    iValidCourseNames.clear();
    for (ClassAssignmentInterface.CourseAssignment course: result) {
        SimpleSuggestion suggestion = new SimpleSuggestion(course, iShowCourses);
        suggestions.add(suggestion);
        iValidCourseNames.put(suggestion.getReplacementString().toLowerCase(), suggestion.getRequestedCourse());
    }
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
}
项目:unitime    文件:SectioningStatusPage.java   
public void onSuccess(List<String[]> result) {
    ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    for (String[] suggestion: result) {
        suggestions.add(new SimpleSuggestion(suggestion[1], suggestion[0]));
    }
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
}
项目: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    文件:SectioningStatusPage.java   
public void onFailure(Throwable caught) {
    ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    // suggestions.add(new SimpleSuggestion("<font color='red'>"+caught.getMessage()+"</font>", ""));
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
    ToolBox.checkAccess(caught);
}
项目: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    文件:SectioningStatusPage.java   
public void onFailure(Throwable caught) {
    ArrayList<Suggestion> suggestions = new ArrayList<Suggestion>();
    // suggestions.add(new SimpleSuggestion("<font color='red'>"+caught.getMessage()+"</font>", ""));
    iCallback.onSuggestionsReady(iRequest, new Response(suggestions));
    ToolBox.checkAccess(caught);
}
项目:RedQueryBuilder    文件:ConfigurationAdapter.java   
EnumerateCallback(AsyncCallback<Response> callback2) {
    this.callback = callback2;
}
项目:RedQueryBuilder    文件:ConfigurationAdapter.java   
@Override
public void fireDefaultSuggest(SuggestRequest sr,
        final AsyncCallback<Response> callback) {
    config.fireDefaultSuggest(sr.getTableName(), sr.getColumnName(), sr.getColumnTypeName(),
            sr.getQuery(), sr.getLimit(), new EnumerateCallback(callback));
}
项目:RedQueryBuilder    文件:ConfigurationAdapter.java   
@Override
public void fireSuggest(SuggestRequest sr,
        final AsyncCallback<Response> callback) {
    config.fireSuggest(sr.getTableName(), sr.getColumnName(), sr.getColumnTypeName(),
            sr.getQuery(), sr.getLimit(), new EnumerateCallback(callback));
}
项目:RedQueryBuilder    文件:ConfigurationAdapter.java   
@Override
public void fireEnumerate(EnumerateRequest er,
        final AsyncCallback<Response> callback) {
    config.fireEnumerate(er.getTableName(), er.getColumnName(), er.getColumnTypeName(),
            new EnumerateCallback(callback));
}
项目:RedQueryBuilder    文件:Configuration.java   
public void fireEnumerate(EnumerateRequest request, AsyncCallback<Response> callback) {
}
项目:RedQueryBuilder    文件:Configuration.java   
public void fireDefaultSuggest(SuggestRequest request, AsyncCallback<Response> callback) {
}
项目:RedQueryBuilder    文件:Configuration.java   
public void fireSuggest(SuggestRequest request, AsyncCallback<Response> callback) {
}
项目:RedQueryBuilder    文件:CapturingConfiguration.java   
public AsyncCallback<Response> getEnumerateCallback() {
    return enumerateCallback;
}
项目:RedQueryBuilder    文件:CapturingConfiguration.java   
@Override
public void fireEnumerate(EnumerateRequest request, AsyncCallback<Response> callback) {
    enumerateCallback = callback;
}