Explorar el Código

Entering "" in ComboBox now selects null even if it's not showing in list. Fixes #2986

svn changeset:8054/svn branch:6.0
tags/6.7.0.beta1
Marc Englund hace 15 años
padre
commit
19a5933502
Se han modificado 1 ficheros con 32 adiciones y 10 borrados
  1. 32
    10
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java

+ 32
- 10
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java Ver fichero

@@ -436,6 +436,20 @@ public class VFilterSelect extends Composite implements Paintable, Field,
public void doSelectedItemAction() {
final MenuItem item = getSelectedItem();
final String enteredItemValue = tb.getText();
if (nullSelectionAllowed && "".equals(enteredItemValue)) {
if (nullSelectItem) {
reset();
return;
}
// null is not visible on pages != 0, and not visible when
// filtering: handle separately
client.updateVariable(paintableId, "filter", "", false);
client.updateVariable(paintableId, "page", 0, false);
client.updateVariable(paintableId, "selected", new String[] {},
immediate);
suggestionPopup.hide();
return;
}
// check for exact match in menu
int p = getItems().size();
if (p > 0) {
@@ -543,6 +557,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
private int totalMatches;
private boolean allowNewItem;
private boolean nullSelectionAllowed;
private boolean nullSelectItem;
private boolean enabled;

// shown in unfocused empty field, disappears on focus (e.g "Search here")
@@ -656,6 +671,9 @@ public class VFilterSelect extends Composite implements Paintable, Field,

nullSelectionAllowed = uidl.hasAttribute("nullselect");

nullSelectItem = uidl.hasAttribute("nullselectitem")
&& uidl.getBooleanAttribute("nullselectitem");

currentPage = uidl.getIntVariable("page");

if (uidl.hasAttribute("pagelength")) {
@@ -867,16 +885,7 @@ public class VFilterSelect extends Composite implements Paintable, Field,
break;
}
case KeyboardListener.KEY_ESCAPE:
if (currentSuggestion != null) {
String text = currentSuggestion.getReplacementString();
setPromptingOff(text);
selectedOptionKey = currentSuggestion.key;
} else {
setPromptingOn();
selectedOptionKey = null;
}
lastFilter = "";
suggestionPopup.hide();
reset();
break;
default:
filterOptions(currentPage);
@@ -885,6 +894,19 @@ public class VFilterSelect extends Composite implements Paintable, Field,
}
}

private void reset() {
if (currentSuggestion != null) {
String text = currentSuggestion.getReplacementString();
setPromptingOff(text);
selectedOptionKey = currentSuggestion.key;
} else {
setPromptingOn();
selectedOptionKey = null;
}
lastFilter = "";
suggestionPopup.hide();
}

/**
* Listener for popupopener
*/

Cargando…
Cancelar
Guardar