changeset 6560:e260e71603ca

[Accessibility] cosmetic changes
author felipe
date Tue, 25 Mar 2014 13:43:32 -0700
parents a4f4d7834a8f
children 85e8ec504bff
files modules/graphics/src/main/java/com/sun/glass/ui/PlatformAccessible.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
diffstat 3 files changed, 56 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/PlatformAccessible.java	Tue Mar 25 13:30:26 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/PlatformAccessible.java	Tue Mar 25 13:43:32 2014 -0700
@@ -25,7 +25,9 @@
 
 package com.sun.glass.ui;
 
+import static javafx.scene.accessibility.Attribute.PARENT;
 import static javafx.scene.accessibility.Attribute.ROLE;
+import javafx.scene.Node;
 import javafx.scene.accessibility.Accessible;
 import javafx.scene.accessibility.Action;
 import javafx.scene.accessibility.Attribute;
@@ -67,6 +69,17 @@
         return role == Role.NODE || role == Role.PARENT;
     }
 
+    protected Node getContainerNode(Role targetRole) {
+        Node node = (Node)getAttribute(PARENT);
+        while (node != null) {
+            Accessible acc = node.getAccessible();
+            Role role = (Role)acc.getAttribute(ROLE);
+            if (role == targetRole) return node;
+            node = (Node)acc.getAttribute(PARENT);
+        }
+        return null;
+    }
+
     protected Object getAttribute(Attribute attribute, Object... parameters) {
         Object result = accessible.getAttribute(attribute, parameters);
         if (result != null) {
--- a/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Tue Mar 25 13:30:26 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/mac/MacAccessible.java	Tue Mar 25 13:43:32 2014 -0700
@@ -602,16 +602,6 @@
         super.dispose();
     }
 
-    private long getContainer(Node node, Role targetRole) {
-        while (node != null) {
-            Accessible acc = node.getAccessible();
-            Role role = (Role)acc.getAttribute(ROLE);
-            if (role == targetRole) return getAccessible(node);
-            node = (Node)acc.getAttribute(PARENT);
-        }
-        return 0;
-    }
-
     @Override
     public void sendNotification(Attribute notification) {
         MacNotifications macNotification;
@@ -648,7 +638,7 @@
                 }
 
                 if (getAttribute(ROLE) == Role.TREE_ITEM) {
-                    long treeView = getContainer((Node)getAttribute(PARENT), Role.TREE_VIEW);
+                    long treeView = getAccessible(getContainerNode(Role.TREE_VIEW));
                     if (treeView != 0) {
                         NSAccessibilityPostNotification(treeView, MacNotifications.NSAccessibilityRowCountChangedNotification.ptr);
                     }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Tue Mar 25 13:30:26 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Tue Mar 25 13:43:32 2014 -0700
@@ -388,17 +388,6 @@
         return node == null ? 0 : getAccessible(node);
     }
 
-    private Node getContainerNode(Role targetRole) {
-        Node node = (Node)getAttribute(PARENT);
-        while (node != null) {
-            Accessible acc = node.getAccessible();
-            Role role = (Role)acc.getAttribute(ROLE);
-            if (role == targetRole) return node;
-            node = (Node)acc.getAttribute(PARENT);
-        }
-        return null;
-    }
-
     private Node getContainerNode() {
         if (isDisposed()) return null;
         Role role = (Role) getAttribute(ROLE);
@@ -624,7 +613,6 @@
                          */
                     default:
                         name = (String)getAttribute(TITLE);
-                        break;
                 }
 
                 if (name == null || name.length() == 0) {
@@ -1036,7 +1024,6 @@
                 case SCROLL_BAR:
                 case TEXT_FIELD:
                 case TEXT_AREA: return false;
-                case PROGRESS_INDICATOR:
                 default:
             }
         }
@@ -1366,7 +1353,7 @@
         Role role = (Role)getAttribute(ROLE);
         switch (role) {
             case THUMB: return true;
-            default:return false;
+            default: return false;
         }
     }
 
@@ -1396,27 +1383,43 @@
 
         /* dealing with vertical scroll first */
         if (get_VerticallyScrollable()) {
-            Node vsb = (Node) getAttribute(VERTICAL_SCROLLBAR);
-            Accessible vsbAccessible = vsb.getAccessible();
+            Node vsb = (Node)getAttribute(VERTICAL_SCROLLBAR);
+            Accessible vsba = vsb.getAccessible();
             switch (verticalAmount) {
-                case ScrollAmount_LargeIncrement: vsbAccessible.executeAction(Action.BLOCK_INCREMENT); break;
-                case ScrollAmount_SmallIncrement: vsbAccessible.executeAction(Action.INCREMENT); break;
-                case ScrollAmount_LargeDecrement: vsbAccessible.executeAction(Action.BLOCK_DECREMENT); break;
-                case ScrollAmount_SmallDecrement: vsbAccessible.executeAction(Action.DECREMENT); break;
-                default: break;
+                case ScrollAmount_LargeIncrement:
+                    vsba.executeAction(Action.BLOCK_INCREMENT);
+                    break;
+                case ScrollAmount_SmallIncrement:
+                    vsba.executeAction(Action.INCREMENT);
+                    break;
+                case ScrollAmount_LargeDecrement:
+                    vsba.executeAction(Action.BLOCK_DECREMENT);
+                    break;
+                case ScrollAmount_SmallDecrement:
+                    vsba.executeAction(Action.DECREMENT);
+                    break;
+                default:
             }
         }
 
         /* now dealing with horizontal scroll */
         if (get_HorizontallyScrollable()) {
-            Node hsb = (Node) getAttribute(HORIZONTAL_SCROLLBAR);
-            Accessible hsbAccessible = hsb.getAccessible();
+            Node hsb = (Node)getAttribute(HORIZONTAL_SCROLLBAR);
+            Accessible hsba = hsb.getAccessible();
             switch (horizontalAmount) {
-                case ScrollAmount_LargeIncrement: hsbAccessible.executeAction(Action.BLOCK_INCREMENT); break;
-                case ScrollAmount_SmallIncrement: hsbAccessible.executeAction(Action.INCREMENT); break;
-                case ScrollAmount_LargeDecrement: hsbAccessible.executeAction(Action.BLOCK_DECREMENT); break;
-                case ScrollAmount_SmallDecrement: hsbAccessible.executeAction(Action.DECREMENT); break;
-                default: break;
+                case ScrollAmount_LargeIncrement:
+                    hsba.executeAction(Action.BLOCK_INCREMENT);
+                    break;
+                case ScrollAmount_SmallIncrement:
+                    hsba.executeAction(Action.INCREMENT);
+                    break;
+                case ScrollAmount_LargeDecrement:
+                    hsba.executeAction(Action.BLOCK_DECREMENT);
+                    break;
+                case ScrollAmount_SmallDecrement:
+                    hsba.executeAction(Action.DECREMENT);
+                    break;
+                default:
             }
         }
     }
