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

项目:Wiab.pro    文件:EditorHarness.java   
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);
    }
  }
}
项目:gerrit    文件:AddMemberBox.java   
public AddMemberBox(final String buttonLabel, String hint, SuggestOracle suggestOracle) {
  addPanel = new FlowPanel();
  addMember = new Button(buttonLabel);

  suggestBox = new RemoteSuggestBox(suggestOracle);
  suggestBox.setStyleName(Gerrit.RESOURCES.css().addMemberTextBox());
  suggestBox.setVisibleLength(50);
  suggestBox.setHintText(hint);
  suggestBox.addSelectionHandler(
      new SelectionHandler<String>() {
        @Override
        public void onSelection(SelectionEvent<String> event) {
          addMember.fireEvent(new ClickEvent() {});
        }
      });

  addPanel.add(suggestBox);
  addPanel.add(addMember);

  initWidget(addPanel);
}
项目:google-apis-explorer    文件:FullView.java   
public FullView(URLManipulator urlManipulator, AuthManager authManager,
    AnalyticsManager analytics, SuggestOracle searchKeywords) {

  this.analytics = analytics;
  this.presenter = new FullViewPresenter(urlManipulator, this);
  this.authManager = authManager;
  PlaceholderTextBox searchBackingTextBox =
      new PlaceholderTextBox("Search for services, methods, and recent requests...");
  this.searchBox = new SuggestBox(searchKeywords, searchBackingTextBox);

  searchBox.setAutoSelectEnabled(false);
  initWidget(uiBinder.createAndBindUi(this));
  setMenuActions();

  // Add a fixed css class name that I can use to be able to style the menu.
  settingsMenu.setStyleName(SETTINGS_MENU_CSS_RULE + " " + settingsMenu.getStyleName());

  // Set the style of the search box.
  searchBackingTextBox.setPlaceholderTextStyleName(style.searchPlaceholderText());
}
项目:incubator-wave    文件:EditorHarness.java   
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);
    }
  }
}
项目:solr-explorer    文件:SearchAutoCompletionPlugin.java   
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);
        }
    });
}
项目:gwt-material-demo    文件:AutoCompleteView.java   
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;
}
项目:firefly    文件:NaifTargetPanel.java   
public void onFailure(Throwable caught) {
    if (!completed) {
        List<NaifSuggestion> sugList= new ArrayList<NaifSuggestion>(0);
        SuggestOracle.Response response= new SuggestOracle.Response(sugList);
        cb.onSuggestionsReady(request,response);
        activeList= null;
    }
    completed= true;
}
项目:firefly    文件:NaifTargetPanel.java   
public void onSuccess(List<EphPair> result) {
    if (!completed) {
        List<NaifSuggestion> sugList= new ArrayList<NaifSuggestion>(result.size());
        for(EphPair ep : result)  sugList.add(new NaifSuggestion(ep));
        SuggestOracle.Response response= new SuggestOracle.Response(sugList);
        cb.onSuggestionsReady(request,response);
        activeList= result;
    }
    completed= true;
}
项目:blogwt    文件:UserController.java   
public SuggestOracle oracle () {
    if (oracle == null) {
        oracle = new UserOracle();
    }

    return oracle;
}
项目:blogwt    文件:PageController.java   
public SuggestOracle oracle () {
    if (oracle == null) {
        oracle = new PageOracle();
    }

    return oracle;
}
项目:blogwt    文件:PostController.java   
/**
 * @return
 */
