On 08/11/2011 10:02 PM, Pavel Porvatov wrote:
Hi Charles,
On 08/08/2011 10:17 PM, Pavel Porvatov wrote:
Hi Charles,
On 08/05/2011 05:00 PM, Pavel Porvatov wrote:
Hi Charles,
On 08/03/2011 08:49 PM, Pavel Porvatov wrote:
Hi Charles,

Yes, that's what I meant...

2. I do not think we should use VK_XXXX code. CR7024118 recommends to remove the VK_XXX code right?
I don't see such recommendations. Anyway we cannot use chars now because of backward compatibility requirement.
CR7024118 says:

"As seen in following, 3 mnemonic keys seems to be hardcoded and making them unable to localize. Please consider externalizing them to src/share/classes/com/sun/swing/internal/plaf/metal/resources/metal.properties"
and
"Since following keys in src/share/classes/com/sun/java/swing/plaf/motif/resources/motif_xx.properties being translated, in some languages mnemonic character is not in label string and won't show up in gui. "

It means the hardcoded VK_XXX codes can not be localized and in some situation the mnemonic character is not shown in the label. So we should use localized character as mnemonic. right?
The last your sentence is incorrect. Hardcoded mnemonics cannot be localized via properties files and therefore they works only for for English, but not for other supported languages. So we should use localized VK_XXX as mnemonics... Because, as I said before, we MUST keep backward compatibility.

Regards, Pavel


3. If the patch is ok, I would like to fix CR7024118 also.

So, there are two comments about the patch:
1. We must use VK_XXX codes for backward compatibility in WindowsLAF and MetalLAFs . Therefore NimbusLAF should use VK_XXX codes as well to be consistent with other LAFs

2. Could you please put mnemonics near labels? E.g.
FileChooser.lookInLabelText=Look In:
FileChooser.lookInLabelMnemonic=<VK_CODE>

It looks much more convenient I believe

Regards, Pavel



Hi Pavel,

I do not quite understand why we should keep VK_CODE, so I make two patches for first review, I will modify other properties if one of the patches is ok :-)
No problem. I wrote the example (see attach) that shows the problem. The test works fine without patches, with the patch.review1 an exception is thrown, with the patch.review2 mnemonic is missed. When I told about regressions I meant that we MUST keep FileChooser.lookInLabelMnemonic as an Integer. Therefore we have only one possible way: to use integer values (VK_XXX codes), but not VK_XXX names or characters.

[1] is the patch which is not use VK_CODE. (attached)
[2] is the patch which is use VK_CODE, I have to use reflect in that patch. Maybe I miss something. (attached)

Regards, Pavel
Here is another one :-) it uses VK_code hard coded as mental does. If it is ok, I will like to take CR7024118. Is reflection ok to you, Pavel?

Your current fix has a localization problem: it doesn't not work for other languages (the same problem described in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7024118). I see the fix in the following way:

1. Change getting mnemonics in SynthFileChooserUIImpl like in WindowsFileChooserUI: lookInLabelMnemonic = UIManager.getInt("FileChooser.lookInLabelMnemonic");

2. Add in synth.properties, synth_de.properties and other synth properties files:
FileChooser.lookInLabelMnemonic=49
FileChooser.folderNameLabelMnemonic=...
FileChooser.filesOfTypeLabelMnemonic=...
FileChooser.filesOfTypeMnemonic=...

where "..." is an appropriate integer numbers. BTW: we are using integer mnemonics in other properties files, e.g. in src\share\classes\com\sun\swing\internal\plaf\basic\resources\basic.properties

I agree that mnemonics in integer numbers is not very readable, but this way is most compatible and localizable way, I think.

Regards, Pavel

Hello Pavel, What about this patch (attached)?

--
Yours Charles

diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
index d222689..29db687 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Look In:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Save In:
 FileChooser.fileNameLabelText=File Name:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Folder name:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Files of Type:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Up One Level
 FileChooser.upFolderAccessibleName=Up
 FileChooser.homeFolderToolTipText=Home
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_de.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_de.properties
index 990f344..339db46 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_de.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_de.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Suchen in:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Speichern in:
 FileChooser.fileNameLabelText=Dateiname:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Ordnername:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Dateityp:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Eine Ebene h\u00F6her
 FileChooser.upFolderAccessibleName=Nach oben
 FileChooser.homeFolderToolTipText=Home
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_es.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_es.properties
index 03d2166..22d19ad 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_es.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_es.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Buscar en:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Guardar en:
 FileChooser.fileNameLabelText=Nombre de Archivo:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Nombre de la Carpeta:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Archivos de Tipo:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Subir un Nivel
 FileChooser.upFolderAccessibleName=Arriba
 FileChooser.homeFolderToolTipText=Inicio
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_fr.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_fr.properties
index 273351d..2b844cd 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_fr.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_fr.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Rechercher dans :
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Enregistrer dans :
 FileChooser.fileNameLabelText=Nom du fichier :
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Nom du dossier :
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Fichiers de type :
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Remonte d'un niveau.
 FileChooser.upFolderAccessibleName=Monter
 FileChooser.homeFolderToolTipText=R\u00E9pertoire d'origine
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_it.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_it.properties
index da2e2c7..aca5aa8 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_it.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_it.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Cerca in:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Salva in:
 FileChooser.fileNameLabelText=Nome file:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Nome della cartella:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Tipo file:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Cartella superiore
 FileChooser.upFolderAccessibleName=Superiore
 FileChooser.homeFolderToolTipText=Home
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ja.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ja.properties
index 382fcf8..0a680e5 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ja.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ja.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=\u53C2\u7167:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=\u4FDD\u5B58:
 FileChooser.fileNameLabelText=\u30D5\u30A1\u30A4\u30EB\u540D:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=\u30D5\u30A9\u30EB\u30C0\u540D:
