]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #5065
authorJohn Alhroos <john.ahlroos@itmill.com>
Wed, 2 Jun 2010 08:00:48 +0000 (08:00 +0000)
committerJohn Alhroos <john.ahlroos@itmill.com>
Wed, 2 Jun 2010 08:00:48 +0000 (08:00 +0000)
svn changeset:13488/svn branch:6.4

src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java

index 338d6a3c98c12fc043904a2ecff152cf16d196bf..c6f74bc360da5644a008020fd4585ceac65a5ba9 100644 (file)
@@ -815,6 +815,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             setRowFocus(getRenderedRowByKey(focusedRow.getKey()));
         }
 
+        if (!isFocusable()) {
+            scrollBodyPanel.getElement().setTabIndex(-1);
+        } else {
+            scrollBodyPanel.getElement().setTabIndex(0);
+        }
+
         rendering = false;
         headerChangedDuringUpdate = false;
     }
@@ -3818,6 +3824,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
 
                                 event.stopPropagation();
                             }
+
+                            if (!isFocusable()) {
+                                scrollBodyPanel.getElement().setTabIndex(-1);
+                            } else {
+                                scrollBodyPanel.getElement().setTabIndex(0);
+                            }
+
                             break;
                         case Event.ONMOUSEOUT:
                             mDown = false;
@@ -4179,6 +4192,11 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             super.setWidth("");
         }
 
+        if (!isFocusable()) {
+            scrollBodyPanel.getElement().setTabIndex(-1);
+        } else {
+            scrollBodyPanel.getElement().setTabIndex(0);
+        }
     }
 
     private static final int LAZY_COLUMN_ADJUST_TIMEOUT = 300;
@@ -4361,6 +4379,12 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
             // overflow hack here to shake body element a bit.
             Util.runWebkitOverflowAutoFix(scrollBodyPanel.getElement());
         }
+
+        if (!isFocusable()) {
+            scrollBodyPanel.getElement().setTabIndex(-1);
+        } else {
+            scrollBodyPanel.getElement().setTabIndex(0);
+        }
     }
 
     /*
@@ -4945,11 +4969,13 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
      * .dom.client.FocusEvent)
      */
     public void onFocus(FocusEvent event) {
-        scrollBodyPanel.addStyleName("focused");
+        if (isFocusable()) {
+            scrollBodyPanel.addStyleName("focused");
 
-        // Focus a row if no row is in focus
-        if (focusedRow == null) {
-            setRowFocus((VScrollTableRow) scrollBody.iterator().next());
+            // Focus a row if no row is in focus
+            if (focusedRow == null) {
+                setRowFocus((VScrollTableRow) scrollBody.iterator().next());
+            }
         }
     }
 
@@ -4995,4 +5021,21 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
         }
     }
 
+    /**
+     * Can the Table be focused?
+     * 
+     * @return True if the table can be focused, else false
+     */
+    public boolean isFocusable() {
+        if (scrollBody != null) {
+            boolean hasVerticalScrollbars = scrollBody.getOffsetHeight() > scrollBodyPanel
+                    .getOffsetHeight();
+            boolean hasHorizontalScrollbars = scrollBody.getOffsetWidth() > scrollBodyPanel
+                    .getOffsetWidth();
+            return !(!hasHorizontalScrollbars && !hasVerticalScrollbars && selectMode == SELECT_MODE_NONE);
+        }
+
+        return false;
+    }
+
 }