summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2017-04-26 09:47:13 +0300
committerIlia Motornyi <elmot@vaadin.com>2017-04-26 08:47:13 +0200
commit2e5b49113439310d2dae9ec86fca3ccdf74833f5 (patch)
tree6f634ff2f15c5487da2602f67696866b49f2c0bf /client
parent38108cb43194117c0f1c8d950917002575946ae4 (diff)
downloadvaadin-framework-2e5b49113439310d2dae9ec86fca3ccdf74833f5.tar.gz
vaadin-framework-2e5b49113439310d2dae9ec86fca3ccdf74833f5.zip
Make TreeGrid follow framework style conventions
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java2
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java8
-rw-r--r--client/src/main/java/com/vaadin/client/renderers/HierarchyRenderer.java25
-rw-r--r--client/src/main/java/com/vaadin/client/widget/treegrid/TreeGrid.java2
4 files changed, 28 insertions, 9 deletions
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 5ede13ca68..9d5187a227 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
@@ -202,6 +202,8 @@ public class GridConnector extends AbstractListingConnector
protected void init() {
super.init();
+ updateWidgetStyleNames();
+
// Remove default headers when initializing Grid widget
while (getWidget().getHeaderRowCount() > 0) {
getWidget().removeHeaderRow(0);
diff --git a/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java b/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java
index ab6ac77f0c..2075b6cff1 100644
--- a/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java
@@ -138,7 +138,8 @@ public class TreeGridConnector extends GridConnector {
private HierarchyRenderer getHierarchyRenderer() {
if (hierarchyRenderer == null) {
- hierarchyRenderer = new HierarchyRenderer(this::setCollapsed);
+ hierarchyRenderer = new HierarchyRenderer(this::setCollapsed,
+ getState().primaryStyleName);
}
return hierarchyRenderer;
}
@@ -208,6 +209,11 @@ public class TreeGridConnector extends GridConnector {
});
}
+ @OnStateChange("primaryStyleName")
+ private void updateHierarchyRendererStyleName() {
+ getHierarchyRenderer().setStyleNames(getState().primaryStyleName);
+ }
+
private native void replaceCellFocusEventHandler(Grid<?> grid,
GridEventHandler<?> eventHandler)
/*-{
diff --git a/client/src/main/java/com/vaadin/client/renderers/HierarchyRenderer.java b/client/src/main/java/com/vaadin/client/renderers/HierarchyRenderer.java
index c03c5c1b01..823961d316 100644
--- a/client/src/main/java/com/vaadin/client/renderers/HierarchyRenderer.java
+++ b/client/src/main/java/com/vaadin/client/renderers/HierarchyRenderer.java
@@ -44,9 +44,10 @@ import elemental.json.JsonObject;
*/
public class HierarchyRenderer extends ClickableRenderer<Object, Widget> {
- private static final String CLASS_TREE_GRID_NODE = "v-tree-grid-node";
- private static final String CLASS_TREE_GRID_EXPANDER = "v-tree-grid-expander";
- private static final String CLASS_TREE_GRID_CELL_CONTENT = "v-tree-grid-cell-content";
+ private String nodeStyleName;
+ private String expanderStyleName;
+ private String cellContentStyleName;
+
private static final String CLASS_COLLAPSED = "collapsed";
private static final String CLASS_COLLAPSE_DISABLED = "collapse-disabled";
private static final String CLASS_EXPANDED = "expanded";
@@ -61,8 +62,11 @@ public class HierarchyRenderer extends ClickableRenderer<Object, Widget> {
*
* @param collapseCallback
* the callback for collapsing nodes with row index
+ * @param styleName
+ * the style name of the widget this renderer is used in
*/
- public HierarchyRenderer(BiConsumer<Integer, Boolean> collapseCallback) {
+ public HierarchyRenderer(BiConsumer<Integer, Boolean> collapseCallback,
+ String styleName) {
addClickHandler(event -> {
try {
JsonObject row = (JsonObject) event.getRow();
@@ -85,11 +89,18 @@ public class HierarchyRenderer extends ClickableRenderer<Object, Widget> {
event.preventDefault();
}
});
+ setStyleNames(styleName);
+ }
+
+ public void setStyleNames(String primaryStyleName) {
+ nodeStyleName = primaryStyleName + "-node";
+ expanderStyleName = primaryStyleName + "-expander";
+ cellContentStyleName = primaryStyleName + "-cell-content";
}
@Override
public Widget createWidget() {
- return new HierarchyItem(CLASS_TREE_GRID_NODE);
+ return new HierarchyItem(nodeStyleName);
}
@Override
@@ -217,7 +228,7 @@ public class HierarchyRenderer extends ClickableRenderer<Object, Widget> {
panel.getElement().addClassName(className);
expander = new Expander();
- expander.getElement().addClassName(CLASS_TREE_GRID_EXPANDER);
+ expander.getElement().addClassName(expanderStyleName);
if (innerRenderer instanceof WidgetRenderer) {
content = ((WidgetRenderer) innerRenderer).createWidget();
@@ -226,7 +237,7 @@ public class HierarchyRenderer extends ClickableRenderer<Object, Widget> {
content = GWT.create(HTML.class);
}
- content.getElement().addClassName(CLASS_TREE_GRID_CELL_CONTENT);
+ content.getElement().addClassName(cellContentStyleName);
panel.add(expander);
panel.add(content);
diff --git a/client/src/main/java/com/vaadin/client/widget/treegrid/TreeGrid.java b/client/src/main/java/com/vaadin/client/widget/treegrid/TreeGrid.java
index 31430e36e4..e2bf37ff36 100644
--- a/client/src/main/java/com/vaadin/client/widget/treegrid/TreeGrid.java
+++ b/client/src/main/java/com/vaadin/client/widget/treegrid/TreeGrid.java
@@ -53,6 +53,6 @@ public class TreeGrid extends Grid<JsonObject> {
@Override
protected String getFocusPrimaryStyleName() {
- return super.getStylePrimaryName() + "-rowmode";
+ return getStylePrimaryName() + "-rowmode";
}
}