aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2017-03-02 15:16:54 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-07 12:36:54 +0200
commit6f8518579fd3301031800dffe046f8719f4cafd8 (patch)
tree4d7a54839a0c0db9ac74fee5d98defa9fdcdc452 /client
parentf5c15b9b2bcc4eeef210a5977449c76f3b952209 (diff)
downloadvaadin-framework-6f8518579fd3301031800dffe046f8719f4cafd8.tar.gz
vaadin-framework-6f8518579fd3301031800dffe046f8719f4cafd8.zip
Picked all changes from 7.7
Synchronises parts of compatibility package code to match 7.7 Picks suitable patches for 8 code as well
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/JavaScriptRendererConnector.java38
-rw-r--r--client/src/main/java/com/vaadin/client/renderers/ImageRenderer.java2
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VComboBox.java6
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VCustomLayout.java4
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java13
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VWindow.java2
-rw-r--r--client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java4
-rw-r--r--client/src/main/java/com/vaadin/client/widget/grid/GridEventHandler.java2
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java97
9 files changed, 96 insertions, 72 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/JavaScriptRendererConnector.java b/client/src/main/java/com/vaadin/client/connectors/JavaScriptRendererConnector.java
index 90ced5e095..3191be2ed1 100644
--- a/client/src/main/java/com/vaadin/client/connectors/JavaScriptRendererConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/JavaScriptRendererConnector.java
@@ -17,6 +17,7 @@ package com.vaadin.client.connectors;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.logging.Logger;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;
@@ -64,7 +65,7 @@ public class JavaScriptRendererConnector
private static native JavaScriptObject createCellReferenceWrapper()
/*-{
var reference = {};
-
+
var setProperty = function(name, getter, setter) {
var descriptor = {
get: getter
@@ -74,25 +75,25 @@ public class JavaScriptRendererConnector
}
Object.defineProperty(reference, name, descriptor);
};
-
+
setProperty("element", function() {
return reference.target.@CellReference::getElement()();
}, null);
-
+
setProperty("rowIndex", function() {
return reference.target.@CellReference::getRowIndex()();
}, null);
-
+
setProperty("columnIndex", function() {
return reference.target.@CellReference::getColumnIndex()();
}, null);
-
+
setProperty("colSpan", function() {
return reference.target.@RendererCellReference::getColSpan()();
}, function(colSpan) {
reference.target.@RendererCellReference::setColSpan(*)(colSpan);
});
-
+
return reference;
}-*/;
@@ -136,8 +137,15 @@ public class JavaScriptRendererConnector
+ " must have a function named 'render'");
}
+ if (hasFunction("destory")) {
+ getLogger().severe("Your JavaScript connector ("
+ + helper.getInitFunctionName()
+ + ") has a typo. The destory method should be renamed to destroy.");
+ }
+
final boolean hasInit = hasFunction("init");
- final boolean hasDestroy = hasFunction("destroy");
+ final boolean hasDestroy = hasFunction("destroy")
+ || hasFunction("destory");
final boolean hasOnActivate = hasFunction("onActivate");
final boolean hasGetConsumedEvents = hasFunction("getConsumedEvents");
final boolean hasOnBrowserEvent = hasFunction("onBrowserEvent");
@@ -183,17 +191,23 @@ public class JavaScriptRendererConnector
@Override
public void destroy(RendererCellReference cell) {
+ getLogger().warning("Destprying: " + cell.getRowIndex() + " "
+ + cell.getColumnIndexDOM());
if (hasDestroy) {
- destory(helper.getConnectorWrapper(), getJsCell(cell));
+ destroy(helper.getConnectorWrapper(), getJsCell(cell));
} else {
super.destroy(cell);
}
}
- private native void destory(JavaScriptObject wrapper,
+ private native void destroy(JavaScriptObject wrapper,
JavaScriptObject cell)
/*-{
- wrapper.destory(cell);
+ if (wrapper.destroy) {
+ wrapper.destroy(cell);
+ } else if (wrapper.destory) {
+ wrapper.destory(cell);
+ }
}-*/;
@Override
@@ -258,6 +272,10 @@ public class JavaScriptRendererConnector
};
}
+ private Logger getLogger() {
+ return Logger.getLogger(JavaScriptRendererConnector.class.getName());
+ }
+
@Override
public Object decode(JsonValue value) {
// Let the js logic decode the raw json that the server sent
diff --git a/client/src/main/java/com/vaadin/client/renderers/ImageRenderer.java b/client/src/main/java/com/vaadin/client/renderers/ImageRenderer.java
index d1195969da..955a0c4cb2 100644
--- a/client/src/main/java/com/vaadin/client/renderers/ImageRenderer.java
+++ b/client/src/main/java/com/vaadin/client/renderers/ImageRenderer.java
@@ -29,7 +29,7 @@ import com.vaadin.client.widget.grid.RendererCellReference;
*/
public class ImageRenderer extends ClickableRenderer<String, Image> {
- public static final String TRANSPARENT_GIF_1PX = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=";
+ public static final String TRANSPARENT_GIF_1PX = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
@Override
public Image createWidget() {
diff --git a/client/src/main/java/com/vaadin/client/ui/VComboBox.java b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
index 4cf7ab8856..d0de766a55 100644
--- a/client/src/main/java/com/vaadin/client/ui/VComboBox.java
+++ b/client/src/main/java/com/vaadin/client/ui/VComboBox.java
@@ -87,7 +87,7 @@ import com.vaadin.shared.util.SharedUtil;
* Client side implementation of the ComboBox component.
*
* TODO needs major refactoring (to be extensible etc)
- *
+ *
* @since 8.0
*/
@SuppressWarnings("deprecation")
@@ -243,12 +243,12 @@ public class VComboBox extends Composite implements Field, KeyDownHandler,
return $entry(function(e) {
var deltaX = e.deltaX ? e.deltaX : -0.5*e.wheelDeltaX;
var deltaY = e.deltaY ? e.deltaY : -0.5*e.wheelDeltaY;
-
+
// IE8 has only delta y
if (isNaN(deltaY)) {
deltaY = -0.5*e.wheelDelta;
}
-
+
@com.vaadin.client.ui.VComboBox.JsniUtil::moveScrollFromEvent(*)(widget, deltaX, deltaY, e, e.deltaMode);
});
}-*/;
diff --git a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
index fa42637b55..374c241409 100644
--- a/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
+++ b/client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
@@ -305,10 +305,12 @@ public class VCustomLayout extends ComplexPanel {
*/
public void updateCaption(ComponentConnector childConnector) {
Widget widget = childConnector.getWidget();
- if (widget.getParent() != this) {
+
+ if (!widget.isAttached()) {
// Widget has not been added because the location was not found
return;
}
+
VCaptionWrapper wrapper = childWidgetToCaptionWrapper.get(widget);
if (VCaption.isNeeded(childConnector)) {
if (wrapper == null) {
diff --git a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java
index 2a07cf8744..9f53935440 100644
--- a/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java
+++ b/client/src/main/java/com/vaadin/client/ui/VDragAndDropWrapper.java
@@ -392,6 +392,7 @@ public class VDragAndDropWrapper extends VCustomComponent
public boolean html5DragDrop(VHtml5DragEvent event) {
if (dropHandler == null || !currentlyValid) {
+ VDragAndDropManager.get().interruptDrag();
return true;
}
try {
@@ -466,11 +467,11 @@ public class VDragAndDropWrapper extends VCustomComponent
public final native void postFile(VHtml5File file)
/*-{
-
+
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);
}-*/;
@@ -626,19 +627,19 @@ public class VDragAndDropWrapper extends VCustomComponent
protected native void hookHtml5Events(com.google.gwt.user.client.Element el)
/*-{
var me = this;
-
+
el.addEventListener("dragenter", $entry(function(ev) {
return me.@com.vaadin.client.ui.VDragAndDropWrapper::html5DragEnter(Lcom/vaadin/client/ui/dd/VHtml5DragEvent;)(ev);
}), false);
-
+
el.addEventListener("dragleave", $entry(function(ev) {
return me.@com.vaadin.client.ui.VDragAndDropWrapper::html5DragLeave(Lcom/vaadin/client/ui/dd/VHtml5DragEvent;)(ev);
}), false);
-
+
el.addEventListener("dragover", $entry(function(ev) {
return me.@com.vaadin.client.ui.VDragAndDropWrapper::html5DragOver(Lcom/vaadin/client/ui/dd/VHtml5DragEvent;)(ev);
}), false);
-
+
el.addEventListener("drop", $entry(function(ev) {
return me.@com.vaadin.client.ui.VDragAndDropWrapper::html5DragDrop(Lcom/vaadin/client/ui/dd/VHtml5DragEvent;)(ev);
}), false);
diff --git a/client/src/main/java/com/vaadin/client/ui/VWindow.java b/client/src/main/java/com/vaadin/client/ui/VWindow.java
index 98fdcc3707..caf41785a7 100644
--- a/client/src/main/java/com/vaadin/client/ui/VWindow.java
+++ b/client/src/main/java/com/vaadin/client/ui/VWindow.java
@@ -691,6 +691,8 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
public void hide() {
if (vaadinModality) {
hideModalityCurtain();
+ hideDraggingCurtain();
+ hideResizingCurtain();
}
super.hide();
diff --git a/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java b/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java
index 6c23d8af87..14467987cf 100644
--- a/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java
+++ b/client/src/main/java/com/vaadin/client/widget/grid/EditorHandler.java
@@ -55,9 +55,9 @@ public interface EditorHandler<T> {
public int getRowIndex();
/**
- * Returns the index of the column being focused.
+ * Returns the DOM index of the column being focused.
*
- * @return the column index
+ * @return the column index (excluding hidden columns)
*/
public int getColumnIndex();
diff --git a/client/src/main/java/com/vaadin/client/widget/grid/GridEventHandler.java b/client/src/main/java/com/vaadin/client/widget/grid/GridEventHandler.java
index cc3ccc6c83..d5e2e27496 100644
--- a/client/src/main/java/com/vaadin/client/widget/grid/GridEventHandler.java
+++ b/client/src/main/java/com/vaadin/client/widget/grid/GridEventHandler.java
@@ -31,4 +31,4 @@ public interface GridEventHandler<T> {
* the event that occurred
*/
public void onEvent(GridEvent<T> event);
-} \ No newline at end of file
+}
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 a135827a5a..a58418d443 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -1097,15 +1097,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private Grid<T> grid;
private final int rowIndex;
- private final int columnIndex;
+ private final int columnIndexDOM;
private RequestCallback<T> callback;
private boolean completed = false;
- public EditorRequestImpl(Grid<T> grid, int rowIndex, int columnIndex,
+ public EditorRequestImpl(Grid<T> grid, int rowIndex, int columnIndexDOM,
RequestCallback<T> callback) {
this.grid = grid;
this.rowIndex = rowIndex;
- this.columnIndex = columnIndex;
+ this.columnIndexDOM = columnIndexDOM;
this.callback = callback;
}
@@ -1116,7 +1116,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
@Override
public int getColumnIndex() {
- return columnIndex;
+ return columnIndexDOM;
}
@Override
@@ -1285,13 +1285,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
/**
- * Returns the column index the editor was opened at. If the editor is
- * not open, returns -1.
+ * Returns the DOM column index (excluding hidden columns) the editor
+ * was opened at. If the editor is not open, returns -1.
*
* @return the column index or -1 if editor is not open
*/
public int getFocusedColumnIndex() {
- return getEditor().focusedColumnIndex;
+ return getEditor().focusedColumnIndexDOM;
}
}
@@ -1362,7 +1362,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private boolean enabled = false;
private State state = State.INACTIVE;
private int rowIndex = -1;
- private int focusedColumnIndex = -1;
+ private int focusedColumnIndexDOM = -1;
private String styleName = null;
private HandlerRegistration hScrollHandler;
@@ -1427,10 +1427,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
bindTimeout.cancel();
rowIndex = request.getRowIndex();
- focusedColumnIndex = request.getColumnIndex();
- if (focusedColumnIndex >= 0) {
+ focusedColumnIndexDOM = request.getColumnIndex();
+ if (focusedColumnIndexDOM >= 0) {
// Update internal focus of Grid
- grid.focusCell(rowIndex, focusedColumnIndex);
+ grid.focusCell(rowIndex, focusedColumnIndexDOM);
}
showOverlay();
@@ -1539,9 +1539,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*
* @param rowIndex
* the index of the row to be edited
- * @param columnIndex
- * the column index of the editor widget that should be
- * initially focused or -1 to not set focus
+ * @param columnIndexDOM
+ * the column index (excluding hidden columns) of the editor
+ * widget that should be initially focused or -1 to not set
+ * focus
*
* @throws IllegalStateException
* if this editor is not enabled
@@ -1551,7 +1552,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*
* @since 7.5
*/
- public void editRow(final int rowIndex, final int columnIndex) {
+ public void editRow(final int rowIndex, final int columnIndexDOM) {
if (!enabled) {
throw new IllegalStateException(
"Cannot edit row: editor is not enabled");
@@ -1576,35 +1577,35 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
return;
}
}
- if (columnIndex >= grid.getVisibleColumns().size()) {
+ if (columnIndexDOM >= grid.getVisibleColumns().size()) {
throw new IllegalArgumentException(
- "Edited column index " + columnIndex
+ "Edited column index " + columnIndexDOM
+ " was bigger than visible column count.");
}
if (this.rowIndex == rowIndex
- && focusedColumnIndex == columnIndex) {
+ && focusedColumnIndexDOM == columnIndexDOM) {
// NO-OP
return;
}
if (this.rowIndex == rowIndex) {
- if (focusedColumnIndex != columnIndex) {
- if (columnIndex >= grid.getFrozenColumnCount()) {
+ if (focusedColumnIndexDOM != columnIndexDOM) {
+ if (columnIndexDOM >= grid.getFrozenColumnCount()) {
// Scroll to new focused column.
- grid.getEscalator().scrollToColumn(columnIndex,
+ grid.getEscalator().scrollToColumn(columnIndexDOM,
ScrollDestination.ANY, 0);
}
- focusedColumnIndex = columnIndex;
+ focusedColumnIndexDOM = columnIndexDOM;
}
updateHorizontalScrollPosition();
// Update Grid internal focus and focus widget if possible
- if (focusedColumnIndex >= 0) {
- grid.focusCell(rowIndex, focusedColumnIndex);
- focusColumn(focusedColumnIndex);
+ if (focusedColumnIndexDOM >= 0) {
+ grid.focusCell(rowIndex, focusedColumnIndexDOM);
+ focusColumn(focusedColumnIndexDOM);
}
// No need to request anything from the editor handler.
@@ -1614,13 +1615,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
final Escalator escalator = grid.getEscalator();
if (escalator.getVisibleRowRange().contains(rowIndex)) {
- show(rowIndex, columnIndex);
+ show(rowIndex, columnIndexDOM);
} else {
vScrollHandler = grid.addScrollHandler(new ScrollHandler() {
@Override
public void onScroll(ScrollEvent event) {
if (escalator.getVisibleRowRange().contains(rowIndex)) {
- show(rowIndex, columnIndex);
+ show(rowIndex, columnIndexDOM);
vScrollHandler.removeHandler();
}
}
@@ -1653,7 +1654,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
"Cannot cancel edit: editor is not in edit mode");
}
handler.cancel(new EditorRequestImpl<>(grid, rowIndex,
- focusedColumnIndex, null), afterSave);
+ focusedColumnIndexDOM, null), afterSave);
doCancel();
}
@@ -1661,7 +1662,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
hideOverlay();
state = State.INACTIVE;
rowIndex = -1;
- focusedColumnIndex = -1;
+ focusedColumnIndexDOM = -1;
grid.getEscalator().setScrollLocked(Direction.VERTICAL, false);
updateSelectionCheckboxesAsNeeded(true);
}
@@ -1699,7 +1700,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
setButtonsEnabled(false);
saveTimeout.schedule(SAVE_TIMEOUT_MS);
EditorRequest<T> request = new EditorRequestImpl<>(grid, rowIndex,
- focusedColumnIndex, saveRequestCallback);
+ focusedColumnIndexDOM, saveRequestCallback);
handler.save(request);
updateSelectionCheckboxesAsNeeded(true);
}
@@ -1871,8 +1872,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
grid.attachWidget(editor, cell);
}
- if (i == focusedColumnIndex) {
- focusColumn(focusedColumnIndex);
+ if (i == focusedColumnIndexDOM) {
+ focusColumn(focusedColumnIndexDOM);
}
} else {
cell.addClassName(NOT_EDITABLE_CLASS_NAME);
@@ -1972,13 +1973,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
Unit.PX);
}
- private void focusColumn(int colIndex) {
- if (colIndex < 0 || colIndex >= grid.getVisibleColumns().size()) {
+ private void focusColumn(int columnIndexDOM) {
+ if (columnIndexDOM < 0
+ || columnIndexDOM >= grid.getVisibleColumns().size()) {
// NO-OP
return;
}
- Widget editor = getWidget(grid.getVisibleColumn(colIndex));
+ Widget editor = getWidget(grid.getVisibleColumn(columnIndexDOM));
if (editor instanceof Focusable) {
((Focusable) editor).focus();
} else if (editor instanceof com.google.gwt.user.client.ui.Focusable) {
@@ -2563,9 +2565,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
++i;
} while (cell != null);
}
- int columnIndex = getColumns()
- .indexOf(getVisibleColumn(columnIndexDOM));
- if (columnIndex >= escalator.getColumnConfiguration()
+ if (columnIndexDOM >= escalator.getColumnConfiguration()
.getFrozenColumnCount()) {
escalator.scrollToColumn(columnIndexDOM, ScrollDestination.ANY,
10);
@@ -6278,21 +6278,22 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
*
* @param rowIndex
* index of row to focus
- * @param columnIndex
- * index of cell to focus
+ * @param columnIndexDOM
+ * index (excluding hidden columns) of cell to focus
*/
- void focusCell(int rowIndex, int columnIndex) {
+ void focusCell(int rowIndex, int columnIndexDOM) {
final Range rowRange = Range.between(0, dataSource.size());
final Range columnRange = Range.between(0, getVisibleColumns().size());
assert rowRange.contains(
rowIndex) : "Illegal row index. Should be in range " + rowRange;
assert columnRange.contains(
- columnIndex) : "Illegal column index. Should be in range "
+ columnIndexDOM) : "Illegal column index. Should be in range "
+ columnRange;
- if (rowRange.contains(rowIndex) && columnRange.contains(columnIndex)) {
- cellFocusHandler.setCellFocus(rowIndex, columnIndex,
+ if (rowRange.contains(rowIndex)
+ && columnRange.contains(columnIndexDOM)) {
+ cellFocusHandler.setCellFocus(rowIndex, columnIndexDOM,
escalator.getBody());
WidgetUtil.focus(getElement());
}
@@ -7447,10 +7448,11 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
Widget widget;
- if (editor.focusedColumnIndex < 0) {
+ if (editor.focusedColumnIndexDOM < 0) {
widget = null;
} else {
- widget = editor.getWidget(getColumn(editor.focusedColumnIndex));
+ widget = editor
+ .getWidget(getColumn(editor.focusedColumnIndexDOM));
}
EditorDomEvent<T> editorEvent = new EditorDomEvent<>(
@@ -7556,8 +7558,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (!event.getCell().isHeader()) {
return;
}
- if (event.getCell().getColumnIndex() < escalator
- .getColumnConfiguration().getFrozenColumnCount()) {
+ if (event.getCell().getColumnIndex() < getFrozenColumnCount()) {
return;
}