]> source.dussan.org Git - vaadin-framework.git/commitdiff
reverting dom structures be similar to previous version
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 20 May 2010 10:22:37 +0000 (10:22 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 20 May 2010 10:22:37 +0000 (10:22 +0000)
svn changeset:13268/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/FocusableScrollPanel.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/SimpleFocusablePanel.java [new file with mode: 0644]
src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
src/com/vaadin/terminal/gwt/client/ui/VTree.java

diff --git a/src/com/vaadin/terminal/gwt/client/ui/FocusableScrollPanel.java b/src/com/vaadin/terminal/gwt/client/ui/FocusableScrollPanel.java
new file mode 100644 (file)
index 0000000..cebdf10
--- /dev/null
@@ -0,0 +1,69 @@
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.dom.client.Style;
+import com.google.gwt.dom.client.Style.Overflow;
+import com.google.gwt.dom.client.Style.Position;
+import com.google.gwt.event.dom.client.HasScrollHandlers;
+import com.google.gwt.event.dom.client.ScrollEvent;
+import com.google.gwt.event.dom.client.ScrollHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.ScrollPanel;
+
+/**
+ * A scrollhandlers similar to {@link ScrollPanel}.
+ * 
+ */
+public class FocusableScrollPanel extends SimpleFocusablePanel implements
+        HasScrollHandlers {
+
+    public FocusableScrollPanel() {
+        // Prevent IE standard mode bug when a AbsolutePanel is contained.
+        Style style = getElement().getStyle();
+        style.setOverflow(Overflow.AUTO);
+        style.setProperty("zoom", "1");
+        style.setPosition(Position.RELATIVE);
+    }
+
+    public HandlerRegistration addScrollHandler(ScrollHandler handler) {
+        return addDomHandler(handler, ScrollEvent.getType());
+    }
+
+    /**
+     * Gets the horizontal scroll position.
+     * 
+     * @return the horizontal scroll position, in pixels
+     */
+    public int getHorizontalScrollPosition() {
+        return getElement().getScrollLeft();
+    }
+
+    /**
+     * Gets the vertical scroll position.
+     * 
+     * @return the vertical scroll position, in pixels
+     */
+    public int getScrollPosition() {
+        return getElement().getScrollTop();
+    }
+
+    /**
+     * Sets the horizontal scroll position.
+     * 
+     * @param position
+     *            the new horizontal scroll position, in pixels
+     */
+    public void setHorizontalScrollPosition(int position) {
+        getElement().setScrollLeft(position);
+    }
+
+    /**
+     * Sets the vertical scroll position.
+     * 
+     * @param position
+     *            the new vertical scroll position, in pixels
+     */
+    public void setScrollPosition(int position) {
+        getElement().setScrollTop(position);
+    }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/SimpleFocusablePanel.java b/src/com/vaadin/terminal/gwt/client/ui/SimpleFocusablePanel.java
new file mode 100644 (file)
index 0000000..e6c53ba
--- /dev/null
@@ -0,0 +1,48 @@
+package com.vaadin.terminal.gwt.client.ui;
+
+import com.google.gwt.event.dom.client.BlurEvent;
+import com.google.gwt.event.dom.client.BlurHandler;
+import com.google.gwt.event.dom.client.FocusEvent;
+import com.google.gwt.event.dom.client.FocusHandler;
+import com.google.gwt.event.dom.client.HasBlurHandlers;
+import com.google.gwt.event.dom.client.HasFocusHandlers;
+import com.google.gwt.event.dom.client.HasKeyDownHandlers;
+import com.google.gwt.event.dom.client.HasKeyPressHandlers;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+import com.google.gwt.event.dom.client.KeyDownHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.user.client.ui.SimplePanel;
+
+/**
+ * Compared to FocusPanel in GWT this panel does not support eg. accesskeys, but
+ * is simpler by its dom hierarchy nor supports focusing via java api.
+ */
+public class SimpleFocusablePanel extends SimplePanel implements
+        HasFocusHandlers, HasBlurHandlers, HasKeyDownHandlers,
+        HasKeyPressHandlers {
+
+    public SimpleFocusablePanel() {
+        // make focusable, as we don't need access key magic we don't need to
+        // use FocusImpl.createFocusable
+        getElement().setTabIndex(0);
+    }
+
+    public HandlerRegistration addFocusHandler(FocusHandler handler) {
+        return addDomHandler(handler, FocusEvent.getType());
+    }
+
+    public HandlerRegistration addBlurHandler(BlurHandler handler) {
+        return addDomHandler(handler, BlurEvent.getType());
+    }
+
+    public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
+        return addDomHandler(handler, KeyDownEvent.getType());
+    }
+
+    public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
+        return addDomHandler(handler, KeyPressEvent.getType());
+    }
+
+}
index a68cfb8d4af01fe9179492d812d3b05154f312bc..d691e71294b1d0032aa4d1c906de8a2b7d1d97e3 100644 (file)
@@ -43,10 +43,8 @@ import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.Timer;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.FocusPanel;
 import com.google.gwt.user.client.ui.Panel;
 import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.ScrollPanel;
 import com.google.gwt.user.client.ui.UIObject;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
