changeset 6899:c9ee52f63808

RT-36636: [Accessibility] WinTextRangeProvider#FindText() implemented.
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Fri, 25 Apr 2014 10:49:26 -0700
parents 8117644a5e28
children efa8b7b3fedc
files modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java	Fri Apr 25 10:30:41 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java	Fri Apr 25 10:49:26 2014 -0700
@@ -217,8 +217,24 @@
     }
 
     long FindText(String text, boolean backward, boolean ignoreCase) {
-        System.err.println("FindText NOT IMPLEMENTED");
-        return 0;
+        if (text == null) return 0;
+        String documentText = (String)getAttribute(TITLE);
+        if (documentText == null) return 0;
+        String rangeText = documentText.substring(start, end);
+        if (ignoreCase) {
+            rangeText = rangeText.toLowerCase();
+            text = text.toLowerCase();
+        }
+        int index = -1;
+        if (backward) {
+            index = rangeText.lastIndexOf(text);
+        } else {
+            index = rangeText.indexOf(text);
+        }
+        if (index == -1) return 0;
+        WinTextRangeProvider result = new WinTextRangeProvider(accessible);
+        result.setRange(start + index, start + index + text.length());
+        return result.getNativeProvider();
     }
 
     WinVariant GetAttributeValue(int attributeId) {