aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-07-13 15:46:31 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2015-07-13 15:46:31 +0300
commitae5793ae460cab22612c134cbec4b8ae6ed4175b (patch)
treee24c1924cc4882a273707661d16d9a67c875aa31 /client/src
parent40dcbc3cfaa438c9b879720c9012331dd85ca694 (diff)
parent96e10ed8be9ec1e694001098584361e43eb35af2 (diff)
downloadvaadin-framework-ae5793ae460cab22612c134cbec4b8ae6ed4175b.tar.gz
vaadin-framework-ae5793ae460cab22612c134cbec4b8ae6ed4175b.zip
Merge remote-tracking branch 'origin/master' into grid-unbuffered-editor
Change-Id: Id630861d5089b0deabbccffe66d971252c44f46b
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/ComputedStyle.java8
-rw-r--r--client/src/com/vaadin/client/WidgetUtil.java6
-rw-r--r--client/src/com/vaadin/client/connectors/GridConnector.java36
-rw-r--r--client/src/com/vaadin/client/extensions/ResponsiveConnector.java19
-rw-r--r--client/src/com/vaadin/client/ui/AbstractComponentConnector.java12
-rw-r--r--client/src/com/vaadin/client/ui/VAbstractSplitPanel.java39
-rw-r--r--client/src/com/vaadin/client/ui/VDragAndDropWrapper.java3
-rw-r--r--client/src/com/vaadin/client/ui/VGridLayout.java18
-rw-r--r--client/src/com/vaadin/client/ui/VSplitPanelHorizontal.java23
-rw-r--r--client/src/com/vaadin/client/ui/VSplitPanelVertical.java23
-rw-r--r--client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java2
-rw-r--r--client/src/com/vaadin/client/widgets/Grid.java201
12 files changed, 264 insertions, 126 deletions
diff --git a/client/src/com/vaadin/client/ComputedStyle.java b/client/src/com/vaadin/client/ComputedStyle.java
index 7a04296b4b..61cb3c2eb6 100644
--- a/client/src/com/vaadin/client/ComputedStyle.java
+++ b/client/src/com/vaadin/client/ComputedStyle.java
@@ -131,7 +131,7 @@ public class ComputedStyle {
/**
* Retrieves the given computed property as an integer
- *
+ *
* Returns 0 if the property cannot be converted to an integer
*
* @param name
@@ -148,7 +148,7 @@ public class ComputedStyle {
/**
* Retrieves the given computed property as a double
- *
+ *
* Returns NaN if the property cannot be converted to a double
*
* @param name
@@ -205,7 +205,7 @@ public class ComputedStyle {
/**
* Returns the current width from the DOM.
*
- * @since
+ * @since 7.5.1
* @return the computed width
*/
public double getWidth() {
@@ -215,7 +215,7 @@ public class ComputedStyle {
/**
* Returns the current height from the DOM.
*
- * @since
+ * @since 7.5.1
* @return the computed height
*/
public double getHeight() {
diff --git a/client/src/com/vaadin/client/WidgetUtil.java b/client/src/com/vaadin/client/WidgetUtil.java
index b9d22193de..4906197b29 100644
--- a/client/src/com/vaadin/client/WidgetUtil.java
+++ b/client/src/com/vaadin/client/WidgetUtil.java
@@ -1641,7 +1641,7 @@ public class WidgetUtil {
* Firefox uses 1/60th of a pixel because it is divisible by three
* (https://bugzilla.mozilla.org/show_bug.cgi?id=1070940)
*
- * @since
+ * @since 7.5.1
* @param size
* the value to round
* @return the rounded value
@@ -1661,7 +1661,7 @@ public class WidgetUtil {
*
* IE9+ uses 1/100th of a pixel
*
- * @since
+ * @since 7.5.1
* @param size
* the value to round
* @return the rounded value
@@ -1694,7 +1694,7 @@ public class WidgetUtil {
/**
* Returns the factor used by browsers to round subpixel values
*
- * @since
+ * @since 7.5.1
* @return the factor N used by the browser when storing subpixels as X+Y/N
*/
private static double getSubPixelRoundingFactor() {
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java
index bee9cedc43..d42041670e 100644
--- a/client/src/com/vaadin/client/connectors/GridConnector.java
+++ b/client/src/com/vaadin/client/connectors/GridConnector.java
@@ -735,13 +735,20 @@ public class GridConnector extends AbstractHasComponentsConnector implements
private final DetailsListener detailsListener = new DetailsListener() {
@Override
- public void reapplyDetailsVisibility(int rowIndex, JsonObject row) {
- if (hasDetailsOpen(row)) {
- getWidget().setDetailsVisible(rowIndex, true);
- detailsConnectorFetcher.schedule();
- } else {
- getWidget().setDetailsVisible(rowIndex, false);
- }
+ public void reapplyDetailsVisibility(final int rowIndex,
+ final JsonObject row) {
+ Scheduler.get().scheduleDeferred(new ScheduledCommand() {
+
+ @Override
+ public void execute() {
+ if (hasDetailsOpen(row)) {
+ getWidget().setDetailsVisible(rowIndex, true);
+ detailsConnectorFetcher.schedule();
+ } else {
+ getWidget().setDetailsVisible(rowIndex, false);
+ }
+ }
+ });
}
private boolean hasDetailsOpen(JsonObject row) {
@@ -945,6 +952,13 @@ public class GridConnector extends AbstractHasComponentsConnector implements
}
@Override
+ public void onUnregister() {
+ customDetailsGenerator.indexToDetailsMap.clear();
+
+ super.onUnregister();
+ }
+
+ @Override
public void onStateChanged(final StateChangeEvent stateChangeEvent) {
super.onStateChanged(stateChangeEvent);
@@ -1061,6 +1075,10 @@ public class GridConnector extends AbstractHasComponentsConnector implements
for (RowState rowState : state.rows) {
HeaderRow row = getWidget().appendHeaderRow();
+ if (rowState.defaultRow) {
+ getWidget().setDefaultHeaderRow(row);
+ }
+
for (CellState cellState : rowState.cells) {
CustomGridColumn column = columnIdToColumn
.get(cellState.columnId);
@@ -1082,10 +1100,6 @@ public class GridConnector extends AbstractHasComponentsConnector implements
updateHeaderCellFromState(row.join(columns), cellState);
}
- if (rowState.defaultRow) {
- getWidget().setDefaultHeaderRow(row);
- }
-
row.setStyleName(rowState.styleName);
}
}
diff --git a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java
index 2e1e75f6cd..621c69788c 100644
--- a/client/src/com/vaadin/client/extensions/ResponsiveConnector.java
+++ b/client/src/com/vaadin/client/extensions/ResponsiveConnector.java
@@ -84,6 +84,10 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
getLogger().log(Level.SEVERE, message);
}
+ private static void warning(String message) {
+ getLogger().warning(message);
+ }
+
@Override
protected void extend(ServerConnector target) {
this.target = (AbstractComponentConnector) target;
@@ -204,10 +208,17 @@ public class ResponsiveConnector extends AbstractExtensionConnector implements
var IE = @com.vaadin.client.BrowserInfo::get()().@com.vaadin.client.BrowserInfo::isIE()();
var IE8 = @com.vaadin.client.BrowserInfo::get()().@com.vaadin.client.BrowserInfo::isIE8()();
- if (sheet.cssRules) {
- theRules = sheet.cssRules
- } else if (sheet.rules) {
- theRules = sheet.rules
+ try {
+ if (sheet.cssRules) {
+ theRules = sheet.cssRules
+ } else if (sheet.rules) {
+ theRules = sheet.rules
+ }
+ } catch (e) {
+ // FF spews if trying to access rules for cross domain styles
+ @ResponsiveConnector::warning(*)("Can't process styles from " + sheet.href +
+ ", probably because of cross domain issues: " + e);
+ return;
}
// Special import handling for IE8
diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
index 24a0438476..1f09c14fb0 100644
--- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
+++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java
@@ -103,11 +103,15 @@ public abstract class AbstractComponentConnector extends AbstractConnector
@Override
public Widget getWidget() {
if (widget == null) {
- Profiler.enter("AbstractComponentConnector.createWidget for "
- + getClass().getSimpleName());
+ if (Profiler.isEnabled()) {
+ Profiler.enter("AbstractComponentConnector.createWidget for "
+ + getClass().getSimpleName());
+ }
widget = createWidget();
- Profiler.leave("AbstractComponentConnector.createWidget for "
- + getClass().getSimpleName());
+ if (Profiler.isEnabled()) {
+ Profiler.leave("AbstractComponentConnector.createWidget for "
+ + getClass().getSimpleName());
+ }
}
return widget;
diff --git a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
index 5565daf19b..6c11783d34 100644
--- a/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
+++ b/client/src/com/vaadin/client/ui/VAbstractSplitPanel.java
@@ -49,7 +49,7 @@ import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler;
import com.vaadin.client.ui.VAbstractSplitPanel.SplitterMoveHandler.SplitterMoveEvent;
import com.vaadin.shared.ui.Orientation;
-public class VAbstractSplitPanel extends ComplexPanel {
+public abstract class VAbstractSplitPanel extends ComplexPanel {
private boolean enabled = false;
@@ -571,6 +571,7 @@ public class VAbstractSplitPanel extends ComplexPanel {
}
break;
case Event.ONCLICK:
+ stopResize();
resizing = false;
break;
}
@@ -590,6 +591,7 @@ public class VAbstractSplitPanel extends ComplexPanel {
}
final Element trg = event.getEventTarget().cast();
if (trg == splitter || trg == DOM.getChild(splitter, 0)) {
+ startResize();
resizing = true;
DOM.setCapture(getElement());
origX = DOM.getElementPropertyInt(splitter, "offsetLeft");
@@ -601,6 +603,40 @@ public class VAbstractSplitPanel extends ComplexPanel {
}
}
+ /**
+ * Called when starting drag resize
+ *
+ * @since 7.5.1
+ */
+ abstract protected void startResize();
+
+ /**
+ * Called when stopping drag resize
+ *
+ * @since 7.5.1
+ */
+ abstract protected void stopResize();
+
+ /**
+ * Gets the first container
+ *
+ * @since 7.5.1
+ * @return the firstContainer
+ */
+ protected Element getFirstContainer() {
+ return firstContainer;
+ }
+
+ /**
+ * Gets the second container
+ *
+ * @since 7.5.1
+ * @return the secondContainer
+ */
+ protected Element getSecondContainer() {
+ return secondContainer;
+ }
+
public void onMouseMove(Event event) {
switch (orientation) {
case HORIZONTAL:
@@ -685,6 +721,7 @@ public class VAbstractSplitPanel extends ComplexPanel {
public void onMouseUp(Event event) {
DOM.releaseCapture(getElement());
hideDraggingCurtain();
+ stopResize();
resizing = false;
if (!WidgetUtil.isTouchEvent(event)) {
onMouseMove(event);
diff --git a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
index defa27fbac..f3905f9e46 100644
--- a/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
+++ b/client/src/com/vaadin/client/ui/VDragAndDropWrapper.java
@@ -472,6 +472,9 @@ public class VDragAndDropWrapper extends VCustomComponent implements
/*-{
this.setRequestHeader('Content-Type', 'multipart/form-data');
+ // Seems like IE10 will loose the file if we don't keep a reference to it...
+ this.fileBeingUploaded = file;
+
this.send(file);
}-*/;
diff --git a/client/src/com/vaadin/client/ui/VGridLayout.java b/client/src/com/vaadin/client/ui/VGridLayout.java
index 0c1d4cec90..42bcb5060a 100644
--- a/client/src/com/vaadin/client/ui/VGridLayout.java
+++ b/client/src/com/vaadin/client/ui/VGridLayout.java
@@ -734,7 +734,8 @@ public class VGridLayout extends ComplexPanel {
setAlignment(new AlignmentInfo(childComponentData.alignment));
}
- public void setComponent(ComponentConnector component) {
+ public void setComponent(ComponentConnector component,
+ List<ComponentConnector> ordering) {
if (slot == null || slot.getChild() != component) {
slot = new ComponentConnectorLayoutSlot(CLASSNAME, component,
getConnector());
@@ -743,7 +744,20 @@ public class VGridLayout extends ComplexPanel {
slot.getWrapperElement().getStyle().setWidth(100, Unit.PCT);
}
Element slotWrapper = slot.getWrapperElement();
- getElement().appendChild(slotWrapper);
+ int childIndex = ordering.indexOf(component);
+ // insert new slot by proper index
+ // do not break default focus order
+ com.google.gwt.user.client.Element element = getElement();
+ if (childIndex == ordering.size()) {
+ element.appendChild(slotWrapper);
+ } else if (childIndex == 0) {
+ element.insertAfter(slotWrapper, spacingMeasureElement);
+ } else {
+ // here we use childIndex - 1 + 1(spacingMeasureElement)
+ Element previousSlot = (Element) element
+ .getChild(childIndex);
+ element.insertAfter(slotWrapper, previousSlot);
+ }
Widget widget = component.getWidget();
insert(widget, slotWrapper, getWidgetCount(), false);
diff --git a/client/src/com/vaadin/client/ui/VSplitPanelHorizontal.java b/client/src/com/vaadin/client/ui/VSplitPanelHorizontal.java
index c6919d456b..1a3e699b20 100644
--- a/client/src/com/vaadin/client/ui/VSplitPanelHorizontal.java
+++ b/client/src/com/vaadin/client/ui/VSplitPanelHorizontal.java
@@ -16,6 +16,8 @@
package com.vaadin.client.ui;
+import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.Orientation;
public class VSplitPanelHorizontal extends VAbstractSplitPanel {
@@ -23,4 +25,25 @@ public class VSplitPanelHorizontal extends VAbstractSplitPanel {
public VSplitPanelHorizontal() {
super(Orientation.HORIZONTAL);
}
+
+ @Override
+ protected void startResize() {
+ if (getFirstWidget() != null && isWidgetFullWidth(getFirstWidget())) {
+ getFirstContainer().getStyle().setOverflow(Overflow.HIDDEN);
+ }
+
+ if (getSecondWidget() != null && isWidgetFullWidth(getSecondWidget())) {
+ getSecondContainer().getStyle().setOverflow(Overflow.HIDDEN);
+ }
+ }
+
+ @Override
+ protected void stopResize() {
+ getFirstContainer().getStyle().clearOverflow();
+ getSecondContainer().getStyle().clearOverflow();
+ }
+
+ private boolean isWidgetFullWidth(Widget w) {
+ return w.getElement().getStyle().getWidth().equals("100%");
+ }
}
diff --git a/client/src/com/vaadin/client/ui/VSplitPanelVertical.java b/client/src/com/vaadin/client/ui/VSplitPanelVertical.java
index b008e5d3f0..7baed03ca3 100644
--- a/client/src/com/vaadin/client/ui/VSplitPanelVertical.java
+++ b/client/src/com/vaadin/client/ui/VSplitPanelVertical.java
@@ -16,6 +16,8 @@
package com.vaadin.client.ui;
+import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.shared.ui.Orientation;
public class VSplitPanelVertical extends VAbstractSplitPanel {
@@ -23,4 +25,25 @@ public class VSplitPanelVertical extends VAbstractSplitPanel {
public VSplitPanelVertical() {
super(Orientation.VERTICAL);
}
+
+ @Override
+ protected void startResize() {
+ if (getFirstWidget() != null && isWidgetFullHeight(getFirstWidget())) {
+ getFirstContainer().getStyle().setOverflow(Overflow.HIDDEN);
+ }
+
+ if (getSecondWidget() != null && isWidgetFullHeight(getSecondWidget())) {
+ getSecondContainer().getStyle().setOverflow(Overflow.HIDDEN);
+ }
+ }
+
+ @Override
+ protected void stopResize() {
+ getFirstContainer().getStyle().clearOverflow();
+ getSecondContainer().getStyle().clearOverflow();
+ }
+
+ private boolean isWidgetFullHeight(Widget w) {
+ return w.getElement().getStyle().getHeight().equals("100%");
+ }
}
diff --git a/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java b/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
index 3102af8da9..4d1ce692ad 100644
--- a/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
+++ b/client/src/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
@@ -159,7 +159,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
for (ComponentConnector componentConnector : getChildComponents()) {
Cell cell = getCell(componentConnector);
- cell.setComponent(componentConnector);
+ cell.setComponent(componentConnector, getChildComponents());
}
}
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java
index a0b0b08aaa..86d2ed5f00 100644
--- a/client/src/com/vaadin/client/widgets/Grid.java
+++ b/client/src/com/vaadin/client/widgets/Grid.java
@@ -867,6 +867,7 @@ public class Grid<T> extends ResizeComposite implements
if (row != null) {
row.setDefault(true);
}
+
defaultRow = row;
requestSectionRefresh();
}
@@ -917,6 +918,16 @@ public class Grid<T> extends ResizeComposite implements
BrowserEvents.TOUCHMOVE, BrowserEvents.TOUCHEND,
BrowserEvents.TOUCHCANCEL, BrowserEvents.CLICK);
}
+
+ @Override
+ protected void addColumn(Column<?, ?> column) {
+ super.addColumn(column);
+
+ // Add default content for new columns.
+ if (defaultRow != null) {
+ column.setDefaultHeaderContent(defaultRow.getCell(column));
+ }
+ }
}
/**
@@ -929,6 +940,11 @@ public class Grid<T> extends ResizeComposite implements
protected void setDefault(boolean isDefault) {
this.isDefault = isDefault;
+ if (isDefault) {
+ for (Column<?, ?> column : getSection().grid.getColumns()) {
+ column.setDefaultHeaderContent(getCell(column));
+ }
+ }
}
public boolean isDefault() {
@@ -2437,8 +2453,6 @@ public class Grid<T> extends ResizeComposite implements
}
void initDone() {
- addSelectAllToDefaultHeader();
-
setWidth(-1);
setEditable(false);
@@ -2446,62 +2460,52 @@ public class Grid<T> extends ResizeComposite implements
initDone = true;
}
- protected void addSelectAllToDefaultHeader() {
- if (getSelectionModel() instanceof SelectionModel.Multi
- && header.getDefaultRow() != null) {
- // If selection cell already contains a widget do not
- // create a new CheckBox
- HeaderCell selectionCell = header.getDefaultRow().getCell(this);
- if (selectionCell.getType().equals(GridStaticCellType.WIDGET)
- && selectionCell.getWidget() instanceof CheckBox) {
- return;
- }
- /*
- * TODO: Currently the select all check box is shown when multi
- * selection is in use. This might result in malfunctions if no
- * SelectAllHandlers are present.
- *
- * Later on this could be fixed so that it check such handlers
- * exist.
- */
- final SelectionModel.Multi<T> model = (Multi<T>) getSelectionModel();
- final CheckBox checkBox = GWT.create(CheckBox.class);
- checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
+ @Override
+ protected void setDefaultHeaderContent(HeaderCell selectionCell) {
+ /*
+ * TODO: Currently the select all check box is shown when multi
+ * selection is in use. This might result in malfunctions if no
+ * SelectAllHandlers are present.
+ *
+ * Later on this could be fixed so that it check such handlers
+ * exist.
+ */
+ final SelectionModel.Multi<T> model = (Multi<T>) getSelectionModel();
+ final CheckBox checkBox = GWT.create(CheckBox.class);
+ checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
- @Override
- public void onValueChange(ValueChangeEvent<Boolean> event) {
- if (event.getValue()) {
- fireEvent(new SelectAllEvent<T>(model));
- selected = true;
- } else {
- model.deselectAll();
- selected = false;
- }
+ @Override
+ public void onValueChange(ValueChangeEvent<Boolean> event) {
+ if (event.getValue()) {
+ fireEvent(new SelectAllEvent<T>(model));
+ selected = true;
+ } else {
+ model.deselectAll();
+ selected = false;
}
- });
- checkBox.setValue(selected);
- selectionCell.setWidget(checkBox);
- // Select all with space when "select all" cell is active
- addHeaderKeyUpHandler(new HeaderKeyUpHandler() {
- @Override
- public void onKeyUp(GridKeyUpEvent event) {
- if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE) {
- return;
- }
- HeaderRow targetHeaderRow = getHeader().getRow(
- event.getFocusedCell().getRowIndex());
- if (!targetHeaderRow.isDefault()) {
- return;
- }
- if (event.getFocusedCell().getColumn() == SelectionColumn.this) {
- // Send events to ensure row selection state is
- // updated
- checkBox.setValue(!checkBox.getValue(), true);
- }
+ }
+ });
+ checkBox.setValue(selected);
+ selectionCell.setWidget(checkBox);
+ // Select all with space when "select all" cell is active
+ addHeaderKeyUpHandler(new HeaderKeyUpHandler() {
+ @Override
+ public void onKeyUp(GridKeyUpEvent event) {
+ if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE) {
+ return;
}
- });
-
- }
+ HeaderRow targetHeaderRow = getHeader().getRow(
+ event.getFocusedCell().getRowIndex());
+ if (!targetHeaderRow.isDefault()) {
+ return;
+ }
+ if (event.getFocusedCell().getColumn() == SelectionColumn.this) {
+ // Send events to ensure row selection state is
+ // updated
+ checkBox.setValue(!checkBox.getValue(), true);
+ }
+ }
+ });
}
@Override
@@ -4300,7 +4304,6 @@ public class Grid<T> extends ResizeComposite implements
this.grid = grid;
if (this.grid != null) {
this.grid.recalculateColumnWidths();
- updateHeader();
}
}
@@ -4838,6 +4841,17 @@ public class Grid<T> extends ResizeComposite implements
*/
}
}
+
+ /**
+ * Resets the default header cell contents to column header captions.
+ *
+ * @since 7.5.1
+ * @param cell
+ * default header cell for this column
+ */
+ protected void setDefaultHeaderContent(HeaderCell cell) {
+ cell.setText(headerCaption);
+ }
}
protected class BodyUpdater implements EscalatorUpdater {
@@ -5091,35 +5105,29 @@ public class Grid<T> extends ResizeComposite implements
final StaticSection.StaticCell metadata = staticRow
.getCell(columns.get(cell.getColumn()));
- boolean updateCellData = true;
// Decorate default row with sorting indicators
if (staticRow instanceof HeaderRow) {
addSortingIndicatorsToHeaderRow((HeaderRow) staticRow, cell);
-
- if (isHeaderSelectionColumn(row, cell)) {
- updateCellData = false;
- }
}
// Assign colspan to cell before rendering
cell.setColSpan(metadata.getColspan());
TableCellElement element = cell.getElement();
- if (updateCellData) {
- switch (metadata.getType()) {
- case TEXT:
- element.setInnerText(metadata.getText());
- break;
- case HTML:
- element.setInnerHTML(metadata.getHtml());
- break;
- case WIDGET:
- preDetach(row, Arrays.asList(cell));
- element.setInnerHTML("");
- postAttach(row, Arrays.asList(cell));
- break;
- }
+ switch (metadata.getType()) {
+ case TEXT:
+ element.setInnerText(metadata.getText());
+ break;
+ case HTML:
+ element.setInnerHTML(metadata.getHtml());
+ break;
+ case WIDGET:
+ preDetach(row, Arrays.asList(cell));
+ element.setInnerHTML("");
+ postAttach(row, Arrays.asList(cell));
+ break;
}
+
setCustomStyleName(element, metadata.getStyleName());
cellFocusHandler.updateFocusedCellStyle(cell, container);
@@ -5178,27 +5186,6 @@ public class Grid<T> extends ResizeComposite implements
@Override
public void preAttach(Row row, Iterable<FlyweightCell> cellsToAttach) {
- // Add select all checkbox if needed on rebuild.
- for (FlyweightCell cell : cellsToAttach) {
- if (isHeaderSelectionColumn(row, cell)) {
- selectionColumn.addSelectAllToDefaultHeader();
- }
- }
- }
-
- /**
- * Check if selectionColumn in the default header row
- */
- private boolean isHeaderSelectionColumn(Row row, FlyweightCell cell) {
- return selectionColumn != null && isDefaultHeaderRow(row)
- && getColumn(cell.getColumn()).equals(selectionColumn);
- }
-
- /**
- * Row is the default header row.
- */
- private boolean isDefaultHeaderRow(Row row) {
- return section.getRow(row.getRow()).equals(header.getDefaultRow());
}
@Override
@@ -5827,6 +5814,9 @@ public class Grid<T> extends ResizeComposite implements
/**
* Sets the default row of the header. The default row is a special header
* row providing a user interface for sorting columns.
+ * <p>
+ * Note: Setting the default header row will reset all cell contents to
+ * Column defaults.
*
* @param row
* the new default row, or null for no default row
@@ -6081,6 +6071,12 @@ public class Grid<T> extends ResizeComposite implements
RowContainer body = escalator.getBody();
int oldSize = body.getRowCount();
+ // Hide all details.
+ Set<Integer> oldDetails = new HashSet<Integer>(visibleDetails);
+ for (int i : oldDetails) {
+ setDetailsVisible(i, false);
+ }
+
if (newSize > oldSize) {
body.insertRows(oldSize, newSize - oldSize);
cellFocusHandler.rowsAddedToBody(Range.withLength(oldSize,
@@ -6946,6 +6942,9 @@ public class Grid<T> extends ResizeComposite implements
selectionModel.setGrid(this);
setSelectColumnRenderer(this.selectionModel
.getSelectionColumnRenderer());
+
+ // Refresh rendered rows to update selection, if it has changed
+ refreshBody();
}
/**
@@ -7782,6 +7781,16 @@ public class Grid<T> extends ResizeComposite implements
}
@Override
+ protected void onDetach() {
+ Set<Integer> details = new HashSet<Integer>(visibleDetails);
+ for (int row : details) {
+ setDetailsVisible(row, false);
+ }
+
+ super.onDetach();
+ }
+
+ @Override
public void onResize() {
super.onResize();
/*