This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 123853

Summary: I18N: "All Languages" and "Default" is not selected by default when these strings are localized
Product: editor Reporter: Masaki Katakai <masaki>
Component: OptionsAssignee: Masaki Katakai <masaki>
Status: RESOLVED FIXED    
Severity: blocker CC: jf4jbug
Priority: P2 Keywords: I18N, SIMPLEFIX
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: proposed patch, please review

Description Masaki Katakai 2007-12-11 23:03:40 UTC
"All Languages" and "Default" should be listed at the top of list and should be selected when Font and Color is selected
on Option dialog.
However, when these strings are localized, sort is not working properly, so other item is selected by default. It's hard
to find such defaults items.

1. Tools > Options
2. select Fonts & Colors tag
  On Syntax tab, top of Language dropdown list should be "All Languages" and it should be selected. but it's not when we
localize it.
3. Select "All Languages"
  "Default" should be listed on the top and selected by default on Category list, but it's not when it's localized.
   (It seems that bug 71987 has not been fixed completely)

For "All Languages" issue, it seems that compare() of LanguagesComparator is not correct.
I think we need to add the case when o2 == ColorModel.ALL_LANGUAGES.

--- editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java  (1.48)
+++ editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java  (1.48 )
@@ -997,6 +997,8 @@
         public int compare(String o1, String o2) {
             if (o1.equals(ColorModel.ALL_LANGUAGES))
                 return o2.equals(ColorModel.ALL_LANGUAGES) ? 0 : -1;
+            if (o2.equals(ColorModel.ALL_LANGUAGES))
+                return 1;
             return o1.compareTo(o2);
         }
     }

For "Default" issue, in the following codes of
editor/options/src/org/netbeans/modules/options/colors/CategoryComparator.java,
it seems that name() is returning localized string. It should compare with localized "Default", not english "default".

    public int compare (AttributeSet o1, AttributeSet o2) {
        String name_1 = name(o1);
        String name_2 = name(o2);
	if (name_1.startsWith ("default")) // NOI18N
	    return name_2.startsWith ("default") ? 0 : -1; // NOI18N
        if (name_2.startsWith ("default")) // NOI18N
            return 1;
	return name_1.compareTo (name_2);
    }
    
    private static String name (AttributeSet o) {
        return ((String) o.getAttribute(EditorStyleConstants.DisplayName)).toLowerCase();
    }
Comment 1 Vitezslav Stejskal 2007-12-12 09:48:17 UTC
Hi Masaki, thanks for catching this and for your analysis. You've become quite familiar with the internals of
Tools-Options, haven't you? That's great! If you would like commit rights to the editor modules for fixing these little
niches, I can give you the developer role. Otherwise, I'm happy to keep applying your patches, no problem with that.
Comment 2 Masaki Katakai 2007-12-13 09:39:55 UTC
Thank you very much. I want to try by myself. I'll let you know when the patch is ready and ask for review.
Comment 3 Vitezslav Stejskal 2007-12-13 10:18:00 UTC
Cool! Thanks for helping out.
Comment 4 Masaki Katakai 2007-12-17 01:37:13 UTC
Created attachment 54309 [details]
proposed patch, please review
Comment 5 Vitezslav Stejskal 2007-12-19 10:32:36 UTC
The patch looks ok to me. Please go ahead and apply it. Thanks
Comment 6 Masaki Katakai 2007-12-19 17:27:09 UTC
Thank you!! I have put them into trunk.

Checking in CategoryComparator.java;
/cvs/editor/options/src/org/netbeans/modules/options/colors/CategoryComparator.java,v  <--  CategoryComparator.java
new revision: 1.10; previous revision: 1.9

Checking in SyntaxColoringPanel.java;
/cvs/editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java,v  <--  SyntaxColoringPanel.java
new revision: 1.49; previous revision: 1.48