Compare commits

..

85 Commits
1319 ... 1440

Author SHA1 Message Date
Mikhail Grishchenko
cc754d6d76 Revert "JBR-2910 Make java2d.font.subpixelResolution=4x1 by default"
This reverts commit f4a8e51d
2021-04-24 14:40:27 +07:00
Artem Semenov
0c3b4bf9b7 JBR-3182: transfer of JBR to a11y protocol based on roles 2021-04-23 15:53:08 +03:00
Maxim Kartashev
216bf92575 JBR-1430: Windows: use UTF16 version of Win32 API to load DLL
Also correct library name encoding in exception messages.
2021-04-23 11:13:48 +03:00
Dmitry Batrak
4c6f3e4510 JBR-3353 Sibling popup window is shown below dialog on macOS 2021-04-22 15:06:10 +03:00
Dmitry Batrak
8d74e8e30b JBR-3339 Window requests focus on horizontal scroll (on Linux) 2021-04-21 21:05:22 +03:00
Nikita Gubarkov
f4a8e51d4a JBR-2910 Make java2d.font.subpixelResolution=4x1 by default 2021-04-21 19:45:25 +03:00
Vitaly Provodin
db9032755a Revert "JBR-3214: CR: remove double negation"
This reverts commit 258184b4
2021-04-21 11:12:42 +07:00
Prasanta Sadhukhan
db017fbd56 8196092: javax/swing/JComboBox/8032878/bug8032878.java fails
Reviewed-by: serb, pbansal

(cherry picked from commit 2ee795d9e4)
2021-04-21 05:55:22 +07:00
Vitaly Provodin
479ceadb35 JBR-3314 reduce number of iterations in regression test 2021-04-20 11:18:51 +07:00
Nikita Gubarkov
ad1d5061a9 JBR-2924 Do not try to create native italic font when we're going to make it fake italic 2021-04-20 01:04:44 +03:00
Vitaly Provodin
ff0a538ebd JBR-3314 unify shell script in regression test 2021-04-19 14:09:39 +07:00
Vitaly Provodin
c81adfed61 JBR-3314 add regression test 2021-04-15 15:57:11 +07:00
Dmitry Batrak
2ccf6b65a7 JBR-3307 First character is dropped when editing a table cell 2021-04-13 15:52:30 +03:00
Alexey Ushakov
a34eeb7735 JBR-3295 Fix error handling in Toolkit — do not ignore error and pass it as a cause
Wrapped original exception
2021-04-13 01:20:54 +03:00
Dmitry Batrak
ba6b9c085e JBR-3291 Input of characters using Alt+<NumPad> stopped working on Windows 2021-04-12 16:30:55 +03:00
Artem Semenov
04f1cf9b47 JBR-3241: MAke a11y element for combobox 2021-04-07 17:23:49 +03:00
Jim Laskey
80c6e03ec4 JBR-2607 backport the fix for crash in [libjimage] ImageStrings::find from OpenJDK
backported from OpenJDK - 8166727: javac crashed: [jimage.dll+0x1942] ImageStrings::find+0x28

Reviewed-by: iklam, alanb
2021-04-07 14:33:38 +07:00
Artem Semenov
9001a78701 JBR-3274: macOS: SIGILL at [libsystem_kernel] __kill -[PlatformAxNavigableText accessibilitySelectedTextAttribute] 2021-04-05 14:47:34 +03:00
Artem Semenov
703cab8d0d JBR-3240: MAke a11y element for TabGroup 2021-04-02 15:51:57 +03:00
Nikita Gubarkov
3c9cdc9251 JBR-3269 Disabled subpixel antialiasing for MacOS Big Sur and newer 2021-04-02 01:24:57 +03:00
Denis Konoplev
032805520d JBR-3214: CR: remove double negation 2021-04-01 16:54:47 +03:00
Dmitry Batrak
b37f7cfdb1 JBR-3255 Applying 'incline' transform might change character's advance 2021-03-30 18:37:21 +03:00
Denis Konoplev
3668d631ca JBR-3214: Reuse openjdk logic and add unicode keycodes 2021-03-30 16:12:29 +03:00
Denis Konoplev
7fa3ea24ac JBR-2509: Fix Escape emulation after Cmd . 2021-03-30 16:05:16 +03:00
Artem Semenov
8a521cbf64 JR-CR-776: JBR-3239: MAke a11y component for ScrollView 2021-03-30 13:43:22 +03:00
Denis Konoplev
fe9601aa6d JBR-3214: Initialize stack variables to fix dead key prefix and enable support on aarch64 2021-03-29 20:06:22 +03:00
Artem Semenov
65e8162d67 JR-CR-775: JBR-3188: NSAccessibilityNavigableStaticText 2021-03-26 14:35:34 +03:00
Artem Semenov
b99be427ce JR-CR-774: JBR-3218: IDEA crash with opening drop down menu and click whatever next. 2021-03-24 18:38:32 +03:00
Denis Konoplev
6b3b011d0b Revert "JBR-2509: Fix Escape emulation after Cmd ."
This reverts commit f096bd2b
2021-03-24 14:01:10 +03:00
Denis Konoplev
b53ef867e4 Revert "JBR-2509: Remove Fokin code."
This reverts commit 99a8e455
2021-03-24 14:01:10 +03:00
Denis Konoplev
215fd32738 Revert "JBR-2509: Turn on option on M1"
This reverts commit 542ee611
2021-03-24 14:01:10 +03:00
Artem Semenov
921603e356 JBR-3028: macOS: SIGILL at [libsystem_kernel] __kill -[PlatformAxList accessibilityParent]
JR-CR-773: JBR-3028: macOS: SIGILL at [libsystem_kernel] __kill -[PlatformAxList accessibilityParent]
2021-03-23 21:04:25 +03:00
Denis Konoplev
542ee611fc JBR-2509: Turn on option on M1 2021-03-23 19:38:58 +03:00
Denis Konoplev
99a8e45598 JBR-2509: Remove Fokin code.
Reuse openjdk logic and add unicode keycodes
2021-03-23 16:45:33 +03:00
Denis Konoplev
f096bd2b0d JBR-2509: Fix Escape emulation after Cmd . 2021-03-23 16:45:33 +03:00
Ivan Migalev
26dd87ab7c JBR-3227 Reload type of required native file dialogs each time a file dialog is requested 2021-03-23 16:00:08 +03:00
Alexey Ushakov
a6ea081ba2 JBR-3023 Gray idea frame after project open with ide.mac.transparentTitleBarAppearance.
Initiate move/resize event on first appearance of window having FULL_WINDOW_CONTENT property set
2021-03-23 00:44:30 +03:00
Artem Semenov
2e87610593 JR-CR-771: JBR-3187: NSAccessibilityStaticText 2021-03-22 20:26:07 +03:00
Artem Semenov
1c336fc03a JR-CR-768: Test for JBR-3187 and JBR-3188
Test for JBR-3187 and JBR-3188
2021-03-22 20:26:07 +03:00
Dmitry Batrak
8eafcaab24 JBR-3215 'deriveFont(float)' can return a different font (not just change the size) 2021-03-22 15:56:46 +03:00
Vitaly Provodin
c096f12994 updated JTreg exclude list 2021-03-22 06:40:23 +07:00
Alexey Ushakov
5cfc8b3629 JBR-3217 [bkp to JBR11] JDK-8262446 DragAndDrop hangs on Windows
backported JDK-8262446 without any conflicts
2021-03-20 00:26:45 +03:00
Denis Konoplev
65b3d32eca JBR-1718: Fix regression java/awt/MenuBar/DefaultMenuBarDispose.java 2021-03-19 21:30:41 +03:00
Alexey Ushakov
61de3c3065 JBR-3208 bkp from JDK17: 8255790: GTKL&F: Java 16 crashes on initialising GTKL&F on Manjaro Linux
Review: disable coretext for now, cleanup
2021-03-18 13:33:55 +03:00
Nikita Gubarkov
3b101f673b JBR-2910 Fixed font size computation (extended glyph cache for MacOS) 2021-03-18 03:59:42 +03:00
Phil Race
bd79159249 8249142: java/awt/FontClass/CreateFont/DeleteFont.sh is unstable
Reviewed-by: serb
2021-03-18 05:47:50 +07:00
Alexey Ushakov
ca4425cb21 JBR-3208 bkp from JDK17: 8255790: GTKL&F: Java 16 crashes on initialising GTKL&F on Manjaro Linux
Backported fix with some minor corrections
2021-03-17 20:50:22 +03:00
Alexey Ushakov
b386e44bf5 Revert "JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine"
This reverts commit e03c9829, 97c0e96a, 746affd7, e766df4b, 847705dc, f10e7aca, 9ee15508, 553e5ca6
2021-03-17 16:31:05 +03:00
Nikita Gubarkov
03995a0327 JBR-2910 Implemented extended glyph cache for MacOS 2021-03-17 01:25:08 +03:00
Vitaly Provodin
bd6a088aaf remove links to bintray - download zulu as BOOT JDK 2021-03-17 04:46:44 +07:00
Denis Konoplev
c2582f8e03 JBR-1718: Add backward compatibility 2021-03-15 16:00:58 +03:00
Denis Konoplev
c122e27068 JBR-1718: Fix MacOs handlers 2021-03-15 16:00:58 +03:00
Dmitry Batrak
52a2428c28 use GPL copyright header 2021-03-15 14:53:42 +03:00
Konstantin Bulenkov
87b60afdf7 Remove links to bintray 2021-03-14 13:03:11 +01:00
Vitaly Provodin
10069846d5 Follow-up to 8221852: reporting actual error when unprivileged symlink creation fails
fix the misprint
2021-03-12 15:47:01 +07:00
Roman Shevchenko
f06f9fe734 Follow-up to 8221852: reporting actual error when unprivileged symlink creation fails
... for a reason other that ERROR_INVALID_PARAMETER.
2021-03-11 12:16:11 +03:00
Vitaly Provodin
348e538d10 updated JTreg exclude list
JBR-3167 excluding java2d tests causing Xwayland crash
2021-03-09 06:37:34 +07:00
Dmitry Batrak
5b9ff9a29e JBR-2766 java/awt/Window/MinimumSizeDPIVariation/MinimumSizeDPIVariation.java: Wrong size 2021-03-02 19:42:44 +03:00
Dmitry Batrak
62b04983f2 JBR-3157 Maximized window with custom decorations isn't focused on showing 2021-03-02 19:00:15 +03:00
Vitaly Provodin
c40b9c8b9e JBR-1505 add jdk.jcmd module into JBR 2021-03-02 05:43:59 +07:00
Artem Semenov
46dfaeecc9 JR-CR-760:
JBR-3144 Extend test for list with list nested in Heavy Weight Window popup
2021-02-24 14:25:30 +03:00
Alexey Ushakov
e03c9829e3 JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
Optimised failure handling
2021-02-20 06:57:05 -08:00
Alexey Ushakov
97c0e96a5a JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
Optimised failure handling
2021-02-20 02:57:25 -08:00
Vitaly Provodin
2b559a30df JBR-3138 fix the issues with signing JNF (follow up) 2021-02-20 16:39:00 +07:00
Sean Coffey
73b4a7e79e JBR-3139 backport the fix for 8253368: TLS connection always receives close_notify exception
Reviewed-by: xuelei
(cherry picked from commit 780ac896b1)
2021-02-20 16:38:20 +07:00
Anton Tarasov
7d8aeaf7de revert: JBR-1434 "New file dialog" popup remains above all windows on switching application
java.awt.peer.WindowPeer.isLightweightDialog() method does not exist.
2021-02-20 11:23:59 +03:00
Vitaly Provodin
94390c3f1e JBR-3138 fix the issues with signing JNF 2021-02-20 14:23:45 +07:00
Artem Bochkarev
78d509ac0f JBR-3131: support custom view for system menu items 2021-02-19 19:46:11 +03:00
Nikita Gubarkov
0b6238990b JBR-2910 Implemented extended glyph cache for Linux 2021-02-17 15:13:06 +03:00
Nikita Gubarkov
c0e4afcddd JBR-2910 Implemented extended glyph cache for Windows 2021-02-17 15:12:40 +03:00
Artem Bochkarev
be6a2c4f0c JBR-3127: add possibility to load NSJavaVirtualMachine
JavaVM framework is deprecated but this class is still checked by AppKit, see https://youtrack.jetbrains.com/issue/JBR-3127#focus=Comments-27-4684465.0-0
2021-02-17 15:00:21 +03:00
Artem Bochkarev
0b8ff1a7e6 JBR-3127: set NSWindowAllowsImplicitFullScreen=NO
fixed JBR-3127 Modal dialogs invoked from modal or floating dialogs are opened in full screen
2021-02-17 15:00:20 +03:00
Dmitry Batrak
63134e091b JBR-3119 Application's panel in KDE taskbar blinks when popup window is shown
this re-fixes JBR-2934 in a different way
2021-02-17 10:43:46 +03:00
Dmitry Batrak
50ab4690de JBR-1752 Floating windows overlap modal dialogs
fix for file dialog case
2021-02-11 12:52:14 +03:00
Ivan Migalev
c790bf3ebc JBR-3068: pass default button localization if not overridden 2021-02-11 11:16:56 +03:00
Alexey Ushakov
746affd753 JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
Corrected symbol name
2021-02-10 08:44:59 -08:00
Alexey Ushakov
e766df4bcc JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
Added missing initializations
2021-02-10 06:17:56 -08:00
Alexey Ushakov
847705dc96 JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
One more fix of compilation (on windows)
2021-02-10 09:53:00 +03:00
Alexey Ushakov
f10e7aca70 JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
Fixed compile problem
2021-02-09 23:18:52 +03:00
Alexey Ushakov
9ee1550815 JBR-3066 jbr 11_10 (1145-88) crashes on IDEA startup, jbr 11_09 (1145-77) works fine
Added manual loading of harfbuzz library. Use pointers to functions to access it's API.
2021-02-09 22:31:18 +03:00
Konstantin Bulenkov
1de6eed0e1 compilation fix 2021-02-09 12:02:41 +01:00
Konstantin Bulenkov
78510922c5 Update JetBrains Mono stylistic set 2021-02-08 19:43:05 +01:00
Vitaly Provodin
41de3a4cb1 JBR-3064 Disable AllowEnhancedClassRedefinition in flight recorder 2021-02-08 16:35:14 +07:00
Dmitry Batrak
304eb7f919 make AwtListGarbageCollectionTest pass reliably 2021-02-08 12:22:09 +03:00
Ivan Migalev
442bb7eecc JBR-3068 Update path selector behavior when sun.awt.windows.useCommonItemDialog is enabled 2021-02-08 12:00:28 +03:00
374 changed files with 5264 additions and 4606 deletions

View File

@@ -1,9 +1,7 @@
<component name="CopyrightManager">
<copyright>
<option name="notice" value="Copyright 2000-&amp;#36;today.year JetBrains s.r.o.&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
<option name="keyword" value="Copyright" />
<option name="allowReplaceKeyword" value="JetBrains" />
<option name="allowReplaceRegexp" value="JetBrains" />
<option name="notice" value="Copyright 2000-&amp;#36;today.year JetBrains s.r.o.&#10;DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.&#10; &#10;This code is free software; you can redistribute it and/or modify it&#10;under the terms of the GNU General Public License version 2 only, as&#10;published by the Free Software Foundation.&#10;&#10;This code is distributed in the hope that it will be useful, but WITHOUT&#10;ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or&#10;FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License&#10;version 2 for more details (a copy is included in the LICENSE file that&#10;accompanied this code).&#10;&#10;You should have received a copy of the GNU General Public License version&#10;2 along with this work; if not, write to the Free Software Foundation,&#10;Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.&#10;&#10;Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA&#10;or visit www.oracle.com if you need additional information or have any&#10;questions." />
<option name="myName" value="JetBrains" />
<option name="myLocal" value="true" />
</copyright>
</component>

View File

