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); } } }
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); }
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()); }
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); } }); }
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; }
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; }
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; }
public SuggestOracle oracle () { if (oracle == null) { oracle = new UserOracle(); } return oracle; }
public SuggestOracle oracle () { if (oracle == null) { oracle = new PageOracle(); } return oracle; }
/** * @return */ public SuggestOracle oracle () { if (oracle == null) { oracle = new PostOracle(); } return oracle; }
public SuggestOracle oracle () { if (oracle == null) { oracle = new RoleOracle(); } return oracle; }
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); }
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; }
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(); } }); }
@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); } }); } }
@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); }
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); }
public AriaSuggestBox(SuggestOracle oracle) { this(new AriaTextBox(), oracle); }
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())); }
public SuggestionBox(SuggestOracle oracle) { super(oracle); addKeyboardListener(this); addFocusListener(this); }
NaifOracleCallback(SuggestOracle.Request request, SuggestOracle.Callback cb) { this.request= request; this.cb= cb; }
public NaifInputField (FieldDef fd, SuggestOracle suggest) { super(fd,suggest); }
public SuggestBoxInputField(FieldDef fieldDef, SuggestOracle oracle) { _inputField = new TextBoxInputField(fieldDef,true); _suggestBox = new SuggestBox(oracle, _inputField.getTextBox()); initWidget(_suggestBox ); }
ParamSuggester(List<String> operators, SuggestOracle parameterSuggestionOracle) { this.operators = operators; this.parameterSuggestionOracle = parameterSuggestionOracle; }
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); }
public RemoteSuggestOracle(SuggestOracle src) { oracle = src; }
@Override public SuggestOracle getAddressesSuggestOracle() { return new AddressSuggestOracle(clientFactory); }
public AutoSuggestTextEditor(SuggestOracle oracle) { this(oracle, "", true); }
public AutoSuggestTextEditor(SuggestOracle oracle, String defaultText) { this(oracle, defaultText, true); }
public AutoSuggestTextEditor(SuggestOracle oracle, boolean enabled) { this(oracle, "", enabled); }
/** * 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()); }
/** * 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()); }
/** * 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); }
public SuggestOracle getAddressesSuggestOracle();