diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-09-27 10:02:29 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-27 10:02:29 +0300 |
commit | 697f770287bb786b6b5d4944a9202d145e4251f5 (patch) | |
tree | 2533cf5d0392129f8094f5d02df15c883f00f304 /shared/src | |
parent | 9776ea2e85468256c70b8618c0e1a2a7ccb8199b (diff) | |
download | vaadin-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 'shared/src')
3 files changed, 77 insertions, 3 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/AbstractComponentState.java b/shared/src/main/java/com/vaadin/shared/AbstractComponentState.java index 81f808f676..9b949111a7 100644 --- a/shared/src/main/java/com/vaadin/shared/AbstractComponentState.java +++ b/shared/src/main/java/com/vaadin/shared/AbstractComponentState.java @@ -21,6 +21,7 @@ import java.util.List; import com.vaadin.shared.annotations.NoLayout; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.ui.ContentMode; +import com.vaadin.shared.ui.ErrorLevel; /** * Default shared state implementation for AbstractComponent. @@ -43,9 +44,15 @@ public class AbstractComponentState extends SharedState { public String id = null; public String primaryStyleName = null; - // HTML formatted error message for the component - // TODO this could be an object with more information, but currently the UI - // only uses the message + /** HTML formatted error message for the component */ public String errorMessage = null; + + /** + * Level of error + * + * @since 8.2 + */ + public ErrorLevel errorLevel = null; + public boolean captionAsHtml = false; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/ErrorLevel.java b/shared/src/main/java/com/vaadin/shared/ui/ErrorLevel.java new file mode 100644 index 0000000000..fe216fb878 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/ErrorLevel.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui; + +/** + * Represents the error levels displayed on components. + * @author Vaadin Ltd + * @since + */ +public enum ErrorLevel { + + /** + * Error level for informational messages. + */ + INFO, + + /** + * Error level for warning messages. + */ + WARNING, + + /** + * Error level for regular messages. + */ + ERROR, + + /** + * Error level for critical messages. + */ + CRITICAL, + + /** + * Error level for system errors and bugs. + */ + SYSTEM; + + /** + * Integer representation of error severity for comparison + * + * @return integer for error severity + */ + public int intValue() { + return ordinal(); + } +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/tabsheet/TabState.java b/shared/src/main/java/com/vaadin/shared/ui/tabsheet/TabState.java index 763f2cf20f..b337d4f063 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/tabsheet/TabState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/tabsheet/TabState.java @@ -19,6 +19,8 @@ import java.io.Serializable; import com.vaadin.shared.ui.ContentMode; +import com.vaadin.shared.ui.ErrorLevel; + /** * Shared state of a single tab in a Tabsheet or an Accordion. * @@ -36,6 +38,13 @@ public class TabState implements Serializable { public String styleName; public String key; public String componentError; + + /** + * Represents the level of error on a tab. + * + * @since 8.2 + */ + public ErrorLevel componentErrorLevel; public String id; public String iconAltText; |