import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.EventHelper;
+import com.vaadin.terminal.gwt.client.MouseEventDetails;
+import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
import com.vaadin.terminal.gwt.client.communication.FieldRpc.FocusAndBlurServerRpc;
import com.vaadin.terminal.gwt.client.communication.RpcProxy;
import com.vaadin.terminal.gwt.client.communication.StateChangeEvent;
@Component(value = Button.class, loadStyle = LoadStyle.EAGER)
public class ButtonConnector extends AbstractComponentConnector implements
- BlurHandler, FocusHandler {
+ BlurHandler, FocusHandler, ClickHandler {
private ButtonServerRpc rpc = RpcProxy.create(ButtonServerRpc.class, this);
private FocusAndBlurServerRpc focusBlurProxy = RpcProxy.create(
@Override
public void init() {
super.init();
- getWidget().buttonRpcProxy = rpc;
+ getWidget().addClickHandler(this);
getWidget().client = getConnection();
- getWidget().paintableId = getConnectorId();
}
@Override
// Set text
getWidget().setText(getState().getCaption());
- getWidget().disableOnClick = getState().isDisableOnClick();
-
// handle error
if (null != getState().getErrorMessage()) {
if (getWidget().errorIndicatorElement == null) {
// there is a listener on server side
focusBlurProxy.blur();
}
+
+ public void onClick(ClickEvent event) {
+ if (getState().isDisableOnClick()) {
+ getWidget().setEnabled(false);
+ rpc.disableOnClick();
+ }
+
+ // Add mouse details
+ MouseEventDetails details = MouseEventDetailsBuilder
+ .buildMouseEventDetails(event.getNativeEvent(), getWidget()
+ .getElement());
+ rpc.click(details);
+
+ }
}
import com.google.gwt.user.client.ui.FocusWidget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.MouseEventDetails;
-import com.vaadin.terminal.gwt.client.MouseEventDetailsBuilder;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.Icon;
protected int mousedownX = 0;
protected int mousedownY = 0;
- protected String paintableId;
-
protected ApplicationConnection client;
protected final Element wrapper = DOM.createSpan();
private int tabIndex = 0;
- protected boolean disableOnClick = false;
-
/*
* BELOW PRIVATE MEMBERS COPY-PASTED FROM GWT CustomButton
*/
private boolean isHovering;
protected int clickShortcut = 0;
- // TODO Move this to VButtonPaintable
- ButtonServerRpc buttonRpcProxy;
public VButton() {
super(DOM.createDiv());
* .dom.client.ClickEvent)
*/
public void onClick(ClickEvent event) {
- if (paintableId == null || client == null) {
- return;
- }
if (BrowserInfo.get().isSafari()) {
VButton.this.setFocus(true);
}
- if (disableOnClick) {
- setEnabled(false);
- buttonRpcProxy.disableOnClick();
- }
-
- // Add mouse details
- MouseEventDetails details = MouseEventDetailsBuilder
- .buildMouseEventDetails(event.getNativeEvent(), getElement());
- buttonRpcProxy.click(details);
clickPending = false;
}
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.ComponentConnector;
+import com.vaadin.terminal.gwt.client.ConnectorHierarchyChangeEvent;
import com.vaadin.terminal.gwt.client.LayoutManager;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.Paintable;
getWidget().setPopupPosition(positionx, positiony);
}
- boolean showingUrl = false;
int childIndex = 0;
- UIDL childUidl = uidl.getChildUIDL(childIndex++);
-
- final ComponentConnector lo = client.getPaintable(childUidl);
- if (getWidget().layout != null) {
- if (getWidget().layout != lo) {
- // remove old
- getWidget().contentPanel.remove(getWidget().layout.getWidget());
- // add new
- if (!showingUrl) {
- getWidget().contentPanel.setWidget(lo.getWidget());
- }
- getWidget().layout = lo;
- }
- } else if (!showingUrl) {
- getWidget().contentPanel.setWidget(lo.getWidget());
- getWidget().layout = lo;
- }
// we may have actions
- if (uidl.getChildCount() > 1) {
- final int cnt = uidl.getChildCount();
- for (int i = 1; i < cnt; i++) {
- childUidl = uidl.getChildUIDL(i);
- if (childUidl.getTag().equals("actions")) {
- if (getWidget().shortcutHandler == null) {
- getWidget().shortcutHandler = new ShortcutActionHandler(
- getConnectorId(), client);
- }
- getWidget().shortcutHandler.updateActionMap(childUidl);
+ for (int i = 0; i < uidl.getChildCount(); i++) {
+ UIDL childUidl = uidl.getChildUIDL(i);
+ if (childUidl.getTag().equals("actions")) {
+ if (getWidget().shortcutHandler == null) {
+ getWidget().shortcutHandler = new ShortcutActionHandler(
+ getConnectorId(), client);
}
+ getWidget().shortcutHandler.updateActionMap(childUidl);
}
}
if (uidl.hasAttribute("bringToFront")) {
/*
- * Focus as a side-efect. Will be overridden by
+ * Focus as a side-effect. Will be overridden by
* ApplicationConnection if another component was focused by the
* server side.
*/
return GWT.create(VWindow.class);
}
+ @Override
+ public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
+ super.onConnectorHierarchyChange(event);
+
+ // We always have 1 child, unless the child is hidden
+ Widget newChildWidget = null;
+ ComponentConnector newChild = null;
+ if (getChildren().size() == 1) {
+ newChild = getChildren().get(0);
+ newChildWidget = newChild.getWidget();
+ }
+
+ getWidget().layout = newChild;
+ getWidget().setWidget(newChildWidget);
+ }
+
public void layout() {
LayoutManager lm = getLayoutManager();
VWindow window = getWidget();