import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.EventHelper;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
-import com.vaadin.terminal.gwt.client.VPaintableWidget;
-import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;
public class VCheckBox extends com.google.gwt.user.client.ui.CheckBox implements
- VPaintableWidget, Field, FocusHandler, BlurHandler {
+ Field, FocusHandler, BlurHandler {
public static final String VARIABLE_STATE = "state";
ApplicationConnection client;
- private Element errorIndicatorElement;
+ Element errorIndicatorElement;
- private Icon icon;
+ Icon icon;
- private HandlerRegistration focusHandlerRegistration;
- private HandlerRegistration blurHandlerRegistration;
+ HandlerRegistration focusHandlerRegistration;
+ HandlerRegistration blurHandlerRegistration;
public VCheckBox() {
setStyleName(CLASSNAME);
}
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- // Save details
- this.client = client;
- id = uidl.getId();
-
- // Ensure correct implementation
- if (client.updateComponent(this, uidl, false)) {
- return;
- }
-
- focusHandlerRegistration = EventHelper.updateFocusHandler(this, client,
- focusHandlerRegistration);
- blurHandlerRegistration = EventHelper.updateBlurHandler(this, client,
- blurHandlerRegistration);
-
- if (uidl.hasAttribute("error")) {
- if (errorIndicatorElement == null) {
- errorIndicatorElement = DOM.createSpan();
- errorIndicatorElement.setInnerHTML(" ");
- DOM.setElementProperty(errorIndicatorElement, "className",
- "v-errorindicator");
- DOM.appendChild(getElement(), errorIndicatorElement);
- DOM.sinkEvents(errorIndicatorElement, VTooltip.TOOLTIP_EVENTS
- | Event.ONCLICK);
- } else {
- DOM.setStyleAttribute(errorIndicatorElement, "display", "");
- }
- } else if (errorIndicatorElement != null) {
- DOM.setStyleAttribute(errorIndicatorElement, "display", "none");
- }
-
- if (uidl.hasAttribute("readonly")) {
- setEnabled(false);
- }
-
- if (uidl.hasAttribute("icon")) {
- if (icon == null) {
- icon = new Icon(client);
- DOM.insertChild(getElement(), icon.getElement(), 1);
- icon.sinkEvents(VTooltip.TOOLTIP_EVENTS);
- icon.sinkEvents(Event.ONCLICK);
- }
- icon.setUri(uidl.getStringAttribute("icon"));
- } else if (icon != null) {
- // detach icon
- DOM.removeChild(getElement(), icon.getElement());
- icon = null;
- }
-
- // Set text
- setText(uidl.getStringAttribute("caption"));
- setValue(uidl.getBooleanVariable(VARIABLE_STATE));
- immediate = uidl.getBooleanAttribute("immediate");
- }
-
@Override
public void onBrowserEvent(Event event) {
if (icon != null && (event.getTypeInt() == Event.ONCLICK)
Util.notifyParentOfSizeChange(this, true);
}
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
}
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.DOM;\r
+import com.google.gwt.user.client.Event;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.EventHelper;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+import com.vaadin.terminal.gwt.client.VTooltip;\r
+\r
+public class VCheckBoxPaintable extends VAbstractPaintableWidget {\r
+\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ // Save details\r
+ getWidgetForPaintable().client = client;\r
+ getWidgetForPaintable().id = uidl.getId();\r
+\r
+ // Ensure correct implementation\r
+ if (client.updateComponent(this, uidl, false)) {\r
+ return;\r
+ }\r
+\r
+ getWidgetForPaintable().focusHandlerRegistration = EventHelper\r
+ .updateFocusHandler(this, client,\r
+ getWidgetForPaintable().focusHandlerRegistration);\r
+ getWidgetForPaintable().blurHandlerRegistration = EventHelper\r
+ .updateBlurHandler(this, client,\r
+ getWidgetForPaintable().blurHandlerRegistration);\r
+\r
+ if (uidl.hasAttribute("error")) {\r
+ if (getWidgetForPaintable().errorIndicatorElement == null) {\r
+ getWidgetForPaintable().errorIndicatorElement = DOM\r
+ .createSpan();\r
+ getWidgetForPaintable().errorIndicatorElement\r
+ .setInnerHTML(" ");\r
+ DOM.setElementProperty(\r
+ getWidgetForPaintable().errorIndicatorElement,\r
+ "className", "v-errorindicator");\r
+ DOM.appendChild(getWidgetForPaintable().getElement(),\r
+ getWidgetForPaintable().errorIndicatorElement);\r
+ DOM.sinkEvents(getWidgetForPaintable().errorIndicatorElement,\r
+ VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);\r
+ } else {\r
+ DOM.setStyleAttribute(\r
+ getWidgetForPaintable().errorIndicatorElement,\r
+ "display", "");\r
+ }\r
+ } else if (getWidgetForPaintable().errorIndicatorElement != null) {\r
+ DOM.setStyleAttribute(\r
+ getWidgetForPaintable().errorIndicatorElement, "display",\r
+ "none");\r
+ }\r
+\r
+ if (uidl.hasAttribute("readonly")) {\r
+ getWidgetForPaintable().setEnabled(false);\r
+ }\r
+\r
+ if (uidl.hasAttribute("icon")) {\r
+ if (getWidgetForPaintable().icon == null) {\r
+ getWidgetForPaintable().icon = new Icon(client);\r
+ DOM.insertChild(getWidgetForPaintable().getElement(),\r
+ getWidgetForPaintable().icon.getElement(), 1);\r
+ getWidgetForPaintable().icon\r
+ .sinkEvents(VTooltip.TOOLTIP_EVENTS);\r
+ getWidgetForPaintable().icon.sinkEvents(Event.ONCLICK);\r
+ }\r
+ getWidgetForPaintable().icon\r
+ .setUri(uidl.getStringAttribute("icon"));\r
+ } else if (getWidgetForPaintable().icon != null) {\r
+ // detach icon\r
+ DOM.removeChild(getWidgetForPaintable().getElement(),\r
+ getWidgetForPaintable().icon.getElement());\r
+ getWidgetForPaintable().icon = null;\r
+ }\r
+\r
+ // Set text\r
+ getWidgetForPaintable().setText(uidl.getStringAttribute("caption"));\r
+ getWidgetForPaintable()\r
+ .setValue(\r
+ uidl.getBooleanVariable(getWidgetForPaintable().VARIABLE_STATE));\r
+ getWidgetForPaintable().immediate = uidl\r
+ .getBooleanAttribute("immediate");\r
+ }\r
+\r
+ @Override\r
+ public VCheckBox getWidgetForPaintable() {\r
+ return (VCheckBox) super.getWidgetForPaintable();\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VCheckBox.class);\r
+ }\r
+\r
+}\r