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.

VSliderPaintable.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.core.client.Scheduler;
  7. import com.google.gwt.user.client.Command;
  8. import com.google.gwt.user.client.ui.Widget;
  9. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  10. import com.vaadin.terminal.gwt.client.UIDL;
  11. public class VSliderPaintable extends VAbstractPaintableWidget {
  12. @Override
  13. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  14. getWidgetForPaintable().client = client;
  15. getWidgetForPaintable().id = uidl.getId();
  16. // Ensure correct implementation
  17. super.updateFromUIDL(uidl, client);
  18. if (!isRealUpdate(uidl)) {
  19. return;
  20. }
  21. getWidgetForPaintable().immediate = uidl
  22. .getBooleanAttribute("immediate");
  23. getWidgetForPaintable().disabled = uidl.getBooleanAttribute("disabled");
  24. getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");
  25. getWidgetForPaintable().vertical = uidl.hasAttribute("vertical");
  26. String style = "";
  27. if (uidl.hasAttribute("style")) {
  28. style = uidl.getStringAttribute("style");
  29. }
  30. if (getWidgetForPaintable().vertical) {
  31. getWidgetForPaintable().addStyleName(
  32. VSlider.CLASSNAME + "-vertical");
  33. } else {
  34. getWidgetForPaintable().removeStyleName(
  35. VSlider.CLASSNAME + "-vertical");
  36. }
  37. getWidgetForPaintable().min = uidl.getDoubleAttribute("min");
  38. getWidgetForPaintable().max = uidl.getDoubleAttribute("max");
  39. getWidgetForPaintable().resolution = uidl.getIntAttribute("resolution");
  40. getWidgetForPaintable().value = new Double(
  41. uidl.getDoubleVariable("value"));
  42. getWidgetForPaintable().setFeedbackValue(getWidgetForPaintable().value);
  43. getWidgetForPaintable().buildBase();
  44. if (!getWidgetForPaintable().vertical) {
  45. // Draw handle with a delay to allow base to gain maximum width
  46. Scheduler.get().scheduleDeferred(new Command() {
  47. public void execute() {
  48. getWidgetForPaintable().buildHandle();
  49. getWidgetForPaintable().setValue(
  50. getWidgetForPaintable().value, false);
  51. }
  52. });
  53. } else {
  54. getWidgetForPaintable().buildHandle();
  55. getWidgetForPaintable().setValue(getWidgetForPaintable().value,
  56. false);
  57. }
  58. }
  59. @Override
  60. public VSlider getWidgetForPaintable() {
  61. return (VSlider) super.getWidgetForPaintable();
  62. }
  63. @Override
  64. protected Widget createWidget() {
  65. return GWT.create(VSlider.class);
  66. }
  67. }