aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJens Jansson <peppe@vaadin.com>2012-01-26 16:09:33 +0200
committerJens Jansson <peppe@vaadin.com>2012-01-26 16:09:33 +0200
commit1efde21bc399ce4fb0e48e8a2e2b4aed401a18ff (patch)
tree0a9b3fd39a89645d9ccf6917556ba51b9dc5b3c8 /src
parentefeb6788645ad33075bb1d29c246f2c3cf717ab0 (diff)
downloadvaadin-framework-1efde21bc399ce4fb0e48e8a2e2b4aed401a18ff.tar.gz
vaadin-framework-1efde21bc399ce4fb0e48e8a2e2b4aed401a18ff.zip
Splitted up VButton and VNativeButton into paintable and widget
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VButton.java85
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java80
-rw-r--r--src/com/vaadin/ui/Button.java3
-rw-r--r--src/com/vaadin/ui/NativeButton.java4
4 files changed, 33 insertions, 139 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VButton.java b/src/com/vaadin/terminal/gwt/client/ui/VButton.java
index 074df531a8..f8397d4a39 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VButton.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VButton.java
@@ -22,16 +22,13 @@ import com.google.gwt.user.client.ui.FocusWidget;
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";
@@ -43,7 +40,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
protected int mousedownX = 0;
protected int mousedownY = 0;
- protected String id;
+ protected String paintableId;
protected ApplicationConnection client;
@@ -66,7 +63,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
private int tabIndex = 0;
- private boolean disableOnClick = false;
+ protected boolean disableOnClick = false;
/*
* BELOW PRIVATE MEMBERS COPY-PASTED FROM GWT CustomButton
@@ -89,10 +86,10 @@ public class VButton extends FocusWidget implements VPaintableWidget,
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());
@@ -114,59 +111,6 @@ public class VButton extends FocusWidget implements VPaintableWidget,
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);
}
@@ -187,7 +131,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
*/
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);
@@ -349,7 +293,7 @@ public class VButton extends FocusWidget implements VPaintableWidget,
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (id == null || client == null) {
+ if (paintableId == null || client == null) {
return;
}
if (BrowserInfo.get().isSafari()) {
@@ -357,15 +301,16 @@ public class VButton extends FocusWidget implements VPaintableWidget,
}
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;
}
@@ -499,11 +444,11 @@ public class VButton extends FocusWidget implements VPaintableWidget,
}-*/;
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() {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
index 97d0747496..9991769e46 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
@@ -18,22 +18,19 @@ import com.google.gwt.user.client.ui.Button;
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;
@@ -50,10 +47,10 @@ public class VNativeButton extends Button implements VPaintableWidget,
*/
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);
@@ -68,56 +65,6 @@ public class VNativeButton extends Button implements VPaintableWidget,
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);
@@ -143,7 +90,7 @@ public class VNativeButton extends Button implements VPaintableWidget,
}
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
}
@@ -161,7 +108,7 @@ public class VNativeButton extends Button implements VPaintableWidget,
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (id == null || client == null) {
+ if (paintableId == null || client == null) {
return;
}
@@ -170,24 +117,25 @@ public class VNativeButton extends Button implements VPaintableWidget,
}
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
diff --git a/src/com/vaadin/ui/Button.java b/src/com/vaadin/ui/Button.java
index 6d9ef0b59d..8f677a9775 100644
--- a/src/com/vaadin/ui/Button.java
+++ b/src/com/vaadin/ui/Button.java
@@ -23,6 +23,7 @@ import com.vaadin.terminal.PaintException;
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;
@@ -36,7 +37,7 @@ 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 {
diff --git a/src/com/vaadin/ui/NativeButton.java b/src/com/vaadin/ui/NativeButton.java
index 46d13c4150..b7b7fcb38c 100644
--- a/src/com/vaadin/ui/NativeButton.java
+++ b/src/com/vaadin/ui/NativeButton.java
@@ -3,10 +3,10 @@
*/
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() {