summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kovatch <skovatch>2011-01-11 19:19:17 +0000
committerScott Kovatch <skovatch>2011-01-11 19:19:17 +0000
commitfe7f4979e1155132a35847cc5f229732c363ec5c (patch)
tree08af950ec51958641e6a1c7fc43a1cbdbb3d78f1
parent4a9cee6826af103781424b5433033d8cfb7ebf4e (diff)
downloadeclipse.platform.swt-fe7f4979e1155132a35847cc5f229732c363ec5c.tar.gz
eclipse.platform.swt-fe7f4979e1155132a35847cc5f229732c363ec5c.tar.xz
eclipse.platform.swt-fe7f4979e1155132a35847cc5f229732c363ec5c.zip
333914 - search for right nib based on current locale.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLocale.java37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java7
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java22
8 files changed, 109 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
index ad830bcb1e..3fca1c5e0d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -4721,6 +4721,18 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(NSLinkAttributeName)
}
#endif
+#ifndef NO_NSLocaleLanguageCode
+JNIEXPORT jintLong JNICALL OS_NATIVE(NSLocaleLanguageCode)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, NSLocaleLanguageCode_FUNC);
+ rc = (jintLong)NSLocaleLanguageCode;
+ OS_NATIVE_EXIT(env, that, NSLocaleLanguageCode_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_NSModalPanelRunLoopMode
JNIEXPORT jintLong JNICALL OS_NATIVE(NSModalPanelRunLoopMode)
(JNIEnv *env, jclass that)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
index 806a2dcfe4..8328a7c752 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 625;
-int OS_nativeFunctionCallCount[625];
+int OS_nativeFunctionCount = 626;
+int OS_nativeFunctionCallCount[626];
char * OS_nativeFunctionNames[] = {
"ATSFontActivateFromFileReference",
"AcquireRootMenu",
@@ -358,6 +358,7 @@ char * OS_nativeFunctionNames[] = {
"NSIntersectionRect",
"NSLigatureAttributeName",
"NSLinkAttributeName",
+ "NSLocaleLanguageCode",
"NSModalPanelRunLoopMode",
"NSNumberOfColorComponents",
"NSObliquenessAttributeName",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
index 9ce8711d09..b9bc3345f2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -366,6 +366,7 @@ typedef enum {
NSIntersectionRect_FUNC,
NSLigatureAttributeName_FUNC,
NSLinkAttributeName_FUNC,
+ NSLocaleLanguageCode_FUNC,
NSModalPanelRunLoopMode_FUNC,
NSNumberOfColorComponents_FUNC,
NSObliquenessAttributeName_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index 40abd86d57..aaf492e9c1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -101,6 +101,13 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="pathForResource:ofType:inDirectory:forLocalization:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="resourcePath" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
@@ -379,6 +386,17 @@
<retval swt_gen="true"></retval>
</method>
</class>
+ <class name="NSLocale" swt_gen="mixed">
+ <method selector="displayNameForKey:value:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="initWithLocaleIdentifier:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
+ </class>
<class name="NSLogicalTest" swt_superclass="NSScriptWhoseTest">
</class>
<class name="NSMachBootstrapServer" swt_superclass="NSPortNameServer">
@@ -1049,6 +1067,7 @@
</class>
<constant name="NSDefaultRunLoopMode" swt_gen="true"></constant>
<constant name="NSErrorFailingURLStringKey" swt_gen="true"></constant>
+ <constant name="NSLocaleLanguageCode" swt_gen="true"></constant>
<enum name="NSAllApplicationsDirectory" swt_gen="true"></enum>
<enum name="NSAllDomainsMask" swt_gen="true"></enum>
<enum name="NSNotFound" swt_gen="true"></enum>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java
index e65d4c541c..ab76f90053 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSBundle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,6 +68,11 @@ public NSString pathForResource(NSString name, NSString ext) {
return result != 0 ? new NSString(result) : null;
}
+public NSString pathForResource(NSString name, NSString ext, NSString subpath, NSString localizationName) {
+ int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_pathForResource_ofType_inDirectory_forLocalization_, name != null ? name.id : 0, ext != null ? ext.id : 0, subpath != null ? subpath.id : 0, localizationName != null ? localizationName.id : 0);
+ return result != 0 ? new NSString(result) : null;
+}
+
public NSString resourcePath() {
int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_resourcePath);
return result != 0 ? new NSString(result) : null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLocale.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLocale.java
new file mode 100644
index 0000000000..0cff397767
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSLocale.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.cocoa;
+
+public class NSLocale extends NSObject {
+
+public NSLocale() {
+ super();
+}
+
+public NSLocale(int /*long*/ id) {
+ super(id);
+}
+
+public NSLocale(id id) {
+ super(id);
+}
+
+public NSString displayNameForKey(id key, id value) {
+ int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_displayNameForKey_value_, key != null ? key.id : 0, value != null ? value.id : 0);
+ return result != 0 ? new NSString(result) : null;
+}
+
+public id initWithLocaleIdentifier(NSString string) {
+ int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_initWithLocaleIdentifier_, string != null ? string.id : 0);
+ return result != 0 ? new id(result) : null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index def4d9b737..fe40f7501a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -724,6 +724,7 @@ public static final int /*long*/ class_NSInputManager = objc_getClass("NSInputMa
public static final int /*long*/ class_NSKeyedArchiver = objc_getClass("NSKeyedArchiver");
public static final int /*long*/ class_NSKeyedUnarchiver = objc_getClass("NSKeyedUnarchiver");
public static final int /*long*/ class_NSLayoutManager = objc_getClass("NSLayoutManager");
+public static final int /*long*/ class_NSLocale = objc_getClass("NSLocale");
public static final int /*long*/ class_NSMenu = objc_getClass("NSMenu");
public static final int /*long*/ class_NSMenuItem = objc_getClass("NSMenuItem");
public static final int /*long*/ class_NSMutableArray = objc_getClass("NSMutableArray");
@@ -1153,6 +1154,7 @@ public static final int /*long*/ sel_discardCursorRects = sel_registerName("disc
public static final int /*long*/ sel_display = sel_registerName("display");
public static final int /*long*/ sel_displayIfNeeded = sel_registerName("displayIfNeeded");
public static final int /*long*/ sel_displayName = sel_registerName("displayName");
+public static final int /*long*/ sel_displayNameForKey_value_ = sel_registerName("displayNameForKey:value:");
public static final int /*long*/ sel_displayRectIgnoringOpacity_inContext_ = sel_registerName("displayRectIgnoringOpacity:inContext:");
public static final int /*long*/ sel_distantFuture = sel_registerName("distantFuture");
public static final int /*long*/ sel_doCommandBySelector_ = sel_registerName("doCommandBySelector:");
@@ -1334,6 +1336,7 @@ public static final int /*long*/ sel_initWithImage_hotSpot_ = sel_registerName("
public static final int /*long*/ sel_initWithIndex_ = sel_registerName("initWithIndex:");
public static final int /*long*/ sel_initWithIndexesInRange_ = sel_registerName("initWithIndexesInRange:");
public static final int /*long*/ sel_initWithItemIdentifier_ = sel_registerName("initWithItemIdentifier:");
+public static final int /*long*/ sel_initWithLocaleIdentifier_ = sel_registerName("initWithLocaleIdentifier:");
public static final int /*long*/ sel_initWithRect_options_owner_userInfo_ = sel_registerName("initWithRect:options:owner:userInfo:");
public static final int /*long*/ sel_initWithSize_ = sel_registerName("initWithSize:");
public static final int /*long*/ sel_initWithStartingColor_endingColor_ = sel_registerName("initWithStartingColor:endingColor:");
@@ -1554,6 +1557,7 @@ public static final int /*long*/ sel_pasteboardWithName_ = sel_registerName("pas
public static final int /*long*/ sel_path = sel_registerName("path");
public static final int /*long*/ sel_pathExtension = sel_registerName("pathExtension");
public static final int /*long*/ sel_pathForResource_ofType_ = sel_registerName("pathForResource:ofType:");
+public static final int /*long*/ sel_pathForResource_ofType_inDirectory_forLocalization_ = sel_registerName("pathForResource:ofType:inDirectory:forLocalization:");
public static final int /*long*/ sel_performDragOperation_ = sel_registerName("performDragOperation:");
public static final int /*long*/ sel_performKeyEquivalent_ = sel_registerName("performKeyEquivalent:");
public static final int /*long*/ sel_performSelector_withObject_afterDelay_inModes_ = sel_registerName("performSelector:withObject:afterDelay:inModes:");
@@ -3038,6 +3042,9 @@ public static final NSString NSDefaultRunLoopMode = new NSString(NSDefaultRunLoo
/** @method flags=const */
public static final native int /*long*/ NSErrorFailingURLStringKey();
public static final NSString NSErrorFailingURLStringKey = new NSString(NSErrorFailingURLStringKey());
+/** @method flags=const */
+public static final native int /*long*/ NSLocaleLanguageCode();
+public static final NSString NSLocaleLanguageCode = new NSString(NSLocaleLanguageCode());
/** Functions */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index 828e5f68d4..d777948512 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -4893,9 +4893,28 @@ void applicationWillFinishLaunching (int /*long*/ id, int /*long*/ sel, int /*lo
if (status == 0) OS.DeleteMenuItem(outMenu[0], outIndex[0]);
}
+ /*
+ * Get the default locale's language, and then the display name of the language. Some Mac OS X localizations use the
+ * display name of the language, but many use the ISO two-char abbreviation instead.
+ */
+ Locale loc = Locale.getDefault();
+ String languageISOValue = loc.getLanguage();
+ NSLocale englishLocale = (NSLocale) new NSLocale().alloc();
+ englishLocale = new NSLocale(englishLocale.initWithLocaleIdentifier(NSString.stringWith("en_US")));
+ NSString languageDisplayName = englishLocale.displayNameForKey(OS.NSLocaleLanguageCode, NSString.stringWith(languageISOValue));
+ if (englishLocale != null) englishLocale.release();
+
+ /* To find the nib look for each of these paths, in order, until one is found:
+ * /System/Library/..../Resources/<display name>.lproj/DefaultApp.nib
+ * /System/Library/..../Resources/<language>.lproj/DefaultApp.nib
+ * /System/Library/..../Resources/<user's default language>.lproj/DefaultApp.nib
+ * /System/Library/..../Resources/English.lproj/DefaultApp.nib.
+ */
NSBundle bundle = NSBundle.bundleWithIdentifier(NSString.stringWith("com.apple.JavaVM"));
NSDictionary dict = NSDictionary.dictionaryWithObject(applicationDelegate, NSString.stringWith("NSOwner"));
- NSString path = bundle.pathForResource(NSString.stringWith("DefaultApp"), NSString.stringWith("nib"));
+ NSString path = bundle.pathForResource(NSString.stringWith("DefaultApp"), NSString.stringWith("nib"), null, languageDisplayName);
+ if (path == null) path = bundle.pathForResource(NSString.stringWith("DefaultApp"), NSString.stringWith("nib"), null, NSString.stringWith(languageISOValue));
+ if (path == null) path = bundle.pathForResource(NSString.stringWith("DefaultApp"), NSString.stringWith("nib"));
if (!loaded) loaded = path != null && NSBundle.loadNibFile(path, dict, 0);
if (!loaded) {
NSString resourcePath = bundle.resourcePath();
@@ -4909,6 +4928,7 @@ void applicationWillFinishLaunching (int /*long*/ id, int /*long*/ sel, int /*lo
if (!loaded) {
createMainMenu();
}
+
//replace %@ with application name
NSMenu mainmenu = application.mainMenu();
NSMenuItem appitem = mainmenu.itemAtIndex(0);