summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-02-22 11:35:19 +0200
committerPekka Hyvönen <pekka@vaadin.com>2017-02-22 11:35:19 +0200
commitca1bfa7511e35fad802271604158afd7be6531d0 (patch)
treef0c68b320cff5051a4a8dc4d5827f55276b1d73c /client
parente76d2e8953e8bfb80018019dc5497e7760313403 (diff)
downloadvaadin-framework-ca1bfa7511e35fad802271604158afd7be6531d0.tar.gz
vaadin-framework-ca1bfa7511e35fad802271604158afd7be6531d0.zip
Pick changes from 7.7.7 (#8577)
* Fix java packaging order (#106) Closes vaadin/archetypes#113 * Use proper UTF-8 encoding for Content-Disposition filenames (#19527) (#6607) * Enable changing the backing bean for BeanItem (#4302) (#77) When storing a bean to the database, you typically get a new and updated bean instance back. By allowing to change the bean instance, we make it possible to just update the single BeanItem instance which can be used in many places. * Make AtmospherePushConnection methods public (#7973) There is no sensible way to use a custom version of APC, so protected access does not help in any way to access the underlying resource and/or connected UI. * Use correct indexes in multiselect checkboxes after removing rows (#8072) Fixes #8011 * Fix removal of hidden Grid columns (#8071) Fixes #8018 * Call error handler for exceptions in UI.init() (#8055) Fixes #4995 * Render font icon correctly on the 'more' menu item (#8126) * Render font icon correctly on the 'more' menu item Fixes #8125 * Reopen Grid details on attach, fixes #8015 (#8074) Fixes #8015 * Fix broken Grid tests after picking changes from 7.7.7 Removed duplicate setDetailsVisible calls from onDetach * Correctly detach components in merged cells when a static row is removed (#8142) Fixes #8140
Diffstat (limited to 'client')
-rw-r--r--client/pom.xml2
-rw-r--r--client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java13
-rw-r--r--client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java18
-rw-r--r--client/src/main/java/com/vaadin/client/widgets/Escalator.java32
-rwxr-xr-x[-rw-r--r--]client/src/main/java/com/vaadin/client/widgets/Grid.java25
5 files changed, 56 insertions, 34 deletions
diff --git a/client/pom.xml b/client/pom.xml
index 53a497b183..e687aee36e 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -57,7 +57,7 @@
<execution>
<id>copy-sources</id>
<!-- here the phase you need -->
- <phase>prepare-package</phase>
+ <phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
diff --git a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java
index cc8e3872ad..79df33e9a7 100644
--- a/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/menubar/MenuBarConnector.java
@@ -25,9 +25,8 @@ import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.Paintable;
import com.vaadin.client.TooltipInfo;
import com.vaadin.client.UIDL;
-import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.AbstractComponentConnector;
-import com.vaadin.client.ui.ImageIcon;
+import com.vaadin.client.ui.Icon;
import com.vaadin.client.ui.SimpleManagedLayout;
import com.vaadin.client.ui.VMenuBar;
import com.vaadin.shared.ui.ComponentStateUtil;
@@ -77,11 +76,11 @@ public class MenuBarConnector extends AbstractComponentConnector
StringBuffer itemHTML = new StringBuffer();
if (moreItemUIDL.hasAttribute("icon")) {
- itemHTML.append("<img src=\""
- + WidgetUtil.escapeAttribute(client.translateVaadinUri(
- moreItemUIDL.getStringAttribute("icon")))
- + "\" class=\"" + ImageIcon.CLASSNAME
- + "\" alt=\"\" />");
+ Icon icon = client
+ .getIcon(moreItemUIDL.getStringAttribute("icon"));
+ if (icon != null) {
+ itemHTML.append(icon.getElement().getString());
+ }
}
String moreItemText = moreItemUIDL.getStringAttribute("text");
diff --git a/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java b/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
index 14c2210696..8ccd4373c2 100644
--- a/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
+++ b/client/src/main/java/com/vaadin/client/widget/grid/selection/MultiSelectionRenderer.java
@@ -26,6 +26,7 @@ import com.google.gwt.dom.client.BrowserEvents;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.TableElement;
+import com.google.gwt.dom.client.TableRowElement;
import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -45,6 +46,7 @@ import com.vaadin.client.widget.grid.RendererCellReference;
import com.vaadin.client.widget.grid.events.GridEnabledHandler;
import com.vaadin.client.widget.grid.events.GridSelectionAllowedEvent;
import com.vaadin.client.widget.grid.events.GridSelectionAllowedHandler;
+import com.vaadin.client.widgets.Escalator.AbstractRowContainer;
import com.vaadin.client.widgets.Grid;
/**
@@ -330,7 +332,7 @@ public class MultiSelectionRenderer<T>
int constrainedPageY = Math.max(bodyAbsoluteTop,
Math.min(bodyAbsoluteBottom, pageY));
- int logicalRow = getLogicalRowIndex(WidgetUtil
+ int logicalRow = getLogicalRowIndex(grid, WidgetUtil
.getElementFromPoint(initialPageX, constrainedPageY));
int incrementOrDecrement = (logicalRow > lastModifiedLogicalRow) ? 1
@@ -584,8 +586,6 @@ public class MultiSelectionRenderer<T>
}
}
- private static final String LOGICAL_ROW_PROPERTY_INT = "vEscalatorLogicalRow";
-
private final Grid<T> grid;
private HandlerRegistration nativePreviewHandlerRegistration;
@@ -629,10 +629,7 @@ public class MultiSelectionRenderer<T>
public void render(final RendererCellReference cell, final Boolean data,
CheckBox checkBox) {
checkBox.setValue(data, false);
- checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive()
- && grid.getSelectionModel().isSelectionAllowed());
- checkBox.getElement().setPropertyInt(LOGICAL_ROW_PROPERTY_INT,
- cell.getRowIndex());
+ checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive());
}
@Override
@@ -666,7 +663,7 @@ public class MultiSelectionRenderer<T>
private void startDragSelect(NativeEvent event, final Element target) {
injectNativeHandler();
- int logicalRowIndex = getLogicalRowIndex(target);
+ int logicalRowIndex = getLogicalRowIndex(grid, target);
autoScrollHandler.start(logicalRowIndex);
event.preventDefault();
event.stopPropagation();
@@ -685,7 +682,7 @@ public class MultiSelectionRenderer<T>
}
}
- private int getLogicalRowIndex(final Element target) {
+ private int getLogicalRowIndex(Grid<T> grid, final Element target) {
if (target == null) {
return -1;
}
@@ -705,7 +702,8 @@ public class MultiSelectionRenderer<T>
final Element checkbox = td.getFirstChildElement();
assert checkbox != null : "Checkbox has disappeared";
- return checkbox.getPropertyInt(LOGICAL_ROW_PROPERTY_INT);
+ return ((AbstractRowContainer) grid.getEscalator().getBody())
+ .getLogicalRowIndex((TableRowElement) tr);
}
tr = tr.getNextSiblingElement();
}
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
index 3c7b7c0159..239ed9b90b 100644
--- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java
@@ -53,7 +53,6 @@ import com.google.gwt.dom.client.TableSectionElement;
import com.google.gwt.dom.client.Touch;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.logging.client.LogConfiguration;
-import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RequiresResize;
@@ -702,13 +701,13 @@ public class Escalator extends Widget
/*-{
var vScroll = esc.@com.vaadin.client.widgets.Escalator::verticalScrollbar;
var vScrollElem = vScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
var hScroll = esc.@com.vaadin.client.widgets.Escalator::horizontalScrollbar;
var hScrollElem = hScroll.@com.vaadin.client.widget.escalator.ScrollbarBundle::getElement()();
-
+
return $entry(function(e) {
var target = e.target;
-
+
// in case the scroll event was native (i.e. scrollbars were dragged, or
// the scrollTop/Left was manually modified), the bundles have old cache
// values. We need to make sure that the caches are kept up to date.
@@ -729,29 +728,29 @@ public class Escalator extends Widget
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// Delta mode 0 is in pixels; we don't need to do anything...
-
+
// A delta mode of 1 means we're scrolling by lines instead of pixels
// We need to scale the number of lines by the default line height
if(e.deltaMode === 1) {
var brc = esc.@com.vaadin.client.widgets.Escalator::body;
deltaY *= brc.@com.vaadin.client.widgets.Escalator.AbstractRowContainer::getDefaultRowHeight()();
}
-
+
// Other delta modes aren't supported
if((e.deltaMode !== undefined) && (e.deltaMode >= 2 || e.deltaMode < 0)) {
var msg = "Unsupported wheel delta mode \"" + e.deltaMode + "\"";
-
+
// Print warning message
esc.@com.vaadin.client.widgets.Escalator::logWarning(*)(msg);
}
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.widgets.Escalator.JsniUtil::moveScrollFromEvent(*)(esc, deltaX, deltaY, e);
});
}-*/;
@@ -1098,7 +1097,7 @@ public class Escalator extends Widget
}
}
- protected abstract class AbstractRowContainer implements RowContainer {
+ public abstract class AbstractRowContainer implements RowContainer {
private EscalatorUpdater updater = EscalatorUpdater.NULL;
private int rows;
@@ -2124,7 +2123,14 @@ public class Escalator extends Widget
*/
protected abstract double getHeightOfSection();
- protected int getLogicalRowIndex(final TableRowElement tr) {
+ /**
+ * Gets the logical row index for the given table row element.
+ *
+ * @param tr
+ * the table row element inside this container.
+ * @return the logical index of the given element
+ */
+ public int getLogicalRowIndex(final TableRowElement tr) {
return tr.getSectionRowIndex();
};
@@ -3433,7 +3439,7 @@ public class Escalator extends Widget
}
@Override
- protected int getLogicalRowIndex(final TableRowElement tr) {
+ public int getLogicalRowIndex(final TableRowElement tr) {
assert tr
.getParentNode() == root : "The given element isn't a row element in the body";
int internalIndex = visualRowOrder.indexOf(tr);
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index 9974505bd4..a135827a5a 100644..100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -4159,6 +4159,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private GridSpacerUpdater gridSpacerUpdater = new GridSpacerUpdater();
/** A set keeping track of the indices of all currently open details */
private Set<Integer> visibleDetails = new HashSet<>();
+ /** A set of indices of details to reopen after detach and on attach */
+ private final Set<Integer> reattachVisibleDetails = new HashSet<>();
private boolean columnReorderingAllowed;
@@ -6450,8 +6452,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
int columnIndex = columns.indexOf(column);
// Remove from column configuration
- escalator.getColumnConfiguration()
- .removeColumns(getVisibleColumns().indexOf(column), 1);
+ int visibleColumnIndex = getVisibleColumns().indexOf(column);
+ if (visibleColumnIndex < 0) {
+ assert column.isHidden();
+ // Hidden columns are not included in Escalator
+ } else {
+ getEscalator().getColumnConfiguration()
+ .removeColumns(visibleColumnIndex, 1);
+ }
updateFrozenColumns();
@@ -6830,7 +6838,12 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
return editor;
}
- protected Escalator getEscalator() {
+ /**
+ * Gets the {@link Escalator} used by this Grid instnace.
+ *
+ * @return the escalator instance, never <code>null</code>
+ */
+ public Escalator getEscalator() {
return escalator;
}
@@ -8712,11 +8725,17 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
// Grid was just attached to DOM. Column widths should be calculated.
recalculateColumnWidths();
+ for (int row : reattachVisibleDetails) {
+ setDetailsVisible(row, true);
+ }
+ reattachVisibleDetails.clear();
}
@Override
protected void onDetach() {
Set<Integer> details = new HashSet<>(visibleDetails);
+ reattachVisibleDetails.clear();
+ reattachVisibleDetails.addAll(details);
for (int row : details) {
setDetailsVisible(row, false);
}