changeset 7568:62382252b90a

RT-37959: [Accessibility] Review a11y enums Part 2: remove SELECTED_CELLS and SELECTED_ROWS, use SELECTED_ITEMS instead
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Tue, 22 Jul 2014 09:44:28 -0700
parents 9d9b35b0e3f6
children bea785e79ae4
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ListViewSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableRowSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableViewSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableViewSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeViewSkin.java modules/controls/src/main/java/javafx/scene/control/ListView.java modules/controls/src/main/java/javafx/scene/control/TableView.java modules/controls/src/main/java/javafx/scene/control/TreeTableView.java modules/controls/src/main/java/javafx/scene/control/TreeView.java modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java modules/graphics/src/main/java/javafx/scene/AccessibleAttribute.java
diffstat 13 files changed, 33 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ListViewSkin.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ListViewSkin.java	Tue Jul 22 09:44:28 2014 -0700
@@ -510,7 +510,7 @@
                 }
                 return null;
             }
-            case SELECTED_ROWS: {
+            case SELECTED_ITEMS: {
                 MultipleSelectionModel<T> sm = getSkinnable().getSelectionModel();
                 ObservableList<Integer> indices = sm.getSelectedIndices();
                 List<Node> selection = new ArrayList<>(indices.size());
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableRowSkin.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableRowSkin.java	Tue Jul 22 09:44:28 2014 -0700
@@ -132,7 +132,7 @@
     @Override
     protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
         switch (attribute) {
-            case SELECTED_CELLS: {
+            case SELECTED_ITEMS: {
                 // FIXME this could be optimised to iterate over cellsMap only
                 // (selectedCells could be big, cellsMap is much smaller)
                 List<Node> selection = new ArrayList<>();
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableViewSkin.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TableViewSkin.java	Tue Jul 22 09:44:28 2014 -0700
@@ -293,7 +293,7 @@
     @Override
     public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
         switch (attribute) {
-            case SELECTED_CELLS: {
+            case SELECTED_ITEMS: {
                 List<Node> selection = new ArrayList<>();
                 TableViewSelectionModel<T> sm = getSkinnable().getSelectionModel();
                 for (TablePosition pos : sm.getSelectedCells()) {
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java	Tue Jul 22 09:44:28 2014 -0700
@@ -407,7 +407,7 @@
     protected Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
         final TreeTableView<T> treeTableView = getSkinnable().getTreeTableView();
         switch (attribute) {
-            case SELECTED_CELLS: {
+            case SELECTED_ITEMS: {
                 // FIXME this could be optimised to iterate over cellsMap only
                 // (selectedCells could be big, cellsMap is much smaller)
                 List<Node> selection = new ArrayList<>();
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableViewSkin.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeTableViewSkin.java	Tue Jul 22 09:44:28 2014 -0700
@@ -393,7 +393,7 @@
                 final int rowIndex = (Integer)parameters[0];
                 return rowIndex < 0 ? null : flow.getPrivateCell(rowIndex);
             }
-            case SELECTED_CELLS: {
+            case SELECTED_ITEMS: {
                 List<Node> selection = new ArrayList<>();
                 TreeTableView.TreeTableViewSelectionModel<S> sm = getSkinnable().getSelectionModel();
                 for (TreeTablePosition<S,?> pos : sm.getSelectedCells()) {
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeViewSkin.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TreeViewSkin.java	Tue Jul 22 09:44:28 2014 -0700
@@ -494,7 +494,7 @@
                 final int rowIndex = (Integer)parameters[0];
                 return rowIndex < 0 ? null : flow.getPrivateCell(rowIndex);
             }
-            case SELECTED_ROWS: {
+            case SELECTED_ITEMS: {
                 MultipleSelectionModel<TreeItem<T>> sm = getSkinnable().getSelectionModel();
                 ObservableList<Integer> indices = sm.getSelectedIndices();
                 List<Node> selection = new ArrayList<>(indices.size());
--- a/modules/controls/src/main/java/javafx/scene/control/ListView.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/ListView.java	Tue Jul 22 09:44:28 2014 -0700
@@ -1415,7 +1415,7 @@
             if (listView.getFocusModel() == null) return;
             listView.getFocusModel().focus(row);
 
-            listView.notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTED_ROWS);
+            listView.notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_ITEM);
         }
 
         /** {@inheritDoc} */
--- a/modules/controls/src/main/java/javafx/scene/control/TableView.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/TableView.java	Tue Jul 22 09:44:28 2014 -0700
@@ -1650,7 +1650,7 @@
         switch (attribute) {
             case COLUMN_COUNT: return getVisibleLeafColumns().size();
             case ROW_COUNT: return getItems().size();
-            case SELECTED_CELLS: {
+            case SELECTED_ITEMS: {
                 // TableViewSkin returns TableRows back to TableView.
                 // TableRowSkin returns TableCells back to TableRow.
                 ObservableList<TableRow<S>> rows = (ObservableList<TableRow<S>>)super.queryAccessibleAttribute(attribute, parameters);
@@ -1915,7 +1915,7 @@
 
         void focus(int row, TableColumn<S,?> column) {
             focus(new TablePosition<>(getTableView(), row, column));
-            getTableView().notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTED_CELLS);
+            getTableView().notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_ITEM);
         }
 
         void focus(TablePosition<S,?> pos) {
--- a/modules/controls/src/main/java/javafx/scene/control/TreeTableView.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/TreeTableView.java	Tue Jul 22 09:44:28 2014 -0700
@@ -1913,7 +1913,7 @@
              * TreeTableViewSkin returns TreeTableRows back to TreeTableView.
              * TreeTableRowSkin returns TreeTableCells back to TreeTableRow.
              */
-            case SELECTED_CELLS: {
+            case SELECTED_ITEMS: {
                 ObservableList<TreeTableRow<S>> rows = (ObservableList<TreeTableRow<S>>)super.queryAccessibleAttribute(attribute, parameters);
                 List<Node> selection = new ArrayList<>();
                 for (TreeTableRow<S> row : rows) {
@@ -2926,7 +2926,7 @@
             if (getTreeTableView().getFocusModel() == null) return;
 
             getTreeTableView().getFocusModel().focus(pos.getRow(), pos.getTableColumn());
-            getTreeTableView().notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTED_CELLS);
+            getTreeTableView().notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_ITEM);
         }
 
         @Override public int getFocusedIndex() {
--- a/modules/controls/src/main/java/javafx/scene/control/TreeView.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/TreeView.java	Tue Jul 22 09:44:28 2014 -0700
@@ -1429,7 +1429,7 @@
             }
 
             // FIXME this is not the correct location for fire selection events (and does not take into account multiple selection)
-            treeView.notifyAccessibleAttributeChanged(AccessibleAttribute.SELECTED_ROWS);
+            treeView.notifyAccessibleAttributeChanged(AccessibleAttribute.FOCUS_ITEM);
         }
 
         /** {@inheritDoc} */
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Tue Jul 22 09:44:28 2014 -0700
@@ -150,10 +150,10 @@
         NSAccessibilityColumnsAttribute(null, null), //virtual only
         NSAccessibilityRowsAttribute(null, null), //virtual only
         NSAccessibilityHeaderAttribute(HEADER, MacVariant::createNSObject),
-        NSAccessibilitySelectedRowsAttribute(SELECTED_ROWS, MacVariant::createNSArray),
+        NSAccessibilitySelectedRowsAttribute(SELECTED_ITEMS, MacVariant::createNSArray),
         NSAccessibilityRowCountAttribute(ROW_COUNT, MacVariant::createNSNumberForInt),
         NSAccessibilityColumnCountAttribute(COLUMN_COUNT, MacVariant::createNSNumberForInt),
-        NSAccessibilitySelectedCellsAttribute(SELECTED_CELLS, MacVariant::createNSArray),
+        NSAccessibilitySelectedCellsAttribute(SELECTED_ITEMS, MacVariant::createNSArray),
         NSAccessibilityRowIndexRangeAttribute(ROW_INDEX, MacVariant::createNSValueForRange),
         NSAccessibilityColumnIndexRangeAttribute(COLUMN_INDEX, MacVariant::createNSValueForRange),
 
@@ -670,19 +670,23 @@
         MacNotification macNotification = null;
         switch (notification) {
             case FOCUS_ITEM: {
-                Node node = (Node)getAttribute(FOCUS_ITEM);
-                long id = getNativeAccessible(node);
-                if (id != 0) {
-                    NSAccessibilityPostNotification(id, MacNotification.NSAccessibilityFocusedUIElementChangedNotification.ptr);
+                AccessibleRole role = (AccessibleRole) getAttribute(ROLE);
+                if (role == AccessibleRole.TABLE_VIEW || role == AccessibleRole.TREE_TABLE_VIEW) {
+                    /* Cell based controls */
+                    macNotification = MacNotification.NSAccessibilitySelectedCellsChangedNotification;
+                } else if (role == AccessibleRole.LIST_VIEW || role == AccessibleRole.TREE_VIEW) {
+                    /* Row based controls */
+                    macNotification = MacNotification.NSAccessibilitySelectedRowsChangedNotification;
+                } else {
+                    /* TabPane and Pagination */
+                    Node node = (Node)getAttribute(FOCUS_ITEM);
+                    long id = getNativeAccessible(node);
+                    if (id != 0) {
+                        NSAccessibilityPostNotification(id, MacNotification.NSAccessibilityFocusedUIElementChangedNotification.ptr);
+                    }
                 }
                 break;
             }
-            case SELECTED_ROWS:
-                macNotification = MacNotification.NSAccessibilitySelectedRowsChangedNotification;
-                break;
-            case SELECTED_CELLS:
-                macNotification = MacNotification.NSAccessibilitySelectedCellsChangedNotification;
-                break;
             case FOCUS_NODE: {
                 Node node = (Node)getAttribute(FOCUS_NODE);
                 View view = getView();
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Tue Jul 22 09:44:28 2014 -0700
@@ -287,30 +287,6 @@
                 }
                 break;
             }
-            case SELECTED_CELLS: {
-                /* 
-                 * Use the notification in the parent to poke the children.
-                 * Note: FOCUS_NODE does not see this case because as for as the scene graph
-                 * is concerned the focus is still on the parent. I.e TableView, ListView.
-                 */
-                ObservableList<Node> selection = (ObservableList<Node>)getAttribute(SELECTED_CELLS);
-                if (selection != null) {
-                    selection.stream().forEach(n -> UiaRaiseAutomationEvent(getNativeAccessible(n), UIA_AutomationFocusChangedEventId));
-                }
-                break;
-            }
-            case SELECTED_ROWS: {
-                /* 
-                 * Use the notification in the parent to poke the children.
-                 * Note: FOCUS_NODE does not see this case because as for as the scene graph
-                 * is concerned the focus is still on the parent. I.e TableView, ListView.
-                 */
-                ObservableList<Node> selection = (ObservableList<Node>)getAttribute(SELECTED_ROWS);
-                if (selection != null) {
-                    selection.stream().forEach(n -> UiaRaiseAutomationEvent(getNativeAccessible(n), UIA_AutomationFocusChangedEventId));
-                }
-                break;
-            }
             case INDETERMINATE: {
                 if (getAttribute(ROLE) == AccessibleRole.CHECK_BOX) {
                     notifyToggleState();
@@ -1070,16 +1046,11 @@
         AccessibleRole role = (AccessibleRole)getAttribute(ROLE);
         switch (role) {
             case TREE_TABLE_VIEW:
-            case TABLE_VIEW: {
-                ObservableList<Node> selection = (ObservableList<Node>)getAttribute(SELECTED_CELLS);
-                if (selection != null) {
-                    return selection.stream().mapToLong(n -> getNativeAccessible(n)).toArray();
-                }
-                break;
-            }
+            case TABLE_VIEW:
             case TREE_VIEW:
             case LIST_VIEW: {
-                ObservableList<Node> selection = (ObservableList<Node>)getAttribute(SELECTED_ROWS);
+                @SuppressWarnings("unchecked")
+                ObservableList<Node> selection = (ObservableList<Node>)getAttribute(SELECTED_ITEMS);
                 if (selection != null) {
                     return selection.stream().mapToLong(n -> getNativeAccessible(n)).toArray();
                 }
--- a/modules/graphics/src/main/java/javafx/scene/AccessibleAttribute.java	Tue Jul 22 09:16:53 2014 -0400
+++ b/modules/graphics/src/main/java/javafx/scene/AccessibleAttribute.java	Tue Jul 22 09:44:28 2014 -0700
@@ -344,16 +344,10 @@
     SELECTED("Selected", Boolean.class),
 
     /**
-     * Returns the list of selected cells
+     * Returns the list of selected items
      * Type: ObservableList&lt;Node&gt;
      */
-    SELECTED_CELLS("SelectedCells", ObservableList.class),
-
-    /**
-     * Returns the list of selected rows
-     * Type: ObservableList&lt;Node&gt;
-     */
-    SELECTED_ROWS("SelectedRows", ObservableList.class),
+    SELECTED_ITEMS("SelectedItems", ObservableList.class),
 
     /**
      * Returns the selection end for the node.