From: Teemu Suo-Anttila Date: Wed, 1 Mar 2017 12:27:49 +0000 (+0200) Subject: Synchronize code between V7 and compatibility package X-Git-Tag: 8.0.2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a67489bf1307b8b97c2559ccfe5dbe5ff55d11d5;p=vaadin-framework.git Synchronize code between V7 and compatibility package --- diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/AbstractRendererConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/AbstractRendererConnector.java index 284cc225e0..fe0c561d5c 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/AbstractRendererConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/AbstractRendererConnector.java @@ -124,5 +124,4 @@ public abstract class AbstractRendererConnector protected void extend(ServerConnector target) { // NOOP } - } 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 c59ec0afe4..87a4c90360 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 @@ -153,7 +153,7 @@ public class GridConnector extends AbstractHasComponentsConnector } /** - * Custom implementation of the custom grid column using a JSONObject to + * Custom implementation of the custom grid column using a JSONObject to * represent the cell value and String as a column type. */ private class CustomGridColumn extends Grid.Column { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/JavaScriptRendererConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/JavaScriptRendererConnector.java index 6a94416ad9..51071e2c50 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/JavaScriptRendererConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/JavaScriptRendererConnector.java @@ -17,6 +17,7 @@ package com.vaadin.v7.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; @@ -135,8 +136,16 @@ 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,16 +192,20 @@ public class JavaScriptRendererConnector @Override public void destroy(RendererCellReference cell) { 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 { + wrapper.destory(cell); + } }-*/; @Override @@ -258,6 +271,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/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/MultiSelectionModelConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/MultiSelectionModelConnector.java index 5103abb285..035498db61 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/MultiSelectionModelConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/MultiSelectionModelConnector.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.logging.Logger; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.ui.CheckBox; @@ -37,12 +38,15 @@ import com.vaadin.v7.client.widget.grid.DataAvailableEvent; import com.vaadin.v7.client.widget.grid.DataAvailableHandler; import com.vaadin.v7.client.widget.grid.events.SelectAllEvent; import com.vaadin.v7.client.widget.grid.events.SelectAllHandler; +import com.vaadin.v7.client.widget.grid.selection.HasUserSelectionAllowed; import com.vaadin.v7.client.widget.grid.selection.MultiSelectionRenderer; import com.vaadin.v7.client.widget.grid.selection.SelectionModel; import com.vaadin.v7.client.widget.grid.selection.SelectionModel.Multi; import com.vaadin.v7.client.widget.grid.selection.SpaceSelectHandler; import com.vaadin.v7.client.widgets.Grid; +import com.vaadin.v7.client.widgets.Grid.Column; import com.vaadin.v7.client.widgets.Grid.HeaderCell; +import com.vaadin.v7.client.widgets.Grid.SelectionColumn; import com.vaadin.v7.shared.ui.grid.GridState; import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState; @@ -94,8 +98,30 @@ public class MultiSelectionModelConnector extends } } + @OnStateChange("userSelectionAllowed") + void updateUserSelectionAllowed() { + if (selectionModel instanceof HasUserSelectionAllowed) { + ((HasUserSelectionAllowed) selectionModel) + .setUserSelectionAllowed(getState().userSelectionAllowed); + } else { + getLogger().warning("userSelectionAllowed set to " + + getState().userSelectionAllowed + + " but the selection model does not implement " + + HasUserSelectionAllowed.class.getSimpleName()); + } + } + + private static Logger getLogger() { + return Logger.getLogger(MultiSelectionModelConnector.class.getName()); + } + + /** + * The default multi selection model used for this connector. + * + */ protected class MultiSelectionModel extends AbstractSelectionModel - implements SelectionModel.Multi.Batched { + implements SelectionModel.Multi.Batched, + HasUserSelectionAllowed { private ComplexRenderer renderer = null; private Set> selected = new HashSet>(); @@ -104,6 +130,7 @@ public class MultiSelectionModelConnector extends private HandlerRegistration dataAvailable; private Range availableRows; private boolean batchSelect = false; + private boolean userSelectionAllowed = true; @Override public void setGrid(Grid grid) { @@ -382,5 +409,21 @@ public class MultiSelectionModelConnector extends public Collection getDeselectedRowsBatch() { return Collections.unmodifiableSet(getRows(deselected)); } + + @Override + public boolean isUserSelectionAllowed() { + return userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + this.userSelectionAllowed = userSelectionAllowed; + for (Column c : getGrid().getColumns()) { + if (c instanceof SelectionColumn) { + ((SelectionColumn) c) + .setUserSelectionAllowed(userSelectionAllowed); + } + } + } } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/SingleSelectionModelConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/SingleSelectionModelConnector.java index 059278c311..d922166451 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/SingleSelectionModelConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/connectors/SingleSelectionModelConnector.java @@ -15,12 +15,15 @@ */ package com.vaadin.v7.client.connectors; +import java.util.logging.Logger; + import com.vaadin.client.ServerConnector; import com.vaadin.client.annotations.OnStateChange; import com.vaadin.client.data.DataSource.RowHandle; import com.vaadin.shared.ui.Connect; import com.vaadin.v7.client.renderers.Renderer; import com.vaadin.v7.client.widget.grid.selection.ClickSelectHandler; +import com.vaadin.v7.client.widget.grid.selection.HasUserSelectionAllowed; import com.vaadin.v7.client.widget.grid.selection.SelectionModel; import com.vaadin.v7.client.widget.grid.selection.SelectionModel.Single; import com.vaadin.v7.client.widget.grid.selection.SpaceSelectHandler; @@ -75,14 +78,34 @@ public class SingleSelectionModelConnector extends selectionModel.setDeselectAllowed(getState().deselectAllowed); } + @OnStateChange("userSelectionAllowed") + void updateUserSelectionAllowed() { + + if (selectionModel instanceof HasUserSelectionAllowed) { + ((HasUserSelectionAllowed) selectionModel) + .setUserSelectionAllowed(getState().userSelectionAllowed); + } else { + getLogger().warning("userSelectionAllowed set to " + + getState().userSelectionAllowed + + " but the selection model does not implement " + + HasUserSelectionAllowed.class.getSimpleName()); + } + } + + private static Logger getLogger() { + return Logger.getLogger(SingleSelectionModelConnector.class.getName()); + } + /** * SingleSelectionModel without a selection column renderer. */ public class SingleSelectionModel extends AbstractSelectionModel - implements SelectionModel.Single { + implements SelectionModel.Single, + HasUserSelectionAllowed { private RowHandle selectedRow; private boolean deselectAllowed; + private boolean userSelectionAllowed = true; @Override public Renderer getSelectionColumnRenderer() { @@ -153,8 +176,14 @@ public class SingleSelectionModelConnector extends @Override public boolean deselect(JsonObject row) { - if (getRowHandle(row).equals(selectedRow)) { - select(null); + if (isSelected(row)) { + // If no selection has happened client side, then selectedRow is + // null but must be set so that a deselection event with the + // correct key can be sent to the server + selectedRow = getRowHandle(row); + selectedRow.pin(); + + return select(null); } return false; } @@ -176,5 +205,15 @@ public class SingleSelectionModelConnector extends public boolean isDeselectAllowed() { return deselectAllowed; } + + @Override + public boolean isUserSelectionAllowed() { + return userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + this.userSelectionAllowed = userSelectionAllowed; + } } -} \ No newline at end of file +} diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/renderers/ImageRenderer.java b/compatibility-client/src/main/java/com/vaadin/v7/client/renderers/ImageRenderer.java index a29b4f2cfd..a151d3ff68 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/renderers/ImageRenderer.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/renderers/ImageRenderer.java @@ -29,7 +29,7 @@ import com.vaadin.v7.client.widget.grid.RendererCellReference; */ public class ImageRenderer extends ClickableRenderer { - 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/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java index a27f2c80cd..8780c980ab 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java @@ -1677,7 +1677,7 @@ public class VCalendarPanel extends FocusableFlexTable implements private ListBox createListBox() { ListBox lb = new ListBox(); - lb.setStyleName("v-select"); + lb.setStyleName(VNativeSelect.CLASSNAME); lb.addChangeHandler(this); lb.addBlurHandler(VCalendarPanel.this); lb.addFocusHandler(VCalendarPanel.this); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java index aa47481e6a..0daaff47f9 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java @@ -1450,7 +1450,10 @@ public class VFilterSelect extends Composite }; private class IconWidget extends Widget { + private Icon icon; + IconWidget(Icon icon) { + this.icon = icon; setElement(icon.getElement()); addDomHandler(VFilterSelect.this, ClickEvent.getType()); } @@ -1908,25 +1911,59 @@ public class VFilterSelect extends Composite afterSelectedItemIconChange(); } } else { + IconWidget newIcon = new IconWidget(client.getIcon(iconUri)); + if (iconEquals(newIcon, selectedItemIcon)) { + /* + * Do not update the icon if nothing has changed. Otherwise we + * can cause problems such as not being able to click in the + * icon to open the popup (blur might occur and call this + * method, icon is replaced and the click event is not delivered + * to the new icon) + */ + return; + } + if (selectedItemIcon != null) { panel.remove(selectedItemIcon); } - selectedItemIcon = new IconWidget(client.getIcon(iconUri)); + // Older IE versions don't scale icon correctly if DOM // contains height and width attributes. - selectedItemIcon.getElement().removeAttribute("height"); - selectedItemIcon.getElement().removeAttribute("width"); - selectedItemIcon.addDomHandler(new LoadHandler() { + newIcon.getElement().removeAttribute("height"); + newIcon.getElement().removeAttribute("width"); + newIcon.addDomHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { afterSelectedItemIconChange(); } }, LoadEvent.getType()); - panel.insert(selectedItemIcon, 0); + panel.insert(newIcon, 0); + selectedItemIcon = newIcon; afterSelectedItemIconChange(); } } + /** + * Checks if the icon widgets show the same icon. + * + * @param icon1 + * the first widget + * @param icon2 + * the second widget + * @return true if they show the same icon, false + * otherwise + */ + private static boolean iconEquals(IconWidget icon1, IconWidget icon2) { + if (icon1 == null) { + return icon2 == null; + } else if (icon2 == null) { + return false; + } else { + return icon1.icon.getUri().equals(icon2.icon.getUri()); + } + + } + private void afterSelectedItemIconChange() { if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isIE8()) { // Some browsers need a nudge to reposition the text field @@ -2392,6 +2429,7 @@ public class VFilterSelect extends Composite } } else if (currentSuggestion != null) { setPromptingOff(currentSuggestion.caption); + setSelectedItemIcon(currentSuggestion.getIconUri()); } } removeStyleDependentName("focus"); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VLabel.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VLabel.java index ebe28c0d31..6022135d90 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VLabel.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VLabel.java @@ -57,4 +57,5 @@ public class VLabel extends HTML { } } + // Vaadin 8 does not support IE8, no override for setText } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroupBase.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroupBase.java index 94a92e2980..239e6ff53a 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroupBase.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroupBase.java @@ -60,6 +60,8 @@ public abstract class VOptionGroupBase extends Composite implements Field, private boolean readonly; + // Intentional removal of cols in compatibility package + /** For internal use only. May be removed or replaced in the future. */ public int rows = 0; @@ -134,6 +136,8 @@ public abstract class VOptionGroupBase extends Composite implements Field, return nullSelectionItemAvailable; } + // Intentional removal of getColumns in compatibility package + /** * For internal use only. May be removed or replaced in the future. * diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VPopupCalendar.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VPopupCalendar.java index 832c03e99c..e93ce4c04c 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VPopupCalendar.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VPopupCalendar.java @@ -62,8 +62,7 @@ import com.vaadin.v7.shared.ui.datefield.Resolution; * selector. * * Note: To change the keyboard assignments used in the popup dialog you - * should extend com.vaadin.v7.client.ui.VCalendarPanel and then - * pass set it by calling the + * should extend VCalendarPanel and then pass set it by calling the * setCalendarPanel(VCalendarPanel panel) method. * */ @@ -270,9 +269,9 @@ public class VPopupCalendar extends VTextualDate * Sets the state of the text field of this component. By default the text * field is enabled. Disabling it causes only the button for date selection * to be active, thus preventing the user from entering invalid dates. See - * {@link http://dev.vaadin.com/ticket/6790}. + * 6790. * - * @param state + * @param textFieldEnabled */ public void setTextFieldEnabled(boolean textFieldEnabled) { this.textFieldEnabled = textFieldEnabled; @@ -366,12 +365,6 @@ public class VPopupCalendar extends VTextualDate } } - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.user.client.ui.UIObject#setStyleName(java.lang.String) - */ @Override public void setStyleName(String style) { super.setStyleName(style); @@ -419,13 +412,6 @@ public class VPopupCalendar extends VTextualDate } } - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event - * .dom.client.ClickEvent) - */ @Override public void onClick(ClickEvent event) { if (event.getSource() == calendarToggle && isEnabled()) { @@ -438,13 +424,6 @@ public class VPopupCalendar extends VTextualDate } } - /* - * (non-Javadoc) - * - * @see - * com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google.gwt - * .event.logical.shared.CloseEvent) - */ @Override public void onClose(CloseEvent event) { if (event.getSource() == popup) { @@ -531,12 +510,6 @@ public class VPopupCalendar extends VTextualDate buildDate(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.client.ui.VDateField#onBrowserEvent(com.google - * .gwt.user.client.Event) - */ @Override public void onBrowserEvent(com.google.gwt.user.client.Event event) { super.onBrowserEvent(event); @@ -617,7 +590,7 @@ public class VPopupCalendar extends VTextualDate * and it depends on the current resolution, what is considered inside the * range. * - * @param startDate + * @param rangeStart * - the allowed range's start date */ public void setRangeStart(Date rangeStart) { @@ -628,7 +601,7 @@ public class VPopupCalendar extends VTextualDate * Sets the end range for this component. The end range is inclusive, and it * depends on the current resolution, what is considered inside the range. * - * @param endDate + * @param rangeEnd * - the allowed range's end date */ public void setRangeEnd(Date rangeEnd) { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java index a6be4dc61a..3affa940fc 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java @@ -3665,6 +3665,7 @@ public class VScrollTable extends FlowPanel } } else { c.setText(caption); + // IE10 is no longer supported } c.setSorted(false); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java index c5d229e153..b42f04f9b9 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java @@ -230,6 +230,7 @@ public class VTextArea extends VTextField implements DragImageModifier { if (info.isSafari()) { return true; } + // Vaadin 8 no longer supports IE10 if (info.isIE11() || info.isEdge()) { return true; } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java index 32bc14d330..2403750b03 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java @@ -367,6 +367,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler, /** For internal use only. May be removed or replaced in the future. */ public void clearInternalWidths() { + // Intentional removal of cols in compatibility package int cols = DEFAULT_COLUMN_COUNT; if (cols >= 0) { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java index 16108792b4..8f892e377e 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java @@ -161,6 +161,7 @@ public class VUpload extends SimplePanel { private static native void setEncoding(Element form, String encoding) /*-{ form.enctype = encoding; + // IE8 not supported in Vaadin 8 }-*/; /** For internal use only. May be removed or replaced in the future. */ diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java index dcc83008b9..e904cd6803 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java @@ -180,6 +180,7 @@ public class FormConnector extends AbstractComponentContainerConnector @Override public boolean isReadOnly() { + // Class hierarchy has changed for FormConnector return getState().readOnly || getState().propertyReadOnly; } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java index 53c0c0d06a..6fe94fa5a5 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java @@ -43,6 +43,7 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector getWidget().selectedKeys = uidl.getStringArrayVariableAsSet("selected"); getWidget().setReadonly(isReadOnly()); + // Intentional change to use state over UIDL in compatibility package getWidget().multiselect = getState().multiSelect; getWidget().immediate = getState().immediate; getWidget().nullSelectionAllowed = uidl @@ -50,12 +51,16 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector getWidget().nullSelectionItemAvailable = uidl .getBooleanAttribute("nullselectitem"); + // Support for cols has been dropped. + if (uidl.hasAttribute("rows")) { getWidget().rows = uidl.getIntAttribute("rows"); } final UIDL ops = uidl.getChildUIDL(0); + // Method getColumns has been removed + getWidget().buildOptions(ops); if (uidl.getBooleanAttribute("allownewitem")) { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java index e88a2070bc..dbed217598 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java @@ -34,6 +34,7 @@ public class OptionGroupConnector extends OptionGroupBaseConnector { @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { + // HTML Content has been moved to state. super.updateFromUIDL(uidl, client); getWidget().sendFocusEvents = client.hasEventListeners(this, diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java index 9d2677af54..091951bc8b 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java @@ -386,6 +386,8 @@ public class TableConnector extends AbstractFieldConnector public void updateEnabledState(boolean enabledState) { super.updateEnabledState(enabledState); getWidget().enabled = isEnabled(); + + // IE8 is no longer supported } @Override @@ -416,6 +418,7 @@ public class TableConnector extends AbstractFieldConnector Scheduler.get().scheduleFinally(new ScheduledCommand() { @Override public void execute() { + // IE8 is no longer supported getLayoutManager().setNeedsMeasure(TableConnector.this); ServerConnector parent = getParent(); if (parent instanceof ComponentConnector) { diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java index a589e75697..d03c0bf55a 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java @@ -66,6 +66,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector if (uidl.hasAttribute("partialUpdate")) { handleUpdate(uidl); + // IE8 is no longer supported with Vaadin 8 + getWidget().rendering = false; return; } @@ -175,6 +177,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector getWidget().focusedNode.setFocused(false); } + // IE8 is no longer supported with Vaadin 8 + getWidget().rendering = false; } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java index 20b1e5d1b9..8e6d9a5243 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java @@ -362,6 +362,7 @@ public abstract class ScrollbarBundle implements DeferredWorker { private HandlerRegistration scrollSizeTemporaryScrollHandler; private HandlerRegistration offsetSizeTemporaryScrollHandler; + private HandlerRegistration scrollInProgress; private ScrollbarBundle() { root.appendChild(scrollSizeElement); @@ -435,6 +436,9 @@ public abstract class ScrollbarBundle implements DeferredWorker { boolean offsetSizeBecomesGreaterThanScrollSize = showsScrollHandle() && newOffsetSizeIsGreaterThanScrollSize; if (offsetSizeBecomesGreaterThanScrollSize && getScrollPos() != 0) { + if (offsetSizeTemporaryScrollHandler != null) { + offsetSizeTemporaryScrollHandler.removeHandler(); + } // must be a field because Java insists. offsetSizeTemporaryScrollHandler = addScrollHandler( new ScrollHandler() { @@ -523,6 +527,17 @@ public abstract class ScrollbarBundle implements DeferredWorker { scrollPos = Math.max(0, Math.min(maxScrollPos, truncate(px))); if (!WidgetUtil.pixelValuesEqual(oldScrollPos, scrollPos)) { + if (scrollInProgress == null) { + // Only used for tracking that there is "workPending" + scrollInProgress = addScrollHandler(new ScrollHandler() { + @Override + public void onScroll(ScrollEvent event) { + scrollInProgress.removeHandler(); + scrollInProgress = null; + } + }); + } + if (isInvisibleScrollbar) { invisibleScrollbarTemporaryResizer.show(); } @@ -631,7 +646,7 @@ public abstract class ScrollbarBundle implements DeferredWorker { * This needs to be made step-by-step because IE8 flat-out refuses to * fire a scroll event when the scroll size becomes smaller than the * offset size. All other browser need to suffer alongside. - * + * * This really should be changed to not use any temporary scroll * handlers at all once IE8 support is dropped, like now done only for * Firefox. @@ -649,7 +664,11 @@ public abstract class ScrollbarBundle implements DeferredWorker { * 'delayedSizeSet' */ boolean delayedSizeSet = !BrowserInfo.get().isFirefox(); + // must be a field because Java insists. if (delayedSizeSet) { + if (scrollSizeTemporaryScrollHandler != null) { + scrollSizeTemporaryScrollHandler.removeHandler(); + } scrollSizeTemporaryScrollHandler = addScrollHandler( new ScrollHandler() { @Override @@ -911,6 +930,6 @@ public abstract class ScrollbarBundle implements DeferredWorker { // requestAnimationFrame - which is not automatically checked return scrollSizeTemporaryScrollHandler != null || offsetSizeTemporaryScrollHandler != null - || scrollEventFirer.isBeingFired; + || scrollInProgress != null || scrollEventFirer.isBeingFired; } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/EditorHandler.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/EditorHandler.java index a0fee4c7fc..7777b821bc 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/EditorHandler.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/EditorHandler.java @@ -54,9 +54,9 @@ public interface EditorHandler { 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/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/GridEventHandler.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/GridEventHandler.java index 0e3e65179e..1e792f9796 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/GridEventHandler.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/GridEventHandler.java @@ -27,8 +27,8 @@ public interface GridEventHandler { /** * Attempts to handle the given grid event. * - * @param gridEvent + * @param event * the event that occurred */ - public void onEvent(GridEvent gridEvent); -} \ No newline at end of file + public void onEvent(GridEvent event); +} diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/ClickSelectHandler.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/ClickSelectHandler.java index 588d8a354b..6887f571b5 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/ClickSelectHandler.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/ClickSelectHandler.java @@ -36,6 +36,10 @@ public class ClickSelectHandler { @Override public void onClick(GridClickEvent event) { + if (!grid.isUserSelectionAllowed()) { + return; + } + T row = (T) event.getTargetCell().getRow(); if (!grid.isSelected(row)) { grid.select(row); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/HasUserSelectionAllowed.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/HasUserSelectionAllowed.java new file mode 100644 index 0000000000..82aa86fae6 --- /dev/null +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/HasUserSelectionAllowed.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.v7.client.widget.grid.selection; + +/** + * Interface implemented by selection models which support disabling client side + * selection while still allowing programmatic selection on the server. + * + * @param + * Grid's row type + * + * @since 7.7.7 + */ +public interface HasUserSelectionAllowed extends SelectionModel { + + /** + * Checks if the user is allowed to change the selection. + * + * @return true if the user is allowed to change the selection, + * false otherwise + */ + public boolean isUserSelectionAllowed(); + + /** + * Sets whether the user is allowed to change the selection. + * + * @param userSelectionAllowed + * true if the user is allowed to change the + * selection, false otherwise + */ + public void setUserSelectionAllowed(boolean userSelectionAllowed); + +} diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java index a7c974aead..86d5e0a323 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java @@ -632,7 +632,8 @@ public class MultiSelectionRenderer public void render(final RendererCellReference cell, final Boolean data, CheckBox checkBox) { checkBox.setValue(data, false); - checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive()); + checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive() + && grid.isUserSelectionAllowed()); } @Override @@ -770,6 +771,10 @@ public class MultiSelectionRenderer } protected void setSelected(final int logicalRow, final boolean select) { + if (!grid.isUserSelectionAllowed()) { + return; + } + T row = grid.getDataSource().getRow(logicalRow); if (select) { grid.select(row); diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java index 8629a5af3a..a93360d77a 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java @@ -33,7 +33,7 @@ import com.vaadin.v7.client.widgets.Grid; * @since 7.4 */ public class SelectionModelMulti extends AbstractRowHandleSelectionModel - implements SelectionModel.Multi.Batched { + implements SelectionModel.Multi.Batched, HasUserSelectionAllowed { private final LinkedHashSet> selectedRows; private Renderer renderer; @@ -45,6 +45,7 @@ public class SelectionModelMulti extends AbstractRowHandleSelectionModel /* Event handling for selection with space key */ private SpaceSelectHandler spaceSelectHandler; + private boolean userSelectionAllowed = true; public SelectionModelMulti() { grid = null; @@ -270,4 +271,14 @@ public class SelectionModelMulti extends AbstractRowHandleSelectionModel } return rows; } + + @Override + public boolean isUserSelectionAllowed() { + return userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + this.userSelectionAllowed = userSelectionAllowed; + } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelSingle.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelSingle.java index 6467759d6e..d78fbc2ba1 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelSingle.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelSingle.java @@ -29,7 +29,7 @@ import com.vaadin.v7.client.widgets.Grid; * @since 7.4 */ public class SelectionModelSingle extends AbstractRowHandleSelectionModel - implements SelectionModel.Single { + implements SelectionModel.Single, HasUserSelectionAllowed { private Grid grid; private RowHandle selectedRow; @@ -41,6 +41,7 @@ public class SelectionModelSingle extends AbstractRowHandleSelectionModel private ClickSelectHandler clickSelectHandler; private boolean deselectAllowed = true; + private boolean userSelectionAllowed = true; @Override public boolean isSelected(T row) { @@ -172,4 +173,13 @@ public class SelectionModelSingle extends AbstractRowHandleSelectionModel } } + @Override + public boolean isUserSelectionAllowed() { + return userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + this.userSelectionAllowed = userSelectionAllowed; + } } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SpaceSelectHandler.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SpaceSelectHandler.java index d4c0f2219f..8de75dde2b 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SpaceSelectHandler.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SpaceSelectHandler.java @@ -44,6 +44,10 @@ public class SpaceSelectHandler { @Override public void onKeyDown(GridKeyDownEvent event) { + if (!grid.isUserSelectionAllowed()) { + return; + } + if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE || spaceDown) { return; } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java index cb2786a4cf..e9879b9b23 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java @@ -308,6 +308,8 @@ public class Escalator extends Widget static class JsniUtil { public static class TouchHandlerBundle { + public static final String POINTER_EVENT_TYPE_TOUCH = "touch"; + /** * A a = event.getNativeEvent().getTouches(); return vertical ? a.get(0).getPageY() : a.get(0).getPageX(); } @@ -496,7 +512,7 @@ public class Escalator extends Widget }; public void touchStart(final CustomTouchEvent event) { - if (event.getNativeEvent().getTouches().length() == 1) { + if (allowTouch(event)) { if (yMov == null) { yMov = new Movement(true); xMov = new Movement(false); @@ -544,6 +560,20 @@ public class Escalator extends Widget } } + // Allow touchStart for IE11 and Edge even though there is no touch + // (#18737), + // otherwise allow touch only if there is a single touch in the + // event + private boolean allowTouch( + final TouchHandlerBundle.CustomTouchEvent event) { + if (isCurrentBrowserIE11OrEdge()) { + return (POINTER_EVENT_TYPE_TOUCH + .equals(event.getPointerType())); + } else { + return (event.getNativeEvent().getTouches().length() == 1); + } + } + private double easingInOutCos(double val, double max) { return 0.5 - 0.5 * Math.cos(Math.PI * Math.signum(val) * Math.min(Math.abs(val), max) / max); @@ -859,8 +889,8 @@ public class Escalator extends Widget if (position instanceof AbsolutePosition) { /* * we don't want to put "top: 0" on the footer, since it'll - * render wrong, as we already have "bottom: $footer-height" - * . + * render wrong, as we already have + * "bottom: $footer-height". */ footElem.getStyle().setLeft(-scrollLeft, Unit.PX); } else { @@ -901,7 +931,7 @@ public class Escalator extends Widget public native void detachScrollListener(Element element) /* - * Attaching events with JSNI instead of the GWT event mechanism because + * Detaching events with JSNI instead of the GWT event mechanism because * GWT didn't provide enough details in events, or triggering the event * handlers with GWT bindings was unsuccessful. Maybe, with more time * and skill, it could be done with better success. JavaScript overlay @@ -978,6 +1008,50 @@ public class Escalator extends Widget element.removeEventListener("touchcancel", this.@com.vaadin.v7.client.widgets.JsniWorkaround::touchEndFunction); }-*/; + /** + * Using pointerdown, pointermove, pointerup, and pointercancel for IE11 + * and Edge instead of touch* listeners (#18737) + * + * @param element + */ + public native void attachPointerEventListeners(Element element) + /* + * Attaching events with JSNI instead of the GWT event mechanism because + * GWT didn't provide enough details in events, or triggering the event + * handlers with GWT bindings was unsuccessful. Maybe, with more time + * and skill, it could be done with better success. JavaScript overlay + * types might work. This might also get rid of the JsniWorkaround + * class. + */ + /*-{ + element.addEventListener("pointerdown", this.@com.vaadin.client.widgets.JsniWorkaround::touchStartFunction); + element.addEventListener("pointermove", this.@com.vaadin.client.widgets.JsniWorkaround::touchMoveFunction); + element.addEventListener("pointerup", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction); + element.addEventListener("pointercancel", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction); + }-*/; + + /** + * Using pointerdown, pointermove, pointerup, and pointercancel for IE11 + * and Edge instead of touch* listeners (#18737) + * + * @param element + */ + public native void detachPointerEventListeners(Element element) + /* + * Detaching events with JSNI instead of the GWT event mechanism because + * GWT didn't provide enough details in events, or triggering the event + * handlers with GWT bindings was unsuccessful. Maybe, with more time + * and skill, it could be done with better success. JavaScript overlay + * types might work. This might also get rid of the JsniWorkaround + * class. + */ + /*-{ + element.removeEventListener("pointerdown", this.@com.vaadin.client.widgets.JsniWorkaround::touchStartFunction); + element.removeEventListener("pointermove", this.@com.vaadin.client.widgets.JsniWorkaround::touchMoveFunction); + element.removeEventListener("pointerup", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction); + element.removeEventListener("pointercancel", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction); + }-*/; + public void scrollToColumn(final int columnIndex, final ScrollDestination destination, final int padding) { assert columnIndex >= columnConfiguration.frozenColumns : "Can't scroll to a frozen column"; @@ -4197,6 +4271,11 @@ public class Escalator extends Widget frozenColumns += numberOfColumns; } + // Add to DOM + header.paintInsertColumns(index, numberOfColumns, frozen); + body.paintInsertColumns(index, numberOfColumns, frozen); + footer.paintInsertColumns(index, numberOfColumns, frozen); + // this needs to be before the scrollbar adjustment. boolean scrollbarWasNeeded = horizontalScrollbar .getOffsetSize() < horizontalScrollbar.getScrollSize(); @@ -4204,14 +4283,12 @@ public class Escalator extends Widget boolean scrollbarIsNowNeeded = horizontalScrollbar .getOffsetSize() < horizontalScrollbar.getScrollSize(); if (!scrollbarWasNeeded && scrollbarIsNowNeeded) { + // This might as a side effect move rows around (when scrolled + // all the way down) and require the DOM to be up to date, i.e. + // the column to be added body.verifyEscalatorCount(); } - // Add to DOM - header.paintInsertColumns(index, numberOfColumns, frozen); - body.paintInsertColumns(index, numberOfColumns, frozen); - footer.paintInsertColumns(index, numberOfColumns, frozen); - // fix initial width if (header.getRowCount() > 0 || body.getRowCount() > 0 || footer.getRowCount() > 0) { @@ -5741,7 +5818,13 @@ public class Escalator extends Widget scroller.attachScrollListener(verticalScrollbar.getElement()); scroller.attachScrollListener(horizontalScrollbar.getElement()); scroller.attachMousewheelListener(getElement()); - scroller.attachTouchListeners(getElement()); + + if (isCurrentBrowserIE11OrEdge()) { + // Touch listeners doesn't work for IE11 and Edge (#18737) + scroller.attachPointerEventListeners(getElement()); + } else { + scroller.attachTouchListeners(getElement()); + } } @Override @@ -5750,7 +5833,13 @@ public class Escalator extends Widget scroller.detachScrollListener(verticalScrollbar.getElement()); scroller.detachScrollListener(horizontalScrollbar.getElement()); scroller.detachMousewheelListener(getElement()); - scroller.detachTouchListeners(getElement()); + + if (isCurrentBrowserIE11OrEdge()) { + // Touch listeners doesn't work for IE11 and Edge (#18737) + scroller.detachPointerEventListeners(getElement()); + } else { + scroller.detachTouchListeners(getElement()); + } /* * We can call paintRemoveRows here, because static ranges are simple to @@ -6807,4 +6896,13 @@ public class Escalator extends Widget double getMinCellWidth(int colIndex) { return columnConfiguration.getMinCellWidth(colIndex); } + + /** + * Internal method for checking whether the browser is IE11 or Edge + * + * @return true only if the current browser is IE11, or Edge + */ + private static boolean isCurrentBrowserIE11OrEdge() { + return BrowserInfo.get().isIE11() || BrowserInfo.get().isEdge(); + } } 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 5e48188128..ea7901773d 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 @@ -81,6 +81,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.DeferredWorker; import com.vaadin.client.Focusable; import com.vaadin.client.WidgetUtil; +import com.vaadin.client.data.AbstractRemoteDataSource; import com.vaadin.client.data.DataChangeHandler; import com.vaadin.client.data.DataSource; import com.vaadin.client.data.DataSource.RowHandle; @@ -96,7 +97,9 @@ import com.vaadin.shared.Registration; import com.vaadin.shared.data.sort.SortDirection; import com.vaadin.shared.util.SharedUtil; import com.vaadin.v7.client.renderers.ComplexRenderer; +import com.vaadin.v7.client.renderers.ProgressBarRenderer; import com.vaadin.v7.client.renderers.Renderer; +import com.vaadin.v7.client.renderers.TextRenderer; import com.vaadin.v7.client.renderers.WidgetRenderer; import com.vaadin.v7.client.widget.escalator.Cell; import com.vaadin.v7.client.widget.escalator.ColumnConfiguration; @@ -128,6 +131,7 @@ import com.vaadin.v7.client.widget.grid.HeightAwareDetailsGenerator; import com.vaadin.v7.client.widget.grid.RendererCellReference; import com.vaadin.v7.client.widget.grid.RowReference; import com.vaadin.v7.client.widget.grid.RowStyleGenerator; +import com.vaadin.v7.client.widget.grid.datasources.ListDataSource; import com.vaadin.v7.client.widget.grid.events.AbstractGridKeyEventHandler; import com.vaadin.v7.client.widget.grid.events.AbstractGridMouseEventHandler; import com.vaadin.v7.client.widget.grid.events.BodyClickHandler; @@ -163,6 +167,7 @@ import com.vaadin.v7.client.widget.grid.events.ScrollHandler; import com.vaadin.v7.client.widget.grid.events.SelectAllEvent; import com.vaadin.v7.client.widget.grid.events.SelectAllHandler; import com.vaadin.v7.client.widget.grid.selection.HasSelectionHandlers; +import com.vaadin.v7.client.widget.grid.selection.HasUserSelectionAllowed; import com.vaadin.v7.client.widget.grid.selection.MultiSelectionRenderer; import com.vaadin.v7.client.widget.grid.selection.SelectionEvent; import com.vaadin.v7.client.widget.grid.selection.SelectionHandler; @@ -201,12 +206,10 @@ import com.vaadin.v7.shared.ui.grid.ScrollDestination; *

* Each column also has a Renderer. Its function is to take the value that is * given by the {@code GridColumn} and display it to the user. A simple column - * might have a {@link com.vaadin.v7.client.renderers.TextRenderer TextRenderer} - * that simply takes in a {@code String} and displays it as the cell's content. - * A more complex renderer might be - * {@link com.vaadin.v7.client.renderers.ProgressBarRenderer - * ProgressBarRenderer} that takes in a floating point number, and displays a - * progress bar instead, based on the given number. + * might have a {@link TextRenderer} that simply takes in a {@code String} and + * displays it as the cell's content. A more complex renderer might be + * {@link ProgressBarRenderer} that takes in a floating point number, and + * displays a progress bar instead, based on the given number. *

* See: {@link #addColumn(Column)}, {@link #addColumn(Column, int)} and * {@link #addColumns(Column...)}. Also @@ -216,10 +219,8 @@ import com.vaadin.v7.shared.ui.grid.ScrollDestination; *

* Grid gets its data from a {@link DataSource}, providing row objects to Grid * from a user-defined endpoint. It can be either a local in-memory data source - * (e.g. {@link com.vaadin.v7.client.widget.grid.datasources.ListDataSource - * ListDataSource}) or even a remote one, retrieving data from e.g. a REST API - * (see {@link com.vaadin.client.data.AbstractRemoteDataSource - * AbstractRemoteDataSource}). + * (e.g. {@link ListDataSource}) or even a remote one, retrieving data from e.g. + * a REST API (see {@link AbstractRemoteDataSource}). * * * @param @@ -445,14 +446,14 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, */ public abstract static class StaticRow { - private Map, CELLTYPE> cells = new HashMap<>(); + private Map, CELLTYPE> cells = new HashMap, CELLTYPE>(); private StaticSection section; /** * Map from set of spanned columns to cell meta data. */ - private Map>, CELLTYPE> cellGroups = new HashMap<>(); + private Map>, CELLTYPE> cellGroups = new HashMap>, CELLTYPE>(); /** * A custom style name for the row or null if none is set. @@ -500,7 +501,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, "You can't merge less than 2 columns together."); } - HashSet> columnGroup = new HashSet<>(); + HashSet> columnGroup = new HashSet>(); // NOTE: this doesn't care about hidden columns, those are // filtered in calculateColspans() for (Column column : columns) { @@ -594,7 +595,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private boolean checkMergedCellIsContinuous( Set> mergedCell) { // no matter if hidden or not, just check for continuous order - final List> columnOrder = new ArrayList<>( + final List> columnOrder = new ArrayList>( section.grid.getColumns()); if (!columnOrder.containsAll(mergedCell)) { @@ -664,7 +665,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, */ void detach() { // Avoid calling detach twice for a merged cell - HashSet cells = new HashSet<>(); + HashSet cells = new HashSet(); for (Column column : getSection().grid.getColumns()) { cells.add(getCell(column)); } @@ -676,7 +677,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private Grid grid; - private List rows = new ArrayList<>(); + private List rows = new ArrayList(); private boolean visible = true; @@ -1100,15 +1101,15 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private Grid grid; private final int rowIndex; - private final int columnIndex; + private final int columnIndexDOM; private RequestCallback callback; private boolean completed = false; - public EditorRequestImpl(Grid grid, int rowIndex, int columnIndex, + public EditorRequestImpl(Grid grid, int rowIndex, int columnIndexDOM, RequestCallback callback) { this.grid = grid; this.rowIndex = rowIndex; - this.columnIndex = columnIndex; + this.columnIndexDOM = columnIndexDOM; this.callback = callback; } @@ -1119,7 +1120,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, @Override public int getColumnIndex() { - return columnIndex; + return columnIndexDOM; } @Override @@ -1289,13 +1290,13 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } /** - * 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; } } @@ -1315,6 +1316,23 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private static final String ERROR_CLASS_NAME = "error"; private static final String NOT_EDITABLE_CLASS_NAME = "not-editable"; + ScheduledCommand fieldFocusCommand = new ScheduledCommand() { + private int count = 0; + + @Override + public void execute() { + Element focusedElement = WidgetUtil.getFocusedElement(); + if (focusedElement == grid.getElement() + || focusedElement == Document.get().getBody() + || count > 2) { + focusColumn(focusedColumnIndexDOM); + } else { + ++count; + Scheduler.get().scheduleDeferred(this); + } + } + }; + /** * A handler for events related to the Grid editor. Responsible for * opening, moving or closing the editor based on the received event. @@ -1360,13 +1378,13 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, // Should only be added to the DOM when there's a message to show private DivElement message = DivElement.as(DOM.createDiv()); - private Map, Widget> columnToWidget = new HashMap<>(); - private List focusHandlers = new ArrayList<>(); + private Map, Widget> columnToWidget = new HashMap, Widget>(); + private List focusHandlers = new ArrayList(); 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; @@ -1431,10 +1449,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, 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(); @@ -1456,7 +1474,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, }; /** A set of all the columns that display an error flag. */ - private final Set> columnErrors = new HashSet<>(); + private final Set> columnErrors = new HashSet>(); private boolean buffered = true; /** Original position of editor */ @@ -1543,9 +1561,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * * @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 @@ -1555,7 +1574,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * * @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"); @@ -1580,35 +1599,35 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, 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. @@ -1618,13 +1637,13 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, 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(); } } @@ -1652,8 +1671,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, throw new IllegalStateException( "Cannot cancel edit: editor is not in edit mode"); } - handler.cancel(new EditorRequestImpl<>(grid, rowIndex, - focusedColumnIndex, null)); + handler.cancel(new EditorRequestImpl(grid, rowIndex, + focusedColumnIndexDOM, null)); doCancel(); } @@ -1661,7 +1680,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, hideOverlay(); state = State.INACTIVE; rowIndex = -1; - focusedColumnIndex = -1; + focusedColumnIndexDOM = -1; grid.getEscalator().setScrollLocked(Direction.VERTICAL, false); updateSelectionCheckboxesAsNeeded(true); } @@ -1698,8 +1717,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, state = State.SAVING; setButtonsEnabled(false); saveTimeout.schedule(SAVE_TIMEOUT_MS); - EditorRequest request = new EditorRequestImpl<>(grid, rowIndex, - focusedColumnIndex, saveRequestCallback); + EditorRequest request = new EditorRequestImpl(grid, rowIndex, + focusedColumnIndexDOM, saveRequestCallback); handler.save(request); updateSelectionCheckboxesAsNeeded(true); } @@ -1762,7 +1781,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (state == State.ACTIVATING) { state = State.BINDING; bindTimeout.schedule(BIND_TIMEOUT_MS); - EditorRequest request = new EditorRequestImpl<>(grid, + EditorRequest request = new EditorRequestImpl(grid, rowIndex, columnIndex, bindRequestCallback); handler.bind(request); grid.getEscalator().setScrollLocked(Direction.VERTICAL, @@ -1871,8 +1890,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, grid.attachWidget(editor, cell); } - if (i == focusedColumnIndex) { - focusColumn(focusedColumnIndex); + if (i == focusedColumnIndexDOM) { + focusColumn(focusedColumnIndexDOM); } } else { cell.addClassName(NOT_EDITABLE_CLASS_NAME); @@ -1902,6 +1921,9 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, checkBox.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { + if (!grid.isUserSelectionAllowed()) { + return; + } T row = pinnedRowHandle.getRow(); if (grid.isSelected(row)) { grid.deselect(row); @@ -1975,13 +1997,14 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, 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) { @@ -2293,7 +2316,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, extends KeyEvent { private Grid grid; - private final Type associatedType = new Type<>( + private final Type associatedType = new Type( getBrowserEventType(), this); private final CellReference targetCell; @@ -2353,7 +2376,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private Grid grid; private final CellReference targetCell; - private final Type associatedType = new Type<>( + private final Type associatedType = new Type( getBrowserEventType(), this); public AbstractGridMouseEvent(Grid grid, @@ -2431,7 +2454,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, */ private static final double DETAILS_ROW_INITIAL_HEIGHT = 50; - private EventCellReference eventCell = new EventCellReference<>(this); + private EventCellReference eventCell = new EventCellReference(this); private GridKeyDownEvent keyDown = new GridKeyDownEvent(this, eventCell); private GridKeyUpEvent keyUp = new GridKeyUpEvent(this, eventCell); private GridKeyPressEvent keyPress = new GridKeyPressEvent(this, eventCell); @@ -2514,8 +2537,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, setStyleName(rowWithFocusStyle, rowFocusStyleName, true); } } else if (rowWithFocusStyle == row.getElement() - || (containerWithFocus != escalator.getBody() - && rowWithFocusStyle != null)) { + || containerWithFocus != escalator.getBody() + && rowWithFocusStyle != null) { // Remove focus style. setStyleName(rowWithFocusStyle, rowFocusStyleName, false); rowWithFocusStyle = null; @@ -2566,9 +2589,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, ++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); @@ -2812,9 +2833,9 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * a range of added rows */ public void rowsAddedToBody(Range added) { - boolean bodyHasFocus = (containerWithFocus == escalator.getBody()); - boolean insertionIsAboveFocusedCell = (added - .getStart() <= rowWithFocus); + boolean bodyHasFocus = containerWithFocus == escalator.getBody(); + boolean insertionIsAboveFocusedCell = added + .getStart() <= rowWithFocus; if (bodyHasFocus && insertionIsAboveFocusedCell) { rowWithFocus += added.length(); rowWithFocus = Math.min(rowWithFocus, @@ -2860,12 +2881,12 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } } - private final List> browserEventHandlers = new ArrayList<>(); + private final List> browserEventHandlers = new ArrayList>(); private CellStyleGenerator cellStyleGenerator; private RowStyleGenerator rowStyleGenerator; - private RowReference rowReference = new RowReference<>(this); - private CellReference cellReference = new CellReference<>(rowReference); + private RowReference rowReference = new RowReference(this); + private CellReference cellReference = new CellReference(rowReference); private RendererCellReference rendererCellReference = new RendererCellReference( (RowReference) rowReference); @@ -2875,6 +2896,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private boolean initDone = false; private boolean selected = false; private CheckBox selectAllCheckBox; + private boolean userSelectionAllowed = true; + private boolean enabled = true; SelectionColumn(final Renderer selectColumnRenderer) { super(selectColumnRenderer); @@ -2905,6 +2928,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (selectAllCheckBox == null) { selectAllCheckBox = GWT.create(CheckBox.class); + selectAllCheckBox.setEnabled(enabled && userSelectionAllowed); selectAllCheckBox.setStylePrimaryName( getStylePrimaryName() + SELECT_ALL_CHECKBOX_CLASSNAME); selectAllCheckBox.addValueChangeHandler( @@ -2913,8 +2937,11 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, @Override public void onValueChange( ValueChangeEvent event) { + if (!isUserSelectionAllowed()) { + return; + } if (event.getValue()) { - fireEvent(new SelectAllEvent<>(model)); + fireEvent(new SelectAllEvent(model)); selected = true; } else { model.deselectAll(); @@ -2927,6 +2954,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, addHeaderClickHandler(new HeaderClickHandler() { @Override public void onClick(GridClickEvent event) { + if (!userSelectionAllowed) { + return; + } + CellReference targetCell = event.getTargetCell(); int defaultRowIndex = getHeader().getRows() .indexOf(getDefaultHeaderRow()); @@ -2946,6 +2977,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE) { return; } + if (!isUserSelectionAllowed()) { + return; + } + HeaderRow targetHeaderRow = getHeader() .getRow(event.getFocusedCell().getRowIndex()); if (!targetHeaderRow.isDefault()) { @@ -3041,8 +3076,9 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * to disable it. */ public void setEnabled(boolean enabled) { + this.enabled = enabled; if (selectAllCheckBox != null) { - selectAllCheckBox.setEnabled(enabled); + selectAllCheckBox.setEnabled(enabled && userSelectionAllowed); } } @@ -3050,6 +3086,27 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, public void onEnabled(boolean enabled) { setEnabled(enabled); } + + /** + * Sets whether the user is allowed to change the selection. + * + * @param userSelectionAllowed + * true if the user is allowed to change the + * selection, false otherwise + * @since 7.7.7 + */ + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + if (userSelectionAllowed == this.userSelectionAllowed) { + return; + } + + this.userSelectionAllowed = userSelectionAllowed; + // Update checkbox state + setEnabled(enabled); + // Re-render select checkboxes + getEscalator().getBody().refreshRows(0, + getEscalator().getBody().getRowCount()); + } } /** @@ -3201,6 +3258,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } } else if (currentDataAvailable.isEmpty() && dataSource.isWaitingForData()) { + // No data available yet but something is incoming soon Scheduler.get().scheduleDeferred(this); } else { calculate(); @@ -3235,7 +3293,6 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private void calculate() { isScheduled = false; rescheduleCount = 0; - assert !(currentDataAvailable.isEmpty() && dataSource .isWaitingForData()) : "Trying to calculate column widths without data while data is still being fetched."; @@ -3266,7 +3323,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, /* Step 1: Apply all column widths as they are. */ - Map selfWidths = new LinkedHashMap<>(); + Map selfWidths = new LinkedHashMap(); List> columns = getVisibleColumns(); for (int index = 0; index < columns.size(); index++) { selfWidths.put(index, columns.get(index).getWidth()); @@ -3280,7 +3337,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * violated, fix it. */ - Map constrainedWidths = new LinkedHashMap<>(); + Map constrainedWidths = new LinkedHashMap(); for (int index = 0; index < columns.size(); index++) { Column column = columns.get(index); @@ -3305,9 +3362,9 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, boolean defaultExpandRatios = true; int totalRatios = 0; double reservedPixels = 0; - final Set> columnsToExpand = new HashSet<>(); - List> nonFixedColumns = new ArrayList<>(); - Map columnSizes = new HashMap<>(); + final Set> columnsToExpand = new HashSet>(); + List> nonFixedColumns = new ArrayList>(); + Map columnSizes = new HashMap(); final List> visibleColumns = getVisibleColumns(); /* @@ -3340,8 +3397,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, setColumnSizes(columnSizes); for (Column column : nonFixedColumns) { - final int expandRatio = (defaultExpandRatios ? 1 - : column.getExpandRatio()); + final int expandRatio = defaultExpandRatios ? 1 + : column.getExpandRatio(); final double maxWidth = getMaxWidth(column); final double newWidth = Math.min(maxWidth, column.getWidthActual()); @@ -3473,8 +3530,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, boolean hasAutoWidth = column.getWidth() < 0; if (hasAutoWidth && currentWidth < minWidth) { columnSizes.put(columnIndex, minWidth); - pixelsToRemoveFromOtherColumns += (minWidth - - currentWidth); + pixelsToRemoveFromOtherColumns += minWidth + - currentWidth; minWidthsCausedReflows = true; /* @@ -3570,7 +3627,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private static final String STRIPE_CLASSNAME = "stripe"; - private final Map elementToWidgetMap = new HashMap<>(); + private final Map elementToWidgetMap = new HashMap(); @Override public void init(Spacer spacer) { @@ -3893,7 +3950,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, .getFirstChildElement(); double height = WidgetUtil .getRequiredHeightBoundingClientRectDouble(firstHeaderCell) - - (WidgetUtil.measureVerticalBorder(getElement()) / 2); + - WidgetUtil.measureVerticalBorder(getElement()) / 2; openCloseButton.setHeight(height + "px"); } @@ -3952,7 +4009,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private final class ColumnHider { /** Map from columns to their hiding toggles, component might change */ - private HashMap, MenuItem> columnToHidingToggleMap = new HashMap<>(); + private HashMap, MenuItem> columnToHidingToggleMap = new HashMap, MenuItem>(); /** * When column is being hidden with a toggle, do not refresh toggles for @@ -3969,7 +4026,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, toggle.setStyleName("hidden", column.isHidden()); } else if (columnToHidingToggleMap.containsKey(column)) { sidebar.menuBar - .removeItem((columnToHidingToggleMap.remove(column))); + .removeItem(columnToHidingToggleMap.remove(column)); } updateTogglesOrder(); } @@ -4051,7 +4108,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, /** * List of columns in the grid. Order defines the visible order. */ - private List> columns = new ArrayList<>(); + private List> columns = new ArrayList>(); /** * The datasource currently in use. Note: it is null @@ -4075,7 +4132,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * Current sort order. The (private) sort() method reads this list to * determine the order in which to present rows. */ - private List sortOrder = new ArrayList<>(); + private List sortOrder = new ArrayList(); private Renderer selectColumnRenderer = null; @@ -4127,9 +4184,9 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, private DetailsGenerator detailsGenerator = DetailsGenerator.NULL; private GridSpacerUpdater gridSpacerUpdater = new GridSpacerUpdater(); /** A set keeping track of the indices of all currently open details */ - private Set visibleDetails = new HashSet<>(); + private Set visibleDetails = new HashSet(); /** A set of indices of details to reopen after detach and on attach */ - private final Set reattachVisibleDetails = new HashSet<>(); + private final Set reattachVisibleDetails = new HashSet(); private boolean columnReorderingAllowed; @@ -4181,7 +4238,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * Map of possible drop positions for the column and the corresponding * column index. */ - private final TreeMap possibleDropPositions = new TreeMap<>(); + private final TreeMap possibleDropPositions = new TreeMap(); /** * Makes sure that drag cancel doesn't cause anything unwanted like sort */ @@ -4377,10 +4434,9 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, final int colspan = header.getRow(eventCell.getRowIndex()) .getCell(eventCell.getColumn()).getColspan(); if (latestColumnDropIndex != draggedColumnIndex - && latestColumnDropIndex != (draggedColumnIndex - + colspan)) { + && latestColumnDropIndex != draggedColumnIndex + colspan) { List> columns = getColumns(); - List> reordered = new ArrayList<>(); + List> reordered = new ArrayList>(); if (draggedColumnIndex < latestColumnDropIndex) { reordered.addAll(columns.subList(0, draggedColumnIndex)); reordered.addAll( @@ -4399,12 +4455,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, reordered.addAll(columns.subList( draggedColumnIndex + colspan, columns.size())); } - reordered.remove(selectionColumn); // since - // setColumnOrder - // will - // add - // it - // anyway! + reordered.remove(selectionColumn); // since setColumnOrder will + // add it anyway! // capture focused cell column before reorder Cell focusedCell = cellFocusHandler.getFocusedCell(); @@ -4418,9 +4470,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, .toArray(new Column[reordered.size()]); setColumnOrder(array); transferCellFocusOnDrop(); - } // else - // no - // reordering + } // else no reordering } private void transferCellFocusOnDrop() { @@ -4514,8 +4564,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, int leftBound = -1; int rightBound = getColumnCount() + 1; - final HashSet unavailableColumnDropIndices = new HashSet<>(); - final List> rows = new ArrayList<>(); + final HashSet unavailableColumnDropIndices = new HashSet(); + final List> rows = new ArrayList>(); rows.addAll(header.getRows()); rows.addAll(footer.getRows()); for (StaticRow row : rows) { @@ -4573,7 +4623,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } } - if (leftBound == (rightBound - 1)) { + if (leftBound == rightBound - 1) { return; } @@ -5101,7 +5151,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, grid.header.updateColSpans(); grid.footer.updateColSpans(); scheduleColumnWidthRecalculator(); - this.grid.fireEvent(new ColumnVisibilityChangeEvent<>(this, + this.grid.fireEvent(new ColumnVisibilityChangeEvent(this, hidden, userOriginated)); } } @@ -5495,7 +5545,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, setStyleName(rowElement, rowHasDataStyleName, hasData); } - boolean isEvenIndex = (row.getRow() % 2 == 0); + boolean isEvenIndex = row.getRow() % 2 == 0; setStyleName(rowElement, rowStripeStyleName, !isEvenIndex); rowReference.set(rowIndex, rowData, rowElement); @@ -5766,7 +5816,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (c.getWidth() < 0) { c.setWidth(c.getWidthActual()); - fireEvent(new ColumnResizeEvent<>(c)); + fireEvent(new ColumnResizeEvent(c)); } } @@ -5821,7 +5871,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, dragEnded(); col.setWidth(width); - fireEvent(new ColumnResizeEvent<>(col)); + fireEvent(new ColumnResizeEvent(col)); } }; @@ -5848,7 +5898,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, public void onComplete() { dragEnded(); col.setWidth(width); - fireEvent(new ColumnResizeEvent<>(col)); + fireEvent(new ColumnResizeEvent(col)); } }; @@ -5958,7 +6008,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, escalator.getColumnConfiguration().setColumnWidth(colIndex, minWidth); - fireEvent(new ColumnResizeEvent<>(column)); + fireEvent(new ColumnResizeEvent(column)); } } @@ -6128,7 +6178,6 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, new RendererEventHandler(), // Moving cell focus by keyboard or mouse new CellFocusEventHandler())); - } @Override @@ -6136,29 +6185,6 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, return enabled; } - /** - * Sets the column resize mode to use. The default mode is - * {@link ColumnResizeMode.ANIMATED}. - * - * @param mode - * a ColumnResizeMode value - * @since 7.7.5 - */ - public void setColumnResizeMode(ColumnResizeMode mode) { - columnResizeMode = mode; - } - - /** - * Returns the current column resize mode. The default mode is - * {@link ColumnResizeMode.ANIMATED}. - * - * @return a ColumnResizeMode value - * @since 7.7.5 - */ - public ColumnResizeMode getColumnResizeMode() { - return columnResizeMode; - } - @Override public void setEnabled(boolean enabled) { if (enabled == this.enabled) { @@ -6206,6 +6232,29 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } } + /** + * Sets the column resize mode to use. The default mode is + * {@link ColumnResizeMode.ANIMATED}. + * + * @param mode + * a ColumnResizeMode value + * @since 7.7.5 + */ + public void setColumnResizeMode(ColumnResizeMode mode) { + columnResizeMode = mode; + } + + /** + * Returns the current column resize mode. The default mode is + * {@link ColumnResizeMode.ANIMATED}. + * + * @return a ColumnResizeMode value + * @since 7.7.5 + */ + public ColumnResizeMode getColumnResizeMode() { + return columnResizeMode; + } + /** * 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 @@ -6279,21 +6328,22 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * * @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()); } @@ -6398,7 +6448,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, column.reapplyWidth(); // Sink all renderer events - Set events = new HashSet<>(); + Set events = new HashSet(); events.addAll(getConsumedEventsForRenderer(column.getRenderer())); if (column.isHidable()) { @@ -6496,7 +6546,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * @return A unmodifiable list of the columns in the grid */ public List> getColumns() { - return Collections.unmodifiableList(new ArrayList<>(columns)); + return Collections + .unmodifiableList(new ArrayList>(columns)); } /** @@ -6508,7 +6559,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * @return A unmodifiable list of the currently visible columns in the grid */ public List> getVisibleColumns() { - ArrayList> visible = new ArrayList<>(); + ArrayList> visible = new ArrayList>(); for (Column c : columns) { if (!c.isHidden()) { visible.add(c); @@ -6535,13 +6586,13 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, return columns.get(index); } - private Column getVisibleColumn(int index) + private Column getVisibleColumn(int columnIndexDOM) throws IllegalArgumentException { List> visibleColumns = getVisibleColumns(); - if (index < 0 || index >= visibleColumns.size()) { + if (columnIndexDOM < 0 || columnIndexDOM >= visibleColumns.size()) { throw new IllegalStateException("Column not found."); } - return visibleColumns.get(index); + return visibleColumns.get(columnIndexDOM); } /** @@ -6928,7 +6979,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, int oldSize = body.getRowCount(); // Hide all details. - Set oldDetails = new HashSet<>(visibleDetails); + Set oldDetails = new HashSet( + visibleDetails); for (int i : oldDetails) { setDetailsVisible(i, false); } @@ -7300,7 +7352,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } private Set getConsumedEventsForRenderer(Renderer renderer) { - Set events = new HashSet<>(); + Set events = new HashSet(); if (renderer instanceof ComplexRenderer) { Collection consumedEvents = ((ComplexRenderer) renderer) .getConsumedEvents(); @@ -7386,7 +7438,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, + "-event with a null cell target"; eventCell.set(cell, getSectionFromContainer(container)); - GridEvent gridEvent = new GridEvent<>(event, eventCell); + GridEvent gridEvent = new GridEvent(event, eventCell); for (GridEventHandler handler : browserEventHandlers) { handler.onEvent(gridEvent); } @@ -7450,13 +7502,14 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, } Widget widget; - if (editor.focusedColumnIndex < 0) { + if (editor.focusedColumnIndexDOM < 0) { widget = null; } else { - widget = editor.getWidget(getColumn(editor.focusedColumnIndex)); + widget = editor.getWidget( + getVisibleColumn(editor.focusedColumnIndexDOM)); } - EditorDomEvent editorEvent = new EditorDomEvent<>( + EditorDomEvent editorEvent = new EditorDomEvent( event.getDomEvent(), event.getCell(), widget); event.setHandled( @@ -7559,8 +7612,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (!event.getCell().isHeader()) { return; } - if (event.getCell().getColumnIndex() < escalator - .getColumnConfiguration().getFrozenColumnCount()) { + if (event.getCell().getColumnIndex() < getFrozenColumnCount()) { return; } @@ -7939,8 +7991,6 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, /** * Deselect all rows using the current selection model. * - * @param row - * a row object * @return true iff the current selection changed * @throws IllegalStateException * if the current selection model is not an instance of @@ -7948,7 +7998,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, */ public boolean deselectAll() { if (selectionModel instanceof SelectionModel.Single) { - Single single = ((SelectionModel.Single) selectionModel); + Single single = (SelectionModel.Single) selectionModel; if (single.getSelectedRow() != null) { return single.deselect(single.getSelectedRow()); } else { @@ -8418,8 +8468,8 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, */ private void sort(boolean userOriginated) { refreshHeader(); - fireEvent(new SortEvent<>(this, Collections.unmodifiableList(sortOrder), - userOriginated)); + fireEvent(new SortEvent(this, + Collections.unmodifiableList(sortOrder), userOriginated)); } private int getLastVisibleRowIndex() { @@ -8500,7 +8550,7 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, // Trigger ComplexRenderer.destroy for old content conf.removeColumns(0, conf.getColumnCount()); - List> newOrder = new ArrayList<>(); + List> newOrder = new ArrayList>(); if (selectionColumn != null) { newOrder.add(selectionColumn); } @@ -8774,11 +8824,15 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, // 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 details = new HashSet<>(visibleDetails); + Set details = new HashSet(visibleDetails); reattachVisibleDetails.clear(); reattachVisibleDetails.addAll(details); for (int row : details) { @@ -9190,11 +9244,28 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, if (container != null) { Cell cell = container.getCell(element); if (cell != null) { - EventCellReference cellRef = new EventCellReference<>(this); + EventCellReference cellRef = new EventCellReference(this); cellRef.set(cell, getSectionFromContainer(container)); return cellRef; } } return null; } + + /** + * Checks if selection by the user is allowed in the grid. + * + * @return true if selection by the user is allowed by the + * selection model (the default), false otherwise + * @since 7.7.7 + */ + public boolean isUserSelectionAllowed() { + if (!(getSelectionModel() instanceof HasUserSelectionAllowed)) { + // Selection model does not support toggling user selection allowed + // - old default is to always allow selection + return true; + } + return ((HasUserSelectionAllowed) getSelectionModel()) + .isUserSelectionAllowed(); + } } diff --git a/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java b/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java index 6cc933e670..5b25a48ba9 100644 --- a/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java +++ b/compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java @@ -344,7 +344,13 @@ public class GAEVaadinServlet extends VaadinServlet { VaadinSession vaadinSession = (VaadinSession) ois.readObject(); getService().storeSession(vaadinSession, new WrappedHttpSession(session)); - } catch (IOException | ClassNotFoundException e) { + } catch (IOException e) { + getLogger().log(Level.WARNING, + "Could not de-serialize ApplicationContext for " + + session.getId() + + " A new one will be created. ", + e); + } catch (ClassNotFoundException e) { getLogger().log(Level.WARNING, "Could not de-serialize ApplicationContext for " + session.getId() diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java index 2bd55555b3..438376923e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java @@ -180,6 +180,7 @@ public interface Buffered extends Serializable { return source; } + // Intentional change in compatibility package @Override public ErrorMessage getErrorMessage() { // no message, only the causes to be painted diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java index 200ed93779..9167dd2c67 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java @@ -167,6 +167,7 @@ public interface Validator extends Serializable { return causes; } + // Intentional change in compatibility package @Override public ErrorMessage getErrorMessage() { UserError error = new UserError(getHtmlMessage(), ContentMode.HTML, diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java index 0fd03c21ad..3a2d5cd526 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java @@ -160,7 +160,7 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { * @since 7.4 * @param fieldType * the type of the field - * @return true if any LegacyAbstractField can be assigned to the field + * @return true if any AbstractField can be assigned to the field */ protected boolean anyField(Class fieldType) { return fieldType == Field.class || fieldType == AbstractField.class; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java index a56703090f..40802512cb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java @@ -39,8 +39,10 @@ import com.vaadin.v7.ui.Field; * FieldGroup provides an easy way of binding fields to data and handling * commits of these fields. *

- * The typical use case is to create a layout outside the FieldGroup and then - * use FieldGroup to bind the fields to a data source. + * The functionality of FieldGroup is similar to {@link Form} but + * {@link FieldGroup} does not handle layouts in any way. The typical use case + * is to create a layout outside the FieldGroup and then use FieldGroup to bind + * the fields to a data source. *

*

* {@link FieldGroup} is not a UI component so it cannot be added to a layout. @@ -991,7 +993,7 @@ public class FieldGroup implements Serializable { .createCaptionByPropertyId(propertyId); } - // Create the component (LegacyField) + // Create the component (Field) field = build(caption, propertyType, fieldType); // Store it in the field @@ -1217,7 +1219,7 @@ public class FieldGroup implements Serializable { *

* The data type is the type that we want to edit using the field. The field * type is the type of field we want to create, can be {@link Field} if any - * LegacyField is good. + * Field is good. *

* * @param caption @@ -1226,7 +1228,7 @@ public class FieldGroup implements Serializable { * The data model type that we want to edit using the field * @param fieldType * The type of field that we want to create - * @return A LegacyField capable of editing the given type + * @return A Field capable of editing the given type * @throws BindException * If the field could not be created */ @@ -1244,9 +1246,9 @@ public class FieldGroup implements Serializable { } /** - * Returns an array containing LegacyField objects reflecting all the fields - * of the class or interface represented by this Class object. The elements - * in the array returned are sorted in declare order from sub class to super + * Returns an array containing Field objects reflecting all the fields of + * the class or interface represented by this Class object. The elements in + * the array returned are sorted in declare order from sub class to super * class. * * @param searchClass diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java index cf9c4d8fcc..4a62a19aaa 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java @@ -20,8 +20,8 @@ import java.io.Serializable; import com.vaadin.v7.ui.Field; /** - * Factory interface for creating new LegacyField-instances based on the data - * type that should be edited. + * Factory interface for creating new Field-instances based on the data type + * that should be edited. * * @author Vaadin Ltd. * @since 7.0 diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java index 70ce642456..1ec6bad129 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java @@ -174,11 +174,6 @@ public abstract class AbstractBeanContainer model = BeanItem.getPropertyDescriptors((Class) type); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getType(java.lang.Object) - */ @Override public Class getType(Object propertyId) { VaadinPropertyDescriptor descriptor = model.get(propertyId); @@ -211,21 +206,11 @@ public abstract class AbstractBeanContainer return type; } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getContainerPropertyIds() - */ @Override public Collection getContainerPropertyIds() { return model.keySet(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#removeAllItems() - */ @Override public boolean removeAllItems() { int origSize = size(); @@ -248,11 +233,6 @@ public abstract class AbstractBeanContainer return true; } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getItem(java.lang.Object) - */ @Override public BeanItem getItem(Object itemId) { // TODO return only if visible? @@ -264,23 +244,12 @@ public abstract class AbstractBeanContainer return itemIdToItem.get(itemId); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getItemIds() - */ @Override @SuppressWarnings("unchecked") public List getItemIds() { return (List) super.getItemIds(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#getContainerProperty(java.lang.Object, - * java.lang.Object) - */ @Override public Property getContainerProperty(Object itemId, Object propertyId) { Item item = getItem(itemId); @@ -290,11 +259,6 @@ public abstract class AbstractBeanContainer return item.getItemProperty(propertyId); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container#removeItem(java.lang.Object) - */ @Override public boolean removeItem(Object itemId) { // TODO should also remove items that are filtered out @@ -330,13 +294,6 @@ public abstract class AbstractBeanContainer filterAll(); } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Container.Filterable#addContainerFilter(java.lang.Object, - * java.lang.String, boolean, boolean) - */ @Override public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) { @@ -349,11 +306,6 @@ public abstract class AbstractBeanContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Filterable#removeAllContainerFilters() - */ @Override public void removeAllContainerFilters() { if (!getFilters().isEmpty()) { @@ -364,13 +316,6 @@ public abstract class AbstractBeanContainer } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Container.Filterable#removeContainerFilters(java.lang - * .Object) - */ @Override public void removeContainerFilters(Object propertyId) { Collection removedFilters = super.removeFilters(propertyId); @@ -393,21 +338,11 @@ public abstract class AbstractBeanContainer removeFilter(filter); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.AbstractInMemoryContainer#hasContainerFilters() - */ @Override public boolean hasContainerFilters() { return super.hasContainerFilters(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters() - */ @Override public Collection getContainerFilters() { return super.getContainerFilters(); @@ -461,22 +396,11 @@ public abstract class AbstractBeanContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds() - */ @Override public Collection getSortableContainerPropertyIds() { return getSortablePropertyIds(); } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[], - * boolean[]) - */ @Override public void sort(Object[] propertyId, boolean[] ascending) { sortContainer(propertyId, ascending); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java index 2f7346d2db..ea7b1ca570 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java @@ -595,11 +595,6 @@ public abstract class AbstractInMemoryContainer getContainerFilters() { return Collections.unmodifiableCollection(filters); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java index 86d6b85bc8..9c084f4bbb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java @@ -70,6 +70,8 @@ public abstract class AbstractProperty implements Property, } } + // LegacyPropertyHelper has been removed in Vaadin 8 + /* Events */ /** diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java index 28213d77dc..3a175ac9ee 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java @@ -253,7 +253,7 @@ public class BeanItem extends PropertysetItem { */ public void addNestedProperty(String nestedPropertyId) { addItemProperty(nestedPropertyId, - new NestedMethodProperty(getBean(), nestedPropertyId)); + new NestedMethodProperty(getBean(), nestedPropertyId)); } /** @@ -278,6 +278,7 @@ public class BeanItem extends PropertysetItem { * * @param bean * The new bean to use for this item, not null + * @since 7.7.7 */ public void setBean(BT bean) { if (bean == null) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java index e0b95bfe14..8e33aee66e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java @@ -402,11 +402,6 @@ public class HierarchicalContainer extends IndexedContainer } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#addItem() - */ @Override public Object addItem() { disableContentsChangeEvents(); @@ -463,11 +458,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#addItem(java.lang.Object) - */ @Override public Item addItem(Object itemId) { disableContentsChangeEvents(); @@ -490,11 +480,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#removeAllItems() - */ @Override public boolean removeAllItems() { disableContentsChangeEvents(); @@ -522,11 +507,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#removeItem(java.lang.Object ) - */ @Override public boolean removeItem(Object itemId) { disableContentsChangeEvents(); @@ -647,11 +627,6 @@ public class HierarchicalContainer extends IndexedContainer } - /* - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#doSort() - */ @Override protected void doSort() { super.doSort(); @@ -693,13 +668,6 @@ public class HierarchicalContainer extends IndexedContainer } } - /* - * Overridden to provide filtering for root & children items. - * - * (non-Javadoc) - * - * @see com.vaadin.data.util.IndexedContainer#updateContainerFiltering() - */ @Override protected boolean doFilterContainer(boolean hasFilters) { if (!hasFilters) { @@ -839,12 +807,6 @@ public class HierarchicalContainer extends IndexedContainer private Set filterOverride = null; - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.util.IndexedContainer#passesFilters(java.lang.Object) - */ @Override protected boolean passesFilters(Object itemId) { if (filterOverride != null) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java index 1e755f1a54..3fada79577 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java @@ -869,6 +869,8 @@ public class IndexedContainer firePropertyValueChange(this); } + // LegacyPropertyHelper has been removed in Vaadin 8 + /** * Calculates a integer hash-code for the Property that's unique inside * the Item containing the Property. Two different Properties inside the @@ -982,13 +984,13 @@ public class IndexedContainer ? (ListSet) ((ListSet) getAllItemIds()).clone() : null); nc.setItemSetChangeListeners(getItemSetChangeListeners() != null - ? new LinkedList( + ? new LinkedList( getItemSetChangeListeners()) : null); nc.propertyIds = propertyIds != null ? (ArrayList) propertyIds.clone() : null; nc.setPropertySetChangeListeners(getPropertySetChangeListeners() != null - ? new LinkedList( + ? new LinkedList( getPropertySetChangeListeners()) : null); nc.propertyValueChangeListeners = propertyValueChangeListeners != null diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java index e3651d0272..87d56bb4c9 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java @@ -773,6 +773,7 @@ public class MethodProperty extends AbstractProperty { * The instance used by this property * * @return the instance used for fetching the property value + * @since 7.7.7 */ public Object getInstance() { return instance; @@ -788,6 +789,7 @@ public class MethodProperty extends AbstractProperty { * * @param instance * the instance to use + * @since 7.7.7 */ public void setInstance(Object instance) { if (this.instance.getClass() != instance.getClass()) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java index de1561034c..3657a70266 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java @@ -272,6 +272,7 @@ public class NestedMethodProperty extends AbstractProperty { * The instance used by this property * * @return the instance used for fetching the property value + * @since 7.7.7 */ public Object getInstance() { return instance; @@ -287,6 +288,7 @@ public class NestedMethodProperty extends AbstractProperty { * * @param instance * the instance to use + * @since 7.7.7 */ public void setInstance(Object instance) { if (this.instance.getClass() != instance.getClass()) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java index a0cfae040c..cd41d887ed 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java @@ -50,7 +50,7 @@ public class NestedPropertyDescriptor public NestedPropertyDescriptor(String name, Class beanType) throws IllegalArgumentException { this.name = name; - NestedMethodProperty property = new NestedMethodProperty( + NestedMethodProperty property = new NestedMethodProperty( beanType, name); this.propertyType = property.getType(); } @@ -67,7 +67,7 @@ public class NestedPropertyDescriptor @Override public Property createProperty(BT bean) { - return new NestedMethodProperty(bean, name); + return new NestedMethodProperty(bean, name); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java index 05a2b55ea7..b60b0ed98b 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java @@ -205,7 +205,7 @@ public class PropertysetItem public void addPropertySetChangeListener( Item.PropertySetChangeListener listener) { if (propertySetChangeListeners == null) { - propertySetChangeListeners = new LinkedList(); + propertySetChangeListeners = new LinkedList(); } propertySetChangeListeners.add(listener); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java index a93489a0b4..9d1580af9e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java @@ -52,6 +52,7 @@ public class ConverterUtil implements Serializable { } if (session != null) { + // Intentional change in compatibility package ConverterFactory factory = (ConverterFactory) session .getConverterFactory(); if (factory == null) { diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java index 3440179e6a..4013915aa7 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java @@ -254,6 +254,8 @@ final public class ColumnProperty implements Property { return propertyId; } + // LegacyPropertyHelper has been removed in Vaadin 8 + private static Logger getLogger() { return Logger.getLogger(ColumnProperty.class.getName()); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java index f18940da8b..38542272ee 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java @@ -1419,7 +1419,7 @@ public class SQLContainer implements Container, Container.Filterable, public void addItemSetChangeListener( Container.ItemSetChangeListener listener) { if (itemSetChangeListeners == null) { - itemSetChangeListeners = new LinkedList(); + itemSetChangeListeners = new LinkedList(); } itemSetChangeListeners.add(listener); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java index 7354a9aa06..ef8dde86f4 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java @@ -28,8 +28,8 @@ import com.vaadin.v7.data.util.converter.StringToDoubleConverter; * field instead or bind the field to a {@link Property} of type * {@link Double}. */ -@SuppressWarnings("serial") @Deprecated +@SuppressWarnings("serial") public class DoubleValidator extends AbstractStringValidator { /** diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java index 59e078e378..3f2b1d5c1f 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java @@ -55,16 +55,15 @@ import com.vaadin.v7.shared.AbstractFieldState; *

* Abstract field component for implementing buffered property editors. The * field may hold an internal value, or it may be connected to any data source - * that implements the {@link Property}interface. - * LegacyAbstractField implements that interface itself, too, so - * accessing the Property value represented by it is straightforward. + * that implements the {@link Property} interface. AbstractField + * implements that interface itself, too, so accessing the Property value + * represented by it is straightforward. *

* *

- * LegacyAbstractField also provides the {@link Buffered} interface for - * buffering the data source value. By default the LegacyField is in write - * through-mode and {@link #setWriteThrough(boolean)}should be called to enable - * buffering. + * AbstractField also provides the {@link Buffered} interface for buffering the + * data source value. By default the Field is in write through-mode and + * {@link #setWriteThrough(boolean)}should be called to enable buffering. *

* *

@@ -193,13 +192,13 @@ public abstract class AbstractField extends AbstractLegacyComponent } /** - * Returns the type of the LegacyField. The methods getValue - * and setValue must be compatible with this type: one must be - * able to safely cast the value returned from getValue to the - * given type and pass any variable assignable to this type as an argument - * to setValue. + * Returns the type of the Field. The methods getValue and + * setValue must be compatible with this type: one must be able + * to safely cast the value returned from getValue to the given + * type and pass any variable assignable to this type as an argument to + * setValue. * - * @return the type of the LegacyField + * @return the type of the Field */ @Override public abstract Class getType(); @@ -348,7 +347,7 @@ public abstract class AbstractField extends AbstractLegacyComponent } /** - * Sets the buffered mode of this LegacyField. + * Sets the buffered mode of this Field. *

* When the field is in buffered mode, changes will not be committed to the * property data source until {@link #commit()} is called. @@ -376,7 +375,7 @@ public abstract class AbstractField extends AbstractLegacyComponent } /** - * Checks the buffered mode of this LegacyField. + * Checks the buffered mode of this Field. * * @return true if buffered mode is on, false otherwise */ @@ -385,6 +384,8 @@ public abstract class AbstractField extends AbstractLegacyComponent return buffered; } + // LegacyPropertyHelper has been removed in Vaadin 8 + /* Property interface implementation */ /** @@ -913,7 +914,7 @@ public abstract class AbstractField extends AbstractLegacyComponent } /** - * Checks the validity of the LegacyField. + * Checks the validity of the Field. * * A field is invalid if it is set as required (using * {@link #setRequired(boolean)} and is empty, if one or several of the @@ -1079,7 +1080,7 @@ public abstract class AbstractField extends AbstractLegacyComponent } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException( - "Internal error finding methods in LegacyAbstractField"); + "Internal error finding methods in AbstractField"); } } @@ -1152,7 +1153,7 @@ public abstract class AbstractField extends AbstractLegacyComponent } catch (final java.lang.NoSuchMethodException e) { // This should never happen throw new java.lang.RuntimeException( - "Internal error finding methods in LegacyAbstractField"); + "Internal error finding methods in AbstractField"); } } @@ -1348,10 +1349,10 @@ public abstract class AbstractField extends AbstractLegacyComponent } /** - * Sets the internal field value. This is purely used by LegacyAbstractField - * to change the internal LegacyField value. It does not trigger valuechange - * events. It can be overridden by the inheriting classes to update all - * dependent variables. + * Sets the internal field value. This is purely used by AbstractField to + * change the internal Field value. It does not trigger valuechange events. + * It can be overridden by the inheriting classes to update all dependent + * variables. * * Subclasses can also override {@link #getInternalValue()} if necessary. * diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java index 482dd0b2af..5fa82535bc 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java @@ -460,8 +460,8 @@ public abstract class AbstractTextField extends AbstractField implements * Make sure w reset lastKnownTextContent field on value change. The * clearing must happen here as well because TextChangeListener can * revert the original value. Client must respect the value in this - * case. LegacyAbstractField optimizes value change if the existing - * value is reset. Also we need to force repaint if the flag is on. + * case. AbstractField optimizes value change if the existing value is + * reset. Also we need to force repaint if the flag is on. */ if (lastKnownTextContent != null) { lastKnownTextContent = null; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java index 6e5c1df7f8..259de0d0ad 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java @@ -942,16 +942,13 @@ public class Calendar extends AbstractLegacyComponent } /** - *

* This method restricts the hours that are shown per day. This affects the * weekly view. The general contract is that firstHour < lastHour. - *

- * *

* Note that this only affects the rendering process. Events are still * requested by the dates set by {@link #setStartDate(Date)} and * {@link #setEndDate(Date)}. - *

+ *

* You can use {@link #autoScaleVisibleHoursOfDay()} for automatic scaling * of the visible hours based on current events. * diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java index 9aabd6293e..7366266787 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java @@ -129,9 +129,9 @@ public class CheckBox extends AbstractField { } /* - * Overridden to keep the shared state in sync with the LegacyAbstractField - * internal value. Should be removed once LegacyAbstractField is refactored - * to use shared state. + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. * * See tickets #10921 and #11064. */ diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java index 33ca986fa1..05b6f950ca 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java @@ -56,8 +56,8 @@ import com.vaadin.v7.shared.ui.datefield.TextualDateFieldState; * compatible with java.util.Date. *

*

- * Since DateField extends LegacyAbstractField it - * implements the {@link Buffered}interface. + * Since DateField extends AbstractField it implements + * the {@link Buffered}interface. *

*

* A DateField is in write-through mode by default, so @@ -717,6 +717,21 @@ public class DateField extends AbstractField implements * and flags about invalid input. */ setInternalValue(null); + + /* + * Due to DateField's special implementation of isValid(), + * datefields validity may change although the logical value does + * not change. This is an issue for Form which expects that validity + * of Fields cannot change unless actual value changes. + * + * So we check if this field is inside a form and the form has + * registered this as a field. In this case we repaint the form. + * Without this hacky solution the form might not be able to clean + * validation errors etc. We could avoid this by firing an extra + * value change event, but feels like at least as bad solution as + * this. + */ + notifyFormOfValidityChange(); markAsDirty(); return; } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java index b8756c3d7f..f42000a119 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java @@ -86,13 +86,13 @@ public class DefaultFieldFactory /** * Creates fields based on the property type. *

- * The default field type is {@link LegacyTextField}. Other field types - * generated by this method: + * The default field type is {@link TextField}. Other field types generated + * by this method: *

* Boolean: {@link CheckBox}.
- * Date: {@link LegacyDateField}(resolution: day).
+ * Date: {@link DateField}(resolution: day).
* Item: {@link Form}.
- * default field type: {@link LegacyTextField}. + * default field type: {@link TextField}. *

* * @param type diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java index 1e3a4fa7a3..6cb08af5f0 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java @@ -22,14 +22,14 @@ import com.vaadin.v7.data.BufferedValidatable; import com.vaadin.v7.data.Property; /** - * LegacyField interface is implemented by all legacy field components that have - * a value that the user can change through the user interface. + * Field interface is implemented by all classes (field components) that have a + * value that the user can change through the user interface. * - * LegacyField components are built upon the framework defined in the - * LegacyField interface and the {@link AbstractField} base class. + * Field components are built upon the framework defined in the Field interface + * and the {@link AbstractField} base class. * - * The LegacyField interface inherits the {@link Component} superinterface and - * also the {@link Property} interface to have a value for the field. + * The Field interface inherits the {@link Component} superinterface and also + * the {@link Property} interface to have a value for the field. * * @author Vaadin Ltd. * @@ -85,8 +85,8 @@ public interface Field extends Component, BufferedValidatable, Property, public String getRequiredError(); /** - * An Event object specifying the LegacyField whose value has - * been changed. + * An Event object specifying the Field whose value has been + * changed. * * @author Vaadin Ltd. * @since 3.0 diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java index c671caea93..4fc9a63789 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java @@ -49,6 +49,7 @@ import com.vaadin.v7.data.Item; import com.vaadin.v7.data.Property; import com.vaadin.v7.data.Validatable; import com.vaadin.v7.data.Validator; +import com.vaadin.v7.data.Validator.InvalidValueException; import com.vaadin.v7.data.fieldgroup.FieldGroup; import com.vaadin.v7.data.util.BeanItem; import com.vaadin.v7.shared.form.FormState; @@ -190,7 +191,7 @@ public class Form extends AbstractField * @param formLayout * the layout of the form. * @param fieldFactory - * the TableFieldFactory of the form. + * the FieldFactory of the form. */ public Form(Layout formLayout, FormFieldFactory fieldFactory) { super(); @@ -317,7 +318,7 @@ public class Form extends AbstractField */ @Override public void commit() - throws Buffered.SourceException, Validator.InvalidValueException { + throws Buffered.SourceException, InvalidValueException { LinkedList problems = null; @@ -961,7 +962,7 @@ public class Form extends AbstractField * @see Validatable#validate() */ @Override - public void validate() throws Validator.InvalidValueException { + public void validate() throws InvalidValueException { super.validate(); for (final Iterator i = propertyIds.iterator(); i.hasNext();) { fields.get(i.next()).validate(); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java index a2c963c0a4..390b77eaac 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -26,9 +26,9 @@ import com.vaadin.v7.data.fieldgroup.FieldGroup; * property id and uiContext (the component responsible for displaying fields). * Currently this interface is used by {@link Form}, but might later be used by * some other components for {@link Field} generation. - * + * *

- * + * * @author Vaadin Ltd. * @since 6.0 * @see TableFieldFactory @@ -40,7 +40,7 @@ public interface FormFieldFactory extends Serializable { /** * Creates a field based on the item, property id and the component (most * commonly {@link Form}) where the Field will be presented. - * + * * @param item * the item where the property belongs to. * @param propertyId diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java index 207132f364..f9a5062ac1 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java @@ -123,6 +123,7 @@ import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState; import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelState; +import com.vaadin.v7.ui.Grid.SelectionModel.HasUserSelectionAllowed; import com.vaadin.v7.ui.renderers.HtmlRenderer; import com.vaadin.v7.ui.renderers.Renderer; import com.vaadin.v7.ui.renderers.TextRenderer; @@ -1141,6 +1142,35 @@ public class Grid extends AbstractComponent */ @Deprecated public interface SelectionModel extends Serializable, Extension { + + /** + * Interface implemented by selection models which support disabling + * client side selection while still allowing programmatic selection on + * the server. + * + * @since 7.7.7 + */ + public interface HasUserSelectionAllowed extends SelectionModel { + + /** + * Checks if the user is allowed to change the selection. + * + * @return true if the user is allowed to change the + * selection, false otherwise + */ + public boolean isUserSelectionAllowed(); + + /** + * Sets whether the user is allowed to change the selection. + * + * @param userSelectionAllowed + * true if the user is allowed to change the + * selection, false otherwise + */ + public void setUserSelectionAllowed(boolean userSelectionAllowed); + + } + /** * Checks whether an item is selected or not. * @@ -1505,7 +1535,7 @@ public class Grid extends AbstractComponent */ @Deprecated public static class SingleSelectionModel extends AbstractSelectionModel - implements SelectionModel.Single { + implements SelectionModel.Single, HasUserSelectionAllowed { @Override protected void extend(AbstractClientConnector target) { @@ -1514,6 +1544,11 @@ public class Grid extends AbstractComponent @Override public void select(String rowKey) { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to select '" + rowKey + + "' although user selection is disallowed"); + } SingleSelectionModel.this.select(getItemId(rowKey), false); } }); @@ -1604,6 +1639,21 @@ public class Grid extends AbstractComponent protected SingleSelectionModelState getState() { return (SingleSelectionModelState) super.getState(); } + + @Override + protected SingleSelectionModelState getState(boolean markAsDirty) { + return (SingleSelectionModelState) super.getState(markAsDirty); + } + + @Override + public boolean isUserSelectionAllowed() { + return getState(false).userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + getState().userSelectionAllowed = userSelectionAllowed; + } } /** @@ -1639,7 +1689,8 @@ public class Grid extends AbstractComponent */ @Deprecated public static class MultiSelectionModel extends AbstractSelectionModel - implements SelectionModel.Multi { + implements SelectionModel.Multi, + SelectionModel.HasUserSelectionAllowed { /** * The default selection size limit. @@ -1657,6 +1708,12 @@ public class Grid extends AbstractComponent @Override public void select(List rowKeys) { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to select '" + rowKeys + + "' although user selection is disallowed"); + } + List items = new ArrayList(); for (String rowKey : rowKeys) { items.add(getItemId(rowKey)); @@ -1666,6 +1723,12 @@ public class Grid extends AbstractComponent @Override public void deselect(List rowKeys) { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to deselect '" + rowKeys + + "' although user selection is disallowed"); + } + List items = new ArrayList(); for (String rowKey : rowKeys) { items.add(getItemId(rowKey)); @@ -1675,11 +1738,21 @@ public class Grid extends AbstractComponent @Override public void selectAll() { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to select all although user selection is disallowed"); + } + MultiSelectionModel.this.selectAll(false); } @Override public void deselectAll() { + if (!isUserSelectionAllowed()) { + throw new IllegalStateException( + "Client tried to deselect all although user selection is disallowed"); + } + MultiSelectionModel.this.deselectAll(false); } }); @@ -1963,6 +2036,21 @@ public class Grid extends AbstractComponent protected MultiSelectionModelState getState() { return (MultiSelectionModelState) super.getState(); } + + @Override + protected MultiSelectionModelState getState(boolean markAsDirty) { + return (MultiSelectionModelState) super.getState(markAsDirty); + } + + @Override + public boolean isUserSelectionAllowed() { + return getState(false).userSelectionAllowed; + } + + @Override + public void setUserSelectionAllowed(boolean userSelectionAllowed) { + getState().userSelectionAllowed = userSelectionAllowed; + } } /** @@ -2390,14 +2478,17 @@ public class Grid extends AbstractComponent } /** - * Merges columns cells in a row + * Merges columns cells in a row. * * @param propertyIds * The property ids of columns to merge * @return The remaining visible cell after the merge */ public CELLTYPE join(Object... propertyIds) { - assert propertyIds.length > 1 : "You need to merge at least 2 properties"; + if (propertyIds.length < 2) { + throw new IllegalArgumentException( + "You need to merge at least 2 properties"); + } Set cells = new HashSet(); for (int i = 0; i < propertyIds.length; ++i) { @@ -2408,14 +2499,17 @@ public class Grid extends AbstractComponent } /** - * Merges columns cells in a row + * Merges columns cells in a row. * * @param cells * The cells to merge. Must be from the same row. * @return The remaining visible cell after the merge */ public CELLTYPE join(CELLTYPE... cells) { - assert cells.length > 1 : "You need to merge at least 2 cells"; + if (cells.length < 2) { + throw new IllegalArgumentException( + "You need to merge at least 2 cells"); + } return join(new HashSet(Arrays.asList(cells))); } @@ -4637,7 +4731,7 @@ public class Grid extends AbstractComponent * own Container. * * @see #setContainerDataSource(Indexed) - * @see #LegacyGrid() + * @see #Grid() */ private boolean defaultContainer = true; @@ -5150,7 +5244,7 @@ public class Grid extends AbstractComponent * @return unmodifiable copy of current columns in visual order */ public List getColumns() { - List columns = new ArrayList(); + List columns = new ArrayList(); for (String columnId : getState(false).columnOrder) { columns.add(getColumnByColumnId(columnId)); } @@ -6830,6 +6924,15 @@ public class Grid extends AbstractComponent } } + /** + * Refreshes, i.e. causes the client side to re-render all rows. + * + * @since 7.7.7 + */ + public void refreshAllRows() { + datasourceExtension.refreshCache(); + } + private static Logger getLogger() { return Logger.getLogger(Grid.class.getName()); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java index de5ae3ab38..f7598637b6 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java @@ -35,6 +35,7 @@ import com.vaadin.ui.Component; * spacing on by default */ @Deprecated +@SuppressWarnings("serial") public class HorizontalLayout extends com.vaadin.ui.HorizontalLayout { /** * Constructs an empty HorizontalLayout. diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java index bb273dab46..a5cb55d54c 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java @@ -549,6 +549,8 @@ public class Label extends AbstractLegacyComponent implements Property, markAsDirty(); } + // LegacyPropertyHelper has been removed in Vaadin 8 + /* * (non-Javadoc) * diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java index b5ae1cd396..16619afdf5 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java @@ -51,6 +51,8 @@ public class ListSelect extends AbstractSelect { super(caption); } + // Columns are no longer used for width. + public int getRows() { return rows; } @@ -75,6 +77,7 @@ public class ListSelect extends AbstractSelect { @Override public void paintContent(PaintTarget target) throws PaintException { + // Width is no longer based on columns // Adds the number of rows if (rows != 0) { target.addAttribute("rows", rows); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java index b23cf99097..99cdf97f04 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java @@ -144,9 +144,9 @@ public class ProgressBar extends AbstractField } /* - * Overridden to keep the shared state in sync with the LegacyAbstractField - * internal value. Should be removed once LegacyAbstractField is refactored - * to use shared state. + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. * * See tickets #10921 and #11064. */ diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java index 8b6ad8dbfb..e3f122f25d 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java @@ -4124,7 +4124,7 @@ public class Table extends AbstractSelect implements Action.Container, /** * Binds an item property to a field generated by TableFieldFactory. The - * default behavior is to bind property straight to LegacyField. If + * default behavior is to bind property straight to Field. If * Property.Viewer type property (e.g. PropertyFormatter) is already set for * field, the property is bound to that Property.Viewer. * @@ -4783,7 +4783,7 @@ public class Table extends AbstractSelect implements Action.Container, * * The FieldFactory is only used if the Table is editable. * - * @return TableFieldFactory used to create the LegacyField instances. + * @return TableFieldFactory used to create the Field instances. * @see #isEditable */ public TableFieldFactory getTableFieldFactory() { @@ -4793,8 +4793,8 @@ public class Table extends AbstractSelect implements Action.Container, /** * Is table editable. * - * If table is editable a editor of type LegacyField is created for each - * table cell. The assigned FieldFactory is used to create the instances. + * If table is editable a editor of type Field is created for each table + * cell. The assigned FieldFactory is used to create the instances. * * To provide custom editors for table cells create a class implementing the * FieldFactory interface, and assign it to table, and set the editable @@ -4812,8 +4812,8 @@ public class Table extends AbstractSelect implements Action.Container, /** * Sets the editable property. * - * If table is editable a editor of type LegacyField is created for each - * table cell. The assigned FieldFactory is used to create the instances. + * If table is editable a editor of type Field is created for each table + * cell. The assigned FieldFactory is used to create the instances. * * To provide custom editors for table cells create a class implementing the * FieldFactory interface, and assign it to table, and set the editable diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java index 8bdec4ca66..1f3d14c8dd 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java @@ -21,7 +21,7 @@ import com.vaadin.ui.Component; import com.vaadin.v7.data.Container; /** - * Factory interface for creating new LegacyField-instances based on Container + * Factory interface for creating new Field-instances based on Container * (datasource), item id, property id and uiContext (the component responsible * for displaying fields). Currently this interface is used by {@link Table}, * but might later be used by some other components for {@link Field} diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java index a78cb3b0d6..3e7be6c7f4 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java @@ -32,11 +32,10 @@ import com.vaadin.v7.data.Property; *

* *

- * Since TextField extends LegacyAbstractField it - * implements the {@link Buffered} interface. A TextField is in - * write-through mode by default, so - * {@link AbstractField#setWriteThrough(boolean)} must be called to enable - * buffering. + * Since TextField extends AbstractField it implements + * the {@link Buffered} interface. A TextField is in write-through + * mode by default, so {@link AbstractField#setWriteThrough(boolean)} must be + * called to enable buffering. *

* * @author Vaadin Ltd. diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java index 67da52df51..5f114c06cb 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java @@ -1242,7 +1242,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical, if (actionHandler != null) { if (actionHandlers == null) { - actionHandlers = new LinkedList(); + actionHandlers = new LinkedList(); actionMapper = new KeyMapper(); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java index d1ddaa4f08..5f585962ff 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java @@ -65,6 +65,8 @@ public class TwinColSelect extends AbstractSelect { setMultiSelect(true); } + // Columns are no longer used for width. + public int getRows() { return rows; } @@ -104,7 +106,7 @@ public class TwinColSelect extends AbstractSelect { @Override public void paintContent(PaintTarget target) throws PaintException { - // Adds the number of columns + // Width is no longer based on columns // Adds the number of rows if (rows != 0) { target.addAttribute("rows", rows); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java index d00439cbb8..a559b09bac 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java @@ -240,13 +240,6 @@ public class ContainerEventProvider return event; } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java. - * util.Date, java.util.Date) - */ @Override public List getEvents(Date startDate, Date endDate) { eventCache.clear(); @@ -279,14 +272,6 @@ public class ContainerEventProvider return Collections.unmodifiableList(eventCache); } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeNotifier - * #addListener(com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeListener) - */ @Override public void addEventSetChangeListener(EventSetChangeListener listener) { if (!eventSetChangeListeners.contains(listener)) { @@ -294,26 +279,11 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeNotifier - * #removeListener(com.vaadin.addon.calendar.event.CalendarEventProvider. - * EventSetChangeListener) - */ @Override public void removeEventSetChangeListener(EventSetChangeListener listener) { eventSetChangeListeners.remove(listener); } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier# - * addListener - * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) - */ @Override public void addEventChangeListener(EventChangeListener listener) { if (eventChangeListeners.contains(listener)) { @@ -321,13 +291,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier# - * removeListener - * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener) - */ @Override public void removeEventChangeListener(EventChangeListener listener) { eventChangeListeners.remove(listener); @@ -421,13 +384,6 @@ public class ContainerEventProvider return allDayProperty; } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Container.ItemSetChangeListener#containerItemSetChange - * (com.vaadin.data.Container.ItemSetChangeEvent) - */ @Override public void containerItemSetChange(ItemSetChangeEvent event) { if (event.getContainer() == container) { @@ -438,13 +394,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data - * .Property.ValueChangeEvent) - */ @Override public void valueChange(ValueChangeEvent event) { /* @@ -454,14 +403,6 @@ public class ContainerEventProvider */ } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler - * #eventMove - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent) - */ @Override public void eventMove(MoveEvent event) { CalendarEvent ce = event.getCalendarEvent(); @@ -485,14 +426,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler - * #eventResize - * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize) - */ @Override public void eventResize(EventResize event) { CalendarEvent ce = event.getCalendarEvent(); @@ -522,13 +455,6 @@ public class ContainerEventProvider ignoreContainerEvents(); } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent - * (com.vaadin.addon.calendar.event.CalendarEvent) - */ @Override public void addEvent(CalendarEvent event) { Item item; @@ -552,13 +478,6 @@ public class ContainerEventProvider } } - /* - * (non-Javadoc) - * - * @see - * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent - * (com.vaadin.addon.calendar.event.CalendarEvent) - */ @Override public void removeEvent(CalendarEvent event) { container.removeItem(event); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java index 9a6e3598e8..3b2ec99d97 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -26,12 +26,12 @@ import com.vaadin.v7.ui.TextField; /** * A component that represents color selection preview within a color picker. - * + * * @since 7.0.0 */ @Deprecated -public class ColorPickerPreview extends CssLayout implements ColorSelector, - ValueChangeListener { +public class ColorPickerPreview extends CssLayout + implements ColorSelector, ValueChangeListener { private static final String STYLE_DARK_COLOR = "v-textfield-dark"; private static final String STYLE_LIGHT_COLOR = "v-textfield-light"; @@ -98,8 +98,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector, // Set the text color field.removeStyleName(STYLE_DARK_COLOR); field.removeStyleName(STYLE_LIGHT_COLOR); - if (this.color.getRed() + this.color.getGreen() + this.color - .getBlue() < 3 * 128) { + if (this.color.getRed() + this.color.getGreen() + + this.color.getBlue() < 3 * 128) { field.addStyleName(STYLE_DARK_COLOR); } else { field.addStyleName(STYLE_LIGHT_COLOR); @@ -161,8 +161,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector, value.length() - 1).split(","); int hue = Integer.parseInt(colors[0]); - int saturation = Integer.parseInt(colors[1] - .replace("%", "")); + int saturation = Integer + .parseInt(colors[1].replace("%", "")); int lightness = Integer .parseInt(colors[2].replace("%", "")); int rgb = Color.HSLtoRGB(hue, saturation, lightness); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java index 63d46d6cc4..79dfdf3b49 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -24,12 +24,12 @@ import com.vaadin.v7.ui.ComboBox; /** * A component that represents color selection swatches within a color picker. - * + * * @since 7.0.0 */ @Deprecated -public class ColorPickerSelect extends CustomComponent implements - ColorSelector, ValueChangeListener { +public class ColorPickerSelect extends CustomComponent + implements ColorSelector, ValueChangeListener { /** The range. */ private final ComboBox range; @@ -49,7 +49,7 @@ public class ColorPickerSelect extends CustomComponent implements /** * Instantiates a new color range property id. - * + * * @param caption * the caption */ @@ -65,7 +65,7 @@ public class ColorPickerSelect extends CustomComponent implements /** * Instantiates a new color picker select. - * + * * @param rows * the rows * @param columns @@ -102,12 +102,12 @@ public class ColorPickerSelect extends CustomComponent implements /** * Creates the all colors. - * + * * @param rows * the rows * @param columns * the columns - * + * * @return the color[][] */ private Color[][] createAllColors(int rows, int columns) { @@ -131,8 +131,8 @@ public class ColorPickerSelect extends CustomComponent implements value = 1f - ((row - (rows / 2f)) / (rows / 2f)); } - colors[row][col] = new Color(Color.HSVtoRGB(hue, - saturation, value)); + colors[row][col] = new Color( + Color.HSVtoRGB(hue, saturation, value)); } // The last row should have the black&white gradient @@ -141,8 +141,8 @@ public class ColorPickerSelect extends CustomComponent implements float saturation = 0f; float value = 1f - ((float) col / (float) columns); - colors[row][col] = new Color(Color.HSVtoRGB(hue, - saturation, value)); + colors[row][col] = new Color( + Color.HSVtoRGB(hue, saturation, value)); } } } @@ -152,14 +152,14 @@ public class ColorPickerSelect extends CustomComponent implements /** * Creates the color. - * + * * @param color * the color * @param rows * the rows * @param columns * the columns - * + * * @return the color[][] */ private Color[][] createColors(Color color, int rows, int columns) { @@ -183,12 +183,12 @@ public class ColorPickerSelect extends CustomComponent implements / (((float) rows * (float) columns) / 2f); } else { index -= ((rows * columns) / 2); - value = 1f - index - / (((float) rows * (float) columns) / 2f); + value = 1f + - index / (((float) rows * (float) columns) / 2f); } - colors[row][col] = new Color(Color.HSVtoRGB(hue, saturation, - value)); + colors[row][col] = new Color( + Color.HSVtoRGB(hue, saturation, value)); } } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java index 755c3fcc60..b41b6c2620 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java @@ -71,7 +71,7 @@ import elemental.json.JsonValue; *
  • init(cell) - Prepares a cell for rendering. Corresponds to * {@link com.vaadin.client.renderers.ComplexRenderer#init(com.vaadin.client.widget.grid.RendererCellReference)} * .
  • - *
  • destory(cell) - Allows the renderer to release resources + *
  • destroy(cell) - Allows the renderer to release resources * allocate for a cell that will no longer be used. Corresponds to * {@link com.vaadin.client.renderers.ComplexRenderer#destroy(com.vaadin.client.widget.grid.RendererCellReference)} * .
  • diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java index 66e68573d8..7924b36f7e 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java @@ -30,6 +30,7 @@ public abstract class AbstractListenerMethodsTestBase { for (Class c : classes) { boolean found = false; for (Method m : c.getDeclaredMethods()) { + // Intentional change in compatibility package String methodName = m.getName(); if (methodName.startsWith("add") && methodName.endsWith("Listener") @@ -154,6 +155,7 @@ public abstract class AbstractListenerMethodsTestBase { private Method getAddListenerMethod(Class cls, Class listenerClass) throws SecurityException, NoSuchMethodException { + // Intentional change in compatibility package return cls.getMethod("add" + listenerClass.getSimpleName(), listenerClass); @@ -161,6 +163,7 @@ public abstract class AbstractListenerMethodsTestBase { private Method getRemoveListenerMethod(Class cls, Class listenerClass) throws SecurityException, NoSuchMethodException { + // Intentional change in compatibility package return cls.getMethod("remove" + listenerClass.getSimpleName(), listenerClass); @@ -178,4 +181,4 @@ public abstract class AbstractListenerMethodsTestBase { registeredListeners.toArray()); } -} \ No newline at end of file +} diff --git a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java index 8c093fdf72..1f7783dda5 100644 --- a/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java +++ b/compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java @@ -41,8 +41,8 @@ public class SliderTest { slider.setValue(-1.0); } catch (Slider.ValueOutOfBoundsException e) { - assertThat(e.getMessage(), - containsString("Value -1.0 is out of bounds: [0.0, 100.0]")); + assertThat(e.getMessage(), containsString( + "Value -1.0 is out of bounds: [0.0, 100.0]")); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java index 3f174eb649..516e4eb63d 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java @@ -17,6 +17,8 @@ public class PerformanceTestIndexedContainerTest { // TODO should improve performance of these methods private static final long ADD_ITEM_AT_FAIL_THRESHOLD = 5000; private static final long ADD_ITEM_AFTER_FAIL_THRESHOLD = 5000; + // FIXME: Vaadin 7 compatibility version fails this check with original + // value of 5000 private static final long ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD = 6000; private static final long ADD_ITEMS_CONSTRUCTOR_FAIL_THRESHOLD = 200; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java index fe1e7e1813..d39d604852 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java @@ -187,7 +187,7 @@ public class SQLContainerTableQueryTest { container.commit(); Item item = getItem(container.lastItemId()); - assertThat(item.getItemProperty(NAME).getValue(), is("foo")); + assertThat(item.getItemProperty(NAME).getValue().toString(), is("foo")); } @Test @@ -196,8 +196,8 @@ public class SQLContainerTableQueryTest { container.refresh(); - assertThat(getItem(existingItemId).getItemProperty(NAME).getValue(), - is("foo")); + assertThat(getItem(existingItemId).getItemProperty(NAME).getValue() + .toString(), is("foo")); } @Test diff --git a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java index 7f27d2a2fd..078363af19 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java @@ -75,7 +75,7 @@ public class SQLGeneratorsTest { @Test public void generateSelectQuery_filtersAndOrderingSet_shouldSucceed() { SQLGenerator sg = new DefaultSQLGenerator(); - List f = new ArrayList(); + List f = new ArrayList(); f.add(new Like("name", "%lle")); List ob = Arrays.asList(new OrderBy("name", true)); StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java index 046b365601..c6652b77d9 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java @@ -88,7 +88,7 @@ public class WriteLegacyDesignTest { private void checkNode(Node node) { if (node instanceof Element) { - assertTrue("Expected " + node.nodeName() + " to start with v-", + assertTrue("Wrong design element prefix", node.nodeName().startsWith("v-")); for (Node child : node.childNodes()) { checkNode(child); diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java index 09ab8fe65f..5aee75af36 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java @@ -68,6 +68,15 @@ public class AbsFieldValidatorsTest { assertFalse(field.getValidators().contains(validator2)); } + @Test + public void validatorShouldMakeImmediate() { + assertFalse("field should not be immediate by default", + field.isImmediate()); + field.addValidator(validator); + assertTrue("field should be immediate when it has a validator", + field.isImmediate()); + } + @Test public void nonImmediateFieldWithValidator() { field.setImmediate(false); @@ -76,4 +85,30 @@ public class AbsFieldValidatorsTest { field.isImmediate()); } + @Test + public void removeValidatorMakesNonImmediate() { + field.addValidator(validator); + field.removeValidator(validator); + assertFalse("field should be non-immediate after validator was removed", + field.isImmediate()); + } + + @Test + public void requiredMakesImmediate() { + assertFalse("field should not be immediate by default", + field.isImmediate()); + field.setRequired(true); + assertTrue("field should be immediate when it is required", + field.isImmediate()); + } + + @Test + public void removeRequiredMakesNonImmediate() { + assertFalse("field should not be immediate by default", + field.isImmediate()); + field.setRequired(true); + field.setRequired(false); + assertFalse("field should not be immediate even though it was required", + field.isImmediate()); + } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java index 6594ed9351..d4bdb4fe53 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java @@ -1,6 +1,7 @@ package com.vaadin.v7.tests.server.component.abstractfield; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Locale; @@ -19,6 +20,7 @@ import com.vaadin.v7.data.util.ObjectProperty; import com.vaadin.v7.data.util.converter.Converter; import com.vaadin.v7.data.util.converter.Converter.ConversionException; import com.vaadin.v7.data.util.converter.StringToIntegerConverter; +import com.vaadin.v7.ui.CheckBox; import com.vaadin.v7.ui.TextField; public class AbsFieldValueConversionsTest { @@ -153,6 +155,65 @@ public class AbsFieldValueConversionsTest { tf.getValue()); } + @Test + public void testBooleanNullConversion() { + CheckBox cb = new CheckBox(); + cb.setConverter(new Converter() { + + @Override + public Boolean convertToModel(Boolean value, + Class targetType, Locale locale) { + // value from a CheckBox should never be null as long as it is + // not set to null (handled by conversion below). + assertNotNull(value); + return value; + } + + @Override + public Boolean convertToPresentation(Boolean value, + Class targetType, Locale locale) { + // Datamodel -> field + if (value == null) { + return false; + } + + return value; + } + + @Override + public Class getModelType() { + return Boolean.class; + } + + @Override + public Class getPresentationType() { + return Boolean.class; + } + + }); + MethodProperty property = new MethodProperty( + paulaBean, "deceased"); + cb.setPropertyDataSource(property); + assertEquals(Boolean.FALSE, property.getValue()); + assertEquals(Boolean.FALSE, cb.getValue()); + Boolean newDmValue = cb.getConverter().convertToPresentation( + cb.getValue(), Boolean.class, new Locale("fi", "FI")); + assertEquals(Boolean.FALSE, newDmValue); + + // FIXME: Should be able to set to false here to cause datamodel to be + // set to false but the change will not be propagated to the Property + // (field value is already false) + + cb.setValue(true); + assertEquals(Boolean.TRUE, cb.getValue()); + assertEquals(Boolean.TRUE, property.getValue()); + + cb.setValue(false); + assertEquals(Boolean.FALSE, cb.getValue()); + assertEquals(Boolean.FALSE, property.getValue()); + + } + // Now specific to Integer because StringToNumberConverter has been removed public static class NumberBean { private Integer number; diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java index f284229e28..ece14756cb 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java @@ -7,7 +7,7 @@ import com.vaadin.v7.data.Property.ReadOnlyStatusChangeEvent; import com.vaadin.v7.data.Property.ReadOnlyStatusChangeListener; import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.ui.Table; +import com.vaadin.v7.ui.CheckBox; public class AbstractFieldListenersTest extends AbstractListenerMethodsTestBase { @@ -15,13 +15,14 @@ public class AbstractFieldListenersTest @Test public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(Table.class, ReadOnlyStatusChangeEvent.class, + testListenerAddGetRemove(CheckBox.class, + ReadOnlyStatusChangeEvent.class, ReadOnlyStatusChangeListener.class); } @Test public void testValueChangeListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(Table.class, ValueChangeEvent.class, + testListenerAddGetRemove(CheckBox.class, ValueChangeEvent.class, ValueChangeListener.class); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java index 0a97a84999..6e43eb2b85 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java @@ -103,4 +103,4 @@ public class ItemSetChangeDuringEditorCommit { .applyInvocation(invocation); } -} \ No newline at end of file +} diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java index 044124bc8a..b4ccb094d0 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java @@ -24,10 +24,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.vaadin.ui.ComponentTest; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.event.SelectionEvent; import com.vaadin.v7.event.SelectionEvent.SelectionListener; +import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc; import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState; import com.vaadin.v7.ui.Grid; @@ -187,4 +189,40 @@ public class MultiSelectionModelTest { } Assert.fail("Not all items were correctly selected"); } + + @Test(expected = IllegalStateException.class) + public void refuseSelectWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.select(Collections.singletonList("a")); + } + + @Test(expected = IllegalStateException.class) + public void refuseDeselectWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.deselect(Collections.singletonList("a")); + } + + @Test(expected = IllegalStateException.class) + public void refuseSelectAllWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.selectAll(); + } + + @Test(expected = IllegalStateException.class) + public void refuseDeselectAllWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), MultiSelectionModelServerRpc.class); + serverRpc.deselectAll(); + } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java index e18c5bbe8b..ffb07b986b 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java @@ -20,10 +20,12 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import com.vaadin.ui.ComponentTest; import com.vaadin.v7.data.Container; import com.vaadin.v7.data.util.IndexedContainer; import com.vaadin.v7.event.SelectionEvent; import com.vaadin.v7.event.SelectionEvent.SelectionListener; +import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelServerRpc; import com.vaadin.v7.ui.Grid; import com.vaadin.v7.ui.Grid.SelectionMode; import com.vaadin.v7.ui.Grid.SingleSelectionModel; @@ -150,4 +152,13 @@ public class SingleSelectionModelTest { } }); } + + @Test(expected = IllegalStateException.class) + public void refuseSelectionWhenUserSelectionDisallowed() { + ((HasUserSelectionAllowed) grid.getSelectionModel()) + .setUserSelectionAllowed(false); + SingleSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy( + grid.getSelectionModel(), SingleSelectionModelServerRpc.class); + serverRpc.select("a"); + } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java index c8b3e8116b..814160782f 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java @@ -36,6 +36,7 @@ public abstract class TableDeclarativeTestBase } protected String getTag() { + // Compatibility classes have a different prefix return "vaadin7-table"; } diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnResizeMode.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnResizeMode.java index 63eacd1fc1..d05166cec9 100644 --- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnResizeMode.java +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnResizeMode.java @@ -17,7 +17,7 @@ package com.vaadin.v7.shared.ui.grid; /** * Collection of modes used for resizing columns in the Grid. - * + * * @since 7.7.5 */ public enum ColumnResizeMode { @@ -35,4 +35,4 @@ public enum ColumnResizeMode { */ SIMPLE -} \ No newline at end of file +} diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java index c04d9aaff5..f57399f6f8 100644 --- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java @@ -27,5 +27,5 @@ public class MultiSelectionModelState extends SharedState { /* Select All -checkbox status */ public boolean allSelected; - + public boolean userSelectionAllowed = true; } diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java index a9fb816449..82f77e9bfb 100644 --- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java @@ -27,4 +27,5 @@ public class SingleSelectionModelState extends SharedState { /* Allow deselecting rows */ public boolean deselectAllowed = true; + public boolean userSelectionAllowed = true; } diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java index 6c0a74b7ea..01f41174bd 100644 --- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java @@ -18,6 +18,7 @@ package com.vaadin.v7.shared.ui.optiongroup; import java.io.Serializable; public class OptionGroupConstants implements Serializable { + // Vaadin 8 option group uses state for HTML content public static final String ATTRIBUTE_OPTION_DISABLED = "disabled"; } diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/progressindicator/ProgressBarState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/progressindicator/ProgressBarState.java index b3e510b43d..a9a98e3395 100644 --- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/progressindicator/ProgressBarState.java +++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/progressindicator/ProgressBarState.java @@ -34,6 +34,6 @@ public class ProgressBarState extends AbstractFieldState { } public boolean indeterminate = false; @NoLayout - public float state = 0.0f; + public Float state = 0.0f; }