]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added ShortcutActionHandler to IPanel.
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Wed, 13 Feb 2008 08:36:21 +0000 (08:36 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Wed, 13 Feb 2008 08:36:21 +0000 (08:36 +0000)
svn changeset:3787/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IPanel.java
src/com/itmill/toolkit/terminal/gwt/client/ui/IWindow.java
src/com/itmill/toolkit/terminal/gwt/public/default/panel/panel.css

index 8ec49570eef50d7d6baf3df2fb77be6bff7e95a4..621ff3f756fa4d570eaf8c7210535c7510686274 100644 (file)
@@ -43,6 +43,8 @@ public class IPanel extends SimplePanel implements Paintable,
 
     private Paintable layout;
 
+    ShortcutActionHandler shortcutHandler;
+
     public IPanel() {
         super();
         DOM.appendChild(getElement(), captionNode);
@@ -58,6 +60,7 @@ public class IPanel extends SimplePanel implements Paintable,
                         + "-content");
         DOM.setElementProperty(bottomDecoration, "className", CLASSNAME
                 + "-deco");
+        DOM.sinkEvents(getElement(), Event.ONKEYDOWN);
     }
 
     protected Element getContainerElement() {
@@ -148,6 +151,20 @@ public class IPanel extends SimplePanel implements Paintable,
         }
         (layout).updateFromUIDL(layoutUidl, client);
 
+        // We may have actions attached to this panel
+        if (uidl.getChildCount() > 1) {
+            final int cnt = uidl.getChildCount();
+            for (int i = 1; i < cnt; i++) {
+                UIDL childUidl = uidl.getChildUIDL(i);
+                if (childUidl.getTag().equals("actions")) {
+                    if (shortcutHandler == null) {
+                        shortcutHandler = new ShortcutActionHandler(id, client);
+                    }
+                    shortcutHandler.updateActionMap(childUidl);
+                }
+            }
+        }
+
     }
 
     private void handleError(UIDL uidl) {
@@ -256,9 +273,14 @@ public class IPanel extends SimplePanel implements Paintable,
 
     public void onBrowserEvent(Event event) {
         final Element target = DOM.eventGetTarget(event);
+        final int type = DOM.eventGetType(event);
+        if (type == Event.ONKEYDOWN && shortcutHandler != null) {
+            shortcutHandler.handleKeyboardEvent(event);
+            return;
+        }
         if (errorIndicatorElement != null
                 && DOM.compare(target, errorIndicatorElement)) {
-            switch (DOM.eventGetType(event)) {
+            switch (type) {
             case Event.ONMOUSEOVER:
                 if (errorMessage != null) {
                     errorMessage.showAt(errorIndicatorElement);
@@ -280,14 +302,14 @@ public class IPanel extends SimplePanel implements Paintable,
     }
 
     /**
-     * Panal handles dimensions by itself
+     * Panel handles dimensions by itself.
      */
     public void setHeight(String height) {
         // NOP
     }
 
     /**
-     * Panal handles dimensions by itself
+     * Panel handles dimensions by itself.
      */
     public void setWidth(String width) {
         // NOP
index dc4da8d09577517b7b5fce38e096c2e3723454bc..2f174840422190f6d7e1b5f234bc5921dd213bdb 100644 (file)
@@ -182,6 +182,10 @@ public class IWindow extends PopupPanel implements Paintable, ScrollListener {
         id = uidl.getId();
         this.client = client;
 
+        // Workaround needed for Testing Tools (GWT generates window DOM
+        // slightly different in different browsers).
+        DOM.setElementProperty(closeBox, "id", id + "_window_close");
+
         if (uidl.hasAttribute("invisible")) {
             this.hide();
             return;
index 7d0dc4789bbf52cf53a9a8b40ed599a06bf2093c..e6c3ee46b7642fbe92de8d05fb82485c9c411a5a 100644 (file)
@@ -58,6 +58,7 @@
        border-top: none;
        border-bottom: 1px solid #dee2e3;
        background-color: #fff;
+       overflow: auto;
 }
 
 .i-panel-deco {