diff options
author | Artur Signell <artur@vaadin.com> | 2012-11-28 20:36:03 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2012-11-29 11:13:07 +0000 |
commit | d87c6f72508a4c76c0c2274bccaf4191bb5fa204 (patch) | |
tree | 9578855494ec87a254187c5d5e3a285a2c0500a5 | |
parent | c4e6e44dde9c107c231422e48322805b50a09d05 (diff) | |
download | vaadin-framework-d87c6f72508a4c76c0c2274bccaf4191bb5fa204.tar.gz vaadin-framework-d87c6f72508a4c76c0c2274bccaf4191bb5fa204.zip |
Fixed tooltip handling for Table (#9088)
Change-Id: I0de74785fbc9eb68f958875031df59f1c61c8ec2
5 files changed, 466 insertions, 43 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 55ad533132..e0bd159951 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -4722,7 +4722,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, .getPaintable((UIDL) cell); addCell(uidl, cellContent.getWidget(), aligns[col++], - style, sorted); + style, sorted, description); } } } @@ -4859,13 +4859,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, break; } } - - if (description != null && !description.equals("")) { - TooltipInfo info = new TooltipInfo(description); - cellToolTips.put(td, info); - } else { - cellToolTips.remove(td); - } + setTooltip(td, description); td.appendChild(container); getElement().appendChild(td); @@ -4886,9 +4880,20 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } public void addCell(UIDL rowUidl, Widget w, char align, - String style, boolean sorted) { + String style, boolean sorted, String description) { final TableCellElement td = DOM.createTD().cast(); initCellWithWidget(w, align, style, sorted, td); + setTooltip(td, description); + } + + private void setTooltip(TableCellElement td, String description) { + if (description != null && !description.equals("")) { + TooltipInfo info = new TooltipInfo(description); + cellToolTips.put(td, info); + } else { + cellToolTips.remove(td); + } + } protected void initCellWithWidget(Widget w, char align, @@ -4995,10 +5000,10 @@ public class VScrollTable extends FlowPanel implements HasWidgets, com.google.gwt.dom.client.Element target) { TooltipInfo info = null; - - if (target.hasTagName("TD")) { - - TableCellElement td = (TableCellElement) target.cast(); + final Element targetTdOrTr = getTdOrTr((Element) target.cast()); + if ("td".equals(targetTdOrTr.getTagName().toLowerCase())) { + TableCellElement td = (TableCellElement) targetTdOrTr + .cast(); info = cellToolTips.get(td); } @@ -5009,6 +5014,22 @@ public class VScrollTable extends FlowPanel implements HasWidgets, return info; } + private Element getTdOrTr(Element target) { + Element thisTrElement = getElement(); + if (target == thisTrElement) { + // This was a on the TR element + return target; + } + + // Iterate upwards until we find the TR element + Element element = target; + while (element != null + && element.getParentElement().cast() != thisTrElement) { + element = element.getParentElement().cast(); + } + return element; + } + /** * Special handler for touch devices that support native scrolling * @@ -5533,18 +5554,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, return null; } } - if (eventTarget == thisTrElement) { - // This was a click on the TR element - return thisTrElement; - } - - // Iterate upwards until we find the TR element - Element element = eventTarget; - while (element != null - && element.getParentElement().cast() != thisTrElement) { - element = element.getParentElement().cast(); - } - return element; + return getTdOrTr(eventTarget); } public void showContextMenu(Event event) { diff --git a/client/src/com/vaadin/client/ui/VTreeTable.java b/client/src/com/vaadin/client/ui/VTreeTable.java index f4e3974505..d4bfa9698d 100644 --- a/client/src/com/vaadin/client/ui/VTreeTable.java +++ b/client/src/com/vaadin/client/ui/VTreeTable.java @@ -219,8 +219,8 @@ public class VTreeTable extends VScrollTable { @Override public void addCell(UIDL rowUidl, Widget w, char align, - String style, boolean isSorted) { - super.addCell(rowUidl, w, align, style, isSorted); + String style, boolean isSorted, String description) { + super.addCell(rowUidl, w, align, style, isSorted, description); if (addTreeSpacer(rowUidl)) { widgetInHierarchyColumn = w; } diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 1b72035e54..c0814b8481 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -3503,14 +3503,13 @@ public class Table extends AbstractSelect implements Action.Container, + currentColumn][indexInRowbuffer]; if (c == null) { target.addText(""); - paintCellTooltips(target, itemId, columnId); } else { LegacyPaint.paint(c, target); } } else { target.addText((String) cells[CELL_FIRSTCOL + currentColumn][indexInRowbuffer]); - paintCellTooltips(target, itemId, columnId); } + paintCellTooltips(target, itemId, columnId); } target.endTag("tr"); diff --git a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html new file mode 100644 index 0000000000..eb3efc28fd --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.html @@ -0,0 +1,358 @@ +<?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://arturwin.office.itmill.com: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/TableItemDescriptionGeneratorTest?restartApplication</td> + <td></td> +</tr> +<!--All on--> +<!--Text tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Cell description item 1,Text</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Button tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Button 1 description</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--TextField tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Textfield's own description</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Cell and row tooltips--> +<tr> + <td>mouseClick</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCheckBox[0]/domChild[0]</td> + <td>12,6</td> +</tr> +<!--Text tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Cell description item 1,Text</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Button tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Cell description item 1,Component</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--TextField tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Cell description item 1,Generated component</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Row and Component tooltips--> +<tr> + <td>mouseClick</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCheckBox[0]/domChild[0]</td> + <td>7,8</td> +</tr> +<tr> + <td>mouseClick</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VCheckBox[0]/domChild[0]</td> + <td>7,5</td> +</tr> +<!--Text tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Row description item 1</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Button tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Button 1 description</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--TextField tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Textfield's own description</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Row tooltips--> +<tr> + <td>mouseClick</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VCheckBox[0]/domChild[0]</td> + <td>7,8</td> +</tr> +<!--Text tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Row description item 1</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--Button tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VButton[0]/domChild[0]/domChild[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Row description item 1</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<!--TextField tooltip--> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::PID_Stable/FocusableScrollPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[1]/VTextField[0]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Row description item 1</td> +</tr> +<tr> + <td>mouseMoveAt</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/domChild[3]</td> + <td>22,7</td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runTableItemDescriptionGeneratorTest::Root/VTooltip[0]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.java b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.java index e7176add0a..ec81194f14 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.java +++ b/uitest/src/com/vaadin/tests/components/table/TableItemDescriptionGeneratorTest.java @@ -2,50 +2,101 @@ package com.vaadin.tests.components.table; import com.vaadin.data.Container; import com.vaadin.data.Item; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.util.IndexedContainer; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; public class TableItemDescriptionGeneratorTest extends TestBase { - private final String COLUMN1_PROPERTY_ID = "Text - Cell description"; - private final String COLUMN2_PROPERTY_ID = "Text - Row description"; - private final String COLUMN3_PROPERTY_ID = "Widget"; + private final String TEXT_PROPERTY_ID = "Text"; + private final String GEN_WIDGET_PROPERTY_ID = "Generated component"; + private final String WIDGET_PROPERTY_ID = "Component"; + private CheckBox componentDescription; + private CheckBox tableCellItemDescription; + private CheckBox tableRowItemDescription; @Override protected void setup() { - final Table table = new Table(); + final Table table = createTable(); table.setId("table"); - table.setContainerDataSource(createContainer()); + componentDescription = new CheckBox("Tooltip on components"); + componentDescription.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + table.setContainerDataSource(createContainer(componentDescription + .getValue())); + } + }); + componentDescription.setImmediate(true); + componentDescription.setValue(true); + tableCellItemDescription = new CheckBox("Tooltip on table cells"); + tableCellItemDescription + .addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + table.refreshRowCache(); + } + }); + tableCellItemDescription.setImmediate(true); + tableCellItemDescription.setValue(true); + + tableRowItemDescription = new CheckBox("Tooltip on table Rows"); + tableRowItemDescription + .addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + table.refreshRowCache(); + } + }); + tableRowItemDescription.setImmediate(true); + tableRowItemDescription.setValue(true); + + addComponent(componentDescription); + addComponent(tableCellItemDescription); + addComponent(tableRowItemDescription); addComponent(table); table.setItemDescriptionGenerator(new ItemDescriptionGenerator() { @Override public String generateDescription(Component source, Object itemId, Object propertyId) { - if (propertyId == null) { + if (propertyId == null && tableRowItemDescription.getValue()) { return "Row description " + itemId; - } else if (propertyId == COLUMN1_PROPERTY_ID) { + } else if (tableCellItemDescription.getValue()) { return "Cell description " + itemId + "," + propertyId; } return null; } }); - table.addGeneratedColumn(COLUMN3_PROPERTY_ID, + table.addGeneratedColumn(GEN_WIDGET_PROPERTY_ID, new Table.ColumnGenerator() { @Override public Component generateCell(Table source, Object itemId, Object columnId) { TextField lbl = new TextField(); - lbl.setDescription("Textfields own description"); + if (componentDescription.getValue()) { + lbl.setDescription("Textfield's own description"); + } return lbl; } }); + + } + + protected Table createTable() { + return new Table(); } @Override @@ -58,17 +109,22 @@ public class TableItemDescriptionGeneratorTest extends TestBase { return 5414; } - private Container createContainer() { + private Container createContainer(boolean description) { IndexedContainer container = new IndexedContainer(); - container.addContainerProperty(COLUMN1_PROPERTY_ID, String.class, ""); - container.addContainerProperty(COLUMN2_PROPERTY_ID, String.class, ""); + container.addContainerProperty(TEXT_PROPERTY_ID, String.class, ""); + container.addContainerProperty(WIDGET_PROPERTY_ID, Component.class, + null); // container.addContainerProperty(COLUMN3_PROPERTY_ID, String.class, // ""); for (int i = 0; i < 5; i++) { Item item = container.addItem("item " + i); - item.getItemProperty(COLUMN1_PROPERTY_ID).setValue("first" + i); - item.getItemProperty(COLUMN2_PROPERTY_ID).setValue("middle" + i); + item.getItemProperty(TEXT_PROPERTY_ID).setValue("Text " + i); + Button b = new Button("Button " + i); + if (description) { + b.setDescription("Button " + i + " description"); + } + item.getItemProperty(WIDGET_PROPERTY_ID).setValue(b); // item.getItemProperty(COLUMN3_PROPERTY_ID).setValue("last" + i); } |