@@ -234,8 +232,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
     private final TableFooter tFoot = new TableFooter();
 
-    private final ScrollPanel bodyContainer = new ScrollPanel();
-    private final FocusPanel bodyContainerFocus = new FocusPanel(bodyContainer);
+    private final FocusableScrollPanel scrollBodyPanel = new FocusableScrollPanel();
 
     private int totalRows;
 
@@ -279,7 +276,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
     private int multiselectmode;
 
     public VScrollTable() {
-        bodyContainerFocus.setStyleName(CLASSNAME + "-body-wrapper");
+        scrollBodyPanel.setStyleName(CLASSNAME + "-body-wrapper");
 
         /*
          * Firefox auto-repeat works correctly only if we use a key press
@@ -287,21 +284,21 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
          * handler
          */
         if (BrowserInfo.get().isGecko()) {
-            bodyContainerFocus.addKeyPressHandler(this);
+            scrollBodyPanel.addKeyPressHandler(this);
         } else {
-            bodyContainerFocus.addKeyDownHandler(this);
+            scrollBodyPanel.addKeyDownHandler(this);
         }
 
-        bodyContainerFocus.addFocusHandler(this);
-        bodyContainerFocus.addBlurHandler(this);
+        scrollBodyPanel.addFocusHandler(this);
+        scrollBodyPanel.addBlurHandler(this);
 
-        bodyContainer.addScrollHandler(this);
-        bodyContainer.setStyleName(CLASSNAME + "-body");
+        scrollBodyPanel.addScrollHandler(this);
+        scrollBodyPanel.setStyleName(CLASSNAME + "-body");
 
         setStyleName(CLASSNAME);
 
         add(tHead);
-        add(bodyContainerFocus);
+        add(scrollBodyPanel);
         add(tFoot);
 
         rowRequestHandler = new RowRequestHandler();
@@ -643,7 +640,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         if (firstvisible != lastRequestedFirstvisible && scrollBody != null) {
             // received 'surprising' firstvisible from server: scroll there
             firstRowInViewPort = firstvisible;
-            bodyContainer.setScrollPosition((int) (firstvisible * scrollBody
+            scrollBodyPanel.setScrollPosition((int) (firstvisible * scrollBody
                     .getRowHeight()));
         }
 
@@ -732,7 +729,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                 // run overflow fix for scrollable area
                 DeferredCommand.addCommand(new Command() {
                     public void execute() {
-                        Util.runWebkitOverflowAutoFix(bodyContainer
+                        Util.runWebkitOverflowAutoFix(scrollBodyPanel
                                 .getElement());
                     }
                 });
@@ -746,7 +743,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
             scrollBody.renderInitialRows(rowData, uidl
                     .getIntAttribute("firstrow"), uidl.getIntAttribute("rows"));
-            bodyContainer.add(scrollBody);
+            scrollBodyPanel.add(scrollBody);
             initialContentReceived = true;
             if (isAttached()) {
                 sizeInit();
@@ -1365,8 +1362,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             if (needsSpaceForHorizontalSrollbar) {
                 bodyHeight += Util.getNativeScrollbarSize();
             }
-            bodyContainer.setHeight(bodyHeight + "px");
-            Util.runWebkitOverflowAutoFix(bodyContainer.getElement());
+            scrollBodyPanel.setHeight(bodyHeight + "px");
+            Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
         }
 
         isNewBody = false;
@@ -1376,7 +1373,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             // without
             DeferredCommand.addCommand(new Command() {
                 public void execute() {
-                    bodyContainer
+                    scrollBodyPanel
                             .setScrollPosition((int) (firstvisible * scrollBody
                                     .getRowHeight()));
                     firstRowInViewPort = firstvisible;
@@ -1419,7 +1416,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         } else {
             int fakeheight = (int) Math.round(scrollBody.getRowHeight()
                     * totalRows);
-            int availableHeight = bodyContainer.getElement().getPropertyInt(
+            int availableHeight = scrollBodyPanel.getElement().getPropertyInt(
                     "clientHeight");
             if (fakeheight > availableHeight) {
                 return true;
@@ -1439,7 +1436,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
         Style style = scrollPositionElement.getStyle();
         style.setMarginLeft(getElement().getOffsetWidth() / 2 - 80, Unit.PX);
-        style.setMarginTop(-bodyContainer.getOffsetHeight(), Unit.PX);
+        style.setMarginTop(-scrollBodyPanel.getOffsetHeight(), Unit.PX);
 
         // indexes go from 1-totalRows, as rowheaders in index-mode indicate
         int last = (firstRowInViewPort + pageLength);
@@ -1831,7 +1828,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                                     cid, false);
                         }
                         // get also cache columns at the same request
-                        bodyContainer.setScrollPosition(0);
+                        scrollBodyPanel.setScrollPosition(0);
                         firstvisible = 0;
                         rowRequestHandler.setReqFirstRow(0);
                         rowRequestHandler.setReqRows((int) (2 * pageLength
@@ -3006,7 +3003,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         }
 
         public int getAvailableWidth() {
-            int availW = bodyContainer.getOffsetWidth() - getBorderWidth();
+            int availW = scrollBodyPanel.getOffsetWidth() - getBorderWidth();
             return availW;
         }
 
@@ -4090,7 +4087,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         }
 
         int rowHeight = (int) scrollBody.getRowHeight();
-        int bodyH = bodyContainer.getOffsetHeight();
+        int bodyH = scrollBodyPanel.getOffsetHeight();
         int rowsAtOnce = bodyH / rowHeight;
         boolean anotherPartlyVisible = ((bodyH % rowHeight) != 0);
         if (anotherPartlyVisible) {
@@ -4106,8 +4103,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                 if (currentlyVisible < pageLength
                         && currentlyVisible < totalRows) {
                     // shake scrollpanel to fill empty space
-                    bodyContainer.setScrollPosition(scrollTop + 1);
-                    bodyContainer.setScrollPosition(scrollTop - 1);
+                    scrollBodyPanel.setScrollPosition(scrollTop + 1);
+                    scrollBodyPanel.setScrollPosition(scrollTop - 1);
                 }
             }
         }
@@ -4222,7 +4219,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     bodyHeight += Util.getNativeScrollbarSize();
                 }
                 int heightBefore = getOffsetHeight();
-                bodyContainer.setHeight(bodyHeight + "px");
+                scrollBodyPanel.setHeight(bodyHeight + "px");
                 if (heightBefore != getOffsetHeight()) {
                     Util.notifyParentOfSizeChange(VScrollTable.this, false);
                 }
@@ -4230,7 +4227,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             scrollBody.reLayoutComponents();
             DeferredCommand.addCommand(new Command() {
                 public void execute() {
-                    Util.runWebkitOverflowAutoFix(bodyContainer.getElement());
+                    Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
                 }
             });
         }
@@ -4243,7 +4240,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      */
     private void setContentWidth(int pixels) {
         tHead.setWidth(pixels + "px");
-        bodyContainer.setWidth(pixels + "px");
+        scrollBodyPanel.setWidth(pixels + "px");
         tFoot.setWidth(pixels + "px");
     }
 
@@ -4254,8 +4251,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      */
     private int getBorderWidth() {
         if (borderWidth < 0) {
-            borderWidth = Util.measureHorizontalPaddingAndBorder(bodyContainer
-                    .getElement(), 2);
+            borderWidth = Util.measureHorizontalPaddingAndBorder(
+                    scrollBodyPanel.getElement(), 2);
             if (borderWidth < 0) {
                 borderWidth = 0;
             }
@@ -4276,7 +4273,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             if (contentH < 0) {
                 contentH = 0;
             }
-            bodyContainer.setHeight(contentH + "px");
+            scrollBodyPanel.setHeight(contentH + "px");
         }
     }
 
@@ -4292,15 +4289,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         if (contentAreaBorderHeight < 0) {
             if (BrowserInfo.get().isIE7() || BrowserInfo.get().isIE6()) {
                 contentAreaBorderHeight = Util
-                        .measureVerticalBorder(bodyContainer.getElement());
+                        .measureVerticalBorder(scrollBodyPanel.getElement());
             } else {
-                DOM.setStyleAttribute(bodyContainer.getElement(), "overflow",
+                DOM.setStyleAttribute(scrollBodyPanel.getElement(), "overflow",
                         "hidden");
-                int oh = bodyContainer.getOffsetHeight();
-                int ch = bodyContainer.getElement().getPropertyInt(
+                int oh = scrollBodyPanel.getOffsetHeight();
+                int ch = scrollBodyPanel.getElement().getPropertyInt(
                         "clientHeight");
                 contentAreaBorderHeight = oh - ch;
-                DOM.setStyleAttribute(bodyContainer.getElement(), "overflow",
+                DOM.setStyleAttribute(scrollBodyPanel.getElement(), "overflow",
                         "auto");
             }
         }
@@ -4319,7 +4316,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             // Webkit may sometimes get an odd rendering bug (white space
             // between header and body), see bug #3875. Running
             // overflow hack here to shake body element a bit.
-            Util.runWebkitOverflowAutoFix(bodyContainer.getElement());
+            Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
         }
     }
 
@@ -4336,7 +4333,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                 if (visible) {
                     DeferredCommand.addCommand(new Command() {
                         public void execute() {
-                            bodyContainer
+                            scrollBodyPanel
                                     .setScrollPosition((int) (firstRowInViewPort * scrollBody
                                             .getRowHeight()));
                         }
@@ -4369,13 +4366,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      * user scrolls
      */
     public void onScroll(ScrollEvent event) {
-        scrollLeft = bodyContainer.getElement().getScrollLeft();
-        scrollTop = bodyContainer.getScrollPosition();
+        scrollLeft = scrollBodyPanel.getElement().getScrollLeft();
+        scrollTop = scrollBodyPanel.getScrollPosition();
         if (!initializedAndAttached) {
             return;
         }
         if (!enabled) {
-            bodyContainer
+            scrollBodyPanel
                     .setScrollPosition((int) (firstRowInViewPort * scrollBody
                             .getRowHeight()));
             return;
@@ -4663,15 +4660,15 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
             // Scroll up or down if needed
             int rowTop = focusedRow.getElement().getAbsoluteTop();
-            int scrollTop = bodyContainer.getElement().getAbsoluteTop();
+            int scrollTop = scrollBodyPanel.getElement().getAbsoluteTop();
             int scrollBottom = scrollTop
-                    + bodyContainer.getElement().getOffsetHeight();
+                    + scrollBodyPanel.getElement().getOffsetHeight();
             if (rowTop > scrollBottom - focusedRow.getOffsetHeight()) {
-                bodyContainer.setScrollPosition(bodyContainer
+                scrollBodyPanel.setScrollPosition(scrollBodyPanel
                         .getScrollPosition()
                         + focusedRow.getOffsetHeight());
             } else if (rowTop < scrollTop) {
-                bodyContainer.setScrollPosition(bodyContainer
+                scrollBodyPanel.setScrollPosition(scrollBodyPanel
                         .getScrollPosition()
                         - focusedRow.getOffsetHeight());
             }
@@ -4699,7 +4696,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
         // Down navigation
         if (selectMode == SELECT_MODE_NONE && keycode == getNavigationDownKey()) {
-            bodyContainer.setScrollPosition(bodyContainer.getScrollPosition()
+            scrollBodyPanel.setScrollPosition(scrollBodyPanel
+                    .getScrollPosition()
                     + scrollingVelocity);
             return true;
         } else if (keycode == getNavigationDownKey()) {
@@ -4715,7 +4713,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
         // Up navigation
         if (selectMode == SELECT_MODE_NONE && keycode == getNavigationUpKey()) {
-            bodyContainer.setScrollPosition(bodyContainer.getScrollPosition()
+            scrollBodyPanel.setScrollPosition(scrollBodyPanel
+                    .getScrollPosition()
                     - scrollingVelocity);
             return true;
         } else if (keycode == getNavigationUpKey()) {
@@ -4730,14 +4729,14 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
         if (keycode == getNavigationLeftKey()) {
             // Left navigation
-            bodyContainer.setHorizontalScrollPosition(bodyContainer
+            scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel
                     .getHorizontalScrollPosition()
                     - scrollingVelocity);
             return true;
 
         } else if (keycode == getNavigationRightKey()) {
             // Right navigation
-            bodyContainer.setHorizontalScrollPosition(bodyContainer
+            scrollBodyPanel.setHorizontalScrollPosition(scrollBodyPanel
                     .getHorizontalScrollPosition()
                     + scrollingVelocity);
         }
@@ -4764,7 +4763,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         if (keycode == getNavigationPageDownKey()) {
             int rowHeight = (int) scrollBody.getRowHeight();
             int offset = pageLength * rowHeight - rowHeight;
-            bodyContainer.setScrollPosition(bodyContainer.getScrollPosition()
+            scrollBodyPanel.setScrollPosition(scrollBodyPanel
+                    .getScrollPosition()
                     + offset);
             if (selectMode > SELECT_MODE_NONE) {
                 if (!moveFocusDown(pageLength - 2)) {
@@ -4786,7 +4786,8 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         if (keycode == getNavigationPageUpKey()) {
             int rowHeight = (int) scrollBody.getRowHeight();
             int offset = pageLength * rowHeight - rowHeight;
-            bodyContainer.setScrollPosition(bodyContainer.getScrollPosition()
+            scrollBodyPanel.setScrollPosition(scrollBodyPanel
+                    .getScrollPosition()
                     - offset);
             if (selectMode > SELECT_MODE_NONE) {
                 if (!moveFocusUp(pageLength - 2)) {
@@ -4817,7 +4818,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     selectFirstItemInNextRender = true;
                 }
             }
-            bodyContainer.setScrollPosition(0);
+            scrollBodyPanel.setScrollPosition(0);
             return true;
         }
 
@@ -4834,7 +4835,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
                     selectLastItemInNextRender = true;
                 }
             }
-            bodyContainer.setScrollPosition(scrollBody.getOffsetHeight());
+            scrollBodyPanel.setScrollPosition(scrollBody.getOffsetHeight());
             return true;
         }
 
@@ -4901,7 +4902,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      * .dom.client.FocusEvent)
      */
     public void onFocus(FocusEvent event) {
-        bodyContainer.addStyleName("focused");
+        scrollBodyPanel.addStyleName("focused");
 
         // Focus a row if no row is in focus
         if (focusedRow == null) {
@@ -4917,7 +4918,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      * .dom.client.BlurEvent)
      */
     public void onBlur(BlurEvent event) {
-        bodyContainer.removeStyleName("focused");
+        scrollBodyPanel.removeStyleName("focused");
 
         // Unfocus any row
         setRowFocus(null);
index b0caf4a6599c6ef95080b7b5dc426bb1cb6ca103..e728ddae541e6ffc2fe82e101a317879f830a05c 100644 (file)
@@ -28,10 +28,10 @@ import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.FocusPanel;
 import com.google.gwt.user.client.ui.SimplePanel;
 import com.google.gwt.user.client.ui.UIObject;
 import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.impl.FocusImpl;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.BrowserInfo;
 import com.vaadin.terminal.gwt.client.MouseEventDetails;
@@ -51,8 +51,9 @@ import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
 /**
  * 
  */
-public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
-        FocusHandler, BlurHandler, KeyPressHandler, KeyDownHandler {
+public class VTree extends SimpleFocusablePanel implements Paintable,
+        VHasDropHandler, FocusHandler, BlurHandler, KeyPressHandler,
+        KeyDownHandler {
 
     public static final String CLASSNAME = "v-tree";
 
@@ -101,7 +102,7 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
         super();
         setStyleName(CLASSNAME);
         add(body);
-        
+
         addFocusHandler(this);
         addBlurHandler(this);
 
@@ -151,8 +152,9 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
                         "onselectstart", null);
             }
         } else if (event.getTypeInt() == Event.ONKEYUP) {
-            if (selectionHasChanged) {                
-                if(event.getKeyCode() == getNavigationDownKey() && !event.getShiftKey()){
+            if (selectionHasChanged) {
+                if (event.getKeyCode() == getNavigationDownKey()
+                        && !event.getShiftKey()) {
                     sendSelectionToServer();
                     event.preventDefault();
                 } else if (event.getKeyCode() == getNavigationUpKey()
@@ -170,6 +172,14 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
         }
     }
 
+    private void setFocus(boolean focus) {
+        if (focus) {
+            FocusImpl.getFocusImplForPanel().focus(getElement());
+        } else {
+            FocusImpl.getFocusImplForPanel().blur(getElement());
+        }
+    }
+
     private void updateActionMap(UIDL c) {
         final Iterator it = c.getChildIterator();
         while (it.hasNext()) {
@@ -1043,13 +1053,13 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
      * @param endNodeKey
      *            The end node key
      */
-    private void selectNodeRange(String startNodeKey, String endNodeKey){
-        
+    private void selectNodeRange(String startNodeKey, String endNodeKey) {
+
         TreeNode startNode = keyToNode.get(startNodeKey);
         TreeNode endNode = keyToNode.get(endNodeKey);
 
         // The nodes have the same parent
-        if(startNode.getParent() == endNode.getParent()){
+        if (startNode.getParent() == endNode.getParent()) {
             doSiblingSelection(startNode, endNode);
 
             // The start node is a grandparent of the end node
@@ -1176,18 +1186,18 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
 
         TreeNode commonParent = getCommonGrandParent(startNode, endNode);
         TreeNode startBranch = null, endBranch = null;
-        
+
         // Find the children of the common parent
         List<TreeNode> children;
-        if(commonParent != null){
-            children = commonParent.getChildren(); 
-        }else{
+        if (commonParent != null) {
+            children = commonParent.getChildren();
+        } else {
             children = new LinkedList<TreeNode>();
             for (int w = 0; w < body.getWidgetCount(); w++) {
                 children.add((TreeNode) body.getWidget(w));
             }
         }
-            
+
         // Find the start and end branches
         for (TreeNode node : children) {
             if (nodeIsInBranch(startNode, node)) {
@@ -1549,7 +1559,6 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
             return true;
         }
 
-
         // Navigate left (close branch)
         if (keycode == getNavigationLeftKey()) {
             if (!focusedNode.isLeaf() && focusedNode.getState()) {
@@ -1570,7 +1579,7 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
         if (keycode == getNavigationSelectKey()) {
             if (!focusedNode.isSelected()) {
                 selectNode(focusedNode, !isMultiselect
-                    || multiSelectMode == MULTISELECT_MODE_SIMPLE);
+                        || multiSelectMode == MULTISELECT_MODE_SIMPLE);
             } else {
                 deselectNode(focusedNode);
             }
@@ -1792,6 +1801,4 @@ public class VTree extends FocusPanel implements Paintable, VHasDropHandler,
         return KeyCodes.KEY_END;
     }
 
-
-    
 }