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.

UIState.java 6.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Copyright 2000-2021 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.shared.ui.ui;
  17. import java.io.Serializable;
  18. import java.util.ArrayList;
  19. import java.util.HashMap;
  20. import java.util.List;
  21. import java.util.Map;
  22. import com.vaadin.shared.annotations.NoLayout;
  23. import com.vaadin.shared.communication.PushMode;
  24. import com.vaadin.shared.ui.AbstractSingleComponentContainerState;
  25. public class UIState extends AbstractSingleComponentContainerState {
  26. /**
  27. * The <i>tabulator index</i> of the field.
  28. */
  29. @NoLayout
  30. public int tabIndex = 0;
  31. public TooltipConfigurationState tooltipConfiguration = new TooltipConfigurationState();
  32. public LoadingIndicatorConfigurationState loadingIndicatorConfiguration = new LoadingIndicatorConfigurationState();
  33. public int pollInterval = -1;
  34. // Informing users of assistive devices, that the content of this container
  35. // is announced automatically and does not need to be navigated into
  36. public String overlayContainerLabel = "This content is announced automatically and does not need to be navigated into.";
  37. public Map<String, NotificationTypeConfiguration> notificationConfigurations = new HashMap<>();
  38. {
  39. notificationConfigurations.put("error",
  40. new NotificationTypeConfiguration("Error: ",
  41. " - close with ESC-key", NotificationRole.ALERT));
  42. notificationConfigurations.put("warning",
  43. new NotificationTypeConfiguration("Warning: ", null,
  44. NotificationRole.ALERT));
  45. notificationConfigurations.put("humanized",
  46. new NotificationTypeConfiguration("Info: ", null,
  47. NotificationRole.ALERT));
  48. // We use alert instead of status for all notifications because
  49. // (at least) Jaws 16 and earlier fail to announce any role=status
  50. // message in Chrome/Firefox
  51. notificationConfigurations.put("tray",
  52. new NotificationTypeConfiguration("Status: ", null,
  53. NotificationRole.ALERT));
  54. notificationConfigurations.put("assistive",
  55. new NotificationTypeConfiguration("Note: ", null,
  56. NotificationRole.ALERT));
  57. }
  58. /**
  59. * State related to the Page class.
  60. */
  61. public PageState pageState = new PageState();
  62. /**
  63. * State related to the LocaleService class.
  64. */
  65. public LocaleServiceState localeServiceState = new LocaleServiceState();
  66. /**
  67. * Configuration for the push channel.
  68. */
  69. public PushConfigurationState pushConfiguration = new PushConfigurationState();
  70. /**
  71. * Currently used theme.
  72. *
  73. * @since 7.3
  74. */
  75. public String theme;
  76. public ReconnectDialogConfigurationState reconnectDialogConfiguration = new ReconnectDialogConfigurationState();
  77. {
  78. primaryStyleName = "v-ui";
  79. // Default is 1 for legacy reasons
  80. tabIndex = 1;
  81. }
  82. /**
  83. * Enable Mobile HTML5 DnD support.
  84. *
  85. * @since 8.1
  86. */
  87. public boolean enableMobileHTML5DnD = false;
  88. /**
  89. * Should the more thorough size check be in use in LayoutManager
  90. * calculations. If this value is changed to {@code false}, the size
  91. * calculations can result in incorrect values if they are triggered while a
  92. * transform animation is ongoing. This can happen e.g. when a PopupView is
  93. * opened.
  94. *
  95. * @since 8.13
  96. */
  97. public boolean thoroughSizeCheck = true;
  98. public static class LoadingIndicatorConfigurationState
  99. implements Serializable {
  100. public int firstDelay = 300;
  101. public int secondDelay = 1500;
  102. public int thirdDelay = 5000;
  103. }
  104. public static class TooltipConfigurationState implements Serializable {
  105. public int openDelay = 750;
  106. public int quickOpenDelay = 100;
  107. public int quickOpenTimeout = 1000;
  108. public int closeTimeout = 300;
  109. public int maxWidth = 500;
  110. }
  111. public static class NotificationTypeConfiguration implements Serializable {
  112. public String prefix;
  113. public String postfix;
  114. public NotificationRole notificationRole = NotificationRole.ALERT;
  115. public NotificationTypeConfiguration() {
  116. }
  117. public NotificationTypeConfiguration(String prefix, String postfix,
  118. NotificationRole role) {
  119. this.prefix = prefix;
  120. this.postfix = postfix;
  121. notificationRole = role;
  122. }
  123. }
  124. public static class PushConfigurationState implements Serializable {
  125. public static final String TRANSPORT_PARAM = "transport";
  126. public static final String FALLBACK_TRANSPORT_PARAM = "fallbackTransport";
  127. public boolean alwaysUseXhrForServerRequests = false;
  128. public PushMode mode = PushMode.DISABLED;
  129. public String pushUrl = null;
  130. public Map<String, String> parameters = new HashMap<>();
  131. {
  132. parameters.put(TRANSPORT_PARAM,
  133. Transport.WEBSOCKET.getIdentifier());
  134. parameters.put(FALLBACK_TRANSPORT_PARAM,
  135. Transport.LONG_POLLING.getIdentifier());
  136. }
  137. }
  138. public static class ReconnectDialogConfigurationState
  139. implements Serializable {
  140. public String dialogText = "Server connection lost, trying to reconnect...";
  141. public String dialogTextGaveUp = "Server connection lost.";
  142. public int reconnectAttempts = 10000;
  143. public int reconnectInterval = 5000;
  144. public int dialogGracePeriod = 400;
  145. public boolean dialogModal = false;
  146. }
  147. public static class LocaleServiceState implements Serializable {
  148. public List<LocaleData> localeData = new ArrayList<>();
  149. }
  150. public static class LocaleData implements Serializable {
  151. public String name;
  152. public String[] monthNames;
  153. public String[] shortMonthNames;
  154. public String[] shortDayNames;
  155. public String[] dayNames;
  156. public int firstDayOfWeek;
  157. public String dateFormat;
  158. public boolean twelveHourClock;
  159. public String hourMinuteDelimiter;
  160. public String am;
  161. public String pm;
  162. }
  163. }