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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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.Paintable;
  10. import com.vaadin.terminal.gwt.client.UIDL;
  11. import com.vaadin.ui.ProgressIndicator;
  12. @Component(ProgressIndicator.class)
  13. public class ProgressIndicatorConnector extends AbstractFieldConnector
  14. implements Paintable {
  15. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  16. if (!isRealUpdate(uidl)) {
  17. return;
  18. }
  19. // Save details
  20. getWidget().client = client;
  21. getWidget().indeterminate = uidl.getBooleanAttribute("indeterminate");
  22. if (getWidget().indeterminate) {
  23. String basename = VProgressIndicator.CLASSNAME + "-indeterminate";
  24. getWidget().addStyleName(basename);
  25. if (!isEnabled()) {
  26. getWidget().addStyleName(basename + "-disabled");
  27. } else {
  28. getWidget().removeStyleName(basename + "-disabled");
  29. }
  30. } else {
  31. try {
  32. final float f = Float.parseFloat(uidl
  33. .getStringAttribute("state"));
  34. final int size = Math.round(100 * f);
  35. DOM.setStyleAttribute(getWidget().indicator, "width", size
  36. + "%");
  37. } catch (final Exception e) {
  38. }
  39. }
  40. if (isEnabled()) {
  41. getWidget().interval = uidl.getIntAttribute("pollinginterval");
  42. getWidget().poller.scheduleRepeating(getWidget().interval);
  43. }
  44. }
  45. @Override
  46. protected Widget createWidget() {
  47. return GWT.create(VProgressIndicator.class);
  48. }
  49. @Override
  50. public VProgressIndicator getWidget() {
  51. return (VProgressIndicator) super.getWidget();
  52. }
  53. }