import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-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 VButton extends FocusWidget implements VPaintableWidget,
- ClickHandler, FocusHandler, BlurHandler {
+public class VButton extends FocusWidget implements ClickHandler, FocusHandler,
+ BlurHandler {
public static final String CLASSNAME = "v-button";
private static final String CLASSNAME_PRESSED = "v-pressed";
protected int mousedownX = 0;
protected int mousedownY = 0;
- protected String id;
+ protected String paintableId;
protected ApplicationConnection client;
private int tabIndex = 0;
- private boolean disableOnClick = false;
+ protected boolean disableOnClick = false;
/*
* BELOW PRIVATE MEMBERS COPY-PASTED FROM GWT CustomButton
private boolean disallowNextClick = false;
private boolean isHovering;
- private HandlerRegistration focusHandlerRegistration;
- private HandlerRegistration blurHandlerRegistration;
+ protected HandlerRegistration focusHandlerRegistration;
+ protected HandlerRegistration blurHandlerRegistration;
- private int clickShortcut = 0;
+ protected int clickShortcut = 0;
public VButton() {
super(DOM.createDiv());
addClickHandler(this);
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- // Ensure correct implementation,
- // but don't let container manage caption etc.
- if (client.updateComponent(this, uidl, false)) {
- return;
- }
-
- focusHandlerRegistration = EventHelper.updateFocusHandler(this, client,
- focusHandlerRegistration);
- blurHandlerRegistration = EventHelper.updateBlurHandler(this, client,
- blurHandlerRegistration);
-
- // Save details
- this.client = client;
- id = uidl.getId();
-
- // Set text
- setText(uidl.getStringAttribute("caption"));
-
- disableOnClick = uidl.hasAttribute(ATTR_DISABLE_ON_CLICK);
-
- // handle error
- if (uidl.hasAttribute("error")) {
- if (errorIndicatorElement == null) {
- errorIndicatorElement = DOM.createSpan();
- errorIndicatorElement.setClassName("v-errorindicator");
- }
- wrapper.insertBefore(errorIndicatorElement, captionElement);
-
- } else if (errorIndicatorElement != null) {
- wrapper.removeChild(errorIndicatorElement);
- errorIndicatorElement = null;
- }
-
- if (uidl.hasAttribute("icon")) {
- if (icon == null) {
- icon = new Icon(client);
- wrapper.insertBefore(icon.getElement(), captionElement);
- }
- icon.setUri(uidl.getStringAttribute("icon"));
- } else {
- if (icon != null) {
- wrapper.removeChild(icon.getElement());
- icon = null;
- }
- }
-
- if (uidl.hasAttribute("keycode")) {
- clickShortcut = uidl.getIntAttribute("keycode");
- }
- }
-
public void setText(String text) {
captionElement.setInnerText(text);
}
*/
public void onBrowserEvent(Event event) {
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
if (DOM.eventGetType(event) == Event.ONLOAD) {
Util.notifyParentOfSizeChange(this, true);
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (id == null || client == null) {
+ if (paintableId == null || client == null) {
return;
}
if (BrowserInfo.get().isSafari()) {
}
if (disableOnClick) {
setEnabled(false);
- client.updateVariable(id, "disabledOnClick", true, false);
+ client.updateVariable(paintableId, "disabledOnClick", true, false);
}
- client.updateVariable(id, "state", true, false);
+ client.updateVariable(paintableId, "state", true, false);
// Add mouse details
MouseEventDetails details = new MouseEventDetails(
event.getNativeEvent(), getElement());
- client.updateVariable(id, "mousedetails", details.serialize(), true);
+ client.updateVariable(paintableId, "mousedetails", details.serialize(),
+ true);
clickPending = false;
}
}-*/;
public void onFocus(FocusEvent arg0) {
- client.updateVariable(id, EventId.FOCUS, "", true);
+ client.updateVariable(paintableId, EventId.FOCUS, "", true);
}
public void onBlur(BlurEvent arg0) {
- client.updateVariable(id, EventId.BLUR, "", true);
+ client.updateVariable(paintableId, EventId.BLUR, "", true);
}
public Widget getWidgetForPaintable() {
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-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 VNativeButton extends Button implements VPaintableWidget,
- ClickHandler, FocusHandler, BlurHandler {
+public class VNativeButton extends Button implements ClickHandler,
+ FocusHandler, BlurHandler {
public static final String CLASSNAME = "v-nativebutton";
protected String width = null;
- protected String id;
+ protected String paintableId;
protected ApplicationConnection client;
*/
private boolean clickPending;
- private HandlerRegistration focusHandlerRegistration;
- private HandlerRegistration blurHandlerRegistration;
+ protected HandlerRegistration focusHandlerRegistration;
+ protected HandlerRegistration blurHandlerRegistration;
- private boolean disableOnClick = false;
+ protected boolean disableOnClick = false;
public VNativeButton() {
setStyleName(CLASSNAME);
sinkEvents(Event.ONMOUSEUP);
}
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
-
- // Ensure correct implementation,
- // but don't let container manage caption etc.
- if (client.updateComponent(this, uidl, false)) {
- return;
- }
-
- disableOnClick = uidl.hasAttribute(VButton.ATTR_DISABLE_ON_CLICK);
-
- focusHandlerRegistration = EventHelper.updateFocusHandler(this, client,
- focusHandlerRegistration);
- blurHandlerRegistration = EventHelper.updateBlurHandler(this, client,
- blurHandlerRegistration);
-
- // Save details
- this.client = client;
- id = uidl.getId();
-
- // Set text
- setText(uidl.getStringAttribute("caption"));
-
- // handle error
- if (uidl.hasAttribute("error")) {
- if (errorIndicatorElement == null) {
- errorIndicatorElement = DOM.createSpan();
- errorIndicatorElement.setClassName("v-errorindicator");
- }
- getElement().insertBefore(errorIndicatorElement, captionElement);
-
- } else if (errorIndicatorElement != null) {
- getElement().removeChild(errorIndicatorElement);
- errorIndicatorElement = null;
- }
-
- if (uidl.hasAttribute("icon")) {
- if (icon == null) {
- icon = new Icon(client);
- getElement().insertBefore(icon.getElement(), captionElement);
- }
- icon.setUri(uidl.getStringAttribute("icon"));
- } else {
- if (icon != null) {
- getElement().removeChild(icon.getElement());
- icon = null;
- }
- }
-
- }
-
@Override
public void setText(String text) {
captionElement.setInnerText(text);
}
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
}
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (id == null || client == null) {
+ if (paintableId == null || client == null) {
return;
}
}
if (disableOnClick) {
setEnabled(false);
- client.updateVariable(id, "disabledOnClick", true, false);
+ client.updateVariable(paintableId, "disabledOnClick", true, false);
}
// Add mouse details
MouseEventDetails details = new MouseEventDetails(
event.getNativeEvent(), getElement());
- client.updateVariable(id, "mousedetails", details.serialize(), false);
+ client.updateVariable(paintableId, "mousedetails", details.serialize(),
+ false);
- client.updateVariable(id, "state", true, true);
+ client.updateVariable(paintableId, "state", true, true);
clickPending = false;
}
public void onFocus(FocusEvent arg0) {
- client.updateVariable(id, EventId.FOCUS, "", true);
+ client.updateVariable(paintableId, EventId.FOCUS, "", true);
}
public void onBlur(BlurEvent arg0) {
- client.updateVariable(id, EventId.BLUR, "", true);
+ client.updateVariable(paintableId, EventId.BLUR, "", true);
}
@Override
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.ui.VButton;
+import com.vaadin.terminal.gwt.client.ui.VButtonPaintable;
import com.vaadin.tools.ReflectTools;
import com.vaadin.ui.ClientWidget.LoadStyle;
import com.vaadin.ui.Component.Focusable;
* @since 3.0
*/
@SuppressWarnings("serial")
-@ClientWidget(value = VButton.class, loadStyle = LoadStyle.EAGER)
+@ClientWidget(value = VButtonPaintable.class, loadStyle = LoadStyle.EAGER)
public class Button extends AbstractComponent implements
FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, Focusable,
Action.ShortcutNotifier {
*/
package com.vaadin.ui;
-import com.vaadin.terminal.gwt.client.ui.VNativeButton;
+import com.vaadin.terminal.gwt.client.ui.VNativeButtonPaintable;
@SuppressWarnings("serial")
-@ClientWidget(VNativeButton.class)
+@ClientWidget(VNativeButtonPaintable.class)
public class NativeButton extends Button {
public NativeButton() {