aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDenis <denis@vaadin.com>2016-12-08 10:57:38 +0200
committerPekka Hyvönen <pekka@vaadin.com>2016-12-08 10:57:38 +0200
commit9fb43988c7335167d40b01479265e41cad55d301 (patch)
tree941d5c15b403776a83b9474df39ffb52eb320768 /server
parent414de3c4b2ea5267808980bd23a9e56aa865e96b (diff)
downloadvaadin-framework-9fb43988c7335167d40b01479265e41cad55d301.tar.gz
vaadin-framework-9fb43988c7335167d40b01479265e41cad55d301.zip
Introduce dedicated shared states for every core vaadin component/ext. (#98)
* Introduce dedicated shared states for every core vaadin component/ext. Updated components are: - PasswordField - CustomField - AbstractListing - AbstractMultiSelect - ColorPicker - ColorPickerArea - DataCommunicator - Responsive - AbstractListingExtension - DetailsManager - AbstractRenderer - ClickableRenderer - ButtonRenderer - CheckBoxRenderer - DateRenderer - HtmlRenderer - ImageRenderer - NumberRenderer - ProgressBarRenderer - TextRenderer Fixes vaadin/framework8-issues#480.
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/AbstractJavaScriptExtension.java5
-rw-r--r--server/src/main/java/com/vaadin/server/FileDownloader.java11
-rw-r--r--server/src/main/java/com/vaadin/server/Responsive.java11
-rw-r--r--server/src/main/java/com/vaadin/server/data/DataCommunicator.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractColorPicker.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractListing.java22
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/ColorPicker.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/ColorPickerArea.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/CustomField.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java22
-rw-r--r--server/src/main/java/com/vaadin/ui/JavaScript.java24
-rw-r--r--server/src/main/java/com/vaadin/ui/PasswordField.java14
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java5
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/AbstractRenderer.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/ButtonRenderer.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/DateRenderer.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/HtmlRenderer.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/ImageRenderer.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/NumberRenderer.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/ProgressBarRenderer.java12
-rw-r--r--server/src/main/java/com/vaadin/ui/renderers/TextRenderer.java12
-rw-r--r--server/src/test/java/com/vaadin/server/DedicatedStateTest.java101
26 files changed, 380 insertions, 21 deletions
diff --git a/server/src/main/java/com/vaadin/server/AbstractJavaScriptExtension.java b/server/src/main/java/com/vaadin/server/AbstractJavaScriptExtension.java
index 82a9fed2bb..8af7e38838 100644
--- a/server/src/main/java/com/vaadin/server/AbstractJavaScriptExtension.java
+++ b/server/src/main/java/com/vaadin/server/AbstractJavaScriptExtension.java
@@ -208,4 +208,9 @@ public abstract class AbstractJavaScriptExtension extends AbstractExtension {
protected JavaScriptExtensionState getState() {
return (JavaScriptExtensionState) super.getState();
}
+
+ @Override
+ protected JavaScriptExtensionState getState(boolean markAsDirty) {
+ return (JavaScriptExtensionState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/server/FileDownloader.java b/server/src/main/java/com/vaadin/server/FileDownloader.java
index c277d58f12..684e12dc6e 100644
--- a/server/src/main/java/com/vaadin/server/FileDownloader.java
+++ b/server/src/main/java/com/vaadin/server/FileDownloader.java
@@ -18,6 +18,7 @@ package com.vaadin.server;
import java.io.IOException;
+import com.vaadin.shared.extension.filedownloader.FileDownloaderState;
import com.vaadin.ui.AbstractComponent;
/**
@@ -163,4 +164,14 @@ public class FileDownloader extends AbstractExtension {
return true;
}
+ @Override
+ protected FileDownloaderState getState() {
+ return (FileDownloaderState) super.getState();
+ }
+
+ @Override
+ protected FileDownloaderState getState(boolean markAsDirty) {
+ return (FileDownloaderState) super.getState(markAsDirty);
+ }
+
}
diff --git a/server/src/main/java/com/vaadin/server/Responsive.java b/server/src/main/java/com/vaadin/server/Responsive.java
index 3354f744e0..5d0bbfb2ab 100644
--- a/server/src/main/java/com/vaadin/server/Responsive.java
+++ b/server/src/main/java/com/vaadin/server/Responsive.java
@@ -16,6 +16,7 @@
package com.vaadin.server;
+import com.vaadin.shared.extension.responsive.ResponsiveState;
import com.vaadin.ui.Component;
/**
@@ -158,4 +159,14 @@ public class Responsive extends AbstractExtension {
}
}
}
+
+ @Override
+ protected ResponsiveState getState() {
+ return (ResponsiveState) super.getState();
+ }
+
+ @Override
+ protected ResponsiveState getState(boolean markAsDirty) {
+ return (ResponsiveState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/server/data/DataCommunicator.java b/server/src/main/java/com/vaadin/server/data/DataCommunicator.java
index 61545ada83..9d84b1bcc9 100644
--- a/server/src/main/java/com/vaadin/server/data/DataCommunicator.java
+++ b/server/src/main/java/com/vaadin/server/data/DataCommunicator.java
@@ -34,6 +34,7 @@ import com.vaadin.shared.Registration;
import com.vaadin.shared.data.DataCommunicatorClientRpc;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.data.DataRequestRpc;
+import com.vaadin.shared.extension.datacommunicator.DataCommunicatorState;
import elemental.json.Json;
import elemental.json.JsonArray;
@@ -515,6 +516,16 @@ public class DataCommunicator<T, F> extends AbstractExtension {
return minPushSize;
}
+ @Override
+ protected DataCommunicatorState getState(boolean markAsDirty) {
+ return (DataCommunicatorState) super.getState(markAsDirty);
+ }
+
+ @Override
+ protected DataCommunicatorState getState() {
+ return (DataCommunicatorState) super.getState();
+ }
+
private void attachDataProviderListener() {
dataProviderUpdateRegistration = getDataProvider()
.addDataProviderListener(
diff --git a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
index 7a40798815..1630a18e65 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractColorPicker.java
@@ -24,7 +24,7 @@ import org.jsoup.nodes.Element;
import com.vaadin.shared.ui.colorpicker.Color;
import com.vaadin.shared.ui.colorpicker.ColorPickerServerRpc;
-import com.vaadin.shared.ui.colorpicker.ColorPickerState;
+import com.vaadin.shared.ui.colorpicker.AbstractColorPickerState;
import com.vaadin.ui.components.colorpicker.ColorPickerPopup;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
@@ -390,13 +390,13 @@ public abstract class AbstractColorPicker extends AbstractField<Color> {
}
@Override
- protected ColorPickerState getState() {
- return (ColorPickerState) super.getState();
+ protected AbstractColorPickerState getState() {
+ return (AbstractColorPickerState) super.getState();
}
@Override
- protected ColorPickerState getState(boolean markAsDirty) {
- return (ColorPickerState) super.getState(markAsDirty);
+ protected AbstractColorPickerState getState(boolean markAsDirty) {
+ return (AbstractColorPickerState) super.getState(markAsDirty);
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java b/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java
index 8e70e9cb03..f643615b81 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractJavaScriptComponent.java
@@ -201,4 +201,9 @@ public abstract class AbstractJavaScriptComponent extends AbstractComponent {
protected JavaScriptComponentState getState() {
return (JavaScriptComponentState) super.getState();
}
+
+ @Override
+ protected JavaScriptComponentState getState(boolean markAsDirty) {
+ return (JavaScriptComponentState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractListing.java b/server/src/main/java/com/vaadin/ui/AbstractListing.java
index 6f0463b822..de742e2145 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractListing.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractListing.java
@@ -29,6 +29,8 @@ import com.vaadin.server.data.DataCommunicator;
import com.vaadin.server.data.DataGenerator;
import com.vaadin.server.data.DataProvider;
import com.vaadin.server.data.Query;
+import com.vaadin.shared.extension.abstractlisting.AbstractListingExtensionState;
+import com.vaadin.shared.ui.abstractlisting.AbstractListingState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignException;
@@ -117,6 +119,16 @@ public abstract class AbstractListing<T> extends AbstractComponent {
protected void refresh(T item) {
getParent().getDataCommunicator().refresh(item);
}
+
+ @Override
+ protected AbstractListingExtensionState getState() {
+ return (AbstractListingExtensionState) super.getState();
+ }
+
+ @Override
+ protected AbstractListingExtensionState getState(boolean markAsDirty) {
+ return (AbstractListingExtensionState) super.getState(markAsDirty);
+ }
}
private final DataCommunicator<T, ?> dataCommunicator;
@@ -438,4 +450,14 @@ public abstract class AbstractListing<T> extends AbstractComponent {
protected String serializeDeclarativeRepresentation(T item) {
return item.toString();
}
+
+ @Override
+ protected AbstractListingState getState() {
+ return (AbstractListingState) super.getState();
+ }
+
+ @Override
+ protected AbstractListingState getState(boolean markAsDirty) {
+ return (AbstractListingState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
index 4bf1ce72e1..c0c3af15d7 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
@@ -39,10 +39,10 @@ import com.vaadin.server.Resource;
import com.vaadin.server.ResourceReference;
import com.vaadin.server.SerializablePredicate;
import com.vaadin.server.data.DataGenerator;
-import com.vaadin.shared.AbstractFieldState;
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.selection.MultiSelectServerRpc;
import com.vaadin.shared.ui.ListingJsonConstants;
+import com.vaadin.shared.ui.abstractmultiselect.AbstractMultiSelectState;
import com.vaadin.ui.declarative.DesignContext;
import com.vaadin.ui.declarative.DesignException;
import com.vaadin.util.ReflectTools;
@@ -282,13 +282,13 @@ public abstract class AbstractMultiSelect<T> extends AbstractListing<T>
}
@Override
- protected AbstractFieldState getState() {
- return (AbstractFieldState) super.getState();
+ protected AbstractMultiSelectState getState() {
+ return (AbstractMultiSelectState) super.getState();
}
@Override
- protected AbstractFieldState getState(boolean markAsDirty) {
- return (AbstractFieldState) super.getState(markAsDirty);
+ protected AbstractMultiSelectState getState(boolean markAsDirty) {
+ return (AbstractMultiSelectState) super.getState(markAsDirty);
}
@Override
diff --git a/server/src/main/java/com/vaadin/ui/ColorPicker.java b/server/src/main/java/com/vaadin/ui/ColorPicker.java
index 706fd6518b..8a137ea652 100644
--- a/server/src/main/java/com/vaadin/ui/ColorPicker.java
+++ b/server/src/main/java/com/vaadin/ui/ColorPicker.java
@@ -16,6 +16,7 @@
package com.vaadin.ui;
import com.vaadin.shared.ui.colorpicker.Color;
+import com.vaadin.shared.ui.colorpicker.ColorPickerState;
/**
* A class that defines default (button-like) implementation for a color picker
@@ -63,4 +64,14 @@ public class ColorPicker extends AbstractColorPicker {
setPrimaryStyleName(STYLENAME_BUTTON);
addStyleName(STYLENAME_DEFAULT);
}
+
+ @Override
+ protected ColorPickerState getState() {
+ return (ColorPickerState) super.getState();
+ }
+
+ @Override
+ protected ColorPickerState getState(boolean markAsDirty) {
+ return (ColorPickerState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/ColorPickerArea.java b/server/src/main/java/com/vaadin/ui/ColorPickerArea.java
index dc2adfed3a..166ed05f23 100644
--- a/server/src/main/java/com/vaadin/ui/ColorPickerArea.java
+++ b/server/src/main/java/com/vaadin/ui/ColorPickerArea.java
@@ -16,6 +16,7 @@
package com.vaadin.ui;
import com.vaadin.shared.ui.colorpicker.Color;
+import com.vaadin.shared.ui.colorpicker.ColorPickerAreaState;
/**
* A class that defines area-like implementation for a color picker component.
@@ -73,4 +74,14 @@ public class ColorPickerArea extends AbstractColorPicker {
getState().width = "30px";
}
}
+
+ @Override
+ protected ColorPickerAreaState getState() {
+ return (ColorPickerAreaState) super.getState();
+ }
+
+ @Override
+ protected ColorPickerAreaState getState(boolean markAsDirty) {
+ return (ColorPickerAreaState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/CustomField.java b/server/src/main/java/com/vaadin/ui/CustomField.java
index b36cb053a6..397346a8cb 100644
--- a/server/src/main/java/com/vaadin/ui/CustomField.java
+++ b/server/src/main/java/com/vaadin/ui/CustomField.java
@@ -20,6 +20,7 @@ import java.io.Serializable;
import java.util.Iterator;
import com.vaadin.data.HasValue;
+import com.vaadin.shared.ui.customfield.CustomFieldState;
/**
* A {@link HasValue} whose UI content can be constructed by the user, enabling
@@ -117,6 +118,16 @@ public abstract class CustomField<T> extends AbstractField<T>
markAsDirtyRecursive();
}
+ @Override
+ protected CustomFieldState getState() {
+ return (CustomFieldState) super.getState();
+ }
+
+ @Override
+ protected CustomFieldState getState(boolean markAsDirty) {
+ return (CustomFieldState) super.getState(markAsDirty);
+ }
+
// ComponentContainer methods
private class ComponentIterator
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 7034d2d028..acb93e9fe3 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -58,7 +58,9 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.DataCommunicatorConstants;
import com.vaadin.shared.data.sort.SortDirection;
+import com.vaadin.shared.ui.grid.AbstractGridExtensionState;
import com.vaadin.shared.ui.grid.ColumnState;
+import com.vaadin.shared.ui.grid.DetailsManagerState;
import com.vaadin.shared.ui.grid.GridConstants;
import com.vaadin.shared.ui.grid.GridConstants.Section;
import com.vaadin.shared.ui.grid.GridServerRpc;
@@ -656,6 +658,16 @@ public class Grid<T> extends AbstractListing<T>
public Grid<T> getParent() {
return (Grid<T>) super.getParent();
}
+
+ @Override
+ protected AbstractGridExtensionState getState() {
+ return (AbstractGridExtensionState) super.getState();
+ }
+
+ @Override
+ protected AbstractGridExtensionState getState(boolean markAsDirty) {
+ return (AbstractGridExtensionState) super.getState(markAsDirty);
+ }
}
private final class GridServerRpcImpl implements GridServerRpc {
@@ -889,6 +901,16 @@ public class Grid<T> extends AbstractListing<T>
public Grid<T> getParent() {
return super.getParent();
}
+
+ @Override
+ protected DetailsManagerState getState() {
+ return (DetailsManagerState) super.getState();
+ }
+
+ @Override
+ protected DetailsManagerState getState(boolean markAsDirty) {
+ return (DetailsManagerState) super.getState(markAsDirty);
+ }
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/JavaScript.java b/server/src/main/java/com/vaadin/ui/JavaScript.java
index 97fd0ad3f3..429f52c3cc 100644
--- a/server/src/main/java/com/vaadin/ui/JavaScript.java
+++ b/server/src/main/java/com/vaadin/ui/JavaScript.java
@@ -52,15 +52,16 @@ public class JavaScript extends AbstractExtension {
* object.
*/
public JavaScript() {
- registerRpc((JavaScriptCallbackRpc) (String name, JsonArray arguments) -> {
- JavaScriptFunction function = functions.get(name);
- // TODO handle situation if name is not registered
- try {
- function.call(arguments);
- } catch (JsonException e) {
- throw new IllegalArgumentException(e);
- }
- });
+ registerRpc(
+ (JavaScriptCallbackRpc) (String name, JsonArray arguments) -> {
+ JavaScriptFunction function = functions.get(name);
+ // TODO handle situation if name is not registered
+ try {
+ function.call(arguments);
+ } catch (JsonException e) {
+ throw new IllegalArgumentException(e);
+ }
+ });
}
@Override
@@ -68,6 +69,11 @@ public class JavaScript extends AbstractExtension {
return (JavaScriptManagerState) super.getState();
}
+ @Override
+ protected JavaScriptManagerState getState(boolean markAsDirty) {
+ return (JavaScriptManagerState) super.getState(markAsDirty);
+ }
+
/**
* Add a new function to the global JavaScript namespace (i.e. the window
* object). The <code>call</code> method in the passed
diff --git a/server/src/main/java/com/vaadin/ui/PasswordField.java b/server/src/main/java/com/vaadin/ui/PasswordField.java
index d357019539..661d848730 100644
--- a/server/src/main/java/com/vaadin/ui/PasswordField.java
+++ b/server/src/main/java/com/vaadin/ui/PasswordField.java
@@ -19,6 +19,7 @@ package com.vaadin.ui;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
+import com.vaadin.shared.ui.passwordfield.PasswordFieldState;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
@@ -72,10 +73,19 @@ public class PasswordField extends TextField {
@Override
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
- AbstractTextField def = designContext
- .getDefaultInstance(this);
+ AbstractTextField def = designContext.getDefaultInstance(this);
Attributes attr = design.attributes();
DesignAttributeHandler.writeAttribute("value", attr, getValue(),
def.getValue(), String.class, designContext);
}
+
+ @Override
+ protected PasswordFieldState getState() {
+ return (PasswordFieldState) super.getState();
+ }
+
+ @Override
+ protected PasswordFieldState getState(boolean markAsDirty) {
+ return (PasswordFieldState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java
index 5663569939..f372954e27 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/AbstractJavaScriptRenderer.java
@@ -176,4 +176,9 @@ public abstract class AbstractJavaScriptRenderer<T, V>
protected JavaScriptExtensionState getState() {
return (JavaScriptExtensionState) super.getState();
}
+
+ @Override
+ protected JavaScriptExtensionState getState(boolean markAsDirty) {
+ return (JavaScriptExtensionState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/AbstractRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/AbstractRenderer.java
index 43ab4108a9..9b9f590945 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/AbstractRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/AbstractRenderer.java
@@ -20,6 +20,7 @@ import java.util.Objects;
import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.AbstractExtension;
import com.vaadin.server.JsonCodec;
+import com.vaadin.shared.ui.grid.renderers.AbstractRendererState;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
@@ -157,4 +158,14 @@ public abstract class AbstractRenderer<T, V> extends AbstractExtension
}
return (Grid<T>) super.getParent().getParent();
}
+
+ @Override
+ protected AbstractRendererState getState() {
+ return (AbstractRendererState) super.getState();
+ }
+
+ @Override
+ protected AbstractRendererState getState(boolean markAsDirty) {
+ return (AbstractRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/ButtonRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/ButtonRenderer.java
index 30e098492f..b9eec4714b 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/ButtonRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/ButtonRenderer.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui.renderers;
+import com.vaadin.shared.ui.grid.renderers.ButtonRendererState;
+
/**
* A Renderer that displays a button with a textual caption. The value of the
* corresponding property is used as the caption. Click listeners can be added
@@ -71,4 +73,14 @@ public class ButtonRenderer<T> extends ClickableRenderer<T, String> {
return super.getNullRepresentation();
}
+ @Override
+ protected ButtonRendererState getState() {
+ return (ButtonRendererState) super.getState();
+ }
+
+ @Override
+ protected ButtonRendererState getState(boolean markAsDirty) {
+ return (ButtonRendererState) super.getState(markAsDirty);
+ }
+
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java
index 92c52c1c0d..c57776d3c0 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/CheckBoxRenderer.java
@@ -18,6 +18,8 @@ package com.vaadin.ui.renderers;
import java.util.function.BiConsumer;
import java.util.function.Function;
+import com.vaadin.shared.ui.grid.renderers.CheckBoxRendererState;
+
/**
* A renderer that displays boolean valued grid columns as checkboxes.
*
@@ -43,4 +45,14 @@ public class CheckBoxRenderer<T> extends ClickableRenderer<T, Boolean> {
addClickListener(clickEvent -> setter.accept(clickEvent.getItem(),
!getter.apply(clickEvent.getItem())));
}
+
+ @Override
+ protected CheckBoxRendererState getState() {
+ return (CheckBoxRendererState) super.getState();
+ }
+
+ @Override
+ protected CheckBoxRendererState getState(boolean markAsDirty) {
+ return (CheckBoxRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
index 8a6c9049f2..28a26620a8 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/ClickableRenderer.java
@@ -21,6 +21,7 @@ import com.vaadin.event.ConnectorEventListener;
import com.vaadin.event.MouseEvents.ClickEvent;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
+import com.vaadin.shared.ui.grid.renderers.ClickableRendererState;
import com.vaadin.shared.ui.grid.renderers.RendererClickRpc;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
@@ -159,4 +160,14 @@ public abstract class ClickableRenderer<T, V> extends AbstractRenderer<T, V> {
public void removeClickListener(RendererClickListener<T> listener) {
removeListener(RendererClickEvent.class, listener);
}
+
+ @Override
+ protected ClickableRendererState getState() {
+ return (ClickableRendererState) super.getState();
+ }
+
+ @Override
+ protected ClickableRendererState getState(boolean markAsDirty) {
+ return (ClickableRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/DateRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/DateRenderer.java
index 85f06697f0..484f88e882 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/DateRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/DateRenderer.java
@@ -19,6 +19,8 @@ import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
+import com.vaadin.shared.ui.grid.renderers.DateRendererState;
+
import elemental.json.JsonValue;
/**
@@ -235,4 +237,14 @@ public class DateRenderer extends AbstractRenderer<Object, Date> {
return String.format("%s [%s]", getClass().getSimpleName(), fieldInfo);
}
+
+ @Override
+ protected DateRendererState getState() {
+ return (DateRendererState) super.getState();
+ }
+
+ @Override
+ protected DateRendererState getState(boolean markAsDirty) {
+ return (DateRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/HtmlRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/HtmlRenderer.java
index c2571b5e3a..a1aa411bbe 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/HtmlRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/HtmlRenderer.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui.renderers;
+import com.vaadin.shared.ui.grid.renderers.HtmlRendererState;
+
/**
* A renderer for presenting HTML content.
*
@@ -43,4 +45,14 @@ public class HtmlRenderer extends AbstractRenderer<Object, String> {
public String getNullRepresentation() {
return super.getNullRepresentation();
}
+
+ @Override
+ protected HtmlRendererState getState() {
+ return (HtmlRendererState) super.getState();
+ }
+
+ @Override
+ protected HtmlRendererState getState(boolean markAsDirty) {
+ return (HtmlRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/ImageRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/ImageRenderer.java
index 2969d516b8..4af28cf5c1 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/ImageRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/ImageRenderer.java
@@ -20,6 +20,7 @@ import com.vaadin.server.Resource;
import com.vaadin.server.ResourceReference;
import com.vaadin.server.ThemeResource;
import com.vaadin.shared.communication.URLReference;
+import com.vaadin.shared.ui.grid.renderers.ImageRendererState;
import elemental.json.JsonValue;
@@ -68,4 +69,14 @@ public class ImageRenderer<T> extends ClickableRenderer<T, Resource> {
return encode(ResourceReference.create(resource, this, null),
URLReference.class);
}
+
+ @Override
+ protected ImageRendererState getState() {
+ return (ImageRendererState) super.getState();
+ }
+
+ @Override
+ protected ImageRendererState getState(boolean markAsDirty) {
+ return (ImageRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/NumberRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/NumberRenderer.java
index b5f64308bd..17730901ff 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/NumberRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/NumberRenderer.java
@@ -18,6 +18,8 @@ package com.vaadin.ui.renderers;
import java.text.NumberFormat;
import java.util.Locale;
+import com.vaadin.shared.ui.grid.renderers.NumberRendererState;
+
import elemental.json.JsonValue;
/**
@@ -202,4 +204,14 @@ public class NumberRenderer extends AbstractRenderer<Object, Number> {
public String getNullRepresentation() {
return super.getNullRepresentation();
}
+
+ @Override
+ protected NumberRendererState getState() {
+ return (NumberRendererState) super.getState();
+ }
+
+ @Override
+ protected NumberRendererState getState(boolean markAsDirty) {
+ return (NumberRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/ProgressBarRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/ProgressBarRenderer.java
index e06f98865d..bf851e5567 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/ProgressBarRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/ProgressBarRenderer.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui.renderers;
+import com.vaadin.shared.ui.grid.renderers.ProgressBarRendererState;
+
import elemental.json.JsonValue;
/**
@@ -42,4 +44,14 @@ public class ProgressBarRenderer extends AbstractRenderer<Object, Double> {
}
return super.encode(value);
}
+
+ @Override
+ protected ProgressBarRendererState getState() {
+ return (ProgressBarRendererState) super.getState();
+ }
+
+ @Override
+ protected ProgressBarRendererState getState(boolean markAsDirty) {
+ return (ProgressBarRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/main/java/com/vaadin/ui/renderers/TextRenderer.java b/server/src/main/java/com/vaadin/ui/renderers/TextRenderer.java
index d6cd527edf..b85e3230bc 100644
--- a/server/src/main/java/com/vaadin/ui/renderers/TextRenderer.java
+++ b/server/src/main/java/com/vaadin/ui/renderers/TextRenderer.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.ui.renderers;
+import com.vaadin.shared.ui.grid.renderers.TextRendererState;
+
/**
* A renderer for presenting simple plain-text string values.
*
@@ -44,4 +46,14 @@ public class TextRenderer extends AbstractRenderer<Object, String> {
public String getNullRepresentation() {
return super.getNullRepresentation();
}
+
+ @Override
+ protected TextRendererState getState() {
+ return (TextRendererState) super.getState();
+ }
+
+ @Override
+ protected TextRendererState getState(boolean markAsDirty) {
+ return (TextRendererState) super.getState(markAsDirty);
+ }
}
diff --git a/server/src/test/java/com/vaadin/server/DedicatedStateTest.java b/server/src/test/java/com/vaadin/server/DedicatedStateTest.java
new file mode 100644
index 0000000000..6d8fa485c6
--- /dev/null
+++ b/server/src/test/java/com/vaadin/server/DedicatedStateTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.server;
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.navigator.Navigator;
+import com.vaadin.tests.VaadinClasses;
+import com.vaadin.ui.LegacyWindow;
+import com.vaadin.ui.components.colorpicker.ColorPickerHistory;
+import com.vaadin.ui.components.colorpicker.ColorPickerPopup;
+import com.vaadin.ui.components.colorpicker.ColorPickerPreview;
+import com.vaadin.ui.components.colorpicker.ColorPickerSelect;
+import com.vaadin.ui.components.grid.NoSelectionModel;
+
+/**
+ * @author Vaadin Ltd
+ *
+ */
+public class DedicatedStateTest {
+
+ private static final Set<String> WHITE_LIST = createWhiteList();
+
+ @Test
+ public void checkDedicatedStates() {
+ VaadinClasses.getAllServerSideClasses().stream().filter(
+ clazz -> AbstractClientConnector.class.isAssignableFrom(clazz))
+ .forEach(this::checkState);
+ }
+
+ private void checkState(Class<?> clazz) {
+ if (WHITE_LIST.contains(clazz.getCanonicalName())) {
+ return;
+ }
+ Method getStateNoArg = getStateNoArg(clazz);
+ Class<?> stateType = getStateNoArg.getReturnType();
+ // check that stateType differs from the super class's state type
+ Class<?> superclass = clazz.getSuperclass();
+ if (!clazz.equals(AbstractClientConnector.class)
+ && !superclass.equals(AbstractExtension.class)) {
+ Assert.assertNotEquals(
+ "Class " + clazz
+ + " has the same state type as its super class "
+ + clazz.getSuperclass(),
+ stateType, getStateNoArg(superclass).getReturnType());
+ }
+ try {
+ Method getStateOneArg = clazz.getDeclaredMethod("getState",
+ boolean.class);
+ Assert.assertEquals(stateType, getStateOneArg.getReturnType());
+ } catch (NoSuchMethodException e) {
+ Assert.fail("Class " + clazz
+ + " doesn't have its own getState(boolean) method");
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Method getStateNoArg(Class<?> clazz) {
+ try {
+ return clazz.getDeclaredMethod("getState");
+ } catch (NoSuchMethodException e) {
+ Assert.fail("Class " + clazz
+ + " doesn't have its own getState() method");
+ return null;
+ } catch (SecurityException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Set<String> createWhiteList() {
+ Set<String> list = new HashSet<>();
+ list.add(AbstractExtension.class.getCanonicalName());
+ list.add(Navigator.EmptyView.class.getCanonicalName());
+ list.add(ColorPickerHistory.class.getCanonicalName());
+ list.add(ColorPickerPopup.class.getCanonicalName());
+ list.add(ColorPickerPreview.class.getCanonicalName());
+ list.add(ColorPickerSelect.class.getCanonicalName());
+ list.add(NoSelectionModel.class.getCanonicalName());
+ list.add(LegacyWindow.class.getCanonicalName());
+ return list;
+ }
+}