summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/ColumnConnector.java4
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java14
-rw-r--r--client/src/main/java/com/vaadin/client/ui/treegrid/TreeGridConnector.java57
3 files changed, 53 insertions, 22 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 89914ea664..c47488f78e 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
@@ -36,7 +36,8 @@ import elemental.json.JsonValue;
@Connect(com.vaadin.ui.Grid.Column.class)
public class ColumnConnector extends AbstractExtensionConnector {
- static abstract class CustomColumn extends Column<Object, JsonObject> {
+ public static abstract class CustomColumn
+ extends Column<Object, JsonObject> {
private final String connectorId;
@@ -99,6 +100,7 @@ public class ColumnConnector extends AbstractExtensionConnector {
@OnStateChange("renderer")
void updateRenderer() {
column.setRenderer(getRendererConnector().getRenderer());
+ getParent().onColumnRendererChanged(column);
}
@OnStateChange("hidingToggleCaption")
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 661289ffb1..0e234cc968 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
@@ -457,6 +457,20 @@ public class GridConnector extends AbstractListingConnector
idToColumn.remove(id);
}
+ /**
+ * Method called by {@code CustomColumn} when its renderer changes. This
+ * method is used to maintain hierarchical renderer wrap in
+ * {@code TreeGrid}.
+ *
+ * @param column
+ * the column which now has a new renderer
+ *
+ * @since 8.1
+ */
+ public void onColumnRendererChanged(CustomColumn column) {
+ // NO-OP
+ }
+
@Override
public void onUnregister() {
super.onUnregister();
diff --git a/client/src/main/java/com/vaadin/client/ui/treegrid/TreeGridConnector.java b/client/src/main/java/com/vaadin/client/ui/treegrid/TreeGridConnector.java
index 71c286aedf..e92747dde9 100644
--- a/client/src/main/java/com/vaadin/client/ui/treegrid/TreeGridConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/treegrid/TreeGridConnector.java
@@ -18,6 +18,7 @@ package com.vaadin.client.ui.treegrid;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import java.util.logging.Logger;
@@ -27,6 +28,7 @@ import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.user.client.Event;
import com.vaadin.client.annotations.OnStateChange;
+import com.vaadin.client.connectors.grid.ColumnConnector.CustomColumn;
import com.vaadin.client.connectors.grid.GridConnector;
import com.vaadin.client.data.AbstractRemoteDataSource;
import com.vaadin.client.data.DataChangeHandler;
@@ -229,7 +231,7 @@ public class TreeGridConnector extends GridConnector {
GridEventHandler<?> eventHandler)
/*-{
var browserEventHandlers = grid.@com.vaadin.client.widgets.Grid::browserEventHandlers;
-
+
// FocusEventHandler is initially 5th in the list of browser event handlers
browserEventHandlers.@java.util.List::set(*)(5, eventHandler);
}-*/;
@@ -352,7 +354,8 @@ public class TreeGridConnector extends GridConnector {
// Hierarchy metadata
JsonObject rowData = cell.getRow();
if (rowData == null) {
- // Row data is lost from the cache, i.e. the row is at least outside the visual area,
+ // Row data is lost from the cache, i.e. the row is at least
+ // outside the visual area,
// let's scroll the row into the view
getWidget().scrollToRow(cell.getRowIndex());
} else if (rowData.hasKey(
@@ -363,21 +366,21 @@ public class TreeGridConnector extends GridConnector {
HierarchicalDataCommunicatorConstants.ROW_LEAF);
boolean collapsed = isCollapsed(rowData);
switch (domEvent.getKeyCode()) {
- case KeyCodes.KEY_RIGHT:
- if (collapsed && !leaf) {
- setCollapsed(cell.getRowIndex(), false);
- }
- break;
- case KeyCodes.KEY_LEFT:
- if (collapsed || leaf) {
- // navigate up
- int columnIndex = cell.getColumnIndex();
- getRpcProxy(FocusParentRpc.class).focusParent(
- cell.getRowIndex(), columnIndex);
- } else if (isCollapseAllowed(rowDescription)) {
- setCollapsed(cell.getRowIndex(), true);
- }
- break;
+ case KeyCodes.KEY_RIGHT:
+ if (collapsed && !leaf) {
+ setCollapsed(cell.getRowIndex(), false);
+ }
+ break;
+ case KeyCodes.KEY_LEFT:
+ if (collapsed || leaf) {
+ // navigate up
+ int columnIndex = cell.getColumnIndex();
+ getRpcProxy(FocusParentRpc.class).focusParent(
+ cell.getRowIndex(), columnIndex);
+ } else if (isCollapseAllowed(rowDescription)) {
+ setCollapsed(cell.getRowIndex(), true);
+ }
+ break;
}
}
@@ -419,17 +422,29 @@ public class TreeGridConnector extends GridConnector {
return rowData
.getObject(
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION)
- .getBoolean(HierarchicalDataCommunicatorConstants.ROW_COLLAPSED);
+ .getBoolean(
+ HierarchicalDataCommunicatorConstants.ROW_COLLAPSED);
}
/**
- * Checks if the item can be collapsed
+ * Checks if the item can be collapsed.
*
- * @param row the item row
- * @return {@code true} if the item is allowed to be collapsed, {@code false} otherwise.
+ * @param row
+ * the item row
+ * @return {@code true} if the item is allowed to be collapsed,
+ * {@code false} otherwise.
*/
public static boolean isCollapseAllowed(JsonObject row) {
return row.getBoolean(
HierarchicalDataCommunicatorConstants.ROW_COLLAPSE_ALLOWED);
}
+
+ @Override
+ public void onColumnRendererChanged(CustomColumn column) {
+ super.onColumnRendererChanged(column);
+
+ if (Objects.equals(getColumnId(column), hierarchyColumnId)) {
+ updateHierarchyColumn();
+ }
+ }
}