summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2018-03-13 14:03:29 +0200
committerIlia Motornyi <elmot@vaadin.com>2018-03-13 15:03:29 +0300
commite813c97e0bdc00c5542c9bf0f55eef65f34ac093 (patch)
treedf2557a4a63a9de77234358e0c55bfc8ca1185ff /server
parent0af3b7d717b44b0de1af82143b3c3d3aece587ab (diff)
downloadvaadin-framework-e813c97e0bdc00c5542c9bf0f55eef65f34ac093.tar.gz
vaadin-framework-e813c97e0bdc00c5542c9bf0f55eef65f34ac093.zip
Setting of tooltips for grid header/footer cells (#10489)
Fixes #7527
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java57
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java57
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java70
3 files changed, 184 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java b/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java
index d9777cbb77..9c4a38bc77 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/FooterCell.java
@@ -17,6 +17,7 @@ package com.vaadin.ui.components.grid;
import java.io.Serializable;
+import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.GridStaticCellType;
import com.vaadin.ui.Component;
@@ -102,4 +103,60 @@ public interface FooterCell extends Serializable {
* the style name to set or null to not use any style name
*/
public void setStyleName(String styleName);
+
+ /**
+ * Gets the tooltip for the cell.
+ * <p>
+ * The tooltip is shown in the mode returned by
+ * {@link #getDescriptionContentMode()}.
+ *
+ * @since
+ */
+ public String getDescription();
+
+ /**
+ * Sets the tooltip for the cell.
+ * <p>
+ * By default, tooltips are shown as plain text. For HTML tooltips, see
+ * {@link #setDescription(String, ContentMode)} or
+ * {@link #setDescriptionContentMode(ContentMode)}.
+ *
+ * @param description
+ * the tooltip to show when hovering the cell
+ * @since
+ */
+ public void setDescription(String description);
+
+ /**
+ * Sets the tooltip for the cell to be shown with the given content mode.
+ *
+ * @see ContentMode
+ * @param description
+ * the tooltip to show when hovering the cell
+ * @param descriptionContentMode
+ * the content mode to use for the tooltip (HTML or plain text)
+ * @since
+ */
+ public void setDescription(String description,
+ ContentMode descriptionContentMode);
+
+ /**
+ * Gets the content mode for the tooltip.
+
+ * @see ContentMode
+ * @return the content mode for the tooltip
+ * @since
+ */
+ public ContentMode getDescriptionContentMode();
+
+ /**
+ * Sets the content mode for the tooltip.
+ *
+ * @see ContentMode
+ * @param descriptionContentMode
+ * the content mode for the tooltip
+ * @since
+ */
+ public void setDescriptionContentMode(ContentMode descriptionContentMode);
+
}
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java b/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java
index 6801622740..79f25b6dea 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/HeaderCell.java
@@ -17,6 +17,7 @@ package com.vaadin.ui.components.grid;
import java.io.Serializable;
+import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.GridStaticCellType;
import com.vaadin.ui.Component;
@@ -102,4 +103,60 @@ public interface HeaderCell extends Serializable {
* the style name to set or null to not use any style name
*/
public void setStyleName(String styleName);
+
+ /**
+ * Gets the tooltip for the cell.
+ * <p>
+ * The tooltip is shown in the mode returned by
+ * {@link #getDescriptionContentMode()}.
+ *
+ * @since
+ */
+ public String getDescription();
+
+ /**
+ * Sets the tooltip for the cell.
+ * <p>
+ * By default, tooltips are shown as plain text. For HTML tooltips, see
+ * {@link #setDescription(String, ContentMode)} or
+ * {@link #setDescriptionContentMode(ContentMode)}.
+ *
+ * @param description
+ * the tooltip to show when hovering the cell
+ * @since
+ */
+ public void setDescription(String description);
+
+ /**
+ * Sets the tooltip for the cell to be shown with the given content mode.
+ *
+ * @see ContentMode
+ * @param description
+ * the tooltip to show when hovering the cell
+ * @param descriptionContentMode
+ * the content mode to use for the tooltip (HTML or plain text)
+ * @since
+ */
+ public void setDescription(String description,
+ ContentMode descriptionContentMode);
+
+ /**
+ * Gets the content mode for the tooltip.
+ * <p>
+ *
+ * @see ContentMode
+ * @return the content mode for the tooltip
+ * @since
+ */
+ public ContentMode getDescriptionContentMode();
+
+ /**
+ * Sets the content mode for the tooltip.
+ *
+ * @see ContentMode
+ * @param descriptionContentMode
+ * the content mode for the tooltip
+ * @since
+ */
+ public void setDescriptionContentMode(ContentMode descriptionContentMode);
}
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java
index ec25339931..40ade7e97e 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java
@@ -35,6 +35,7 @@ import java.util.stream.Stream;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
+import com.vaadin.shared.ui.ContentMode;
import com.vaadin.shared.ui.grid.GridStaticCellType;
import com.vaadin.shared.ui.grid.SectionState;
import com.vaadin.shared.ui.grid.SectionState.CellState;
@@ -615,6 +616,75 @@ public abstract class StaticSection<ROW extends StaticSection.StaticRow<?>>
void detach() {
removeComponentIfPresent();
}
+
+ /**
+ * Gets the tooltip for the cell.
+ * <p>
+ * The tooltip is shown in the mode returned by
+ * {@link #getDescriptionContentMode()}.
+ *
+ * @since
+ */
+ public String getDescription() {
+ return cellState.description;
+ }
+
+ /**
+ * Sets the tooltip for the cell.
+ * <p>
+ * By default, tooltips are shown as plain text. For HTML tooltips, see
+ * {@link #setDescription(String, ContentMode)} or
+ * {@link #setDescriptionContentMode(ContentMode)}.
+ *
+ * @param description
+ * the tooltip to show when hovering the cell
+ * @since
+ */
+ public void setDescription(String description) {
+ cellState.description = description;
+ }
+
+ /**
+ * Sets the tooltip for the cell to be shown with the given content
+ * mode.
+ *
+ * @see ContentMode
+ * @param description
+ * the tooltip to show when hovering the cell
+ * @param descriptionContentMode
+ * the content mode to use for the tooltip (HTML or plain
+ * text)
+ * @since
+ */
+ public void setDescription(String description,
+ ContentMode descriptionContentMode) {
+ setDescription(description);
+ setDescriptionContentMode(descriptionContentMode);
+ }
+
+ /**
+ * Gets the content mode for the tooltip.
+ *
+ * @see ContentMode
+ * @return the content mode for the tooltip
+ * @since
+ */
+ public ContentMode getDescriptionContentMode() {
+ return cellState.descriptionContentMode;
+ }
+
+ /**
+ * Sets the content mode for the tooltip.
+ *
+ * @see ContentMode
+ * @param descriptionContentMode
+ * the content mode for the tooltip
+ * @since
+ */
+ public void setDescriptionContentMode(
+ ContentMode descriptionContentMode) {
+ cellState.descriptionContentMode = descriptionContentMode;
+ }
}
private final List<ROW> rows = new ArrayList<>();