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.

VProgressIndicatorPaintable.java 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui;
  5. import com.google.gwt.core.client.GWT;
  6. import com.google.gwt.user.client.DOM;
  7. import com.google.gwt.user.client.ui.Widget;
  8. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  9. import com.vaadin.terminal.gwt.client.UIDL;
  10. public class VProgressIndicatorPaintable extends AbstractComponentConnector {
  11. @Override
  12. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  13. // Ensure correct implementation,
  14. // but don't let container manage caption etc.
  15. super.updateFromUIDL(uidl, client);
  16. if (!isRealUpdate(uidl)) {
  17. return;
  18. }
  19. // Save details
  20. getWidget().client = client;
  21. getWidget().indeterminate = uidl
  22. .getBooleanAttribute("indeterminate");
  23. if (getWidget().indeterminate) {
  24. String basename = VProgressIndicator.CLASSNAME + "-indeterminate";
  25. getWidget().addStyleName(basename);
  26. if (getState().isDisabled()) {
  27. getWidget().addStyleName(basename + "-disabled");
  28. } else {
  29. getWidget().removeStyleName(basename + "-disabled");
  30. }
  31. } else {
  32. try {
  33. final float f = Float.parseFloat(uidl
  34. .getStringAttribute("state"));
  35. final int size = Math.round(100 * f);
  36. DOM.setStyleAttribute(getWidget().indicator,
  37. "width", size + "%");
  38. } catch (final Exception e) {
  39. }
  40. }
  41. if (!getState().isDisabled()) {
  42. getWidget().interval = uidl
  43. .getIntAttribute("pollinginterval");
  44. getWidget().poller
  45. .scheduleRepeating(getWidget().interval);
  46. }
  47. }
  48. @Override
  49. protected Widget createWidget() {
  50. return GWT.create(VProgressIndicator.class);
  51. }
  52. @Override
  53. public VProgressIndicator getWidget() {
  54. return (VProgressIndicator) super.getWidget();
  55. }
  56. }