mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-29 04:39:43 +01:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc754d6d76 | ||
|
|
0c3b4bf9b7 | ||
|
|
216bf92575 | ||
|
|
4c6f3e4510 | ||
|
|
8d74e8e30b | ||
|
|
f4a8e51d4a | ||
|
|
db9032755a | ||
|
|
db017fbd56 | ||
|
|
479ceadb35 | ||
|
|
ad1d5061a9 | ||
|
|
ff0a538ebd | ||
|
|
c81adfed61 | ||
|
|
2ccf6b65a7 | ||
|
|
a34eeb7735 | ||
|
|
ba6b9c085e | ||
|
|
04f1cf9b47 | ||
|
|
80c6e03ec4 | ||
|
|
9001a78701 | ||
|
|
703cab8d0d | ||
|
|
3c9cdc9251 | ||
|
|
032805520d | ||
|
|
b37f7cfdb1 | ||
|
|
3668d631ca | ||
|
|
7fa3ea24ac | ||
|
|
8a521cbf64 | ||
|
|
fe9601aa6d | ||
|
|
65e8162d67 | ||
|
|
b99be427ce | ||
|
|
6b3b011d0b | ||
|
|
b53ef867e4 | ||
|
|
215fd32738 | ||
|
|
921603e356 | ||
|
|
542ee611fc | ||
|
|
99a8e45598 | ||
|
|
f096bd2b0d | ||
|
|
26dd87ab7c | ||
|
|
a6ea081ba2 | ||
|
|
2e87610593 | ||
|
|
1c336fc03a | ||
|
|
8eafcaab24 | ||
|
|
c096f12994 | ||
|
|
5cfc8b3629 | ||
|
|
65b3d32eca | ||
|
|
61de3c3065 | ||
|
|
3b101f673b | ||
|
|
bd79159249 | ||
|
|
ca4425cb21 | ||
|
|
b386e44bf5 | ||
|
|
03995a0327 | ||
|
|
bd6a088aaf | ||
|
|
c2582f8e03 | ||
|
|
c122e27068 | ||
|
|
52a2428c28 | ||
|
|
87b60afdf7 | ||
|
|
10069846d5 | ||
|
|
f06f9fe734 | ||
|
|
348e538d10 | ||
|
|
5b9ff9a29e | ||
|
|
62b04983f2 | ||
|
|
c40b9c8b9e | ||
|
|
46dfaeecc9 | ||
|
|
e03c9829e3 | ||
|
|
97c0e96a5a |
6
.idea/copyright/JetBrains.xml
generated
6
.idea/copyright/JetBrains.xml
generated
@@ -1,9 +1,7 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright 2000-&#36;today.year JetBrains s.r.o. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and 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-&#36;today.year JetBrains s.r.o. 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. 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." />
|
||||
<option name="myName" value="JetBrains" />
|
||||
<option name="myLocal" value="true" />
|
||||
</copyright>
|
||||
</component>
|
||||
@@ -1,12 +1,5 @@
|
||||
[](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
|
||||
|
||||
# Downloads
|
||||
|
||||
|Windows-x64 |macOS |Linux-x64 |
|
||||
|-------------|-------------|-------------|
|
||||
|[  ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-windows-x64/_latestVersion)|[  ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-osx-x64/_latestVersion)|[  ](https://bintray.com/jetbrains/intellij-jdk/openjdk11-linux-x64/_latestVersion)|
|
||||
|
||||
|
||||
# How JetBrains Runtime is organised
|
||||
## Workspaces
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -572,105 +572,43 @@ endif
|
||||
###########################################################################
|
||||
|
||||
ifeq ($(USE_EXTERNAL_HARFBUZZ), true)
|
||||
LIBHARFBUZZ_LIBS := $(HARFBUZZ_LIBS)
|
||||
LIBFONTMANAGER_EXTRA_SRC =
|
||||
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBHARFBUZZ_LIBS)
|
||||
else
|
||||
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
|
||||
# This is better than adding EXPORT_ALL_SYMBOLS
|
||||
ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang solstudio), )
|
||||
HARFBUZZ_CFLAGS += -DHB_EXTERN=__attribute__\(\(visibility\(\"default\"\)\)\)
|
||||
else ifeq ($(TOOLCHAIN_TYPE), microsoft)
|
||||
HARFBUZZ_CFLAGS += -DHB_EXTERN=__declspec\(dllexport\)
|
||||
endif
|
||||
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
|
||||
|
||||
LIBHARFBUZZ_LDFLAGS := $(LDFLAGS_JDKLIB) \
|
||||
$(call SET_SHARED_LIBRARY_ORIGIN)
|
||||
ifeq ($(TOOLCHAIN_TYPE), gcc)
|
||||
ifeq ($(CC_VERSION_NUMBER), 4.4.7)
|
||||
LIBHARFBUZZ_LDFLAGS := $(subst -Xlinker -z -Xlinker defs,, \
|
||||
$(subst -Wl$(COMMA)-z$(COMMA)defs,,$(LDFLAGS_JDKLIB))) \
|
||||
$(call SET_SHARED_LIBRARY_ORIGIN)
|
||||
endif
|
||||
endif
|
||||
# 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
|
||||
|
||||
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
|
||||
HARFBUZZ_EXTRA_HEADER_DIRS := \
|
||||
libharfbuzz/hb-ucdn
|
||||
|
||||
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-coretext.cc
|
||||
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
|
||||
|
||||
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
|
||||
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-ft.cc
|
||||
|
||||
LIBHARFBUZZ_CFLAGS += $(HARFBUZZ_CFLAGS)
|
||||
|
||||
# For use by libfontmanager:
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
LIBHARFBUZZ_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjharfbuzz/jharfbuzz.lib
|
||||
else ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
LIBHARFBUZZ_LIBS := -ljharfbuzz
|
||||
endif
|
||||
|
||||
LIBHARFBUZZ_EXTRA_HEADER_DIRS := \
|
||||
libjharfbuzz/hb-ucdn \
|
||||
#
|
||||
|
||||
LIBHARFBUZZ_OPTIMIZATION := HIGH
|
||||
|
||||
LIBHARFBUZZ_CFLAGS += $(X_CFLAGS) -DLE_STANDALONE -DHEADLESS
|
||||
|
||||
$(eval $(call SetupJdkLibrary, BUILD_LIBHARFBUZZ, \
|
||||
NAME := jharfbuzz, \
|
||||
EXCLUDE_FILES := $(LIBHARFBUZZ_EXCLUDE_FILES), \
|
||||
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
|
||||
CFLAGS := $(CFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
|
||||
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
|
||||
OPTIMIZATION := $(LIBHARFBUZZ_OPTIMIZATION), \
|
||||
CFLAGS_windows = -DCC_NOEX, \
|
||||
EXTRA_HEADER_DIRS := $(LIBHARFBUZZ_EXTRA_HEADER_DIRS), \
|
||||
WARNINGS_AS_ERRORS_xlc := false, \
|
||||
DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing, \
|
||||
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
|
||||
maybe-uninitialized class-memaccess, \
|
||||
DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
|
||||
tautological-constant-out-of-range-compare int-to-pointer-cast \
|
||||
undef missing-field-initializers, \
|
||||
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 4090 4146 4334 4819 4101 4068 4805 4138, \
|
||||
LDFLAGS := $(LIBHARFBUZZ_LDFLAGS), \
|
||||
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
|
||||
LDFLAGS_aix := -Wl$(COMMA)-berok, \
|
||||
LIBS := $(BUILD_LIBHARFBUZZ), \
|
||||
LIBS_unix := $(LIBM) $(LIBCXX), \
|
||||
LIBS_macosx := -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
|
||||
LIBS_windows := user32.lib, \
|
||||
))
|
||||
|
||||
ifeq ($(FREETYPE_TO_USE), bundled)
|
||||
$(BUILD_LIBHARFBUZZ): $(BUILD_LIBFREETYPE)
|
||||
endif
|
||||
|
||||
TARGETS += $(BUILD_LIBHARFBUZZ)
|
||||
LIBFONTMANAGER_CFLAGS += $(HARFBUZZ_CFLAGS)
|
||||
|
||||
endif
|
||||
|
||||
###########################################################################
|
||||
|
||||
LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
|
||||
libjharfbuzz \
|
||||
libharfbuzz \
|
||||
common/awt \
|
||||
common/font \
|
||||
libawt/java2d \
|
||||
@@ -678,10 +616,10 @@ LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
|
||||
libawt/java2d/loops \
|
||||
#
|
||||
|
||||
LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS) $(HARFBUZZ_FLAGS)
|
||||
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBHARFBUZZ_LIBS) $(LIBFREETYPE_LIBS)
|
||||
LIBFONTMANAGER_CFLAGS += $(LIBFREETYPE_CFLAGS)
|
||||
BUILD_LIBFONTMANAGER_FONTLIB += $(LIBFREETYPE_LIBS)
|
||||
|
||||
LIBFONTMANAGER_OPTIMIZATION := HIGH
|
||||
LIBFONTMANAGER_OPTIMIZATION := HIGHEST
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
|
||||
@@ -720,18 +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 unused-function int-to-pointer-cast, \
|
||||
DISABLED_WARNINGS_clang := sign-compare, \
|
||||
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 := 4018 4146 4244 4996 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), \
|
||||
@@ -739,17 +672,13 @@ $(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, \
|
||||
LIBS_macosx := -lawt_lwawt -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
|
||||
LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \
|
||||
$(WIN_AWT_LIB), \
|
||||
))
|
||||
|
||||
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
|
||||
|
||||
ifeq ($(USE_EXTERNAL_HARFBUZZ), false)
|
||||
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBHARFBUZZ)
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
$(BUILD_LIBFONTMANAGER): $(call FindLib, $(MODULE), awt_lwawt)
|
||||
endif
|
||||
|
||||
@@ -54,4 +54,5 @@ jdk.security.jgss,
|
||||
jdk.unsupported,
|
||||
jdk.xml.dom,
|
||||
jdk.zipfs,
|
||||
jdk.hotspot.agent
|
||||
jdk.hotspot.agent,
|
||||
jdk.jcmd
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) { }
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,4 @@ package com.apple.eawt;
|
||||
|
||||
interface _OpenAppHandler {
|
||||
void handleOpenApp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <jni.h>
|
||||
|
||||
extern NSMutableDictionary *sActions;
|
||||
extern NSMutableDictionary *sActionSelectores;
|
||||
extern NSMutableArray *sAllActionSelectores;
|
||||
void initializeActions();
|
||||
|
||||
@protocol JavaAccessibilityAction
|
||||
|
||||
|
||||
@@ -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))];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,93 @@
|
||||
// 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 "JavaTabButtonAccessibility.h"
|
||||
#import "JavaAccessibilityAction.h"
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
static BOOL javaObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component);
|
||||
|
||||
@implementation JavaTabButtonAccessibility
|
||||
|
||||
- (NSString *)getPlatformAxElementClassName {
|
||||
return @"PlatformAxTabButton";
|
||||
}
|
||||
|
||||
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole {
|
||||
self = [super initWithParent:parent withEnv:env withAccessible:accessible withIndex:index withView:view withJavaRole:javaRole];
|
||||
if (self) {
|
||||
if (tabGroup != NULL) {
|
||||
fTabGroupAxContext = JNFNewWeakGlobalRef(env, tabGroup);
|
||||
} else {
|
||||
fTabGroupAxContext = NULL;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (jobject)tabGroup {
|
||||
if (fTabGroupAxContext == NULL) {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject tabGroupAxContext = [(JavaComponentAccessibility *)[self parent] axContextWithEnv:env];
|
||||
fTabGroupAxContext = JNFNewWeakGlobalRef(env, tabGroupAxContext);
|
||||
(*env)->DeleteLocalRef(env, tabGroupAxContext);
|
||||
}
|
||||
return fTabGroupAxContext;
|
||||
}
|
||||
|
||||
- (id)accessibleValue {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
jobject selAccessible = getAxContextSelection(env, [self tabGroup], fIndex, fComponent);
|
||||
|
||||
// Returns the current selection of the page tab list
|
||||
id val = [NSNumber numberWithBool:javaObjectEquals(env, axContext, selAccessible, fComponent)];
|
||||
|
||||
(*env)->DeleteLocalRef(env, selAccessible);
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
return val;
|
||||
}
|
||||
|
||||
- (void)performPressAction {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
TabGroupAction *action = [[TabGroupAction alloc] initWithEnv:env withTabGroup:[self tabGroup] withIndex:fIndex withComponent:fComponent];
|
||||
[action perform];
|
||||
[action release];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PlatformAxTabButton
|
||||
|
||||
- (NSAccessibilitySubrole)accessibilitySubrole {
|
||||
return NSAccessibilityTabButtonSubrole;
|
||||
}
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaTabButtonAccessibility *) [self javaComponent] accessibleValue];
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityPerformPress {
|
||||
[(JavaTabButtonAccessibility *) [self javaComponent] performPressAction];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_Object, "java/lang/Object");
|
||||
static BOOL javaObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component) {
|
||||
static JNF_MEMBER_CACHE(jm_equals, sjc_Object, "equals", "(Ljava/lang/Object;)Z");
|
||||
|
||||
if ((a == NULL) && (b == NULL)) return YES;
|
||||
if ((a == NULL) || (b == NULL)) return NO;
|
||||
|
||||
if (pthread_main_np() != 0) {
|
||||
// If we are on the AppKit thread
|
||||
static JNF_CLASS_CACHE(sjc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_doEquals, sjc_LWCToolkit, "doEquals", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/awt/Component;)Z");
|
||||
return JNFCallStaticBooleanMethod(env, jm_doEquals, a, b, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
}
|
||||
|
||||
return JNFCallBooleanMethod(env, a, jm_equals, b); // AWT_THREADING Safe (!appKit)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// 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 JavaTabGroupAccessibility : JavaComponentAccessibility {
|
||||
NSInteger _numTabs;
|
||||
}
|
||||
|
||||
- (id)currentTabWithEnv:(JNIEnv *)env withAxContext:(jobject)axContext;
|
||||
- (NSArray *)tabButtonsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
|
||||
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
|
||||
|
||||
@property(readonly) NSArray *accessibleTabs;
|
||||
@property(readonly) NSArray *accessibleContents;
|
||||
@property(readonly) id accessibleValue;
|
||||
@property(readonly) NSInteger numTabs;
|
||||
|
||||
@end
|
||||
|
||||
@interface PlatformAxTabGroup : PlatformAxElement
|
||||
@end
|
||||
@@ -0,0 +1,179 @@
|
||||
// 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 "JavaTabGroupAccessibility.h"
|
||||
#import "JavaTabButtonAccessibility.h"
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;");
|
||||
|
||||
@implementation JavaTabGroupAccessibility
|
||||
|
||||
- (NSString *)getPlatformAxElementClassName {
|
||||
return @"PlatformAxTabGroup";
|
||||
}
|
||||
|
||||
- (id)currentTabWithEnv:(JNIEnv *)env withAxContext:(jobject)axContext {
|
||||
NSArray *tabs = [self tabButtonsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
|
||||
|
||||
// Looking at the JTabbedPane sources, there is always one AccessibleSelection.
|
||||
jobject selAccessible = getAxContextSelection(env, axContext, 0, fComponent);
|
||||
if (selAccessible == NULL) return nil;
|
||||
|
||||
// Go through the tabs and find selAccessible
|
||||
_numTabs = [tabs count];
|
||||
JavaComponentAccessibility *aTab;
|
||||
NSInteger i;
|
||||
for (i = 0; i < _numTabs; i++) {
|
||||
aTab = [(PlatformAxElement *) [tabs objectAtIndex:i] javaComponent];
|
||||
if ([aTab isAccessibleWithEnv:env forAccessible:selAccessible]) {
|
||||
(*env)->DeleteLocalRef(env, selAccessible);
|
||||
return [aTab platformAxElement];
|
||||
}
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, selAccessible);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *)tabButtonsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored {
|
||||
jobjectArray jtabsAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, fAccessible, fComponent, whichTabs, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
|
||||
if(jtabsAndRoles == NULL) return nil;
|
||||
|
||||
jsize arrayLen = (*env)->GetArrayLength(env, jtabsAndRoles);
|
||||
if (arrayLen == 0) {
|
||||
(*env)->DeleteLocalRef(env, jtabsAndRoles);
|
||||
return nil;
|
||||
}
|
||||
NSMutableArray *tabs = [NSMutableArray arrayWithCapacity:(arrayLen/2)];
|
||||
|
||||
// all of the tabs have the same role, so we can just find out what that is here and use it for all the tabs
|
||||
jobject jtabJavaRole = (*env)->GetObjectArrayElement(env, jtabsAndRoles, 1); // the array entries alternate between tab/role, starting with tab. so the first role is entry 1.
|
||||
if (jtabJavaRole == NULL) {
|
||||
(*env)->DeleteLocalRef(env, jtabsAndRoles);
|
||||
return nil;
|
||||
}
|
||||
jobject jkey = JNFGetObjectField(env, jtabJavaRole, sjf_key);
|
||||
NSString *tabJavaRole = JNFJavaToNSString(env, jkey);
|
||||
(*env)->DeleteLocalRef(env, jkey);
|
||||
|
||||
NSInteger i;
|
||||
NSUInteger tabIndex = (whichTabs >= 0) ? whichTabs : 0; // if we're getting one particular child, make sure to set its index correctly
|
||||
for(i = 0; i < arrayLen; i+=2) {
|
||||
jobject jtab = (*env)->GetObjectArrayElement(env, jtabsAndRoles, i);
|
||||
JavaComponentAccessibility *tab = [[[JavaTabButtonAccessibility alloc] initWithParent:self withEnv:env withAccessible:jtab withIndex:tabIndex withTabGroup:axContext withView:[self view] withJavaRole:tabJavaRole] autorelease];
|
||||
(*env)->DeleteLocalRef(env, jtab);
|
||||
[tabs addObject:[tab platformAxElement]];
|
||||
tabIndex++;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, jtabsAndRoles);
|
||||
return tabs;
|
||||
}
|
||||
|
||||
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored {
|
||||
// Contents are the children of the selected tab.
|
||||
PlatformAxElement *currentTab = [self currentTabWithEnv:env withAxContext:axContext];
|
||||
if (currentTab == nil) return nil;
|
||||
|
||||
NSArray *contents = [JavaComponentAccessibility childrenOfParent:[currentTab javaComponent] withEnv:env withChildrenCode:whichTabs allowIgnored:allowIgnored];
|
||||
if ([contents count] <= 0) return nil;
|
||||
return contents;
|
||||
}
|
||||
|
||||
- (NSArray *)accessibleTabs {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
id tabs = [self tabButtonsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
return tabs;
|
||||
}
|
||||
|
||||
- (NSArray *) accessibleContents {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
NSArray* cont = [self contentsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
return cont;
|
||||
}
|
||||
|
||||
-(id) accessibleValue {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
id val = [self currentTabWithEnv:env withAxContext:axContext];
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
return val;
|
||||
}
|
||||
|
||||
- (NSInteger)numTabs {
|
||||
return _numTabs;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PlatformAxTabGroup
|
||||
|
||||
- (NSArray *)accessibilityTabs {
|
||||
return [(JavaTabGroupAccessibility *) [self javaComponent] accessibleTabs];
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilityContents {
|
||||
return [(JavaTabGroupAccessibility *) [self javaComponent] accessibleContents];
|
||||
}
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaTabGroupAccessibility *) [self javaComponent] accessibleValue];
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilityChildren {
|
||||
//children = AXTabs + AXContents
|
||||
NSArray *tabs = [self accessibilityTabs];
|
||||
NSArray *contents = [self accessibilityContents];
|
||||
|
||||
NSMutableArray *children = [NSMutableArray arrayWithCapacity:[tabs count] + [contents count]];
|
||||
[children addObjectsFromArray:tabs];
|
||||
[children addObjectsFromArray:contents];
|
||||
|
||||
return (NSArray *)children;
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilityArrayAttributeValues:(NSAccessibilityAttributeName)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount {
|
||||
NSArray *result = nil;
|
||||
if ( (maxCount == 1) && [attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
||||
// Children codes for ALL, SELECTED, VISIBLE are <0. If the code is >=0, we treat it as an index to a single child
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [(JavaTabGroupAccessibility *) [self javaComponent] axContextWithEnv:env];
|
||||
|
||||
//children = AXTabs + AXContents
|
||||
NSArray *children = [(JavaTabGroupAccessibility *) [self javaComponent] tabButtonsWithEnv:env
|
||||
withTabGroupAxContext:axContext
|
||||
withTabCode:index
|
||||
allowIgnored:NO]; // first look at the tabs
|
||||
if ([children count] > 0) {
|
||||
result = children;
|
||||
} else {
|
||||
children= [(JavaTabGroupAccessibility *) [self javaComponent] contentsWithEnv:env
|
||||
withTabGroupAxContext:axContext
|
||||
withTabCode:(index-[(JavaTabGroupAccessibility *) [self javaComponent] numTabs])
|
||||
allowIgnored:NO];
|
||||
if ([children count] > 0) {
|
||||
result = children;
|
||||
}
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
} else {
|
||||
result = [super accessibilityArrayAttributeValues:attribute index:index maxCount:maxCount];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)setAccessibilityValue:(id)accessibilityValue {
|
||||
NSNumber *number = (NSNumber *)accessibilityValue;
|
||||
if (![number boolValue]) return;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
setAxContextSelection(env, axContext, [[self javaComponent] index], [[self javaComponent] component]);
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -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 JavaTableAccessibility : JavaElementAccessibility
|
||||
@interface JavaTableAccessibility : JavaComponentAccessibility
|
||||
|
||||
@property(readonly) int accessibleRowCount;
|
||||
@property(readonly) int accessibleColCount;
|
||||
|
||||
@@ -57,6 +57,7 @@ static const char* ACCESSIBLE_JTABLE_NAME = "javax.swing.JTable$AccessibleJTable
|
||||
for (int i = 0; i < arrayLen; i++) {
|
||||
[nsArraySelectidRowNumbers addObject:[NSNumber numberWithInt:indexsis[i]]];
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, selectidRowNumbers);
|
||||
return [NSArray<NSNumber *> arrayWithArray:nsArraySelectidRowNumbers];
|
||||
}
|
||||
|
||||
@@ -76,18 +77,17 @@ static const char* ACCESSIBLE_JTABLE_NAME = "javax.swing.JTable$AccessibleJTable
|
||||
for (int i = 0; i < arrayLen; i++) {
|
||||
[nsArraySelectidColumnNumbers addObject:[NSNumber numberWithInt:indexsis[i]]];
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, selectidColumnNumbers);
|
||||
return [NSArray<NSNumber *> arrayWithArray:nsArraySelectidColumnNumbers];
|
||||
}
|
||||
|
||||
- (int)accessibleRowAtIndex:(int)index {
|
||||
printf("Пришёл индекс %d\n", index);
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNFClassInfo clsInfo;
|
||||
clsInfo.name = ACCESSIBLE_JTABLE_NAME;
|
||||
clsInfo.cls = (*env)->GetObjectClass(env, [self axContextWithEnv:env]);
|
||||
JNF_MEMBER_CACHE(jm_getAccessibleRowAtIndex, clsInfo, "getAccessibleRowAtIndex", "(I)I");
|
||||
jint rowAtIndex = JNFCallIntMethod(env, [self axContextWithEnv:env], jm_getAccessibleRowAtIndex, (jint)index);
|
||||
printf("Получен индекс %d\n", rowAtIndex);
|
||||
return (int)rowAtIndex;
|
||||
}
|
||||
|
||||
@@ -145,28 +145,28 @@ static const char* ACCESSIBLE_JTABLE_NAME = "javax.swing.JTable$AccessibleJTable
|
||||
}
|
||||
|
||||
- (nullable NSArray *)accessibilityColumns {
|
||||
int colCount = [(JavaTableAccessibility *)[self javaBase] accessibleColCount];
|
||||
int colCount = [(JavaTableAccessibility *) [self javaComponent] accessibleColCount];
|
||||
NSMutableArray *columns = [NSMutableArray arrayWithCapacity:colCount];
|
||||
for (int i = 0; i < colCount; i++) {
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaBase]
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaComponent]
|
||||
withEnv:[ThreadUtilities getJNIEnv]
|
||||
withAccessible:NULL
|
||||
withIndex:i
|
||||
withView:[[self javaBase] view]
|
||||
withView:[[self javaComponent] view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
return [NSArray arrayWithArray:columns];
|
||||
}
|
||||
|
||||
- (nullable NSArray *)accessibilitySelectedColumns {
|
||||
NSArray<NSNumber *> *indexes = [(JavaTableAccessibility *)[self javaBase] selectedAccessibleColumns];
|
||||
NSArray<NSNumber *> *indexes = [(JavaTableAccessibility *) [self javaComponent] selectedAccessibleColumns];
|
||||
NSMutableArray *columns = [NSMutableArray arrayWithCapacity:[indexes count]];
|
||||
for (NSNumber *i in indexes) {
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaBase]
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaComponent]
|
||||
withEnv:[ThreadUtilities getJNIEnv]
|
||||
withAccessible:NULL
|
||||
withIndex:i.unsignedIntValue
|
||||
withView:[[self javaBase] view]
|
||||
withView:[[self javaComponent] view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
return [NSArray arrayWithArray:columns];
|
||||
|
||||
@@ -1,13 +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.
|
||||
|
||||
#ifndef JavaTableRowAccessibility_h
|
||||
#define JavaTableRowAccessibility_h
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
|
||||
#endif /* JavaTableRowAccessibility_h */
|
||||
#import "JavaElementAccessibility.h"
|
||||
|
||||
@interface JavaTableRowAccessibility : JavaElementAccessibility
|
||||
@interface JavaTableRowAccessibility : JavaComponentAccessibility
|
||||
@end
|
||||
|
||||
@interface PlatformAxTableRow : PlatformAxElement <NSAccessibilityRow>
|
||||
|
||||
@@ -24,17 +24,17 @@ 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);
|
||||
NSMutableArray *childrenCells = [NSMutableArray arrayWithCapacity:arrayLen/2];
|
||||
|
||||
NSUInteger childIndex = [self rowNumberInTable] * [(JavaTableAccessibility *)[[self accessibilityParent] javaBase] accessibleColCount];
|
||||
NSUInteger childIndex = [self rowNumberInTable] * [(JavaTableAccessibility *) [[self accessibilityParent] javaComponent] accessibleColCount];
|
||||
NSInteger i = childIndex * 2;
|
||||
NSInteger n = ([self rowNumberInTable] + 1) * [(JavaTableAccessibility *)[[self accessibilityParent] javaBase] accessibleColCount] * 2;
|
||||
JavaTableRowAccessibility *selfRow = [self javaBase];
|
||||
NSInteger n = ([self rowNumberInTable] + 1) * [(JavaTableAccessibility *) [[self accessibilityParent] javaComponent] accessibleColCount] * 2;
|
||||
JavaTableRowAccessibility *selfRow = [self javaComponent];
|
||||
for(i; i < n; i+=2)
|
||||
{
|
||||
jobject /* Accessible */ jchild = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i);
|
||||
@@ -68,7 +68,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityIndex {
|
||||
return [[self javaBase] index];
|
||||
return [[self accessibilityParent] accessibilityIndexOfChild:self];
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityLabel {
|
||||
@@ -89,7 +89,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
}
|
||||
|
||||
- (NSUInteger)rowNumberInTable {
|
||||
return [[self javaBase] index];
|
||||
return [[self javaComponent] index];
|
||||
}
|
||||
|
||||
- (NSRect)accessibilityFrame {
|
||||
@@ -102,5 +102,9 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
return NSMakeRect(point.x, point.y, width, height);
|
||||
}
|
||||
|
||||
- (NSAccessibilitySubrole)accessibilitySubrole {
|
||||
return NSAccessibilityTableRowSubrole;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
#import <AppKit/NSAccessibility.h>
|
||||
|
||||
|
||||
@interface JavaTextAccessibility : JavaComponentAccessibility {
|
||||
|
||||
}
|
||||
// attributes
|
||||
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
|
||||
- (NSString *)accessibilityValueAttribute;
|
||||
- (BOOL)accessibilityIsValueAttributeSettable;
|
||||
- (void)accessibilitySetValueAttribute:(id)value;
|
||||
- (NSString *)accessibilitySelectedTextAttribute;
|
||||
- (BOOL)accessibilityIsSelectedTextAttributeSettable;
|
||||
- (NSValue *)accessibilitySelectedTextRangeAttribute;
|
||||
- (BOOL)accessibilityIsSelectedTextRangeAttributeSettable;
|
||||
- (NSNumber *)accessibilityNumberOfCharactersAttribute;
|
||||
- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable;
|
||||
- (NSValue *)accessibilityVisibleCharacterRangeAttribute;
|
||||
- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable;
|
||||
- (NSValue *)accessibilityInsertionPointLineNumberAttribute;
|
||||
- (BOOL)accessibilityIsInsertionPointLineNumberAttributeSettable;
|
||||
- (void)accessibilitySetSelectedTextAttribute:(id)value;
|
||||
- (NSValue *)accessibilitySelectedTextRangeAttribute;
|
||||
- (NSValue *)accessibilityInsertionPointLineNumberAttribute;
|
||||
- (BOOL)accessibilityIsInsertionPointLineNumberAttributeSettable;
|
||||
|
||||
// parameterized attributes
|
||||
- (NSArray *)accessibilityParameterizedAttributeNames;
|
||||
- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter;
|
||||
- (NSNumber *)accessibilityLineForIndexAttributeForParameter:(id)parameter;
|
||||
- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter;
|
||||
- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter;
|
||||
- (NSValue *)accessibilityRangeForPositionAttributeForParameter:(id)parameter;
|
||||
- (NSValue *)accessibilityRangeForIndexAttributeForParameter:(id)parameter;
|
||||
|
||||
@end
|
||||
@@ -1,441 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "JavaTextAccessibility.h"
|
||||
#import "JavaAccessibilityAction.h"
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "ThreadUtilities.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;");
|
||||
|
||||
/*
|
||||
* Converts an int array to an NSRange wrapped inside an NSValue
|
||||
* takes [start, end] values and returns [start, end - start]
|
||||
*/
|
||||
NSValue *javaIntArrayToNSRangeValue(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;
|
||||
}
|
||||
|
||||
@implementation JavaTextAccessibility
|
||||
|
||||
// based strongly upon NSTextViewAccessibility:accessibilityAttributeNames
|
||||
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
|
||||
{
|
||||
static NSArray *attributes = nil;
|
||||
|
||||
if (attributes == nil) {
|
||||
//APPKIT_LOCK;
|
||||
if (attributes == nil) {
|
||||
NSMutableArray *temp = [[super initializeAttributeNamesWithEnv:env] mutableCopy];
|
||||
//[temp removeObject:NSAccessibilityTitleAttribute]; // title may have been set in the superclass implementation - some static text reports from java that it has a name
|
||||
[temp addObjectsFromArray:[NSArray arrayWithObjects:
|
||||
NSAccessibilityValueAttribute,
|
||||
NSAccessibilitySelectedTextAttribute,
|
||||
NSAccessibilitySelectedTextRangeAttribute,
|
||||
NSAccessibilityNumberOfCharactersAttribute,
|
||||
NSAccessibilityVisibleCharacterRangeAttribute,
|
||||
NSAccessibilityInsertionPointLineNumberAttribute,
|
||||
// NSAccessibilitySharedTextUIElementsAttribute, // cmcnote: investigate what these two are for. currently unimplemented
|
||||
// NSAccessibilitySharedCharacterRangeAttribute,
|
||||
nil]];
|
||||
attributes = [[NSArray alloc] initWithArray:temp];
|
||||
[temp release];
|
||||
}
|
||||
//APPKIT_UNLOCK;
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
// copied from NSTextViewAccessibility.
|
||||
- (NSArray *)accessibilityParameterizedAttributeNames
|
||||
{
|
||||
static NSArray *attributes = nil;
|
||||
|
||||
if (attributes == nil) {
|
||||
//APPKIT_LOCK;
|
||||
if (attributes == nil) {
|
||||
attributes = [[NSArray alloc] initWithObjects:
|
||||
NSAccessibilityLineForIndexParameterizedAttribute,
|
||||
NSAccessibilityRangeForLineParameterizedAttribute,
|
||||
NSAccessibilityStringForRangeParameterizedAttribute,
|
||||
NSAccessibilityRangeForPositionParameterizedAttribute,
|
||||
NSAccessibilityRangeForIndexParameterizedAttribute,
|
||||
NSAccessibilityBoundsForRangeParameterizedAttribute,
|
||||
//NSAccessibilityRTFForRangeParameterizedAttribute, // cmcnote: not sure when/how these three are used. Investigate. radr://3960026
|
||||
//NSAccessibilityStyleRangeForIndexParameterizedAttribute,
|
||||
//NSAccessibilityAttributedStringForRangeParameterizedAttribute,
|
||||
nil];
|
||||
}
|
||||
//APPKIT_UNLOCK;
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityValueAttribute
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
if ([[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityStaticTextRole]) {
|
||||
// if it's static text, the AppKit AXValue is the java accessibleName
|
||||
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;
|
||||
}
|
||||
// value is still nil if no accessibleName for static text. Below, try to get the accessibleText.
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsValueAttributeSettable
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
- (void)accessibilitySetValueAttribute:(id)value
|
||||
{
|
||||
// cmcnote: should set the accessibleEditableText to the stringValue of value - AccessibleEditableText.setTextContents(String s)
|
||||
#ifdef JAVA_AX_DEBUG
|
||||
NSLog(@"Not yet implemented: %s\n", __FUNCTION__); // radr://3954018
|
||||
#endif
|
||||
}
|
||||
|
||||
// Currently selected text (NSString)
|
||||
- (NSString *)accessibilitySelectedTextAttribute
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsSelectedTextAttributeSettable
|
||||
{
|
||||
return YES; //cmcnote: for AXTextField that's selectable, it's settable. Investigate further.
|
||||
}
|
||||
|
||||
- (void)accessibilitySetSelectedTextAttribute:(id)value
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG_PARMS
|
||||
if (![value isKindOfClass:[NSString class]]) {
|
||||
JavaAccessibilityRaiseSetAttributeToIllegalTypeException(__FUNCTION__, self, NSAccessibilitySelectedTextAttribute, value);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jstring jstringValue = JNFNSToJavaString(env, (NSString *)value);
|
||||
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)
|
||||
}
|
||||
|
||||
// Range of selected text (NSValue)
|
||||
- (NSValue *)accessibilitySelectedTextRangeAttribute
|
||||
{
|
||||
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 javaIntArrayToNSRangeValue(env, axTextRange);
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsSelectedTextRangeAttributeSettable
|
||||
{
|
||||
return [(NSNumber *)[self accessibilityEnabledAttribute] boolValue]; // cmcnote: also may want to find out if isSelectable. Investigate.
|
||||
}
|
||||
|
||||
- (void)accessibilitySetSelectedTextRangeAttribute:(id)value
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG_PARMS
|
||||
if (!([value isKindOfClass:[NSValue class]] && strcmp([(NSValue *)value objCType], @encode(NSRange)) == 0)) {
|
||||
JavaAccessibilityRaiseSetAttributeToIllegalTypeException(__FUNCTION__, self, NSAccessibilitySelectedTextRangeAttribute, value);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSRange range = [(NSValue *)value rangeValue];
|
||||
jint startIndex = range.location;
|
||||
jint endIndex = startIndex + range.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)
|
||||
}
|
||||
|
||||
- (NSNumber *)accessibilityNumberOfCharactersAttribute
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsNumberOfCharactersAttributeSettable
|
||||
{
|
||||
return NO; // according to NSTextViewAccessibility.m and NSCellTextAttributesAccessibility.m
|
||||
}
|
||||
|
||||
- (NSValue *)accessibilityVisibleCharacterRangeAttribute
|
||||
{
|
||||
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 javaIntArrayToNSRangeValue(env, axTextRange);
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsVisibleCharacterRangeAttributeSettable
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG
|
||||
NSLog(@"Not yet implemented: %s\n", __FUNCTION__);
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSValue *)accessibilityInsertionPointLineNumberAttribute
|
||||
{
|
||||
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)accessibilityIsInsertionPointLineNumberAttributeSettable
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG
|
||||
NSLog(@"Not yet implemented: %s\n", __FUNCTION__);
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
|
||||
// parameterized attributes
|
||||
|
||||
//
|
||||
// Usage of accessibilityBoundsForRangeAttributeForParameter:
|
||||
// ---
|
||||
// called by VoiceOver when interacting with text via ctrl-option-shift-downArrow.
|
||||
// Need to know bounding box for the character / word / line of interest in
|
||||
// order to draw VoiceOver cursor
|
||||
//
|
||||
- (NSValue *)accessibilityBoundsForRangeAttributeForParameter:(id)parameter
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG_PARMS
|
||||
if (!([parameter isKindOfClass:[NSValue class]] && strcmp([(NSValue *)parameter objCType], @encode(NSRange)) == 0)) {
|
||||
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityBoundsForRangeParameterizedAttribute, parameter);
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSRange range = [(NSValue *)parameter rangeValue];
|
||||
|
||||
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 *)accessibilityLineForIndexAttributeForParameter:(id)parameter
|
||||
{
|
||||
NSNumber *line = (NSNumber *) parameter;
|
||||
if (line == nil) return nil;
|
||||
|
||||
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, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
|
||||
if (row < 0) return nil;
|
||||
return [NSNumber numberWithInt:row];
|
||||
}
|
||||
|
||||
- (NSValue *)accessibilityRangeForLineAttributeForParameter:(id)parameter
|
||||
{
|
||||
NSNumber *line = (NSNumber *) parameter;
|
||||
if (line == nil) return nil;
|
||||
|
||||
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 intValue]); // AWT_THREADING Safe (AWTRunLoop)
|
||||
if (axTextRange == NULL) return nil;
|
||||
|
||||
return javaIntArrayToNSRangeValue(env,axTextRange);
|
||||
}
|
||||
|
||||
//
|
||||
// Usage of accessibilityStringForRangeAttributeForParameter:
|
||||
// ---
|
||||
// called by VoiceOver when interacting with text via ctrl-option-shift-downArrow.
|
||||
// VO needs to know the particular string its currently dealing with so it can
|
||||
// speak the string
|
||||
//
|
||||
- (NSString *)accessibilityStringForRangeAttributeForParameter:(id)parameter
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG_PARMS
|
||||
if (!([parameter isKindOfClass:[NSValue class]] && strcmp([(NSValue *)parameter objCType], @encode(NSRange)) == 0)) {
|
||||
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityBoundsForRangeParameterizedAttribute, parameter);
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSRange range = [(NSValue *)parameter rangeValue];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// Usage of accessibilityRangeForPositionAttributeForParameter:
|
||||
// ---
|
||||
// cmcnote: I'm not sure when this is called / how it's used. Investigate.
|
||||
// probably could be used in a special text-only accessibilityHitTest to
|
||||
// find the index of the string under the mouse?
|
||||
//
|
||||
- (NSValue *)accessibilityRangeForPositionAttributeForParameter:(id)parameter
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG_PARMS
|
||||
if (!([parameter isKindOfClass:[NSValue class]] && strcmp([(NSValue *)parameter objCType], @encode(NSPoint)) == 0)) {
|
||||
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityRangeForPositionParameterizedAttribute, parameter);
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSPoint point = [(NSValue *)parameter pointValue]; // point is in screen coords
|
||||
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];
|
||||
}
|
||||
|
||||
//
|
||||
// Usage of accessibilityRangeForIndexAttributeForParameter:
|
||||
// ---
|
||||
// cmcnote: I'm not sure when this is called / how it's used. Investigate.
|
||||
// AppKit version calls: [string rangeOfComposedCharacterSequenceAtIndex:index]
|
||||
// We call: CAccessibility.getRangeForIndex, which calls AccessibleText.getAtIndex(AccessibleText.WORD, index)
|
||||
// to determine the word closest to the given index. Then we find the length/location of this string.
|
||||
//
|
||||
- (NSValue *)accessibilityRangeForIndexAttributeForParameter:(id)parameter
|
||||
{
|
||||
#ifdef JAVA_AX_DEBUG_PARMS
|
||||
if (![parameter isKindOfClass:[NSNumber class]]) {
|
||||
JavaAccessibilityRaiseIllegalParameterTypeException(__FUNCTION__, self, NSAccessibilityRangeForIndexParameterizedAttribute, parameter);
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSUInteger index = [(NSNumber *)parameter unsignedIntegerValue];
|
||||
|
||||
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 javaIntArrayToNSRangeValue(env, axTextRange);
|
||||
}
|
||||
|
||||
/*
|
||||
* - (NSDictionary *)getActions:(JNIEnv *)env { ... }
|
||||
*
|
||||
* In the future, possibly add support: Editable text has AXShowMenu.
|
||||
* Textfields have AXConfirm.
|
||||
*
|
||||
* Note: JLabels (static text) in JLists have a press/click selection action
|
||||
* which is currently handled in superclass JavaComponentAccessibility.
|
||||
* If function is added here be sure to use [super getActions:env] for JLabels.
|
||||
*/
|
||||
|
||||
@end
|
||||
@@ -35,6 +35,8 @@
|
||||
JRSFontRenderingStyle fStyle;
|
||||
jint fAAStyle;
|
||||
jint fFmHint;
|
||||
jint fSubpixelResolutionX;
|
||||
jint fSubpixelResolutionY;
|
||||
|
||||
CGAffineTransform fTx;
|
||||
CGAffineTransform fDevTx;
|
||||
@@ -42,6 +44,13 @@
|
||||
CGAffineTransform fFontTx;
|
||||
}
|
||||
|
||||
+ (AWTStrike *) awtStrikeForFont:(AWTFont *)awtFont tx:(CGAffineTransform)tx invDevTx:(CGAffineTransform)invDevTx style:(JRSFontRenderingStyle)style aaStyle:(jint)aaStyle fmHint:(jint)fmHint;
|
||||
+ (AWTStrike *) awtStrikeForFont:(AWTFont *)awtFont
|
||||
tx:(CGAffineTransform)tx
|
||||
invDevTx:(CGAffineTransform)invDevTx
|
||||
style:(JRSFontRenderingStyle)style
|
||||
aaStyle:(jint)aaStyle
|
||||
fmHint:(jint)fmHint
|
||||
subpixelResolutionX:(jint)subpixelResolutionX
|
||||
subpixelResolutionY:(jint)subpixelResolutionY;
|
||||
|
||||
@end
|
||||
|
||||
@@ -42,7 +42,9 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
invDevTx:(CGAffineTransform)invDevTx
|
||||
style:(JRSFontRenderingStyle)style
|
||||
aaStyle:(jint)aaStyle
|
||||
fmHint:(jint)fmHint {
|
||||
fmHint:(jint)fmHint
|
||||
subpixelResolutionX:(jint)subpixelResolutionX
|
||||
subpixelResolutionY:(jint)subpixelResolutionY {
|
||||
|
||||
self = [super init];
|
||||
if (self) {
|
||||
@@ -50,6 +52,8 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
fStyle = style;
|
||||
fAAStyle = aaStyle;
|
||||
fFmHint = fmHint;
|
||||
fSubpixelResolutionX = subpixelResolutionX;
|
||||
fSubpixelResolutionY = subpixelResolutionY;
|
||||
|
||||
fTx = tx; // composited glyph and device transform
|
||||
|
||||
@@ -80,13 +84,17 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
invDevTx:(CGAffineTransform)invDevTx
|
||||
style:(JRSFontRenderingStyle)style
|
||||
aaStyle:(jint)aaStyle
|
||||
fmHint:(jint)fmHint {
|
||||
fmHint:(jint)fmHint
|
||||
subpixelResolutionX:(jint)subpixelResolutionX
|
||||
subpixelResolutionY:(jint)subpixelResolutionY {
|
||||
|
||||
return [[[AWTStrike alloc] initWithFont:awtFont
|
||||
tx:tx invDevTx:invDevTx
|
||||
style:style
|
||||
aaStyle:aaStyle
|
||||
fmHint:fmHint] autorelease];
|
||||
fmHint:fmHint
|
||||
subpixelResolutionX:subpixelResolutionX
|
||||
subpixelResolutionY:subpixelResolutionY] autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -405,7 +413,8 @@ JNF_COCOA_EXIT(env);
|
||||
* Signature: (J[D[DII)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_sun_font_CStrike_createNativeStrikePtr
|
||||
(JNIEnv *env, jclass clazz, jlong nativeFontPtr, jdoubleArray glyphTxArray, jdoubleArray invDevTxArray, jint aaStyle, jint fmHint)
|
||||
(JNIEnv *env, jclass clazz, jlong nativeFontPtr, jdoubleArray glyphTxArray, jdoubleArray invDevTxArray,
|
||||
jint aaStyle, jint fmHint, jint subpixelResolutionX, jint subpixelResolutionY)
|
||||
{
|
||||
AWTStrike *awtStrike = nil;
|
||||
JNF_COCOA_ENTER(env);
|
||||
@@ -416,7 +425,8 @@ JNF_COCOA_ENTER(env);
|
||||
CGAffineTransform glyphTx = GetTxFromDoubles(env, glyphTxArray);
|
||||
CGAffineTransform invDevTx = GetTxFromDoubles(env, invDevTxArray);
|
||||
|
||||
awtStrike = [AWTStrike awtStrikeForFont:awtFont tx:glyphTx invDevTx:invDevTx style:style aaStyle:aaStyle fmHint:fmHint]; // autoreleased
|
||||
awtStrike = [AWTStrike awtStrikeForFont:awtFont tx:glyphTx invDevTx:invDevTx style:style
|
||||
aaStyle:aaStyle fmHint:fmHint subpixelResolutionX:subpixelResolutionX subpixelResolutionY:subpixelResolutionY]; // autoreleased
|
||||
|
||||
if (awtStrike)
|
||||
{
|
||||
|
||||
@@ -285,6 +285,64 @@ CGGI_ConvertBWPixelToByteGray(UInt32 p)
|
||||
return 0xFF - (((p >> 24 & 0xFF) + (p >> 16 & 0xFF) + (p >> 8 & 0xFF)) / 3);
|
||||
}
|
||||
|
||||
static void
|
||||
CGGI_CopySubpixelImageFromCanvasToAlphaInfo(const UInt32* srcImage, int srcRowWidth,
|
||||
UInt8* dstImage,
|
||||
int dstWidth, int dstHeight,
|
||||
int subpixelResolutionX,
|
||||
int subpixelResolutionY,
|
||||
short *tempBuffer)
|
||||
{
|
||||
int srcWidth = dstWidth * subpixelResolutionX;
|
||||
int srcHeight = dstHeight * subpixelResolutionY;
|
||||
int imageSize = dstWidth * dstHeight;
|
||||
int xGlyph, yGlyph, x, y;
|
||||
// For each subpixel offset by x axis
|
||||
for (xGlyph = 0; xGlyph < subpixelResolutionX; xGlyph++) {
|
||||
// Sum values by x axis and store into temporary buffer
|
||||
for (y = 0; y < srcHeight; y++) {
|
||||
for (x = 0; x < dstWidth; x++) {
|
||||
int value = 0;
|
||||
int xFrom = x * subpixelResolutionX - xGlyph,
|
||||
xTo = xFrom + subpixelResolutionX;
|
||||
if (xFrom < 0) xFrom = 0;
|
||||
if (xTo > srcWidth) xTo = srcWidth;
|
||||
int i;
|
||||
for (i = xFrom; i < xTo; i++) {
|
||||
value += CGGI_ConvertBWPixelToByteGray(
|
||||
srcImage[y * srcRowWidth + i]);
|
||||
}
|
||||
tempBuffer[y * dstWidth + x] = (short) value;
|
||||
}
|
||||
}
|
||||
// For each subpixel offset by y axis
|
||||
for (yGlyph = 0; yGlyph < subpixelResolutionY; yGlyph++) {
|
||||
UInt8 *dst = dstImage +
|
||||
imageSize * (xGlyph + yGlyph * subpixelResolutionX);
|
||||
// Sum values by y axis and store average into destination image
|
||||
for (y = 0; y < dstHeight; y++) {
|
||||
for (x = 0; x < dstWidth; x++) {
|
||||
int value = 0;
|
||||
int yFrom = y * subpixelResolutionY - yGlyph,
|
||||
yTo = yFrom + subpixelResolutionY;
|
||||
if (yFrom < 0) yFrom = 0;
|
||||
if (yTo > srcHeight) yTo = srcHeight;
|
||||
int j;
|
||||
for (j = yFrom; j < yTo; j++) {
|
||||
value += tempBuffer[j * dstWidth + x];
|
||||
}
|
||||
dst[y * dstWidth + x] =
|
||||
value / subpixelResolutionX / subpixelResolutionY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Size (in pixels) of stack-allocated temporary buffer for glyph downscaling.
|
||||
* If glyph is too big and requires more memory, it will use malloc. */
|
||||
#define SUBPIXEL_DOWNSCALE_STATIC_BUFFER_SIZE 2048
|
||||
|
||||
static void
|
||||
CGGI_CopyImageFromCanvasToAlphaInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info)
|
||||
{
|
||||
@@ -296,16 +354,35 @@ CGGI_CopyImageFromCanvasToAlphaInfo(CGGI_GlyphCanvas *canvas, GlyphInfo *info)
|
||||
|
||||
size_t height = info->height;
|
||||
|
||||
size_t y;
|
||||
|
||||
// fill empty glyph image with black-on-white glyph
|
||||
for (y = 0; y < height; y++) {
|
||||
size_t destRow = y * destRowWidth;
|
||||
size_t srcRow = y * srcRowWidth;
|
||||
size_t x;
|
||||
for (x = 0; x < destRowWidth; x++) {
|
||||
UInt32 p = src[srcRow + x];
|
||||
dest[destRow + x] = CGGI_ConvertBWPixelToByteGray(p);
|
||||
if (info->subpixelResolutionX > 1 || info->subpixelResolutionY > 1) {
|
||||
int bufferSize = destRowWidth * height * info->subpixelResolutionY;
|
||||
if (bufferSize <= SUBPIXEL_DOWNSCALE_STATIC_BUFFER_SIZE) {
|
||||
short staticBuffer[bufferSize];
|
||||
CGGI_CopySubpixelImageFromCanvasToAlphaInfo(
|
||||
src, srcRowWidth,
|
||||
dest, destRowWidth, height,
|
||||
info->subpixelResolutionX, info->subpixelResolutionY,
|
||||
staticBuffer);
|
||||
} else {
|
||||
short *buffer = malloc(sizeof(short) * bufferSize);
|
||||
CGGI_CopySubpixelImageFromCanvasToAlphaInfo(
|
||||
src, srcRowWidth,
|
||||
dest, destRowWidth, height,
|
||||
info->subpixelResolutionX, info->subpixelResolutionY,
|
||||
buffer);
|
||||
free(buffer);
|
||||
}
|
||||
} else {
|
||||
size_t y;
|
||||
// fill empty glyph image with black-on-white glyph
|
||||
for (y = 0; y < height; y++) {
|
||||
size_t destRow = y * destRowWidth;
|
||||
size_t srcRow = y * srcRowWidth;
|
||||
size_t x;
|
||||
for (x = 0; x < destRowWidth; x++) {
|
||||
UInt32 p = src[srcRow + x];
|
||||
dest[destRow + x] = CGGI_ConvertBWPixelToByteGray(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,8 +430,10 @@ typedef struct CGGI_GlyphInfoDescriptor {
|
||||
} CGGI_GlyphInfoDescriptor;
|
||||
|
||||
typedef struct CGGI_RenderingMode {
|
||||
CGGI_GlyphInfoDescriptor *glyphDescriptor;
|
||||
CGGI_GlyphInfoDescriptor *mainFontDescriptor;
|
||||
JRSFontRenderingStyle cgFontMode;
|
||||
bool lcdRendering;
|
||||
bool subpixelResolution;
|
||||
} CGGI_RenderingMode;
|
||||
|
||||
static CGGI_GlyphInfoDescriptor grey =
|
||||
@@ -379,7 +458,7 @@ static inline CGGI_GlyphInfoDescriptor*
|
||||
CGGI_GetGlyphInfoDescriptor(const CGGI_RenderingMode *mode, CGFontRef font)
|
||||
{
|
||||
bool isFixedColor = CGGI_IsColorFont(font);
|
||||
return isFixedColor ? &argb : mode->glyphDescriptor;
|
||||
return isFixedColor ? &argb : mode->mainFontDescriptor;
|
||||
}
|
||||
|
||||
static inline CGGI_RenderingMode
|
||||
@@ -389,16 +468,26 @@ CGGI_GetRenderingMode(const AWTStrike *strike)
|
||||
mode.cgFontMode = strike->fStyle;
|
||||
NSException *e = nil;
|
||||
|
||||
#ifdef USE_IMAGE_ALIGNED_MEMORY
|
||||
mode.subpixelResolution = false;
|
||||
#else
|
||||
mode.subpixelResolution = strike->fAAStyle == sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_ON &&
|
||||
strike->fFmHint == sun_awt_SunHints_INTVAL_FRACTIONALMETRICS_ON &&
|
||||
(strike->fSubpixelResolutionX > 1 || strike->fSubpixelResolutionY > 1);
|
||||
#endif
|
||||
|
||||
switch (strike->fAAStyle) {
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_OFF:
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_ON:
|
||||
mode.glyphDescriptor = &grey;
|
||||
mode.lcdRendering = false;
|
||||
mode.mainFontDescriptor = &grey;
|
||||
break;
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_HBGR:
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_LCD_VBGR:
|
||||
mode.glyphDescriptor = &rgb;
|
||||
mode.lcdRendering = true;
|
||||
mode.mainFontDescriptor = &rgb;
|
||||
break;
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_GASP:
|
||||
case sun_awt_SunHints_INTVAL_TEXT_ANTIALIAS_DEFAULT:
|
||||
@@ -412,6 +501,10 @@ CGGI_GetRenderingMode(const AWTStrike *strike)
|
||||
userInfo:nil];
|
||||
@throw e;
|
||||
}
|
||||
if (CGGI_IsColorFont(strike->fAWTFont->fNativeCGFont)) {
|
||||
mode.mainFontDescriptor = &argb;
|
||||
mode.subpixelResolution = false;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
@@ -444,7 +537,7 @@ CGGI_InitCanvas(CGGI_GlyphCanvas *canvas,
|
||||
}
|
||||
|
||||
uint32_t bmpInfo = kCGImageAlphaPremultipliedFirst;
|
||||
if (mode->glyphDescriptor == &rgb) {
|
||||
if (mode->lcdRendering) {
|
||||
bmpInfo |= kCGBitmapByteOrder32Host;
|
||||
}
|
||||
|
||||
@@ -522,8 +615,8 @@ CGGI_ClearCanvas(CGGI_GlyphCanvas *canvas, GlyphInfo *info, bool transparent)
|
||||
{
|
||||
vImage_Buffer canvasRectToClear;
|
||||
canvasRectToClear.data = canvas->image->data;
|
||||
canvasRectToClear.height = info->height;
|
||||
canvasRectToClear.width = info->width;
|
||||
canvasRectToClear.height = info->height * info->subpixelResolutionY;
|
||||
canvasRectToClear.width = info->width * info->subpixelResolutionX;
|
||||
// use the row stride of the canvas, not the info
|
||||
canvasRectToClear.rowBytes = canvas->image->rowBytes;
|
||||
|
||||
@@ -561,7 +654,8 @@ static inline CGSize CGGI_ScaleAdvance(CGSize advance, const AWTStrike *strike)
|
||||
static inline GlyphInfo *
|
||||
CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||
const AWTStrike *strike,
|
||||
const CGGI_GlyphInfoDescriptor *glyphDescriptor)
|
||||
const CGGI_GlyphInfoDescriptor *glyphDescriptor,
|
||||
bool subpixelResolution)
|
||||
{
|
||||
size_t pixelSize = glyphDescriptor->pixelSize;
|
||||
|
||||
@@ -573,8 +667,23 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||
bbox.origin.x -= CGGI_GLYPH_BBOX_PADDING;
|
||||
bbox.origin.y -= CGGI_GLYPH_BBOX_PADDING;
|
||||
|
||||
vImagePixelCount width = ceilf(bbox.size.width);
|
||||
vImagePixelCount height = ceilf(bbox.size.height);
|
||||
int subpixelResX = 1;
|
||||
int subpixelResY = 1;
|
||||
int topLeftX, topLeftY;
|
||||
vImagePixelCount width, height;
|
||||
if (subpixelResolution) {
|
||||
subpixelResX = strike->fSubpixelResolutionX;
|
||||
subpixelResY = strike->fSubpixelResolutionY;
|
||||
topLeftX = floorf(bbox.origin.x / (float) subpixelResX);
|
||||
topLeftY = floorf(bbox.origin.y / (float) subpixelResY);
|
||||
width = ceilf((bbox.origin.x + bbox.size.width) / (float) subpixelResX) - topLeftX;
|
||||
height = ceilf((bbox.origin.y + bbox.size.height) / (float) subpixelResY) - topLeftY;
|
||||
} else {
|
||||
topLeftX = round(bbox.origin.x);
|
||||
topLeftY = round(bbox.origin.y);
|
||||
width = ceilf(bbox.size.width);
|
||||
height = ceilf(bbox.size.height);
|
||||
}
|
||||
|
||||
// if the glyph is larger than 1MB, don't even try...
|
||||
// the GlyphVector path should have taken over by now
|
||||
@@ -595,19 +704,20 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||
void *image = (void *)malloc(imageBytes + extraPixelStorage);
|
||||
#else
|
||||
// create a GlyphInfo struct fused to the image it points to
|
||||
GlyphInfo *glyphInfo = (GlyphInfo *)malloc(sizeof(GlyphInfo) + imageBytes + extraPixelStorage);
|
||||
GlyphInfo *glyphInfo = (GlyphInfo *)malloc(sizeof(GlyphInfo) +
|
||||
(imageBytes + extraPixelStorage) * subpixelResX * subpixelResY);
|
||||
#endif
|
||||
|
||||
glyphInfo->advanceX = advance.width;
|
||||
glyphInfo->advanceY = advance.height;
|
||||
glyphInfo->topLeftX = round(bbox.origin.x);
|
||||
glyphInfo->topLeftY = round(bbox.origin.y);
|
||||
glyphInfo->topLeftX = topLeftX;
|
||||
glyphInfo->topLeftY = topLeftY;
|
||||
glyphInfo->width = width;
|
||||
glyphInfo->height = height;
|
||||
glyphInfo->rowBytes = width * pixelSize;
|
||||
glyphInfo->cellInfo = NULL;
|
||||
glyphInfo->subpixelResolutionX = 1;
|
||||
glyphInfo->subpixelResolutionY = 1;
|
||||
glyphInfo->subpixelResolutionX = subpixelResX;
|
||||
glyphInfo->subpixelResolutionY = subpixelResY;
|
||||
|
||||
#ifdef USE_IMAGE_ALIGNED_MEMORY
|
||||
glyphInfo->image = image;
|
||||
@@ -624,6 +734,19 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
|
||||
|
||||
#pragma mark --- Glyph Striking onto Canvas ---
|
||||
|
||||
static inline void CGGI_ScaleTXForSubpixelResolution(CGAffineTransform *tx,
|
||||
const AWTStrike *strike,
|
||||
bool subpixelResolution) {
|
||||
if (subpixelResolution) {
|
||||
float subResX = (float) strike->fSubpixelResolutionX;
|
||||
float subResY = (float) strike->fSubpixelResolutionY;
|
||||
tx->a *= subResX;
|
||||
tx->b *= subResY;
|
||||
tx->c *= subResX;
|
||||
tx->d *= subResY;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clears the canvas, strikes the glyph with CoreGraphics, and then
|
||||
* copies the struck pixels into the GlyphInfo image.
|
||||
@@ -649,12 +772,13 @@ CGGI_CreateImageForGlyph
|
||||
CGGI_ClearCanvas(canvas, info, glyphDescriptor == &argb);
|
||||
|
||||
// strike the glyph in the upper right corner
|
||||
CGFloat x = -info->topLeftX;
|
||||
CGFloat y = canvas->image->height + info->topLeftY;
|
||||
CGFloat x = -info->topLeftX * (float) info->subpixelResolutionX;
|
||||
CGFloat y = canvas->image->height + info->topLeftY * (float) info->subpixelResolutionY;
|
||||
|
||||
if (isCatalinaOrAbove || glyphDescriptor == &argb) {
|
||||
CGAffineTransform matrix = CGContextGetTextMatrix(canvas->context);
|
||||
CGFloat fontSize = sqrt(fabs(matrix.a * matrix.d - matrix.b * matrix.c));
|
||||
CGFloat fontSize = sqrt(fabs(matrix.a * matrix.d - matrix.b * matrix.c) /
|
||||
(float) info->subpixelResolutionX / (float) info->subpixelResolutionY);
|
||||
CTFontRef font = CTFontCreateWithGraphicsFont(cgFont, fontSize, NULL, NULL);
|
||||
|
||||
CGFloat normFactor = 1.0 / fontSize;
|
||||
@@ -699,8 +823,10 @@ CGGI_CreateImageForUnicode
|
||||
const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar,
|
||||
const bool isCatalinaOrAbove)
|
||||
{
|
||||
// save the state of the world
|
||||
// save the graphics state
|
||||
CGContextSaveGState(canvas->context);
|
||||
// text matrix is not considered part of graphics state
|
||||
CGAffineTransform originalTx = CGContextGetTextMatrix(canvas->context);
|
||||
|
||||
// get the glyph, measure it using CG
|
||||
CGGlyph glyph;
|
||||
@@ -717,26 +843,32 @@ CGGI_CreateImageForUnicode
|
||||
fallback = CTS_CopyCTFallbackFontAndGlyphForUnicode(strike->fAWTFont, (const UTF16Char *)&charRef, &glyph, 1);
|
||||
}
|
||||
|
||||
CGAffineTransform tx = strike->fTx;
|
||||
JRSFontRenderingStyle style = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
|
||||
|
||||
const CGFontRef cgFallback = CTFontCopyGraphicsFont(fallback, NULL);
|
||||
CGGI_GlyphInfoDescriptor *glyphDescriptor = CGGI_GetGlyphInfoDescriptor(mode, cgFallback);
|
||||
|
||||
bool subpixelResolution = mode->subpixelResolution && glyphDescriptor == &grey;
|
||||
|
||||
CGAffineTransform tx = strike->fTx;
|
||||
CGGI_ScaleTXForSubpixelResolution(&tx, strike, subpixelResolution);
|
||||
CGRect bbox;
|
||||
JRSFontGetBoundingBoxesForGlyphsAndStyle(fallback, &tx, style, &glyph, 1, &bbox);
|
||||
|
||||
CGSize advance;
|
||||
CTFontGetAdvancesForGlyphs(fallback, kCTFontDefaultOrientation, &glyph, &advance, 1);
|
||||
|
||||
const CGFontRef cgFallback = CTFontCopyGraphicsFont(fallback, NULL);
|
||||
CGGI_GlyphInfoDescriptor *glyphDescriptor = CGGI_GetGlyphInfoDescriptor(mode, cgFallback);
|
||||
|
||||
// create the Sun2D GlyphInfo we are going to strike into
|
||||
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, glyphDescriptor);
|
||||
GlyphInfo *info = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, glyphDescriptor, subpixelResolution);
|
||||
|
||||
// fix the context size, just in case the substituted character is unexpectedly large
|
||||
CGGI_SizeCanvas(canvas, info->width, info->height, mode);
|
||||
CGGI_SizeCanvas(canvas, info->width * info->subpixelResolutionX, info->height * info->subpixelResolutionY, mode);
|
||||
|
||||
// align the transform for the real CoreText strike
|
||||
CGContextSetTextMatrix(canvas->context, strike->fAltTx);
|
||||
CGAffineTransform altTx = strike->fAltTx;
|
||||
CGGI_ScaleTXForSubpixelResolution(&altTx, strike, subpixelResolution);
|
||||
CGContextSetTextMatrix(canvas->context, altTx);
|
||||
|
||||
CGContextSetFont(canvas->context, cgFallback);
|
||||
CFRelease(cgFallback);
|
||||
@@ -744,8 +876,9 @@ CGGI_CreateImageForUnicode
|
||||
// clean the canvas - align, strike, and copy the glyph from the canvas into the info
|
||||
CGGI_CreateImageForGlyph(cgFallback, canvas, glyph, info, glyphDescriptor, strike, isCatalinaOrAbove);
|
||||
|
||||
// restore the state of the world
|
||||
// restore graphics state
|
||||
CGContextRestoreGState(canvas->context);
|
||||
CGContextSetTextMatrix(canvas->context, originalTx);
|
||||
|
||||
CFRelease(fallback);
|
||||
#ifdef CGGI_DEBUG
|
||||
@@ -780,20 +913,20 @@ CGGI_FillImagesForGlyphsWithSizedCanvas(CGGI_GlyphCanvas *canvas,
|
||||
const CGGlyph glyphs[],
|
||||
const CFIndex len)
|
||||
{
|
||||
CGContextSetTextMatrix(canvas->context, strike->fAltTx);
|
||||
CGAffineTransform tx = strike->fAltTx;
|
||||
CGGI_ScaleTXForSubpixelResolution(&tx, strike, mode->subpixelResolution);
|
||||
CGContextSetTextMatrix(canvas->context, tx);
|
||||
|
||||
CGContextSetFont(canvas->context, strike->fAWTFont->fNativeCGFont);
|
||||
JRSFontSetRenderingStyleOnContext(canvas->context, strike->fStyle);
|
||||
|
||||
CGGI_GlyphInfoDescriptor* mainFontDescriptor = CGGI_GetGlyphInfoDescriptor(mode, strike->fAWTFont->fNativeCGFont);
|
||||
|
||||
const bool isMojaveOrAbove = IS_OSX_GT10_13;
|
||||
CFIndex i;
|
||||
for (i = 0; i < len; i++) {
|
||||
GlyphInfo *info = (GlyphInfo *)jlong_to_ptr(glyphInfos[i]);
|
||||
if (info != NULL) {
|
||||
CGGI_CreateImageForGlyph(strike->fAWTFont->fNativeCGFont,
|
||||
canvas, glyphs[i], info, mainFontDescriptor, strike, isMojaveOrAbove);
|
||||
canvas, glyphs[i], info, mode->mainFontDescriptor, strike, isMojaveOrAbove);
|
||||
} else {
|
||||
info = CGGI_CreateImageForUnicode(canvas, strike, mode, uniChars[i], isMojaveOrAbove);
|
||||
glyphInfos[i] = ptr_to_jlong(info);
|
||||
@@ -852,7 +985,7 @@ CGGI_FillImagesForGlyphs(jlong *glyphInfos, const AWTStrike *strike,
|
||||
NSMutableDictionary *threadDict =
|
||||
[[NSThread currentThread] threadDictionary];
|
||||
|
||||
NSString* theKey = (mode->glyphDescriptor == &rgb) ?
|
||||
NSString* theKey = mode->lcdRendering ?
|
||||
threadLocalLCDCanvasKey : threadLocalAACanvasKey;
|
||||
|
||||
CGGI_GlyphCanvas *canvas = [threadDict objectForKey:theKey];
|
||||
@@ -884,6 +1017,7 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
|
||||
{
|
||||
AWTFont *font = strike->fAWTFont;
|
||||
CGAffineTransform tx = strike->fTx;
|
||||
CGGI_ScaleTXForSubpixelResolution(&tx, strike, mode->subpixelResolution);
|
||||
JRSFontRenderingStyle bboxCGMode = JRSFontAlignStyleForFractionalMeasurement(strike->fStyle);
|
||||
|
||||
JRSFontGetBoundingBoxesForGlyphsAndStyle((CTFontRef)font->fFont, &tx, bboxCGMode, glyphs, len, bboxes);
|
||||
@@ -892,8 +1026,6 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
|
||||
size_t maxWidth = 1;
|
||||
size_t maxHeight = 1;
|
||||
|
||||
CGGI_GlyphInfoDescriptor* mainFontDescriptor = CGGI_GetGlyphInfoDescriptor(mode, strike->fAWTFont->fNativeCGFont);
|
||||
|
||||
CFIndex i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
@@ -906,10 +1038,15 @@ CGGI_CreateGlyphInfos(jlong *glyphInfos, const AWTStrike *strike,
|
||||
CGSize advance = advances[i];
|
||||
CGRect bbox = bboxes[i];
|
||||
|
||||
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike, mainFontDescriptor);
|
||||
GlyphInfo *glyphInfo = CGGI_CreateNewGlyphInfoFrom(advance, bbox, strike,
|
||||
mode->mainFontDescriptor,
|
||||
mode->subpixelResolution);
|
||||
|
||||
if (maxWidth < glyphInfo->width) maxWidth = glyphInfo->width;
|
||||
if (maxHeight < glyphInfo->height) maxHeight = glyphInfo->height;
|
||||
int w = glyphInfo->width * glyphInfo->subpixelResolutionX;
|
||||
int h = glyphInfo->height * glyphInfo->subpixelResolutionY;
|
||||
|
||||
if (maxWidth < w) maxWidth = w;
|
||||
if (maxHeight < h) maxHeight = h;
|
||||
|
||||
glyphInfos[i] = ptr_to_jlong(glyphInfo);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
|
||||
private LinkedList<TypeAheadMarker> typeAheadMarkers = new LinkedList<TypeAheadMarker>();
|
||||
private boolean consumeNextKeyTyped;
|
||||
private Component restoreFocusTo;
|
||||
private Component keyPressedComponent;
|
||||
private WeakReference<Component> lastKeyPressedOrReleasedTarget = NULL_COMPONENT_WR;
|
||||
|
||||
private static boolean fxAppThreadIsDispatchThread;
|
||||
|
||||
@@ -1100,19 +1100,15 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
|
||||
if (((AWTEvent) ke).isPosted) {
|
||||
Component focusOwner;
|
||||
if (ke.getID() == KeyEvent.KEY_TYPED) {
|
||||
focusOwner = keyPressedComponent;
|
||||
focusOwner = lastKeyPressedOrReleasedTarget.get();
|
||||
} else {
|
||||
focusOwner = getFocusOwner();
|
||||
if (focusOwner == null) {
|
||||
focusOwner = getFocusedWindow();
|
||||
}
|
||||
lastKeyPressedOrReleasedTarget = new WeakReference<>(focusOwner);
|
||||
}
|
||||
ke.setSource(focusOwner);
|
||||
if (ke.getID() == KeyEvent.KEY_PRESSED) {
|
||||
keyPressedComponent = focusOwner;
|
||||
} else if (ke.getID() == KeyEvent.KEY_RELEASED) {
|
||||
keyPressedComponent = null;
|
||||
}
|
||||
}
|
||||
if (ke.getSource() == null) {
|
||||
return true;
|
||||
|
||||
@@ -41,10 +41,7 @@ import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
import java.text.CharacterIterator;
|
||||
import java.util.EventListener;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import sun.awt.ComponentFactory;
|
||||
import sun.font.StandardGlyphVector;
|
||||
@@ -585,7 +582,7 @@ public class Font implements java.io.Serializable
|
||||
|
||||
/* This constructor is used by deriveFont when attributes is null */
|
||||
private Font(String name, int style, float sizePts,
|
||||
boolean created, Font2DHandle handle) {
|
||||
boolean created, Font2DHandle handle, boolean useOldHandle) {
|
||||
this(name, style, sizePts);
|
||||
this.createdFont = created;
|
||||
/* Fonts created from a stream will use the same font2D instance
|
||||
@@ -605,6 +602,8 @@ public class Font implements java.io.Serializable
|
||||
} else {
|
||||
this.font2DHandle = handle;
|
||||
}
|
||||
} else if (useOldHandle) {
|
||||
this.font2DHandle = handle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,7 +649,7 @@ public class Font implements java.io.Serializable
|
||||
* In these cases there is no need to interrogate "values".
|
||||
*/
|
||||
private Font(AttributeValues values, String oldName, int oldStyle,
|
||||
boolean created, Font2DHandle handle) {
|
||||
boolean created, Font2DHandle handle, boolean useOldHandle) {
|
||||
|
||||
this.createdFont = created;
|
||||
if (created) {
|
||||
@@ -679,6 +678,8 @@ public class Font implements java.io.Serializable
|
||||
this.createdFont = false;
|
||||
this.font2DHandle = null;
|
||||
}
|
||||
} else if (useOldHandle) {
|
||||
this.font2DHandle = handle;
|
||||
}
|
||||
initFromValues(values);
|
||||
}
|
||||
@@ -848,7 +849,7 @@ public class Font implements java.io.Serializable
|
||||
values = font.getAttributeValues().clone();
|
||||
values.merge(attributes, SECONDARY_MASK);
|
||||
return new Font(values, font.name, font.style,
|
||||
font.createdFont, font.font2DHandle);
|
||||
font.createdFont, font.font2DHandle, false);
|
||||
}
|
||||
return new Font(attributes);
|
||||
}
|
||||
@@ -859,7 +860,7 @@ public class Font implements java.io.Serializable
|
||||
AttributeValues values = font.getAttributeValues().clone();
|
||||
values.merge(attributes, SECONDARY_MASK);
|
||||
return new Font(values, font.name, font.style,
|
||||
font.createdFont, font.font2DHandle);
|
||||
font.createdFont, font.font2DHandle, false);
|
||||
}
|
||||
|
||||
return font;
|
||||
@@ -2055,13 +2056,13 @@ public class Font implements java.io.Serializable
|
||||
*/
|
||||
public Font deriveFont(int style, float size){
|
||||
if (values == null) {
|
||||
return new Font(name, style, size, createdFont, font2DHandle);
|
||||
return new Font(name, style, size, createdFont, font2DHandle, false);
|
||||
}
|
||||
AttributeValues newValues = getAttributeValues().clone();
|
||||
int oldStyle = (this.style != style) ? this.style : -1;
|
||||
applyStyle(style, newValues);
|
||||
newValues.setSize(size);
|
||||
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
|
||||
return new Font(newValues, null, oldStyle, createdFont, font2DHandle, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2080,7 +2081,7 @@ public class Font implements java.io.Serializable
|
||||
int oldStyle = (this.style != style) ? this.style : -1;
|
||||
applyStyle(style, newValues);
|
||||
applyTransform(trans, newValues);
|
||||
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
|
||||
return new Font(newValues, null, oldStyle, createdFont, font2DHandle, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2092,11 +2093,11 @@ public class Font implements java.io.Serializable
|
||||
*/
|
||||
public Font deriveFont(float size){
|
||||
if (values == null) {
|
||||
return new Font(name, style, size, createdFont, font2DHandle);
|
||||
return new Font(name, style, size, createdFont, font2DHandle, true);
|
||||
}
|
||||
AttributeValues newValues = getAttributeValues().clone();
|
||||
newValues.setSize(size);
|
||||
return new Font(newValues, null, -1, createdFont, font2DHandle);
|
||||
return new Font(newValues, null, -1, createdFont, font2DHandle, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2112,7 +2113,7 @@ public class Font implements java.io.Serializable
|
||||
public Font deriveFont(AffineTransform trans){
|
||||
AttributeValues newValues = getAttributeValues().clone();
|
||||
applyTransform(trans, newValues);
|
||||
return new Font(newValues, null, -1, createdFont, font2DHandle);
|
||||
return new Font(newValues, null, -1, createdFont, font2DHandle, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2124,14 +2125,24 @@ public class Font implements java.io.Serializable
|
||||
*/
|
||||
public Font deriveFont(int style){
|
||||
if (values == null) {
|
||||
return new Font(name, style, size, createdFont, font2DHandle);
|
||||
return new Font(name, style, size, createdFont, font2DHandle, false);
|
||||
}
|
||||
AttributeValues newValues = getAttributeValues().clone();
|
||||
int oldStyle = (this.style != style) ? this.style : -1;
|
||||
applyStyle(style, newValues);
|
||||
return new Font(newValues, null, oldStyle, createdFont, font2DHandle);
|
||||
return new Font(newValues, null, oldStyle, createdFont, font2DHandle, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set of attributes, updating which on a Font instance cannot possibly
|
||||
* change the underlying Font2D instance it uses.
|
||||
*/
|
||||
private static final Set<? extends Attribute> FONT_2D_UNRELATED_ATTRS
|
||||
= Set.of(TextAttribute.KERNING,
|
||||
TextAttribute.LIGATURES,
|
||||
TextAttribute.SIZE,
|
||||
TextAttribute.TRANSFORM);
|
||||
|
||||
/**
|
||||
* Creates a new {@code Font} object by replicating the current
|
||||
* {@code Font} object and applying a new set of font attributes
|
||||
@@ -2149,7 +2160,15 @@ public class Font implements java.io.Serializable
|
||||
AttributeValues newValues = getAttributeValues().clone();
|
||||
newValues.merge(attributes, RECOGNIZED_MASK);
|
||||
|
||||
return new Font(newValues, name, style, createdFont, font2DHandle);
|
||||
boolean keepFont2DHandle = true;
|
||||
for (Attribute attribute : attributes.keySet()) {
|
||||
if (!FONT_2D_UNRELATED_ATTRS.contains(attribute)) {
|
||||
keepFont2DHandle = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Font(newValues, name, style, createdFont, font2DHandle,
|
||||
keepFont2DHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user