summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-11-10 15:46:57 +0100
committerPéter Török <31210544+torok-peter@users.noreply.github.com>2017-11-10 16:46:57 +0200
commit37bd6b1a32c9d5d6a53755de8bb1a94556b4471b (patch)
treebe2f97ccada0e6c261536450da29e62bf5d871c9
parentfe2b4d941fdfe06fbb79d3e9168618592136c337 (diff)
downloadvaadin-framework-37bd6b1a32c9d5d6a53755de8bb1a94556b4471b.tar.gz
vaadin-framework-37bd6b1a32c9d5d6a53755de8bb1a94556b4471b.zip
Add ContentMode for row and cell descriptions in Grid (#10282)
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java31
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java68
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/grid/ColumnState.java8
-rw-r--r--shared/src/main/java/com/vaadin/shared/ui/grid/GridState.java26
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java72
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridDescriptionGeneratorTest.java127
7 files changed, 295 insertions, 49 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java
index e46a01c1ae..4112a29e6b 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java
@@ -23,6 +23,7 @@ import com.vaadin.client.widgets.Grid.Column;
import com.vaadin.client.widgets.Grid.HeaderCell;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.ColumnState;
import elemental.json.JsonObject;
@@ -41,6 +42,7 @@ public class ColumnConnector extends AbstractExtensionConnector {
extends Column<Object, JsonObject> {
private final String connectorId;
+ private ContentMode contentMode;
CustomColumn(String connectorId) {
this.connectorId = connectorId;
@@ -54,6 +56,29 @@ public class ColumnConnector extends AbstractExtensionConnector {
protected void setDefaultHeaderContent(HeaderCell cell) {
// NO-OP, Server takes care of header contents.
}
+
+ /**
+ * Gets the content mode for tooltips in this column.
+ *
+ * @return the content mode.
+ *
+ * @since 8.2
+ */
+ public ContentMode getContentMode() {
+ return contentMode;
+ }
+
+ /**
+ * Sets the content mode for tooltips in this column.
+ *
+ * @param contentMode
+ * the content mode for tooltips
+ *
+ * @since 8.2
+ */
+ public void setContentMode(ContentMode contentMode) {
+ this.contentMode = contentMode;
+ }
}
private CustomColumn column;
@@ -164,6 +189,11 @@ public class ColumnConnector extends AbstractExtensionConnector {
column.setEditable(getState().editable);
}
+ @OnStateChange("contentMode")
+ void updateContentMode() {
+ column.setContentMode(getState().contentMode);
+ }
+
@Override
public void onUnregister() {
super.onUnregister();
@@ -186,5 +216,4 @@ public class ColumnConnector extends AbstractExtensionConnector {
public ColumnState getState() {
return (ColumnState) super.getState();
}
-
}
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
index eb7277af54..14d5b297eb 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
@@ -256,8 +256,7 @@ public class GridConnector extends AbstractListingConnector
grid.setRowStyleGenerator(rowRef -> {
JsonObject json = rowRef.getRow();
return json.hasKey(GridState.JSONKEY_ROWSTYLE)
- ? json.getString(GridState.JSONKEY_ROWSTYLE)
- : null;
+ ? json.getString(GridState.JSONKEY_ROWSTYLE) : null;
});
grid.setCellStyleGenerator(cellRef -> {
JsonObject row = cellRef.getRow();
@@ -631,12 +630,15 @@ public class GridConnector extends AbstractListingConnector
.getObject(GridState.JSONKEY_CELLDESCRIPTION);
String id = ((CustomColumn) column).getConnectorId();
+
if (cellDescriptions != null
&& cellDescriptions.hasKey(id)) {
- return new TooltipInfo(cellDescriptions.getString(id));
+ return new TooltipInfo(cellDescriptions.getString(id),
+ ((CustomColumn) column).getContentMode());
} else if (row.hasKey(GridState.JSONKEY_ROWDESCRIPTION)) {
- return new TooltipInfo(row
- .getString(GridState.JSONKEY_ROWDESCRIPTION));
+ return new TooltipInfo(
+ row.getString(GridState.JSONKEY_ROWDESCRIPTION),
+ getState().rowDescriptionContentMode);
}
}
}
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 1e35578b19..e6cc4d4454 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -80,6 +80,7 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.data.sort.SortDirection;
+import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.AbstractGridExtensionState;
import com.vaadin.shared.ui.grid.ColumnResizeMode;
import com.vaadin.shared.ui.grid.ColumnState;
@@ -1206,8 +1207,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
* Sets the header aria-label for this column.
*
* @param caption
- * the header aria-label, null removes
- * the aria-label from this column
+ * the header aria-label, null removes the aria-label from
+ * this column
*
* @return this column
*
@@ -1383,16 +1384,43 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
/**
* Sets the description generator that is used for generating
- * descriptions for cells in this column.
+ * descriptions for cells in this column. This method uses the
+ * {@link ContentMode#PREFORMATTED} content mode.
+ *
+ * @see #setDescriptionGenerator(DescriptionGenerator, ContentMode)
*
* @param cellDescriptionGenerator
- * the cell description generator to set, or
- * <code>null</code> to remove a previously set generator
+ * the cell description generator to set, or {@code null} to
+ * remove a previously set generator
* @return this column
*/
public Column<T, V> setDescriptionGenerator(
DescriptionGenerator<T> cellDescriptionGenerator) {
+ return setDescriptionGenerator(cellDescriptionGenerator,
+ ContentMode.PREFORMATTED);
+ }
+
+ /**
+ * Sets the description generator that is used for generating
+ * descriptions for cells in this column. This method uses the given
+ * content mode.
+ *
+ * @see #setDescriptionGenerator(DescriptionGenerator)
+ *
+ * @param cellDescriptionGenerator
+ * the cell description generator to set, or {@code null} to
+ * remove a previously set generator
+ * @param contentMode
+ * the content mode for tooltips
+ * @return this column
+ *
+ * @since 8.2
+ */
+ public Column<T, V> setDescriptionGenerator(
+ DescriptionGenerator<T> cellDescriptionGenerator,
+ ContentMode contentMode) {
this.descriptionGenerator = cellDescriptionGenerator;
+ getState().contentMode = contentMode;
getGrid().getDataCommunicator().reset();
return this;
}
@@ -3200,7 +3228,10 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
/**
* Sets the description generator that is used for generating descriptions
- * for rows.
+ * for rows. This method uses the {@link ContentMode#PREFORMATTED} content
+ * mode.
+ *
+ * @see #setDescriptionGenerator(DescriptionGenerator, ContentMode)
*
* @param descriptionGenerator
* the row description generator to set, or <code>null</code> to
@@ -3208,7 +3239,29 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
*/
public void setDescriptionGenerator(
DescriptionGenerator<T> descriptionGenerator) {
+ setDescriptionGenerator(descriptionGenerator, ContentMode.PREFORMATTED);
+ }
+
+ /**
+ * Sets the description generator that is used for generating descriptions
+ * for rows. This method uses the given content mode.
+ *
+ * @see #setDescriptionGenerator(DescriptionGenerator)
+ *
+ * @param descriptionGenerator
+ * the row description generator to set, or {@code null} to
+ * remove a previously set generator
+ * @param contentMode
+ * the content mode for row tooltips
+ *
+ * @since 8.2
+ */
+ public void setDescriptionGenerator(
+ DescriptionGenerator<T> descriptionGenerator,
+ ContentMode contentMode) {
+ Objects.requireNonNull(contentMode, "contentMode cannot be null");
this.descriptionGenerator = descriptionGenerator;
+ getState().rowDescriptionContentMode = contentMode;
getDataCommunicator().reset();
}
@@ -4623,8 +4676,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
* as both original comparators are also serializable
*/
BinaryOperator<SerializableComparator<T>> operator = (comparator1,
- comparator2) ->
- comparator1.thenComparing(comparator2)::compare;
+ comparator2) -> comparator1.thenComparing(comparator2)::compare;
return sortOrder.stream().map(
order -> order.getSorted().getComparator(order.getDirection()))
.reduce((x, y) -> 0, operator);
diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/ColumnState.java b/shared/src/main/java/com/vaadin/shared/ui/grid/ColumnState.java
index 82f6b77639..eb0e28dce9 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/grid/ColumnState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/grid/ColumnState.java
@@ -16,6 +16,7 @@
package com.vaadin.shared.ui.grid;
import com.vaadin.shared.Connector;
+import com.vaadin.shared.ui.ContentMode;
/**
* Shared state for a Grid column.
@@ -74,4 +75,11 @@ public class ColumnState extends AbstractGridExtensionState {
*/
public boolean minimumWidthFromContent = true;
+ /**
+ * The content mode for tooltips.
+ *
+ * @since 8.2
+ */
+ public ContentMode contentMode;
+
}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/grid/GridState.java b/shared/src/main/java/com/vaadin/shared/ui/grid/GridState.java
index 98508ad705..75f53d11d5 100644
--- a/shared/src/main/java/com/vaadin/shared/ui/grid/GridState.java
+++ b/shared/src/main/java/com/vaadin/shared/ui/grid/GridState.java
@@ -22,6 +22,7 @@ import java.util.List;
import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.shared.data.sort.SortDirection;
import com.vaadin.shared.ui.AbstractSingleSelectState;
+import com.vaadin.shared.ui.ContentMode;
/**
* The shared state for the {@link com.vaadin.ui.Grid} component.
@@ -41,42 +42,48 @@ public class GridState extends AbstractSingleSelectState {
/**
* The key in which a row's data can be found.
*
- * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, elemental.json.JsonArray)
+ * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
+ * elemental.json.JsonArray)
*/
public static final String JSONKEY_DATA = "d";
/**
* The key in which a row's own key can be found.
*
- * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, elemental.json.JsonArray)
+ * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
+ * elemental.json.JsonArray)
*/
public static final String JSONKEY_ROWKEY = "k";
/**
* The key in which a row's generated style can be found.
*
- * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, elemental.json.JsonArray)
+ * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
+ * elemental.json.JsonArray)
*/
public static final String JSONKEY_ROWSTYLE = "rs";
/**
* The key in which a generated styles for a row's cells can be found.
*
- * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, elemental.json.JsonArray)
+ * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
+ * elemental.json.JsonArray)
*/
public static final String JSONKEY_CELLSTYLES = "cs";
/**
* The key in which a row's description can be found.
*
- * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, elemental.json.JsonArray)
+ * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
+ * elemental.json.JsonArray)
*/
public static final String JSONKEY_ROWDESCRIPTION = "rd";
/**
* The key in which a cell's description can be found.
*
- * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int, elemental.json.JsonArray)
+ * @see com.vaadin.shared.data.DataProviderRpc#setRowData(int,
+ * elemental.json.JsonArray)
*/
public static final String JSONKEY_CELLDESCRIPTION = "cd";
@@ -167,4 +174,11 @@ public class GridState extends AbstractSingleSelectState {
* @since 8.2
*/
public double footerRowHeight = -1;
+
+ /**
+ * The content mode for row descriptions.
+ *
+ * @since 8.2
+ */
+ public ContentMode rowDescriptionContentMode;
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
index 5c580c89f3..ef7533d082 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
@@ -23,6 +23,7 @@ import com.vaadin.event.selection.SingleSelectionEvent;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.sort.SortDirection;
+import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.ColumnResizeMode;
import com.vaadin.shared.ui.grid.HeightMode;
import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -42,6 +43,7 @@ import com.vaadin.ui.SingleSelect;
import com.vaadin.ui.StyleGenerator;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.components.grid.DescriptionGenerator;
import com.vaadin.ui.components.grid.DetailsGenerator;
import com.vaadin.ui.components.grid.FooterCell;
import com.vaadin.ui.components.grid.FooterRow;
@@ -256,8 +258,7 @@ public class GridBasics extends AbstractTestUIWithLog {
private void onSingleSelect(SingleSelectionEvent<DataObject> event) {
log("SingleSelectionEvent: Selected: "
+ (event.getSelectedItem().isPresent()
- ? event.getSelectedItem().get().toString()
- : "none"));
+ ? event.getSelectedItem().get().toString() : "none"));
}
private void onMultiSelect(MultiSelectionEvent<DataObject> event) {
@@ -268,8 +269,7 @@ public class GridBasics extends AbstractTestUIWithLog {
String addedRow = firstAdded.isPresent() ? firstAdded.get().toString()
: "none";
String removedRow = firstRemoved.isPresent()
- ? firstRemoved.get().toString()
- : "none";
+ ? firstRemoved.get().toString() : "none";
log("SelectionEvent: Added " + addedRow + ", Removed " + removedRow);
}
@@ -363,11 +363,9 @@ public class GridBasics extends AbstractTestUIWithLog {
}
columnsMenu.addItem("Clear sort", item -> grid.clearSortOrder());
- columnsMenu
- .addItem("Simple resize mode",
- item -> grid.setColumnResizeMode(
- item.isChecked() ? ColumnResizeMode.SIMPLE
- : ColumnResizeMode.ANIMATED))
+ columnsMenu.addItem("Simple resize mode",
+ item -> grid.setColumnResizeMode(item.isChecked()
+ ? ColumnResizeMode.SIMPLE : ColumnResizeMode.ANIMATED))
.setCheckable(true);
}
@@ -405,18 +403,10 @@ public class GridBasics extends AbstractTestUIWithLog {
}
createRowStyleMenu(stateMenu.addItem("Row style generator", null));
createCellStyleMenu(stateMenu.addItem("Cell style generator", null));
- stateMenu.addItem("Row description generator",
- item -> grid.setDescriptionGenerator(item.isChecked()
- ? t -> "Row tooltip for row " + t.getRowNumber()
- : null))
- .setCheckable(true);
- stateMenu.addItem("Cell description generator",
- item -> grid.getColumns().stream().findFirst().ifPresent(
- c -> c.setDescriptionGenerator(item.isChecked()
- ? t -> "Cell tooltip for row "
- + t.getRowNumber() + ", Column 0"
- : null)))
- .setCheckable(true);
+ createRowDescriptionMenu(
+ stateMenu.addItem("Row description generator", null));
+ createCellDescriptionMenu(
+ stateMenu.addItem("Cell description generator", null));
stateMenu.addItem("Item click listener", new Command() {
private Registration registration = null;
@@ -430,8 +420,7 @@ public class GridBasics extends AbstractTestUIWithLog {
!grid.isDetailsVisible(event.getItem()));
log("Item click on row "
+ event.getItem().getRowNumber() + ", Column '"
- + event.getColumn().getCaption()
- + "'");
+ + event.getColumn().getCaption() + "'");
});
log("Registered an item click listener.");
}
@@ -481,6 +470,43 @@ public class GridBasics extends AbstractTestUIWithLog {
stateMenu.addItem("Set focus", item -> grid.focus());
}
+ private void createRowDescriptionMenu(MenuItem rowDescriptionMenu) {
+ DescriptionGenerator<DataObject> description = t -> "Row tooltip for row <b>"
+ + t.getRowNumber() + "</b>";
+ DescriptionGenerator<DataObject> halfEmpty = t -> t.getRowNumber()
+ % 2 == 0 ? description.apply(t) : null;
+
+ addGridMethodMenu(rowDescriptionMenu, "Remove descriptions", null,
+ g -> grid.setDescriptionGenerator(null));
+ addGridMethodMenu(rowDescriptionMenu, "Preformatted", description,
+ generator -> grid.setDescriptionGenerator(generator));
+ addGridMethodMenu(rowDescriptionMenu, "HTML", description,
+ generator -> grid.setDescriptionGenerator(generator,
+ ContentMode.HTML));
+ addGridMethodMenu(rowDescriptionMenu, "Even rows HTML", halfEmpty,
+ generator -> grid.setDescriptionGenerator(generator,
+ ContentMode.HTML));
+ }
+
+ private void createCellDescriptionMenu(MenuItem cellDescriptionMenu) {
+ Column<DataObject, ?> column = grid.getColumns().get(0);
+ DescriptionGenerator<DataObject> description = t -> "Cell tooltip for row <b>"
+ + t.getRowNumber() + "</b>, " + column.getCaption();
+ DescriptionGenerator<DataObject> halfEmpty = t -> t.getRowNumber()
+ % 2 == 0 ? description.apply(t) : null;
+
+ addGridMethodMenu(cellDescriptionMenu, "Remove descriptions", null,
+ g -> column.setDescriptionGenerator(null));
+ addGridMethodMenu(cellDescriptionMenu, "Preformatted", description,
+ generator -> column.setDescriptionGenerator(generator));
+ addGridMethodMenu(cellDescriptionMenu, "HTML", description,
+ generator -> column.setDescriptionGenerator(generator,
+ ContentMode.HTML));
+ addGridMethodMenu(cellDescriptionMenu, "Even rows HTML", halfEmpty,
+ generator -> column.setDescriptionGenerator(generator,
+ ContentMode.HTML));
+ }
+
private void createRowStyleMenu(MenuItem rowStyleMenu) {
addGridMethodMenu(rowStyleMenu, ROW_STYLE_GENERATOR_NONE,
(StyleGenerator<DataObject>) t -> null,
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridDescriptionGeneratorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridDescriptionGeneratorTest.java
index 58ded39798..3cbb3da26d 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridDescriptionGeneratorTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridDescriptionGeneratorTest.java
@@ -24,9 +24,28 @@ import org.openqa.selenium.By;
public class GridDescriptionGeneratorTest extends GridBasicsTest {
@Test
- public void testCellDescription() {
+ public void testPreformattedCellDescription() {
openTestURL();
- selectMenuPath("Component", "State", "Cell description generator");
+ selectMenuPath("Component", "State", "Cell description generator",
+ "Preformatted");
+
+ getGridElement().getCell(1, 0).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Cell tooltip for row <b>1</b>, Column 0",
+ tooltipText);
+
+ getGridElement().getCell(1, 1).showTooltip();
+ assertTrue("Tooltip should not be present in cell (1, 1) ",
+ findElement(By.className("v-tooltip-text")).getText()
+ .isEmpty());
+ }
+
+ @Test
+ public void testHTMLCellDescription() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Cell description generator",
+ "HTML");
getGridElement().getCell(1, 0).showTooltip();
String tooltipText = findElement(By.className("v-tooltip-text"))
@@ -41,9 +60,46 @@ public class GridDescriptionGeneratorTest extends GridBasicsTest {
}
@Test
- public void testRowDescription() {
+ public void testHTMLCellDescriptionOnEvenRows() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Cell description generator",
+ "Even rows HTML");
+
+ getGridElement().getCell(0, 0).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Cell tooltip for row 0, Column 0",
+ tooltipText);
+
+ getGridElement().getCell(1, 0).showTooltip();
+ assertTrue("Tooltip should not be present in cell (1, 0) ",
+ findElement(By.className("v-tooltip-text")).getText()
+ .isEmpty());
+ }
+
+ @Test
+ public void testPreformattedRowDescription() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Row description generator",
+ "Preformatted");
+
+ getGridElement().getCell(5, 3).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Row tooltip for row <b>5</b>",
+ tooltipText);
+
+ getGridElement().getCell(15, 3).showTooltip();
+ tooltipText = findElement(By.className("v-tooltip-text")).getText();
+ assertEquals("Tooltip text", "Row tooltip for row <b>15</b>",
+ tooltipText);
+ }
+
+ @Test
+ public void testHTMLRowDescription() {
openTestURL();
- selectMenuPath("Component", "State", "Row description generator");
+ selectMenuPath("Component", "State", "Row description generator",
+ "HTML");
getGridElement().getCell(5, 3).showTooltip();
String tooltipText = findElement(By.className("v-tooltip-text"))
@@ -56,10 +112,29 @@ public class GridDescriptionGeneratorTest extends GridBasicsTest {
}
@Test
+ public void testHTMLRowDescriptionOnEvenRows() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Row description generator",
+ "Even rows HTML");
+
+ getGridElement().getCell(4, 3).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Row tooltip for row 4", tooltipText);
+
+ getGridElement().getCell(5, 3).showTooltip();
+ assertTrue("Tooltip should not be present on row 5",
+ findElement(By.className("v-tooltip-text")).getText()
+ .isEmpty());
+ }
+
+ @Test
public void testRowAndCellDescription() {
openTestURL();
- selectMenuPath("Component", "State", "Row description generator");
- selectMenuPath("Component", "State", "Cell description generator");
+ selectMenuPath("Component", "State", "Row description generator",
+ "HTML");
+ selectMenuPath("Component", "State", "Cell description generator",
+ "HTML");
getGridElement().getCell(5, 0).showTooltip();
String tooltipText = findElement(By.className("v-tooltip-text"))
@@ -71,4 +146,44 @@ public class GridDescriptionGeneratorTest extends GridBasicsTest {
tooltipText = findElement(By.className("v-tooltip-text")).getText();
assertEquals("Tooltip text", "Row tooltip for row 5", tooltipText);
}
+
+ @Test
+ public void testRemoveCellDescription() {
+ selectMenuPath("Component", "State", "Cell description generator",
+ "HTML");
+
+ getGridElement().getCell(1, 0).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Cell tooltip for row 1, Column 0",
+ tooltipText);
+
+ selectMenuPath("Component", "State", "Cell description generator",
+ "Remove descriptions");
+
+ getGridElement().getCell(1, 0).showTooltip();
+ assertTrue("Tooltip should not be present in cell (1, 0) ",
+ findElement(By.className("v-tooltip-text")).getText()
+ .isEmpty());
+ }
+
+ @Test
+ public void testRemoveRowDescription() {
+ openTestURL();
+ selectMenuPath("Component", "State", "Row description generator",
+ "HTML");
+
+ getGridElement().getCell(5, 3).showTooltip();
+ String tooltipText = findElement(By.className("v-tooltip-text"))
+ .getText();
+ assertEquals("Tooltip text", "Row tooltip for row 5", tooltipText);
+
+ selectMenuPath("Component", "State", "Row description generator",
+ "Remove descriptions");
+
+ getGridElement().getCell(5, 3).showTooltip();
+ assertTrue("Tooltip should not be present on row 5",
+ findElement(By.className("v-tooltip-text")).getText()
+ .isEmpty());
+ }
}