aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-09-27 10:02:29 +0300
committerHenri Sara <henri.sara@gmail.com>2017-09-27 10:02:29 +0300
commit697f770287bb786b6b5d4944a9202d145e4251f5 (patch)
tree2533cf5d0392129f8094f5d02df15c883f00f304 /server
parent9776ea2e85468256c70b8618c0e1a2a7ccb8199b (diff)
downloadvaadin-framework-697f770287bb786b6b5d4944a9202d145e4251f5.tar.gz
vaadin-framework-697f770287bb786b6b5d4944a9202d145e4251f5.zip
Implement error level on client side (#9817)
Add additional class names and style to components and error indicators to distinguish different error levels. Vaadin 8 implementation of #9816. Cherry picked changes and added compatibility package component changes and tests. Resolves #3139
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/AbstractErrorMessage.java2
-rw-r--r--server/src/main/java/com/vaadin/server/CompositeErrorMessage.java6
-rw-r--r--server/src/main/java/com/vaadin/server/ErrorMessage.java65
-rw-r--r--server/src/main/java/com/vaadin/server/SystemError.java4
-rw-r--r--server/src/main/java/com/vaadin/server/UserError.java2
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractComponent.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/TabSheet.java12
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java2
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java2
9 files changed, 31 insertions, 68 deletions
diff --git a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java
index cad1dc425d..b7e439244e 100644
--- a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java
+++ b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java
@@ -21,6 +21,8 @@ import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
+import com.vaadin.shared.ui.ErrorLevel;
+
/**
* Base class for component error messages.
*
diff --git a/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java b/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java
index 6d6a775a1b..510ef4ed00 100644
--- a/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java
+++ b/server/src/main/java/com/vaadin/server/CompositeErrorMessage.java
@@ -19,6 +19,8 @@ package com.vaadin.server;
import java.util.Collection;
import java.util.Iterator;
+import com.vaadin.shared.ui.ErrorLevel;
+
/**
* Class for combining multiple error messages together.
*
@@ -37,7 +39,7 @@ public class CompositeErrorMessage extends AbstractErrorMessage {
*/
public CompositeErrorMessage(ErrorMessage... errorMessages) {
super(null);
- setErrorLevel(ErrorLevel.INFORMATION);
+ setErrorLevel(ErrorLevel.INFO);
for (ErrorMessage errorMessage : errorMessages) {
addErrorMessage(errorMessage);
@@ -60,7 +62,7 @@ public class CompositeErrorMessage extends AbstractErrorMessage {
public CompositeErrorMessage(
Collection<? extends ErrorMessage> errorMessages) {
super(null);
- setErrorLevel(ErrorLevel.INFORMATION);
+ setErrorLevel(ErrorLevel.INFO);
for (ErrorMessage errorMessage : errorMessages) {
addErrorMessage(errorMessage);
diff --git a/server/src/main/java/com/vaadin/server/ErrorMessage.java b/server/src/main/java/com/vaadin/server/ErrorMessage.java
index f4030ed4c9..8095a5afdd 100644
--- a/server/src/main/java/com/vaadin/server/ErrorMessage.java
+++ b/server/src/main/java/com/vaadin/server/ErrorMessage.java
@@ -18,6 +18,8 @@ package com.vaadin.server;
import java.io.Serializable;
+import com.vaadin.shared.ui.ErrorLevel;
+
/**
* Interface for rendering error messages to terminal. All the visible errors
* shown to user must implement this interface.
@@ -27,66 +29,11 @@ import java.io.Serializable;
*/
public interface ErrorMessage extends Serializable {
- public enum ErrorLevel {
- /**
- * Error code for informational messages.
- */
- INFORMATION("info", 0),
- /**
- * Error code for warning messages.
- */
- WARNING("warning", 1),
- /**
- * Error code for regular error messages.
- */
- ERROR("error", 2),
- /**
- * Error code for critical error messages.
- */
- CRITICAL("critical", 3),
- /**
- * Error code for system errors and bugs.
- */
- SYSTEMERROR("system", 4);
-
- String text;
- int errorLevel;
-
- private ErrorLevel(String text, int errorLevel) {
- this.text = text;
- this.errorLevel = errorLevel;
- }
-
- /**
- * Textual representation for server-client communication of level
- *
- * @return String for error severity
- */
- public String getText() {
- return text;
- }
-
- /**
- * Integer representation of error severity for comparison
- *
- * @return integer for error severity
- */
- public int intValue() {
- return errorLevel;
- }
-
- @Override
- public String toString() {
- return text;
- }
-
- }
-
/**
- * @deprecated As of 7.0, use {@link ErrorLevel#SYSTEMERROR} instead    
+ * @deprecated As of 7.0, use {@link ErrorLevel#SYSTEM} instead    
*/
@Deprecated
- public static final ErrorLevel SYSTEMERROR = ErrorLevel.SYSTEMERROR;
+ public static final ErrorLevel SYSTEMERROR = ErrorLevel.SYSTEM;
/**
* @deprecated As of 7.0, use {@link ErrorLevel#CRITICAL} instead    
@@ -108,10 +55,10 @@ public interface ErrorMessage extends Serializable {
public static final ErrorLevel WARNING = ErrorLevel.WARNING;
/**
- * @deprecated As of 7.0, use {@link ErrorLevel#INFORMATION} instead    
+ * @deprecated As of 7.0, use {@link ErrorLevel#INFO} instead    
*/
@Deprecated
- public static final ErrorLevel INFORMATION = ErrorLevel.INFORMATION;
+ public static final ErrorLevel INFORMATION = ErrorLevel.INFO;
/**
* Gets the errors level.
diff --git a/server/src/main/java/com/vaadin/server/SystemError.java b/server/src/main/java/com/vaadin/server/SystemError.java
index 734b4862a8..151021d1f8 100644
--- a/server/src/main/java/com/vaadin/server/SystemError.java
+++ b/server/src/main/java/com/vaadin/server/SystemError.java
@@ -16,6 +16,8 @@
package com.vaadin.server;
+import com.vaadin.shared.ui.ErrorLevel;
+
/**
* <code>SystemError</code> is an error message for a problem caused by error in
* system, not the user application code. The system error can contain technical
@@ -39,7 +41,7 @@ public class SystemError extends AbstractErrorMessage {
*/
public SystemError(String message) {
super(message);
- setErrorLevel(ErrorLevel.SYSTEMERROR);
+ setErrorLevel(ErrorLevel.SYSTEM);
setMode(ContentMode.HTML);
setMessage(getHtmlMessage());
}
diff --git a/server/src/main/java/com/vaadin/server/UserError.java b/server/src/main/java/com/vaadin/server/UserError.java
index b017c9e1f9..636e98a02f 100644
--- a/server/src/main/java/com/vaadin/server/UserError.java
+++ b/server/src/main/java/com/vaadin/server/UserError.java
@@ -16,6 +16,8 @@
package com.vaadin.server;
+import com.vaadin.shared.ui.ErrorLevel;
+
/**
* <code>UserError</code> is a controlled error occurred in application. User
* errors are occur in normal usage of the application and guide the user.
diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
index a0bb648ffb..f74f2141da 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java
@@ -45,7 +45,6 @@ import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.ComponentSizeValidator;
import com.vaadin.server.ErrorMessage;
-import com.vaadin.server.ErrorMessage.ErrorLevel;
import com.vaadin.server.Extension;
import com.vaadin.server.Resource;
import com.vaadin.server.Responsive;
@@ -62,6 +61,7 @@ import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.Registration;
import com.vaadin.shared.ui.ComponentStateUtil;
import com.vaadin.shared.ui.ContentMode;
+import com.vaadin.shared.ui.ErrorLevel;
import com.vaadin.shared.util.SharedUtil;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
@@ -723,8 +723,10 @@ public abstract class AbstractComponent extends AbstractClientConnector
ErrorMessage error = getErrorMessage();
if (null != error) {
getState().errorMessage = error.getFormattedHtmlMessage();
+ getState().errorLevel = error.getErrorLevel();
} else {
getState().errorMessage = null;
+ getState().errorLevel = null;
}
}
diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java
index 385c6b5f5c..ac3a22eb41 100644
--- a/server/src/main/java/com/vaadin/ui/TabSheet.java
+++ b/server/src/main/java/com/vaadin/ui/TabSheet.java
@@ -1314,9 +1314,15 @@ public class TabSheet extends AbstractComponentContainer
public void setComponentError(ErrorMessage componentError) {
this.componentError = componentError;
- String formattedHtmlMessage = componentError != null
- ? componentError.getFormattedHtmlMessage() : null;
- tabState.componentError = formattedHtmlMessage;
+ if (componentError != null) {
+ tabState.componentError = componentError
+ .getFormattedHtmlMessage();
+ tabState.componentErrorLevel = componentError.getErrorLevel();
+ } else {
+ tabState.componentError = null;
+ tabState.componentErrorLevel = null;
+ }
+
markAsDirty();
}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
index 018aa25cd4..b2a32efaa0 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java
@@ -28,13 +28,13 @@ import org.jsoup.parser.Tag;
import org.junit.Before;
import org.junit.Test;
-import com.vaadin.server.ErrorMessage.ErrorLevel;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.FileResource;
import com.vaadin.server.Responsive;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
+import com.vaadin.shared.ui.ErrorLevel;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button;
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java
index 84c2534f84..48d9646c37 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTestBase.java
@@ -24,11 +24,11 @@ import java.util.Locale;
import org.junit.Test;
-import com.vaadin.server.ErrorMessage.ErrorLevel;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.FileResource;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UserError;
+import com.vaadin.shared.ui.ErrorLevel;
import com.vaadin.tests.design.DeclarativeTestBase;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.declarative.DesignContext;