Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: API review changes #9287

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3faf7af
Make CollapseListener and ExpandListener extend SerializableEventList…
ahie May 10, 2017
00deb9e
Clarify HierarchicalQuery javadocs
ahie May 10, 2017
8fb1b07
Clarify InMemoryHierarchicalDataProvider constructor's javadoc
ahie May 10, 2017
96c93a7
Improvements to HierarchyRenderer
ahie May 10, 2017
225e815
Add javadoc to client-side TreeGrid widget
ahie May 10, 2017
622c158
Move CompositeState to different package
ahie May 10, 2017
68da461
Wrap DataCommunicator#getBackEndSorting in an unmodifiable list
ahie May 10, 2017
3a46647
Add FunctionalInterface annotation to DependencyFilter
ahie May 10, 2017
20e1bd1
Remove redundant method getComponentCount from Composite
ahie May 10, 2017
553853e
Rename TreeGridCommunicationConstants to HierarchicalDataCommunicator…
ahie May 11, 2017
fb82a63
Rename BodyRowContainer.setNewEscalatorRowCallback to setNewRowCallback
ahie May 11, 2017
e0e255a
Make HierarchyRendererCellReferenceWrapper a nested class of Hierarch…
ahie May 11, 2017
254c6fa
Add setHierarchyColumn(column) overload to TreeGrid
ahie May 11, 2017
e48c65a
Add javadocs to Grid#readData and writeData
ahie May 11, 2017
cbade61
Add convenience constructors to TreeGrid
ahie May 11, 2017
6fe1feb
Move HierarchicalDataCommunicatorConstants to the correct package
ahie May 12, 2017
da597ab
Move LocalDataTime and LocalDateRendererConnectors to a different pac…
ahie May 12, 2017
2159347
Add BackEndHierarchicalDataProvider and an abstract base class
ahie May 12, 2017
01f6814
Improve CollapseEvent and ExpandEvent javadocs
ahie May 12, 2017
561627e
Remove unnecessary rowmode prefix from TreeGrid focus styles
ahie May 11, 2017
e541c6f
Add TreeGrid#getHierarchyColumn
ahie May 15, 2017
43ad4e2
Add ItemCollapseAllowedProvider interface
ahie May 15, 2017
b1a5594
Merge remote-tracking branch 'github/master' into api-review-changes
ahie May 16, 2017
d771e6b
Fix code review comments
ahie May 16, 2017
34dd944
Merge master into api-review-changes
ahie May 16, 2017
16f03f0
Make LazyHierarchicalDataProvider extend AbstractBackEndHierarchicalD…
ahie May 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.connectors.grid;
package com.vaadin.client.connectors;

import com.vaadin.client.connectors.grid.TextRendererConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.grid.renderers.LocalDateRendererState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.client.connectors.grid;
package com.vaadin.client.connectors;

import com.vaadin.client.connectors.grid.TextRendererConnector;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.grid.renderers.LocalDateTimeRendererState;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package com.vaadin.client.connectors.data;

import com.vaadin.data.provider.HierarchicalDataCommunicator;
import com.vaadin.shared.data.HierarchicalDataCommunicatorConstants;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.treegrid.TreeGridCommunicationConstants;

import elemental.json.JsonObject;

Expand All @@ -35,24 +35,24 @@ public class HierarchicalDataCommunicatorConnector
protected void onRowDataUpdate(JsonObject newRowData,
JsonObject oldRowData) {
assert newRowData.hasKey(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION);
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION);
assert oldRowData.hasKey(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION);
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION);

/*
* Since server side can't know the index of a random item, any
* refreshItem(..) cannot know the depth. Thus need to copy it from
* previous item.
*/
JsonObject hierarchyData = newRowData.getObject(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION);
if (!hierarchyData.hasKey(TreeGridCommunicationConstants.ROW_DEPTH)) {
hierarchyData.put(TreeGridCommunicationConstants.ROW_DEPTH,
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION);
if (!hierarchyData.hasKey(HierarchicalDataCommunicatorConstants.ROW_DEPTH)) {
hierarchyData.put(HierarchicalDataCommunicatorConstants.ROW_DEPTH,
oldRowData
.getObject(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION)
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION)
.getNumber(
TreeGridCommunicationConstants.ROW_DEPTH));
HierarchicalDataCommunicatorConstants.ROW_DEPTH));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void extend(ServerConnector target) {
}

