From 23183e37594e1763adc9e32a7fdc939ed8d47d17 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 12 Aug 2010 09:09:23 +0000 Subject: [PATCH] Test case for #5427 svn changeset:14465/svn branch:6.4 --- .../components/table/EditableModeChange.html | 56 +++++++++++++ .../components/table/EditableModeChange.java | 78 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/table/EditableModeChange.html create mode 100644 tests/src/com/vaadin/tests/components/table/EditableModeChange.java diff --git a/tests/src/com/vaadin/tests/components/table/EditableModeChange.html b/tests/src/com/vaadin/tests/components/table/EditableModeChange.html new file mode 100644 index 0000000000..2a7949f3ba --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/EditableModeChange.html @@ -0,0 +1,56 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.table.EditableModeChange?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]24,8
doubleClickvaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]24,8
enterCharactervaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]baa
mouseClickvaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[1]/domChild[0]34,11
assertTextvaadin=runcomvaadintestscomponentstableEditableModeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]baa
screenCaptureselected-teemu
+ + diff --git a/tests/src/com/vaadin/tests/components/table/EditableModeChange.java b/tests/src/com/vaadin/tests/components/table/EditableModeChange.java new file mode 100644 index 0000000000..3ed0161b82 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/table/EditableModeChange.java @@ -0,0 +1,78 @@ +package com.vaadin.tests.components.table; + +import java.util.Date; + +import com.vaadin.data.Container; +import com.vaadin.event.ItemClickEvent; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Component; +import com.vaadin.ui.DefaultFieldFactory; +import com.vaadin.ui.Field; +import com.vaadin.ui.Table; +import com.vaadin.ui.TableFieldFactory; + +public class EditableModeChange extends TestBase { + + private ItemClickEvent selectionEvent; + + private final String[] names = { "Teemu", "Teppo", "Seppo", "Matti", + "Pekka" }; + + @Override + public void setup() { + + final Table items = new Table("Items - double-click to edit"); + items.setSelectable(true); + items.addContainerProperty("name", String.class, ""); + items.addContainerProperty("birthday", Date.class, ""); + + final TableFieldFactory fieldFactory = new ItemFieldFactory(); + items.setTableFieldFactory(fieldFactory); + + for (String name : names) { + items.addItem(name); + items.getItem(name).getItemProperty("name").setValue(name); + items.getItem(name).getItemProperty("birthday") + .setValue(new Date()); + } + + items.addListener(new ItemClickEvent.ItemClickListener() { + + public void itemClick(ItemClickEvent event) { + if (event.isDoubleClick()) { + selectionEvent = event; + items.setEditable(true); + } else if (items.isEditable()) { + items.setEditable(false); + } + } + }); + + addComponent(items); + } + + private class ItemFieldFactory extends DefaultFieldFactory { + @Override + public Field createField(Container container, Object itemId, + Object propertyId, Component uiContext) { + if (selectionEvent != null) { + if ((selectionEvent.getItemId().equals(itemId)) + && (selectionEvent.getPropertyId().equals(propertyId))) { + return super.createField(container, itemId, propertyId, + uiContext); + } + } + return null; + } + } + + @Override + protected String getDescription() { + return "Double click a cell to edit, then click on another row to select it (editmode is set to false). The clicked row should now be selected without any flickering."; + } + + @Override + protected Integer getTicketNumber() { + return 5427; + } +} \ No newline at end of file -- 2.39.5