@@ -1,12 +1,5 @@
[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
# Downloads
|Windows-x64 |macOS |Linux-x64 |
|-------------|-------------|-------------|
|[ ![Download](https://api.bintray.com/packages/jetbrains/intellij-jdk/openjdk11-windows-x64/images/download.svg) ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-windows-x64/_latestVersion)|[ ![Download](https://api.bintray.com/packages/jetbrains/intellij-jdk/openjdk11-osx-x64/images/download.svg) ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-osx-x64/_latestVersion)|[ ![Download](https://api.bintray.com/packages/jetbrains/intellij-jdk/openjdk11-linux-x64/images/download.svg) ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-linux-x64/_latestVersion)|
# How JetBrains Runtime is organised
## Workspaces

View File

@@ -4,9 +4,9 @@ RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-8
RUN yum -y install zip bzip2 unzip tar wget make autoconf automake libtool alsa-devel cups-devel xorg-x11-devel libjpeg62-devel giflib-devel freetype-devel file which libXtst-devel libXt-devel libXrender-devel alsa-lib-devel fontconfig-devel libXrandr-devel libXi-devel git
# Install Java 11
RUN wget https://bintray.com/jetbrains/intellij-jbr/download_file?file_path=jbrsdk-11_0_3-linux-x64-b360.2.tar.gz \
RUN wget https://cdn.azul.com/zulu/bin/zulu11.45.27-ca-jdk11.0.10-linux_x64.tar.gz \
-O - | tar xz -C /
ENV JAVA_HOME /jbrsdk
ENV JAVA_HOME /zulu11.45.27-ca-jdk11.0.10-linux_x64
ENV PATH $JAVA_HOME/bin:/opt/rh/devtoolset-8/root/usr/bin:$PATH
RUN git config --global user.email "teamcity@buildserver.intellij.net"
RUN git config --global user.name "builduser"

View File

@@ -39,15 +39,8 @@ source jb/project/tools/common.sh
function copyJNF {
__contents_dir=$1
# we can't notarize this library as usual framework (with headers and tbd-file)
# but single library notarizes correctly
mkdir -p ${__contents_dir}/Frameworks/JavaNativeFoundation.framework/Resources
cp -p Frameworks/JavaNativeFoundation.framework/JavaNativeFoundation \
${__contents_dir}/Frameworks/JavaNativeFoundation.framework || do_exit $?
cp -p Frameworks/JavaNativeFoundation.framework/Resources/Info.plist \
${__contents_dir}/Frameworks/JavaNativeFoundation.framework/Resources || do_exit $?
# unsign JavaNativeFoundation binary (otherwise notarization will fail)
codesign --remove-signature ${__contents_dir}/Frameworks/JavaNativeFoundation.framework/JavaNativeFoundation || do_exit $?
mkdir -p ${__contents_dir}/Frameworks
cp -Rp Frameworks/JavaNativeFoundation.framework ${__contents_dir}/Frameworks
}
function create_jbr {

View File

@@ -26,8 +26,7 @@ log "Signing libraries and executables..."
# -perm +111 searches for executables
for f in \
"Contents/Home/bin" \
"Contents/Home/lib" \
"Contents/Frameworks"; do
"Contents/Home/lib"; do
if [ -d "$APP_DIRECTORY/$f" ]; then
find "$APP_DIRECTORY/$f" \
-type f \( -name "*.jnilib" -o -name "*.dylib" -o -name "*.so" -o -perm +111 \) \
@@ -37,6 +36,20 @@ for f in \
fi
done
if [ -d "$APP_DIRECTORY/Contents/Frameworks" ]; then
log "Signing frameworks..."
for f in $APP_DIRECTORY/Contents/Frameworks/*; do
find "$f" \
-type f \( -name "*.jnilib" -o -name "*.dylib" -o -name "*.so" \) \
-exec codesign --timestamp --force \
-v -s "$JB_CERT" \
--entitlements entitlements.xml {} \;
codesign --timestamp --force \
-v -s "$JB_CERT" --options=runtime \
--entitlements entitlements.xml "$f"
done
fi
log "Signing libraries in jars in $PWD"
# todo: add set -euo pipefail; into the inner sh -c

View File

@@ -1,18 +1,18 @@
diff --git modules.list modules.list
index e23d793..368d022 100644
index 33375b527c4..76539cbc0e0 100644
--- modules.list
+++ modules.list
@@ -54,4 +54,7 @@ jdk.security.jgss,
jdk.unsupported,
@@ -55,4 +55,7 @@ jdk.unsupported,
jdk.xml.dom,
jdk.zipfs,
-jdk.hotspot.agent
+jdk.hotspot.agent,
jdk.hotspot.agent,
-jdk.jcmd
+jdk.jcmd,
+jcef,
+gluegen.rt,
+jogl.all
diff --git src/java.desktop/share/classes/module-info.java src/java.desktop/share/classes/module-info.java
index b663b38..3e9acdc 100644
index b663b382f52..3e9acdc0c27 100644
--- src/java.desktop/share/classes/module-info.java
+++ src/java.desktop/share/classes/module-info.java
@@ -109,7 +109,11 @@ module java.desktop {

View File

@@ -99,6 +99,8 @@ apt_help() {
PKGHANDLER_COMMAND="sudo apt-get install libfontconfig1-dev" ;;
freetype)
PKGHANDLER_COMMAND="sudo apt-get install libfreetype6-dev" ;;
harfbuzz)
PKGHANDLER_COMMAND="sudo apt-get install libharfbuzz-dev" ;;
ffi)
PKGHANDLER_COMMAND="sudo apt-get install libffi-dev" ;;
x11)
@@ -124,6 +126,8 @@ yum_help() {
PKGHANDLER_COMMAND="sudo yum install fontconfig-devel" ;;
freetype)
PKGHANDLER_COMMAND="sudo yum install freetype-devel" ;;
harfbuzz)
PKGHANDLER_COMMAND="sudo yum install harfbuzz-devel" ;;
x11)
PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel" ;;
ccache)

View File

@@ -37,6 +37,7 @@ AC_DEFUN_ONCE([LIB_SETUP_BUNDLED_LIBS],
LIB_SETUP_LIBPNG
LIB_SETUP_ZLIB
LIB_SETUP_LCMS
LIB_SETUP_HARFBUZZ
])
################################################################################
@@ -260,3 +261,43 @@ AC_DEFUN_ONCE([LIB_SETUP_LCMS],
AC_SUBST(LCMS_CFLAGS)
AC_SUBST(LCMS_LIBS)
])
################################################################################
# Setup harfbuzz
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_HARFBUZZ],
[
AC_ARG_WITH(harfbuzz, [AS_HELP_STRING([--with-harfbuzz],
[use harfbuzz from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
AC_MSG_CHECKING([for which harfbuzz to use])
DEFAULT_HARFBUZZ=bundled
# If user didn't specify, use DEFAULT_HARFBUZZ
if test "x${with_harfbuzz}" = "x"; then
with_harfbuzz=${DEFAULT_HARFBUZZ}
fi
if test "x${with_harfbuzz}" = "xbundled"; then
USE_EXTERNAL_HARFBUZZ=false
HARFBUZZ_CFLAGS=""
HARFBUZZ_LIBS=""
AC_MSG_RESULT([bundled])
elif test "x${with_harfbuzz}" = "xsystem"; then
AC_MSG_RESULT([system])
PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz], [HARFBUZZ_FOUND=yes], [HARFBUZZ_FOUND=no])
if test "x${HARFBUZZ_FOUND}" = "xyes"; then
# PKG_CHECK_MODULES will set HARFBUZZ_CFLAGS and HARFBUZZ_LIBS
USE_EXTERNAL_HARFBUZZ=true
else
HELP_MSG_MISSING_DEPENDENCY([harfbuzz])
AC_MSG_ERROR([--with-harfbuzz=system specified, but no harfbuzz found! $HELP_MSG])
fi
else
AC_MSG_ERROR([Invalid value for --with-harfbuzz: ${with_harfbuzz}, use 'system' or 'bundled'])
fi
AC_SUBST(USE_EXTERNAL_HARFBUZZ)
AC_SUBST(HARFBUZZ_CFLAGS)
AC_SUBST(HARFBUZZ_LIBS)
])

View File

@@ -832,6 +832,10 @@ USE_EXTERNAL_LCMS:=@USE_EXTERNAL_LCMS@
LCMS_CFLAGS:=@LCMS_CFLAGS@
LCMS_LIBS:=@LCMS_LIBS@
USE_EXTERNAL_HARFBUZZ:=@USE_EXTERNAL_HARFBUZZ@
HARFBUZZ_CFLAGS:=@HARFBUZZ_CFLAGS@
HARFBUZZ_LIBS:=@HARFBUZZ_LIBS@
USE_EXTERNAL_LIBPNG:=@USE_EXTERNAL_LIBPNG@
PNG_LIBS:=@PNG_LIBS@
PNG_CFLAGS:=@PNG_CFLAGS@

View File

@@ -73,6 +73,10 @@ ifeq ($(FREETYPE_TO_USE), system)
LEGAL_EXCLUDES += freetype.md
endif
ifeq ($(USE_EXTERNAL_HARFBUZZ), true)
LEGAL_EXCLUDES += harfbuzz.md
endif
$(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \
EXCLUDES := $(LEGAL_EXCLUDES), \
))

View File

@@ -571,34 +571,44 @@ endif
###########################################################################
#### Begin harfbuzz configuration
ifeq ($(USE_EXTERNAL_HARFBUZZ), true)
LIBFONTMANAGER_EXTRA_SRC =
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBHARFBUZZ_LIBS)
else
LIBFONTMANAGER_EXTRA_SRC = libharfbuzz
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
ifneq ($(OPENJDK_TARGET_OS), windows)
HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
-DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
-DHB_NO_PRAGMA_GCC_DIAGNOSTIC
endif
ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx))
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
LIBFONTMANAGER_EXCLUDE_FILES += libharfbuzz/hb-ft.cc \
libharfbuzz/hb-coretext.cc
HARFBUZZ_EXTRA_HEADER_DIRS := \
libharfbuzz/hb-ucdn
HARFBUZZ_DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing
HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
maybe-uninitialized class-memaccess
HARFBUZZ_DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
tautological-constant-out-of-range-compare int-to-pointer-cast \
undef missing-field-initializers range-loop-analysis
HARFBUZZ_DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138
LIBFONTMANAGER_CFLAGS += $(HARFBUZZ_CFLAGS)
ifneq ($(OPENJDK_TARGET_OS), windows)
HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
-DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
-DHB_NO_PRAGMA_GCC_DIAGNOSTIC
endif
ifneq (, $(findstring $(OPENJDK_TARGET_OS), linux macosx))
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
ifeq ($(OPENJDK_TARGET_OS), solaris)
HARFBUZZ_CFLAGS += -DHAVE_SOLARIS_ATOMIC_OPS
endif
LIBFONTMANAGER_EXCLUDE_FILES += harfbuzz/hb-coretext.cc
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
LIBFONTMANAGER_EXCLUDE_FILES += harfbuzz/hb-ft.cc
LIBFONTMANAGER_CFLAGS += $(HARFBUZZ_CFLAGS)
#### End harfbuzz configuration
###########################################################################
LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
libfontmanager/harfbuzz \
libfontmanager/harfbuzz/hb-ucdn \
libharfbuzz \
common/awt \
common/font \
libawt/java2d \
@@ -607,9 +617,9 @@ LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
#
LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS)
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS)
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS)
LIBFONTMANAGER_OPTIMIZATION := HIGH
LIBFONTMANAGER_OPTIMIZATION := HIGHEST
ifeq ($(OPENJDK_TARGET_OS), windows)
LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
@@ -648,22 +658,13 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBFONTMANAGER_CFLAGS), \
OPTIMIZATION := $(LIBFONTMANAGER_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
EXTRA_HEADER_DIRS := $(LIBFONTMANAGER_EXTRA_HEADER_DIRS), \
EXTRA_HEADER_DIRS := $(LIBFONTMANAGER_EXTRA_HEADER_DIRS) $(HARFBUZZ_EXTRA_HEADER_DIRS), \
EXTRA_SRC := $(LIBFONTMANAGER_EXTRA_SRC), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := sign-compare int-to-pointer-cast \
type-limits missing-field-initializers implicit-fallthrough strict-aliasing, \
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
maybe-uninitialized, \
DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
tautological-constant-out-of-range-compare int-to-pointer-cast, \
DISABLED_WARNINGS_C_solstudio = \
E_INTEGER_OVERFLOW_DETECTED \
E_ARG_INCOMPATIBLE_WITH_ARG_L \
E_ENUM_VAL_OVERFLOWS_INT_MAX, \
DISABLED_WARNINGS_CXX_solstudio := \
truncwarn wvarhidenmem wvarhidemem wbadlkginit identexpected \
hidevf w_novirtualdescr arrowrtn2 unknownpragma, \
DISABLED_WARNINGS_microsoft := 4267 4244 4018 4090 4996 4146 4334 4819 4101 4068 4805 4138, \
DISABLED_WARNINGS_gcc := $(HARFBUZZ_DISABLED_WARNINGS_gcc), \
DISABLED_WARNINGS_CXX_gcc := $(HARFBUZZ_DISABLED_WARNINGS_CXX_gcc), \
DISABLED_WARNINGS_clang := $(HARFBUZZ_DISABLED_WARNINGS_clang), \
DISABLED_WARNINGS_microsoft := $(HARFBUZZ_DISABLED_WARNINGS_microsoft), \
LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
$(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -671,8 +672,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
LDFLAGS_aix := -Wl$(COMMA)-berok, \
LIBS := $(BUILD_LIBFONTMANAGER_FONTLIB), \
LIBS_unix := -lawt -ljava -ljvm $(LIBM) $(LIBCXX), \
LIBS_macosx := -lawt_lwawt -framework CoreText -framework CoreFoundation \
-framework CoreGraphics, \
LIBS_macosx := -lawt_lwawt -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
$(WIN_AWT_LIB), \
))

View File

@@ -54,4 +54,5 @@ jdk.security.jgss,
jdk.unsupported,
jdk.xml.dom,
jdk.zipfs,
jdk.hotspot.agent
jdk.hotspot.agent,
jdk.jcmd

View File

@@ -1354,18 +1354,109 @@ static int _print_module(const char* fname, address base_address,
return 0;
}
static errno_t convert_to_UTF16(char const* source_str, UINT source_encoding, LPWSTR* dest_utf16_str) {
const int flag_source_str_is_null_terminated = -1;
const int flag_estimate_chars_count = 0;
int utf16_chars_count_estimated = MultiByteToWideChar(source_encoding,
MB_ERR_INVALID_CHARS,
source_str, flag_source_str_is_null_terminated,
NULL, flag_estimate_chars_count);
if (utf16_chars_count_estimated == 0) {
// Probably source_str contains characters that cannot be represented in the source_encoding given.
*dest_utf16_str = NULL;
return EINVAL;
}
*dest_utf16_str = NEW_C_HEAP_ARRAY(WCHAR, utf16_chars_count_estimated, mtInternal);
int utf16_chars_count_real = MultiByteToWideChar(source_encoding,
MB_ERR_INVALID_CHARS,
source_str, flag_source_str_is_null_terminated,
*dest_utf16_str, utf16_chars_count_estimated);
assert(utf16_chars_count_real == utf16_chars_count_estimated, "length already checked above");
return ERROR_SUCCESS;
}
// Converts a string in the "platform" encoding to UTF16.
static errno_t convert_to_UTF16(char const* platform_str, LPWSTR* utf16_str) {
return convert_to_UTF16(platform_str, CP_ACP, utf16_str);
}
static errno_t convert_UTF8_to_UTF16(char const* utf8_str, LPWSTR* utf16_str) {
return convert_to_UTF16(utf8_str, CP_UTF8, utf16_str);
}
// Converts a wide-character string in UTF-16 encoding to the 8-bit "platform" encoding.
// Unless the platform encoding is UTF-8, not all characters in the source string can be represented in the dest string.
// The function succeeds in this case anyway and just replaces these with a certain character.
static errno_t convert_UTF16_to_platform(LPWSTR source_utf16_str, char*& dest_str) {
const int flag_source_str_is_null_terminated = -1;
const int flag_estimate_chars_count = 0;
int chars_count_estimated = WideCharToMultiByte(CP_ACP,
0,
source_utf16_str, flag_source_str_is_null_terminated,
NULL, flag_estimate_chars_count, NULL, NULL);
if (chars_count_estimated == 0) {
dest_str = NULL;
return EINVAL;
}
dest_str = NEW_C_HEAP_ARRAY(CHAR, chars_count_estimated, mtInternal);
int chars_count_real = WideCharToMultiByte(CP_ACP,
0,
source_utf16_str, flag_source_str_is_null_terminated,
dest_str, chars_count_estimated, NULL, NULL);
assert(chars_count_real == chars_count_estimated, "length already checked above");
return ERROR_SUCCESS;
}
class MemoryReleaserW : public StackObj {
private:
WCHAR* _object_ptr;
public:
MemoryReleaserW(WCHAR * object_ptr) : _object_ptr(object_ptr) {}
~MemoryReleaserW() { if (_object_ptr != NULL) FREE_C_HEAP_ARRAY(WCHAR, _object_ptr); }
};
class MemoryReleaser : public StackObj {
private:
CHAR* _object_ptr;
public:
MemoryReleaser(CHAR * object_ptr) : _object_ptr(object_ptr) {}
~MemoryReleaser() { if (_object_ptr != NULL) FREE_C_HEAP_ARRAY(CHAR, _object_ptr); }
};
// Loads .dll/.so and
// in case of error it checks if .dll/.so was built for the
// same architecture as Hotspot is running on
void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
log_info(os)("attempting shared library load of %s", name);
// The name given is in UTF-8.
void * os::dll_load(const char *utf8_name, char *ebuf, int ebuflen) {
LPWSTR utf16_name = NULL;
errno_t err = convert_UTF8_to_UTF16(utf8_name, &utf16_name);
MemoryReleaserW release_utf16_name(utf16_name);
if (err != ERROR_SUCCESS) {
errno = err;
return NULL;
}
char* platform_name = NULL; // name of the library converted to the "platform" encoding for use in log messages
errno_t ignored_err = convert_UTF16_to_platform(utf16_name, platform_name);
MemoryReleaser release_platform_name(platform_name);
log_info(os)("attempting shared library load of %s", platform_name);
void * result = LoadLibraryW(utf16_name);
void * result = LoadLibrary(name);
if (result != NULL) {
Events::log(NULL, "Loaded shared library %s", name);
Events::log(NULL, "Loaded shared library %s", platform_name);
// Recalculate pdb search path if a DLL was loaded successfully.
SymbolEngine::recalc_search_path();
log_info(os)("shared library load of %s was successful", name);
log_info(os)("shared library load of %s was successful", platform_name);
return result;
}
DWORD errcode = GetLastError();
@@ -1373,8 +1464,8 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
// It may or may not be overwritten below (in the for loop and just above)
lasterror(ebuf, (size_t) ebuflen);
ebuf[ebuflen - 1] = '\0';
Events::log(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
log_info(os)("shared library load of %s failed, error code %lu", name, errcode);
Events::log(NULL, "Loading shared library %s failed, error code %lu", platform_name, errcode);
log_info(os)("shared library load of %s failed, error code %lu", platform_name, errcode);
if (errcode == ERROR_MOD_NOT_FOUND) {
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);
@@ -1387,7 +1478,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
// for an architecture other than Hotspot is running in
// - then print to buffer "DLL was built for a different architecture"
// else call os::lasterror to obtain system error message
int fd = ::open(name, O_RDONLY | O_BINARY, 0);
int fd = ::wopen(utf16_name, O_RDONLY | O_BINARY, 0);
if (fd < 0) {
return NULL;
}
@@ -4246,27 +4337,6 @@ static void file_attribute_data_to_stat(struct stat* sbuf, WIN32_FILE_ATTRIBUTE_
}
}
static errno_t convert_to_unicode(char const* char_path, LPWSTR* unicode_path) {
// Get required buffer size to convert to Unicode
int unicode_path_len = MultiByteToWideChar(CP_ACP,
MB_ERR_INVALID_CHARS,
char_path, -1,
NULL, 0);
if (unicode_path_len == 0) {
return EINVAL;
}
*unicode_path = NEW_C_HEAP_ARRAY(WCHAR, unicode_path_len, mtInternal);
int result = MultiByteToWideChar(CP_ACP,
MB_ERR_INVALID_CHARS,
char_path, -1,
*unicode_path, unicode_path_len);
assert(result == unicode_path_len, "length already checked above");
return ERROR_SUCCESS;
}
static errno_t get_full_path(LPCWSTR unicode_path, LPWSTR* full_path) {
// Get required buffer size to convert to full path. The return
// value INCLUDES the terminating null character.
@@ -4327,7 +4397,7 @@ static wchar_t* wide_abs_unc_path(char const* path, errno_t & err, int additiona
set_path_prefix(buf, &prefix, &prefix_off, &needs_fullpath);
LPWSTR unicode_path = NULL;
err = convert_to_unicode(buf, &unicode_path);
err = convert_to_UTF16(buf, &unicode_path);
FREE_C_HEAP_ARRAY(char, buf);
if (err != ERROR_SUCCESS) {
return NULL;

View File

@@ -3442,6 +3442,7 @@ JVM_END
// Library support ///////////////////////////////////////////////////////////////////////////
// The name of the library is in UTF8
JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name))
//%note jvm_ct
JVMWrapper("JVM_LoadLibrary");
@@ -3455,14 +3456,10 @@ JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name))
if (load_result == NULL) {
char msg[1024];
jio_snprintf(msg, sizeof msg, "%s: %s", name, ebuf);
// Since 'ebuf' may contain a string encoded using
// platform encoding scheme, we need to pass
// Exceptions::unsafe_to_utf8 to the new_exception method
// as the last argument. See bug 6367357.
Handle h_exception =
Exceptions::new_exception(thread,
vmSymbols::java_lang_UnsatisfiedLinkError(),
msg, Exceptions::unsafe_to_utf8);
msg);
THROW_HANDLE_0(h_exception);
}

View File

@@ -113,6 +113,7 @@ inline int g_isfinite(jdouble f) { return _finite(f); }
// Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead
#if _MSC_VER >= 1400
#define open _open
#define wopen _wopen
#define close _close
#define read _read
#define write _write

View File

@@ -736,16 +736,17 @@ public final class SSLSocketImpl
// Is it ready to close inbound?
//
// No need to throw exception if the initial handshake is not started.
if (checkCloseNotify && !conContext.isInputCloseNotified &&
(conContext.isNegotiated || conContext.handshakeContext != null)) {
throw conContext.fatal(Alert.INTERNAL_ERROR,
try {
if (checkCloseNotify && !conContext.isInputCloseNotified &&
(conContext.isNegotiated || conContext.handshakeContext != null)) {
throw new SSLException(
"closing inbound before receiving peer's close_notify");
}
conContext.closeInbound();
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
} finally {
conContext.closeInbound();
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
super.shutdownInput();
}
}
}

View File

@@ -338,7 +338,6 @@ JNIEXPORT jboolean JNICALL
Java_java_lang_ClassLoader_00024NativeLibrary_load0
(JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
{
const char *cname;
jint jniVersion;
jthrowable cause;
void * handle;
@@ -347,7 +346,8 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
if (!initIDs(env))
return JNI_FALSE;
cname = JNU_GetStringPlatformChars(env, name, 0);
char cname_buf[128];
char * cname = getUTF(env, name, cname_buf, sizeof(cname_buf));
if (cname == 0)
return JNI_FALSE;
handle = isBuiltin ? procHandle : JVM_LoadLibrary(cname);
@@ -400,7 +400,9 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
loaded = JNI_TRUE;
done:
JNU_ReleaseStringPlatformChars(env, name, cname);
if (cname != NULL && cname != cname_buf) {
free(cname);
}
return loaded;
}

View File

@@ -211,17 +211,6 @@ ImageFileReaderTable::ImageFileReaderTable() : _count(0), _max(_growth) {
assert(_table != NULL && "allocation failed");
}
ImageFileReaderTable::~ImageFileReaderTable() {
for (u4 i = 0; i < _count; i++) {
ImageFileReader* image = _table[i];
if (image != NULL) {
delete image;
}
}
free(_table);
}
// Add a new image entry to the table.
void ImageFileReaderTable::add(ImageFileReader* image) {
if (_count == _max) {

View File

@@ -371,7 +371,12 @@ private:
public:
ImageFileReaderTable();
~ImageFileReaderTable();
// ~ImageFileReaderTable()
// Bug 8166727
//
// WARNING: Should never close jimage files.
// Threads may still be running during shutdown.
//
// Return the number of entries.
inline u4 count() { return _count; }

View File

@@ -944,9 +944,12 @@ class WindowsNativeDispatcher {
CreateSymbolicLink0(linkBuffer.address(),
targetBuffer.address(), flags);
return;
} catch (WindowsException ignored) {
} catch (WindowsException xx) {
// Will fail with ERROR_INVALID_PARAMETER for Windows
// builds older than 14972.
if (xx.lastError() != ERROR_INVALID_PARAMETER) {
x = xx;
}
}
}
throw x;

View File

@@ -1,51 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.AppForegroundEvent;
/**
* Implementors are notified when the app becomes the foreground app and when it resigns being the foreground app.
* This notification is useful for hiding and showing transient UI like palette windows which should be hidden when the app is in the background.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface AppForegroundListener extends AppEventListener {
/**
* Called when the app becomes the foreground app.
* @param e the app became foreground notification.
*/
public void appRaisedToForeground(final AppForegroundEvent e);
/**
* Called when the app resigns to the background and another app becomes the foreground app.
* @param e the app resigned foreground notification.
*/
public void appMovedToBackground(final AppForegroundEvent e);
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.AppHiddenEvent;
/**
* Implementors are notified when the app is hidden or shown by the user.
* This notification is helpful for discontinuing a costly animation if it's not visible to the user.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface AppHiddenListener extends AppEventListener {
/**
* Called the app is hidden.
* @param e
*/
public void appHidden(final AppHiddenEvent e);
/**
* Called when the hidden app is shown again (but not necessarily brought to the foreground).
* @param e
*/
public void appUnhidden(final AppHiddenEvent e);
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.AppReOpenedEvent;
/**
* Implementors receive notification when the app has been asked to open again.
* Re-open events occur when the user clicks on the running app's Dock icon.
* Re-open events also occur when the app is double-clicked in the Finder and the app is already running.
*
* This notification is useful for showing a new document when your app has no open windows.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface AppReOpenedListener extends AppEventListener {
/**
* Called when the app has been re-opened (it's Dock icon was clicked on, or was double-clicked in the Finder)
* @param e the request to re-open the app
*/
public void appReOpened(final AppReOpenedEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,38 @@
package com.apple.eawt;
import java.awt.*;
import java.awt.peer.*;
import java.awt.Image;
import java.awt.PopupMenu;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.desktop.AboutHandler;
import java.awt.desktop.AppForegroundListener;
import java.awt.desktop.AppHiddenListener;
import java.awt.desktop.AppReopenedListener;
import java.awt.desktop.OpenFilesEvent;
import java.awt.desktop.OpenFilesHandler;
import java.awt.desktop.OpenURIEvent;
import java.awt.desktop.OpenURIHandler;
import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.PrintFilesEvent;
import java.awt.desktop.PrintFilesHandler;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.QuitResponse;
import java.awt.desktop.QuitStrategy;
import java.awt.desktop.ScreenSleepListener;
import java.awt.desktop.SystemEventListener;
import java.awt.desktop.SystemSleepListener;
import java.awt.desktop.UserSessionListener;
import java.beans.Beans;
import java.util.function.Consumer;
import javax.swing.JMenuBar;
import sun.lwawt.*;
import sun.lwawt.macosx.*;
import sun.awt.AWTAccessor;
import sun.util.logging.PlatformLogger;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CPlatformWindow;
/**
* The <code>Application</code> class allows you to integrate your Java application with the native Mac OS X environment.
* The {@code Application} class allows you to integrate your Java application with the native Mac OS X environment.
* You can provide your Mac OS X users a greatly enhanced experience by implementing a few basic handlers for standard system events.
*
* For example:
@@ -56,22 +74,13 @@ import sun.util.logging.PlatformLogger;
* @since 1.4
*/
public class Application {
private static final PlatformLogger focusRequestLog = PlatformLogger.getLogger("jb.focus.requests");
private static native void nativeInitializeApplicationDelegate();
static Application sApplication = null;
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
checkSecurity();
Toolkit.getDefaultToolkit(); // Start AppKit
if (!Beans.isDesignTime()) {
nativeInitializeApplicationDelegate();
}
@@ -112,11 +121,11 @@ public class Application {
}
/**
* Adds sub-types of {@link AppEventListener} to listen for notifications from the native Mac OS X system.
* Adds sub-types of {@link SystemEventListener} to listen for notifications from the native Mac OS X system.
*
* @see AppForegroundListener
* @see AppHiddenListener
* @see AppReOpenedListener
* @see AppReopenedListener
* @see ScreenSleepListener
* @see SystemSleepListener
* @see UserSessionListener
@@ -125,16 +134,16 @@ public class Application {
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public void addAppEventListener(final AppEventListener listener) {
public void addAppEventListener(final SystemEventListener listener) {
eventHandler.addListener(listener);
}
/**
* Removes sub-types of {@link AppEventListener} from listening for notifications from the native Mac OS X system.
* Removes sub-types of {@link SystemEventListener} from listening for notifications from the native Mac OS X system.
*
* @see AppForegroundListener
* @see AppHiddenListener
* @see AppReOpenedListener
* @see AppReopenedListener
* @see ScreenSleepListener
* @see SystemSleepListener
* @see UserSessionListener
@@ -143,16 +152,16 @@ public class Application {
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public void removeAppEventListener(final AppEventListener listener) {
public void removeAppEventListener(final SystemEventListener listener) {
eventHandler.removeListener(listener);
}
/**
* Installs a handler to show a custom About window for your application.
*
* Setting the {@link AboutHandler} to <code>null</code> reverts it to the default Cocoa About window.
* Setting the {@link AboutHandler} to {@code null} reverts it to the default Cocoa About window.
*
* @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout()} message
* @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout} message
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
@@ -163,7 +172,7 @@ public class Application {
/**
* Installs a handler to create the Preferences menu item in your application's app menu.
*
* Setting the {@link PreferencesHandler} to <code>null</code> will remove the Preferences item from the app menu.
* Setting the {@link PreferencesHandler} to {@code null} will remove the Preferences item from the app menu.
*
* @param preferencesHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -175,8 +184,8 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to open a list of files.
* The {@link OpenFilesHandler#openFiles(AppEvent.OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleDocumentTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleDocumentTypes</code> key to your app's Info.plist.
* The {@link OpenFilesHandler#openFiles(OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist.
*
* @param openFileHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -188,8 +197,8 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to print a list of files.
* The {@link PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleDocumentTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleDocumentTypes</code> key to your app's Info.plist.
* The {@link PrintFilesHandler#printFiles(PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist.
*
* @param printFileHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -201,10 +210,10 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to open a URL.
* The {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleURLTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleURLTypes</code> key to your app's Info.plist.
* The {@link OpenURIHandler#openURI(OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleURLTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleURLTypes} key to your app's Info.plist.
*
* Setting the handler to <code>null</code> causes all {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be enqueued until another handler is set.
* Setting the handler to {@code null} causes all {@link OpenURIHandler#openURI(OpenURIEvent)} requests to be enqueued until another handler is set.
*
* @param openURIHandler
* @since Java for Mac OS X 10.6 Update 3
@@ -217,7 +226,7 @@ public class Application {
/**
* Installs the handler which determines if the application should quit.
* The handler is passed a one-shot {@link QuitResponse} which can cancel or proceed with the quit.
* Setting the handler to <code>null</code> causes all quit requests to directly perform the default {@link QuitStrategy}.
* Setting the handler to {@code null} causes all quit requests to directly perform the default {@link QuitStrategy}.
*
* @param quitHandler the handler that is called when the application is asked to quit
* @since Java for Mac OS X 10.6 Update 3
@@ -287,9 +296,6 @@ public class Application {
* @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
*/
public void requestForeground(final boolean allWindows) {
if (focusRequestLog.isLoggable(PlatformLogger.Level.FINE)) {
focusRequestLog.fine("requestForeground(" + (allWindows ? "allWindows" : "") + ")", new Throwable());
}
_AppMiscHandlers.requestActivation(allWindows);
}
@@ -378,6 +384,16 @@ public class Application {
iconHandler.setDockIconBadge(badge);
}
/**
* Displays a progress bar to this application's Dock icon.
* Acceptable values are from 0 to 100, any other disables progress indication.
*
* @param value progress value
*/
public void setDockIconProgress(final int value) {
iconHandler.setDockIconProgress(value);
}
/**
* Sets the default menu bar to use when there are no active frames.
* Only used when the system property "apple.laf.useScreenMenuBar" is "true", and
@@ -400,189 +416,12 @@ public class Application {
*
* @since Java for Mac OS X 10.7 Update 1
*/
@SuppressWarnings("deprecation")
public void requestToggleFullScreen(final Window window) {
invokeOnPlatformWindow(window, pw -> pw.toggleFullScreen());
}
public void requestEnterFullScreen(final Window window) {
invokeOnPlatformWindow(window, pw -> pw.enterFullScreen());
}
public void requestLeaveFullScreen(final Window window) {
invokeOnPlatformWindow(window, pw -> pw.leaveFullScreen());
}
private void invokeOnPlatformWindow (final Window window, Consumer<CPlatformWindow> consumer) {
final Object peer = AWTAccessor.getComponentAccessor().getPeer(window);
if (!(peer instanceof LWWindowPeer)) return;
Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow();
if (!(platformWindow instanceof CPlatformWindow)) return;
consumer.accept((CPlatformWindow)platformWindow);
((CPlatformWindow)platformWindow).toggleFullScreen();
}
// -- DEPRECATED API --
/**
* Adds the specified ApplicationListener as a receiver of callbacks from this class.
* This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
*
* @param listener an implementation of ApplicationListener that handles ApplicationEvents
*
* @deprecated register individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
* @since 1.4
*/
@SuppressWarnings("deprecation")
@Deprecated
public void addApplicationListener(final ApplicationListener listener) {
eventHandler.legacyHandler.addLegacyAppListener(listener);
}
/**
* Removes the specified ApplicationListener from being a receiver of callbacks from this class.
* This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
*
* @param listener an implementation of ApplicationListener that had previously been registered to handle ApplicationEvents
*
* @deprecated unregister individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
* @since 1.4
*/
@SuppressWarnings("deprecation")
@Deprecated
public void removeApplicationListener(final ApplicationListener listener) {
eventHandler.legacyHandler.removeLegacyAppListener(listener);
}
/**
* Enables the Preferences item in the application menu. The ApplicationListener receives a callback for
* selection of the Preferences item in the application menu only if this is set to <code>true</code>.
*
* If a Preferences item isn't present, this method adds and enables it.
*
* @param enable specifies whether the Preferences item in the application menu should be enabled (<code>true</code>) or not (<code>false</code>)
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public void setEnabledPreferencesMenu(final boolean enable) {
menuBarHandler.setPreferencesMenuItemVisible(true);
menuBarHandler.setPreferencesMenuItemEnabled(enable);
}
/**
* Enables the About item in the application menu. The ApplicationListener receives a callback for
* selection of the About item in the application menu only if this is set to <code>true</code>. Because AWT supplies
* a standard About window when an application may not, by default this is set to <code>true</code>.
*
* If the About item isn't present, this method adds and enables it.
*
* @param enable specifies whether the About item in the application menu should be enabled (<code>true</code>) or not (<code>false</code>)
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public void setEnabledAboutMenu(final boolean enable) {
menuBarHandler.setAboutMenuItemEnabled(enable);
}
/**
* Determines if the Preferences item of the application menu is enabled.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean getEnabledPreferencesMenu() {
return menuBarHandler.isPreferencesMenuItemEnabled();
}
/**
* Determines if the About item of the application menu is enabled.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean getEnabledAboutMenu() {
return menuBarHandler.isAboutMenuItemEnabled();
}
/**
* Determines if the About item of the application menu is present.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean isAboutMenuItemPresent() {
return menuBarHandler.isAboutMenuItemVisible();
}
/**
* Adds the About item to the application menu if the item is not already present.
*
* @deprecated use {@link #setAboutHandler(AboutHandler)} with a non-null {@link AboutHandler} parameter
* @since 1.4
*/
@Deprecated
public void addAboutMenuItem() {
menuBarHandler.setAboutMenuItemVisible(true);
}
/**
* Removes the About item from the application menu if the item is present.
*
* @deprecated use {@link #setAboutHandler(AboutHandler)} with a null parameter
* @since 1.4
*/
@Deprecated
public void removeAboutMenuItem() {
menuBarHandler.setAboutMenuItemVisible(false);
}
/**
* Determines if the About Preferences of the application menu is present. By default there is no Preferences menu item.
*
* @deprecated no replacement
* @since 1.4
*/
@Deprecated
public boolean isPreferencesMenuItemPresent() {
return menuBarHandler.isPreferencesMenuItemVisible();
}
/**
* Adds the Preferences item to the application menu if the item is not already present.
*
* @deprecated use {@link #setPreferencesHandler(PreferencesHandler)} with a non-null {@link PreferencesHandler} parameter
* @since 1.4
*/
@Deprecated
public void addPreferencesMenuItem() {
menuBarHandler.setPreferencesMenuItemVisible(true);
}
/**
* Removes the Preferences item from the application menu if that item is present.
*
* @deprecated use {@link #setPreferencesHandler(PreferencesHandler)} with a null parameter
* @since 1.4
*/
@Deprecated
public void removePreferencesMenuItem() {
menuBarHandler.setPreferencesMenuItemVisible(false);
}
/**
* @deprecated Use <code>java.awt.MouseInfo.getPointerInfo().getLocation()</code>.
*
* @since 1.4
*/
@Deprecated
public static Point getMouseLocationOnScreen() {
return java.awt.MouseInfo.getPointerInfo().getLocation();
}
}

View File

@@ -1,75 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
/**
* An abstract adapter class for receiving <code>ApplicationEvents</code>.
*
* ApplicationEvents are deprecated. Use individual app event listeners or handlers instead.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @see AboutHandler
* @see PreferencesHandler
* @see OpenURIHandler
* @see OpenFilesHandler
* @see PrintFilesHandler
* @see QuitHandler
*
* @see AppReOpenedListener
* @see AppForegroundListener
* @see AppHiddenListener
* @see UserSessionListener
* @see ScreenSleepListener
* @see SystemSleepListener
*
* @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}.
* @since 1.4
*/
@SuppressWarnings("deprecation")
@Deprecated
public class ApplicationAdapter implements ApplicationListener {
@Deprecated
public void handleAbout(final ApplicationEvent event) { }
@Deprecated
public void handleOpenApplication(final ApplicationEvent event) { }
@Deprecated
public void handleOpenFile(final ApplicationEvent event) { }
@Deprecated
public void handlePreferences(final ApplicationEvent event) { }
@Deprecated
public void handlePrintFile(final ApplicationEvent event) { }
@Deprecated
public void handleQuit(final ApplicationEvent event) { }
@Deprecated
public void handleReOpenApplication(final ApplicationEvent event) { }
}

View File

@@ -1,95 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import java.util.EventObject;
/**
* The class of events sent to the deprecated ApplicationListener callbacks.
*
* @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}
* @since 1.4
*/
@Deprecated
public class ApplicationEvent extends EventObject {
private String fFilename = null;
private boolean fHandled = false;
ApplicationEvent(final Object source) {
super(source);
}
ApplicationEvent(final Object source, final String filename) {
super(source);
fFilename = filename;
}
/**
* Determines whether an ApplicationListener has acted on a particular event.
* An event is marked as having been handled with <code>setHandled(true)</code>.
*
* @return <code>true</code> if the event has been handled, otherwise <code>false</code>
*
* @since 1.4
* @deprecated
*/
@Deprecated
public boolean isHandled() {
return fHandled;
}
/**
* Marks the event as handled.
* After this method handles an ApplicationEvent, it may be useful to specify that it has been handled.
* This is usually used in conjunction with <code>getHandled()</code>.
* Set to <code>true</code> to designate that this event has been handled. By default it is <code>false</code>.
*
* @param state <code>true</code> if the event has been handled, otherwise <code>false</code>.
*
* @since 1.4
* @deprecated
*/
@Deprecated
public void setHandled(final boolean state) {
fHandled = state;
}
/**
* Provides the filename associated with a particular AppleEvent.
* When the ApplicationEvent corresponds to an AppleEvent that needs to act on a particular file, the ApplicationEvent carries the name of the specific file with it.
* For example, the Print and Open events refer to specific files.
* For these cases, this returns the appropriate file name.
*
* @return the full path to the file associated with the event, if applicable, otherwise <code>null</code>
*
* @since 1.4
* @deprecated use {@link OpenFilesHandler} or {@link PrintFilesHandler} instead
*/
@Deprecated
public String getFilename() {
return fFilename;
}
}

View File

@@ -1,153 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import java.util.EventListener;
/**
* ApplicationEvents are deprecated. Use individual AppEvent listeners or handlers instead.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @see AboutHandler
* @see PreferencesHandler
* @see OpenURIHandler
* @see OpenFilesHandler
* @see PrintFilesHandler
* @see QuitHandler
*
* @see AppReOpenedListener
* @see AppForegroundListener
* @see AppHiddenListener
* @see UserSessionListener
* @see ScreenSleepListener
* @see SystemSleepListener
*
* @since 1.4
* @deprecated replaced by {@link AboutHandler}, {@link PreferencesHandler}, {@link AppReOpenedListener}, {@link OpenFilesHandler}, {@link PrintFilesHandler}, {@link QuitHandler}, {@link QuitResponse}
*/
@SuppressWarnings("deprecation")
@Deprecated
public interface ApplicationListener extends EventListener {
/**
* Called when the user selects the About item in the application menu. If <code>event</code> is not handled by
* setting <code>isHandled(true)</code>, a default About window consisting of the application's name and icon is
* displayed. To display a custom About window, designate the <code>event</code> as being handled and display the
* appropriate About window.
*
* @param event an ApplicationEvent initiated by the user choosing About in the application menu
* @deprecated use {@link AboutHandler}
*/
@Deprecated
public void handleAbout(ApplicationEvent event);
/**
* Called when the application receives an Open Application event from the Finder or another application. Usually
* this will come from the Finder when a user double-clicks your application icon. If there is any special code
* that you want to run when you user launches your application from the Finder or by sending an Open Application
* event from another application, include that code as part of this handler. The Open Application event is sent
* after AWT has been loaded.
*
* @param event the Open Application event
* @deprecated no replacement
*/
@Deprecated
public void handleOpenApplication(ApplicationEvent event);
/**
* Called when the application receives an Open Document event from the Finder or another application. This event
* is generated when a user double-clicks a document in the Finder. If the document is registered as belonging
* to your application, this event is sent to your application. Documents are bound to a particular application based
* primarily on their suffix. In the Finder, a user selects a document and then from the File Menu chooses Get Info.
* The Info window allows users to bind a document to a particular application.
*
* These events are sent only if the bound application has file types listed in the Info.plist entries Document Types
* or CFBundleDocumentTypes.
*
* The ApplicationEvent sent to this handler holds a reference to the file being opened.
*
* @param event an Open Document event with reference to the file to be opened
* @deprecated use {@link OpenFilesHandler}
*/
@Deprecated
public void handleOpenFile(ApplicationEvent event);
/**
* Called when the Preference item in the application menu is selected. Native Mac OS X applications make their
* Preferences window available through the application menu. Java applications are automatically given an application
* menu in Mac OS X. By default, the Preferences item is disabled in that menu. If you are deploying an application
* on Mac OS X, you should enable the preferences item with <code>setEnabledPreferencesMenu(true)</code> in the
* Application object and then display your Preferences window in this handler.
*
* @param event triggered when the user selects Preferences from the application menu
* @deprecated use {@link PreferencesHandler}
*/
@Deprecated
public void handlePreferences(ApplicationEvent event);
/**
* Called when the application is sent a request to print a particular file or files. You can allow other applications to
* print files with your application by implementing this handler. If another application sends a Print Event along
* with the name of a file that your application knows how to process, you can use this handler to determine what to
* do with that request. You might open your entire application, or just invoke your printing classes.
*
* These events are sent only if the bound application has file types listed in the Info.plist entries Document Types
* or CFBundleDocumentTypes.
*
* The ApplicationEvent sent to this handler holds a reference to the file being opened.
*
* @param event a Print Document event with a reference to the file(s) to be printed
* @deprecated use {@link PrintFilesHandler}
*/
@Deprecated
public void handlePrintFile(ApplicationEvent event);
/**
* Called when the application is sent the Quit event. This event is generated when the user selects Quit from the
* application menu, when the user types Command-Q, or when the user control clicks on your application icon in the
* Dock and chooses Quit. You can either accept or reject the request to quit. You might want to reject the request
* to quit if the user has unsaved work. Reject the request, move into your code to save changes, then quit your
* application. To accept the request to quit, and terminate the application, set <code>isHandled(true)</code> for the
* <code>event</code>. To reject the quit, set <code>isHandled(false)</code>.
*
* @param event a Quit Application event
* @deprecated use {@link QuitHandler} and {@link QuitResponse}
*/
@Deprecated
public void handleQuit(ApplicationEvent event);
/**
* Called when the application receives a Reopen Application event from the Finder or another application. Usually
* this will come when a user clicks on your application icon in the Dock. If there is any special code
* that needs to run when your user clicks on your application icon in the Dock or when a Reopen Application
* event is sent from another application, include that code as part of this handler.
*
* @param event the Reopen Application event
* @deprecated use {@link AppReOpenedListener}
*/
@Deprecated
public void handleReOpenApplication(ApplicationEvent event);
}

View File

@@ -25,7 +25,7 @@
package com.apple.eawt;
import com.apple.eawt.AppEvent.FullScreenEvent;
import com.apple.eawt.event.FullScreenEvent;
/**
* Abstract adapter class for receiving fullscreen events. This class is provided

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,13 @@
package com.apple.eawt;
import com.apple.eawt.event.FullScreenEvent;
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.RootPaneContainer;
import com.apple.eawt.AppEvent.FullScreenEvent;
import sun.awt.SunToolkit;
import java.lang.annotation.Native;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,9 @@
package com.apple.eawt;
import com.apple.eawt.event.FullScreenEvent;
import java.util.EventListener;
import com.apple.eawt.AppEvent.FullScreenEvent;
/**
*
@@ -37,25 +37,25 @@ import com.apple.eawt.AppEvent.FullScreenEvent;
public interface FullScreenListener extends EventListener {
/**
* Invoked when a window has started to enter full screen.
* @param event containing the specific window entering full screen.
* @param e containing the specific window entering full screen.
*/
public void windowEnteringFullScreen(final FullScreenEvent e);
/**
* Invoked when a window has fully entered full screen.
* @param event containing the specific window which has entered full screen.
* @param e containing the specific window which has entered full screen.
*/
public void windowEnteredFullScreen(final FullScreenEvent e);
/**
* Invoked when a window has started to exit full screen.
* @param event containing the specific window exiting full screen.
* @param e containing the specific window exiting full screen.
*/
public void windowExitingFullScreen(final FullScreenEvent e);
/**
* Invoked when a window has fully exited full screen.
* @param event containing the specific window which has exited full screen.
* @param e containing the specific window which has exited full screen.
*/
public void windowExitedFullScreen(final FullScreenEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,27 +25,25 @@
package com.apple.eawt;
import java.awt.*;
import java.awt.Component;
import java.awt.Window;
import javax.swing.RootPaneContainer;
import sun.lwawt.macosx.*;
import com.apple.eawt.event.GestureUtilities;
import sun.lwawt.macosx.CPlatformWindow;
/**
* Utility class perform animated full screen actions to top-level {@link Window}s.
*
* This class manages the relationship between {@link Windows}s and the {@link FullScreenListener}s
* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}
* class which adds additional functionality to AWT Windows, without adding new API to the
* This class manages the relationship between {@link Window}s and the {@link FullScreenListener}s
* attached to them. It adds additional functionality to AWT Windows, without adding new API to the
* {@link java.awt.Window} class.
*
* Full screen operations can only be performed on top-level {@link Window}s that are also {@link RootPaneContainer}s.
*
* @see FullScreenAdapter
* @see GestureUtilities
* @see com.sun.awt.AWTUtilities
*
* @since Java for Mac OS X 10.7 Update 1
*/

View File

@@ -53,7 +53,7 @@ public class MacQuitResponse implements QuitResponse {
*/
@Override
public void performQuit() {
//if (appEventHandler.currentQuitResponse != this) return;
if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.performQuit();
}
@@ -63,7 +63,7 @@ public class MacQuitResponse implements QuitResponse {
*/
@Override
public void cancelQuit() {
//if (appEventHandler.currentQuitResponse != this) return;
if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.cancelQuit();
}
}

View File

@@ -47,8 +47,6 @@ public class QuitResponse {
* Notifies the external quit requester that the quit will proceed, and performs the default {@link QuitStrategy}.
*/
public void performQuit() {
if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.performQuit();
}
/**
@@ -56,7 +54,5 @@ public class QuitResponse {
* <b>Note: this will cancel a pending log-out, restart, or shutdown.</b>
*/
public void cancelQuit() {
if (appEventHandler.currentQuitResponse != this) return;
appEventHandler.cancelQuit();
}
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.ScreenSleepEvent;
/**
* Implementors receive notification when the displays attached to the system have entered power save sleep.
*
* This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
*
* This message is not sent on Mac OS X versions prior to 10.6.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface ScreenSleepListener extends AppEventListener {
/**
* Called when the system displays have entered power save sleep.
* @param e the screen sleep event
*/
public void screenAboutToSleep(final ScreenSleepEvent e);
/**
* Called when the system displays have awoke from power save sleep.
* @param e the screen sleep event
*/
public void screenAwoke(final ScreenSleepEvent e);
}

View File

@@ -1,53 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.SystemSleepEvent;
/**
* Implementors receive notification as the system is entering sleep, and after the system wakes.
*
* This notification is useful for disconnecting from network services prior to sleep, or re-establishing a connection if the network configuration has changed during sleep.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface SystemSleepListener extends AppEventListener {
/**
* Called when the system is about to sleep.
* Note: This message may not be delivered prior to the actual system sleep, and may be processed after the corresponding wake has occurred.
* @param e the system sleep event
*/
public void systemAboutToSleep(final SystemSleepEvent e);
/**
* Called after the system has awoke from sleeping.
* @param e the system sleep event
*/
public void systemAwoke(final SystemSleepEvent e);
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import com.apple.eawt.AppEvent.UserSessionEvent;
/**
* Implementors receive notification when Fast User Switching changes the user session.
*
* This notification is useful for discontinuing a costly animation, or indicating that the user is no longer present on a network service.
*
* @see Application#addAppEventListener(AppEventListener)
*
* @since Java for Mac OS X 10.6 Update 3
* @since Java for Mac OS X 10.5 Update 8
*/
public interface UserSessionListener extends AppEventListener {
/**
* Called when the user session has been switched away.
* @param e the user session switch event
*/
public void userSessionDeactivated(final UserSessionEvent e);
/**
* Called when the user session has been switched to.
* @param e the user session switch event
*/
public void userSessionActivated(final UserSessionEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,13 +28,14 @@ package com.apple.eawt;
import java.awt.*;
import java.lang.reflect.*;
import sun.awt.AWTAccessor;
import sun.lwawt.macosx.*;
import sun.lwawt.macosx.CImage.Creator;
import sun.awt.AWTAccessor;
class _AppDockIconHandler {
private static native void nativeSetDockMenu(final long cmenu);
private static native void nativeSetDockIconImage(final long image);
private static native void nativeSetDockIconProgress(final int value);
private static native long nativeGetDockIconImage();
private static native void nativeSetDockIconBadge(final String badge);
@@ -42,7 +43,6 @@ class _AppDockIconHandler {
_AppDockIconHandler() { }
@SuppressWarnings("deprecation")
public void setDockMenu(final PopupMenu menu) {
fDockMenu = menu;
@@ -72,9 +72,8 @@ class _AppDockIconHandler {
public void setDockIconImage(final Image image) {
try {
final CImage cImage = getCImageCreator().createFromImage(image);
final long nsImagePtr = getNSImagePtrFrom(cImage);
nativeSetDockIconImage(nsImagePtr);
final CImage cImage = CImage.createFromImage(image);
cImage.execute(_AppDockIconHandler::nativeSetDockIconImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
@@ -84,7 +83,11 @@ class _AppDockIconHandler {
try {
final long dockNSImage = nativeGetDockIconImage();
if (dockNSImage == 0) return null;
return getCImageCreator().createImageUsingNativeSize(dockNSImage);
final Method getCreatorMethod = CImage.class.getDeclaredMethod(
"getCreator", new Class<?>[]{});
getCreatorMethod.setAccessible(true);
Creator imageCreator = (Creator) getCreatorMethod.invoke(null, new Object[]{});
return imageCreator.createImageUsingNativeSize(dockNSImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
@@ -94,26 +97,7 @@ class _AppDockIconHandler {
nativeSetDockIconBadge(badge);
}
@SuppressWarnings("rawtypes")
static Creator getCImageCreator() {
try {
final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {});
getCreatorMethod.setAccessible(true);
return (Creator)getCreatorMethod.invoke(null, new Object[] {});
} catch (final Throwable e) {
throw new RuntimeException(e);
}
}
static long getNSImagePtrFrom(final CImage cImage) {
if (cImage == null) return 0;
try {
final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr");
cImagePtrField.setAccessible(true);
return cImagePtrField.getLong(cImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
void setDockIconProgress(int value) {
nativeSetDockIconProgress(value);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,47 @@
package com.apple.eawt;
import java.awt.*;
import java.awt.EventQueue;
import java.awt.Frame;
import java.awt.desktop.AboutEvent;
import java.awt.desktop.AboutHandler;
import java.awt.desktop.AppForegroundEvent;
import java.awt.desktop.AppForegroundListener;
import java.awt.desktop.AppHiddenEvent;
import java.awt.desktop.AppHiddenListener;
import java.awt.desktop.AppReopenedEvent;
import java.awt.desktop.AppReopenedListener;
import java.awt.desktop.OpenFilesEvent;
import java.awt.desktop.OpenFilesHandler;
import java.awt.desktop.OpenURIEvent;
import java.awt.desktop.OpenURIHandler;
import java.awt.desktop.PreferencesEvent;
import java.awt.desktop.PreferencesHandler;
import java.awt.desktop.PrintFilesEvent;
import java.awt.desktop.PrintFilesHandler;
import java.awt.desktop.QuitEvent;
import java.awt.desktop.QuitHandler;
import java.awt.desktop.QuitStrategy;
import java.awt.desktop.ScreenSleepEvent;
import java.awt.desktop.ScreenSleepListener;
import java.awt.desktop.SystemEventListener;
import java.awt.desktop.SystemSleepEvent;
import java.awt.desktop.SystemSleepListener;
import java.awt.desktop.UserSessionEvent;
import java.awt.desktop.UserSessionEvent.Reason;
import java.awt.desktop.UserSessionListener;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.*;
import java.util.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import com.apple.eawt.AppEvent.*;
class _AppEventHandler {
private static final int NOTIFY_ABOUT = 1;
private static final int NOTIFY_PREFS = 2;
@@ -62,7 +92,7 @@ class _AppEventHandler {
private static native void nativeReplyToAppShouldTerminate(final boolean shouldTerminate);
private static native void nativeRegisterForNotification(final int notification);
final static _AppEventHandler instance = new _AppEventHandler();
static final _AppEventHandler instance = new _AppEventHandler();
static _AppEventHandler getInstance() {
return instance;
}
@@ -84,9 +114,7 @@ class _AppEventHandler {
final _ScreenSleepDispatcher screenSleepDispatcher = new _ScreenSleepDispatcher();
final _SystemSleepDispatcher systemSleepDispatcher = new _SystemSleepDispatcher();
final _AppEventLegacyHandler legacyHandler = new _AppEventLegacyHandler(this);
QuitStrategy defaultQuitAction = QuitStrategy.SYSTEM_EXIT_0;
QuitStrategy defaultQuitAction = QuitStrategy.NORMAL_EXIT;
_AppEventHandler() {
final String strategyProp = System.getProperty("apple.eawt.quitStrategy");
@@ -94,15 +122,16 @@ class _AppEventHandler {
if ("CLOSE_ALL_WINDOWS".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS);
} else if ("SYSTEM_EXIT_O".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.SYSTEM_EXIT_0);
} else if ("SYSTEM_EXIT_O".equals(strategyProp)
|| "NORMAL_EXIT".equals(strategyProp)) {
setDefaultQuitStrategy(QuitStrategy.NORMAL_EXIT);
} else {
System.err.println("unrecognized apple.eawt.quitStrategy: " + strategyProp);
}
}
void addListener(final AppEventListener listener) {
if (listener instanceof AppReOpenedListener) reOpenAppDispatcher.addListener((AppReOpenedListener)listener);
void addListener(final SystemEventListener listener) {
if (listener instanceof AppReopenedListener) reOpenAppDispatcher.addListener((AppReopenedListener)listener);
if (listener instanceof AppForegroundListener) foregroundAppDispatcher.addListener((AppForegroundListener)listener);
if (listener instanceof AppHiddenListener) hiddenAppDispatcher.addListener((AppHiddenListener)listener);
if (listener instanceof UserSessionListener) userSessionDispatcher.addListener((UserSessionListener)listener);
@@ -110,8 +139,8 @@ class _AppEventHandler {
if (listener instanceof SystemSleepListener) systemSleepDispatcher.addListener((SystemSleepListener)listener);
}
void removeListener(final AppEventListener listener) {
if (listener instanceof AppReOpenedListener) reOpenAppDispatcher.removeListener((AppReOpenedListener)listener);
void removeListener(final SystemEventListener listener) {
if (listener instanceof AppReopenedListener) reOpenAppDispatcher.removeListener((AppReopenedListener)listener);
if (listener instanceof AppForegroundListener) foregroundAppDispatcher.removeListener((AppForegroundListener)listener);
if (listener instanceof AppHiddenListener) hiddenAppDispatcher.removeListener((AppHiddenListener)listener);
if (listener instanceof UserSessionListener) userSessionDispatcher.removeListener((UserSessionListener)listener);
@@ -127,10 +156,10 @@ class _AppEventHandler {
this.defaultQuitAction = defaultQuitAction;
}
QuitResponse currentQuitResponse;
synchronized QuitResponse obtainQuitResponse() {
MacQuitResponse currentQuitResponse;
synchronized MacQuitResponse obtainQuitResponse() {
if (currentQuitResponse != null) return currentQuitResponse;
return currentQuitResponse = new QuitResponse(this);
return currentQuitResponse = new MacQuitResponse(this);
}
synchronized void cancelQuit() {
@@ -142,7 +171,8 @@ class _AppEventHandler {
currentQuitResponse = null;
try {
if (defaultQuitAction == QuitStrategy.SYSTEM_EXIT_0) System.exit(0);
if (defaultQuitAction == QuitStrategy.NORMAL_EXIT
|| _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0);
if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
throw new RuntimeException("Unknown quit action");
@@ -270,10 +300,10 @@ class _AppEventHandler {
}
}
class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReOpenedListener> {
void performOnListener(AppReOpenedListener listener, final _NativeEvent event) {
final AppReOpenedEvent e = new AppReOpenedEvent();
listener.appReOpened(e);
class _AppReOpenedDispatcher extends _AppEventMultiplexor<AppReopenedListener> {
void performOnListener(AppReopenedListener listener, final _NativeEvent event) {
final AppReopenedEvent e = new AppReopenedEvent();
listener.appReopened(e);
}
}
@@ -302,7 +332,9 @@ class _AppEventHandler {
}
class _UserSessionDispatcher extends _BooleanAppEventMultiplexor<UserSessionListener, UserSessionEvent> {
UserSessionEvent createEvent(final boolean isTrue) { return new UserSessionEvent(); }
UserSessionEvent createEvent(final boolean isTrue) {
return new UserSessionEvent(Reason.UNSPECIFIED);
}
void performFalseEventOn(final UserSessionListener listener, final UserSessionEvent e) {
listener.userSessionDeactivated(e);
@@ -391,7 +423,11 @@ class _AppEventHandler {
}
void performUsing(final QuitHandler handler, final _NativeEvent event) {
final QuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
if (_AppMiscHandlers.isSuddenTerminationEnbaled()) {
performDefaultAction(event);
return;
}
final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response
handler.handleQuitRequestWith(new QuitEvent(), response);
}
}
@@ -524,9 +560,6 @@ class _AppEventHandler {
setHandlerContext(AppContext.getAppContext());
// if a new handler is installed, block addition of legacy ApplicationListeners
if (handler == legacyHandler) return;
legacyHandler.blockLegacyAPI();
}
void performDefaultAction(final _NativeEvent event) { } // by default, do nothing
@@ -574,10 +607,6 @@ class _AppEventHandler {
}
}
}
// if a new handler is installed, block addition of legacy ApplicationListeners
if (handler == legacyHandler) return;
legacyHandler.blockLegacyAPI();
}
}
}

View File

@@ -1,188 +0,0 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.eawt;
import java.awt.Toolkit;
import java.io.File;
import java.util.*;
import com.apple.eawt.AppEvent.*;
@SuppressWarnings("deprecation")
class _AppEventLegacyHandler implements AboutHandler, PreferencesHandler, _OpenAppHandler, AppReOpenedListener, OpenFilesHandler, PrintFilesHandler, QuitHandler {
final _AppEventHandler parent;
final Vector<ApplicationListener> legacyAppListeners = new Vector<ApplicationListener>();
boolean blockLegacyAPI;
boolean initializedParentDispatchers;
_AppEventLegacyHandler(final _AppEventHandler parent) {
this.parent = parent;
}
void blockLegacyAPI() {
blockLegacyAPI = true;
}
void checkIfLegacyAPIBlocked() {
if (!blockLegacyAPI) return;
throw new IllegalStateException("Cannot add com.apple.eawt.ApplicationListener after installing an app event handler");
}
void addLegacyAppListener(final ApplicationListener listener) {
checkIfLegacyAPIBlocked();
if (!initializedParentDispatchers) {
final _AppMenuBarHandler menuBarHandler = Application.getApplication().menuBarHandler;
final boolean prefsMenuAlreadyExplicitlySet = menuBarHandler.prefsMenuItemExplicitlySet;
parent.aboutDispatcher.setHandler(this);
parent.preferencesDispatcher.setHandler(this);
if (!prefsMenuAlreadyExplicitlySet) {
menuBarHandler.setPreferencesMenuItemVisible(false); // default behavior is not to have a preferences item
}
parent.openAppDispatcher.setHandler(this);
parent.reOpenAppDispatcher.addListener(this);
parent.openFilesDispatcher.setHandler(this);
parent.printFilesDispatcher.setHandler(this);
parent.quitDispatcher.setHandler(this);
initializedParentDispatchers = true;
}
synchronized (legacyAppListeners) {
legacyAppListeners.addElement(listener);
}
}
public void removeLegacyAppListener(final ApplicationListener listener) {
checkIfLegacyAPIBlocked();
synchronized (legacyAppListeners) {
legacyAppListeners.removeElement(listener);
}
}
@Override
public void handleAbout(final AboutEvent e) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleAbout(ae);
}
});
if (ae.isHandled()) return;
parent.openCocoaAboutWindow();
}
@Override
public void handlePreferences(final PreferencesEvent e) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handlePreferences(ae);
}
});
}
@Override
public void handleOpenApp() {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleOpenApplication(ae);
}
});
}
@Override
public void appReOpened(final AppReOpenedEvent e) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleReOpenApplication(ae);
}
});
}
@Override
public void openFiles(final OpenFilesEvent e) {
final List<File> files = e.getFiles();
for (final File file : files) { // legacy ApplicationListeners only understood one file at a time
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleOpenFile(ae);
}
});
}
}
@Override
public void printFiles(PrintFilesEvent e) {
final List<File> files = e.getFiles();
for (final File file : files) { // legacy ApplicationListeners only understood one file at a time
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit(), file.getAbsolutePath());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handlePrintFile(ae);
}
});
}
}
@Override
public void handleQuitRequestWith(final QuitEvent e, final QuitResponse response) {
final ApplicationEvent ae = new ApplicationEvent(Toolkit.getDefaultToolkit());
sendEventToEachListenerUntilHandled(ae, new EventDispatcher() {
public void dispatchEvent(final ApplicationListener listener) {
listener.handleQuit(ae);
}
});
if (ae.isHandled()) {
parent.performQuit();
} else {
parent.cancelQuit();
}
}
interface EventDispatcher {
void dispatchEvent(final ApplicationListener listener);
}
// helper that cycles through the loop and aborts if the event is handled, or there are no listeners
void sendEventToEachListenerUntilHandled(final ApplicationEvent event, final EventDispatcher dispatcher) {
synchronized (legacyAppListeners) {
if (legacyAppListeners.size() == 0) return;
final Enumeration<ApplicationListener> e = legacyAppListeners.elements();
while (e.hasMoreElements() && !event.isHandled()) {
dispatcher.dispatchEvent(e.nextElement());
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,20 @@
package com.apple.eawt;
import java.awt.Container;
import java.awt.Frame;
import java.awt.peer.MenuComponentPeer;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenuBar;
import javax.swing.plaf.MenuBarUI;
import com.apple.laf.ScreenMenuBar;
import sun.awt.AWTAccessor;
import sun.lwawt.macosx.CMenuBar;
import com.apple.laf.AquaMenuBarUI;
import sun.awt.AWTAccessor;
class _AppMenuBarHandler {
private static final int MENU_ABOUT = 1;
@@ -43,14 +46,20 @@ class _AppMenuBarHandler {
private static native void nativeSetMenuState(final int menu, final boolean visible, final boolean enabled);
private static native void nativeSetDefaultMenuBar(final long menuBarPeer);
private static native void nativeActivateDefaultMenuBar(final long menuBarPeer);
static final _AppMenuBarHandler instance = new _AppMenuBarHandler();
static _AppMenuBarHandler getInstance() {
return instance;
}
private static ScreenMenuBar defaultMenuBar;
// callback from the native delegate -init function
private static void initMenuStates(final boolean aboutMenuItemVisible, final boolean aboutMenuItemEnabled, final boolean prefsMenuItemVisible, final boolean prefsMenuItemEnabled) {
private static void initMenuStates(final boolean aboutMenuItemVisible,
final boolean aboutMenuItemEnabled,
final boolean prefsMenuItemVisible,
final boolean prefsMenuItemEnabled) {
synchronized (instance) {
instance.aboutMenuItemVisible = aboutMenuItemVisible;
instance.aboutMenuItemEnabled = aboutMenuItemEnabled;
@@ -70,41 +79,45 @@ class _AppMenuBarHandler {
void setDefaultMenuBar(final JMenuBar menuBar) {
installDefaultMenuBar(menuBar);
}
static boolean isMenuBarActivationNeeded() {
// scan the current frames, and see if any are foreground
final Frame[] frames = Frame.getFrames();
for (final Frame frame : frames) {
if (frame.isVisible() && !isFrameMinimized(frame)) {
return;
return false;
}
}
// if we have no foreground frames, then we have to "kick" the menubar
final JFrame pingFrame = new JFrame();
pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
pingFrame.setUndecorated(true);
pingFrame.setVisible(true);
pingFrame.toFront();
pingFrame.setVisible(false);
pingFrame.dispose();
return true;
}
static boolean isFrameMinimized(final Frame frame) {
return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
}
@SuppressWarnings("deprecation")
static void installDefaultMenuBar(final JMenuBar menuBar) {
if (menuBar == null) {
// intentionally clearing the default menu
if (defaultMenuBar != null) {
defaultMenuBar.removeNotify();
defaultMenuBar = null;
}
nativeSetDefaultMenuBar(0);
return;
}
final MenuBarUI ui = menuBar.getUI();
Container parent = menuBar.getParent();
if (parent instanceof JLayeredPane) {
((JLayeredPane) parent).remove(menuBar);
}
MenuBarUI ui = menuBar.getUI();
if (!(ui instanceof AquaMenuBarUI)) {
// Aqua was not installed
throw new IllegalStateException("Application.setDefaultMenuBar() only works with the Aqua Look and Feel");
ui = new AquaMenuBarUI();
menuBar.setUI(ui);
}
final AquaMenuBarUI aquaUI = (AquaMenuBarUI)ui;
@@ -114,7 +127,14 @@ class _AppMenuBarHandler {
throw new IllegalStateException("Application.setDefaultMenuBar() only works if apple.laf.useScreenMenuBar=true");
}
screenMenuBar.addNotify();
if (screenMenuBar != defaultMenuBar) {
if (defaultMenuBar != null) {
defaultMenuBar.removeNotify();
}
defaultMenuBar = screenMenuBar;
screenMenuBar.addNotify();
}
final Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(screenMenuBar);
if (!(peer instanceof CMenuBar)) {
// such a thing should not be possible
@@ -123,6 +143,11 @@ class _AppMenuBarHandler {
// grab the pointer to the CMenuBar, and retain it in native
((CMenuBar) peer).execute(_AppMenuBarHandler::nativeSetDefaultMenuBar);
// if there is no currently active frame, install the default menu bar in the application main menu
if (isMenuBarActivationNeeded()) {
((CMenuBar) peer).execute(_AppMenuBarHandler::nativeActivateDefaultMenuBar);
}
}
void setAboutMenuItemVisible(final boolean present) {

View File

@@ -26,6 +26,8 @@
package com.apple.eawt;
class _AppMiscHandlers {
private static boolean isSuddenTerminationEnabled;
private static native void nativeOpenHelpViewer();
private static native void nativeRequestActivation(final boolean allWindows);
@@ -47,10 +49,16 @@ class _AppMiscHandlers {
}
static void enableSuddenTermination() {
isSuddenTerminationEnabled = true;
nativeEnableSuddenTermination();
}
static void disableSuddenTermination() {
isSuddenTerminationEnabled = false;
nativeDisableSuddenTermination();
}
public static boolean isSuddenTerminationEnbaled() {
return isSuddenTerminationEnabled;
}
}

View File

@@ -27,4 +27,4 @@ package com.apple.eawt;
interface _OpenAppHandler {
void handleOpenApp();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@ package com.apple.eawt.event;
* Abstract adapter class for receiving gesture events. This class is provided
* as a convenience for creating listeners.
*
* Subclasses registered with {@link GestureUtilities#addGestureListenerTo()}
* Subclasses registered with {@link GestureUtilities#addGestureListenerTo}
* will receive all phase, magnification, rotation, and swipe events.
*
* @see GestureUtilities

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package com.apple.eawt.event;
import java.awt.*;
import java.awt.event.InputEvent;
/**
* Abstract event all gestures inherit from.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,13 +39,13 @@ package com.apple.eawt.event;
public interface GesturePhaseListener extends GestureListener {
/**
* Invoked when the user has started a continuous gesture.
* @param event representing the start of a continuous gesture.
* @param e representing the start of a continuous gesture.
*/
public void gestureBegan(final GesturePhaseEvent e);
/**
* Invoked when the user has stopped a continuous gesture.
* @param event representing the end of a continuous gesture.
* @param e representing the end of a continuous gesture.
*/
public void gestureEnded(final GesturePhaseEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,15 @@
package com.apple.eawt.event;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JRootPane;
/**
* Registration utility class to add {@link GestureListener}s to Swing components.
*
* This class manages the relationship between {@link JComponent}s and the {@link GestureListener}s
* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}
* class which adds additional functionality to AWT Windows, without adding new API to the
* attached to them. It adds additional functionality to AWT Windows, without adding new API to the
* {@link java.awt.Window} class.
*
* To add a {@link GestureListener} to a top-level Swing window, use the {@link JRootPane} of the
@@ -40,7 +41,6 @@ import javax.swing.*;
*
* @see GestureAdapter
* @see JFrame#getRootPane()
* @see com.sun.awt.AWTUtilities
*
* @since Java for Mac OS X 10.5 Update 7, Java for Mac OS X 10.6 Update 2
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@ package com.apple.eawt.event;
public interface MagnificationListener extends GestureListener {
/**
* Invoked when a magnification gesture is performed by the user.
* @param event containing the scale of the magnification.
* @param e containing the scale of the magnification.
*/
public void magnify(final MagnificationEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@ package com.apple.eawt.event;
public interface RotationListener extends GestureListener {
/**
* Invoked when a rotation gesture is performed by the user.
* @param event containing an abstract measure of rotation.
* @param e containing an abstract measure of rotation.
*/
public void rotate(final RotationEvent e);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,25 +38,25 @@ package com.apple.eawt.event;
public interface SwipeListener extends GestureListener {
/**
* Invoked when an upwards swipe gesture is performed by the user.
* @param event representing the occurrence of a swipe.
* @param e representing the occurrence of a swipe.
*/
public void swipedUp(final SwipeEvent e);
/**
* Invoked when a downward swipe gesture is performed by the user.
* @param event representing the occurrence of a swipe.
* @param e representing the occurrence of a swipe.
*/
public void swipedDown(final SwipeEvent e);
/**
* Invoked when a leftward swipe gesture is performed by the user.
* @param event representing the occurrence of a swipe.
* @param e representing the occurrence of a swipe.
*/
public void swipedLeft(final SwipeEvent e);
/**
* Invoked when a rightward swipe gesture is performed by the user.
* @param event representing the occurrence of a swipe.
* @param e representing the occurrence of a swipe.
*/
public void swipedRight(final SwipeEvent e);
}

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body bgcolor="white">
Classes for receiving gesture events.
Provides a mechanism to receive various gesture events on JComponents. Gesture notifications are relayed up the component hierarchy from the deepest component under the cursor to the top-level container. Events may be consumed by deeper components to prevent them from propagating to higher components.
Gesture listeners are added to components using the GestureUtilities helper class.
</body>
</html>

View File

@@ -1,10 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body bgcolor="white">
Provides classes for integrating Java applications with the native application environment.
These classes provide a simple way to implement native features to fine tune Java applications on Mac OS X. These listeners and handlers can help make Java applications behaviors and user interface indistinguishable from native applications. For further information on the Mac OS X user interface, consult the <a target=_blank href="http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines"> Aqua Human Interface Guidelines</a>.</body>
</html>

View File

@@ -100,6 +100,17 @@ final class ScreenMenuItem extends MenuItem
fMenuItem.removeComponentListener(this);
}
static void syncAcceleratorText(MenuItem menuItem, JMenuItem fMenuItem) {
Object acceleratorText = fMenuItem.getClientProperty("accelerator.text");
if (acceleratorText instanceof String) {
Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(menuItem);
if (peer instanceof CMenuItem) {
final CMenuItem cmi = (CMenuItem) peer;
cmi.setAcceleratorText((String)acceleratorText);
}
}
}
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
Object peer = AWTAccessor.getMenuComponentAccessor().getPeer(menuItem);
if (!(peer instanceof CMenuItem)) {
@@ -123,6 +134,12 @@ final class ScreenMenuItem extends MenuItem
@Override
public void setAccelerator(final KeyStroke ks) {
syncLabelAndKS(this, fMenuItem.getText(), ks);
syncAcceleratorText(this, fMenuItem);
}
@Override
public void setAcceleratorText(String acceleratorText) {
syncAcceleratorText(this, fMenuItem);
}
public void actionPerformed(final ActionEvent e) {

View File

@@ -123,6 +123,12 @@ final class ScreenMenuItemCheckbox extends CheckboxMenuItem
@Override
public void setAccelerator(final KeyStroke ks) {
ScreenMenuItem.syncLabelAndKS(this, fMenuItem.getText(), ks);
ScreenMenuItem.syncAcceleratorText(this, fMenuItem);
}
@Override
public void setAcceleratorText(String acceleratorText) {
ScreenMenuItem.syncAcceleratorText(this, fMenuItem);
}
public void actionPerformed(final ActionEvent e) {

View File

@@ -36,6 +36,7 @@ interface ScreenMenuPropertyHandler {
public void setLabel(String f);
public void setIcon(Icon icon);
public void setAccelerator(KeyStroke ks);
default void setAcceleratorText(String acceleratorText) {}
public void setToolTipText(String tooltip);
public void setChildVisible(javax.swing.JMenuItem child, boolean b);
public void setIndeterminate(boolean indeterminate);

View File

@@ -67,6 +67,11 @@ class ScreenMenuPropertyListener implements PropertyChangeListener {
return;
}
if ("accelerator.text".equals(propertyName)) {
fMenu.setAcceleratorText((String)e.getNewValue());
return;
}
if (AbstractButton.TEXT_CHANGED_PROPERTY.equals(propertyName)) {
fMenu.setLabel((String)e.getNewValue());
return;

View File

@@ -189,7 +189,10 @@ public final class CFont extends PhysicalFont implements FontSubstitution, FontW
protected synchronized long getNativeFontPtr() {
if (nativeFontPtr == 0L) {
nativeFontPtr = createNativeFont(nativeFontName, style);
/* Do not try to create native italic font when isFakeItalic
* is true, otherwise we can make it italic twice */
nativeFontPtr = createNativeFont(nativeFontName, style &
(isFakeItalic ? ~Font.ITALIC : -1));
}
return nativeFontPtr;
}

View File

@@ -40,7 +40,9 @@ public final class CStrike extends PhysicalStrike {
double[] glyphTx,
double[] invDevTxMatrix,
int aaHint,
int fmHint);
int fmHint,
int subpixelResolutionX,
int subpixelResolutionY);
// Disposes the native strike
private static native void disposeNativeStrikePtr(long nativeStrikePtr);
@@ -127,7 +129,9 @@ public final class CStrike extends PhysicalStrike {
}
nativeStrikePtr =
createNativeStrikePtr(nativeFont.getNativeFontPtr(),
glyphTx, invDevTxMatrix, aaHint, fmHint);
glyphTx, invDevTxMatrix, aaHint, fmHint,
FontUtilities.supplementarySubpixelGlyphResolution.width,
FontUtilities.supplementarySubpixelGlyphResolution.height);
}
return nativeStrikePtr;

View File

@@ -234,6 +234,7 @@ public class LWWindowPeer
setOpaque(getTarget().isOpaque());
updateInsets(platformWindow.getInsets());
if (getSurfaceData() == null) {
replaceSurfaceData(false);
}
@@ -310,7 +311,6 @@ public class LWWindowPeer
}
}
}
updateInsets(platformWindow.getInsets());
}
@Override

View File

@@ -467,7 +467,7 @@ class CAccessibility implements PropertyChangeListener {
}, c);
}
public static void requestSelection(final Accessible a, final Component c) {
public static void requestSelection(final Accessible a, final Component c, final boolean selected) {
if (a == null) return;
invokeLater(new Runnable() {
public void run() {
@@ -480,7 +480,15 @@ class CAccessibility implements PropertyChangeListener {
if (pac == null) return;
AccessibleSelection as = pac.getAccessibleSelection();
if (as == null) return;
as.addAccessibleSelection(i);
if (parent instanceof JList) {
((JList) parent).setSelectedIndex(i);
return;
}
if (selected) {
as.addAccessibleSelection(i);
} else {
as.removeAccessibleSelection(i);
}
}
}, c);
}

View File

@@ -76,72 +76,72 @@ final public class CDesktopPeer implements DesktopPeer {
@Override
public void addAppEventListener(SystemEventListener listener) {
//Application.getApplication().addAppEventListener(listener);
Application.getApplication().addAppEventListener(listener);
}
@Override
public void removeAppEventListener(SystemEventListener listener) {
//Application.getApplication().removeAppEventListener(listener);
Application.getApplication().removeAppEventListener(listener);
}
@Override
public void setAboutHandler(AboutHandler aboutHandler) {
// Application.getApplication().setAboutHandler(aboutHandler);
Application.getApplication().setAboutHandler(aboutHandler);
}
@Override
public void setPreferencesHandler(PreferencesHandler preferencesHandler) {
// Application.getApplication().setPreferencesHandler(preferencesHandler);
Application.getApplication().setPreferencesHandler(preferencesHandler);
}
@Override
public void setOpenFileHandler(OpenFilesHandler openFileHandler) {
// Application.getApplication().setOpenFileHandler(openFileHandler);
Application.getApplication().setOpenFileHandler(openFileHandler);
}
@Override
public void setPrintFileHandler(PrintFilesHandler printFileHandler) {
// Application.getApplication().setPrintFileHandler(printFileHandler);
Application.getApplication().setPrintFileHandler(printFileHandler);
}
@Override
public void setOpenURIHandler(OpenURIHandler openURIHandler) {
// Application.getApplication().setOpenURIHandler(openURIHandler);
Application.getApplication().setOpenURIHandler(openURIHandler);
}
@Override
public void setQuitHandler(QuitHandler quitHandler) {
// Application.getApplication().setQuitHandler(quitHandler);
Application.getApplication().setQuitHandler(quitHandler);
}
@Override
public void setQuitStrategy(QuitStrategy strategy) {
// Application.getApplication().setQuitStrategy(strategy);
Application.getApplication().setQuitStrategy(strategy);
}
@Override
public void enableSuddenTermination() {
// Application.getApplication().enableSuddenTermination();
Application.getApplication().enableSuddenTermination();
}
@Override
public void disableSuddenTermination() {
// Application.getApplication().disableSuddenTermination();
Application.getApplication().disableSuddenTermination();
}
@Override
public void requestForeground(boolean allWindows) {
// Application.getApplication().requestForeground(allWindows);
Application.getApplication().requestForeground(allWindows);
}
@Override
public void openHelpViewer() {
// Application.getApplication().openHelpViewer();
Application.getApplication().openHelpViewer();
}
@Override
public void setDefaultMenuBar(JMenuBar menuBar) {
// Application.getApplication().setDefaultMenuBar(menuBar);
Application.getApplication().setDefaultMenuBar(menuBar);
}
@Override

View File

@@ -100,8 +100,12 @@ public class CEmbeddedFrame extends EmbeddedFrame {
deltaY, NSEvent.SCROLL_PHASE_UNSUPPORTED);
}
public void handleKeyEvent(NSEvent nsEvent) {
responder.handleKeyEvent(nsEvent);
public void handleKeyEvent(int eventType, int modifierFlags, String characters,
String charsIgnoringMods, boolean isRepeat, short keyCode,
boolean needsKeyTyped) {
responder.handleKeyEvent(eventType, modifierFlags, characters,
charsIgnoringMods, /*charsIgnoringModifiersAndShift*/ null,
keyCode, needsKeyTyped, isRepeat);
}
public void handleInputEvent(String text) {

View File

@@ -104,6 +104,10 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer {
setLabel(label, (char)0, KeyEvent.VK_UNDEFINED, 0);
}
public void setAcceleratorText(String acceleratorText) {
execute(ptr -> nativeSetAcceleratorText(ptr, acceleratorText));
}
/**
* This is new API that we've added to AWT menu items
* because AWT menu items are used for Swing screen menu bars
@@ -150,6 +154,7 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer {
private native void nativeSetImage(long modelPtr, long image);
private native void nativeSetTooltip(long modelPtr, String text);
private native void nativeSetEnabled(long modelPtr, boolean b);
private native void nativeSetAcceleratorText(long modelPtr, String acceleratorText);
// native callbacks
void handleAction(final long when, final int modifiers) {

View File

@@ -29,24 +29,20 @@ import sun.awt.SunToolkit;
import sun.awt.event.KeyEventProcessing;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformEventNotifier;
import sun.util.logging.PlatformLogger;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.InputEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.KeyEvent;
import java.security.PrivilegedAction;
import java.util.Arrays;
import java.util.Locale;import java.util.MissingResourceException;import java.util.ResourceBundle;
import java.util.Locale;
/**
* Translates NSEvents/NPCocoaEvents into AWT events.
*/
final class CPlatformResponder {
private static final PlatformLogger keyboardLog = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformResponder");
private final PlatformEventNotifier eventNotifier;
private final boolean isNpapiCallback;
private int lastKeyPressCode = KeyEvent.VK_UNDEFINED;
@@ -61,7 +57,6 @@ final class CPlatformResponder {
private int lastDraggedRelativeX;
private int lastDraggedRelativeY;
CPlatformResponder(final PlatformEventNotifier eventNotifier,
final boolean isNpapiCallback) {
this.eventNotifier = eventNotifier;
@@ -166,41 +161,6 @@ final class CPlatformResponder {
-roundDelta, -delta, null);
}
private void handleFlagChangedEvent(int modifierFlags, short keyCode) {
int[] in = new int[] {modifierFlags, keyCode};
int[] out = new int[3]; // [jkeyCode, jkeyLocation, jkeyType]
NSEvent.nsKeyModifiersToJavaKeyInfo(in, out);
int jkeyCode = out[0];
int jkeyLocation = out[1];
int jeventType = out[2];
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
long when = System.currentTimeMillis();
if (jeventType == KeyEvent.KEY_PRESSED) {
lastKeyPressCode = jkeyCode;
}
eventNotifier.notifyKeyEvent(jeventType, when, jmodifiers,
jkeyCode, KeyEvent.CHAR_UNDEFINED, jkeyLocation);
}
private static char mapNsCharsToCompatibleWithJava (char ch) {
switch (ch) {
case 0x0003: // NSEnterCharacter
case 0x000d: // NSCarriageReturnCharacter
return 0x000a; // NSNewlineCharacter
// case 0x007f: // NSDeleteCharacter
// return 0x0008; // NSBackspaceCharacter
case 0xF728: // NSDeleteFunctionKey
return 0x0008; // NSDeleteCharacter
case 0x0019: // NSBackTabCharacter
return 0x0009; // NSTabCharacter
}
return ch;
}
private static final String [] cyrillicKeyboardLayouts = new String [] {
"com.apple.keylayout.Russian",
"com.apple.keylayout.RussianWin",
@@ -216,181 +176,6 @@ final class CPlatformResponder {
return Arrays.stream(cyrillicKeyboardLayouts).anyMatch(l -> l.equals(LWCToolkit.getKeyboardLayoutId()));
}
/**
* Handles key events.
*/
void handleKeyEvent(NSEvent nsEvent)
{
if (!KeyEventProcessing.useNationalLayouts || isCyrillicKeyboardLayout()) {
handleKeyEvent(
nsEvent.getType(),
nsEvent.getModifierFlags(),
nsEvent.getOldCharacters(),
nsEvent.getOldCharactersIgnoringModifiers(),
nsEvent.getKeyCode(),
true,
false
);
return;
}
boolean isFlagsChangedEvent =
isNpapiCallback ? (nsEvent.getType() == CocoaConstants.NPCocoaEventFlagsChanged) :
(nsEvent.getType() == CocoaConstants.NSFlagsChanged);
int jeventType = KeyEvent.KEY_PRESSED;
int jkeyCode = KeyEvent.VK_UNDEFINED;
int jkeyLocation = KeyEvent.KEY_LOCATION_UNKNOWN;
boolean postsTyped = false;
boolean spaceKeyTyped = false;
if (isFlagsChangedEvent) {
handleFlagChangedEvent(nsEvent.getModifierFlags(), nsEvent.getKeyCode());
return;
}
int jmodifiers = NSEvent.nsToJavaModifiers(nsEvent.getModifierFlags());
boolean metaAltCtrlAreNotPressed = (jmodifiers &
(InputEvent.META_DOWN_MASK
| InputEvent.ALT_DOWN_MASK
| InputEvent.CTRL_DOWN_MASK)
) == 0;
boolean shiftIsPressed = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
boolean useShiftedCharacters = metaAltCtrlAreNotPressed && shiftIsPressed;
boolean shiftAltDownAreNotPressed = (jmodifiers &
(InputEvent.META_DOWN_MASK
| InputEvent.ALT_DOWN_MASK
| InputEvent.SHIFT_DOWN_MASK)
) == 0;
boolean ctrlIsPressed = (jmodifiers & InputEvent.CTRL_DOWN_MASK) != 0;
boolean isISOControl = false;
char checkedChar = (nsEvent.getCharacters() == null
|| nsEvent.getCharacters().isEmpty()) ? KeyEvent.CHAR_UNDEFINED : nsEvent.getCharacters().charAt(0);
if (shiftAltDownAreNotPressed && ctrlIsPressed) {
if (Character.isISOControl(checkedChar)) {
isISOControl = true;
}
}
char characterToGetKeyCode = KeyEvent.CHAR_UNDEFINED;
boolean charactersIgnoringModifiersIsValid = (nsEvent.getCharactersIgnoringModifiers() != null && nsEvent.getCharactersIgnoringModifiers().length() > 0);
boolean charactersIsValid = (nsEvent.getCharacters() != null && nsEvent.getCharacters().length() > 0);
// We use this char to find a character that is printed depending on pressing modifiers
characterToGetKeyCode = charactersIgnoringModifiersIsValid
? nsEvent.getCharactersIgnoringModifiers().charAt(0)
: charactersIsValid ? nsEvent.getCharacters().charAt(0) : KeyEvent.CHAR_UNDEFINED;
if (useShiftedCharacters && nsEvent.getCharactersIgnoringModifiers() != null && !nsEvent.getCharactersIgnoringModifiers().isEmpty()) {
characterToGetKeyCode = nsEvent.getCharactersIgnoringModifiers().charAt(0);
} else if (nsEvent.getCharactersIgnoringModifiersAndShift() != null && !nsEvent.getCharactersIgnoringModifiersAndShift().isEmpty()) {
characterToGetKeyCode = nsEvent.getCharactersIgnoringModifiersAndShift().charAt(0);
} else if (nsEvent.getCharacters() != null && !nsEvent.getCharacters().isEmpty() && metaAltCtrlAreNotPressed && shiftIsPressed) {
characterToGetKeyCode = checkedChar;
}
// We use char candidate if modifiers are not used
// otherwise, we use char ignoring modifiers
int[] in = new int[] {
characterToGetKeyCode,
nsEvent.isHasDeadKey() ? 1 : 0,
nsEvent.getModifierFlags(),
nsEvent.getKeyCode(),
/*useNationalLayouts*/ 1
};
int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar]
postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
char characterToSendWithTheEvent = characterToGetKeyCode;
if(nsEvent.isHasDeadKey()){
characterToSendWithTheEvent = (char) out[2];
jkeyCode = nsEvent.getDeadKeyCode();
if(characterToSendWithTheEvent == 0){
return;
}
}
// If Pinyin Simplified input method is selected, CAPS_LOCK key is supposed to switch
// input to la tin letters.
// It is necessary to use charIgnoringModifiers instead of charCandidate for event
// generation in such case to avoid uppercase letters in text components.
LWCToolkit lwcToolkit = (LWCToolkit)Toolkit.getDefaultToolkit();
if (lwcToolkit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK) &&
Locale.SIMPLIFIED_CHINESE.equals(lwcToolkit.getDefaultKeyboardLocale())) {
characterToSendWithTheEvent = characterToGetKeyCode;
}
jkeyCode = out[0];
jkeyLocation = out[1];
jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(nsEvent.getType()) :
NSEvent.nsToJavaEventType(nsEvent.getType());
if (isISOControl) {
characterToSendWithTheEvent = checkedChar;
} else {
characterToSendWithTheEvent = mapNsCharsToCompatibleWithJava(characterToSendWithTheEvent);
}
String stringWithChar = NSEvent.nsToJavaChar(characterToSendWithTheEvent, nsEvent.getModifierFlags(), spaceKeyTyped);
characterToSendWithTheEvent = stringWithChar == null ? KeyEvent.CHAR_UNDEFINED : stringWithChar.charAt(0);
long when = System.currentTimeMillis();
if (jeventType == KeyEvent.KEY_PRESSED) {
lastKeyPressCode = jkeyCode;
}
eventNotifier.notifyKeyEvent(jeventType, when, jmodifiers,
jkeyCode, characterToSendWithTheEvent, jkeyLocation);
// Current browser may be sending input events, so don't
// post the KEY_TYPED here.
postsTyped &= true;
// That's the reaction on the PRESSED (not RELEASED) event as it comes to
// appear in MacOSX.
// Modifier keys (shift, etc) don't want to send TYPED events.
// On the other hand we don't want to generate keyTyped events
// for clipboard related shortcuts like Meta + [CVX]
if (jeventType == KeyEvent.KEY_PRESSED && postsTyped &&
(jmodifiers & KeyEvent.META_DOWN_MASK) == 0) {
char characterToSendWithTypedEvent = KeyEvent.CHAR_UNDEFINED;
if (nsEvent.getCharacters()!= null ) {
characterToSendWithTypedEvent = mapNsCharsToCompatibleWithJava(checkedChar);
stringWithChar = NSEvent.nsToJavaChar(characterToSendWithTypedEvent, nsEvent.getModifierFlags(), spaceKeyTyped);
characterToSendWithTypedEvent = stringWithChar == null ? KeyEvent.CHAR_UNDEFINED : stringWithChar.charAt(0);
}
boolean nonInputMethodsModifiersAreNotPressed = (jmodifiers &
(InputEvent.META_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)
) == 0;
if (nonInputMethodsModifiersAreNotPressed) {
eventNotifier.notifyKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
jkeyCode, characterToSendWithTypedEvent,
KeyEvent.KEY_LOCATION_UNKNOWN);
}
}
}
void handleInputEvent(String text) {
if (text != null) {
int index = 0, length = text.length();
@@ -412,10 +197,9 @@ final class CPlatformResponder {
/**
* Handles key events.
* @deprecated
*/
@Deprecated
void handleKeyEvent(int eventType, int modifierFlags, String chars, String charsIgnoringModifiers,
void handleKeyEvent(int eventType, int modifierFlags, String chars,
String charsIgnoringModifiers, String charsIgnoringModifiersAndShift,
short keyCode, boolean needsKeyTyped, boolean needsKeyReleased) {
boolean isFlagsChangedEvent =
isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
@@ -425,6 +209,9 @@ final class CPlatformResponder {
int jkeyCode = KeyEvent.VK_UNDEFINED;
int jkeyLocation = KeyEvent.KEY_LOCATION_UNKNOWN;
boolean postsTyped = false;
boolean spaceKeyTyped = false;
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
char testChar = KeyEvent.CHAR_UNDEFINED;
boolean isDeadChar = (chars!= null && chars.length() == 0);
@@ -441,12 +228,26 @@ final class CPlatformResponder {
} else {
if (chars != null && chars.length() > 0) {
testChar = chars.charAt(0);
//Check if String chars contains SPACE character.
if (chars.trim().isEmpty()) {
spaceKeyTyped = true;
}
}
// Workaround for JBR-2981
int metaAltCtrlMods = KeyEvent.META_DOWN_MASK | KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK;
boolean metaAltCtrlAreNotPressed = (jmodifiers & metaAltCtrlMods) == 0;
boolean useShiftedCharacter = ((jmodifiers & KeyEvent.SHIFT_DOWN_MASK) == KeyEvent.SHIFT_DOWN_MASK) && metaAltCtrlAreNotPressed;
char testCharIgnoringModifiers = charsIgnoringModifiers != null && charsIgnoringModifiers.length() > 0 ?
charsIgnoringModifiers.charAt(0) : KeyEvent.CHAR_UNDEFINED;
if (!useShiftedCharacter && charsIgnoringModifiersAndShift != null && charsIgnoringModifiersAndShift.length() > 0) {
testCharIgnoringModifiers = charsIgnoringModifiersAndShift.charAt(0);
}
int[] in = new int[] {testCharIgnoringModifiers, isDeadChar ? 1 : 0, modifierFlags, keyCode, /*useNationalLayouts*/ 0};
int useNationalLayouts = (!KeyEventProcessing.useNationalLayouts || isCyrillicKeyboardLayout()) ? 0 : 1;
int[] in = new int[] {testCharIgnoringModifiers, isDeadChar ? 1 : 0, modifierFlags, keyCode, useNationalLayouts};
int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar]
postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
@@ -480,7 +281,7 @@ final class CPlatformResponder {
NSEvent.nsToJavaEventType(eventType);
}
char javaChar = NSEvent.nsToJavaCharOld(testChar, modifierFlags);
char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags, spaceKeyTyped);
// Some keys may generate a KEY_TYPED, but we can't determine
// what that character is. That's likely a bug, but for now we
// just check for CHAR_UNDEFINED.
@@ -488,8 +289,6 @@ final class CPlatformResponder {
postsTyped = false;
}
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
long when = System.currentTimeMillis();
if (jeventType == KeyEvent.KEY_PRESSED) {

View File

@@ -220,8 +220,10 @@ public class CPlatformView extends CFRetainedResource {
}
}
private void deliverKeyEvent(NSEvent nsEvent) {
responder.handleKeyEvent(nsEvent);
private void deliverKeyEvent(NSEvent event) {
responder.handleKeyEvent(event.getType(), event.getModifierFlags(), event.getCharacters(),
event.getCharactersIgnoringModifiers(), event.getCharactersIgnoringModifiersAndShift(),
event.getKeyCode(), true, false);
}
/**

View File

@@ -89,7 +89,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
private static native void nativeSetNSWindowStyleBits(long nsWindowPtr, int mask, int data);
private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr);
private static native Insets nativeGetNSWindowInsets(long nsWindowPtr);
private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h, boolean wait);
private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h);
private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr);
private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr,
double x, double y, double w, double h);
@@ -683,7 +683,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
@Override // PlatformWindow
public void setBounds(int x, int y, int w, int h) {
execute(ptr -> AWTThreading.executeWaitToolkit(wait -> nativeSetNSWindowBounds(ptr, x, y, w, h, wait)));
execute(ptr -> nativeSetNSWindowBounds(ptr, x, y, w, h));
}
public void setMaximizedBounds(int x, int y, int w, int h) {
@@ -745,6 +745,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
execute(CPlatformWindow::nativeSetNSWindowLocationByPlatform);
}
this.visible = visible;
// Actually show or hide the window
LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
if (blocker == null || !visible) {
@@ -796,7 +798,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
});
});
}
this.visible = visible;
// Manage the extended state when showing
if (visible) {

View File

@@ -52,7 +52,7 @@ final public class CTaskbarPeer implements TaskbarPeer {
@Override
public void setProgressValue(int value) {
//Application.getApplication().setDockIconProgress(value);
Application.getApplication().setDockIconProgress(value);
}
@Override

View File

@@ -298,8 +298,7 @@ final class NSEvent {
* There is a small number of NS characters that need to be converted
* into other characters before we pass them to AWT.
*/
static native String nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped);
static native char nsToJavaCharOld(char nsChar, int modifierFlags);
static native char nsToJavaChar(char nsChar, int modifierFlags, boolean spaceKeyTyped);
static boolean isPopupTrigger(int jmodifiers) {
final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);

View File

@@ -222,6 +222,7 @@ struct CharToVKEntry {
static const struct CharToVKEntry charToDeadVKTable[] = {
{0x0060, java_awt_event_KeyEvent_VK_DEAD_GRAVE},
{0x00B4, java_awt_event_KeyEvent_VK_DEAD_ACUTE},
{0xFFFF, java_awt_event_KeyEvent_VK_DEAD_ACUTE},
{0x0384, java_awt_event_KeyEvent_VK_DEAD_ACUTE}, // Unicode "GREEK TONOS" -- Greek keyboard, semicolon key
{0x005E, java_awt_event_KeyEvent_VK_DEAD_CIRCUMFLEX},
{0x007E, java_awt_event_KeyEvent_VK_DEAD_TILDE},
@@ -887,42 +888,20 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_NSEvent
* Method: nsToJavaChar
* Signature: (CI)Ljava/lang/String
*/
JNIEXPORT jstring JNICALL
Java_sun_lwawt_macosx_NSEvent_nsToJavaChar
(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags, jboolean spaceKeyTyped)
{
jstring charAsString = NULL;
JNF_COCOA_ENTER(env);
NSString * nsStr = [NSString stringWithFormat: @"%C", nsChar];
charAsString = JNFNSToJavaString(env, nsStr);
JNF_COCOA_EXIT(env);
return charAsString;
}
/*
* Class: sun_lwawt_macosx_NSEvent
* Method: nsToJavaChar
* Signature: (CI)C
*/
JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_NSEvent_nsToJavaCharOld
(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags)
Java_sun_lwawt_macosx_NSEvent_nsToJavaChar
(JNIEnv *env, jclass cls, jchar nsChar, jint modifierFlags, jboolean spaceKeyTyped)
{
jchar javaChar = 0;
JNF_COCOA_ENTER(env);
javaChar = NsCharToJavaChar(nsChar, modifierFlags, false);
javaChar = NsCharToJavaChar(nsChar, modifierFlags, spaceKeyTyped);
JNF_COCOA_EXIT(env);

View File

@@ -34,7 +34,7 @@
#import "AWTView.h"
#import "AWTWindow.h"
#import "JavaComponentAccessibility.h"
#import "JavaTextAccessibility.h"
#import "JavaStaticTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "GeomUtilities.h"
#import "CGLLayer.h"
@@ -374,6 +374,21 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
if (![self hasMarkedText] && !fInPressAndHold) {
[self deliverJavaKeyEventHelper: event];
}
// Workaround for 8020209: special case for "Cmd =" and "Cmd ."
// because Cocoa calls performKeyEquivalent twice for these keystrokes
NSUInteger modFlags = [event modifierFlags] &
(NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask);
if (modFlags == NSCommandKeyMask) {
NSString *eventChars = [event charactersIgnoringModifiers];
if ([eventChars length] == 1) {
unichar ch = [eventChars characterAtIndex:0];
if (ch == '=' || ch == '.' ||
ch == 0x044E) { // small cyrillic u
[[NSApp mainMenu] performKeyEquivalent: event];
return YES;
}
}
}
NSUInteger deviceIndependentModifierFlagsMask =
[event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
@@ -507,10 +522,10 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
const UCKeyboardLayout *keyboardLayout = (UCKeyboardLayout*)CFDataGetBytePtr(keyLayoutPtr);
UInt32 isDeadKeyPressed;
UInt32 isDeadKeyPressed = 0;
UInt32 lengthOfBuffer = 8;
UniChar stringWithChars[lengthOfBuffer];
UniCharCount actualLength;
UniCharCount actualLength = 0;
OSStatus status = UCKeyTranslate(
keyboardLayout,
@@ -770,7 +785,7 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
- (id)getAxData:(JNIEnv*)env
{
jobject jcomponent = [self awtComponent:env];
id ax = [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] autorelease];
id ax = [[[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] platformAxElement] autorelease];
(*env)->DeleteLocalRef(env, jcomponent);
return ax;
}
@@ -803,9 +818,9 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
return [super accessibilityAttributeValue:attribute];
}
}
- (BOOL)accessibilityIsIgnored
{
return YES;
- (BOOL)isAccessibilityElement {
return NO;
}
- (id)accessibilityHitTest:(NSPoint)point
@@ -815,7 +830,7 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
(*env)->PushLocalFrame(env, 4);
id result = [[self getAxData:env] accessibilityHitTest:point withEnv:env];
id result = [[self getAxData:env] accessibilityHitTest:point];
(*env)->PopLocalFrame(env, NULL);
@@ -843,8 +858,8 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
- (NSString *)accessibleSelectedText
{
id focused = [self accessibilityFocusedUIElement];
if (![focused isKindOfClass:[JavaTextAccessibility class]]) return nil;
return [(JavaTextAccessibility *)focused accessibilitySelectedTextAttribute];
if (![focused respondsToSelector:@selector(accessibilitySelectedText)]) return nil;
return [focused accessibilitySelectedText];
}
// same as above, but converts to RTFD
@@ -863,8 +878,8 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
- (BOOL)replaceAccessibleTextSelection:(NSString *)text
{
id focused = [self accessibilityFocusedUIElement];
if (![focused isKindOfClass:[JavaTextAccessibility class]]) return NO;
[(JavaTextAccessibility *)focused accessibilitySetSelectedTextAttribute:text];
if (![focused respondsToSelector:@selector(setAccessibilitySelectedText)]) return NO;
[focused setAccessibilitySelectedText:text];
return YES;
}

View File

@@ -49,6 +49,7 @@
BOOL isMinimizing;
NSWindowTabbingMode javaWindowTabbingMode;
BOOL isEnterFullScreen;
BOOL isJustCreated;
}
// An instance of either AWTWindow_Normal or AWTWindow_Panel
@@ -66,6 +67,7 @@
@property (nonatomic) BOOL isMinimizing;
@property (nonatomic) NSWindowTabbingMode javaWindowTabbingMode;
@property (nonatomic) BOOL isEnterFullScreen;
@property (nonatomic) BOOL isJustCreated;
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
ownerWindow:owner

View File

@@ -303,6 +303,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
@synthesize isMinimizing;
@synthesize javaWindowTabbingMode;
@synthesize isEnterFullScreen;
@synthesize isJustCreated;
- (void) updateMinMaxSize:(BOOL)resizable {
if (resizable) {
@@ -446,6 +447,7 @@ AWT_ASSERT_APPKIT_THREAD;
self.javaWindowTabbingMode = [self getJavaWindowTabbingMode];
self.isEnterFullScreen = NO;
self.isJustCreated = YES;
return self;
}
@@ -1191,6 +1193,11 @@ JNF_COCOA_ENTER(env);
nsWindow.contentView.frame = contentFrame;
resized = YES;
}
if (window.isJustCreated) {
// Perform Move/Resize event for just created windows
resized = YES;
window.isJustCreated = NO;
}
}
// resets the NSWindow's style mask if the mask intersects any of those bits
@@ -1292,10 +1299,10 @@ JNF_COCOA_EXIT(env);
/*
* Class: sun_lwawt_macosx_CPlatformWindow
* Method: nativeSetNSWindowBounds
* Signature: (JDDDDZ)V
* Signature: (JDDDD)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height, jboolean wait)
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height)
{
JNF_COCOA_ENTER(env);
@@ -1303,7 +1310,7 @@ JNF_COCOA_ENTER(env);
// TODO: not sure we need displayIfNeeded message in our view
NSWindow *nsWindow = OBJC(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:(BOOL)wait block:^(){
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
AWTWindow *window = (AWTWindow*)[nsWindow delegate];

View File

@@ -35,6 +35,7 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "CPopupMenu.h"
#import "CMenuBar.h"
#import "ThreadUtilities.h"
#import "NSApplicationAWT.h"
@@ -824,3 +825,23 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
/*
* Class: com_apple_eawt__AppMenuBarHandler
* Method: nativeActivateDefaultMenuBar
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeActivateDefaultMenuBar
(JNIEnv *env, jclass clz, jlong cMenuBarPtr)
{
JNF_COCOA_ENTER(env);
CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
if (menu) {
[CMenuBar activate:menu modallyDisabled:NO];
}
}];
JNF_COCOA_EXIT(env);
}

View File

@@ -169,44 +169,25 @@ canChooseDirectories:(BOOL)inChooseDirectories
[thePanel setAppearance:fOwner.appearance];
}
void (^onComplete)(BOOL, BOOL) = ^(BOOL responseOK, BOOL doStopModal) {
if (responseOK) {
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
fURLs = (fMode == java_awt_FileDialog_LOAD)
? [openPanel URLs]
: [NSArray arrayWithObject:[openPanel URL]];
fPanelResult = [thePanel runModal];
fPanelResult = NSFileHandlingPanelOKButton;
} else {
fURLs = [NSArray array];
}
[fURLs retain];
if (doStopModal)
[NSApp stopModal];
if (menuBar != nil) {
[CMenuBar activate:menuBar modallyDisabled:NO];
}
};
[thePanel beginSheetModalForWindow:fOwner completionHandler:^(NSInteger result) {
onComplete(result == NSFileHandlingPanelOKButton, YES);
}];
[NSApp runModalForWindow:thePanel];
if (menuBar != nil) {
[CMenuBar activate:menuBar modallyDisabled:NO];
}
}
else
{
fPanelResult = [thePanel runModalForDirectory:fDirectory file:fFile];
}
if ([self userClickedOK]) {
if (fMode == java_awt_FileDialog_LOAD) {
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
fURLs = [openPanel URLs];
} else {
fURLs = [NSArray arrayWithObject:[thePanel URL]];
}
[fURLs retain];
if ([self userClickedOK]) {
if (fMode == java_awt_FileDialog_LOAD) {
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
fURLs = [openPanel URLs];
} else {
fURLs = [NSArray arrayWithObject:[thePanel URL]];
}
[fURLs retain];
}
[thePanel setDelegate:nil];

View File

@@ -38,6 +38,277 @@
#define NOT_A_CHECKBOXMENU -2
@interface CustomMenuItemView : NSView {
int16_t fireTimes;
BOOL isSelected;
NSSize shortcutSize;
NSSize textSize;
NSTrackingArea * trackingArea;
CMenuItem * owner;
}
@property (retain) NSString * keyShortcut;
@end
@implementation CustomMenuItemView
static CGFloat menuItemHeight = 18.f;
static CGFloat marginLeft = 20.f;
static CGFloat marginRight = 10.f;
static CGFloat gapTxtIcon = 5.f;
static CGFloat gapTxtShortcut = 23.f;
static NSFont * menuFont;
static NSFont * menuShortcutFont;
static NSColor * customBg = nil;
+ (void)initialize {
menuFont = [NSFont menuBarFontOfSize:(0)];
menuShortcutFont = [NSFont menuBarFontOfSize:(0)];
NSDictionary * attributes = [NSDictionary dictionaryWithObjectsAndKeys:menuFont, NSFontAttributeName, nil];
NSSize qSize = [[[[NSAttributedString alloc] initWithString:@"Q" attributes:attributes] autorelease] size];
// use empiric proportions (to look like default view)
menuItemHeight = qSize.height * 1.1f;
marginLeft = menuItemHeight * 1.1f;
marginRight = menuItemHeight * 0.55f;
gapTxtIcon = menuItemHeight * 0.27f;
gapTxtShortcut = menuItemHeight * 1.2f;
// Initialize custom bg color (for light theme with enabled accessibility.reduceTransparency)
// If we use transparent bg than we will see visual inconsistency
// And it seems that we can't obtain this color from system
NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];
NSDictionary<NSString *,id> * dict = [defs persistentDomainForName:@"com.apple.universalaccess.plist"];
if (dict != nil) {
id reduceVal = [dict valueForKey:@"reduceTransparency"];
if (reduceVal != nil && [reduceVal isKindOfClass:[NSNumber class]] && [reduceVal intValue] != 0) {
NSString * mode = [defs stringForKey:@"AppleInterfaceStyle"];
if (mode == nil) { // light system theme
customBg = [NSColor colorWithCalibratedWhite:246.f/255 alpha:1.f];
[customBg retain];
// NSLog(@"\treduceTransparency is enabled (use custom background color for menu items)");
}
}
}
// NSLog(@"\tmenuItemHeight=%1.2f, marginLeft=%1.2f, marginRight=%1.2f, gapTxtIcon=%1.2f, gapTxtShortcut=%1.2f",
// menuItemHeight, marginLeft, marginRight, gapTxtIcon, gapTxtShortcut);
}
- (id)initWithOwner:(CMenuItem *)menuItem {
NSRect viewRect = NSMakeRect(0, 0, /* width autoresizes */ 1, menuItemHeight);
self = [super initWithFrame:viewRect];
if (self == nil) {
return self;
}
owner = menuItem;
self.autoresizingMask = NSViewWidthSizable;
self.keyShortcut = nil;
fireTimes = 0;
isSelected = NO;
trackingArea = nil;
shortcutSize = NSZeroSize;
textSize = NSZeroSize;
return self;
}
- (void)dealloc {
if(trackingArea != nil) {
[trackingArea release];
}
[super dealloc];
}
- (void)mouseEntered:(NSEvent*)event {
if ([owner isEnabled] && !isSelected) {
isSelected = YES;
[self setNeedsDisplay:YES];
}
}
- (void)mouseExited:(NSEvent *)event {
if (isSelected) {
isSelected = NO;
[self setNeedsDisplay:YES];
}
}
- (void)mouseUp:(NSEvent*)event {
if (![owner isEnabled])
return;
fireTimes = 0;
isSelected = !isSelected;
[self setNeedsDisplay:YES];
NSTimer *timer = [NSTimer timerWithTimeInterval:0.05 target:self selector:@selector(animateDismiss:) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode];
}
-(void)updateTrackingAreas {
[super updateTrackingAreas];
if(trackingArea != nil) {
[self removeTrackingArea:trackingArea];
[trackingArea release];
}
int opts = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways);
trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
options:opts
owner:self
userInfo:nil];
[self addTrackingArea:trackingArea];
}
-(void)animateDismiss:(NSTimer *)aTimer {
if (fireTimes <= 2) {
isSelected = !isSelected;
[self setNeedsDisplay:YES];
} else {
[aTimer invalidate];
[self sendAction];
}
fireTimes++;
}
- (void)sendAction {
NSMenuItem * mi = owner.menuItem;
[NSApp sendAction:[mi action] to:[mi target] from:mi];
NSMenu *menu = [mi menu];
[menu cancelTracking];
// NOTE: we can also invoke handler directly [owner handleAction:[owner menuItem]];
}
//#define VISUAL_DEBUG_CUSTOM_ITEM_VIEW
- (void) drawRect:(NSRect)dirtyRect {
NSRect rectBounds = [self bounds];
NSString * text = owner.menuItem.title;
#ifdef VISUAL_DEBUG_CUSTOM_ITEM_VIEW
[[NSColor yellowColor] set];
NSFrameRectWithWidth([self bounds], 1.0f);
#endif // VISUAL_DEBUG_CUSTOM_ITEM_VIEW
const BOOL isEnabled = [owner isEnabled];
NSColor * textColor = [NSColor textColor];
NSColor * bgColor = customBg != nil ? customBg : [NSColor clearColor];
if (!isEnabled) {
textColor = [NSColor grayColor];
} else if (isSelected) {
if (@available(macOS 10.14, *)) {
bgColor = [NSColor controlAccentColor];
} else {
bgColor = [NSColor selectedControlColor];
}
textColor = [NSColor selectedMenuItemTextColor];
}
// 1. draw bg
[bgColor set];
NSRectFill(rectBounds);
// 2. draw icon if presented
CGFloat x = rectBounds.origin.x + marginLeft;
NSImage * image = owner.menuItem.image;
if (image != nil) {
NSRect imageBounds = rectBounds;
imageBounds.origin.x = x;
imageBounds.size.width = image.size.width;
[image drawInRect:imageBounds];
x += image.size.width + gapTxtIcon;
#ifdef VISUAL_DEBUG_CUSTOM_ITEM_VIEW
[[NSColor redColor] set];
NSFrameRectWithWidth(imageBounds, 1.0f);
#endif // VISUAL_DEBUG_CUSTOM_ITEM_VIEW
}
// 3. draw text
[textColor set];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
menuFont, NSFontAttributeName,
textColor, NSForegroundColorAttributeName,
nil];
NSRect txtBounds = rectBounds;
txtBounds.origin.x = x;
txtBounds.size.width = textSize.width;
[text drawInRect:txtBounds withAttributes:attributes];
#ifdef VISUAL_DEBUG_CUSTOM_ITEM_VIEW
[[NSColor blackColor] set];
NSFrameRectWithWidth(txtBounds, 1.0f);
#endif // VISUAL_DEBUG_CUSTOM_ITEM_VIEW
if (self.keyShortcut != nil) {
// 4.1 draw shortcut
NSRect keyBounds = rectBounds;
keyBounds.origin.x = keyBounds.size.width - marginRight - shortcutSize.width;
keyBounds.size.width = shortcutSize.width;
NSDictionary *keyAttr = [NSDictionary dictionaryWithObjectsAndKeys:
menuShortcutFont, NSFontAttributeName,
textColor, NSForegroundColorAttributeName,
nil];
[self.keyShortcut drawInRect:keyBounds withAttributes:keyAttr];
#ifdef VISUAL_DEBUG_CUSTOM_ITEM_VIEW
[[NSColor magentaColor] set];
NSFrameRectWithWidth(keyBounds, 1.0f);
#endif // VISUAL_DEBUG_CUSTOM_ITEM_VIEW
} else {
if ([owner isKindOfClass:CMenu.class]) {
// 4.2 draw arrow-image of submenu
NSImage *arrow = [NSImage imageNamed:NSImageNameRightFacingTriangleTemplate]; // TODO: use correct triangle image
NSRect arrowBounds = rectBounds;
arrowBounds.origin.x = rectBounds.size.width - marginRight - arrow.size.width;
arrowBounds.origin.y = rectBounds.origin.y + (rectBounds.size.height - arrow.size.height) / 2;
arrowBounds.size = arrow.size;
[arrow drawInRect:arrowBounds];
#ifdef VISUAL_DEBUG_CUSTOM_ITEM_VIEW
[[NSColor magentaColor] set];
NSFrameRectWithWidth(arrowBounds, 1.0f);
#endif // VISUAL_DEBUG_CUSTOM_ITEM_VIEW
}
}
}
- (void)recalcSizes {
NSString * text = owner.menuItem.title;
NSImage * image = owner.menuItem.image;
NSDictionary * attributes = [NSDictionary dictionaryWithObjectsAndKeys:menuFont, NSFontAttributeName, nil];
textSize = [[[[NSAttributedString alloc] initWithString:text attributes:attributes] autorelease] size];
NSSize resultSize = NSMakeSize(textSize.width + marginLeft + marginRight, menuItemHeight);
if (image != nil) {
NSSize imgSize = image.size;
resultSize.width += imgSize.width + gapTxtIcon;
}
if (self.keyShortcut != nil) {
NSDictionary * ksa = [NSDictionary dictionaryWithObjectsAndKeys:menuShortcutFont, NSFontAttributeName, nil];
shortcutSize = [[[[NSAttributedString alloc] initWithString:self.keyShortcut attributes:ksa] autorelease] size];
resultSize.width += shortcutSize.width + gapTxtShortcut;
}
[self.widthAnchor constraintGreaterThanOrEqualToConstant:resultSize.width].active = YES;
}
@end
@implementation CMenuItem
@@ -140,6 +411,20 @@
}
- (void) setAcceleratorText:(NSString *)acceleratorText {
if ([acceleratorText isEqualToString:@""]) {
acceleratorText = nil;
}
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
CustomMenuItemView *menuItemView = fMenuItem.view;
if (menuItemView == nil) {
fMenuItem.view = menuItemView = [[[CustomMenuItemView alloc] initWithOwner:self] autorelease];
}
menuItemView.keyShortcut = acceleratorText;
[menuItemView recalcSizes];
}];
}
- (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers {
NSUInteger modifierMask = 0;
@@ -166,13 +451,18 @@
[fMenuItem setKeyEquivalent:theKeyEquivalent];
[fMenuItem setKeyEquivalentModifierMask:modifierMask];
[fMenuItem setTitle:theLabel];
if ([fMenuItem.view isKindOfClass:CustomMenuItemView.class]) {
[(CustomMenuItemView *)fMenuItem.view recalcSizes];
}
}];
}
- (void) setJavaImage:(NSImage *)theImage {
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[fMenuItem setImage:theImage];
if ([fMenuItem.view isKindOfClass:CustomMenuItemView.class]) {
[(CustomMenuItemView *)fMenuItem.view recalcSizes];
}
}];
}
@@ -183,7 +473,6 @@
}];
}
- (void)setJavaEnabled:(BOOL) enabled {
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
@@ -358,6 +647,21 @@ Java_sun_lwawt_macosx_CMenuItem_nativeSetLabel
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CMenuItem
* Method: nativeSetAcceleratorText
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CMenuItem_nativeSetAcceleratorText
(JNIEnv *env, jobject peer, jlong menuItemObj, jstring acceleratorText)
{
JNF_COCOA_ENTER(env);
NSString *theText = JNFJavaToNSString(env, acceleratorText);
[((CMenuItem *)jlong_to_ptr(menuItemObj)) setAcceleratorText:theText];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CMenuItem
* Method: nativeSetTooltip

View File

@@ -26,6 +26,10 @@
#import <AppKit/AppKit.h>
#import <jni.h>
extern NSMutableDictionary *sActions;
extern NSMutableDictionary *sActionSelectores;
extern NSMutableArray *sAllActionSelectores;
void initializeActions();
@protocol JavaAccessibilityAction

View File

@@ -28,11 +28,18 @@
#import "ThreadUtilities.h"
NSMutableDictionary *sActions = nil;
NSMutableDictionary *sActionSelectores = nil;
NSMutableArray *sAllActionSelectores = nil;
void initializeActions();
@implementation JavaAxAction
- (id)initWithEnv:(JNIEnv *)env withAccessibleAction:(jobject)accessibleAction withIndex:(jint)index withComponent:(jobject)component
{
if (sActions == nil) {
initializeActions();
}
self = [super init];
if (self) {
fAccessibleAction = JNFNewWeakGlobalRef(env, accessibleAction);
@@ -130,3 +137,31 @@
}
@end
void initializeActions() {
int actionsCount = 5;
sActions = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
[sActions setObject:NSAccessibilityPressAction forKey:@"click"];
[sActions setObject:NSAccessibilityIncrementAction forKey:@"increment"];
[sActions setObject:NSAccessibilityDecrementAction forKey:@"decrement"];
[sActions setObject:NSAccessibilityShowMenuAction forKey:@"toggle popup"];
[sActions setObject:NSAccessibilityPressAction forKey:@"toggleexpand"];
sActionSelectores = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformPress)) forKey:NSAccessibilityPressAction];
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformShowMenu)) forKey:NSAccessibilityShowMenuAction];
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformDecrement)) forKey:NSAccessibilityDecrementAction];
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformIncrement)) forKey:NSAccessibilityIncrementAction];
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformPick)) forKey:NSAccessibilityPickAction];
sAllActionSelectores = [[NSMutableArray alloc] initWithCapacity:actionsCount];
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformPick))];
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformIncrement))];
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformDecrement))];
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformShowMenu))];
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformPress))];
}

