1 package com.vaadin.tests.widgetset.client.minitutorials.v7b1;
3 import com.google.gwt.event.dom.client.KeyPressEvent;
4 import com.google.gwt.event.dom.client.KeyPressHandler;
5 import com.google.gwt.user.client.ui.HTML;
6 import com.google.gwt.user.client.ui.Widget;
7 import com.vaadin.client.ComponentConnector;
8 import com.vaadin.client.ServerConnector;
9 import com.vaadin.client.communication.RpcProxy;
10 import com.vaadin.client.extensions.AbstractExtensionConnector;
11 import com.vaadin.client.ui.VOverlay;
12 import com.vaadin.shared.ui.Connect;
13 import com.vaadin.tests.minitutorials.v7b1.CapsLockWarningWithRpc;
15 @Connect(CapsLockWarningWithRpc.class)
16 public class CapsLockWarningWithRpcConnector extends AbstractExtensionConnector {
18 private CapsLockWarningRpc rpc = RpcProxy.create(CapsLockWarningRpc.class,
22 protected void extend(ServerConnector target) {
23 final Widget passwordWidget = ((ComponentConnector) target).getWidget();
25 final VOverlay warning = new VOverlay();
26 warning.setOwner(passwordWidget);
27 warning.add(new HTML("Caps Lock is enabled!"));
29 passwordWidget.addDomHandler(new KeyPressHandler() {
31 public void onKeyPress(KeyPressEvent event) {
32 if (isEnabled() && isCapsLockOn(event)) {
33 warning.showRelativeTo(passwordWidget);
34 rpc.isCapsLockEnabled(true); // Added to send message to the
38 rpc.isCapsLockEnabled(false); // Added to send message to
42 }, KeyPressEvent.getType());
45 private boolean isCapsLockOn(KeyPressEvent e) {
46 return e.isShiftKeyDown() ^ Character.isUpperCase(e.getCharCode());