import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
import com.vaadin.terminal.gwt.client.BrowserInfo;\r
import com.vaadin.terminal.gwt.client.ContainerResizedListener;\r
-import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
-import com.vaadin.terminal.gwt.client.UIDL;\r
import com.vaadin.terminal.gwt.client.Util;\r
import com.vaadin.terminal.gwt.client.VConsole;\r
\r
-public class VSlider extends SimpleFocusablePanel implements VPaintableWidget,\r
- Field, ContainerResizedListener {\r
+public class VSlider extends SimpleFocusablePanel implements Field,\r
+ ContainerResizedListener {\r
\r
public static final String CLASSNAME = "v-slider";\r
\r
\r
String id;\r
\r
- private boolean immediate;\r
- private boolean disabled;\r
- private boolean readonly;\r
+ boolean immediate;\r
+ boolean disabled;\r
+ boolean readonly;\r
\r
private int acceleration = 1;\r
- private double min;\r
- private double max;\r
- private int resolution;\r
- private Double value;\r
- private boolean vertical;\r
+ double min;\r
+ double max;\r
+ int resolution;\r
+ Double value;\r
+ boolean vertical;\r
\r
private final HTML feedback = new HTML("", false);\r
private final VOverlay feedbackPopup = new VOverlay(true, false, true) {\r
feedbackPopup.setWidget(feedback);\r
}\r
\r
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
-\r
- this.client = client;\r
- id = uidl.getId();\r
-\r
- // Ensure correct implementation\r
- if (client.updateComponent(this, uidl, true)) {\r
- return;\r
- }\r
-\r
- immediate = uidl.getBooleanAttribute("immediate");\r
- disabled = uidl.getBooleanAttribute("disabled");\r
- readonly = uidl.getBooleanAttribute("readonly");\r
-\r
- vertical = uidl.hasAttribute("vertical");\r
-\r
- String style = "";\r
- if (uidl.hasAttribute("style")) {\r
- style = uidl.getStringAttribute("style");\r
- }\r
-\r
- if (vertical) {\r
- addStyleName(CLASSNAME + "-vertical");\r
- } else {\r
- removeStyleName(CLASSNAME + "-vertical");\r
- }\r
-\r
- min = uidl.getDoubleAttribute("min");\r
- max = uidl.getDoubleAttribute("max");\r
- resolution = uidl.getIntAttribute("resolution");\r
- value = new Double(uidl.getDoubleVariable("value"));\r
-\r
- setFeedbackValue(value);\r
-\r
- buildBase();\r
-\r
- if (!vertical) {\r
- // Draw handle with a delay to allow base to gain maximum width\r
- Scheduler.get().scheduleDeferred(new Command() {\r
- public void execute() {\r
- buildHandle();\r
- setValue(value, false);\r
- }\r
- });\r
- } else {\r
- buildHandle();\r
- setValue(value, false);\r
- }\r
- }\r
-\r
- private void setFeedbackValue(double value) {\r
+ void setFeedbackValue(double value) {\r
String currentValue = "" + value;\r
if (resolution == 0) {\r
currentValue = "" + new Double(value).intValue();\r
}\r
}\r
\r
- private void buildBase() {\r
+ void buildBase() {\r
final String styleAttribute = vertical ? "height" : "width";\r
final String domProperty = vertical ? "offsetHeight" : "offsetWidth";\r
\r
// TODO attach listeners for focusing and arrow keys\r
}\r
\r
- private void buildHandle() {\r
+ void buildHandle() {\r
final String handleAttribute = vertical ? "marginTop" : "marginLeft";\r
\r
DOM.setStyleAttribute(handle, handleAttribute, "0");\r
\r
}\r
\r
- private void setValue(Double value, boolean updateToServer) {\r
+ void setValue(Double value, boolean updateToServer) {\r
if (value == null) {\r
return;\r
}\r
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.core.client.Scheduler;\r
+import com.google.gwt.user.client.Command;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+\r
+public class VSliderPaintable extends VAbstractPaintableWidget {\r
+\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+\r
+ getWidgetForPaintable().client = client;\r
+ getWidgetForPaintable().id = uidl.getId();\r
+\r
+ // Ensure correct implementation\r
+ if (client.updateComponent(this, uidl, true)) {\r
+ return;\r
+ }\r
+\r
+ getWidgetForPaintable().immediate = uidl\r
+ .getBooleanAttribute("immediate");\r
+ getWidgetForPaintable().disabled = uidl.getBooleanAttribute("disabled");\r
+ getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");\r
+\r
+ getWidgetForPaintable().vertical = uidl.hasAttribute("vertical");\r
+\r
+ String style = "";\r
+ if (uidl.hasAttribute("style")) {\r
+ style = uidl.getStringAttribute("style");\r
+ }\r
+\r
+ if (getWidgetForPaintable().vertical) {\r
+ getWidgetForPaintable().addStyleName(\r
+ VSlider.CLASSNAME + "-vertical");\r
+ } else {\r
+ getWidgetForPaintable().removeStyleName(\r
+ VSlider.CLASSNAME + "-vertical");\r
+ }\r
+\r
+ getWidgetForPaintable().min = uidl.getDoubleAttribute("min");\r
+ getWidgetForPaintable().max = uidl.getDoubleAttribute("max");\r
+ getWidgetForPaintable().resolution = uidl.getIntAttribute("resolution");\r
+ getWidgetForPaintable().value = new Double(\r
+ uidl.getDoubleVariable("value"));\r
+\r
+ getWidgetForPaintable().setFeedbackValue(getWidgetForPaintable().value);\r
+\r
+ getWidgetForPaintable().buildBase();\r
+\r
+ if (!getWidgetForPaintable().vertical) {\r
+ // Draw handle with a delay to allow base to gain maximum width\r
+ Scheduler.get().scheduleDeferred(new Command() {\r
+ public void execute() {\r
+ getWidgetForPaintable().buildHandle();\r
+ getWidgetForPaintable().setValue(\r
+ getWidgetForPaintable().value, false);\r
+ }\r
+ });\r
+ } else {\r
+ getWidgetForPaintable().buildHandle();\r
+ getWidgetForPaintable().setValue(getWidgetForPaintable().value,\r
+ false);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public VSlider getWidgetForPaintable() {\r
+ return (VSlider) super.getWidgetForPaintable();\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VSlider.class);\r
+ }\r
+\r
+}\r