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.

ProgressIndicatorConnector.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.v7.client.ui.progressindicator;
  17. import com.google.gwt.user.client.Timer;
  18. import com.vaadin.client.communication.StateChangeEvent;
  19. import com.vaadin.client.ui.VProgressBar;
  20. import com.vaadin.client.ui.VProgressIndicator;
  21. import com.vaadin.shared.ui.Connect;
  22. import com.vaadin.shared.ui.progressindicator.ProgressIndicatorServerRpc;
  23. import com.vaadin.shared.ui.progressindicator.ProgressIndicatorState;
  24. import com.vaadin.v7.ui.ProgressIndicator;
  25. /**
  26. * Connector for {@link VProgressBar} with polling support.
  27. *
  28. * @since 7.0
  29. * @author Vaadin Ltd
  30. * @deprecated as of 7.1, use {@link ProgressBarConnector} combined with server
  31. * push or UI polling.
  32. */
  33. @Connect(ProgressIndicator.class)
  34. @Deprecated
  35. public class ProgressIndicatorConnector extends ProgressBarConnector {
  36. @Override
  37. public ProgressIndicatorState getState() {
  38. return (ProgressIndicatorState) super.getState();
  39. }
  40. private Timer poller = new Timer() {
  41. @Override
  42. public void run() {
  43. getRpcProxy(ProgressIndicatorServerRpc.class).poll();
  44. }
  45. };
  46. @Override
  47. public void onStateChanged(StateChangeEvent stateChangeEvent) {
  48. super.onStateChanged(stateChangeEvent);
  49. if (isEnabled()) {
  50. poller.scheduleRepeating(getState().pollingInterval);
  51. } else {
  52. poller.cancel();
  53. }
  54. }
  55. @Override
  56. public VProgressIndicator getWidget() {
  57. return (VProgressIndicator) super.getWidget();
  58. }
  59. @Override
  60. public void onUnregister() {
  61. super.onUnregister();
  62. poller.cancel();
  63. }
  64. }