From fa4b26686d2f1184e7874c37ebcbba81a4dd86f4 Mon Sep 17 00:00:00 2001 From: Ilya Ermakov Date: Thu, 26 Feb 2015 20:54:29 +0300 Subject: Prevent opening Table context menu on short tapping on iOS (#15297) With this patch handling touchstart in Table body is prevented if it is handled in Table row. This is the smallest patch that solves the problem, refactoring remains an open problem. Change-Id: Iea54210ee81a3fdf17e45c6c98026af9080abddf --- .../components/table/TableContextMenuTouch.java | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java b/uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java new file mode 100644 index 0000000000..1d909d101e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableContextMenuTouch.java @@ -0,0 +1,106 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.Action; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Notification; +import com.vaadin.ui.Table; +import com.vaadin.ui.VerticalLayout; + +/* + * Differs from TableContextMenu by number of items, their numbering and + * immediate/selectable/multiselect toggling + */ +public class TableContextMenuTouch extends AbstractTestUI { + + private static final Action ACTION_MYACTION = new Action("Action!!"); + + @Override + protected void setup(VaadinRequest req) { + + HorizontalLayout hlay = new HorizontalLayout(); + addComponent(hlay); + hlay.setSpacing(true); + + final Table table = new Table(); + + table.addActionHandler(new Action.Handler() { + @Override + public void handleAction(Action action, Object sender, Object target) { + Notification.show("Done that :-)"); + } + + @Override + public Action[] getActions(Object target, Object sender) { + return new Action[] { ACTION_MYACTION }; + } + }); + + table.addContainerProperty("Foo", String.class, "BAR1"); + table.addContainerProperty("Bar", String.class, "FOO2"); + + table.setHeight("200px"); + + for (int i = 0; i < 30; i++) { + Object key = table.addItem(); + table.getItem(key).getItemProperty("Foo") + .setValue(new Integer(i).toString()); + } + + hlay.addComponent(table); + + VerticalLayout vlay = new VerticalLayout(); + hlay.addComponent(vlay); + + final CheckBox immediateCheckBox = new CheckBox("Immediate"); + vlay.addComponent(immediateCheckBox); + immediateCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setImmediate(immediateCheckBox.getValue()); + } + }); + immediateCheckBox.setValue(true); + table.setImmediate(immediateCheckBox.getValue()); + + final CheckBox selectableCheckBox = new CheckBox("Selectable"); + final CheckBox multiselectCheckBox = new CheckBox("Multiselect"); + vlay.addComponent(selectableCheckBox); + selectableCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setSelectable(selectableCheckBox.getValue()); + multiselectCheckBox.setEnabled(selectableCheckBox.getValue()); + } + }); + selectableCheckBox.setValue(true); + multiselectCheckBox.setEnabled(selectableCheckBox.getValue()); + table.setSelectable(selectableCheckBox.getValue()); + + vlay.addComponent(multiselectCheckBox); + multiselectCheckBox.addValueChangeListener(new ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + table.setMultiSelect(multiselectCheckBox.getValue()); + } + }); + multiselectCheckBox.setValue(true); + table.setMultiSelect(multiselectCheckBox.getValue()); + + } + + @Override + protected String getTestDescription() { + return "Context menu in Table on touch devices should not open on selection tapping"; + } + + @Override + protected Integer getTicketNumber() { + return 15297; + } + +} \ No newline at end of file -- cgit v1.2.3