// Set newly added rows draggable
getGridBody().setNewEscalatorRowCallback(
getGridBody().setNewRowCallback(
rows -> rows.forEach(this::addDraggable));

// Add drag listeners to body element
Expand Down Expand Up @@ -350,7 +350,7 @@ public void onUnregister() {
removeDragListeners(getGridBody().getElement());

// Remove callback for newly added rows
getGridBody().setNewEscalatorRowCallback(null);
getGridBody().setNewRowCallback(null);

if (touchScrollDelayUsed) {
gridConnector.getWidget().getEscalator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import com.vaadin.client.widgets.Grid;
import com.vaadin.shared.Range;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.data.HierarchicalDataCommunicatorConstants;
import com.vaadin.shared.ui.Connect;
import com.vaadin.shared.ui.treegrid.FocusParentRpc;
import com.vaadin.shared.ui.treegrid.FocusRpc;
import com.vaadin.shared.ui.treegrid.NodeCollapseRpc;
import com.vaadin.shared.ui.treegrid.TreeGridClientRpc;
import com.vaadin.shared.ui.treegrid.TreeGridCommunicationConstants;
import com.vaadin.shared.ui.treegrid.TreeGridState;

import elemental.json.JsonObject;
Expand Down Expand Up @@ -356,11 +356,11 @@ public void onEvent(Grid.GridEvent<JsonObject> event) {
// let's scroll the row into the view
getWidget().scrollToRow(cell.getRowIndex());
} else if (rowData.hasKey(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION)) {
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION)) {
JsonObject rowDescription = rowData.getObject(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION);
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION);
boolean leaf = rowDescription.getBoolean(
TreeGridCommunicationConstants.ROW_LEAF);
HierarchicalDataCommunicatorConstants.ROW_LEAF);
boolean collapsed = isCollapsed(rowData);
switch (domEvent.getKeyCode()) {
case KeyCodes.KEY_RIGHT:
Expand Down Expand Up @@ -414,12 +414,12 @@ private void checkExpand(int firstRowIndex, int numberOfRows) {

private static boolean isCollapsed(JsonObject rowData) {
assert rowData
.hasKey(TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION) : "missing hierarchy data for row "
.hasKey(HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION) : "missing hierarchy data for row "
+ rowData.asString();
return rowData
.getObject(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION)
.getBoolean(TreeGridCommunicationConstants.ROW_COLLAPSED);
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION)
.getBoolean(HierarchicalDataCommunicatorConstants.ROW_COLLAPSED);
}

/**
Expand All @@ -430,6 +430,6 @@ private static boolean isCollapsed(JsonObject rowData) {
*/
public static boolean isCollapseAllowed(JsonObject row) {
return row.getBoolean(
TreeGridCommunicationConstants.ROW_COLLAPSE_ALLOWED);
HierarchicalDataCommunicatorConstants.ROW_COLLAPSE_ALLOWED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.TableCellElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
Expand All @@ -30,9 +31,10 @@
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.connectors.treegrid.TreeGridConnector;
import com.vaadin.client.widget.escalator.FlyweightCell;
import com.vaadin.client.widget.grid.RendererCellReference;
import com.vaadin.client.widget.treegrid.HierarchyRendererCellReferenceWrapper;
import com.vaadin.shared.ui.treegrid.TreeGridCommunicationConstants;
import com.vaadin.client.widget.grid.RowReference;
import com.vaadin.shared.data.HierarchicalDataCommunicatorConstants;

import elemental.json.JsonObject;

Expand All @@ -44,6 +46,42 @@
*/
public class HierarchyRenderer extends ClickableRenderer<Object, Widget> {

/**
* Wrapper for cell references. Used to get the correct inner element to
* render.
*
* @author Vaadin Ltd
* @since 8.1
*/
private static class HierarchyRendererCellReferenceWrapper
extends RendererCellReference {

private Element element;

public HierarchyRendererCellReferenceWrapper(RendererCellReference cell,
Element element) {
super(getRowReference(cell));
set(getFlyweightCell(cell), cell.getColumnIndex(),
cell.getColumn());
this.element = element;
}

@Override
public TableCellElement getElement() {
return (TableCellElement) element;
}

private native static RowReference<Object> getRowReference(
RendererCellReference cell) /*-{
return cell.@com.vaadin.client.widget.grid.CellReference::getRowReference()();
}-*/;

private native static FlyweightCell getFlyweightCell(
RendererCellReference cell) /*-{
return cell.@com.vaadin.client.widget.grid.RendererCellReference::cell;
}-*/;
}

private String nodeStyleName;
private String expanderStyleName;
private String cellContentStyleName;
Expand Down Expand Up @@ -92,10 +130,17 @@ public HierarchyRenderer(BiConsumer<Integer, Boolean> collapseCallback,
setStyleNames(styleName);
}

public void setStyleNames(String primaryStyleName) {
nodeStyleName = primaryStyleName + "-node";
expanderStyleName = primaryStyleName + "-expander";
cellContentStyleName = primaryStyleName + "-cell-content";
/**
* Set the style name prefix for the node, expander and cell-content
* elements.
*
* @param styleName
* the style name to set
*/
public void setStyleNames(String styleName) {
nodeStyleName = styleName + "-node";
expanderStyleName = styleName + "-expander";
cellContentStyleName = styleName + "-cell-content";
}

@Override
Expand Down Expand Up @@ -155,30 +200,30 @@ public void render(RendererCellReference cell, Object data, Widget widget) {

private int getDepth(JsonObject rowDescription) {
return (int) rowDescription
.getNumber(TreeGridCommunicationConstants.ROW_DEPTH);
.getNumber(HierarchicalDataCommunicatorConstants.ROW_DEPTH);
}

private JsonObject getHierarchyData(JsonObject row) {
return row.getObject(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION);
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION);
}

private boolean hasHierarchyData(JsonObject row) {
return row.hasKey(
TreeGridCommunicationConstants.ROW_HIERARCHY_DESCRIPTION);
HierarchicalDataCommunicatorConstants.ROW_HIERARCHY_DESCRIPTION);
}

private boolean isLeaf(JsonObject rowDescription) {
boolean leaf;
leaf = rowDescription
.getBoolean(TreeGridCommunicationConstants.ROW_LEAF);
.getBoolean(HierarchicalDataCommunicatorConstants.ROW_LEAF);
return leaf;
}

private boolean isCollapsed(JsonObject rowDescription) {
boolean collapsed;
collapsed = rowDescription
.getBoolean(TreeGridCommunicationConstants.ROW_COLLAPSED);
.getBoolean(HierarchicalDataCommunicatorConstants.ROW_COLLAPSED);
return collapsed;
}

Expand Down Expand Up @@ -312,7 +357,7 @@ public HandlerRegistration addClickHandler(ClickHandler handler) {
}
}

enum ExpanderState {
private enum ExpanderState {
EXPANDED, COLLAPSED, LEAF;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void removeRows(int index, int numberOfRows)
* row elements.
* @since 8.1
*/
public void setNewEscalatorRowCallback(
public void setNewRowCallback(
Consumer<List<TableRowElement>> consumer);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import elemental.json.JsonObject;

/**
* An extension of the Grid widget, which supports displaying of hierarchical
* data.
*
* @see Grid
*
* @author Vaadin Ltd
* @since 8.1
Expand All @@ -50,9 +54,4 @@ public native boolean isElementInChildWidget(Element e)/*-{
public HandlerRegistration addBodyClickHandler(BodyClickHandler handler) {
return addHandler(handler, TreeGridClickEvent.TYPE);
}

@Override
protected String getFocusPrimaryStyleName() {
return getStylePrimaryName() + "-rowmode";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4037,7 +4037,7 @@ void scrollToSpacer(int spacerIndex, ScrollDestination destination,
}

@Override
public void setNewEscalatorRowCallback(
public void setNewRowCallback(
Consumer<List<TableRowElement>> callback) {
newEscalatorRowCallback = callback;
}
Expand Down
8 changes: 2 additions & 6 deletions client/src/main/java/com/vaadin/client/widgets/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -6217,8 +6217,8 @@ public void setStylePrimaryName(String style) {
rowSelectedStyleName = rowStyle + "-selected";
rowStripeStyleName = rowStyle + "-stripe";

cellFocusStyleName = getFocusPrimaryStyleName() + "-cell-focused";
rowFocusStyleName = getFocusPrimaryStyleName() + "-row-focused";
cellFocusStyleName = getStylePrimaryName() + "-cell-focused";
rowFocusStyleName = getStylePrimaryName() + "-row-focused";

if (isAttached()) {
refreshHeader();
Expand All @@ -6227,10 +6227,6 @@ public void setStylePrimaryName(String style) {
}
}

protected String getFocusPrimaryStyleName() {
return getStylePrimaryName();
}

/**
* Creates the escalator updater used to update the header rows in this
* grid. The updater is invoked when header rows or columns are added or
Expand Down
Loading