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.2KB

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 VAbstractPaintableWidget {
  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. getWidgetForPaintable().client = client;
  21. getWidgetForPaintable().indeterminate = uidl
  22. .getBooleanAttribute("indeterminate");
  23. if (getWidgetForPaintable().indeterminate) {
  24. String basename = VProgressIndicator.CLASSNAME + "-indeterminate";
  25. getWidgetForPaintable().addStyleName(basename);
  26. if (uidl.getBooleanAttribute("disabled")) {
  27. getWidgetForPaintable().addStyleName(basename + "-disabled");
  28. } else {
  29. getWidgetForPaintable().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(getWidgetForPaintable().indicator,
  37. "width", size + "%");
  38. } catch (final Exception e) {
  39. }
  40. }
  41. if (!uidl.getBooleanAttribute("disabled")) {
  42. getWidgetForPaintable().interval = uidl
  43. .getIntAttribute("pollinginterval");
  44. getWidgetForPaintable().poller
  45. .scheduleRepeating(getWidgetForPaintable().interval);
  46. }
  47. }
  48. @Override
  49. protected Widget createWidget() {
  50. return GWT.create(VProgressIndicator.class);
  51. }
  52. @Override
  53. public VProgressIndicator getWidgetForPaintable() {
  54. return (VProgressIndicator) super.getWidgetForPaintable();
  55. }
  56. }