8183529: FilleChooser in "Detail view" does not change the Language of the column headings
Reviewed-by: ssadetsky
--- a/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java Thu Jul 13 12:14:59 2017 +0530
+++ b/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java Fri Jul 14 10:30:32 2017 +0530
@@ -42,9 +42,9 @@
*/
@SuppressWarnings("serial") // JDK-implementation class
public abstract class ShellFolder extends File {
- private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText";
- private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText";
- private static final String COLUMN_DATE = "FileChooser.fileDateHeaderText";
+ public static final String COLUMN_NAME = "FileChooser.fileNameHeaderText";
+ public static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText";
+ public static final String COLUMN_DATE = "FileChooser.fileDateHeaderText";
protected ShellFolder parent;
--- a/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java Thu Jul 13 12:14:59 2017 +0530
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java Fri Jul 14 10:30:32 2017 +0530
@@ -240,6 +240,10 @@
private Image largeIcon = null;
private Boolean isDir = null;
private final boolean isLib;
+ private static final String FNAME = COLUMN_NAME;
+ private static final String FSIZE = COLUMN_SIZE;
+ private static final String FTYPE = "FileChooser.fileTypeHeaderText";
+ private static final String FDATE = COLUMN_DATE;
/*
* The following is to identify the My Documents folder as being special
--- a/jdk/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp Thu Jul 13 12:14:59 2017 +0530
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp Fri Jul 14 10:30:32 2017 +0530
@@ -109,6 +109,16 @@
static IMalloc* pMalloc;
static IShellFolder* pDesktop;
+// locale sensitive folder info
+static jfieldID FID_lsName;
+static jfieldID FID_lsSize;
+static jfieldID FID_lsType;
+static jfieldID FID_lsDate;
+static jstring lsName;
+static jstring lsSize;
+static jstring lsType;
+static jstring lsDate;
+
// Some macros from awt.h, because it is not included in release
#ifndef IS_WIN2000
#define IS_WIN2000 (LOBYTE(LOWORD(::GetVersion())) >= 5)
@@ -246,6 +256,36 @@
CHECK_NULL(FID_displayName);
FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;");
CHECK_NULL(FID_folderType);
+
+ FID_lsName = env->GetStaticFieldID(cls, "FNAME", "Ljava/lang/String;");
+ CHECK_NULL(FID_lsName);
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ return;
+ }
+ FID_lsSize = env->GetStaticFieldID(cls, "FSIZE", "Ljava/lang/String;");
+ CHECK_NULL(FID_lsSize);
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ return;
+ }
+ FID_lsType = env->GetStaticFieldID(cls, "FTYPE", "Ljava/lang/String;");
+ CHECK_NULL(FID_lsType);
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ return;
+ }
+ FID_lsDate = env->GetStaticFieldID(cls, "FDATE", "Ljava/lang/String;");
+ CHECK_NULL(FID_lsDate);
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ return;
+ }
+
+ lsName = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsName)));
+ lsSize = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsSize)));
+ lsType = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsType)));
+ lsDate = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsDate)));
}
@@ -1105,11 +1145,21 @@
*/
static jobject CreateColumnInfo(JNIEnv *pEnv,
jclass *pClass, jmethodID *pConstructor,
- SHELLDETAILS *psd, ULONG visible)
+ int colNum, SHELLDETAILS *psd, ULONG visible)
{
jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str));
JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL);
+ // Convert ShellFolder column names to locale-sensitive names
+ if (colNum == 0) {
+ str = lsName;
+ } else if (colNum == 1) {
+ str = lsSize;
+ } else if (colNum == 2) {
+ str = lsType;
+ } else if (colNum == 3) {
+ str = lsDate;
+ }
return pEnv->NewObject(*pClass, *pConstructor,
str,
(jint)(psd->cxChar * 6), // TODO: is 6 OK for converting chars to pixels?
@@ -1178,7 +1228,7 @@
if(!(csFlags & SHCOLSTATE_HIDDEN)) {
jobject column = CreateColumnInfo(env,
&columnClass, &columnConstructor,
- &sd, csFlags & SHCOLSTATE_ONBYDEFAULT);
+ colNum, &sd, csFlags & SHCOLSTATE_ONBYDEFAULT);
if(!column){
pIShellFolder2->Release();
return NULL;
@@ -1222,7 +1272,7 @@
if (SUCCEEDED (hr)) {
jobject column = CreateColumnInfo(env,
&columnClass, &columnConstructor,
- &sd, 1);
+ colNum, &sd, 1);
if(!column){
pIShellDetails->Release();
return NULL;