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.

ReconnectDialogConfiguration.java 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * Copyright 2000-2018 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.ui;
  17. import java.io.Serializable;
  18. /**
  19. * Provides method for configuring the reconnect dialog.
  20. *
  21. * @since 7.6
  22. * @author Vaadin Ltd
  23. */
  24. public interface ReconnectDialogConfiguration extends Serializable {
  25. /**
  26. * Gets the text to show in the reconnect dialog when trying to re-establish
  27. * the server connection.
  28. *
  29. * @return the text to show in the reconnect dialog
  30. */
  31. public String getDialogText();
  32. /**
  33. * Sets the text to show in the reconnect dialog when trying to
  34. * re-establish. the server connection
  35. *
  36. * @param dialogText
  37. * the text to show in the reconnect dialog
  38. */
  39. public void setDialogText(String dialogText);
  40. /**
  41. * Gets the text to show in the reconnect dialog after giving up trying to
  42. * reconnect ({@link #getReconnectAttempts()} reached).
  43. *
  44. * @return the text to show in the reconnect dialog after giving up
  45. */
  46. public String getDialogTextGaveUp();
  47. /**
  48. * Sets the text to show in the reconnect dialog after giving up trying to
  49. * reconnect ({@link #getReconnectAttempts()} reached).
  50. *
  51. * @param dialogTextGaveUp
  52. * the text to show in the reconnect dialog after giving up
  53. */
  54. public void setDialogTextGaveUp(String dialogTextGaveUp);
  55. /**
  56. * Gets the number of times to try to reconnect to the server before giving
  57. * up.
  58. *
  59. * @return the number of times to try to reconnect
  60. */
  61. public int getReconnectAttempts();
  62. /**
  63. * Sets the number of times to try to reconnect to the server before giving
  64. * up.
  65. *
  66. * @param reconnectAttempts
  67. * the number of times to try to reconnect
  68. */
  69. public void setReconnectAttempts(int reconnectAttempts);
  70. /**
  71. * Gets the interval (in milliseconds) between reconnect attempts.
  72. *
  73. * @return the interval (in ms) between reconnect attempts
  74. */
  75. public int getReconnectInterval();
  76. /**
  77. * Sets the interval (in milliseconds) between reconnect attempts.
  78. *
  79. * @param reconnectInterval
  80. * the interval (in ms) between reconnect attempts
  81. */
  82. public void setReconnectInterval(int reconnectInterval);
  83. /**
  84. * Gets the timeout (in milliseconds) between noticing a loss of connection
  85. * and showing the dialog.
  86. *
  87. * @return the time to wait before showing a dialog
  88. */
  89. public int getDialogGracePeriod();
  90. /**
  91. * Sets the timeout (in milliseconds) between noticing a loss of connection
  92. * and showing the dialog.
  93. *
  94. * @param dialogGracePeriod
  95. * the time to wait before showing a dialog
  96. */
  97. public void setDialogGracePeriod(int dialogGracePeriod);
  98. /**
  99. * Sets the modality of the dialog.
  100. * <p>
  101. * If the dialog is set to modal, it will prevent the usage of the
  102. * application while the dialog is being shown. If not modal, the user can
  103. * continue to use the application as normally and all server events will be
  104. * queued until connection has been re-established.
  105. *
  106. * @param dialogModal
  107. * true to make the dialog modal, false otherwise
  108. */
  109. public void setDialogModal(boolean dialogModal);
  110. /**
  111. * Checks the modality of the dialog.
  112. * <p>
  113. *
  114. * @see #setDialogModal(boolean)
  115. * @return true if the dialog is modal, false otherwise
  116. */
  117. public boolean isDialogModal();
  118. }
  119. class ReconnectDialogConfigurationImpl implements ReconnectDialogConfiguration {
  120. private final UI ui;
  121. public ReconnectDialogConfigurationImpl(UI ui) {
  122. this.ui = ui;
  123. }
  124. @Override
  125. public String getDialogText() {
  126. return ui.getState(false).reconnectDialogConfiguration.dialogText;
  127. }
  128. @Override
  129. public void setDialogText(String dialogText) {
  130. ui.getState().reconnectDialogConfiguration.dialogText = dialogText;
  131. }
  132. @Override
  133. public String getDialogTextGaveUp() {
  134. return ui.getState(false).reconnectDialogConfiguration.dialogTextGaveUp;
  135. }
  136. @Override
  137. public void setDialogTextGaveUp(String dialogTextGaveUp) {
  138. ui.getState().reconnectDialogConfiguration.dialogTextGaveUp = dialogTextGaveUp;
  139. }
  140. @Override
  141. public int getReconnectAttempts() {
  142. return ui
  143. .getState(false).reconnectDialogConfiguration.reconnectAttempts;
  144. }
  145. @Override
  146. public void setReconnectAttempts(int reconnectAttempts) {
  147. ui.getState().reconnectDialogConfiguration.reconnectAttempts = reconnectAttempts;
  148. }
  149. @Override
  150. public int getReconnectInterval() {
  151. return ui
  152. .getState(false).reconnectDialogConfiguration.reconnectInterval;
  153. }
  154. @Override
  155. public void setReconnectInterval(int reconnectInterval) {
  156. ui.getState().reconnectDialogConfiguration.reconnectInterval = reconnectInterval;
  157. }
  158. @Override
  159. public int getDialogGracePeriod() {
  160. return ui
  161. .getState(false).reconnectDialogConfiguration.dialogGracePeriod;
  162. }
  163. @Override
  164. public void setDialogGracePeriod(int dialogGracePeriod) {
  165. ui.getState().reconnectDialogConfiguration.dialogGracePeriod = dialogGracePeriod;
  166. }
  167. @Override
  168. public boolean isDialogModal() {
  169. return ui.getState(false).reconnectDialogConfiguration.dialogModal;
  170. }
  171. @Override
  172. public void setDialogModal(boolean dialogModal) {
  173. ui.getState().reconnectDialogConfiguration.dialogModal = dialogModal;
  174. }
  175. }