summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-07-31 12:00:44 +0300
committerLeif Åstrand <leif@vaadin.com>2012-07-31 12:00:44 +0300
commite6ba86347ce0aea0b2dd7aa064586ce4fe7f2096 (patch)
tree5d07d002edd4984536ade795c8c42451651d6f5c
parent569a82a7bfc4958a9ac164e16caecc3fb47fdbc7 (diff)
parent64c7bbb569d5194eb9c5c083726a8c96053368e8 (diff)
downloadvaadin-framework-e6ba86347ce0aea0b2dd7aa064586ce4fe7f2096.tar.gz
vaadin-framework-e6ba86347ce0aea0b2dd7aa064586ce4fe7f2096.zip
Merge remote-tracking branch 'origin/6.8'
Conflicts: src/com/vaadin/terminal/gwt/client/ui/popupview/VPopupView.java tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
-rw-r--r--src/com/vaadin/data/util/sqlcontainer/SQLContainer.java1
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/popupview/VPopupView.java33
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/splitpanel/VAbstractSplitPanel.java19
-rw-r--r--src/com/vaadin/ui/AbstractSelect.java44
-rw-r--r--src/com/vaadin/ui/Table.java26
-rw-r--r--tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java15
-rw-r--r--tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java22
-rw-r--r--tests/testbench/com/vaadin/tests/components/table/MultiSelectValueOrder.html275
-rw-r--r--tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java78
-rw-r--r--tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java27
-rw-r--r--tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java91
11 files changed, 503 insertions, 128 deletions
diff --git a/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
index 250b2eb4c3..5827390723 100644
--- a/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
+++ b/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
@@ -534,6 +534,7 @@ public class SQLContainer implements Container, Container.Filterable,
@Override
public void removeContainerFilter(Filter filter) {
filters.remove(filter);
+ refresh();
}
/**
diff --git a/src/com/vaadin/terminal/gwt/client/ui/popupview/VPopupView.java b/src/com/vaadin/terminal/gwt/client/ui/popupview/VPopupView.java
index c923c5d0ab..1b7cfd091f 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/popupview/VPopupView.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/popupview/VPopupView.java
@@ -10,6 +10,8 @@ import java.util.Set;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.DOM;
@@ -26,6 +28,8 @@ import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ComponentConnector;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VCaptionWrapper;
+import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler;
+import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
import com.vaadin.terminal.gwt.client.ui.VOverlay;
import com.vaadin.terminal.gwt.client.ui.richtextarea.VRichTextArea;
@@ -183,8 +187,23 @@ public class VPopupView extends HTML {
private final Set<Element> activeChildren = new HashSet<Element>();
private boolean hiding = false;
+ private ShortcutActionHandler shortcutActionHandler;
+
public CustomPopup() {
super(true, false, true); // autoHide, not modal, dropshadow
+
+ // Delegate popup keyboard events to the relevant handler. The
+ // events do not propagate automatically because the popup is
+ // directly attached to the RootPanel.
+ addDomHandler(new KeyDownHandler() {
+ @Override
+ public void onKeyDown(KeyDownEvent event) {
+ if (shortcutActionHandler != null) {
+ shortcutActionHandler.handleKeyboardEvent(Event
+ .as(event.getNativeEvent()));
+ }
+ }
+ }, KeyDownEvent.getType());
}
// For some reason ONMOUSEOUT events are not always received, so we have
@@ -233,12 +252,26 @@ public class VPopupView extends HTML {
remove(popupComponentWidget);
}
hasHadMouseOver = false;
+ shortcutActionHandler = null;
super.hide(autoClosed);
}
@Override
public void show() {
hiding = false;
+
+ // Find the shortcut action handler that should handle keyboard
+ // events from the popup. The events do not propagate automatically
+ // because the popup is directly attached to the RootPanel.
+ Widget widget = VPopupView.this;
+ while (shortcutActionHandler == null && widget != null) {
+ if (widget instanceof ShortcutActionHandlerOwner) {
+ shortcutActionHandler = ((ShortcutActionHandlerOwner) widget)
+ .getShortcutActionHandler();
+ }
+ widget = widget.getParent();
+ }
+
super.show();
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VAbstractSplitPanel.java b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VAbstractSplitPanel.java
index 1c14ce2a73..a20c0476a5 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VAbstractSplitPanel.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/splitpanel/VAbstractSplitPanel.java
@@ -255,23 +255,22 @@ public class VAbstractSplitPanel extends ComplexPanel {
* @return
*/
private float convertToPercentage(String pos) {
- float posAsFloat = 0;
-
- if (pos.indexOf("px") > 0) {
- int posAsInt = Integer.parseInt(pos.substring(0, pos.length() - 2));
+ if (pos.endsWith("px")) {
+ float pixelPosition = Float.parseFloat(pos.substring(0,
+ pos.length() - 2));
int offsetLength = orientation == ORIENTATION_HORIZONTAL ? getOffsetWidth()
: getOffsetHeight();
- // 100% needs special handling
- if (posAsInt + getSplitterSize() >= offsetLength) {
- posAsInt = offsetLength;
+ // Take splitter size into account at the edge
+ if (pixelPosition + getSplitterSize() >= offsetLength) {
+ return 100;
}
- posAsFloat = ((float) posAsInt / (float) offsetLength * 100);
+ return pixelPosition / offsetLength * 100;
} else {
- posAsFloat = Float.parseFloat(pos.substring(0, pos.length() - 1));
+ assert pos.endsWith("%");
+ return Float.parseFloat(pos.substring(0, pos.length() - 1));
}
- return posAsFloat;
}
/**
diff --git a/src/com/vaadin/ui/AbstractSelect.java b/src/com/vaadin/ui/AbstractSelect.java
index 63e7ae92fe..0a97ceb649 100644
--- a/src/com/vaadin/ui/AbstractSelect.java
+++ b/src/com/vaadin/ui/AbstractSelect.java
@@ -436,7 +436,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
// Selection change
if (variables.containsKey("selected")) {
- final String[] ka = (String[]) variables.get("selected");
+ final String[] clientSideSelectedKeys = (String[]) variables
+ .get("selected");
// Multiselect mode
if (isMultiSelect()) {
@@ -444,19 +445,20 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
// TODO Optimize by adding repaintNotNeeded when applicable
// Converts the key-array to id-set
- final LinkedList<Object> s = new LinkedList<Object>();
- for (int i = 0; i < ka.length; i++) {
- final Object id = itemIdMapper.get(ka[i]);
+ final LinkedList<Object> acceptedSelections = new LinkedList<Object>();
+ for (int i = 0; i < clientSideSelectedKeys.length; i++) {
+ final Object id = itemIdMapper
+ .get(clientSideSelectedKeys[i]);
if (!isNullSelectionAllowed()
&& (id == null || id == getNullSelectionItemId())) {
// skip empty selection if nullselection is not allowed
requestRepaint();
} else if (id != null && containsId(id)) {
- s.add(id);
+ acceptedSelections.add(id);
}
}
- if (!isNullSelectionAllowed() && s.size() < 1) {
+ if (!isNullSelectionAllowed() && acceptedSelections.size() < 1) {
// empty selection not allowed, keep old value
requestRepaint();
return;
@@ -464,27 +466,32 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
// Limits the deselection to the set of visible items
// (non-visible items can not be deselected)
- final Collection<?> visible = getVisibleItemIds();
- if (visible != null) {
+ Collection<?> visibleNotSelected = getVisibleItemIds();
+ if (visibleNotSelected != null) {
+ visibleNotSelected = new HashSet<Object>(visibleNotSelected);
+ // Don't remove those that will be added to preserve order
+ visibleNotSelected.removeAll(acceptedSelections);
+
@SuppressWarnings("unchecked")
Set<Object> newsel = (Set<Object>) getValue();
if (newsel == null) {
- newsel = new HashSet<Object>();
+ newsel = new LinkedHashSet<Object>();
} else {
- newsel = new HashSet<Object>(newsel);
+ newsel = new LinkedHashSet<Object>(newsel);
}
- newsel.removeAll(visible);
- newsel.addAll(s);
+ newsel.removeAll(visibleNotSelected);
+ newsel.addAll(acceptedSelections);
setValue(newsel, true);
}
} else {
// Single select mode
if (!isNullSelectionAllowed()
- && (ka.length == 0 || ka[0] == null || ka[0] == getNullSelectionItemId())) {
+ && (clientSideSelectedKeys.length == 0
+ || clientSideSelectedKeys[0] == null || clientSideSelectedKeys[0] == getNullSelectionItemId())) {
requestRepaint();
return;
}
- if (ka.length == 0) {
+ if (clientSideSelectedKeys.length == 0) {
// Allows deselection only if the deselected item is
// visible
final Object current = getValue();
@@ -493,7 +500,8 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
setValue(null, true);
}
} else {
- final Object id = itemIdMapper.get(ka[0]);
+ final Object id = itemIdMapper
+ .get(clientSideSelectedKeys[0]);
if (!isNullSelectionAllowed() && id == null) {
requestRepaint();
} else if (id != null
@@ -675,10 +683,10 @@ public abstract class AbstractSelect extends AbstractField<Object> implements
if (isMultiSelect()) {
if (newValue == null) {
- super.setValue(new HashSet<Object>(), repaintIsNotNeeded);
+ super.setValue(new LinkedHashSet<Object>(), repaintIsNotNeeded);
} else if (Collection.class.isAssignableFrom(newValue.getClass())) {
- super.setValue(new HashSet<Object>((Collection<?>) newValue),
- repaintIsNotNeeded);
+ super.setValue(new LinkedHashSet<Object>(
+ (Collection<?>) newValue), repaintIsNotNeeded);
}
} else if (newValue == null || items.containsId(newValue)) {
super.setValue(newValue, repaintIsNotNeeded);
diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java
index 78427a0a66..71f41fb257 100644
--- a/src/com/vaadin/ui/Table.java
+++ b/src/com/vaadin/ui/Table.java
@@ -2410,8 +2410,9 @@ public class Table extends AbstractSelect implements Action.Container,
* The end key
* @return
*/
- private Set<Object> getItemIdsInRange(Object itemId, final int length) {
- HashSet<Object> ids = new HashSet<Object>();
+ private LinkedHashSet<Object> getItemIdsInRange(Object itemId,
+ final int length) {
+ LinkedHashSet<Object> ids = new LinkedHashSet<Object>();
for (int i = 0; i < length; i++) {
assert itemId != null; // should not be null unless client-server
// are out of sync
@@ -2431,21 +2432,15 @@ public class Table extends AbstractSelect implements Action.Container,
final String[] ka = (String[]) variables.get("selected");
final String[] ranges = (String[]) variables.get("selectedRanges");
- Set<Object> renderedItemIds = getCurrentlyRenderedItemIds();
+ Set<Object> renderedButNotSelectedItemIds = getCurrentlyRenderedItemIds();
@SuppressWarnings("unchecked")
- HashSet<Object> newValue = new HashSet<Object>(
+ HashSet<Object> newValue = new LinkedHashSet<Object>(
(Collection<Object>) getValue());
if (variables.containsKey("clearSelections")) {
// the client side has instructed to swipe all previous selections
newValue.clear();
- } else {
- /*
- * first clear all selections that are currently rendered rows (the
- * ones that the client side counterpart is aware of)
- */
- newValue.removeAll(renderedItemIds);
}
/*
@@ -2462,6 +2457,7 @@ public class Table extends AbstractSelect implements Action.Container,
requestRepaint();
} else if (id != null && containsId(id)) {
newValue.add(id);
+ renderedButNotSelectedItemIds.remove(id);
}
}
@@ -2471,9 +2467,17 @@ public class Table extends AbstractSelect implements Action.Container,
String[] split = range.split("-");
Object startItemId = itemIdMapper.get(split[0]);
int length = Integer.valueOf(split[1]);
- newValue.addAll(getItemIdsInRange(startItemId, length));
+ LinkedHashSet<Object> itemIdsInRange = getItemIdsInRange(
+ startItemId, length);
+ newValue.addAll(itemIdsInRange);
+ renderedButNotSelectedItemIds.removeAll(itemIdsInRange);
}
}
+ /*
+ * finally clear all currently rendered rows (the ones that the client
+ * side counterpart is aware of) that the client didn't send as selected
+ */
+ newValue.removeAll(renderedButNotSelectedItemIds);
if (!isNullSelectionAllowed() && newValue.isEmpty()) {
// empty selection not allowed, keep old value
diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java
index 66b5e23cda..1bc76fff1e 100644
--- a/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java
+++ b/tests/testbench/com/vaadin/tests/components/abstractfield/AbstractFieldTest.java
@@ -24,6 +24,8 @@ public abstract class AbstractFieldTest<T extends AbstractField<?>> extends
AbstractComponentTest<T> implements ValueChangeListener,
ReadOnlyStatusChangeListener {
+ private boolean sortValueChanges = true;
+
@Override
protected void createActions() {
super.createActions();
@@ -73,6 +75,17 @@ public abstract class AbstractFieldTest<T extends AbstractField<?>> extends
}
}
});
+
+ MenuItem sortValueChangesItem = abstractField.addItem(
+ "Show sorted value changes", new MenuBar.Command() {
+ public void menuSelected(MenuItem selectedItem) {
+ sortValueChanges = selectedItem.isChecked();
+ log("Show sorted value changes: "
+ + sortValueChanges);
+ }
+ });
+ sortValueChangesItem.setCheckable(true);
+ sortValueChangesItem.setChecked(true);
}
}
@@ -140,7 +153,7 @@ public abstract class AbstractFieldTest<T extends AbstractField<?>> extends
@SuppressWarnings({ "rawtypes", "unchecked" })
private String getValue(Property property) {
Object o = property.getValue();
- if (o instanceof Collection) {
+ if (o instanceof Collection && sortValueChanges) {
// Sort collections to avoid problems with values printed in
// different order
try {
diff --git a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java
index 47c97bbc21..6461d10277 100644
--- a/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java
+++ b/tests/testbench/com/vaadin/tests/components/popupview/PopupViewClickShortcut.java
@@ -45,17 +45,19 @@ public class PopupViewClickShortcut extends TestBase {
l.setCaption(caption);
l.setWidth(null);
- Button b = new Button("Submit " + caption, new Button.ClickListener() {
- private int i = 5;
+ Button b = new Button("Submit " + caption + " (Ctrl+Alt+"
+ + String.valueOf(Character.toChars(keyCode)) + ")",
+ new Button.ClickListener() {
+ private int i = 5;
- @Override
- public void buttonClick(ClickEvent event) {
- log.log("Submitted from "
- + event.getButton().getParent().getCaption());
- t.addItem(new String[] { "added " + i++ }, i);
- }
- });
- b.setClickShortcut(keyCode, ModifierKey.ALT);
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log.log("Submitted from "
+ + event.getButton().getParent().getCaption());
+ t.addItem(new String[] { "added " + i++ }, i);
+ }
+ });
+ b.setClickShortcut(keyCode, ModifierKey.CTRL, ModifierKey.ALT);
l.addComponent(t);
l.addComponent(b);
diff --git a/tests/testbench/com/vaadin/tests/components/table/MultiSelectValueOrder.html b/tests/testbench/com/vaadin/tests/components/table/MultiSelectValueOrder.html
new file mode 100644
index 0000000000..4bac7741da
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/table/MultiSelectValueOrder.html
@@ -0,0 +1,275 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.Tables?restartApplication</td>
+ <td></td>
+</tr>
+<!--Default multi select-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
+ <td>6,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item4</td>
+ <td>73,0</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item1</td>
+ <td>33,13</td>
+</tr>
+<!--ValueChangeListener-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
+ <td>14,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>75,5</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item0</td>
+ <td>64,6</td>
+</tr>
+<!--Disable sorting value change logging-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item1</td>
+ <td>16,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item3</td>
+ <td>22,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item1</td>
+ <td>16,12</td>
+</tr>
+<!--Clear log to ensure numbers matches with the later case-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item1</td>
+ <td>29,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td>
+ <td>40,7</td>
+</tr>
+<!--Start clicking-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[0]/domChild[0]</td>
+ <td>48,18</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>0. ValueChangeEvent, new value: '[Item 5]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]</td>
+ <td>40,12:ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>1. ValueChangeEvent, new value: '[Item 5, Item 3]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[1]/domChild[0]</td>
+ <td>54,15:ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>2. ValueChangeEvent, new value: '[Item 5, Item 3, Item 7]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[8]/domChild[1]/domChild[0]</td>
+ <td>54,9:shift+ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>3. ValueChangeEvent, new value: '[Item 5, Item 3, Item 7, Item 8, Item 9]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[0]</td>
+ <td>67,8:ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>4. ValueChangeEvent, new value: '[Item 5, Item 3, Item 7, Item 8, Item 9, Item 1]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[2]/domChild[0]</td>
+ <td>71,8:shift+ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>5. ValueChangeEvent, new value: '[Item 5, Item 3, Item 7, Item 8, Item 9, Item 1, Item 2, Item 4]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[2]/domChild[0]</td>
+ <td>56,6:ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>6. ValueChangeEvent, new value: '[Item 3, Item 7, Item 8, Item 9, Item 1, Item 2, Item 4]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[2]/domChild[0]</td>
+ <td>67,11:ctrl</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>7. ValueChangeEvent, new value: '[Item 3, Item 7, Item 8, Item 9, Item 1, Item 2, Item 4, Item 5]'</td>
+</tr>
+<!--Simple multi select-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
+ <td>33,9</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item4</td>
+ <td>44,7</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item2</td>
+ <td>40,11</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item2</td>
+ <td>58,8</td>
+</tr>
+<!--Clear value-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item0</td>
+ <td>38,6</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item4</td>
+ <td>14,8</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[1]/VMenuBar[0]#item3</td>
+ <td>55,3</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[2]/VMenuBar[0]#item0</td>
+ <td>21,3</td>
+</tr>
+<!--Clear log-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_Smenu#item1</td>
+ <td>26,7</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::Root/VOverlay[0]/VMenuBar[0]#item1</td>
+ <td>30,6</td>
+</tr>
+<!--Start clicking-->
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]/domChild[0]</td>
+ <td>60,9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>0. ValueChangeEvent, new value: '[Item 5]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]</td>
+ <td>38,9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>1. ValueChangeEvent, new value: '[Item 5, Item 3]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[1]/domChild[0]</td>
+ <td>46,13</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>2. ValueChangeEvent, new value: '[Item 5, Item 3, Item 4]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[2]/domChild[1]/domChild[0]</td>
+ <td>65,8</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>3. ValueChangeEvent, new value: '[Item 5, Item 4]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[2]/domChild[0]</td>
+ <td>45,7</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>4. ValueChangeEvent, new value: '[Item 4]'</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_StestComponent/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[2]/domChild[0]</td>
+ <td>35,9</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableTables::PID_SLog_row_0</td>
+ <td>5. ValueChangeEvent, new value: '[Item 4, Item 5]'</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
index a5a8f7d24b..f34c12607a 100644
--- a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
+++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
@@ -1,8 +1,6 @@
package com.vaadin.tests.containers.sqlcontainer;
-import java.sql.Connection;
import java.sql.SQLException;
-import java.sql.Statement;
import com.vaadin.Application;
import com.vaadin.data.Container.ItemSetChangeEvent;
@@ -10,11 +8,6 @@ import com.vaadin.data.Container.ItemSetChangeListener;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.util.sqlcontainer.AllTests;
-import com.vaadin.data.util.sqlcontainer.SQLContainer;
-import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
-import com.vaadin.data.util.sqlcontainer.query.TableQuery;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Form;
@@ -118,75 +111,4 @@ public class CheckboxUpdateProblem extends Application.LegacyApplication
}
- private class DatabaseHelper {
-
- private JDBCConnectionPool connectionPool = null;
- private SQLContainer testContainer = null;
- private static final String TABLENAME = "testtable";
-
- public DatabaseHelper() {
- initConnectionPool();
- initDatabase();
- initContainers();
- }
-
- private void initDatabase() {
- try {
- Connection conn = connectionPool.reserveConnection();
- Statement statement = conn.createStatement();
- try {
- statement.execute("drop table " + TABLENAME);
- } catch (SQLException e) {
- // Will fail if table doesn't exist, which is OK.
- conn.rollback();
- }
- switch (AllTests.db) {
- case MYSQL:
- statement
- .execute("create table "
- + TABLENAME
- + " (id integer auto_increment not null, field1 varchar(100), field2 boolean, primary key(id))");
- break;
- case POSTGRESQL:
- statement
- .execute("create table "
- + TABLENAME
- + " (\"id\" serial primary key, \"field1\" varchar(100), \"field2\" boolean)");
- break;
- }
- statement.executeUpdate("insert into " + TABLENAME
- + " values(default, 'Kalle', 'true')");
- statement.close();
- conn.commit();
- connectionPool.releaseConnection(conn);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- private void initContainers() {
- try {
- TableQuery q1 = new TableQuery(TABLENAME, connectionPool);
- q1.setVersionColumn("id");
- testContainer = new SQLContainer(q1);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- private void initConnectionPool() {
- try {
- connectionPool = new SimpleJDBCConnectionPool(
- AllTests.dbDriver, AllTests.dbURL, AllTests.dbUser,
- AllTests.dbPwd, 2, 5);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
- public SQLContainer getTestContainer() {
- return testContainer;
- }
- }
-
}
diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java
new file mode 100644
index 0000000000..b7d1b8c37e
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/ComboBoxUpdateProblem.java
@@ -0,0 +1,27 @@
+package com.vaadin.tests.containers.sqlcontainer;
+
+import com.vaadin.Application;
+import com.vaadin.ui.AbstractSelect.Filtering;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Root;
+
+/**
+ * See http://dev.vaadin.com/ticket/9155 .
+ */
+public class ComboBoxUpdateProblem extends Application.LegacyApplication {
+ private final DatabaseHelper databaseHelper = new DatabaseHelper();
+
+ @Override
+ public void init() {
+ setMainWindow(new Root.LegacyWindow("Test window"));
+
+ ComboBox combo = new ComboBox("Names",
+ databaseHelper.getTestContainer());
+ combo.setItemCaptionPropertyId("FIELD1");
+ combo.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS);
+ combo.setImmediate(true);
+
+ getMainWindow().addComponent(combo);
+ }
+
+} \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
new file mode 100644
index 0000000000..b7b1e74eb0
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/containers/sqlcontainer/DatabaseHelper.java
@@ -0,0 +1,91 @@
+package com.vaadin.tests.containers.sqlcontainer;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import com.vaadin.data.util.sqlcontainer.AllTests;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.TableQuery;
+
+class DatabaseHelper {
+
+ private JDBCConnectionPool connectionPool = null;
+ private SQLContainer testContainer = null;
+ private static final String TABLENAME = "testtable";
+
+ public DatabaseHelper() {
+ initConnectionPool();
+ initDatabase();
+ initContainers();
+ }
+
+ private void initDatabase() {
+ try {
+ Connection conn = connectionPool.reserveConnection();
+ Statement statement = conn.createStatement();
+ try {
+ statement.execute("drop table " + TABLENAME);
+ } catch (SQLException e) {
+ // Will fail if table doesn't exist, which is OK.
+ conn.rollback();
+ }
+ switch (AllTests.db) {
+ case HSQLDB:
+ statement
+ .execute("create table "
+ + TABLENAME
+ + " (id integer GENERATED BY DEFAULT AS IDENTITY, field1 varchar(100), field2 boolean, primary key(id))");
+ break;
+ case MYSQL:
+ statement
+ .execute("create table "
+ + TABLENAME
+ + " (id integer auto_increment not null, field1 varchar(100), field2 boolean, primary key(id))");
+ break;
+ case POSTGRESQL:
+ statement
+ .execute("create table "
+ + TABLENAME
+ + " (\"id\" serial primary key, \"field1\" varchar(100), \"field2\" boolean)");
+ break;
+ }
+ statement.executeUpdate("insert into " + TABLENAME
+ + " values(default, 'Kalle', 'true')");
+ statement.executeUpdate("insert into " + TABLENAME
+ + " values(default, 'Ville', 'true')");
+ statement.executeUpdate("insert into " + TABLENAME
+ + " values(default, 'Jussi', 'true')");
+ statement.close();
+ conn.commit();
+ connectionPool.releaseConnection(conn);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void initContainers() {
+ try {
+ TableQuery q1 = new TableQuery(TABLENAME, connectionPool);
+ q1.setVersionColumn("id");
+ testContainer = new SQLContainer(q1);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void initConnectionPool() {
+ try {
+ connectionPool = new SimpleJDBCConnectionPool(AllTests.dbDriver,
+ AllTests.dbURL, AllTests.dbUser, AllTests.dbPwd, 2, 5);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public SQLContainer getTestContainer() {
+ return testContainer;
+ }
+} \ No newline at end of file