public SuggestOracle oracle () {
    if (oracle == null) {
        oracle = new PostOracle();
    }

    return oracle;
}
项目:blogwt    文件:RoleController.java   
public SuggestOracle oracle () {
    if (oracle == null) {
        oracle = new RoleOracle();
    }

    return oracle;
}
项目:dojo-ibl    文件:SuggestBoxItem.java   
public SuggestBoxItem(String s, String s1, SuggestOracle suggestOracle) {
    super(s, s1);

    suggestBoxField = new SuggestBox(suggestOracle);

    suggestBoxField.setStyleName("gwt-SuggestBox");
    suggestBoxField.setHeight(getHeight() + "px");

    canvas.setHeight(getHeight());
    canvas.setStyleName("gwt-SuggestBoxCanvas");
    canvas.addChild(suggestBoxField);

    setCanvas(canvas);
}
项目:suggestfield    文件:VSuggestField.java   
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;

}
项目:gwtutil    文件:DTOSuggestBox.java   
public DTOSuggestBox() {
    super(new DTOSuggestOracle<T>());
    addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {

        @SuppressWarnings("unchecked")
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
            selected = ((DTOSuggestion<T>) event.getSelectedItem()).getDTO();
        }
    });
}
项目:gharonda    文件:HomeView.java   
@Override
public void requestSuggestions(final Request request, final Callback callback) {
    String searchTextVal = request.getQuery();
    if (!searchTextVal.trim().isEmpty()) {
        List<SearchCriteriaIFace> stList = getSearchTextCriteriaList(searchTextVal);
        int mode = modeTypesList.getSelectedIndex() + 1;
        List<SearchCriteriaIFace> slCriteria = new ArrayList<SearchCriteriaIFace>();
        PropertyOptions.adjustForPModeSearchCriteria(slCriteria, mode);
        GetSearchProperties action = new GetSearchProperties(PropertyOptions.DEFAULT_SUGGESTBOX_SEARCH_PROFILE,
                slCriteria, stList, true, CommonConstants.SUGGESTBOX_RESULTS_SIZE);
        dispatcher.execute(action, new AsyncCallback<GetSearchPropertiesResult>() {
            @Override
            public void onFailure(Throwable caught) {

            }

            @Override
            public void onSuccess(GetSearchPropertiesResult result) {
                Set<PropertiesSuggestion> suggestions = new HashSet<PropertiesSuggestion>();
                if (result.getSearchProperties().size() == 0) {
                    suggestions.add(new PropertiesSuggestion(PropertyOptions.noPropertyFound));
                } else {
                    for (PropertiesDTO p : result.getSearchProperties()) {
                        suggestions.add(new PropertiesSuggestion(p.getSuburb() + ", " + p.getCity() + ", "
                                + p.getState() + ", " + p.getPostCode()));
                    }
                }

                SuggestOracle.Response response = new SuggestOracle.Response();
                response.setSuggestions(suggestions);
                callback.onSuggestionsReady(request, response);
            }
        });
    }

}
项目:solr-explorer    文件:SearchAutoCompletionPlugin.java   
@Override
public void init(SolrCore solrCore) {
    setActive(solrCore.getConfiguration().isActive(TermsConfig.class));

    if (!isActive()) {
        searchPane.setSearchTextBox(new TextBox());
        return;
    }

    oracle = new SuggestOracle() {
        public void requestSuggestions(final Request request, final Callback callback) {
            findSuggestions(request.getQuery(), new org.apache.solr.explorer.client.util.Callback<List<Suggestion>>() {
                public void onSuccess(List<Suggestion> suggestions) {
                    callback.onSuggestionsReady(request, new Response(suggestions));
                }
            });

        }
    };
    suggestBox = new SuggestBox(oracle);
    suggestBox.setPopupStyleName("AutoCompletionPopup");

    suggestBox.addKeyDownHandler(new EnterKeyHandler() {
        @Override
        protected void onEnter(KeyDownEvent keyDownEvent) {
            if (!suggestBox.isSuggestionListShowing()) {
                searchPane.executeSearch();
            }
        }
    });
    suggestBox.setAutoSelectEnabled(false);
    suggestBox.setAnimationEnabled(true);

    searchPane.setSearchTextBox(suggestBox);
}
项目:solr-explorer    文件:AutoSuggestTextEditor.java   
public AutoSuggestTextEditor(SuggestOracle oracle, String defaultText, boolean enabled) {
    box = new SuggestBox(oracle);
    box.setPopupStyleName("AutoCompletionPopup");
    box.setAnimationEnabled(true);
    box.setText(defaultText == null ? "" : defaultText);
    box.getTextBox().setEnabled(enabled);
}
项目:unitimes    文件:AriaSuggestBox.java   
public AriaSuggestBox(SuggestOracle oracle) {
    this(new AriaTextBox(), oracle);
}
项目: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()));
}
项目:ephesoft    文件:SuggestionBox.java   
public SuggestionBox(SuggestOracle oracle) {
    super(oracle);
    addKeyboardListener(this);
    addFocusListener(this);

}
项目:firefly    文件:NaifTargetPanel.java   
NaifOracleCallback(SuggestOracle.Request request, SuggestOracle.Callback cb) {
    this.request= request;
    this.cb= cb;
}
项目:firefly    文件:NaifTargetPanel.java   
public NaifInputField (FieldDef fd, SuggestOracle suggest) {
    super(fd,suggest);
}
项目:firefly    文件:SuggestBoxInputField.java   
public SuggestBoxInputField(FieldDef fieldDef, SuggestOracle oracle) {
    _inputField = new TextBoxInputField(fieldDef,true);
    _suggestBox = new SuggestBox(oracle, _inputField.getTextBox());
    initWidget(_suggestBox );
}
项目:gerrit    文件:SearchSuggestOracle.java   
ParamSuggester(List<String> operators, SuggestOracle parameterSuggestionOracle) {
  this.operators = operators;
  this.parameterSuggestionOracle = parameterSuggestionOracle;
}
项目:gerrit    文件:RemoteSuggestBox.java   
public RemoteSuggestBox(SuggestOracle oracle) {
  remoteSuggestOracle = new RemoteSuggestOracle(oracle);
  remoteSuggestOracle.setServeSuggestions(true);
  display = new DefaultSuggestionDisplay();

  textBox = new HintTextBox();
  textBox.addKeyDownHandler(
      new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent e) {
          submitOnSelection = false;
          if (e.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
            CloseEvent.fire(RemoteSuggestBox.this, RemoteSuggestBox.this);
          } else if (e.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
            if (display.isSuggestionListShowing()) {
              if (textBox.getValue().equals(remoteSuggestOracle.getLast())) {
                submitOnSelection = true;
              } else {
                display.hideSuggestions();
              }
            } else {
              SelectionEvent.fire(RemoteSuggestBox.this, getText());
            }
          }
        }
      });

  suggestBox = new SuggestBox(remoteSuggestOracle, textBox, display);
  suggestBox.addSelectionHandler(
      new SelectionHandler<Suggestion>() {
        @Override
        public void onSelection(SelectionEvent<Suggestion> event) {
          if (submitOnSelection) {
            SelectionEvent.fire(RemoteSuggestBox.this, getText());
          }
          remoteSuggestOracle.cancelOutstandingRequest();
          display.hideSuggestions();
        }
      });
  initWidget(suggestBox);
}
项目:gerrit    文件:RemoteSuggestOracle.java   
public RemoteSuggestOracle(SuggestOracle src) {
  oracle = src;
}
项目:unitime    文件:AriaSuggestBox.java   
public AriaSuggestBox(SuggestOracle oracle) {
    this(new AriaTextBox(), oracle);
}
项目: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()));
}
项目:multipool-stats-backend    文件:MiddlecoinViewPresenter.java   
@Override
public SuggestOracle getAddressesSuggestOracle() {
    return new AddressSuggestOracle(clientFactory);
}
项目:multipool-stats-backend    文件:CoinshiftViewPresenter.java   
@Override
public SuggestOracle getAddressesSuggestOracle() {
    return new AddressSuggestOracle(clientFactory);
}
项目:multipool-stats-backend    文件:CoinsolverViewPresenter.java   
@Override
public SuggestOracle getAddressesSuggestOracle() {
    return new AddressSuggestOracle(clientFactory);
}
项目:multipool-stats-backend    文件:WaffleViewPresenter.java   
@Override
public SuggestOracle getAddressesSuggestOracle() {
    return new AddressSuggestOracle(clientFactory);
}
项目:solr-explorer    文件:AutoSuggestTextEditor.java   
public AutoSuggestTextEditor(SuggestOracle oracle) {
    this(oracle, "", true);
}
项目:solr-explorer    文件:AutoSuggestTextEditor.java   
public AutoSuggestTextEditor(SuggestOracle oracle, String defaultText) {
    this(oracle, defaultText, true);
}
项目:solr-explorer    文件:AutoSuggestTextEditor.java   
public AutoSuggestTextEditor(SuggestOracle oracle, boolean enabled) {
    this(oracle, "", enabled);
}
项目:gwtbootstrap3    文件:SuggestBox.java   
/**
 * Constructor for {@link SuggestBox}. Creates a {@link TextBox} to use with this {@link SuggestBox}.
 *
 * @param oracle the oracle for this <code>SuggestBox</code>
 */
public SuggestBox(SuggestOracle oracle) {
    this(oracle, new TextBox());
}
项目:gwtbootstrap3    文件:SuggestBox.java   
/**
 * Constructor for {@link SuggestBox}. The text box will be removed from it's current location and wrapped
 * by the {@link SuggestBox}.
 *
 * @param oracle supplies suggestions based upon the current contents of the text widget
 * @param box the text widget
 */
public SuggestBox(SuggestOracle oracle, ValueBoxBase<String> box) {
    this(oracle, box, new CustomSuggestionDisplay());
}
项目:gwtbootstrap3    文件:SuggestBox.java   
/**
 * Constructor for {@link SuggestBox}. The text box will be removed from it's current location and wrapped
 * by the {@link SuggestBox}.
 *
 * @param oracle supplies suggestions based upon the current contents of the text widget
 * @param box the text widget
 * @param suggestDisplay the class used to display suggestions
 */
public SuggestBox(SuggestOracle oracle, ValueBoxBase<String> box, SuggestionDisplay suggestDisplay) {
    super(oracle, box, suggestDisplay);
    setStyleName(Styles.FORM_CONTROL);
}
项目:multipool-stats-backend    文件:PoolView.java   
public SuggestOracle getAddressesSuggestOracle();