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 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright 2000-2014 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.communication.PushMode;
  23. import com.vaadin.shared.ui.TabIndexState;
  24. public class UIState extends TabIndexState {
  25. public TooltipConfigurationState tooltipConfiguration = new TooltipConfigurationState();
  26. public LoadingIndicatorConfigurationState loadingIndicatorConfiguration = new LoadingIndicatorConfigurationState();
  27. public int pollInterval = -1;
  28. // Informing users of assistive devices, that the content of this container
  29. // is announced automatically and does not need to be navigated into
  30. public String overlayContainerLabel = "This content is announced automatically and does not need to be navigated into.";
  31. public Map<String, NotificationTypeConfiguration> notificationConfigurations = new HashMap<String, NotificationTypeConfiguration>();
  32. {
  33. notificationConfigurations.put("error",
  34. new NotificationTypeConfiguration("Error: ",
  35. " - close with ESC-key", NotificationRole.ALERT));
  36. notificationConfigurations.put("warning",
  37. new NotificationTypeConfiguration("Warning: ", null,
  38. NotificationRole.ALERT));
  39. notificationConfigurations.put("humanized",
  40. new NotificationTypeConfiguration("Info: ", null,
  41. NotificationRole.ALERT));
  42. notificationConfigurations.put("tray",
  43. new NotificationTypeConfiguration("Status: ", null,
  44. NotificationRole.STATUS));
  45. notificationConfigurations.put("assistive",
  46. new NotificationTypeConfiguration("Note: ", null,
  47. NotificationRole.STATUS));
  48. }
  49. /**
  50. * State related to the Page class.
  51. */
  52. public PageState pageState = new PageState();
  53. /**
  54. * State related to the LocaleService class.
  55. */
  56. public LocaleServiceState localeServiceState = new LocaleServiceState();
  57. /**
  58. * Configuration for the push channel
  59. */
  60. public PushConfigurationState pushConfiguration = new PushConfigurationState();
  61. public String theme;
  62. {
  63. primaryStyleName = "v-ui";
  64. // Default is 1 for legacy reasons
  65. tabIndex = 1;
  66. }
  67. public static class LoadingIndicatorConfigurationState implements
  68. Serializable {
  69. public int firstDelay = 300;
  70. public int secondDelay = 1500;
  71. public int thirdDelay = 5000;
  72. }
  73. public static class TooltipConfigurationState implements Serializable {
  74. public int openDelay = 750;
  75. public int quickOpenDelay = 100;
  76. public int quickOpenTimeout = 1000;
  77. public int closeTimeout = 300;
  78. public int maxWidth = 500;
  79. }
  80. public static class NotificationTypeConfiguration implements Serializable {
  81. public String prefix;
  82. public String postfix;
  83. public NotificationRole notificationRole = NotificationRole.ALERT;
  84. public NotificationTypeConfiguration() {
  85. }
  86. public NotificationTypeConfiguration(String prefix, String postfix,
  87. NotificationRole role) {
  88. this.prefix = prefix;
  89. this.postfix = postfix;
  90. notificationRole = role;
  91. }
  92. }
  93. public static class PushConfigurationState implements Serializable {
  94. public static final String TRANSPORT_PARAM = "transport";
  95. public static final String FALLBACK_TRANSPORT_PARAM = "fallbackTransport";
  96. public PushMode mode = PushMode.DISABLED;
  97. public Map<String, String> parameters = new HashMap<String, String>();
  98. {
  99. parameters
  100. .put(TRANSPORT_PARAM, Transport.WEBSOCKET.getIdentifier());
  101. parameters.put(FALLBACK_TRANSPORT_PARAM,
  102. Transport.LONG_POLLING.getIdentifier());
  103. }
  104. }
  105. public static class LocaleServiceState implements Serializable {
  106. public List<LocaleData> localeData = new ArrayList<LocaleData>();
  107. }
  108. public static class LocaleData implements Serializable {
  109. public String name;
  110. public String[] monthNames;
  111. public String[] shortMonthNames;
  112. public String[] shortDayNames;
  113. public String[] dayNames;
  114. public int firstDayOfWeek;
  115. public String dateFormat;
  116. public boolean twelveHourClock;
  117. public String hourMinuteDelimiter;
  118. public String am;
  119. public String pm;
  120. }
  121. }