@@ -1426,7 +1429,7 @@
 
         /* dealing with vertical scroll first */
         if (verticalPercent != UIA_ScrollPatternNoScroll && get_VerticallyScrollable()) {
-            Node vsb = (Node) getAttribute(VERTICAL_SCROLLBAR);
+            Node vsb = (Node)getAttribute(VERTICAL_SCROLLBAR);
             Double min = (Double)vsb.getAccessible().getAttribute(MIN_VALUE);
             Double max = (Double)vsb.getAccessible().getAttribute(MAX_VALUE);
             if (min != null && max != null) {
@@ -1436,7 +1439,7 @@
 
         /* now dealing with horizontal scroll */
         if (horizontalPercent != UIA_ScrollPatternNoScroll && get_HorizontallyScrollable()) {
-            Node hsb = (Node) getAttribute(HORIZONTAL_SCROLLBAR);
+            Node hsb = (Node)getAttribute(HORIZONTAL_SCROLLBAR);
             Double min = (Double)hsb.getAccessible().getAttribute(MIN_VALUE);
             Double max = (Double)hsb.getAccessible().getAttribute(MAX_VALUE);
             if (min != null && max != null) {
@@ -1448,8 +1451,8 @@
     boolean get_HorizontallyScrollable() {
         if (isDisposed()) return false;
 
-        Node hsb = (Node) getAttribute(HORIZONTAL_SCROLLBAR);
-        if(hsb == null) return false;
+        Node hsb = (Node)getAttribute(HORIZONTAL_SCROLLBAR);
+        if (hsb == null) return false;
 
         Boolean visible = (Boolean)hsb.getAccessible().getAttribute(VISIBLE);
         return Boolean.TRUE.equals(visible);
@@ -1458,7 +1461,7 @@
     double get_HorizontalScrollPercent() {
         if (isDisposed()) return 0;
 
-        if (! get_HorizontallyScrollable()) {
+        if (!get_HorizontallyScrollable()) {
             return UIA_ScrollPatternNoScroll;
         }
 
@@ -1494,7 +1497,7 @@
         if (isDisposed()) return false;
 
         Node vsb = (Node) getAttribute(VERTICAL_SCROLLBAR);
-        if(vsb == null) return false;
+        if (vsb == null) return false;
 
         Boolean visible = (Boolean)vsb.getAccessible().getAttribute(VISIBLE);
         return Boolean.TRUE.equals(visible);
@@ -1503,7 +1506,7 @@
     double get_VerticalScrollPercent() {
         if (isDisposed()) return 0;
 
-        if (! get_VerticallyScrollable()) {
+        if (!get_VerticallyScrollable()) {
             return UIA_ScrollPatternNoScroll;
         }
 
@@ -1531,7 +1534,7 @@
 
         Bounds scrollPaneBounds = (Bounds) getAttribute(BOUNDS);
         if (scrollPaneBounds == null) return 0;
-        final double scrollPaneHeight = scrollPaneBounds.getHeight();
+        double scrollPaneHeight = scrollPaneBounds.getHeight();
 
         Role role = (Role) getAttribute(ROLE);
         if (role == Role.SCROLL_PANE) {
@@ -1542,7 +1545,6 @@
             }
         } else {
             Integer itemCount = 0;
-
             switch (role) {
                 case LIST_VIEW:
                 case TABLE_VIEW:
@@ -1550,7 +1552,7 @@
                 case TREE_TABLE_VIEW:
                     itemCount = (Integer) getAttribute(ROW_COUNT);
                     break;
-                default: break;
+                default:
             }
 
             /*
@@ -1571,8 +1573,8 @@
     void ScrollIntoView() {
         if (isDisposed()) return;
 
-        final Integer cellIndex = (Integer) getAttribute(INDEX);
-        final Node container = getContainerNode();
+        Integer cellIndex = (Integer)getAttribute(INDEX);
+        Node container = getContainerNode();
         if (cellIndex != null && container != null) {
             container.getAccessible().executeAction(Action.SCROLL_TO_INDEX, cellIndex);
         }