@Override public HandlerRegistration addSelectionChangeHandler(SelectionChangeHandler handler) { return suggestBox.addSelectionChangeHandler(handler); }
@Override public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) { return suggestBox.addValueChangeHandler(handler); }
@Override public void exec(IdableSuggestion result) { currentSuggestion = result; KSSuggestBox.this.setText((currentSuggestion == null) ? "" : currentSuggestion.getReplacementString()); currentId = KSSuggestBox.this.getSelectedId(); } });
currentSuggestion.setDisplayString(""); currentSuggestion.setReplacementString(""); KSSuggestBox.this.setText(""); currentId = KSSuggestBox.this.getSelectedId(); this.setValue(id);
private void setupSuggestBox(LookupMetadata inLookupMetadata){ if(config.canEdit) { final SearchSuggestOracle orgSearchOracle = new SearchSuggestOracle(inLookupMetadata); final KSSuggestBox suggestBox = new KSSuggestBox(orgSearchOracle, true); suggestBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { suggestBox.addSelectionChangeHandler(new SelectionChangeHandler(){ ((KSSuggestBox) basicWidget.get()).setAutoSelectEnabled(false); orgSearchOracle.setTextWidget(((SuggestBox) basicWidget.get()).getTextBox()); } else {
@Override public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) { currentSuggestion = (IdableSuggestion)(event.getSelectedItem()); getTextBox().setFocus(true); currentId = KSSuggestBox.this.getSelectedId(); SelectionChangeEvent.fire(KSSuggestBox.this); } });
@Override public void onBlur(BlurEvent event) { String currentText = KSSuggestBox.this.getText(); boolean isEmpty = false; if(currentText != null && !currentText.equals("")){ if((currentSuggestion != null && !KSSuggestBox.this.getText().equals(currentSuggestion.getReplacementString())) || currentSuggestion == null){ currentSuggestion = KSSuggestBox.this.oracle.getSuggestionByText(currentText); if(!KSSuggestBox.this.getSelectedId().equals(currentId)){ currentId = KSSuggestBox.this.getSelectedId(); if(isEmpty){ currentId = "";
@Override public String getValue() { return suggestBox.getSelectedId(); }
public void clear() { if(basicWidget instanceof KSTextBox) { ((KSTextBox)basicWidget).setText(null); } else if(basicWidget instanceof KSSuggestBox) { ((KSSuggestBox) basicWidget).setValue((String)null); } else if(basicWidget instanceof KSLabel) { ((KSLabel)basicWidget).setText(null); } else if(basicWidget instanceof KSDropDown) { ((KSDropDown)basicWidget).clear(); } else { ((KSSuggestBox) basicWidget).setValue(null, false); } } public void setValue(final String id, String translation) {
@Override protected void onEnsureDebugId(String baseID) { super.onEnsureDebugId(baseID); suggestBox.getTextBox().ensureDebugId(baseID); }
this.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>(){ this.getTextBox().addBlurHandler(new BlurHandler(){
public String getText() { return suggestBox.getText(); }
@Override public HandlerRegistration addSelectionChangeHandler( SelectionChangeHandler handler) { return addHandler(handler, SelectionChangeEvent.getType()); }
public String getSelectedId() { return suggestBox.getSelectedId(); }
public void setResults(List<SelectedResults> results) { if (basicWidget instanceof KSTextBox) { ((KSTextBox)basicWidget).setText(results.get(0).getDisplayKey()); //FIXME: what about the result id? } else if (basicWidget.getClass().getName().contains("ContainerWidget")) { List<String> selections = new ArrayList<String>(); for (SelectedResults result: results) { //selections.add(result.getDisplayKey()); //FIXME: what about the result ids? selections.add(result.getReturnKey()); //we don't need display key, at least for now } ((SelectionContainerWidget) basicWidget).setSelections(selections); } else if (basicWidget instanceof KSSuggestBox) { IdableSuggestion theSuggestion = new IdableSuggestion(); theSuggestion.setReplacementString(results.get(0).getDisplayKey()); theSuggestion.setId(results.get(0).getReturnKey()); theSuggestion.setAttrMap(results.get(0).getResultRow().getColumnValues()); ((KSSuggestBox) basicWidget).setValue(theSuggestion); } } public void clear() {
private void init() { focus.addWidget(suggestBox); loSearchOracle.setTextWidget(suggestBox.getTextBox()); main.add(suggestBox); initWidget(main); }
@Override public void onSelectionChange(SelectionChangeEvent event) { //Compare the user entered value in picker's input textbox with the current display value //from the picker suggest list, if they are the same (ie. user has selected item from list) //then enable the add to list button. NOTE: This comparison should not be required if the picker //ONLY fired selection change event when an actual selection change took place, but doesn't seem //to be doing that. String userValue = ((KSSuggestBox) picker.getInputWidget()).getText(); String displayValue = picker.getDisplayValue(); boolean enabled = displayValue != null && !displayValue.isEmpty() && displayValue.equals(userValue); addItemButton.setEnabled(enabled); } });
@Override public void exec(IdableSuggestion result) { currentSuggestion = result; KSSuggestBox.this.setText((currentSuggestion == null) ? "" : currentSuggestion.getReplacementString()); if(!KSSuggestBox.this.getSelectedId().equals(currentId)){ SelectionChangeEvent.fire(KSSuggestBox.this); currentId = KSSuggestBox.this.getSelectedId(); } } });
@Override public String getValue() { return this.getSelectedId(); }