+FileChooser.folderNameLabelMnemonic=70
 
FileChooser.filesOfTypeLabelText=\u30D5\u30A1\u30A4\u30EB\u306E\u30BF\u30A4\u30D7:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=1\u30EC\u30D9\u30EB\u4E0A\u3078
 FileChooser.upFolderAccessibleName=\u4E0A\u3078
 FileChooser.homeFolderToolTipText=\u30DB\u30FC\u30E0
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties
index adc9b1d..6f91512 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_ko.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=\uAC80\uC0C9 \uC704\uCE58:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=\uC800\uC7A5 \uC704\uCE58:
 FileChooser.fileNameLabelText=\uD30C\uC77C \uC774\uB984:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=\uD3F4\uB354 \uC774\uB984:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=\uD30C\uC77C \uC720\uD615:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=\uD55C \uB808\uBCA8 \uC704\uB85C
 FileChooser.upFolderAccessibleName=\uC704\uB85C
 FileChooser.homeFolderToolTipText=\uD648
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_pt_BR.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_pt_BR.properties
index b14a61f..292f7ff 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_pt_BR.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_pt_BR.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Consultar Em:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Salvar Em:
 FileChooser.fileNameLabelText=Nome do Arquivo:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Nome da pasta:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Arquivos do Tipo:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Um N\u00EDvel Acima
 FileChooser.upFolderAccessibleName=Acima
 FileChooser.homeFolderToolTipText=In\u00EDcio
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_sv.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_sv.properties
index 9167b72..296934c 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_sv.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_sv.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=Leta i:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=Spara i:
 FileChooser.fileNameLabelText=Filnamn:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=Mapp:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=Filformat:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=Upp en niv\u00E5
 FileChooser.upFolderAccessibleName=Upp
 FileChooser.homeFolderToolTipText=Hem
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_CN.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_CN.properties
index 547fd15..dd131fa 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_CN.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_CN.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=\u67E5\u770B: 
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=\u4FDD\u5B58: 
 FileChooser.fileNameLabelText=\u6587\u4EF6\u540D: 
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=\u6587\u4EF6\u5939\u540D: 
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=\u6587\u4EF6\u7C7B\u578B: 
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=\u5411\u4E0A\u4E00\u7EA7
 FileChooser.upFolderAccessibleName=\u5411\u4E0A
 FileChooser.homeFolderToolTipText=\u4E3B\u76EE\u5F55
diff --git 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_TW.properties
 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_TW.properties
index 1144f61..2a6dc5d 100644
--- 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_TW.properties
+++ 
src/share/classes/com/sun/swing/internal/plaf/synth/resources/synth_zh_TW.properties
@@ -19,10 +19,14 @@
 ############ FILE CHOOSER STRINGS #############
 
 FileChooser.lookInLabelText=\u67E5\u8A62:
+FileChooser.lookInLabelMnemonic=73
 FileChooser.saveInLabelText=\u5132\u5B58\u65BC: 
 FileChooser.fileNameLabelText=\u6A94\u6848\u540D\u7A31:
+FileChooser.fileNameLabelMnemonic=78
 FileChooser.folderNameLabelText=\u8CC7\u6599\u593E\u540D\u7A31:
+FileChooser.folderNameLabelMnemonic=70
 FileChooser.filesOfTypeLabelText=\u6A94\u6848\u985E\u578B:
+FileChooser.filesOfTypeLabelMnemonic=84
 FileChooser.upFolderToolTipText=\u5F80\u4E0A\u4E00\u5C64
 FileChooser.upFolderAccessibleName=\u5F80\u4E0A
 FileChooser.homeFolderToolTipText=\u4E3B\u76EE\u9304
diff --git src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java 
src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
index d8e0236..54b73a1 100644
--- src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
+++ src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
@@ -501,7 +501,16 @@ public class SynthFileChooserUIImpl extends 
SynthFileChooserUI {
     }
 
     private int getMnemonic(String key, Locale l) {
-        return SwingUtilities2.getUIDefaultsInt(key, l);
+       Object value = UIManager.get(key, l);
+       if (value instanceof Integer) {
+           return ((Integer)value).intValue();
+       }
+       if (value instanceof String) {
+           try {
+               return Integer.parseInt((String)value);
+           } catch (NumberFormatException nfe) {}
+       }
+       return -1;
     }
 
 

Reply via email to