changeset 7573:d114805cda20

RT-37964: [Accessibility] implement a set focus action Follow-up: implementing REQUEST_FOCUS on ListCell, TableCell, TreeCell, TreeTableCell. Common on Windows
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Tue, 22 Jul 2014 16:52:49 -0700
parents 1eaf140df101
children e248baa75433
files modules/controls/src/main/java/javafx/scene/control/ListCell.java modules/controls/src/main/java/javafx/scene/control/TableCell.java modules/controls/src/main/java/javafx/scene/control/TreeCell.java modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java
diffstat 4 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/javafx/scene/control/ListCell.java	Tue Jul 22 16:25:15 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/ListCell.java	Tue Jul 22 16:52:49 2014 -0700
@@ -572,5 +572,22 @@
             default: return super.queryAccessibleAttribute(attribute, parameters);
         }
     }
+
+    @Override
+    public void executeAccessibleAction(AccessibleAction action, Object... parameters) {
+        switch (action) {
+            case REQUEST_FOCUS: {
+                ListView<T> listView = getListView();
+                if (listView != null) {
+                    FocusModel<T> fm = listView.getFocusModel();
+                    if (fm != null) {
+                        fm.focus(getIndex());
+                    }
+                }
+                break;
+            }
+            default: super.executeAccessibleAction(action, parameters);
+        }
+    }
 }
 
--- a/modules/controls/src/main/java/javafx/scene/control/TableCell.java	Tue Jul 22 16:25:15 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TableCell.java	Tue Jul 22 16:52:49 2014 -0700
@@ -790,4 +790,20 @@
         }
     }
 
+    @Override
+    public void executeAccessibleAction(AccessibleAction action, Object... parameters) {
+        switch (action) {
+            case REQUEST_FOCUS: {
+                TableView<S> tableView = getTableView();
+                if (tableView != null) {
+                    TableViewFocusModel<S> fm = tableView.getFocusModel();
+                    if (fm != null) {
+                        fm.focus(getIndex(), getTableColumn());
+                    }
+                }
+                break;
+            }
+            default: super.executeAccessibleAction(action, parameters);
+        }
+    }
 }
--- a/modules/controls/src/main/java/javafx/scene/control/TreeCell.java	Tue Jul 22 16:25:15 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TreeCell.java	Tue Jul 22 16:52:49 2014 -0700
@@ -687,6 +687,16 @@
                 if (treeItem != null) treeItem.setExpanded(false);
                 break;
             }
+            case REQUEST_FOCUS: {
+                TreeView<T> treeView = getTreeView();
+                if (treeView != null) {
+                    FocusModel<TreeItem<T>> fm = treeView.getFocusModel();
+                    if (fm != null) {
+                        fm.focus(getIndex());
+                    }
+                }
+                break;
+            }
             default: super.executeAccessibleAction(action);
         }
     }
--- a/modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java	Tue Jul 22 16:25:15 2014 -0700
+++ b/modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java	Tue Jul 22 16:52:49 2014 -0700
@@ -42,6 +42,7 @@
 import javafx.scene.AccessibleAttribute;
 import javafx.scene.AccessibleRole;
 import javafx.scene.control.TreeTableColumn.CellEditEvent;
+import javafx.scene.control.TreeTableView.TreeTableViewFocusModel;
 
 
 /**
@@ -783,4 +784,21 @@
             default: return super.queryAccessibleAttribute(attribute, parameters);
         }
     }
+
+    @Override
+    public void executeAccessibleAction(AccessibleAction action, Object... parameters) {
+        switch (action) {
+            case REQUEST_FOCUS: {
+                TreeTableView<S> treeTableView = getTreeTableView();
+                if (treeTableView != null) {
+                    TreeTableViewFocusModel<S> fm = treeTableView.getFocusModel();
+                    if (fm != null) {
+                        fm.focus(getIndex(), getTableColumn());
+                    }
+                }
+                break;
+            }
+            default: super.executeAccessibleAction(action, parameters);
+        }
+    }
 }