summaryrefslogtreecommitdiffstats
path: root/compatibility-client/src
diff options
context:
space:
mode:
authorDenis <denis@vaadin.com>2016-12-15 12:40:54 +0200
committerPekka Hyvönen <pekka@vaadin.com>2016-12-15 12:40:54 +0200
commit809a486c60a680d31308ffd078e6f8036252a990 (patch)
tree75a3d7481a12d042606316fad190130ada181b62 /compatibility-client/src
parent616e1f8ce5e544693268f54a2ac4cec2158d4a19 (diff)
downloadvaadin-framework-809a486c60a680d31308ffd078e6f8036252a990.tar.gz
vaadin-framework-809a486c60a680d31308ffd078e6f8036252a990.zip
Migrate 7.7.5 branch patches to v8. (#7969)
* Prevent adding several scrollbar handlers (#19189). Change-Id: Ib0cc6c6835aab6d263f153362a328bcf2be7bc5c * Prevent adding several scrollbar handlers (#19189). * Keep expand ratio for last row/column when reducing grid layout size (#20297) Change-Id: Iff53a803596f4fc1eae8e4bfa307b9c1f4df961a * Fixed drag and drop failure when message dragged from email client (#20451) When dragging message form email client on Windows, item.webkitGetAsEntry() might return null creating NPE on the client side. Added additional checks for this situation. Change-Id: I569f7e6d0d7b137f24be53d1fbce384695ae8c73 * Change expected pre-release version number pattern in publish report Change-Id: Icdacecc490d2490ea9e262f5c5736c1dece2a89d * Mark TextField/TextArea as busy when a text change event is pending (#20469) Change-Id: I404985ae0be1e7dc65171b610032f8649e700f50 # Conflicts: # client/src/main/java/com/vaadin/client/ui/VTextField.java # uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java * Fixed touch scrolling issue in Surface and WP devices (#18737) Fixed by using pointerevents instead of touchevents when the browser is IE11, or Edge. Also added touch-action: none; css rules into escalator.css to prevent default touch behaviour on IE11 and Edge. Does not affect IE8 to IE10 browsers, behaviour on those will stay the same as before the fix. No new unit tests since we do not have automatic touch testing possibilities yet. Please test manually with Surface: IE11 and Edge, use for example uitest: com.vaadin.tests.components.grid.basics.GridBasicsomponents.grid.basics.GridBasics Change-Id: Iddbf1852e6ffafc855f749d6f4ebb235ed0f5703 * Add lazy/simple resize mode to Grid (#20108) Change-Id: I47427efc28c350382dba8c1f50fd332a3f4585e4 # Conflicts: # client/src/main/java/com/vaadin/client/connectors/GridConnector.java # client/src/main/java/com/vaadin/client/widgets/Grid.java # server/src/main/java/com/vaadin/ui/Grid.java # shared/src/main/java/com/vaadin/shared/ui/grid/GridState.java # themes/src/main/themes/VAADIN/themes/base/grid/grid.scss # uitest/src/main/java/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java Change-Id: Ieca56121875198ed559a41c143b28926e2695433 * Fix NPE in case some items don't contain all properties of Grid. This could occur in when parent is a different entity than its children in hierarchical data. Change-Id: Icd53b5b5e5544a3680d0cd99702ab78224b2dc08 # Conflicts: # server/src/main/java/com/vaadin/data/fieldgroup/FieldGroup.java # server/src/main/java/com/vaadin/ui/Grid.java * Mark TextField/TextArea as busy when a text change event is pending (#20469) Change-Id: I404985ae0be1e7dc65171b610032f8649e700f50 # Conflicts: # client/src/main/java/com/vaadin/client/ui/VTextField.java # uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java * Add lazy/simple resize mode to Grid (#20108) Change-Id: I47427efc28c350382dba8c1f50fd332a3f4585e4 * Removed V8 VTextField unused import, forgotten @RunLocally. * Don't rely on selenium "sendKeys" behavior. * Revert "Change expected pre-release version number pattern in publish report" This reverts commit 8df27b952dddb691aead6a633c5b3724c98bf343. * Migrate TextField/TextArea patch from 7.7 to master (modern components) Mark TextField/TextArea as busy when a text change event is pending (#20469) Change-Id: I404985ae0be1e7dc65171b610032f8649e700f50
Diffstat (limited to 'compatibility-client/src')
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java29
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextField.java8
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java224
3 files changed, 199 insertions, 62 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java
index cf48586d01..cba6fc6565 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java
@@ -389,7 +389,7 @@ public class GridConnector extends AbstractHasComponentsConnector
} else {
Collection<Column<?, JsonObject>> errorColumns;
if (errorColumnsIds != null) {
- errorColumns = new ArrayList<Grid.Column<?, JsonObject>>();
+ errorColumns = new ArrayList<>();
for (String colId : errorColumnsIds) {
errorColumns.add(columnIdToColumn.get(colId));
}
@@ -435,7 +435,7 @@ public class GridConnector extends AbstractHasComponentsConnector
public void onColumnReorder(ColumnReorderEvent<JsonObject> event) {
if (!columnsUpdatedFromState) {
List<Column<?, JsonObject>> columns = getWidget().getColumns();
- final List<String> newColumnOrder = new ArrayList<String>();
+ final List<String> newColumnOrder = new ArrayList<>();
for (Column<?, JsonObject> column : columns) {
if (column instanceof CustomGridColumn) {
newColumnOrder.add(((CustomGridColumn) column).id);
@@ -494,8 +494,8 @@ public class GridConnector extends AbstractHasComponentsConnector
private class CustomDetailsGenerator
implements HeightAwareDetailsGenerator {
- private final Map<String, ComponentConnector> idToDetailsMap = new HashMap<String, ComponentConnector>();
- private final Map<String, Integer> idToRowIndex = new HashMap<String, Integer>();
+ private final Map<String, ComponentConnector> idToDetailsMap = new HashMap<>();
+ private final Map<String, Integer> idToRowIndex = new HashMap<>();
@Override
public Widget getDetails(int rowIndex) {
@@ -544,7 +544,7 @@ public class GridConnector extends AbstractHasComponentsConnector
}
public void updateConnectorHierarchy(List<ServerConnector> children) {
- Set<String> connectorIds = new HashSet<String>();
+ Set<String> connectorIds = new HashSet<>();
for (ServerConnector child : children) {
if (child instanceof ComponentConnector) {
connectorIds.add(child.getConnectorId());
@@ -553,7 +553,7 @@ public class GridConnector extends AbstractHasComponentsConnector
}
}
- Set<String> removedDetails = new HashSet<String>();
+ Set<String> removedDetails = new HashSet<>();
for (Entry<String, ComponentConnector> entry : idToDetailsMap
.entrySet()) {
ComponentConnector connector = entry.getValue();
@@ -626,9 +626,9 @@ public class GridConnector extends AbstractHasComponentsConnector
/**
* Maps a generated column id to a grid column instance
*/
- private Map<String, CustomGridColumn> columnIdToColumn = new HashMap<String, CustomGridColumn>();
+ private Map<String, CustomGridColumn> columnIdToColumn = new HashMap<>();
- private List<String> columnOrder = new ArrayList<String>();
+ private List<String> columnOrder = new ArrayList<>();
/**
* {@link #columnsUpdatedFromState} is set to true when
@@ -642,7 +642,7 @@ public class GridConnector extends AbstractHasComponentsConnector
private RpcDataSource dataSource;
/* Used to track Grid editor columns with validation errors */
- private final Map<Column<?, JsonObject>, String> columnToErrorMessage = new HashMap<Column<?, JsonObject>, String>();
+ private final Map<Column<?, JsonObject>, String> columnToErrorMessage = new HashMap<>();
private ItemClickHandler itemClickHandler = new ItemClickHandler();
@@ -839,6 +839,11 @@ public class GridConnector extends AbstractHasComponentsConnector
}
}
+ // Column resize mode
+ if (stateChangeEvent.hasPropertyChanged("columnResizeMode")) {
+ getWidget().setColumnResizeMode(getState().columnResizeMode);
+ }
+
// Header and footer
if (stateChangeEvent.hasPropertyChanged("header")) {
updateHeaderFromState(getState().header);
@@ -1101,7 +1106,7 @@ public class GridConnector extends AbstractHasComponentsConnector
private void purgeRemovedColumns() {
// Get columns still registered in the state
- Set<String> columnsInState = new HashSet<String>();
+ Set<String> columnsInState = new HashSet<>();
for (GridColumnState columnState : getState().columns) {
columnsInState.add(columnState.id);
}
@@ -1126,7 +1131,7 @@ public class GridConnector extends AbstractHasComponentsConnector
}
private void onSortStateChange() {
- List<SortOrder> sortOrder = new ArrayList<SortOrder>();
+ List<SortOrder> sortOrder = new ArrayList<>();
String[] sortColumns = getState().sortColumns;
SortDirection[] sortDirs = getState().sortDirs;
@@ -1283,7 +1288,7 @@ public class GridConnector extends AbstractHasComponentsConnector
* @return displayed error string
*/
private String getColumnErrors() {
- List<String> errors = new ArrayList<String>();
+ List<String> errors = new ArrayList<>();
for (Grid.Column<?, JsonObject> c : getWidget().getColumns()) {
if (!(c instanceof CustomGridColumn)) {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextField.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextField.java
index ffaec8ad20..8357a7649a 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextField.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextField.java
@@ -34,6 +34,7 @@ import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.TextBoxBase;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.DeferredWorker;
import com.vaadin.client.WidgetUtil;
import com.vaadin.client.ui.Field;
import com.vaadin.shared.EventId;
@@ -47,7 +48,7 @@ import com.vaadin.v7.shared.ui.textfield.TextFieldConstants;
*/
@Deprecated
public class VTextField extends TextBoxBase implements Field, ChangeHandler,
- FocusHandler, BlurHandler, KeyDownHandler {
+ FocusHandler, BlurHandler, KeyDownHandler, DeferredWorker {
/**
* The input node CSS classname.
@@ -530,4 +531,9 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler,
}
possibleInputError = false;
}
+
+ @Override
+ public boolean isWorkPending() {
+ return scheduled;
+ }
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
index 49a6c6b986..0ea348553a 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
@@ -36,6 +36,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.dom.client.BrowserEvents;
import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
import com.google.gwt.dom.client.NativeEvent;
@@ -179,6 +180,7 @@ import com.vaadin.v7.client.widgets.Escalator.SubPartArguments;
import com.vaadin.v7.client.widgets.Grid.Editor.State;
import com.vaadin.v7.client.widgets.Grid.StaticSection.StaticCell;
import com.vaadin.v7.client.widgets.Grid.StaticSection.StaticRow;
+import com.vaadin.v7.shared.ui.grid.ColumnResizeMode;
import com.vaadin.v7.shared.ui.grid.GridConstants;
import com.vaadin.v7.shared.ui.grid.GridConstants.Section;
import com.vaadin.v7.shared.ui.grid.GridStaticCellType;
@@ -4105,6 +4107,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
private AutoScroller autoScroller = new AutoScroller(this);
+ private ColumnResizeMode columnResizeMode = ColumnResizeMode.ANIMATED;
+
private DragAndDropHandler.DragAndDropCallback headerCellDndCallback = new DragAndDropCallback() {
private final AutoScrollerCallback autoScrollerCallback = new AutoScrollerCallback() {
@@ -5691,63 +5695,164 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
&& staticRow instanceof HeaderRow
&& ((HeaderRow) staticRow).isDefault()) {
+ final DivElement resizeElement = Document.get()
+ .createDivElement();
+ resizeElement.addClassName(getStylePrimaryName()
+ + "-column-resize-simple-indicator");
+
final int column = cell.getColumn();
- DragHandle dragger = new DragHandle(
- getStylePrimaryName() + "-column-resize-handle",
- new DragHandleCallback() {
-
- private Column<?, T> col = getVisibleColumn(
- column);
- private double initialWidth = 0;
- private double minCellWidth;
-
- @Override
- public void onUpdate(double deltaX,
- double deltaY) {
- col.setWidth(Math.max(minCellWidth,
- initialWidth + deltaX));
- }
+ final DragHandle dragger = new DragHandle(
+ getStylePrimaryName() + "-column-resize-handle");
+ dragger.addTo(td);
- @Override
- public void onStart() {
- initialWidth = col.getWidthActual();
-
- minCellWidth = escalator.getMinCellWidth(
- getVisibleColumns().indexOf(col));
- for (Column<?, T> c : getVisibleColumns()) {
- if (selectionColumn == c) {
- // Don't modify selection column.
- continue;
- }
-
- if (c.getWidth() < 0) {
- c.setWidth(c.getWidthActual());
- fireEvent(
- new ColumnResizeEvent<>(c));
- }
- }
+ // Common functionality for drag handle callback
+ // implementations
+ abstract class AbstractDHCallback
+ implements DragHandleCallback {
+ protected Column<?, T> col = getVisibleColumn(column);
+ protected double initialWidth = 0;
+ protected double minCellWidth;
+ protected double width;
+
+ protected void dragStarted() {
+ initialWidth = col.getWidthActual();
+ width = initialWidth;
+
+ minCellWidth = escalator.getMinCellWidth(
+ getVisibleColumns().indexOf(col));
+ for (Column<?, T> c : getVisibleColumns()) {
+ if (selectionColumn == c) {
+ // Don't modify selection column.
+ continue;
+ }
- WidgetUtil.setTextSelectionEnabled(
- getElement(), false);
+ if (c.getWidth() < 0) {
+ c.setWidth(c.getWidthActual());
+ fireEvent(new ColumnResizeEvent<>(c));
}
+ }
- @Override
- public void onComplete() {
- fireEvent(new ColumnResizeEvent<>(col));
+ WidgetUtil.setTextSelectionEnabled(getElement(),
+ false);
+ }
- WidgetUtil.setTextSelectionEnabled(
- getElement(), true);
- }
+ protected void dragEnded() {
+ WidgetUtil.setTextSelectionEnabled(getElement(),
+ true);
+ }
+ }
- @Override
- public void onCancel() {
- col.setWidth(initialWidth);
+ final DragHandleCallback simpleResizeMode = new AbstractDHCallback() {
+ @Override
+ protected void dragEnded() {
+ super.dragEnded();
+ dragger.getElement().removeChild(resizeElement);
+ }
- WidgetUtil.setTextSelectionEnabled(
- getElement(), true);
- }
- });
- dragger.addTo(td);
+ @Override
+ public void onStart() {
+ dragStarted();
+ dragger.getElement().appendChild(resizeElement);
+ resizeElement.getStyle().setLeft(
+ (dragger.getElement().getOffsetWidth()
+ - resizeElement.getOffsetWidth())
+ * .5,
+ Unit.PX);
+ resizeElement.getStyle().setHeight(
+ col.grid.getOffsetHeight(), Unit.PX);
+ }
+
+ @Override
+ public void onUpdate(double deltaX, double deltaY) {
+ width = Math.max(minCellWidth,
+ initialWidth + deltaX);
+ resizeElement.getStyle().setLeft(
+ (dragger.getElement().getOffsetWidth()
+ - resizeElement.getOffsetWidth())
+ * .5 + (width - initialWidth),
+ Unit.PX);
+ }
+
+ @Override
+ public void onCancel() {
+ dragEnded();
+ }
+
+ @Override
+ public void onComplete() {
+ dragEnded();
+
+ col.setWidth(width);
+ fireEvent(new ColumnResizeEvent<>(col));
+ }
+ };
+
+ final DragHandleCallback animatedResizeMode = new AbstractDHCallback() {
+ @Override
+ public void onStart() {
+ dragStarted();
+ }
+
+ @Override
+ public void onUpdate(double deltaX, double deltaY) {
+ width = Math.max(minCellWidth,
+ initialWidth + deltaX);
+ col.setWidth(width);
+ }
+
+ @Override
+ public void onCancel() {
+ dragEnded();
+ col.setWidth(initialWidth);
+ }
+
+ @Override
+ public void onComplete() {
+ dragEnded();
+ col.setWidth(width);
+ fireEvent(new ColumnResizeEvent<>(col));
+ }
+ };
+
+ // DragHandle gets assigned a 'master callback' that
+ // delegates
+ // functionality to the correct case-specific implementation
+ dragger.setCallback(new DragHandleCallback() {
+
+ private DragHandleCallback currentCallback;
+
+ @Override
+ public void onStart() {
+ switch (getColumnResizeMode()) {
+ case SIMPLE:
+ currentCallback = simpleResizeMode;
+ break;
+ case ANIMATED:
+ currentCallback = animatedResizeMode;
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ "Support for current column resize mode is not yet implemented");
+ }
+
+ currentCallback.onStart();
+ }
+
+ @Override
+ public void onUpdate(double deltaX, double deltaY) {
+ currentCallback.onUpdate(deltaX, deltaY);
+ }
+
+ @Override
+ public void onCancel() {
+ currentCallback.onCancel();
+ }
+
+ @Override
+ public void onComplete() {
+ currentCallback.onComplete();
+ }
+ });
}
cellFocusHandler.updateFocusedCellStyle(cell, container);
@@ -5979,6 +6084,27 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
return enabled;
}
+ /**
+ * Sets the column resize mode to use. The default mode is
+ * {@link ColumnResizeMode.ANIMATED}.
+ *
+ * @param mode
+ * a ColumnResizeMode value
+ */
+ public void setColumnResizeMode(ColumnResizeMode mode) {
+ columnResizeMode = mode;
+ }
+
+ /**
+ * Returns the current column resize mode. The default mode is
+ * {@link ColumnResizeMode.ANIMATED}.
+ *
+ * @return a ColumnResizeMode value
+ */
+ public ColumnResizeMode getColumnResizeMode() {
+ return columnResizeMode;
+ }
+
@Override
public void setEnabled(boolean enabled) {
if (enabled == this.enabled) {