summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-07-01 13:32:29 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2014-07-01 13:33:21 +0300
commitb159b8bfe615b7fb273d652b9c9bbc9f04901873 (patch)
treed8c3b9b7ac5e31ac46d68895985014e443ba7572 /server
parentcad8f2bf2c02fbe2a6f406d51103909d78033c9d (diff)
parent264e617c58d537d12a03b5f3fb73f5129fcadc09 (diff)
downloadvaadin-framework-b159b8bfe615b7fb273d652b9c9bbc9f04901873.tar.gz
vaadin-framework-b159b8bfe615b7fb273d652b9c9bbc9f04901873.zip
Merge remote-tracking branch 'origin/master' into grid
Conflicts: WebContent/release-notes.html Change-Id: I515edf75b3ba2eb0bf94fa0d747cadbce2c79a21
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/AbstractClientConnector.java13
-rw-r--r--server/src/com/vaadin/server/AbstractErrorMessage.java2
-rw-r--r--server/src/com/vaadin/server/BrowserWindowOpener.java13
-rw-r--r--server/src/com/vaadin/server/Constants.java1
-rw-r--r--server/src/com/vaadin/server/DefaultDeploymentConfiguration.java23
-rw-r--r--server/src/com/vaadin/server/DeploymentConfiguration.java11
-rw-r--r--server/src/com/vaadin/server/FontAwesome.java3
-rw-r--r--server/src/com/vaadin/server/VaadinService.java2
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java36
-rw-r--r--server/src/com/vaadin/server/communication/ServerRpcHandler.java12
-rw-r--r--server/src/com/vaadin/server/communication/UidlWriter.java10
-rw-r--r--server/src/com/vaadin/ui/AbstractColorPicker.java9
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java6
-rw-r--r--server/src/com/vaadin/ui/AbstractEmbedded.java7
-rw-r--r--server/src/com/vaadin/ui/AbstractMedia.java17
-rw-r--r--server/src/com/vaadin/ui/AbstractOrderedLayout.java11
-rw-r--r--server/src/com/vaadin/ui/AbstractSplitPanel.java11
-rw-r--r--server/src/com/vaadin/ui/AbstractTextField.java11
-rw-r--r--server/src/com/vaadin/ui/Button.java13
-rw-r--r--server/src/com/vaadin/ui/ConnectorTracker.java17
-rw-r--r--server/src/com/vaadin/ui/CustomLayout.java11
-rw-r--r--server/src/com/vaadin/ui/DragAndDropWrapper.java7
-rw-r--r--server/src/com/vaadin/ui/Flash.java7
-rw-r--r--server/src/com/vaadin/ui/Form.java16
-rw-r--r--server/src/com/vaadin/ui/GridLayout.java151
-rw-r--r--server/src/com/vaadin/ui/Label.java14
-rw-r--r--server/src/com/vaadin/ui/MenuBar.java7
-rw-r--r--server/src/com/vaadin/ui/Panel.java11
-rw-r--r--server/src/com/vaadin/ui/PopupDateField.java9
-rw-r--r--server/src/com/vaadin/ui/PopupView.java16
-rw-r--r--server/src/com/vaadin/ui/Slider.java13
-rw-r--r--server/src/com/vaadin/ui/TextArea.java9
-rw-r--r--server/src/com/vaadin/ui/UI.java29
-rw-r--r--server/src/com/vaadin/ui/Window.java28
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java16
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java23
-rw-r--r--server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java15
-rw-r--r--server/src/com/vaadin/ui/themes/ValoTheme.java809
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirty.java100
-rw-r--r--server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java10
40 files changed, 1301 insertions, 228 deletions
diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java
index 92c235167c..bafecdabf4 100644
--- a/server/src/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/com/vaadin/server/AbstractClientConnector.java
@@ -243,7 +243,7 @@ public abstract class AbstractClientConnector implements ClientConnector,
@Override
public JSONObject encodeState() throws JSONException {
- return LegacyCommunicationManager.encodeState(this, getState());
+ return LegacyCommunicationManager.encodeState(this, getState(false));
}
/**
@@ -292,11 +292,13 @@ public abstract class AbstractClientConnector implements ClientConnector,
Method m = class1.getDeclaredMethod("getState",
(Class[]) null);
Class<?> type = m.getReturnType();
- return type.asSubclass(SharedState.class);
+ if (!m.isSynthetic()) {
+ return type.asSubclass(SharedState.class);
+ }
} catch (NoSuchMethodException nsme) {
- // Try in superclass instead
- class1 = class1.getSuperclass();
}
+ // Try in superclass instead
+ class1 = class1.getSuperclass();
}
throw new NoSuchMethodException(getClass().getCanonicalName()
+ ".getState()");
@@ -664,7 +666,8 @@ public abstract class AbstractClientConnector implements ClientConnector,
* @see #setResource(String, Resource)
*/
protected Resource getResource(String key) {
- return ResourceReference.getResource(getState().resources.get(key));
+ return ResourceReference
+ .getResource(getState(false).resources.get(key));
}
/**
diff --git a/server/src/com/vaadin/server/AbstractErrorMessage.java b/server/src/com/vaadin/server/AbstractErrorMessage.java
index c733cc493e..b56521993a 100644
--- a/server/src/com/vaadin/server/AbstractErrorMessage.java
+++ b/server/src/com/vaadin/server/AbstractErrorMessage.java
@@ -126,7 +126,7 @@ public abstract class AbstractErrorMessage implements ErrorMessage {
StringBuilder sb = new StringBuilder();
for (ErrorMessage cause : getCauses()) {
String childMessage = cause.getFormattedHtmlMessage();
- if (null != childMessage) {
+ if (null != childMessage && !childMessage.isEmpty()) {
sb.append("<div>");
sb.append(childMessage);
sb.append("</div>\n");
diff --git a/server/src/com/vaadin/server/BrowserWindowOpener.java b/server/src/com/vaadin/server/BrowserWindowOpener.java
index df03e76bcd..44679fbfbb 100644
--- a/server/src/com/vaadin/server/BrowserWindowOpener.java
+++ b/server/src/com/vaadin/server/BrowserWindowOpener.java
@@ -147,7 +147,7 @@ public class BrowserWindowOpener extends AbstractExtension {
* @return the window target string
*/
public String getWindowName() {
- return getState().target;
+ return getState(false).target;
}
// Avoid breaking url to multiple lines
@@ -171,7 +171,7 @@ public class BrowserWindowOpener extends AbstractExtension {
* @return
*/
public String getFeatures() {
- return getState().features;
+ return getState(false).features;
}
@Override
@@ -180,6 +180,11 @@ public class BrowserWindowOpener extends AbstractExtension {
}
@Override
+ protected BrowserWindowOpenerState getState(boolean markAsDirty) {
+ return (BrowserWindowOpenerState) super.getState(markAsDirty);
+ }
+
+ @Override
public void attach() {
super.attach();
if (uiProvider != null
@@ -226,7 +231,7 @@ public class BrowserWindowOpener extends AbstractExtension {
* @see #setUriFragment(String)
*/
public String getUriFragment() {
- return getState().uriFragment;
+ return getState(false).uriFragment;
}
/**
@@ -301,7 +306,7 @@ public class BrowserWindowOpener extends AbstractExtension {
if (name == null) {
throw new IllegalArgumentException("Null not allowed");
}
- return getState().parameters.get(name);
+ return getState(false).parameters.get(name);
}
}
diff --git a/server/src/com/vaadin/server/Constants.java b/server/src/com/vaadin/server/Constants.java
index 39329c32ce..34c9b5b767 100644
--- a/server/src/com/vaadin/server/Constants.java
+++ b/server/src/com/vaadin/server/Constants.java
@@ -126,6 +126,7 @@ public interface Constants {
static final String SERVLET_PARAMETER_PUSH_MODE = "pushMode";
static final String SERVLET_PARAMETER_UI_PROVIDER = "UIProvider";
static final String SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING = "legacyPropertyToString";
+ static final String SERVLET_PARAMETER_SYNC_ID_CHECK = "syncIdCheck";
// Configurable parameter names
static final String PARAMETER_VAADIN_RESOURCES = "Resources";
diff --git a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
index e72b411720..97790e7c0c 100644
--- a/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DefaultDeploymentConfiguration.java
@@ -51,6 +51,11 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
*/
public static final LegacyProperyToStringMode DEFAULT_LEGACY_PROPERTY_TO_STRING = LegacyProperyToStringMode.WARNING;
+ /**
+ * Default value for {@link #isSyncIdCheckEnabled()} = {@value} .
+ */
+ public static final boolean DEFAULT_SYNC_ID_CHECK = true;
+
private final Properties initParameters;
private boolean productionMode;
private boolean xsrfProtectionEnabled;
@@ -60,6 +65,7 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
private PushMode pushMode;
private final Class<?> systemPropertyBaseClass;
private LegacyProperyToStringMode legacyPropertyToStringMode;
+ private boolean syncIdCheck;
/**
* Create a new deployment configuration instance.
@@ -83,6 +89,7 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
checkCloseIdleSessions();
checkPushMode();
checkLegacyPropertyToString();
+ checkSyncIdCheck();
}
private void checkLegacyPropertyToString() {
@@ -238,6 +245,16 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
/**
* {@inheritDoc}
* <p>
+ * The default value is <code>true</code>.
+ */
+ @Override
+ public boolean isSyncIdCheckEnabled() {
+ return syncIdCheck;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
* The default mode is {@link PushMode#DISABLED}.
*/
@Override
@@ -321,6 +338,12 @@ public class DefaultDeploymentConfiguration implements DeploymentConfiguration {
}
}
+ private void checkSyncIdCheck() {
+ syncIdCheck = getApplicationOrSystemProperty(
+ Constants.SERVLET_PARAMETER_SYNC_ID_CHECK,
+ Boolean.toString(DEFAULT_SYNC_ID_CHECK)).equals("true");
+ }
+
private Logger getLogger() {
return Logger.getLogger(getClass().getName());
}
diff --git a/server/src/com/vaadin/server/DeploymentConfiguration.java b/server/src/com/vaadin/server/DeploymentConfiguration.java
index b600d01cbd..50d84812ea 100644
--- a/server/src/com/vaadin/server/DeploymentConfiguration.java
+++ b/server/src/com/vaadin/server/DeploymentConfiguration.java
@@ -85,6 +85,17 @@ public interface DeploymentConfiguration extends Serializable {
public boolean isXsrfProtectionEnabled();
/**
+ * Returns whether sync id checking is enabled. The sync id is used to
+ * gracefully handle situations when the client sends a message to a
+ * connector that has recently been removed on the server.
+ *
+ * @since
+ * @return <code>true</code> if sync id checking is enabled;
+ * <code>false</code> otherwise
+ */
+ public boolean isSyncIdCheckEnabled();
+
+ /**
* Returns the time resources can be cached in the browsers, in seconds.
*
* @return The resource cache time.
diff --git a/server/src/com/vaadin/server/FontAwesome.java b/server/src/com/vaadin/server/FontAwesome.java
index 71a2249dca..c99f42fac1 100644
--- a/server/src/com/vaadin/server/FontAwesome.java
+++ b/server/src/com/vaadin/server/FontAwesome.java
@@ -25,6 +25,9 @@ package com.vaadin.server;
* these icons, and all of them, so you might want to consider making a custom
* icon font - either to get other icons, or to minimize the size of the font.
* </p>
+ * <p>
+ * The Font Awesome version currently included is 4.0.3.
+ * </p>
*
* @since 7.2
* @author Vaadin Ltd
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 08bc6f5c79..e8cdcd7055 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -59,6 +59,7 @@ import com.vaadin.server.communication.HeartbeatHandler;
import com.vaadin.server.communication.PublishedFileHandler;
import com.vaadin.server.communication.SessionRequestHandler;
import com.vaadin.server.communication.UidlRequestHandler;
+import com.vaadin.shared.ApplicationConstants;
import com.vaadin.shared.JsonConstants;
import com.vaadin.shared.ui.ui.UIConstants;
import com.vaadin.ui.UI;
@@ -1590,6 +1591,7 @@ public abstract class VaadinService implements Serializable {
json.put("resources", new JSONObject());
json.put("locales", new JSONObject());
json.put("meta", meta);
+ json.put(ApplicationConstants.SERVER_SYNC_ID, -1);
returnString = json.toString();
} catch (JSONException e) {
getLogger().log(Level.WARNING,
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 81c3f374ea..12e7c28cd8 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -547,42 +547,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
return DEFAULT_THEME_NAME;
}
- private void handleServiceSecurityException(VaadinServletRequest request,
- VaadinServletResponse response) throws IOException,
- ServletException {
-
- try {
- /*
- * We might have a UI, but we don't want to leak any information in
- * this case so just use the info provided in the request.
- */
- SystemMessages ci = getService().getSystemMessages(
- request.getLocale(), request);
- if (ServletPortletHelper.isUIDLRequest(request)) {
- // send uidl redirect
- getService().writeStringResponse(
- response,
- JsonConstants.JSON_CONTENT_TYPE,
- VaadinService.createCriticalNotificationJSON(
- ci.getCommunicationErrorCaption(),
- ci.getCommunicationErrorMessage(),
- INVALID_SECURITY_KEY_MSG,
- ci.getCommunicationErrorURL()));
- } else if (ServletPortletHelper.isHeartbeatRequest(request)) {
- response.sendError(HttpServletResponse.SC_FORBIDDEN,
- "Forbidden");
- } else {
- // 'plain' http req - e.g. browser reload;
- // just go ahead redirect the browser
- response.sendRedirect(ci.getCommunicationErrorURL());
- }
- } catch (SystemMessageException ee) {
- throw new ServletException(ee);
- }
-
- log("Invalid security key received from " + request.getRemoteHost());
- }
-
/**
* Check if this is a request for a static resource and, if it is, serve the
* resource to the client.
diff --git a/server/src/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
index 89d87567d7..36bfc8bcc6 100644
--- a/server/src/com/vaadin/server/communication/ServerRpcHandler.java
+++ b/server/src/com/vaadin/server/communication/ServerRpcHandler.java
@@ -75,10 +75,16 @@ public class ServerRpcHandler implements Serializable {
private final int syncId;
private final JSONObject json;
- public RpcRequest(String jsonString) throws JSONException {
+ public RpcRequest(String jsonString, VaadinRequest request)
+ throws JSONException {
json = new JSONObject(jsonString);
csrfToken = json.getString(ApplicationConstants.CSRF_TOKEN);
- syncId = json.getInt(ApplicationConstants.SERVER_SYNC_ID);
+ if (request.getService().getDeploymentConfiguration()
+ .isSyncIdCheckEnabled()) {
+ syncId = json.getInt(ApplicationConstants.SERVER_SYNC_ID);
+ } else {
+ syncId = -1;
+ }
invocations = new JSONArray(
json.getString(ApplicationConstants.RPC_INVOCATIONS));
}
@@ -157,7 +163,7 @@ public class ServerRpcHandler implements Serializable {
return;
}
- RpcRequest rpcRequest = new RpcRequest(changeMessage);
+ RpcRequest rpcRequest = new RpcRequest(changeMessage, request);
// Security: double cookie submission pattern unless disabled by
// property
diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java
index 00522e2aa5..9d55f7e197 100644
--- a/server/src/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/com/vaadin/server/communication/UidlWriter.java
@@ -37,6 +37,7 @@ import com.vaadin.server.JsonPaintTarget;
import com.vaadin.server.LegacyCommunicationManager;
import com.vaadin.server.LegacyCommunicationManager.ClientCache;
import com.vaadin.server.SystemMessages;
+import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.ApplicationConstants;
import com.vaadin.ui.ConnectorTracker;
@@ -75,10 +76,11 @@ public class UidlWriter implements Serializable {
public void write(UI ui, Writer writer, boolean repaintAll, boolean async)
throws IOException, JSONException {
VaadinSession session = ui.getSession();
+ VaadinService service = session.getService();
// Purge pending access calls as they might produce additional changes
// to write out
- session.getService().runPendingAccessTasks(session);
+ service.runPendingAccessTasks(session);
ArrayList<ClientConnector> dirtyVisibleConnectors = ui
.getConnectorTracker().getDirtyVisibleConnectors();
@@ -99,8 +101,12 @@ public class UidlWriter implements Serializable {
uiConnectorTracker.setWritingResponse(true);
try {
+
+ int syncId = service.getDeploymentConfiguration()
+ .isSyncIdCheckEnabled() ? uiConnectorTracker
+ .getCurrentSyncId() : -1;
writer.write("\"" + ApplicationConstants.SERVER_SYNC_ID + "\": "
- + uiConnectorTracker.getCurrentSyncId() + ", ");
+ + syncId + ", ");
writer.write("\"changes\" : ");
diff --git a/server/src/com/vaadin/ui/AbstractColorPicker.java b/server/src/com/vaadin/ui/AbstractColorPicker.java
index db4239f8a6..acf3b2c042 100644
--- a/server/src/com/vaadin/ui/AbstractColorPicker.java
+++ b/server/src/com/vaadin/ui/AbstractColorPicker.java
@@ -189,7 +189,7 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
* currently selected color, e.g. #ffffff) if no other caption is available.
*/
public boolean isDefaultCaptionEnabled() {
- return getState().showDefaultCaption;
+ return getState(false).showDefaultCaption;
}
/**
@@ -358,6 +358,11 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
return (ColorPickerState) super.getState();
}
+ @Override
+ protected ColorPickerState getState(boolean markAsDirty) {
+ return (ColorPickerState) super.getState(markAsDirty);
+ }
+
/**
* Sets the default styles of the component
*
@@ -462,6 +467,6 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
* <code>false</code> otherwise
*/
public boolean isHtmlContentAllowed() {
- return getState().htmlContentAllowed;
+ return getState(false).htmlContentAllowed;
}
}
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index b6289e0b7d..9dbd9a093d 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -151,8 +151,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public String getStyleName() {
String s = "";
- if (ComponentStateUtil.hasStyles(getState())) {
- for (final Iterator<String> it = getState().styles.iterator(); it
+ if (ComponentStateUtil.hasStyles(getState(false))) {
+ for (final Iterator<String> it = getState(false).styles.iterator(); it
.hasNext();) {
s += it.next();
if (it.hasNext()) {
@@ -191,7 +191,7 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public String getPrimaryStyleName() {
- return getState().primaryStyleName;
+ return getState(false).primaryStyleName;
}
@Override
diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java
index 8c574fd59e..66752aa5d7 100644
--- a/server/src/com/vaadin/ui/AbstractEmbedded.java
+++ b/server/src/com/vaadin/ui/AbstractEmbedded.java
@@ -34,6 +34,11 @@ public abstract class AbstractEmbedded extends AbstractComponent {
return (AbstractEmbeddedState) super.getState();
}
+ @Override
+ protected AbstractEmbeddedState getState(boolean markAsDirty) {
+ return (AbstractEmbeddedState) super.getState(markAsDirty);
+ }
+
/**
* Sets the object source resource. The dimensions are assumed if possible.
* The type is guessed from resource.
@@ -73,7 +78,7 @@ public abstract class AbstractEmbedded extends AbstractComponent {
* @returns Alternate text
*/
public String getAlternateText() {
- return getState().alternateText;
+ return getState(false).alternateText;
}
}
diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java
index a841aa672e..0bd8c3ea77 100644
--- a/server/src/com/vaadin/ui/AbstractMedia.java
+++ b/server/src/com/vaadin/ui/AbstractMedia.java
@@ -47,6 +47,11 @@ public abstract class AbstractMedia extends AbstractComponent {
return (AbstractMediaState) super.getState();
}
+ @Override
+ protected AbstractMediaState getState(boolean markAsDirty) {
+ return (AbstractMediaState) super.getState(markAsDirty);
+ }
+
/**
* Sets a single media file as the source of the media component.
*
@@ -141,7 +146,7 @@ public abstract class AbstractMedia extends AbstractComponent {
*/
public List<Resource> getSources() {
ArrayList<Resource> sources = new ArrayList<Resource>();
- for (URLReference ref : getState().sources) {
+ for (URLReference ref : getState(false).sources) {
sources.add(((ResourceReference) ref).getResource());
}
return sources;
@@ -160,7 +165,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @return true if the browser is to show native media controls.
*/
public boolean isShowControls() {
- return getState().showControls;
+ return getState(false).showControls;
}
/**
@@ -183,7 +188,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* HTML5.
*/
public String getAltText() {
- return getState().altText;
+ return getState(false).altText;
}
/**
@@ -201,7 +206,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* be rendered as HTML.
*/
public boolean isHtmlContentAllowed() {
- return getState().htmlContentAllowed;
+ return getState(false).htmlContentAllowed;
}
/**
@@ -218,7 +223,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @return true if the media is set to automatically start playback.
*/
public boolean isAutoplay() {
- return getState().autoplay;
+ return getState(false).autoplay;
}
/**
@@ -234,7 +239,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @return true if the audio is muted.
*/
public boolean isMuted() {
- return getState().muted;
+ return getState(false).muted;
}
/**
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
index 039c87333e..27880db75f 100644
--- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -69,6 +69,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
return (AbstractOrderedLayoutState) super.getState();
}
+ @Override
+ protected AbstractOrderedLayoutState getState(boolean markAsDirty) {
+ return (AbstractOrderedLayoutState) super.getState(markAsDirty);
+ }
+
/**
* Add a component into this container. The component is added to the right
* or under the previous component.
@@ -285,7 +290,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public boolean isSpacing() {
- return getState().spacing;
+ return getState(false).spacing;
}
/**
@@ -335,7 +340,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
* @return expand ratio of given component, 0.0f by default.
*/
public float getExpandRatio(Component component) {
- ChildComponentData childData = getState().childData.get(component);
+ ChildComponentData childData = getState(false).childData.get(component);
if (childData == null) {
throw new IllegalArgumentException(
"The given component is not a child of this layout");
@@ -413,7 +418,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public MarginInfo getMargin() {
- return new MarginInfo(getState().marginsBitmask);
+ return new MarginInfo(getState(false).marginsBitmask);
}
/*
diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java
index 3a1b7ca35a..1c69ebf87e 100644
--- a/server/src/com/vaadin/ui/AbstractSplitPanel.java
+++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java
@@ -186,7 +186,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the first component of this split panel
*/
public Component getFirstComponent() {
- return (Component) getState().firstChild;
+ return (Component) getState(false).firstChild;
}
/**
@@ -196,7 +196,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the second component of this split panel
*/
public Component getSecondComponent() {
- return (Component) getState().secondChild;
+ return (Component) getState(false).secondChild;
}
/**
@@ -534,7 +534,12 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
return (AbstractSplitPanelState) super.getState();
}
+ @Override
+ protected AbstractSplitPanelState getState(boolean markAsDirty) {
+ return (AbstractSplitPanelState) super.getState(markAsDirty);
+ }
+
private SplitterState getSplitterState() {
- return getState().splitterState;
+ return getState(false).splitterState;
}
}
diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java
index 25b34ae19f..e0318ddf2b 100644
--- a/server/src/com/vaadin/ui/AbstractTextField.java
+++ b/server/src/com/vaadin/ui/AbstractTextField.java
@@ -96,6 +96,11 @@ public abstract class AbstractTextField extends AbstractField<String> implements
}
@Override
+ protected AbstractTextFieldState getState(boolean markAsDirty) {
+ return (AbstractTextFieldState) super.getState(markAsDirty);
+ }
+
+ @Override
public void beforeClientResponse(boolean initial) {
super.beforeClientResponse(initial);
@@ -311,7 +316,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the maxLength
*/
public int getMaxLength() {
- return getState().maxLength;
+ return getState(false).maxLength;
}
/**
@@ -333,7 +338,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the number of columns in the editor.
*/
public int getColumns() {
- return getState().columns;
+ return getState(false).columns;
}
/**
@@ -358,7 +363,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the current input prompt, or null if not enabled
*/
public String getInputPrompt() {
- return getState().inputPrompt;
+ return getState(false).inputPrompt;
}
/**
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index 5a5d03a3ee..58b6f9de81 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -556,7 +556,7 @@ public class Button extends AbstractComponent implements
* @return true if the button is disabled when clicked, false otherwise
*/
public boolean isDisableOnClick() {
- return getState().disableOnClick;
+ return getState(false).disableOnClick;
}
/**
@@ -582,7 +582,7 @@ public class Button extends AbstractComponent implements
*/
@Override
public int getTabIndex() {
- return getState().tabIndex;
+ return getState(false).tabIndex;
}
/*
@@ -606,6 +606,11 @@ public class Button extends AbstractComponent implements
return (ButtonState) super.getState();
}
+ @Override
+ protected ButtonState getState(boolean markAsDirty) {
+ return (ButtonState) super.getState(markAsDirty);
+ }
+
/**
* Sets the component's icon and alt text.
*
@@ -628,7 +633,7 @@ public class Button extends AbstractComponent implements
* @return String with the alt text
*/
public String getIconAlternateText() {
- return getState().iconAltText;
+ return getState(false).iconAltText;
}
public void setIconAlternateText(String iconAltText) {
@@ -658,7 +663,7 @@ public class Button extends AbstractComponent implements
* <code>false</code> otherwise
*/
public boolean isHtmlContentAllowed() {
- return getState().htmlContentAllowed;
+ return getState(false).htmlContentAllowed;
}
}
diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java
index f7eae0013a..c0f973106b 100644
--- a/server/src/com/vaadin/ui/ConnectorTracker.java
+++ b/server/src/com/vaadin/ui/ConnectorTracker.java
@@ -774,7 +774,7 @@ public class ConnectorTracker implements Serializable {
* concurrently or not.
* @param lastSyncIdSeenByClient
* the most recent sync id the client has seen at the time the
- * request was sent
+ * request was sent, or -1 to ignore potential problems
* @return <code>true</code> if the connector was removed before the client
* had a chance to react to it.
*/
@@ -784,7 +784,8 @@ public class ConnectorTracker implements Serializable {
assert getConnector(connectorId) == null : "Connector " + connectorId
+ " is still attached";
- boolean clientRequestIsTooOld = lastSyncIdSeenByClient < currentSyncId;
+ boolean clientRequestIsTooOld = lastSyncIdSeenByClient < currentSyncId
+ && lastSyncIdSeenByClient != -1;
if (clientRequestIsTooOld) {
/*
* The headMap call is present here because we're only interested in
@@ -823,6 +824,9 @@ public class ConnectorTracker implements Serializable {
* packet is sent. If the state has changed on the server side since that,
* the server can try to adjust the way it handles the actions from the
* client side.
+ * <p>
+ * The sync id value <code>-1</code> is ignored to facilitate testing with
+ * pre-recorded requests.
*
* @see #setWritingResponse(boolean)
* @see #connectorWasPresentAsRequestWasSent(String, long)
@@ -846,6 +850,9 @@ public class ConnectorTracker implements Serializable {
* Entries that both client and server agree upon are removed. Since
* argument is the last sync id that the client has seen from the server, we
* know that entries earlier than that cannot cause any problems anymore.
+ * <p>
+ * The sync id value <code>-1</code> is ignored to facilitate testing with
+ * pre-recorded requests.
*
* @see #connectorWasPresentAsRequestWasSent(String, long)
* @since 7.2
@@ -854,6 +861,12 @@ public class ConnectorTracker implements Serializable {
* server.
*/
public void cleanConcurrentlyRemovedConnectorIds(int lastSyncIdSeenByClient) {
+ if (lastSyncIdSeenByClient == -1) {
+ // Sync id checking is not in use, so we should just clear the
+ // entire map to avoid leaking memory
+ syncIdToUnregisteredConnectorIds.clear();
+ return;
+ }
/*
* We remove all entries _older_ than the one reported right now,
* because the remaining still contain components that might cause
diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java
index fd56ed9219..7f1aa1ce46 100644
--- a/server/src/com/vaadin/ui/CustomLayout.java
+++ b/server/src/com/vaadin/ui/CustomLayout.java
@@ -124,6 +124,11 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
return (CustomLayoutState) super.getState();
}
+ @Override
+ protected CustomLayoutState getState(boolean markAsDirty) {
+ return (CustomLayoutState) super.getState(markAsDirty);
+ }
+
/**
* Adds the component into this container to given location. If the location
* is already populated, the old component is removed.
@@ -251,12 +256,12 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
/** Get the name of the template */
public String getTemplateName() {
- return getState().templateName;
+ return getState(false).templateName;
}
/** Get the contents of the template */
public String getTemplateContents() {
- return getState().templateContents;
+ return getState(false).templateContents;
}
/**
@@ -292,7 +297,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
public void paintContent(PaintTarget target) throws PaintException {
// Workaround to make the CommunicationManager read the template file
// and send it to the client
- String templateName = getState().templateName;
+ String templateName = getState(false).templateName;
if (templateName != null && templateName.length() != 0) {
Set<Object> usedResources = ((JsonPaintTarget) target)
.getUsedResources();
diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java
index cb94a774a5..3d3356b338 100644
--- a/server/src/com/vaadin/ui/DragAndDropWrapper.java
+++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java
@@ -187,6 +187,10 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
private Set<String> sentIds = new HashSet<String>();
+ private DragAndDropWrapper() {
+ super();
+ }
+
/**
* Wraps given component in a {@link DragAndDropWrapper}.
*
@@ -194,7 +198,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget,
* the component to be wrapped
*/
public DragAndDropWrapper(Component root) {
- super(root);
+ this();
+ setCompositionRoot(root);
}
/**
diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java
index 791202f4a9..bbbd4e3285 100644
--- a/server/src/com/vaadin/ui/Flash.java
+++ b/server/src/com/vaadin/ui/Flash.java
@@ -67,6 +67,11 @@ public class Flash extends AbstractEmbedded {
return (FlashState) super.getState();
}
+ @Override
+ protected FlashState getState(boolean markAsDirty) {
+ return (FlashState) super.getState(markAsDirty);
+ }
+
/**
* This attribute specifies the base path used to resolve relative URIs
* specified by the classid, data, and archive attributes. When absent, its
@@ -156,7 +161,7 @@ public class Flash extends AbstractEmbedded {
* @return the Value of parameter or null if not found.
*/
public String getParameter(String name) {
- return getState().embedParams != null ? getState().embedParams
+ return getState(false).embedParams != null ? getState(false).embedParams
.get(name) : null;
}
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 5653a83cee..391ee45536 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -198,6 +198,11 @@ public class Form extends AbstractField<Object> implements Item.Editor,
return (FormState) super.getState();
}
+ @Override
+ protected FormState getState(boolean markAsDirty) {
+ return (FormState) super.getState(markAsDirty);
+ }
+
/* Documented in interface */
@Override
public void paintContent(PaintTarget target) throws PaintException {
@@ -775,7 +780,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
* @return the Layout of the form.
*/
public Layout getLayout() {
- return (Layout) getState().layout;
+ return (Layout) getState(false).layout;
}
/**
@@ -1054,8 +1059,9 @@ public class Form extends AbstractField<Object> implements Item.Editor,
* @return the Field.
*/
private Field<?> getFirstFocusableField() {
- if (getItemPropertyIds() != null) {
- for (Object id : getItemPropertyIds()) {
+ Collection<?> itemPropertyIds = getItemPropertyIds();
+ if (itemPropertyIds != null && itemPropertyIds.size() > 0) {
+ for (Object id : itemPropertyIds) {
if (id != null) {
Field<?> field = getField(id);
if (field.isEnabled() && !field.isReadOnly()) {
@@ -1065,7 +1071,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
}
// fallback: first field if none of the fields is enabled and
// writable
- Object id = getItemPropertyIds().iterator().next();
+ Object id = itemPropertyIds.iterator().next();
if (id != null) {
return getField(id);
}
@@ -1214,7 +1220,7 @@ public class Form extends AbstractField<Object> implements Item.Editor,
* is used
*/
public Layout getFooter() {
- return (Layout) getState().footer;
+ return (Layout) getState(false).footer;
}
/**
diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java
index 989f5efdea..0c097abc83 100644
--- a/server/src/com/vaadin/ui/GridLayout.java
+++ b/server/src/com/vaadin/ui/GridLayout.java
@@ -39,12 +39,12 @@ import com.vaadin.shared.ui.gridlayout.GridLayoutState.ChildComponentData;
/**
* A layout where the components are laid out on a grid using cell coordinates.
- *
+ *
* <p>
* The GridLayout also maintains a cursor for adding components in
* left-to-right, top-to-bottom order.
* </p>
- *
+ *
* <p>
* Each component in a <code>GridLayout</code> uses a defined
* {@link GridLayout.Area area} (column1,row1,column2,row2) from the grid. The
@@ -52,12 +52,12 @@ import com.vaadin.shared.ui.gridlayout.GridLayoutState.ChildComponentData;
* you will get an {@link OverlapsException}. Adding a component with cursor
* automatically extends the grid by increasing the grid height.
* </p>
- *
+ *
* <p>
* The grid coordinates, which are specified by a row and column index, always
* start from 0 for the topmost row and the leftmost column.
* </p>
- *
+ *
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -96,10 +96,10 @@ public class GridLayout extends AbstractLayout implements
/**
* Constructor for a grid of given size (number of columns and rows).
- *
+ *
* The grid may grow or shrink later. Grid grows automatically if you add
* components outside its area.
- *
+ *
* @param columns
* Number of columns in the grid.
* @param rows
@@ -121,9 +121,9 @@ public class GridLayout extends AbstractLayout implements
/**
* Constructs a GridLayout of given size (number of columns and rows) and
* adds the given components in order to the grid.
- *
+ *
* @see #addComponents(Component...)
- *
+ *
* @param columns
* Number of columns in the grid.
* @param rows
@@ -141,19 +141,24 @@ public class GridLayout extends AbstractLayout implements
return (GridLayoutState) super.getState();
}
+ @Override
+ protected GridLayoutState getState(boolean markAsDirty) {
+ return (GridLayoutState) super.getState(markAsDirty);
+ }
+
/**
* <p>
* Adds a component to the grid in the specified area. The area is defined
* by specifying the upper left corner (column1, row1) and the lower right
* corner (column2, row2) of the area. The coordinates are zero-based.
* </p>
- *
+ *
* <p>
* If the area overlaps with any of the existing components already present
* in the grid, the operation will fail and an {@link OverlapsException} is
* thrown.
* </p>
- *
+ *
* @param component
* the component to be added, not <code>null</code>.
* @param column1
@@ -257,7 +262,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Tests if the given area overlaps with any of the items already on the
* grid.
- *
+ *
* @param area
* the Area to be checked for overlapping.
* @throws OverlapsException
@@ -279,7 +284,7 @@ public class GridLayout extends AbstractLayout implements
* the area.) End coordinates (SouthEast corner of the area) are the same as
* column1,row1. The coordinates are zero-based. Component width and height
* is 1.
- *
+ *
* @param component
* the component to be added, not <code>null</code>.
* @param column
@@ -299,16 +304,16 @@ public class GridLayout extends AbstractLayout implements
/**
* Forces the next component to be added at the beginning of the next line.
- *
+ *
* <p>
* Sets the cursor column to 0 and increments the cursor row by one.
* </p>
- *
+ *
* <p>
* By calling this function you can ensure that no more components are added
* right of the previous component.
* </p>
- *
+ *
* @see #space()
*/
public void newLine() {
@@ -319,7 +324,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Moves the cursor forward by one. If the cursor goes out of the right grid
* border, it is moved to the first column of the next row.
- *
+ *
* @see #newLine()
*/
public void space() {
@@ -335,7 +340,7 @@ public class GridLayout extends AbstractLayout implements
* cursor position is already occupied, the cursor is moved forwards to find
* free position. If the cursor goes out from the bottom of the grid, the
* grid is automatically extended.
- *
+ *
* @param component
* the component to be added, not <code>null</code>.
*/
@@ -371,7 +376,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Removes the specified component from the layout.
- *
+ *
* @param component
* the component to be removed.
*/
@@ -391,7 +396,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Removes the component specified by its cell coordinates.
- *
+ *
* @param column
* the component's column, starting from 0.
* @param row
@@ -414,7 +419,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets an Iterator for the components contained in the layout. By using the
* Iterator it is possible to step through the contents of the layout.
- *
+ *
* @return the Iterator of the components inside the layout.
*/
@Override
@@ -425,7 +430,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the number of components contained in the layout. Consistent with
* the iterator returned by {@link #getComponentIterator()}.
- *
+ *
* @return the number of contained components
*/
@Override
@@ -440,7 +445,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Paints the contents of this component.
- *
+ *
* @param target
* the Paint Event.
* @throws PaintException
@@ -519,7 +524,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public Alignment getComponentAlignment(Component childComponent) {
- ChildComponentData childComponentData = getState().childData
+ ChildComponentData childComponentData = getState(false).childData
.get(childComponent);
if (childComponentData == null) {
throw new IllegalArgumentException(
@@ -531,17 +536,17 @@ public class GridLayout extends AbstractLayout implements
/**
* Defines a rectangular area of cells in a GridLayout.
- *
+ *
* <p>
* Also maintains a reference to the component contained in the area.
* </p>
- *
+ *
* <p>
* The area is specified by the cell coordinates of its upper left corner
* (column1,row1) and lower right corner (column2,row2). As otherwise with
* GridLayout, the column and row coordinates start from zero.
* </p>
- *
+ *
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -553,7 +558,7 @@ public class GridLayout extends AbstractLayout implements
* <p>
* Construct a new area on a grid.
* </p>
- *
+ *
* @param component
* the component connected to the area.
* @param column1
@@ -587,7 +592,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Tests if this Area overlaps with another Area.
- *
+ *
* @param other
* the other Area that is to be tested for overlap with this
* area
@@ -600,7 +605,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the component connected to the area.
- *
+ *
* @return the Component.
*/
public Component getComponent() {
@@ -609,7 +614,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the column of the top-left corner cell.
- *
+ *
* @return the column of the top-left corner cell.
*/
public int getColumn1() {
@@ -618,7 +623,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the column of the bottom-right corner cell.
- *
+ *
* @return the column of the bottom-right corner cell.
*/
public int getColumn2() {
@@ -627,7 +632,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the row of the top-left corner cell.
- *
+ *
* @return the row of the top-left corner cell.
*/
public int getRow1() {
@@ -636,7 +641,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the row of the bottom-right corner cell.
- *
+ *
* @return the row of the bottom-right corner cell.
*/
public int getRow2() {
@@ -655,7 +660,7 @@ public class GridLayout extends AbstractLayout implements
* Gridlayout does not support laying components on top of each other. An
* <code>OverlapsException</code> is thrown when a component already exists
* (even partly) at the same space on a grid with the new component.
- *
+ *
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -665,7 +670,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Constructs an <code>OverlapsException</code>.
- *
+ *
* @param existingArea
*/
public OverlapsException(Area existingArea) {
@@ -700,7 +705,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the area .
- *
+ *
* @return the existing area.
*/
public Area getArea() {
@@ -711,7 +716,7 @@ public class GridLayout extends AbstractLayout implements
/**
* An <code>Exception</code> object which is thrown when an area exceeds the
* bounds of the grid.
- *
+ *
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -722,7 +727,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Constructs an <code>OoutOfBoundsException</code> with the specified
* detail message.
- *
+ *
* @param areaOutOfBounds
*/
public OutOfBoundsException(Area areaOutOfBounds) {
@@ -731,7 +736,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the area that is out of bounds.
- *
+ *
* @return the area out of Bound.
*/
public Area getArea() {
@@ -742,7 +747,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Sets the number of columns in the grid. The column count can not be
* reduced if there are any areas that would be outside of the shrunk grid.
- *
+ *
* @param columns
* the new number of columns in the grid.
*/
@@ -776,17 +781,17 @@ public class GridLayout extends AbstractLayout implements
/**
* Get the number of columns in the grid.
- *
+ *
* @return the number of columns in the grid.
*/
public int getColumns() {
- return getState().columns;
+ return getState(false).columns;
}
/**
* Sets the number of rows in the grid. The number of rows can not be
* reduced if there are any areas that would be outside of the shrunk grid.
- *
+ *
* @param rows
* the new number of rows in the grid.
*/
@@ -820,23 +825,23 @@ public class GridLayout extends AbstractLayout implements
/**
* Get the number of rows in the grid.
- *
+ *
* @return the number of rows in the grid.
*/
public int getRows() {
- return getState().rows;
+ return getState(false).rows;
}
/**
* Gets the current x-position (column) of the cursor.
- *
+ *
* <p>
* The cursor position points the position for the next component that is
* added without specifying its coordinates (grid cell). When the cursor
* position is occupied, the next component will be added to first free
* position after the cursor.
* </p>
- *
+ *
* @return the grid column the cursor is on, starting from 0.
*/
public int getCursorX() {
@@ -846,7 +851,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Sets the current cursor x-position. This is usually handled automatically
* by GridLayout.
- *
+ *
* @param cursorX
*/
public void setCursorX(int cursorX) {
@@ -855,14 +860,14 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the current y-position (row) of the cursor.
- *
+ *
* <p>
* The cursor position points the position for the next component that is
* added without specifying its coordinates (grid cell). When the cursor
* position is occupied, the next component will be added to the first free
* position after the cursor.
* </p>
- *
+ *
* @return the grid row the Cursor is on.
*/
public int getCursorY() {
@@ -872,7 +877,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Sets the current y-coordinate (row) of the cursor. This is usually
* handled automatically by GridLayout.
- *
+ *
* @param cursorY
* the row number, starting from 0 for the topmost row.
*/
@@ -951,12 +956,12 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public boolean isSpacing() {
- return getState().spacing;
+ return getState(false).spacing;
}
/**
* Inserts an empty row at the specified position in the grid.
- *
+ *
* @param row
* Index of the row before which the new row will be inserted.
* The leftmost row has index 0.
@@ -990,18 +995,18 @@ public class GridLayout extends AbstractLayout implements
/**
* Removes a row and all the components in the row.
- *
+ *
* <p>
* Components which span over several rows are removed if the selected row
* is on the first row of such a component.
* </p>
- *
+ *
* <p>
* If the last row is removed then all remaining components will be removed
* and the grid will be reduced to one row. The cursor will be moved to the
* upper left cell of the grid.
* </p>
- *
+ *
* @param row
* Index of the row to remove. The leftmost row has index 0.
*/
@@ -1048,20 +1053,20 @@ public class GridLayout extends AbstractLayout implements
/**
* Sets the expand ratio of given column.
- *
+ *
* <p>
* The expand ratio defines how excess space is distributed among columns.
* Excess space means space that is left over from components that are not
* sized relatively. By default, the excess space is distributed evenly.
* </p>
- *
+ *
* <p>
* Note that the component width of the GridLayout must be defined (fixed or
* relative, as opposed to undefined) for this method to have any effect.
* </p>
- *
+ *
* @see #setWidth(float, int)
- *
+ *
* @param columnIndex
* @param ratio
*/
@@ -1073,9 +1078,9 @@ public class GridLayout extends AbstractLayout implements
/**
* Returns the expand ratio of given column
- *
+ *
* @see #setColumnExpandRatio(int, float)
- *
+ *
* @param columnIndex
* @return the expand ratio, 0.0f by default
*/
@@ -1086,20 +1091,20 @@ public class GridLayout extends AbstractLayout implements
/**
* Sets the expand ratio of given row.
- *
+ *
* <p>
* Expand ratio defines how excess space is distributed among rows. Excess
* space means the space left over from components that are not sized
* relatively. By default, the excess space is distributed evenly.
* </p>
- *
+ *
* <p>
* Note, that height needs to be defined (fixed or relative, as opposed to
* undefined height) for this method to have any effect.
* </p>
- *
+ *
* @see #setHeight(float, int)
- *
+ *
* @param rowIndex
* The row index, starting from 0 for the topmost row.
* @param ratio
@@ -1112,9 +1117,9 @@ public class GridLayout extends AbstractLayout implements
/**
* Returns the expand ratio of given row.
- *
+ *
* @see #setRowExpandRatio(int, float)
- *
+ *
* @param rowIndex
* The row index, starting from 0 for the topmost row.
* @return the expand ratio, 0.0f by default
@@ -1126,7 +1131,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the Component at given index.
- *
+ *
* @param x
* The column index, starting from 0 for the leftmost column.
* @param y
@@ -1134,7 +1139,7 @@ public class GridLayout extends AbstractLayout implements
* @return Component in given cell or null if empty
*/
public Component getComponent(int x, int y) {
- for (Entry<Connector, ChildComponentData> entry : getState().childData
+ for (Entry<Connector, ChildComponentData> entry : getState(false).childData
.entrySet()) {
ChildComponentData childData = entry.getValue();
if (childData.column1 <= x && x <= childData.column2
@@ -1148,14 +1153,14 @@ public class GridLayout extends AbstractLayout implements
/**
* Returns information about the area where given component is laid in the
* GridLayout.
- *
+ *
* @param component
* the component whose area information is requested.
* @return an Area object that contains information how component is laid in
* the grid
*/
public Area getComponentArea(Component component) {
- ChildComponentData childComponentData = getState().childData
+ ChildComponentData childComponentData = getState(false).childData
.get(component);
if (childComponentData == null) {
return null;
@@ -1226,7 +1231,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public MarginInfo getMargin() {
- return new MarginInfo(getState().marginsBitmask);
+ return new MarginInfo(getState(false).marginsBitmask);
}
/*
diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java
index b4685adcea..c73840e6e9 100644
--- a/server/src/com/vaadin/ui/Label.java
+++ b/server/src/com/vaadin/ui/Label.java
@@ -155,6 +155,11 @@ public class Label extends AbstractComponent implements Property<String>,
return (LabelState) super.getState();
}
+ @Override
+ protected LabelState getState(boolean markAsDirty) {
+ return (LabelState) super.getState(markAsDirty);
+ }
+
/**
* Gets the value of the label.
* <p>
@@ -168,7 +173,7 @@ public class Label extends AbstractComponent implements Property<String>,
public String getValue() {
if (getPropertyDataSource() == null) {
// Use internal value if we are running without a data source
- return getState().text;
+ return getState(false).text;
}
return getDataSourceValue();
}
@@ -196,7 +201,7 @@ public class Label extends AbstractComponent implements Property<String>,
public void setValue(String newStringValue) {
if (getPropertyDataSource() == null) {
- LabelState state = (LabelState) getState(false);
+ LabelState state = getState(false);
String oldTextValue = state.text;
if (!SharedUtil.equals(oldTextValue, newStringValue)) {
getState().text = newStringValue;
@@ -281,7 +286,7 @@ public class Label extends AbstractComponent implements Property<String>,
* @see ContentMode
*/
public ContentMode getContentMode() {
- return getState().contentMode;
+ return getState(false).contentMode;
}
/**
@@ -412,8 +417,7 @@ public class Label extends AbstractComponent implements Property<String>,
private void updateValueFromDataSource() {
// Update the internal value from the data source
String newConvertedValue = getDataSourceValue();
- if (!SharedUtil.equals(newConvertedValue,
- ((LabelState) getState(false)).text)) {
+ if (!SharedUtil.equals(newConvertedValue, getState(false).text)) {
getState().text = newConvertedValue;
fireValueChange();
}
diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java
index 17a2f8e391..6b6555c0a2 100644
--- a/server/src/com/vaadin/ui/MenuBar.java
+++ b/server/src/com/vaadin/ui/MenuBar.java
@@ -57,6 +57,11 @@ public class MenuBar extends AbstractComponent implements LegacyComponent,
return (MenuBarState) super.getState();
}
+ @Override
+ protected MenuBarState getState(boolean markAsDirty) {
+ return (MenuBarState) super.getState(markAsDirty);
+ }
+
/** Paint (serialise) the component for the client. */
@Override
public void paintContent(PaintTarget target) throws PaintException {
@@ -396,7 +401,7 @@ public class MenuBar extends AbstractComponent implements LegacyComponent,
@Override
public int getTabIndex() {
- return getState().tabIndex;
+ return getState(false).tabIndex;
}
/*
diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java
index 34ff6ec112..9b1d8fd5fa 100644
--- a/server/src/com/vaadin/ui/Panel.java
+++ b/server/src/com/vaadin/ui/Panel.java
@@ -171,7 +171,7 @@ public class Panel extends AbstractSingleComponentContainer implements
*/
@Override
public int getScrollLeft() {
- return getState().scrollLeft;
+ return getState(false).scrollLeft;
}
/*
@@ -181,7 +181,7 @@ public class Panel extends AbstractSingleComponentContainer implements
*/
@Override
public int getScrollTop() {
- return getState().scrollTop;
+ return getState(false).scrollTop;
}
/*
@@ -309,7 +309,7 @@ public class Panel extends AbstractSingleComponentContainer implements
*/
@Override
public int getTabIndex() {
- return getState().tabIndex;
+ return getState(false).tabIndex;
}
/**
@@ -334,4 +334,9 @@ public class Panel extends AbstractSingleComponentContainer implements
return (PanelState) super.getState();
}
+ @Override
+ protected PanelState getState(boolean markAsDirty) {
+ return (PanelState) super.getState(markAsDirty);
+ }
+
}
diff --git a/server/src/com/vaadin/ui/PopupDateField.java b/server/src/com/vaadin/ui/PopupDateField.java
index 61aac16a97..f07ac84160 100644
--- a/server/src/com/vaadin/ui/PopupDateField.java
+++ b/server/src/com/vaadin/ui/PopupDateField.java
@@ -93,6 +93,11 @@ public class PopupDateField extends DateField {
return (PopupDateFieldState) super.getState();
}
+ @Override
+ protected PopupDateFieldState getState(boolean markAsDirty) {
+ return (PopupDateFieldState) super.getState(markAsDirty);
+ }
+
/**
* Checks whether the text field is enabled (default) or not.
*
@@ -101,7 +106,7 @@ public class PopupDateField extends DateField {
* @return <b>true</b> if the text field is enabled, <b>false</b> otherwise.
*/
public boolean isTextFieldEnabled() {
- return getState().textFieldEnabled;
+ return getState(false).textFieldEnabled;
}
/**
@@ -136,6 +141,6 @@ public class PopupDateField extends DateField {
* @return String with the description
*/
public String getAssistiveText() {
- return getState().descriptionForAssistiveDevices;
+ return getState(false).descriptionForAssistiveDevices;
}
}
diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java
index b347576b22..90c60edc6e 100644
--- a/server/src/com/vaadin/ui/PopupView.java
+++ b/server/src/com/vaadin/ui/PopupView.java
@@ -61,6 +61,11 @@ public class PopupView extends AbstractComponent implements HasComponents {
/* Constructors */
+ private PopupView() {
+ registerRpc(rpc);
+ setHideOnMouseOut(true);
+ }
+
/**
* A simple way to create a PopupPanel. Note that the minimal representation
* may not be dynamically updated, in order to achieve this create your own
@@ -94,9 +99,7 @@ public class PopupView extends AbstractComponent implements HasComponents {
* the PopupView.Content that contains the information for this
*/
public PopupView(PopupView.Content content) {
- super();
- registerRpc(rpc);
- setHideOnMouseOut(true);
+ this();
setContent(content);
}
@@ -185,7 +188,7 @@ public class PopupView extends AbstractComponent implements HasComponents {
* @return true if the popup is hidden on mouse out, false otherwise
*/
public boolean isHideOnMouseOut() {
- return getState().hideOnMouseOut;
+ return getState(false).hideOnMouseOut;
}
/**
@@ -234,6 +237,11 @@ public class PopupView extends AbstractComponent implements HasComponents {
return (PopupViewState) super.getState();
}
+ @Override
+ protected PopupViewState getState(boolean markAsDirty) {
+ return (PopupViewState) super.getState(markAsDirty);
+ }
+
/**
* Used to deliver customized content-packages to the PopupView. These are
* dynamically loaded when they are redrawn. The user must take care that
diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java
index e108c74ba2..ff6c955e47 100644
--- a/server/src/com/vaadin/ui/Slider.java
+++ b/server/src/com/vaadin/ui/Slider.java
@@ -144,13 +144,18 @@ public class Slider extends AbstractField<Double> {
return (SliderState) super.getState();
}
+ @Override
+ public SliderState getState(boolean markAsDirty) {
+ return (SliderState) super.getState(markAsDirty);
+ }
+
/**
* Gets the maximum slider value
*
* @return the largest value the slider can have
*/
public double getMax() {
- return getState().maxValue;
+ return getState(false).maxValue;
}
/**
@@ -173,7 +178,7 @@ public class Slider extends AbstractField<Double> {
* @return the smallest value the slider can have
*/
public double getMin() {
- return getState().minValue;
+ return getState(false).minValue;
}
/**
@@ -197,7 +202,7 @@ public class Slider extends AbstractField<Double> {
* {@link SliderOrientation#VERTICAL}
*/
public SliderOrientation getOrientation() {
- return getState().orientation;
+ return getState(false).orientation;
}
/**
@@ -219,7 +224,7 @@ public class Slider extends AbstractField<Double> {
* @return resolution
*/
public int getResolution() {
- return getState().resolution;
+ return getState(false).resolution;
}
/**
diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java
index 56c97f58eb..e38be8ad3c 100644
--- a/server/src/com/vaadin/ui/TextArea.java
+++ b/server/src/com/vaadin/ui/TextArea.java
@@ -85,6 +85,11 @@ public class TextArea extends AbstractTextField {
return (TextAreaState) super.getState();
}
+ @Override
+ protected TextAreaState getState(boolean markAsDirty) {
+ return (TextAreaState) super.getState(markAsDirty);
+ }
+
/**
* Sets the number of rows in the text area.
*
@@ -104,7 +109,7 @@ public class TextArea extends AbstractTextField {
* @return number of explicitly set rows.
*/
public int getRows() {
- return getState().rows;
+ return getState(false).rows;
}
/**
@@ -125,7 +130,7 @@ public class TextArea extends AbstractTextField {
* <code>false</code> if not.
*/
public boolean isWordwrap() {
- return getState().wordwrap;
+ return getState(false).wordwrap;
}
}
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 562b30f81d..4bde8a95b3 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -549,8 +549,6 @@ public abstract class UI extends AbstractSingleComponentContainer implements
private boolean resizeLazy = false;
- private String theme;
-
private Navigator navigator;
private PushConnection pushConnection = null;
@@ -633,7 +631,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
this.embedId = embedId;
// Actual theme - used for finding CustomLayout templates
- theme = request.getParameter("theme");
+ getState(false).theme = request.getParameter("theme");
getPage().init(request);
@@ -1135,12 +1133,31 @@ public abstract class UI extends AbstractSingleComponentContainer implements
}
/**
- * Gets the theme that was used when the UI was initialized.
+ * Gets the theme currently in use by this UI
*
* @return the theme name
*/
public String getTheme() {
- return theme;
+ return getState(false).theme;
+ }
+
+ /**
+ * Sets the theme currently in use by this UI
+ * <p>
+ * Calling this method will remove the old theme (CSS file) from the
+ * application and add the new theme.
+ * <p>
+ * Note that this method is NOT SAFE to call in a portal environment or
+ * other environment where there are multiple UIs on the same page. The old
+ * CSS file will be removed even if there are other UIs on the page which
+ * are still using it.
+ *
+ * @since
+ * @param theme
+ * The new theme name
+ */
+ public void setTheme(String theme) {
+ getState().theme = theme;
}
/**
@@ -1581,7 +1598,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
* @return the label of the container
*/
public String getOverlayContainerLabel() {
- return getState().overlayContainerLabel;
+ return getState(false).overlayContainerLabel;
}
/**
diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java
index 149fcd536f..35583c6052 100644
--- a/server/src/com/vaadin/ui/Window.java
+++ b/server/src/com/vaadin/ui/Window.java
@@ -36,9 +36,9 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.shared.Connector;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.window.WindowMode;
+import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.shared.ui.window.WindowServerRpc;
import com.vaadin.shared.ui.window.WindowState;
-import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.util.ReflectTools;
/**
@@ -254,7 +254,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public int getPositionX() {
- return getState().positionX;
+ return getState(false).positionX;
}
/**
@@ -283,7 +283,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public int getPositionY() {
- return getState().positionY;
+ return getState(false).positionY;
}
/**
@@ -661,7 +661,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return true if this window is modal.
*/
public boolean isModal() {
- return getState().modal;
+ return getState(false).modal;
}
/**
@@ -679,7 +679,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return true if window is resizable by the end-user, otherwise false.
*/
public boolean isResizable() {
- return getState().resizable;
+ return getState(false).resizable;
}
/**
@@ -688,7 +688,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* sizes are recalculated immediately.
*/
public boolean isResizeLazy() {
- return getState().resizeLazy;
+ return getState(false).resizeLazy;
}
/**
@@ -764,7 +764,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* true if the window can be dragged by the user
*/
public boolean isDraggable() {
- return getState().draggable;
+ return getState(false).draggable;
}
/**
@@ -1034,7 +1034,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return array of previously set components
*/
public Component[] getAssistiveDescription() {
- Connector[] contentDescription = getState().contentDescription;
+ Connector[] contentDescription = getState(false).contentDescription;
if (contentDescription == null) {
return null;
}
@@ -1068,7 +1068,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return The accessibility prefix
*/
public String getAssistivePrefix() {
- return getState().assistivePrefix;
+ return getState(false).assistivePrefix;
}
/**
@@ -1093,7 +1093,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return The accessibility postfix
*/
public String getAssistivePostfix() {
- return getState().assistivePostfix;
+ return getState(false).assistivePostfix;
}
/**
@@ -1124,7 +1124,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return WAI-ARIA role set for the window
*/
public WindowRole getAssistiveRole() {
- return getState().role;
+ return getState(false).role;
}
/**
@@ -1152,7 +1152,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* focus can leave the window
*/
public boolean isTabStopEnabled() {
- return getState().assistiveTabStop;
+ return getState(false).assistiveTabStop;
}
/**
@@ -1193,7 +1193,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return the top message
*/
public String getTabStopTopAssistiveText() {
- return getState().assistiveTabStopTopText;
+ return getState(false).assistiveTabStopTopText;
}
/**
@@ -1204,6 +1204,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return the bottom message
*/
public String getTabStopBottomAssistiveText() {
- return getState().assistiveTabStopBottomText;
+ return getState(false).assistiveTabStopBottomText;
}
}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
index 6147fcdd96..81b178e4f0 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java
@@ -56,7 +56,7 @@ public class ColorPickerGradient extends AbstractComponent implements
};
/** The converter. */
- private final Coordinates2Color converter;
+ private Coordinates2Color converter;
/** The foreground color. */
private Color color;
@@ -67,6 +67,14 @@ public class ColorPickerGradient extends AbstractComponent implements
/** The y-coordinate. */
private int y = 0;
+ private ColorPickerGradient() {
+ registerRpc(rpc);
+ // width and height must be set here instead of in theme, otherwise
+ // coordinate calculations fail
+ getState().width = "220px";
+ getState().height = "220px";
+ }
+
/**
* Instantiates a new color picker gradient.
*
@@ -76,12 +84,8 @@ public class ColorPickerGradient extends AbstractComponent implements
* the converter
*/
public ColorPickerGradient(String id, Coordinates2Color converter) {
- registerRpc(rpc);
+ this();
addStyleName(id);
- // width and height must be set here instead of in theme, otherwise
- // coordinate calculations fail
- getState().width = "220px";
- getState().height = "220px";
this.converter = converter;
}
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
index e7b412f7eb..b9a8c001ce 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java
@@ -143,14 +143,7 @@ public class ColorPickerPopup extends Window implements ClickListener,
*/
private boolean updatingColors = false;
- /**
- * Instantiates a new color picker popup.
- */
- public ColorPickerPopup(Color initialColor) {
- super();
-
- selectedColor = initialColor;
-
+ private ColorPickerPopup() {
// Set the layout
layout = new VerticalLayout();
layout.setSpacing(false);
@@ -162,15 +155,21 @@ public class ColorPickerPopup extends Window implements ClickListener,
setStyleName(STYLENAME);
setResizable(false);
setImmediate(true);
+ // Create the history
+ history = new ColorPickerHistory();
+ history.addColorChangeListener(this);
+ }
+ /**
+ * Instantiates a new color picker popup.
+ */
+ public ColorPickerPopup(Color initialColor) {
+ this();
+ selectedColor = initialColor;
initContents();
}
private void initContents() {
- // Create the history
- history = new ColorPickerHistory();
- history.addColorChangeListener(this);
-
// Create the preview on the rgb tab
rgbPreview = new ColorPickerPreview(selectedColor);
rgbPreview.setWidth("240px");
diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
index ae00b267ce..21a3630de2 100644
--- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
+++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java
@@ -56,24 +56,23 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
/** The old value. */
private String oldValue;
- /**
- * Instantiates a new color picker preview.
- */
- public ColorPickerPreview(Color color) {
+ private ColorPickerPreview() {
setStyleName("v-colorpicker-preview");
setImmediate(true);
-
- this.color = color;
-
field = new TextField();
field.setImmediate(true);
field.setSizeFull();
field.setStyleName("v-colorpicker-preview-textfield");
field.setData(this);
field.addValueChangeListener(this);
-
addComponent(field);
+ }
+ /**
+ * Instantiates a new color picker preview.
+ */
+ public ColorPickerPreview(Color color) {
+ this();
setColor(color);
}
diff --git a/server/src/com/vaadin/ui/themes/ValoTheme.java b/server/src/com/vaadin/ui/themes/ValoTheme.java
new file mode 100644
index 0000000000..51e2e283f2
--- /dev/null
+++ b/server/src/com/vaadin/ui/themes/ValoTheme.java
@@ -0,0 +1,809 @@
+/*
+ * Copyright 2000-2014 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.ui.themes;
+
+import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.Table.ColumnHeaderMode;
+
+/**
+ * <p>
+ * Additional style names which can be used with the Valo theme.
+ * </p>
+ *
+ * <p>
+ * These styles are only available if the Valo theme (or any of it's variants)
+ * is built with the <code>$valo-include-common-stylenames</code> Sass variable
+ * set to <code>true</code>.
+ * </p>
+ *
+ * <p>
+ * Most of these additional style names can be included individually into your
+ * custom theme using the component specific Sass mixins, in which case you can
+ * also define the style names yourself. See the Valo theme Sass API
+ * documentation for additional information.
+ * </p>
+ *
+ * TODO link to Sass API documentation
+ *
+ * @since 7.3.0
+ * @author Vaadin Ltd
+ */
+public class ValoTheme {
+
+ public static final String THEME_NAME = "valo";
+
+ /***************************************************************************
+ *
+ * Notification styles
+ *
+ **************************************************************************/
+
+ /**
+ * Styles the notification to look like {@link Type#TRAY_NOTIFICATION},
+ * without setting the position and delay. Can be combined with any other
+ * Notification style.
+ */
+ public static final String NOTIFICATION_TRAY = "tray";
+
+ /**
+ * Styles the notification to look like {@link Type#WARNING_MESSAGE},
+ * without setting the position and delay. Can be combined with any other
+ * Notification style.
+ */
+ public static final String NOTIFICATION_WARNING = "warning";
+
+ /**
+ * Styles the notification to look like {@link Type#ERROR_MESSAGE}, without
+ * setting the position and delay. Can be combined with any other
+ * Notification style.
+ */
+ public static final String NOTIFICATION_ERROR = "error";
+
+ /**
+ * Styles the notification to look like a system notification. Can be
+ * combined with any other Notification style.
+ */
+ public static final String NOTIFICATION_SYSTEM = "system";
+
+ /**
+ * Styles the notification to span the entire width of the viewport. Can be
+ * combined with any other Notification style.
+ */
+ public static final String NOTIFICATION_BAR = "bar";
+
+ /**
+ * Smaller padding and font size for the notification. Can be combined with
+ * any other Notification style.
+ */
+ public static final String NOTIFICATION_SMALL = "small";
+
+ /**
+ * Adds a close button to the notification to imply that the user must click
+ * on the notification to dismiss it. Use in combination with an infinite
+ * delay (<code>-1</code>). Can be combined with any other Notification
+ * style.
+ */
+ public static final String NOTIFICATION_CLOSABLE = "closable";
+
+ /**
+ * Success notification style. Adds a border around the notification and an
+ * icon next to the title. Can be combined with any other Label style.
+ */
+ public static final String NOTIFICATION_SUCCESS = "success";
+
+ /**
+ * Failure notification style. Adds a border around the notification and an
+ * icon next to the title. Can be combined with any other Label style.
+ */
+ public static final String NOTIFICATION_FAILURE = "failure";
+
+ /***************************************************************************
+ *
+ * Label styles
+ *
+ **************************************************************************/
+
+ /**
+ * Header style for main application headings. Can be combined with any
+ * other Label style.
+ */
+ public static final String LABEL_H1 = "h1";
+
+ /**
+ * Header style for different sections in the application. Can be combined
+ * with any other Label style.
+ */
+ public static final String LABEL_H2 = "h2";
+
+ /**
+ * Header style for different sub-sections in the application. Can be
+ * combined with any other Label style.
+ */
+ public static final String LABEL_H3 = "h3";
+
+ /**
+ * Header style for different sub-sections in the application. Can be
+ * combined with any other Label style.
+ */
+ public static final String LABEL_H4 = "h4";
+
+ /**
+ * A utility style that can be combined with the {@link #LABEL_H1},
+ * {@link #LABEL_H2}, {@link #LABEL_H3} and {@link #LABEL_H4} styles to
+ * remove the default margins from the header.
+ */
+ public static final String LABEL_NO_MARGIN = "no-margin";
+
+ /**
+ * Small font size. Suitable for additional/supplementary UI text. Can be
+ * combined with any other Label style.
+ */
+ public static final String LABEL_SMALL = "small";
+
+ /**
+ * Large font size. Suitable for important/prominent UI text. Can be
+ * combined with any other Label style.
+ */
+ public static final String LABEL_LARGE = "large";
+
+ /**
+ * Lighter font weight. Suitable for additional/supplementary UI text. Can
+ * be combined with any other Label style.
+ */
+ public static final String LABEL_LIGHT = "light";
+
+ /**
+ * Bolder font weight. Suitable for important/prominent UI text. Can be
+ * combined with any other Label style.
+ */
+ public static final String LABEL_BOLD = "bold";
+
+ /**
+ * Success badge style. Adds a border around the label and an icon next to
+ * the text. Suitable for UI notifications that need to in the direct
+ * context of some component. Can be combined with any other Label style.
+ */
+ public static final String LABEL_SUCCESS = "success";
+
+ /**
+ * Failure badge style. Adds a border around the label and an icon next to
+ * the text. Suitable for UI notifications that need to in the direct
+ * context of some component. Can be combined with any other Label style.
+ */
+ public static final String LABEL_FAILURE = "failure";
+
+ /***************************************************************************
+ *
+ * Button styles
+ *
+ **************************************************************************/
+
+ /**
+ * Primary action button (e.g. the button that should get activated when the
+ * user presses the <code>enter</code> key in a form). Use sparingly, only
+ * one default button per view should be visible. Can be combined with any
+ * other Button style.
+ */
+ public static final String BUTTON_PRIMARY = "primary";
+
+ /**
+ * A prominent button that can be used instead of the
+ * {@link #BUTTON_PRIMARY} for primary actions when the action is considered
+ * <b>safe</b> for the user (i.e. does not cause any data loss or any other
+ * irreversible action). Can be combined with any other Button style.
+ */
+ public static final String BUTTON_FRIENDLY = "friendly";
+
+ /**
+ * A prominent button that can be used when the action is considered
+ * <b>unsafe</b> for the user (i.e. it causes data loss or some other
+ * irreversible action). Can be combined with any other Button style.
+ */
+ public static final String BUTTON_DANGER = "danger";
+
+ /**
+ * Borderless button. Can be combined with any other Button style.
+ */
+ public static final String BUTTON_BORDERLESS = "borderless";
+
+ /**
+ * Borderless button with a colored caption text. Can be combined with any
+ * other Button style.
+ */
+ public static final String BUTTON_BORDERLESS_COLORED = "borderless-colored";
+
+ /**
+ * "Quiet" button, which looks like {@link #BUTTON_BORDERLESS} until you
+ * hover over it with the mouse. Can be combined with any other Button
+ * style.
+ */
+ public static final String BUTTON_QUIET = "quiet";
+
+ /**
+ * Makes the button look like the Link component. Can be combined with any
+ * other Button style.
+ */
+ public static final String BUTTON_LINK = "link";
+
+ /**
+ * Small size button. Can be combined with any other Button style.
+ */
+ public static final String BUTTON_SMALL = "small";
+
+ /**
+ * Large size button. Can be combined with any other Button style.
+ */
+ public static final String BUTTON_LARGE = "large";
+
+ /**
+ * Align the icon to the right side of the button caption. Can be combined
+ * with any other Button style.
+ */
+ public static final String BUTTON_ICON_ALIGN_RIGHT = "icon-align-right";
+
+ /**
+ * Stack the icon on top of the button caption. Can be combined with any
+ * other Button style.
+ */
+ public static final String BUTTON_ICON_ALIGN_TOP = "icon-align-top";
+
+ /**
+ * Only show the icon in the button, and size the button to a square shape.
+ */
+ public static final String BUTTON_ICON_ONLY = "icon-only";
+
+ /***************************************************************************
+ *
+ * Link styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size link.
+ */
+ public static final String LINK_SMALL = "small";
+
+ /**
+ * Large size link.
+ */
+ public static final String LINK_LARGE = "large";
+
+ /***************************************************************************
+ *
+ * TextField styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size text field. Can be combined with any other TextField style.
+ */
+ public static final String TEXTFIELD_SMALL = "small";
+
+ /**
+ * Large size text field. Can be combined with any other TextField style.
+ */
+ public static final String TEXTFIELD_LARGE = "large";
+
+ /**
+ * Removes the border and background from the text field. Can be combined
+ * with any other TextField style.
+ */
+ public static final String TEXTFIELD_BORDERLESS = "borderless";
+
+ /**
+ * Align the text inside the field to the right. Can be combined with any
+ * other TextField style.
+ */
+ public static final String TEXTFIELD_ALIGN_RIGHT = "align-right";
+
+ /**
+ * Align the text inside the field to center. Can be combined with any other
+ * TextField style.
+ */
+ public static final String TEXTFIELD_ALIGN_CENTER = "align-center";
+
+ /**
+ * Move the default caption icon inside the text field. Can be combined with
+ * any other TextField style.
+ */
+ public static final String TEXTFIELD_INLINE_ICON = "inline-icon";
+
+ /***************************************************************************
+ *
+ * TextArea styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size text area. Can be combined with any other TextArea style.
+ */
+ public static final String TEXTAREA_SMALL = "small";
+
+ /**
+ * Large size text area. Can be combined with any other TextArea style.
+ */
+ public static final String TEXTAREA_LARGE = "large";
+
+ /**
+ * Removes the border and background from the text area. Can be combined
+ * with any other TextArea style.
+ */
+ public static final String TEXTAREA_BORDERLESS = "borderless";
+
+ /**
+ * Align the text inside the area to the right. Can be combined with any
+ * other TextArea style.
+ */
+ public static final String TEXTAREA_ALIGN_RIGHT = "align-right";
+
+ /**
+ * Align the text inside the area to center. Can be combined with any other
+ * TextArea style.
+ */
+ public static final String TEXTAREA_ALIGN_CENTER = "align-center";
+
+ /***************************************************************************
+ *
+ * DateField styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size date field. Can be combined with any other DateField style.
+ */
+ public static final String DATEFIELD_SMALL = "small";
+
+ /**
+ * Large size date field. Can be combined with any other DateField style.
+ */
+ public static final String DATEFIELD_LARGE = "large";
+
+ /**
+ * Removes the border and background from the date field. Can be combined
+ * with any other DateField style.
+ */
+ public static final String DATEFIELD_BORDERLESS = "borderless";
+
+ /**
+ * Align the text inside the field to the right. Can be combined with any
+ * other DateField style.
+ */
+ public static final String DATEFIELD_ALIGN_RIGHT = "align-right";
+
+ /**
+ * Align the text inside the field to center. Can be combined with any other
+ * DateField style.
+ */
+ public static final String DATEFIELD_ALIGN_CENTER = "align-center";
+
+ /***************************************************************************
+ *
+ * ComboBox styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size combo box. Can be combined with any other ComboBox style.
+ */
+ public static final String COMBOBOX_SMALL = "small";
+
+ /**
+ * Large size combo box. Can be combined with any other ComboBox style.
+ */
+ public static final String COMBOBOX_LARGE = "large";
+
+ /**
+ * Removes the border and background from the combo box. Can be combined
+ * with any other ComboBox style.
+ */
+ public static final String COMBOBOX_BORDERLESS = "borderless";
+
+ /**
+ * Align the text inside the combo box to the right. Can be combined with
+ * any other TextField style.
+ */
+ public static final String COMBOBOX_ALIGN_RIGHT = "align-right";
+
+ /**
+ * Align the text inside the combo box to center. Can be combined with any
+ * other TextField style.
+ */
+ public static final String COMBOBOX_ALIGN_CENTER = "align-center";
+
+ /***************************************************************************
+ *
+ * CheckBox styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size check box. Can be combined with any other CheckBox style.
+ */
+ public static final String CHECKBOX_SMALL = "small";
+
+ /**
+ * Large size check box. Can be combined with any other CheckBox style.
+ */
+ public static final String CHECKBOX_LARGE = "large";
+
+ /***************************************************************************
+ *
+ * OptionGroup styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size option group. Can be combined with any other OptionGroup
+ * style.
+ */
+ public static final String OPTIONGROUP_SMALL = "small";
+
+ /**
+ * Large size option group. Can be combined with any other OptionGroup
+ * style.
+ */
+ public static final String OPTIONGROUP_LARGE = "large";
+
+ /***************************************************************************
+ *
+ * Slider styles
+ *
+ **************************************************************************/
+
+ /**
+ * Hide the indicator bar from the slider. Can be combined with any other
+ * Slider style.
+ */
+ public static final String SLIDER_NO_INDICATOR = "no-indicator";
+
+ /***************************************************************************
+ *
+ * ProgressBar styles
+ *
+ **************************************************************************/
+
+ /**
+ * Make the progress bar indicator appear as a dot which progresses over the
+ * progress bar track (instead of a growing bar).
+ */
+ public static final String PROBRESSBAR_POINT = "point";
+
+ /***************************************************************************
+ *
+ * MenuBar styles
+ *
+ **************************************************************************/
+
+ /**
+ * Small size menu bar. Can be combined with any other MenuBar style.
+ */
+ public static final String MENUBAR_SMALL = "small";
+
+ /**
+ * Borderless menu bar. Can be combined with any other MenuBar style.
+ */
+ public static final String MENUBAR_BORDERLESS = "borderless";
+
+ /***************************************************************************
+ *
+ * Table and TreeTable styles
+ *
+ **************************************************************************/
+
+ /**
+ * Remove the alternating row colors. Can be combined with any other
+ * Table/TreeTable style.
+ */
+ public static final String TABLE_NO_STRIPES = "no-stripes";
+
+ /**
+ * See {@link #TABLE_NO_STRIPES}
+ */
+ public static final String TREETABLE_NO_STRIPES = TABLE_NO_STRIPES;
+
+ /**
+ * Remove the vertical divider lines between the table columns. Can be
+ * combined with any other Table/TreeTable style.
+ */
+ public static final String TABLE_NO_VERTICAL_LINES = "no-vertical-lines";
+
+ /**
+ * See {@link #TABLE_NO_VERTICAL_LINES}
+ */
+ public static final String TREETABLE_NO_VERTICAL_LINES = TABLE_NO_VERTICAL_LINES;
+
+ /**
+ * Remove the horizontal divider lines between the table rows. Can be
+ * combined with any other Table/TreeTable style.
+ */
+ public static final String TABLE_NO_HORIZONTAL_LINES = "no-horizontal-lines";
+
+ /**
+ * See {@link #TABLE_NO_HORIZONTAL_LINES}
+ */
+ public static final String TREETABLE_NO_HORIZONTAL_LINES = TABLE_NO_HORIZONTAL_LINES;
+
+ /**
+ * Hide the table column headers (effectively the same as
+ * {@link ColumnHeaderMode#HIDDEN}). Can be combined with any other
+ * Table/TreeTable style.
+ */
+ public static final String TABLE_NO_HEADER = "no-header";
+
+ /**
+ * See {@link #TABLE_NO_HEADER}
+ */
+ public static final String TREETABLE_NO_HEADER = TABLE_NO_HEADER;
+
+ /**
+ * Remove the outer border of the table. Can be combined with any other
+ * Table/TreeTable style.
+ */
+ public static final String TABLE_BORDERLESS = "borderless";
+
+ /**
+ * See {@link #TABLE_BORDERLESS}
+ */
+ public static final String TREETABLE_BORDERLESS = TABLE_BORDERLESS;
+
+ /**
+ * Reduce the white space inside the table cells. Can be combined with any
+ * other Table/TreeTable style.
+ */
+ public static final String TABLE_COMPACT = "compact";
+
+ /**
+ * See {@link #TABLE_COMPACT}
+ */
+ public static final String TREETABLE_COMPACT = TABLE_COMPACT;
+
+ /**
+ * Small font size and reduced the white space inside the table cells. Can
+ * be combined with any other Table/TreeTable style.
+ */
+ public static final String TABLE_SMALL = "small";
+
+ /**
+ * See {@link #TABLE_SMALL}
+ */
+ public static final String TREETABLE_SMALL = TABLE_SMALL;
+
+ /***************************************************************************
+ *
+ * DragAndDropWrapper styles
+ *
+ **************************************************************************/
+
+ /**
+ * Hide the "box drag hints" (i.e. the style which gets applied when the
+ * drag is in the middle/center area of the drag target).
+ */
+ public static final String DRAG_AND_DROP_WRAPPER_NO_BOX_DRAG_HINTS = "no-box-drag-hints";
+
+ /**
+ * Hide the "vertical drag hints" (i.e. the style which gets applied when
+ * the drag is in the top/bottom part of the drag target).
+ */
+ public static final String DRAG_AND_DROP_WRAPPER_NO_VERTICAL_DRAG_HINTS = "no-vertical-drag-hints";
+
+ /**
+ * Hide the "horizontal drag hints" (i.e. the style which gets applied when
+ * the drag is in the left/right part of the drag target).
+ */
+ public static final String DRAG_AND_DROP_WRAPPER_NO_HORIZONTAL_DRAG_HINTS = "no-horizontal-drag-hints";
+
+ /***************************************************************************
+ *
+ * Panel styles
+ *
+ **************************************************************************/
+
+ /**
+ * Remove borders and the background color of the panel. Can be combined
+ * with any other Panel style.
+ */
+ public static final String PANEL_BORDERLESS = "borderless";
+
+ /**
+ * Show a divider between the panel caption and content when the content
+ * area is scrolled. Suitable with the {@link #PANEL_BORDERLESS} style. Can
+ * be combined with any other Panel style.
+ */
+ public static final String PANEL_SCROLL_INDICATOR = "scroll-indicator";
+
+ /**
+ * Inset panel style. Can be combined with any other Panel style.
+ */
+ public static final String PANEL_WELL = "well";
+
+ /***************************************************************************
+ *
+ * SplitPanel styles
+ *
+ **************************************************************************/
+
+ /**
+ * Make the split handle wider.
+ */
+ public static final String SPLITPANEL_LARGE = "large";
+
+ /***************************************************************************
+ *
+ * TabSheet styles
+ *
+ **************************************************************************/
+
+ /**
+ * Adds a border around the whole component as well as around individual
+ * tabs in the tab bar. Can be combined with any other TabSheet style.
+ */
+ public static final String TABSHEET_FRAMED = "framed";
+
+ /**
+ * Center the tabs inside the tab bar. Works best if all the tabs fit
+ * completely in the tab bar (i.e. no tab bar scrolling). Can be combined
+ * with any other TabSheet style.
+ */
+ public static final String TABSHEET_CENTERED_TABS = "centered-tabs";
+
+ /**
+ * Give equal amount of space to all tabs in the tab bar (.i.e expand ratio
+ * == 1 for all tabs). The tab captions will be truncated if they do not fit
+ * in to the tab. Tab scrolling will be disabled when this style is applied
+ * (all tabs will be visible at the same time). Can be combined with any
+ * other TabSheet style.
+ */
+ public static final String TABSHEET_EQUAL_WIDTH_TABS = "equal-width-tabs";
+
+ /**
+ * Add a small amount of padding around the tabs in the tab bar, so that
+ * they don't touch the outer edges of the component. Can be combined with
+ * any other TabSheet style.
+ */
+ public static final String TABSHEET_PADDED_TABBAR = "padded-tabbar";
+
+ /**
+ * Reduce the whitespace around the tabs in the tab bar. Can be combined
+ * with any other TabSheet style.
+ */
+ public static final String TABSHEET_COMPACT_TABBAR = "compact-tabbar";
+
+ /**
+ * Display tab icons on top of the tab captions (by default the icons are
+ * place on the left side of the caption). Can be combined with any other
+ * TabSheet style.
+ */
+ public static final String TABSHEET_ICONS_ON_TOP = "icons-on-top";
+
+ /**
+ * Only the selected tab has the close button visible. Does not prevent
+ * closing the tab programmatically, it only hides the button from the end
+ * user. Can be combined with any other TabSheet style.
+ */
+ public static final String TABSHEET_ONLY_SELECTED_TAB_IS_CLOSABLE = "only-selected-closable";
+
+ /***************************************************************************
+ *
+ * Accordion styles
+ *
+ **************************************************************************/
+
+ /**
+ * Remove the outer border from the accordion. Can be combined with any
+ * other Accordion style.
+ */
+ public static final String ACCORDION_BORDERLESS = "borderless";
+
+ /***************************************************************************
+ *
+ * Window and related styles
+ *
+ **************************************************************************/
+
+ /**
+ * Add this style to any layout component (e.g. CssLayout, VerticalLayout or
+ * HorizontalLayout) and place it inside the root layout of the window to
+ * create a toolbar area for the window. You can then place any other
+ * components inside the toolbar layout, e.g. a MenuBar.
+ */
+ public static final String WINDOW_TOP_TOOLBAR = "v-window-top-toolbar";
+
+ /**
+ * Add this style to any layout component (e.g. CssLayout, VerticalLayout or
+ * HorizontalLayout) and place it inside the root layout of the window to
+ * create a toolbar area for the window. You can then place any other
+ * components inside the toolbar layout, e.g. a MenuBar.
+ */
+ public static final String WINDOW_BOTTOM_TOOLBAR = "v-window-bottom-toolbar";
+
+ /***************************************************************************
+ *
+ * FormLayout styles
+ *
+ **************************************************************************/
+
+ /**
+ * Removes the borders and background from any direct child field components
+ * (TextField, TextArea, DateField, ComboBox) in the layout. Reduces the
+ * spacing between the form rows adds separator lines between them.
+ */
+ public static final String FORMLAYOUT_LIGHT = "light";
+
+ /***************************************************************************
+ *
+ * Layout styles
+ *
+ **************************************************************************/
+
+ /**
+ * Make a layout look like the Panel component (resembles visually a card).
+ * Add an additional <code>v-panel-caption</code> style name to any layout
+ * inside the card layout to make it look like a Panel's caption.
+ */
+ public static final String LAYOUT_CARD = "card";
+
+ /**
+ * Make a layout look like the {@link #PANEL_WELL} style. Add an additional
+ * <code>v-panel-caption</code> style name to any layout inside the card
+ * layout to make it look like a Panel's caption.
+ */
+ public static final String LAYOUT_WELL = "well";
+
+ /***************************************************************************
+ *
+ * Valo menu styles
+ *
+ **************************************************************************/
+
+ /**
+ * Set the primary style name of a CssLayout to this, and add any number of
+ * layouts with the {@link #MENU_PART} style inside it.
+ */
+ public static final String MENU_ROOT = "valo-menu";
+
+ /**
+ * Add this style name to any layout and place it inside a layout with the
+ * {@link #MENU_ROOT} style to build a menu component. Use the additional
+ * MENU styles for individual components inside the layout.
+ */
+ public static final String MENU_PART = "valo-menu-part";
+
+ /**
+ * TODO
+ */
+ public static final String MENU_TITLE = "valo-menu-title";
+
+ /**
+ * TODO
+ */
+ public static final String MENU_SUBTITLE = "valo-menu-subtitle";
+
+ /**
+ * TODO
+ */
+ public static final String MENU_ITEM = "valo-menu-title";
+
+ /**
+ * TODO
+ */
+ public static final String MENU_BADGE = "valo-menu-badge";
+
+ /**
+ * TODO
+ */
+ public static final String MENU_LOGO = "valo-menu-logo";
+
+}
diff --git a/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirty.java b/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirty.java
new file mode 100644
index 0000000000..280d638707
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/server/component/StateGetDoesNotMarkDirty.java
@@ -0,0 +1,100 @@
+package com.vaadin.tests.server.component;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+
+import com.vaadin.tests.VaadinClasses;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ConnectorTracker;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.UI;
+
+public class StateGetDoesNotMarkDirty extends TestCase {
+
+ private Set<String> excludedMethods = new HashSet<String>();
+
+ @Override
+ protected void setUp() throws Exception {
+ excludedMethods.add(Label.class.getName() + "getDataSourceValue");
+ excludedMethods.add("getConnectorId");
+ }
+
+ public void testGetDoesntMarkStateDirty() throws Exception {
+ for (Class<? extends Component> c : VaadinClasses.getComponents()) {
+ Component newInstance = construct(c);
+ prepareMockUI(newInstance);
+
+ Set<Method> methods = new HashSet<Method>();
+ methods.addAll(Arrays.asList(c.getMethods()));
+ methods.addAll(Arrays.asList(c.getDeclaredMethods()));
+ for (Method method : methods) {
+ try {
+ if (method.getName().startsWith("is")
+ || method.getName().startsWith("get")) {
+ if (method.getName().startsWith("getState")) {
+ continue;
+ }
+ if (method.getParameterTypes().length > 0) {
+ // usually getters do not have params, if they have
+ // we still wouldnt know what to put into
+ continue;
+ }
+ if (excludedMethods.contains(c.getName()
+ + method.getName())) {
+ // blacklisted method for specific classes
+ continue;
+ }
+ if (excludedMethods.contains(method.getName())) {
+ // blacklisted method for all classes
+ continue;
+ }
+ // just to make sure we can invoke it
+ method.setAccessible(true);
+ method.invoke(newInstance);
+ }
+ } catch (Exception e) {
+ System.err.println("problem with method " + c.getName()
+ + "# " + method.getName());
+ e.printStackTrace();
+ throw e;
+ }
+ }
+ }
+
+ }
+
+ private void prepareMockUI(Component newInstance) {
+ UI ui = Mockito.mock(UI.class);
+ Mockito.when(ui.getLocale()).thenReturn(Locale.ENGLISH);
+ ConnectorTracker connectorTracker = Mockito
+ .mock(ConnectorTracker.class);
+ Mockito.when(ui.getConnectorTracker()).thenReturn(connectorTracker);
+ Mockito.doThrow(new RuntimeException("getState(true) called in getter"))
+ .when(connectorTracker).markDirty(newInstance);
+
+ newInstance.setParent(ui);
+ }
+
+ private Component construct(Class<? extends Component> c) {
+ try {
+ try {
+ Constructor<? extends Component> declaredConstructor = c
+ .getDeclaredConstructor();
+ declaredConstructor.setAccessible(true);
+ return declaredConstructor.newInstance();
+ } catch (NoSuchMethodException e) {
+ return c.newInstance();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java b/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
index d113efdfaf..fe7f9ba03e 100644
--- a/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
+++ b/server/tests/src/com/vaadin/tests/util/MockDeploymentConfiguration.java
@@ -19,6 +19,7 @@ public class MockDeploymentConfiguration implements DeploymentConfiguration {
private Properties initParameters = new Properties();
private Map<String, String> applicationOrSystemProperty = new HashMap<String, String>();
private LegacyProperyToStringMode legacyPropertyToStringMode = LegacyProperyToStringMode.DISABLED;
+ private boolean syncIdCheckEnabled = true;
@Override
public boolean isProductionMode() {
@@ -34,6 +35,15 @@ public class MockDeploymentConfiguration implements DeploymentConfiguration {
return xsrfProtectionEnabled;
}
+ @Override
+ public boolean isSyncIdCheckEnabled() {
+ return syncIdCheckEnabled;
+ }
+
+ public void setSyncIdCheckEnabled(boolean syncIdCheckEnabled) {
+ this.syncIdCheckEnabled = syncIdCheckEnabled;
+ }
+
public void setXsrfProtectionEnabled(boolean xsrfProtectionEnabled) {
this.xsrfProtectionEnabled = xsrfProtectionEnabled;
}