View File

@@ -1,90 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#include "jni.h"
#import <AppKit/AppKit.h>
//#define JAVA_AX_DEBUG 1
//#define JAVA_AX_NO_IGNORES 1
//#define JAVA_AX_DEBUG_PARMS 1
// these constants are duplicated in CAccessibility.java
#define JAVA_AX_ALL_CHILDREN (-1)
#define JAVA_AX_SELECTED_CHILDREN (-2)
#define JAVA_AX_VISIBLE_CHILDREN (-3)
// If the value is >=0, it's an index
@class JavaBaseAccessibility;
@protocol JavaBaseProvider
@property (nonatomic, retain) JavaBaseAccessibility *javaBase;
@end
@protocol PlatformAxElementProvider
@required
- (NSString *)getPlatformAxElementClassName;
@property (nonatomic, retain) NSObject <JavaBaseProvider> *platformAxElement;
@end
@interface JavaBaseAccessibility : NSObject <JavaBaseProvider, PlatformAxElementProvider> {
NSView *fView;
NSObject *fParent;
NSString *fNSRole;
NSString *fJavaRole;
jint fIndex;
jobject fAccessible;
jobject fComponent;
}
- (id)initWithParent:(NSObject*)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole;
- (void)unregisterFromCocoaAXSystem;
- (void)postValueChanged;
- (void)postSelectedTextChanged;
- (void)postSelectionChanged;
- (BOOL)isEqual:(id)anObject;
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible;
+ (void)postFocusChanged:(id)message;
+ (NSArray *)childrenOfParent:(JavaBaseAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored;
+ (NSArray *)childrenOfParent:(JavaBaseAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored recursive:(BOOL)recursive;
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)role index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view;
// If the isWraped parameter is true, then the object passed as a parent was created based on the same java component,
// but performs a different NSAccessibilityRole of a table cell, or a list row, or tree row,
// and we need to create an element whose role corresponds to the role in Java.
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view isWrapped:(BOOL)wrapped;
// The current parameter is used to bypass the check for an item's index on the parent so that the item is created. This is necessary,
// for example, for AccessibleJTreeNode, whose currentComponent has index -1
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current;
@property(readonly) jobject accessible;
@property(readonly) jobject component;
@property(readonly) jint index;
- (jobject)axContextWithEnv:(JNIEnv *)env;
- (NSView*)view;
- (NSWindow*)window;
- (id)parent;
-(void)setParent:(id)javaBaseAccessibilityParent;
- (NSString *)javaRole;
- (NSString *)nsRole;
- (BOOL)isMenu;
- (BOOL)isSelected:(JNIEnv *)env;
- (BOOL)isSelectable:(JNIEnv *)env;
- (BOOL)isVisible:(JNIEnv *)env;
- (NSSize)getSize;
- (NSRect)getBounds;
- (id)getFocusedElement;
@end

View File

@@ -1,716 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaBaseAccessibility.h"
#import "sun_lwawt_macosx_CAccessibility.h"
#import <AppKit/AppKit.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
#import <dlfcn.h>
#import "JavaBaseAccessibility.h"
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "JavaTextAccessibility.h"
#import "JavaListAccessibility.h"
#import "JavaTableAccessibility.h"
#import "JavaListRowAccessibility.h"
#import "JavaTableRowAccessibility.h"
#import "JavaCellAccessibility.h"
#import "JavaOutlineAccessibility.h"
#import "JavaOutlineRowAccessibility.h"
#import "JavaComponentAccessibility.h"
#import "ThreadUtilities.h"
#import "AWTView.h"
// getChildrenAndRolesRecursive
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;");
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRolesRecursive, sjc_CAccessibility, "getChildrenAndRolesRecursive", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZI)[Ljava/lang/Object;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleComponent, sjc_CAccessibility, "getAccessibleComponent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_STATIC_MEMBER_CACHE(sjm_isFocusTraversable, sjc_CAccessibility, "isFocusTraversable", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
static JNF_MEMBER_CACHE(jf_ptr, sjc_CAccessible, "ptr", "J");
static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;");
static jobject sAccessibilityClass = NULL;
@implementation JavaBaseAccessibility
@synthesize platformAxElement;
@synthesize javaBase;
- (id)init
{
self = [super init];
if (self) {
NSString *className = [self getPlatformAxElementClassName];
self.platformAxElement = className != NULL ? [[NSClassFromString(className) alloc] init] : self; // defaults to [self]
self.platformAxElement.javaBase = self;
}
return self;
}
// to override in subclasses
- (NSString *)getPlatformAxElementClassName
{
return NULL;
}
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
{
self = [self init];
if (self) {
fParent = [parent retain];
fView = [view retain];
fJavaRole = [javaRole retain];
fAccessible = (*env)->NewWeakGlobalRef(env, accessible);
(*env)->ExceptionClear(env); // in case of OOME
jobject jcomponent = [(AWTView *)fView awtComponent:env];
fComponent = (*env)->NewWeakGlobalRef(env, jcomponent);
(*env)->DeleteLocalRef(env, jcomponent);
fIndex = index;
}
return self;
}
- (void)unregisterFromCocoaAXSystem
{
AWT_ASSERT_APPKIT_THREAD;
static dispatch_once_t initialize_unregisterUniqueId_once;
static void (*unregisterUniqueId)(id);
dispatch_once(&initialize_unregisterUniqueId_once, ^{
void *jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL);
unregisterUniqueId = dlsym(jrsFwk, "JRSAccessibilityUnregisterUniqueIdForUIElement");
});
if (unregisterUniqueId) unregisterUniqueId(self);
}
- (void)dealloc
{
[self unregisterFromCocoaAXSystem];
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
(*env)->DeleteWeakGlobalRef(env, fAccessible);
fAccessible = NULL;
(*env)->DeleteWeakGlobalRef(env, fComponent);
fComponent = NULL;
[fParent release];
fParent = nil;
[fNSRole release];
fNSRole = nil;
[fJavaRole release];
fJavaRole = nil;
[fView release];
fView = nil;
if (self.platformAxElement != self) {
[self.platformAxElement dealloc];
}
[super dealloc];
}
- (void)postValueChanged
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self.platformAxElement, NSAccessibilityValueChangedNotification);
}
- (void)postSelectedTextChanged
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self.platformAxElement, NSAccessibilitySelectedTextChangedNotification);
}
- (void)postSelectionChanged
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self.platformAxElement, NSAccessibilitySelectedChildrenChangedNotification);
}
- (void)postMenuOpened
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self.platformAxElement, (NSString *)kAXMenuOpenedNotification);
}
- (void)postMenuClosed
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self.platformAxElement, (NSString *)kAXMenuClosedNotification);
}
- (void)postMenuItemSelected
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification(self.platformAxElement, (NSString *)kAXMenuItemSelectedNotification);
}
- (BOOL)isEqual:(id)anObject
{
if (![anObject isKindOfClass:[self class]]) return NO;
JavaBaseAccessibility *accessibility = (JavaBaseAccessibility *)anObject;
JNIEnv* env = [ThreadUtilities getJNIEnv];
return (*env)->IsSameObject(env, accessibility->fAccessible, fAccessible);
}
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible
{
return (*env)->IsSameObject(env, fAccessible, accessible);
}
+ (void)initialize
{
if (sRoles == nil) {
initializeRoles();
}
if (sAccessibilityClass == NULL) {
JNF_STATIC_MEMBER_CACHE(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;");
#ifdef JAVA_AX_NO_IGNORES
NSArray *ignoredKeys = [NSArray array];
#else
NSArray *ignoredKeys = [sRoles allKeysForObject:JavaAccessibilityIgnore];
#endif
jobjectArray result = NULL;
jsize count = [ignoredKeys count];
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_CLASS_CACHE(jc_String, "java/lang/String");
result = JNFNewObjectArray(env, &jc_String, count);
if (!result) {
NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__);
return;
}
NSInteger i;
for (i = 0; i < count; i++) {
jstring jString = JNFNSToJavaString(env, [ignoredKeys objectAtIndex:i]);
(*env)->SetObjectArrayElement(env, result, i, jString);
(*env)->DeleteLocalRef(env, jString);
}
sAccessibilityClass = JNFCallStaticObjectMethod(env, jm_getAccessibility, result); // AWT_THREADING Safe (known object)
}
}
+ (void)postFocusChanged:(id)message
{
AWT_ASSERT_APPKIT_THREAD;
NSAccessibilityPostNotification([NSApp accessibilityFocusedUIElement], NSAccessibilityFocusedUIElementChangedNotification);
}
+ (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env {
if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) {
return jaccessible;
} else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) {
return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible);
}
return NULL;
}
+ (NSArray *) childrenOfParent:(JavaBaseAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored
{
return [JavaBaseAccessibility childrenOfParent:parent withEnv:env withChildrenCode:whichChildren allowIgnored:allowIgnored recursive:NO];
}
+ (NSArray *) childrenOfParent:(JavaBaseAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored recursive:(BOOL)recursive
{
if ([parent isKindOfClass:[JavaTableAccessibility class]]) {
if (whichChildren == JAVA_AX_SELECTED_CHILDREN) {
NSArray<NSNumber *> *selectedRowIndexses = [parent selectedAccessibleRows];
NSMutableArray *children = [NSMutableArray arrayWithCapacity:[selectedRowIndexses count]];
for (NSNumber *index in selectedRowIndexses) {
[children addObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
withEnv:env
withAccessible:NULL
withIndex:index.unsignedIntValue
withView:[parent view]
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
}
return [NSArray arrayWithArray:children];
} else if (whichChildren == JAVA_AX_ALL_CHILDREN) {
int rowCount = [parent accessibleRowCount];
NSMutableArray *children = [NSMutableArray arrayWithCapacity:rowCount];
for (int i = 0; i < rowCount; i++) {
[children addObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
withEnv:env
withAccessible:NULL
withIndex:i
withView:[parent view]
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
}
return [NSArray arrayWithArray:children];
} else {
return [NSArray arrayWithObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
withEnv:env
withAccessible:NULL
withIndex:whichChildren
withView:[parent view]
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
}
}
if (parent->fAccessible == NULL) return nil;
jobjectArray jchildrenAndRoles = NULL;
if (recursive) {
jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRolesRecursive, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored, 1);
} else {
jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
}
if (jchildrenAndRoles == NULL) return nil;
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
NSMutableArray *children = [NSMutableArray arrayWithCapacity:arrayLen/2]; //childrenAndRoles array contains two elements (child, role) for each child
NSInteger i;
NSUInteger childIndex = (whichChildren >= 0) ? whichChildren : 0; // if we're getting one particular child, make sure to set its index correctly
int inc = recursive ? 3 : 2;
for(i = 0; i < arrayLen; i += inc)
{
jobject /* Accessible */ jchild = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i);
jobject /* String */ jchildJavaRole = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i+1);
NSString *childJavaRole = nil;
if (jchildJavaRole != NULL) {
jobject jkey = JNFGetObjectField(env, jchildJavaRole, sjf_key);
childJavaRole = JNFJavaToNSString(env, jkey);
(*env)->DeleteLocalRef(env, jkey);
}
JavaBaseAccessibility *child = [self createWithParent:parent accessible:jchild role:childJavaRole index:childIndex withEnv:env withView:parent->fView];
if ([child isKindOfClass:[JavaOutlineRowAccessibility class]]) {
jobject jLevel = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i+2);
NSString *sLevel = nil;
if (jLevel != NULL) {
sLevel = JNFJavaToNSString(env, jLevel);
(*env)->DeleteLocalRef(env, jLevel);
int level = sLevel.intValue;
[(JavaOutlineRowAccessibility *)child setAccessibleLevel:level];
}
}
[children addObject:child.platformAxElement];
(*env)->DeleteLocalRef(env, jchild);
(*env)->DeleteLocalRef(env, jchildJavaRole);
childIndex++;
}
(*env)->DeleteLocalRef(env, jchildrenAndRoles);
return children;
}
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view
{
return [JavaBaseAccessibility createWithAccessible:jaccessible withEnv:env withView:view isCurrent:NO];
}
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current
{
JavaBaseAccessibility *ret = nil;
jobject jcomponent = [(AWTView *)view awtComponent:env];
jint index = JNFCallStaticIntMethod(env, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
if ((index >= 0) || current) {
ret = [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
}
(*env)->DeleteLocalRef(env, jcomponent);
return ret;
}
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
{
return [self createWithParent:nil accessible:jaccessible role:javaRole index:index withEnv:env withView:view];
}
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
{
return [JavaBaseAccessibility createWithParent:parent accessible:jaccessible role:javaRole index:index withEnv:env withView:view isWrapped:NO];
}
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view isWrapped:(BOOL)wrapped
{
// try to fetch the jCAX from Java, and return autoreleased
jobject jCAX = [JavaBaseAccessibility getCAccessible:jaccessible withEnv:env];
if (jCAX == NULL) return nil;
if (!wrapped) { // If wrapped is true, then you don't need to get an existing instance, you need to create a new one
JavaBaseAccessibility *value = (JavaBaseAccessibility *) jlong_to_ptr(JNFGetLongField(env, jCAX, jf_ptr));
if (value != nil) {
(*env)->DeleteLocalRef(env, jCAX);
return [[value retain] autorelease];
}
}
// otherwise, create a new instance
JavaBaseAccessibility *newChild = nil;
if ([[sRoles objectForKey:[parent javaRole]] isEqualToString:NSAccessibilityListRole]) {
newChild = [JavaListRowAccessibility alloc];
} else if ([parent isKindOfClass:[JavaOutlineAccessibility class]]) {
newChild = [JavaOutlineRowAccessibility alloc];
} else if ([javaRole isEqualToString:@"pagetablist"]) {
newChild = [TabGroupAccessibility alloc];
} else if ([javaRole isEqualToString:@"scrollpane"]) {
newChild = [ScrollAreaAccessibility alloc];
} else {
NSString *nsRole = [sRoles objectForKey:javaRole];
if ([nsRole isEqualToString:NSAccessibilityStaticTextRole] || [nsRole isEqualToString:NSAccessibilityTextAreaRole] || [nsRole isEqualToString:NSAccessibilityTextFieldRole]) {
newChild = [JavaTextAccessibility alloc];
} else if ([nsRole isEqualToString:NSAccessibilityListRole]) {
newChild = [JavaListAccessibility alloc];
} else if ([nsRole isEqualToString:NSAccessibilityTableRole]) {
newChild = [JavaTableAccessibility alloc];
} else if ([nsRole isEqualToString:NSAccessibilityOutlineRole]) {
newChild = [JavaOutlineAccessibility alloc];
} else {
newChild = [JavaComponentAccessibility alloc];
}
}
// must init freshly -alloc'd object
[newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance
// If creating a JPopupMenu (not a combobox popup list) need to fire menuOpened.
// This is the only way to know if the menu is opening; visible state change
// can't be caught because the listeners are not set up in time.
if ( [javaRole isEqualToString:@"popupmenu"] &&
![[parent javaRole] isEqualToString:@"combobox"] ) {
[newChild postMenuOpened];
}
// must hard retain pointer poked into Java object
[newChild retain];
JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
// the link is removed in the wrapper
if (!wrapped) {
(*env)->DeleteLocalRef(env, jCAX);
}
// return autoreleased instance
return [newChild autorelease];
}
- (jobject)axContextWithEnv:(JNIEnv *)env
{
return getAxContext(env, fAccessible, fComponent);
}
- (id)parent
{
static JNF_CLASS_CACHE(sjc_Window, "java/awt/Window");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleParent, sjc_CAccessibility, "getAccessibleParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
static JNF_STATIC_MEMBER_CACHE(sjm_getSwingAccessible, sjc_CAccessible, "getSwingAccessible", "(Ljavax/accessibility/Accessible;)Ljavax/accessibility/Accessible;");
if(fParent == nil) {
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject jparent = JNFCallStaticObjectMethod(env, sjm_getAccessibleParent, fAccessible, fComponent);
if (jparent == NULL) {
fParent = fView;
} else {
AWTView *view = fView;
jobject jax = JNFCallStaticObjectMethod(env, sjm_getSwingAccessible, fAccessible);
if (JNFIsInstanceOf(env, jax, &sjc_Window)) {
// In this case jparent is an owner toplevel and we should retrieve its own view
view = [AWTView awtView:env ofAccessible:jparent];
}
if (view != nil) {
fParent = [JavaBaseAccessibility createWithAccessible:jparent withEnv:env withView:view];
}
if (fParent == nil) {
fParent = fView;
}
(*env)->DeleteLocalRef(env, jparent);
(*env)->DeleteLocalRef(env, jax );
}
[fParent retain];
}
return fParent;
}
- (NSView *)view
{
return fView;
}
- (NSWindow *)window
{
return [[self view] window];
}
- (NSString *)javaRole
{
if(fJavaRole == nil) {
JNIEnv* env = [ThreadUtilities getJNIEnv];
fJavaRole = getJavaRole(env, fAccessible, fComponent);
[fJavaRole retain];
}
return fJavaRole;
}
- (BOOL)isMenu
{
id role = [self accessibilityRoleAttribute];
return [role isEqualToString:NSAccessibilityMenuBarRole] || [role isEqualToString:NSAccessibilityMenuRole] || [role isEqualToString:NSAccessibilityMenuItemRole];
}
- (BOOL)isSelected:(JNIEnv *)env
{
if (fIndex == -1) {
return NO;
}
return isChildSelected(env, ((JavaBaseAccessibility *)[self parent])->fAccessible, fIndex, fComponent);
}
- (BOOL)isSelectable:(JNIEnv *)env
{
jobject axContext = [self axContextWithEnv:env];
BOOL selectable = isSelectable(env, axContext, fComponent);
(*env)->DeleteLocalRef(env, axContext);
return selectable;
}
- (BOOL)isVisible:(JNIEnv *)env
{
if (fIndex == -1) {
return NO;
}
jobject axContext = [self axContextWithEnv:env];
BOOL showing = isShowing(env, axContext, fComponent);
(*env)->DeleteLocalRef(env, axContext);
return showing;
}
- (NSSize)getSize
{
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
NSSize size = getAxComponentSize(env, axComponent, fComponent);
(*env)->DeleteLocalRef(env, axComponent);
return size;
}
- (NSRect)getBounds
{
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
// NSAccessibility wants the bottom left point of the object in
// bottom left based screen coords
// Get the java screen coords, and make a NSPoint of the bottom left of the AxComponent.
NSSize size = getAxComponentSize(env, axComponent, fComponent);
NSPoint point = getAxComponentLocationOnScreen(env, axComponent, fComponent);
(*env)->DeleteLocalRef(env, axComponent);
point.y += size.height;
// Now make it into Cocoa screen coords.
point.y = [[[[self view] window] screen] frame].size.height - point.y;
return NSMakeRect(point.x, point.y, size.width, size.height);
}
- (id)getFocusedElement
{
static JNF_STATIC_MEMBER_CACHE(jm_getFocusOwner, sjc_CAccessibility, "getFocusOwner", "(Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
JNIEnv *env = [ThreadUtilities getJNIEnv];
id value = nil;
NSWindow* hostWindow = [[self->fView window] retain];
jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
[hostWindow release];
if (focused != NULL) {
if (JNFIsInstanceOf(env, focused, &sjc_Accessible)) {
value = [JavaComponentAccessibility createWithAccessible:focused withEnv:env withView:fView];
value = ((JavaBaseAccessibility *)value).platformAxElement;
}
(*env)->DeleteLocalRef(env, focused);
}
if (value == nil) {
value = self;
}
#ifdef JAVA_AX_DEBUG
NSLog(@"%s: %@", __FUNCTION__, value);
#endif
return value;
}
- (jobject)accessible {
return fAccessible;
}
- (jobject)component {
return fComponent;
}
-(jint)index {
return fIndex;
}
- (void)setParent:(id)javaBaseAccessibilityParent {
fParent = javaBaseAccessibilityParent;
}
- (NSString *)nsRole {
return fNSRole;
}
- (NSUInteger)accessibilityIndexOfChild:(id)child {
if ([child isKindOfClass:[PlatformAxElement class]]) {
child = [child javaBase];
}
jint returnValue = JNFCallStaticIntMethod( [ThreadUtilities getJNIEnv],
sjm_getAccessibleIndexInParent,
[child accessible],
[child component]);
return (returnValue == -1) ? NSNotFound : returnValue;
}
@end
/*
* Class: sun_lwawt_macosx_CAccessibility
* Method: focusChanged
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessibility_focusChanged
(JNIEnv *env, jobject jthis)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postFocusChanged:) on:[JavaBaseAccessibility class] withObject:nil waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: valueChanged
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_valueChanged
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postValueChanged) on:(JavaBaseAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: selectedTextChanged
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectedTextChanged
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postSelectedTextChanged)
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
withObject:nil
waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: selectionChanged
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectionChanged
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postSelectionChanged) on:(JavaBaseAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: menuOpened
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postMenuOpened)
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
withObject:nil
waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: menuClosed
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postMenuClosed)
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
withObject:nil
waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: menuItemSelected
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
withObject:nil
waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: unregisterFromCocoaAXSystem
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem
(JNIEnv *env, jclass jklass, jlong element)
{
JNF_COCOA_ENTER(env);
[ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) on:(JavaBaseAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
JNF_COCOA_EXIT(env);
}

View File

@@ -1,8 +1,8 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaElementAccessibility.h"
#import "JavaComponentAccessibility.h"
@interface JavaCellAccessibility : JavaElementAccessibility
@interface JavaCellAccessibility : JavaComponentAccessibility
@end
@interface PlatformAxCell : PlatformAxElement

View File

@@ -20,13 +20,13 @@
- (NSArray *)accessibilityChildren {
NSArray *children = [super accessibilityChildren];
if (children == NULL) {
NSString *javaRole = [[self javaBase] javaRole];
JavaBaseAccessibility *newChild = [JavaBaseAccessibility createWithParent:[self javaBase]
accessible:[[self javaBase] accessible]
NSString *javaRole = [[self javaComponent] javaRole];
JavaComponentAccessibility *newChild = [JavaComponentAccessibility createWithParent:[self javaComponent]
accessible:[[self javaComponent] accessible]
role:javaRole
index:[[self javaBase] index]
index:[[self javaComponent] index]
withEnv:[ThreadUtilities getJNIEnv]
withView:[[self javaBase] view]
withView:[[self javaComponent] view]
isWrapped:YES];
return [NSArray arrayWithObject:newChild.platformAxElement];
} else {

View File

@@ -1,8 +1,8 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaElementAccessibility.h"
#import "JavaComponentAccessibility.h"
@interface JavaColumnAccessibility : JavaElementAccessibility
@interface JavaColumnAccessibility : JavaComponentAccessibility
@end
@interface PlatformAxColumn : PlatformAxElement

View File

@@ -30,8 +30,8 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
NSArray *children = [super accessibilityChildren];
if (children == NULL) {
JNIEnv *env = [ThreadUtilities getJNIEnv];
if ([[[self accessibilityParent] javaBase] accessible] == NULL) return nil;
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, [[[self accessibilityParent] javaBase] accessible], [[[self accessibilityParent] javaBase] component], JAVA_AX_ALL_CHILDREN, NO);
if ([[[self accessibilityParent] javaComponent] accessible] == NULL) return nil;
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, [[[self accessibilityParent] javaComponent] accessible], [[[self accessibilityParent] javaComponent] component], JAVA_AX_ALL_CHILDREN, NO);
if (jchildrenAndRoles == NULL) return nil;
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
@@ -39,8 +39,8 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
NSUInteger childIndex = [self columnNumberInTable];
JavaColumnAccessibility *selfRow = [self javaBase];
int inc = [(JavaTableAccessibility *)[[self accessibilityParent] javaBase] accessibleColCount] * 2;
JavaColumnAccessibility *selfRow = [self javaComponent];
int inc = [(JavaTableAccessibility *) [[self accessibilityParent] javaComponent] accessibleColCount] * 2;
NSInteger i = childIndex * 2;
for(NSInteger i; i < arrayLen; i += inc)
{
@@ -75,7 +75,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
}
- (NSUInteger)columnNumberInTable {
return [[self javaBase] index];
return [[self javaComponent] index];
}
@end

View File

@@ -0,0 +1,12 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaComponentAccessibility.h"
@interface JavaComboBoxAccessibility : JavaComponentAccessibility
@property(readonly) NSString *accessibleSelectedText;
@end
@interface PlatformAxComboBox : PlatformAxElement
@end

View File

@@ -0,0 +1,48 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaComboBoxAccessibility.h"
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static const char* ACCESSIBLE_JCOMBOBOX_NAME = "javax.swing.JComboBox$AccessibleJComboBox";
@implementation JavaComboBoxAccessibility
- (NSString *)getPlatformAxElementClassName {
return @"PlatformAxComboBox";
}
- (NSString *)accessibleSelectedText {
JNIEnv *env = [ThreadUtilities getJNIEnv];
JNFClassInfo clsInfo;
clsInfo.name = ACCESSIBLE_JCOMBOBOX_NAME;
clsInfo.cls = (*env)->GetObjectClass(env, [self axContextWithEnv:env]);
JNF_MEMBER_CACHE(jm_getAccessibleSelection, clsInfo, "getAccessibleSelection", "(I)Ljavax/accessibility/Accessible;");
jobject axSelectedChild = JNFCallObjectMethod(env, [self axContextWithEnv:env], jm_getAccessibleSelection, 0);
if (axSelectedChild == NULL) {
return nil;
}
jobject childName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, axSelectedChild, fComponent);
if (childName == NULL) {
(*env)->DeleteLocalRef(env, axSelectedChild);
return nil;
}
NSString *selectedText = JNFObjectToString(env, childName);
(*env)->DeleteLocalRef(env, axSelectedChild);
(*env)->DeleteLocalRef(env, childName);
return selectedText;
}
@end
@implementation PlatformAxComboBox
- (id)accessibilityValue {
return [(JavaComboBoxAccessibility *) [self javaComponent] accessibleSelectedText];
}
@end

View File

@@ -1,147 +1,127 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "jni.h"
#import <AppKit/AppKit.h>
#import "JavaBaseAccessibility.h"
@interface JavaComponentAccessibility : JavaBaseAccessibility {
//#define JAVA_AX_DEBUG 1
//#define JAVA_AX_NO_IGNORES 1
//#define JAVA_AX_DEBUG_PARMS 1
// these constants are duplicated in CAccessibility.java
#define JAVA_AX_ALL_CHILDREN (-1)
#define JAVA_AX_SELECTED_CHILDREN (-2)
#define JAVA_AX_VISIBLE_CHILDREN (-3)
// If the value is >=0, it's an index
@class JavaComponentAccessibility;
@protocol JavaComponentProvider
@property (nonatomic, retain) JavaComponentAccessibility *javaComponent;
@end
@interface PlatformAxElement : NSAccessibilityElement <JavaComponentProvider>
// begin of NSAccessibility protocol methods
- (BOOL)isAccessibilityElement;
- (NSString *)accessibilityLabel;
- (NSArray *)accessibilityChildren;
- (NSArray *)accessibilitySelectedChildren;
- (NSRect)accessibilityFrame;
- (id)accessibilityParent;
- (BOOL)isAccessibilityEnabled;
- (id)accessibilityApplicationFocusedUIElement;
- (id)getAccessibilityWindow;
// end of NSAccessibility protocol methods
@end
@protocol PlatformAxElementProvider
@required
- (NSString *)getPlatformAxElementClassName;
@property (nonatomic, retain) PlatformAxElement *platformAxElement;
@end
@interface JavaComponentAccessibility : NSObject <PlatformAxElementProvider> {
NSView *fView;
NSObject *fParent;
NSString *fNSRole;
NSString *fJavaRole;
jint fIndex;
jobject fAccessible;
jobject fComponent;
NSMutableDictionary *fActions;
NSMutableArray *fActionSElectors;
NSObject *fActionsLOCK;
}
- (NSDictionary*)getActions:(JNIEnv *)env;
- (id)initWithParent:(NSObject*)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole;
- (void)unregisterFromCocoaAXSystem;
- (void)postValueChanged;
- (void)postSelectedTextChanged;
- (void)postSelectionChanged;
- (BOOL)isEqual:(id)anObject;
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible;
+ (void)postFocusChanged:(id)message;
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored;
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored recursive:(BOOL)recursive;
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)role index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view;
// If the isWraped parameter is true, then the object passed as a parent was created based on the same java component,
// but performs a different NSAccessibilityRole of a table cell, or a list row, or tree row,
// and we need to create an element whose role corresponds to the role in Java.
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view isWrapped:(BOOL)wrapped;
// The current parameter is used to bypass the check for an item's index on the parent so that the item is created. This is necessary,
// for example, for AccessibleJTreeNode, whose currentComponent has index -1
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current;
@property(readonly) jobject accessible;
@property(readonly) jobject component;
@property(readonly) jint index;
@property(readonly, copy) NSArray *actionSelectores;;
- (jobject)axContextWithEnv:(JNIEnv *)env;
- (NSView*)view;
- (NSWindow*)window;
- (id)parent;
- (void)setParent:(id)javaComponentAccessibilityParent;
- (NSString *)javaRole;
- (NSString *)nsRole;
- (BOOL)isMenu;
- (BOOL)isSelected:(JNIEnv *)env;
- (BOOL)isSelectable:(JNIEnv *)env;
- (BOOL)isVisible:(JNIEnv *)env;
- (NSSize)getSize;
- (NSRect)getBounds;
- (id)getFocusedElement;
@property(readonly) int accessibleIndexOfParent;
@property(readonly) BOOL accessibleEnabled;
@property(readwrite) BOOL accessibleFocused;
@property(readonly) NSNumber *accessibleMaxValue;
@property(readonly) NSNumber *accessibleMinValue;
@property(readonly) id accessibleOrientation;
@property(readonly) NSValue *accessiblePosition;
@property(readonly) NSString *accessibleRole;
@property(readonly) NSString *accessibleRoleDescription;
@property(readonly) id accessibleParent;
@property(readwrite, copy) NSNumber *accessibleSelected;
@property(readonly) id accessibleValue;;
@property(readonly) NSMutableDictionary *getActions;
- (id)accessibleHitTest:(NSPoint)point;
- (void)getActionsWithEnv:(JNIEnv *)env;
// attribute names
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
- (NSArray *)accessibilityAttributeNames;
// attributes
- (id)accessibilityAttributeValue:(NSString *)attribute;
- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
- (NSArray *)accessibilityChildrenAttribute;
- (BOOL)accessibilityIsChildrenAttributeSettable;
- (NSUInteger)accessibilityIndexOfChild:(id)child;
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute
index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
- (NSNumber *)accessibilityEnabledAttribute;
- (BOOL)accessibilityIsEnabledAttributeSettable;
- (NSNumber *)accessibilityFocusedAttribute;
- (BOOL)accessibilityIsFocusedAttributeSettable;
- (void)accessibilitySetFocusedAttribute:(id)value;
- (NSString *)accessibilityHelpAttribute;
- (BOOL)accessibilityIsHelpAttributeSettable;
- (NSValue *)accessibilityIndexAttribute;
- (BOOL)accessibilityIsIndexAttributeSettable;
- (id)accessibilityMaxValueAttribute;
- (BOOL)accessibilityIsMaxValueAttributeSettable;
- (id)accessibilityMinValueAttribute;
- (BOOL)accessibilityIsMinValueAttributeSettable;
- (id)accessibilityOrientationAttribute;
- (BOOL)accessibilityIsOrientationAttributeSettable;
- (id)accessibilityParentAttribute;
- (BOOL)accessibilityIsParentAttributeSettable;
- (NSValue *)accessibilityPositionAttribute;
- (BOOL)accessibilityIsPositionAttributeSettable;
- (NSString *)accessibilityRoleAttribute;
- (BOOL)accessibilityIsRoleAttributeSettable;
- (NSString *)accessibilityRoleDescriptionAttribute;
- (BOOL)accessibilityIsRoleDescriptionAttributeSettable;
- (NSArray *)accessibilitySelectedChildrenAttribute;
- (BOOL)accessibilityIsSelectedChildrenAttributeSettable;
- (NSNumber *)accessibilitySelectedAttribute;
- (BOOL)accessibilityIsSelectedAttributeSettable;
- (void)accessibilitySetSelectedAttribute:(id)value;
- (NSValue *)accessibilitySizeAttribute;
- (BOOL)accessibilityIsSizeAttributeSettable;
- (NSString *)accessibilitySubroleAttribute;
- (BOOL)accessibilityIsSubroleAttributeSettable;
- (NSString *)accessibilityTitleAttribute;
- (BOOL)accessibilityIsTitleAttributeSettable;
- (NSWindow *)accessibilityTopLevelUIElementAttribute;
- (BOOL)accessibilityIsTopLevelUIElementAttributeSettable;
- (id)accessibilityValueAttribute;
- (BOOL)accessibilityIsValueAttributeSettable;
- (void)accessibilitySetValueAttribute:(id)value;
- (NSArray *)accessibilityVisibleChildrenAttribute;
- (BOOL)accessibilityIsVisibleChildrenAttributeSettable;
- (id)accessibilityWindowAttribute;
- (BOOL)accessibilityIsWindowAttributeSettable;
// actions
- (NSArray *)accessibilityActionNames;
- (NSString *)accessibilityActionDescription:(NSString *)action;
- (void)accessibilityPerformAction:(NSString *)action;
- (BOOL)accessibilityIsIgnored;
- (id)accessibilityHitTest:(NSPoint)point withEnv:(JNIEnv *)env;
- (id)accessibilityFocusedUIElement;
- (BOOL)accessiblePerformAction:(NSAccessibilityActionName)actionName;
@end
@interface TabGroupAccessibility : JavaComponentAccessibility {
NSInteger _numTabs;
}
- (id)currentTabWithEnv:(JNIEnv *)env withAxContext:(jobject)axContext;
- (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
- (NSArray *)accessibilityChildrenAttribute;
- (id) accessibilityTabsAttribute;
- (BOOL)accessibilityIsTabsAttributeSettable;
- (NSArray *)accessibilityContentsAttribute;
- (BOOL)accessibilityIsContentsAttributeSettable;
- (id) accessibilityValueAttribute;
@end
@interface TabGroupControlAccessibility : JavaComponentAccessibility {
jobject fTabGroupAxContext;
}
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole;
- (jobject)tabGroup;
- (void)getActionsWithEnv:(JNIEnv *)env;
- (id)accessibilityValueAttribute;
@end
@interface ScrollAreaAccessibility : JavaComponentAccessibility {
}
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
- (NSArray *)accessibilityContentsAttribute;
- (BOOL)accessibilityIsContentsAttributeSettable;
- (id)accessibilityVerticalScrollBarAttribute;
- (BOOL)accessibilityIsVerticalScrollBarAttributeSettable;
- (id)accessibilityHorizontalScrollBarAttribute;
- (BOOL)accessibilityIsHorizontalScrollBarAttributeSettable;
@end

View File

@@ -1,26 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaBaseAccessibility.h"
@interface JavaElementAccessibility : JavaBaseAccessibility
@property(readonly) int accessibleIndexOfParent;
@end
@interface PlatformAxElement : NSAccessibilityElement <JavaBaseProvider>
// begin of NSAccessibility protocol methods
- (BOOL)isAccessibilityElement;
- (NSString *)accessibilityLabel;
- (NSArray *)accessibilityChildren;
- (NSArray *)accessibilitySelectedChildren;
- (NSRect)accessibilityFrame;
- (id)accessibilityParent;
- (BOOL)accessibilityIsIgnored;
- (BOOL)isAccessibilityEnabled;
- (id)accessibilityApplicationFocusedUIElement;
- (id)getAccessibilityWindow;
// end of NSAccessibility protocol methods
@end

View File

@@ -1,122 +0,0 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaElementAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
static JNF_MEMBER_CACHE(jm_getAccessibleContext, sjc_CAccessible, "getAccessibleContext", "()Ljavax/accessibility/AccessibleContext;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
static void RaiseMustOverrideException(NSString *method)
{
@throw [NSException exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", method]
userInfo:nil];
};
@implementation JavaElementAccessibility
- (NSString *)getPlatformAxElementClassName
{
RaiseMustOverrideException(@"getPlatformAxElementClassName");
return NULL;
}
- (int)accessibleIndexOfParent {
return (int)JNFCallStaticIntMethod ([ThreadUtilities getJNIEnv], sjm_getAccessibleIndexInParent, fAccessible, fComponent);
}
@end
@implementation PlatformAxElement
@synthesize javaBase;
- (BOOL)isAccessibilityElement
{
return YES;
}
- (NSString *)accessibilityLabel
{
// RaiseMustOverrideException(@"accessibilityLabel");
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, [javaBase accessible], [javaBase component]);
NSString* str = JNFJavaToNSString(env, axName);
(*env)->DeleteLocalRef(env, axName);
return str;
}
- (NSArray *)accessibilityChildren
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSArray *children = [JavaBaseAccessibility childrenOfParent:self.javaBase
withEnv:env
withChildrenCode:JAVA_AX_ALL_CHILDREN
allowIgnored:([[self accessibilityRole] isEqualToString:NSAccessibilityListRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityTableRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole])
recursive:[[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole]];
if ([children count] > 0) {
return children;
}
return NULL;
}
- (NSArray *)accessibilitySelectedChildren
{
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSArray *selectedChildren = [JavaBaseAccessibility childrenOfParent:self.javaBase
withEnv:env
withChildrenCode:JAVA_AX_SELECTED_CHILDREN
allowIgnored:([[self accessibilityRole] isEqualToString:NSAccessibilityListRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityTableRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole])
recursive:[[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole]];
if ([selectedChildren count] > 0) {
return selectedChildren;
}
return NULL;
}
- (NSRect)accessibilityFrame
{
return [self.javaBase getBounds];
}
- (id)accessibilityParent
{
JavaBaseAccessibility *parent = (JavaBaseAccessibility *) [self.javaBase parent];
return parent.platformAxElement;
}
- (BOOL)accessibilityIsIgnored
{
RaiseMustOverrideException(@"accessibilityIsIgnored");
return NO;
}
- (BOOL)isAccessibilityEnabled
{
RaiseMustOverrideException(@"isAccessibilityEnabled");
return YES;
}
- (id)accessibilityApplicationFocusedUIElement
{
return [self.javaBase getFocusedElement];
}
- (id)getAccessibilityWindow
{
return [self.javaBase window];
}
- (void)setAccessibilityParent:(id)accessibilityParent {
[[self javaBase] setParent:accessibilityParent];
}
- (NSUInteger)accessibilityIndexOfChild:(id)child {
return [[self javaBase] accessibilityIndexOfChild:child];
}
@end

View File

@@ -1,14 +1,9 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#ifndef NATIVE_JAVALISTACCESSIBILITY_H
#define NATIVE_JAVALISTACCESSIBILITY_H
#import "JavaComponentAccessibility.h"
#endif // NATIVE_JAVALISTACCESSIBILITY_H
#import "JavaElementAccessibility.h"
@interface JavaListAccessibility : JavaElementAccessibility
@interface JavaListAccessibility : JavaComponentAccessibility
@end
@interface PlatformAxList : PlatformAxElement <NSAccessibilityList>
@end
@end

View File

@@ -15,13 +15,11 @@
@implementation PlatformAxList
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilityRows
{
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilityRows {
return [self accessibilityChildren];
}
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilitySelectedRows
{
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilitySelectedRows {
return [self accessibilitySelectedChildren];
}
@@ -30,23 +28,15 @@
return [super accessibilityLabel] == NULL ? @"list" : [super accessibilityLabel];
}
- (BOOL)accessibilityIsIgnored
{
return NO;
}
- (BOOL)isAccessibilityEnabled
{
return YES;
}
// to avoid warning (why?): method in protocol 'NSAccessibilityElement' not implemented
- (NSRect)accessibilityFrame
{
return [super accessibilityFrame];
}
// to avoid warning (why?): method in protocol 'NSAccessibilityElement' not implemented
- (id)accessibilityParent
{
return [super accessibilityParent];

View File

@@ -1,8 +1,8 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaElementAccessibility.h"
#import "JavaComponentAccessibility.h"
@interface JavaListRowAccessibility : JavaElementAccessibility
@interface JavaListRowAccessibility : JavaComponentAccessibility
@end
@interface PlatformAxListRow : PlatformAxElement <NSAccessibilityRow>

View File

@@ -4,7 +4,6 @@
#import "JavaListRowAccessibility.h"
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "JavaTextAccessibility.h"
#import "JavaListAccessibility.h"
#import "ThreadUtilities.h"
@@ -23,12 +22,12 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
- (NSArray *)accessibilityChildren {
NSArray *children = [super accessibilityChildren];
if (children == NULL) {
JavaBaseAccessibility *newChild = [JavaBaseAccessibility createWithParent:[self javaBase]
accessible:[[self javaBase] accessible]
role:[[self javaBase] javaRole]
index:[[self javaBase] index]
JavaComponentAccessibility *newChild = [JavaComponentAccessibility createWithParent:[self javaComponent]
accessible:[[self javaComponent] accessible]
role:[[self javaComponent] javaRole]
index:[[self javaComponent] index]
withEnv:[ThreadUtilities getJNIEnv]
withView:[[self javaBase] view]
withView:[[self javaComponent] view]
isWrapped:YES];
return [NSArray arrayWithObject:[newChild autorelease].platformAxElement];
} else {
@@ -37,7 +36,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
}
- (NSInteger)accessibilityIndex {
return [super accessibilityIndex];
return [[self accessibilityParent] accessibilityIndexOfChild:self];
}
- (id)accessibilityParent
@@ -45,4 +44,8 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
return [super accessibilityParent];
}
- (NSRect)accessibilityFrame {
return [super accessibilityFrame];
}
@end

View File

@@ -0,0 +1,29 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaStaticTextAccessibility.h"
@interface JavaNavigableTextAccessibility : JavaStaticTextAccessibility
// protocol methods
- (NSValue *)accessibleBoundsForRange:(NSRange)range;
- (NSNumber *)accessibleLineForIndex:(NSInteger)index;
- (NSValue *)accessibleRangeForLine:(NSInteger)line;
- (NSString *)accessibleStringForRange:(NSRange)range;
- (NSValue *)accessibleRangeForIndex:(NSInteger)index;
- (NSValue *)accessibleRangeForPosition:(NSPoint)point;
@property(readonly) NSString *accessibleSelectedText;
@property(readonly) NSValue *accessibleSelectedTextRange;
@property(readonly) NSNumber *accessibleNumberOfCharacters;
@property(readonly) NSNumber *accessibleInsertionPointLineNumber;
@property(readonly) BOOL accessibleIsValueSettable;
@property(readonly) BOOL accessibleIsPasswordText;
- (void)accessibleSetSelectedText:(NSString *)accessibilitySelectedText;
- (void)accessibleSetSelectedTextRange:(NSRange)accessibilitySelectedTextRange;
@end
@interface PlatformAxNavigableText : PlatformAxStaticText <NSAccessibilityNavigableStaticText>
@end

View File

@@ -0,0 +1,267 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaNavigableTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
static JNF_CLASS_CACHE(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
@implementation JavaNavigableTextAccessibility
- (NSString *)getPlatformAxElementClassName {
return @"PlatformAxNavigableText";
}
- (NSString *)accessibleValue {
JNIEnv *env = [ThreadUtilities getJNIEnv];
// cmcnote: inefficient to make three distinct JNI calls. Coalesce. radr://3951923
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return nil;
(*env)->DeleteLocalRef(env, axText);
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return nil;
static JNF_STATIC_MEMBER_CACHE(jm_getTextRange, sjc_CAccessibleText, "getTextRange", "(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;");
jobject jrange = JNFCallStaticObjectMethod(env, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent);
NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop)
(*env)->DeleteLocalRef(env, jrange);
(*env)->DeleteLocalRef(env, axEditableText);
if (string == nil) string = @"";
return string;
}
- (NSValue *)accessibleBoundsForRange:(NSRange)range {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D");
jdoubleArray axBounds = (jdoubleArray)JNFCallStaticObjectMethod(env, jm_getBoundsForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (axBounds == NULL) return nil;
// We cheat because we know that the array is 4 elements long (x, y, width, height)
jdouble *values = (*env)->GetDoubleArrayElements(env, axBounds, 0);
if (values == NULL) {
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
NSLog(@"%s failed calling GetDoubleArrayElements", __FUNCTION__);
return nil;
};
NSRect bounds;
bounds.origin.x = values[0];
bounds.origin.y = [[[[self view] window] screen] frame].size.height - values[1] - values[3]; //values[1] is y-coord from top-left of screen. Flip. Account for the height (values[3]) when flipping
bounds.size.width = values[2];
bounds.size.height = values[3];
NSValue *result = [NSValue valueWithRect:bounds];
(*env)->ReleaseDoubleArrayElements(env, axBounds, values, 0);
return result;
}
- (NSNumber *)accessibleLineForIndex:(NSInteger)index {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForIndex, sjc_CAccessibleText, "getLineNumberForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I");
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
if (row < 0) return nil;
return [NSNumber numberWithInt:row];
}
- (NSValue *)accessibleRangeForLine:(NSInteger)line {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForLine, fAccessible, fComponent, line); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env,axTextRange);
}
- (NSString *)accessibleStringForRange:(NSRange)range {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;");
jstring jstringForRange = (jstring)JNFCallStaticObjectMethod(env, jm_getStringForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
if (jstringForRange == NULL) return @"";
NSString* str = JNFJavaToNSString(env, jstringForRange);
(*env)->DeleteLocalRef(env, jstringForRange);
return str;
}
- (NSValue *)accessibleRangeForIndex:(NSInteger)index {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env, axTextRange);
}
- (NSValue *)accessibleRangeForPosition:(NSPoint)point {
point.y = [[[[self view] window] screen] frame].size.height - point.y; // flip into java screen coords (0 is at upper-left corner of screen)
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getCharacterIndexAtPosition, sjc_CAccessibleText, "getCharacterIndexAtPosition", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)I");
jint charIndex = JNFCallStaticIntMethod(env, jm_getCharacterIndexAtPosition, fAccessible, fComponent, point.x, point.y); // AWT_THREADING Safe (AWTRunLoop)
if (charIndex == -1) return nil;
// AccessibleText.getIndexAtPoint returns -1 for an invalid point
NSRange range = NSMakeRange(charIndex, 1); //range's length is 1 - one-character range
return [NSValue valueWithRange:range];
}
- (NSString *)accessibleSelectedText {
JNIEnv* env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
jobject axText = JNFCallStaticObjectMethod(env, jm_getSelectedText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axText == NULL) return @"";
NSString* str = JNFJavaToNSString(env, axText);
(*env)->DeleteLocalRef(env, axText);
return str;
}
- (NSValue *)accessibleSelectedTextRange {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedTextRange, sjc_CAccessibleText, "getSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getSelectedTextRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env, axTextRange);
}
- (NSNumber *)accessibleNumberOfCharacters {
// cmcnote: should coalesce these two calls - radr://3951923
// also, static text doesn't always have accessibleText. if axText is null, should get the charcount of the accessibleName instead
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
NSNumber* num = [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)];
(*env)->DeleteLocalRef(env, axText);
return num;
}
- (NSNumber *)accessibleInsertionPointLineNumber {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForInsertionPoint, sjc_CAccessibleText, "getLineNumberForInsertionPoint", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForInsertionPoint, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (row < 0) return nil;
return [NSNumber numberWithInt:row];
}
- (BOOL)accessibleIsValueSettable {
// if text is enabled and editable, it's settable (according to NSCellTextAttributesAccessibility)
BOOL isEnabled = [(NSNumber *)[self accessibilityEnabledAttribute] boolValue];
if (!isEnabled) return NO;
JNIEnv* env = [ThreadUtilities getJNIEnv];
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axEditableText == NULL) return NO;
(*env)->DeleteLocalRef(env, axEditableText);
return YES;
}
- (BOOL)accessibleIsPasswordText {
return [[self javaRole] isEqualToString:@"passwordtext"];
}
- (void)accessibleSetSelectedText:(NSString *)accessibilitySelectedText {
JNIEnv *env = [ThreadUtilities getJNIEnv];
jstring jstringValue = JNFNSToJavaString(env, accessibilitySelectedText);
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedText, sjc_CAccessibleText, "setSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;Ljava/lang/String;)V");
JNFCallStaticVoidMethod(env, jm_setSelectedText, fAccessible, fComponent, jstringValue); // AWT_THREADING Safe (AWTRunLoop)
}
- (void)accessibleSetSelectedTextRange:(NSRange)accessibilitySelectedTextRange {
jint startIndex = accessibilitySelectedTextRange.location;
jint endIndex = startIndex + accessibilitySelectedTextRange.length;
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedTextRange, sjc_CAccessibleText, "setSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)V");
JNFCallStaticVoidMethod(env, jm_setSelectedTextRange, fAccessible, fComponent, startIndex, endIndex); // AWT_THREADING Safe (AWTRunLoop)
}
@end
@implementation PlatformAxNavigableText
- (NSRect)accessibilityFrameForRange:(NSRange)range {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleBoundsForRange:range] rectValue];
}
- (NSInteger)accessibilityLineForIndex:(NSInteger)index {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleLineForIndex:index] integerValue];
}
- (NSRange)accessibilityRangeForLine:(NSInteger)line {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleRangeForLine:line] rangeValue];
}
- (NSString *)accessibilityStringForRange:(NSRange)range {
return [(JavaNavigableTextAccessibility *) [self javaComponent] accessibleStringForRange:range];
}
- (id)accessibilityValue {
return [(JavaNavigableTextAccessibility *) [self javaComponent] accessibleValue];
}
- (NSAccessibilitySubrole)accessibilitySubrole {
if ([(JavaNavigableTextAccessibility *) [self javaComponent] accessibleIsPasswordText]) {
return NSAccessibilitySecureTextFieldSubrole;
}
return nil;
}
- (NSRange)accessibilityRangeForIndex:(NSInteger)index {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleRangeForIndex:index] rangeValue];
}
- (NSAccessibilityRole)accessibilityRole {
return [sRoles objectForKey:[self javaComponent].javaRole];
}
- (NSRange)accessibilityRangeForPosition:(NSPoint)point {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleRangeForPosition:point] rangeValue];
}
- (NSString *)accessibilitySelectedText {
return [(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSelectedText];
}
- (NSRange)accessibilitySelectedTextRange {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSelectedTextRange] rangeValue];
}
- (NSInteger)accessibilityNumberOfCharacters {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleNumberOfCharacters] integerValue];
}
- (NSInteger)accessibilityInsertionPointLineNumber {
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleInsertionPointLineNumber] integerValue];
}
- (void)setAccessibilitySelectedText:(NSString *)accessibilitySelectedText {
[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSetSelectedText:accessibilitySelectedText];
}
- (void)setAccessibilitySelectedTextRange:(NSRange)accessibilitySelectedTextRange {
[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSetSelectedTextRange:accessibilitySelectedTextRange];
}
- (BOOL)isAccessibilityEdited {
return YES;
}
- (BOOL)isAccessibilityEnabled {
return YES;
}
/*
* Other text methods
- (NSRange)accessibilitySharedCharacterRange;
- (NSArray *)accessibilitySharedTextUIElements;
- (NSData *)accessibilityRTFForRange:(NSRange)range;
- (NSRange)accessibilityStyleRangeForIndex:(NSInteger)index;
*/
@end

View File

@@ -41,25 +41,29 @@ static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessi
- (NSArray *)accessibilityChildren {
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject currentAccessible = [(JavaOutlineRowAccessibility *)[self javaBase] currentAccessibleWithENV:env];
jobject currentAccessible = [(JavaOutlineRowAccessibility *) [self javaComponent] currentAccessibleWithENV:env];
if (currentAccessible == NULL) {
return nil;
}
JavaBaseAccessibility *currentElement = [JavaBaseAccessibility createWithAccessible:currentAccessible withEnv:env withView:[[self javaBase] view] isCurrent:YES];
NSArray *children = [JavaBaseAccessibility childrenOfParent:currentElement withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
JavaComponentAccessibility *currentElement = [JavaComponentAccessibility createWithAccessible:currentAccessible withEnv:env withView:[[self javaComponent] view] isCurrent:YES];
NSArray *children = [JavaComponentAccessibility childrenOfParent:currentElement withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
if ([children count] == 0) {
return [NSArray arrayWithObject:[JavaBaseAccessibility createWithParent:[self javaBase] accessible:[[self javaBase] accessible] role:[[self javaBase] javaRole] index:[[self javaBase] index] withEnv:env withView:[[self javaBase] view] isWrapped:YES].platformAxElement];
return [NSArray arrayWithObject:[JavaComponentAccessibility createWithParent:[self javaComponent] accessible:[[self javaComponent] accessible] role:[[self javaComponent] javaRole] index:[[self javaComponent] index] withEnv:env withView:[[self javaComponent] view] isWrapped:YES].platformAxElement];
} else {
return children;
}
}
- (NSInteger)accessibilityDisclosureLevel {
return [(JavaOutlineRowAccessibility *)[self javaBase] accessibleLevel];
return [(JavaOutlineRowAccessibility *) [self javaComponent] accessibleLevel];
}
- (BOOL)isAccessibilityDisclosed {
return isExpanded([ThreadUtilities getJNIEnv], [[self javaBase] axContextWithEnv:[ThreadUtilities getJNIEnv]], [[self javaBase] component]);
return isExpanded([ThreadUtilities getJNIEnv], [[self javaComponent] axContextWithEnv:[ThreadUtilities getJNIEnv]], [[self javaComponent] component]);
}
- (NSAccessibilitySubrole)accessibilitySubrole {
return NSAccessibilityOutlineRowSubrole;;
}
@end

View File

@@ -0,0 +1,14 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaComponentAccessibility.h"
@interface JavaScrollAreaAccessibility : JavaComponentAccessibility
@property(readonly) NSArray *accessibleContents;
@property(readonly) id accessibleVerticalScrollBar;
@property(readonly) id accessibleHorizontalScrollBar;
@end
@interface PlatformAxScrollArea : PlatformAxElement
@end

View File

@@ -0,0 +1,99 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaScrollAreaAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
@implementation JavaScrollAreaAccessibility
- (NSString *)getPlatformAxElementClassName {
return @"PlatformAxScrollArea";
}
- (NSArray *)accessibleContents {
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
if ([children count] <= 0) return nil;
NSArray *contents = [NSMutableArray arrayWithCapacity:[children count]];
// The scroll bars are in the children. children less the scroll bars is the contents
NSEnumerator *enumerator = [children objectEnumerator];
id aElement;
while ((aElement = [enumerator nextObject])) {
NSString *nsRole = [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
if (![nsRole isEqualToString:NSAccessibilityScrollBarRole]) {
// no scroll bars in contents
[(NSMutableArray *) contents addObject:aElement];
}
}
return contents;
}
- (id)accessibleVerticalScrollBar {
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
if ([children count] <= 0) return nil;
// The scroll bars are in the children.
NSEnumerator *enumerator = [children objectEnumerator];
id aElement;
while ((aElement = (PlatformAxElement *)[enumerator nextObject])) {
NSString *nsRole = [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
if ([nsRole isEqualToString:NSAccessibilityScrollBarRole]) {
jobject elementAxContext = [[aElement javaComponent] axContextWithEnv:env];
if (isVertical(env, elementAxContext, fComponent)) {
(*env)->DeleteLocalRef(env, elementAxContext);
return aElement;
}
(*env)->DeleteLocalRef(env, elementAxContext);
}
}
return nil;
}
- (id)accessibleHorizontalScrollBar {
JNIEnv *env = [ThreadUtilities getJNIEnv];
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
if ([children count] <= 0) return nil;
// The scroll bars are in the children.
id aElement;
NSEnumerator *enumerator = [children objectEnumerator];
while ((aElement = [enumerator nextObject])) {
NSString *nsRole = [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
if ([nsRole isEqualToString:NSAccessibilityScrollBarRole]) {
jobject elementAxContext = [[aElement javaComponent] axContextWithEnv:env];
if (isHorizontal(env, elementAxContext, fComponent)) {
(*env)->DeleteLocalRef(env, elementAxContext);
return aElement;
}
(*env)->DeleteLocalRef(env, elementAxContext);
}
}
return nil;
}
@end
@implementation PlatformAxScrollArea
- (NSArray *)accessibilityContents {
return [(JavaScrollAreaAccessibility *) [self javaComponent] accessibleContents];
}
- (id)accessibilityVerticalScrollBar {
return [(JavaScrollAreaAccessibility *) [self javaComponent] accessibleVerticalScrollBar];
}
- (id)accessibilityHorizontalScrollBar {
return [(JavaScrollAreaAccessibility *) [self javaComponent] accessibleHorizontalScrollBar];
}
@end

View File

@@ -0,0 +1,19 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaComponentAccessibility.h"
@interface JavaStaticTextAccessibility : JavaComponentAccessibility
/*
* Converts an int array to an NSRange wrapped inside an NSValue
* takes [start, end] values and returns [start, end - start]
*/
NSValue *javaConvertIntArrayToNSRangeValue(JNIEnv* env, jintArray array);
@property(readonly) NSString *accessibleValue;
@property(readonly) NSValue *accessibleVisibleCharacterRange;
@end
@interface PlatformAxStaticText : PlatformAxElement <NSAccessibilityStaticText>
@end

View File

@@ -0,0 +1,72 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaStaticTextAccessibility.h"
#import "JavaAccessibilityUtilities.h"
#import "ThreadUtilities.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
static JNF_CLASS_CACHE(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
@implementation JavaStaticTextAccessibility
- (NSString *)getPlatformAxElementClassName {
return @"PlatformAxStaticText";
}
- (NSString *)accessibleValue {
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axName != NULL) {
NSString* str = JNFJavaToNSString(env, axName);
(*env)->DeleteLocalRef(env, axName);
return str;
}
return @"";
}
- (NSValue *)accessibleVisibleCharacterRange {
JNIEnv *env = [ThreadUtilities getJNIEnv];
static JNF_STATIC_MEMBER_CACHE(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (axTextRange == NULL) return nil;
return javaConvertIntArrayToNSRangeValue(env, axTextRange);
}
@end
@implementation PlatformAxStaticText
- (id)accessibilityValue {
return [(JavaStaticTextAccessibility *) [self javaComponent] accessibleValue];
}
- (NSRect)accessibilityFrame {
return [super accessibilityFrame];
}
- (id)accessibilityParent {
return [super accessibilityParent];
}
- (NSRange)accessibilityVisibleCharacterRange {
return [[(JavaStaticTextAccessibility *) [self javaComponent] accessibleVisibleCharacterRange] rangeValue];
}
@end
NSValue *javaConvertIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
jint *values = (*env)->GetIntArrayElements(env, array, 0);
if (values == NULL) {
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
NSLog(@"%s failed calling GetIntArrayElements", __FUNCTION__);
return nil;
};
NSValue *value = [NSValue valueWithRange:NSMakeRange(values[0], values[1] - values[0])];
(*env)->ReleaseIntArrayElements(env, array, values, 0);
return value;
}

View File

@@ -0,0 +1,19 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
#import "JavaComponentAccessibility.h"
@interface JavaTabButtonAccessibility : JavaComponentAccessibility {
jobject fTabGroupAxContext;
}
// from TabGroup controller
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole;
@property(readonly) jobject tabGroup;
@property(readonly) id accessibleValue;
- (void)performPressAction;
@end
@interface PlatformAxTabButton : PlatformAxElement
@end

Some files were not shown because too many files have changed in this diff Show More