diff options
author | Henri Sara <hesara@vaadin.com> | 2013-05-10 16:25:55 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-14 13:15:22 +0000 |
commit | b8c6a15da87ff6d2a83e7c0d79dd45ee120fe6a2 (patch) | |
tree | d6ad713f9a5d2e10a53df71017ff5b7b3fbbf91e /uitest | |
parent | 6d7f5e4bc9b16cb5b6bc3ad2503f251977cbb2af (diff) | |
download | vaadin-framework-b8c6a15da87ff6d2a83e7c0d79dd45ee120fe6a2.tar.gz vaadin-framework-b8c6a15da87ff6d2a83e7c0d79dd45ee120fe6a2.zip |
Clear items in ComboBox only if changed (#10924)
Selection is now sent only as a key, removed redundant attribute on the
item.
Change-Id: I882d4ae17a1dc91f7a55a0b4a94e47c078ffc022
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java b/uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java new file mode 100644 index 0000000000..fe2cffdc4c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboPushTiming.java @@ -0,0 +1,110 @@ +package com.vaadin.tests.components.combobox; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.event.FieldEvents; +import com.vaadin.event.FieldEvents.BlurEvent; +import com.vaadin.event.FieldEvents.FocusEvent; +import com.vaadin.server.VaadinSession; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; +import com.vaadin.ui.ProgressIndicator; +import com.vaadin.ui.TextField; + +public class ComboPushTiming extends TestBase { + + private int counter = 0; + private final MyExecutor executor = new MyExecutor(); + + @Override + protected void setup() { + + List<String> list = new ArrayList<String>(); + for (int i = 0; i < 100; i++) { + list.add("Item " + i); + } + + final ComboBox cb = new ComboBox("Combobox", list); + cb.setImmediate(true); + cb.setInputPrompt("Enter text"); + cb.setDescription("Some Combobox"); + addComponent(cb); + + final ObjectProperty<String> log = new ObjectProperty<String>(""); + + cb.addListener(new FieldEvents.FocusListener() { + @Override + public void focus(FocusEvent event) { + log.setValue(log.getValue().toString() + "<br>" + counter + + ": Focus event!"); + counter++; + changeValue(cb); + } + }); + + cb.addListener(new FieldEvents.BlurListener() { + @Override + public void blur(BlurEvent event) { + log.setValue(log.getValue().toString() + "<br>" + counter + + ": Blur event!"); + counter++; + } + }); + + TextField field = new TextField("Some textfield"); + field.setImmediate(true); + addComponent(field); + + Label output = new Label(log); + output.setCaption("Events:"); + + output.setContentMode(ContentMode.HTML); + addComponent(output); + + ProgressIndicator progressIndicator = new ProgressIndicator(); + addComponent(progressIndicator); + progressIndicator.setPollingInterval(3000); + } + + private void changeValue(final ComboBox cb) { + executor.execute(new Runnable() { + public void run() { + VaadinSession.getCurrent().lock(); + try { + cb.setEnabled(true); + cb.setValue("B"); + cb.setEnabled(true); + + // If this isn't sent by push or poll in the background, the + // problem will go away + } finally { + VaadinSession.getCurrent().unlock(); + } + } + }); + } + + class MyExecutor extends ThreadPoolExecutor { + public MyExecutor() { + super(5, 20, 20, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); + } + } + + @Override + protected String getDescription() { + return "When an update is received while the popup is open, the suggestion popup blurs away"; + } + + @Override + protected Integer getTicketNumber() { + return 10924; + } + +} |