You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserError.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.server;
  17. import com.vaadin.shared.ui.ErrorLevel;
  18. /**
  19. * <code>UserError</code> is a controlled error occurred in application. User
  20. * errors are occur in normal usage of the application and guide the user.
  21. *
  22. * @author Vaadin Ltd.
  23. * @since 3.0
  24. */
  25. @SuppressWarnings("serial")
  26. public class UserError extends AbstractErrorMessage {
  27. /**
  28. * @deprecated As of 7.0, use {@link ContentMode#TEXT} instead    
  29. */
  30. @Deprecated
  31. public static final ContentMode CONTENT_TEXT = ContentMode.TEXT;
  32. /**
  33. * @deprecated As of 7.0, use {@link ContentMode#PREFORMATTED} instead    
  34. */
  35. @Deprecated
  36. public static final ContentMode CONTENT_PREFORMATTED = ContentMode.PREFORMATTED;
  37. /**
  38. * @deprecated As of 7.0, use {@link ContentMode#HTML} instead    
  39. */
  40. @Deprecated
  41. public static final ContentMode CONTENT_XHTML = ContentMode.HTML;
  42. /**
  43. * Creates a textual error message of level ERROR.
  44. *
  45. * @param textErrorMessage
  46. * the text of the error message.
  47. */
  48. public UserError(String textErrorMessage) {
  49. super(textErrorMessage);
  50. }
  51. /**
  52. * Creates an error message with level and content mode.
  53. *
  54. * @param message
  55. * the error message.
  56. * @param contentMode
  57. * the content Mode.
  58. * @param errorLevel
  59. * the level of error.
  60. */
  61. public UserError(String message, ContentMode contentMode,
  62. ErrorLevel errorLevel) {
  63. super(message);
  64. if (contentMode == null) {
  65. contentMode = ContentMode.TEXT;
  66. }
  67. if (errorLevel == null) {
  68. errorLevel = ErrorLevel.ERROR;
  69. }
  70. setMode(contentMode);
  71. setErrorLevel(errorLevel);
  72. }
  73. }