diff options
author | Silenio Quarti <silenio> | 2009-10-01 21:46:24 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2009-10-01 21:46:24 +0000 |
commit | 7796d3ee90efb3692b32bd7c53083adde87b6e72 (patch) | |
tree | d423326b16147824cf498a3e64540a8bb316fb9c | |
parent | e69ccdf91eaf47c7d23ca34831636ebd90362b25 (diff) | |
download | eclipse.platform.swt-7796d3ee90efb3692b32bd7c53083adde87b6e72.tar.gz eclipse.platform.swt-7796d3ee90efb3692b32bd7c53083adde87b6e72.tar.xz eclipse.platform.swt-7796d3ee90efb3692b32bd7c53083adde87b6e72.zip |
204582 - Mac - manually added external editors fail to launch
6 files changed, 220 insertions, 196 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os.c index 1027b1524f..dc4f54078a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os.c @@ -1243,6 +1243,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(CFArrayGetValueAtIndex) } #endif +#ifndef NO_CFBundleCreateBundlesFromDirectory +JNIEXPORT jint JNICALL OS_NATIVE(CFBundleCreateBundlesFromDirectory) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, CFBundleCreateBundlesFromDirectory_FUNC); + rc = (jint)CFBundleCreateBundlesFromDirectory((CFAllocatorRef)arg0, (CFURLRef)arg1, (CFStringRef)arg2); + OS_NATIVE_EXIT(env, that, CFBundleCreateBundlesFromDirectory_FUNC); + return rc; +} +#endif + #ifndef NO_CFBundleGetIdentifier JNIEXPORT jint JNICALL OS_NATIVE(CFBundleGetIdentifier) (JNIEnv *env, jclass that, jint arg0) @@ -1284,6 +1296,18 @@ fail: } #endif +#ifndef NO_CFBundleGetValueForInfoDictionaryKey +JNIEXPORT jint JNICALL OS_NATIVE(CFBundleGetValueForInfoDictionaryKey) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, CFBundleGetValueForInfoDictionaryKey_FUNC); + rc = (jint)CFBundleGetValueForInfoDictionaryKey((CFBundleRef)arg0, (CFStringRef)arg1); + OS_NATIVE_EXIT(env, that, CFBundleGetValueForInfoDictionaryKey_FUNC); + return rc; +} +#endif + #ifndef NO_CFDataGetBytePtr JNIEXPORT jint JNICALL OS_NATIVE(CFDataGetBytePtr) (JNIEnv *env, jclass that, jint arg0) @@ -1519,6 +1543,64 @@ JNIEXPORT void JNICALL OS_NATIVE(CFRunLoopWakeUp) } #endif +#ifndef NO_CFSetAddValue +JNIEXPORT void JNICALL OS_NATIVE(CFSetAddValue) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + OS_NATIVE_ENTER(env, that, CFSetAddValue_FUNC); + CFSetAddValue((CFMutableSetRef)arg0, (const void *)arg1); + OS_NATIVE_EXIT(env, that, CFSetAddValue_FUNC); +} +#endif + +#ifndef NO_CFSetCreateMutable +JNIEXPORT jint JNICALL OS_NATIVE(CFSetCreateMutable) + (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, CFSetCreateMutable_FUNC); + rc = (jint)CFSetCreateMutable((CFAllocatorRef)arg0, (CFIndex)arg1, (const CFSetCallBacks *)arg2); + OS_NATIVE_EXIT(env, that, CFSetCreateMutable_FUNC); + return rc; +} +#endif + +#ifndef NO_CFSetGetCount +JNIEXPORT jint JNICALL OS_NATIVE(CFSetGetCount) + (JNIEnv *env, jclass that, jint arg0) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, CFSetGetCount_FUNC); + rc = (jint)CFSetGetCount((CFMutableSetRef)arg0); + OS_NATIVE_EXIT(env, that, CFSetGetCount_FUNC); + return rc; +} +#endif + +#ifndef NO_CFSetGetValues +JNIEXPORT void JNICALL OS_NATIVE(CFSetGetValues) + (JNIEnv *env, jclass that, jint arg0, jintArray arg1) +{ + jint *lparg1=NULL; + OS_NATIVE_ENTER(env, that, CFSetGetValues_FUNC); + if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail; + CFSetGetValues((CFMutableSetRef)arg0, (const void **)lparg1); +fail: + if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0); + OS_NATIVE_EXIT(env, that, CFSetGetValues_FUNC); +} +#endif + +#ifndef NO_CFSetRemoveValue +JNIEXPORT void JNICALL OS_NATIVE(CFSetRemoveValue) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + OS_NATIVE_ENTER(env, that, CFSetRemoveValue_FUNC); + CFSetRemoveValue((CFMutableSetRef)arg0, (const void *)arg1); + OS_NATIVE_EXIT(env, that, CFSetRemoveValue_FUNC); +} +#endif + #ifndef NO_CFStringCreateWithBytes JNIEXPORT jint JNICALL OS_NATIVE(CFStringCreateWithBytes) (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jboolean arg4) @@ -13600,6 +13682,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(kCFTypeArrayCallBacks) } #endif +#ifndef NO_kCFTypeSetCallBacks +JNIEXPORT jint JNICALL OS_NATIVE(kCFTypeSetCallBacks) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, kCFTypeSetCallBacks_FUNC); + rc = (jint)&kCFTypeSetCallBacks; + OS_NATIVE_EXIT(env, that, kCFTypeSetCallBacks_FUNC); + return rc; +} +#endif + #ifndef NO_kFontPanelAttributeSizesKey JNIEXPORT jint JNICALL OS_NATIVE(kFontPanelAttributeSizesKey) (JNIEnv *env, jclass that) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.c index 0b9cd7fea3..7770573e55 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.c @@ -14,8 +14,8 @@ #ifdef NATIVE_STATS -int OS_nativeFunctionCount = 990; -int OS_nativeFunctionCallCount[990]; +int OS_nativeFunctionCount = 998; +int OS_nativeFunctionCallCount[998]; char * OS_nativeFunctionNames[] = { "AECoerceDesc", "AECountItems", @@ -94,9 +94,11 @@ char * OS_nativeFunctionNames[] = { "CFArrayCreateMutable", "CFArrayGetCount", "CFArrayGetValueAtIndex", + "CFBundleCreateBundlesFromDirectory", "CFBundleGetIdentifier", "CFBundleGetMainBundle", "CFBundleGetPackageInfo", + "CFBundleGetValueForInfoDictionaryKey", "CFDataGetBytePtr", "CFDataGetBytes", "CFDataGetLength", @@ -117,6 +119,11 @@ char * OS_nativeFunctionNames[] = { "CFRunLoopSourceSignal", "CFRunLoopStop", "CFRunLoopWakeUp", + "CFSetAddValue", + "CFSetCreateMutable", + "CFSetGetCount", + "CFSetGetValues", + "CFSetRemoveValue", "CFStringCreateWithBytes", "CFStringCreateWithCharacters__III", "CFStringCreateWithCharacters__I_3CI", @@ -977,6 +984,7 @@ char * OS_nativeFunctionNames[] = { "kCFRunLoopCommonModes", "kCFRunLoopDefaultMode", "kCFTypeArrayCallBacks", + "kCFTypeSetCallBacks", "kFontPanelAttributeSizesKey", "kFontPanelAttributeTagsKey", "kFontPanelAttributeValuesKey", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.h index a9301ce99c..73e4604163 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/os_stats.h @@ -102,9 +102,11 @@ typedef enum { CFArrayCreateMutable_FUNC, CFArrayGetCount_FUNC, CFArrayGetValueAtIndex_FUNC, + CFBundleCreateBundlesFromDirectory_FUNC, CFBundleGetIdentifier_FUNC, CFBundleGetMainBundle_FUNC, CFBundleGetPackageInfo_FUNC, + CFBundleGetValueForInfoDictionaryKey_FUNC, CFDataGetBytePtr_FUNC, CFDataGetBytes_FUNC, CFDataGetLength_FUNC, @@ -125,6 +127,11 @@ typedef enum { CFRunLoopSourceSignal_FUNC, CFRunLoopStop_FUNC, CFRunLoopWakeUp_FUNC, + CFSetAddValue_FUNC, + CFSetCreateMutable_FUNC, + CFSetGetCount_FUNC, + CFSetGetValues_FUNC, + CFSetRemoveValue_FUNC, CFStringCreateWithBytes_FUNC, CFStringCreateWithCharacters__III_FUNC, CFStringCreateWithCharacters__I_3CI_FUNC, @@ -985,6 +992,7 @@ typedef enum { kCFRunLoopCommonModes_FUNC, kCFRunLoopDefaultMode_FUNC, kCFTypeArrayCallBacks_FUNC, + kCFTypeSetCallBacks_FUNC, kFontPanelAttributeSizesKey_FUNC, kFontPanelAttributeTagsKey_FUNC, kFontPanelAttributeValuesKey_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java index 74a58bbc17..5c31ba14de 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java @@ -1072,6 +1072,8 @@ public static final native int kCFRunLoopCommonModes(); public static final native int kCFRunLoopDefaultMode(); /** @method flags=const address */ public static final native int kCFTypeArrayCallBacks(); +/** @method flags=const address */ +public static final native int kCFTypeSetCallBacks(); /** @method flags=const */ public static final native int kFontPanelAttributesKey(); /** @method flags=const */ @@ -1506,7 +1508,41 @@ public static final native int CFArrayCreateMutable(int allocator, int capacity, /** @param theArray cast=(CFArrayRef) */ public static final native int CFArrayGetCount(int theArray); /** @param theArray cast=(CFArrayRef) */ -public static final native int CFArrayGetValueAtIndex(int theArray, int idx); +public static final native int CFArrayGetValueAtIndex(int theArray, int idx); +/** + * @param theSet cast=(CFMutableSetRef) + * @param value cast=(const void *) + */ +public static final native void CFSetAddValue(int theSet, int value); +/** + * @param allocator cast=(CFAllocatorRef) + * @param capacity cast=(CFIndex) + * @param callBacks cast=(const CFSetCallBacks *) + */ +public static final native int CFSetCreateMutable(int allocator, int capacity, int callBacks); +/** @param theSet cast=(CFMutableSetRef) */ +public static final native int CFSetGetCount(int theSet); +/** + * @param theSet cast=(CFMutableSetRef) + * @param values cast=(const void **) + */ +public static final native void CFSetGetValues(int theSet, int[] values); +/** + * @param theSet cast=(CFMutableSetRef) + * @param value cast=(const void *) + */ +public static final native void CFSetRemoveValue(int theSet, int value); +/** + * @param allocater cast=(CFAllocatorRef) + * @param directoryURL cast=(CFURLRef) + * @param bundleType cast=(CFStringRef) + */ +public static final native int CFBundleCreateBundlesFromDirectory(int allocater, int directoryURL, int bundleType); +/** + * @param bundle cast=(CFBundleRef) + * @param cFBundleDocumentTypes cast=(CFStringRef) + */ +public static final native int CFBundleGetValueForInfoDictionaryKey(int bundle, int cFBundleDocumentTypes); public static final native int CFBundleGetMainBundle(); /** @param bundle cast=(CFBundleRef) */ public static final native int CFBundleGetIdentifier(int bundle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java index 78c3d07117..6db28d1634 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/cocoa/Cocoa.java @@ -234,6 +234,7 @@ public static final int NSURLCredentialPersistenceForSession = 1; public static final int NSURLRequestReloadIgnoringLocalCacheData = 1; public static final int NSAllDomainsMask = 0xffff; +public static final int NSAllApplicationsDirectory = 100; public static final int NSDesktopDirectory = 12; public static final int NSDocumentDirectory = 9; public static final int NSDownloadsDirectory = 15; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java index e6599715b8..c78e96bbc9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Program/carbon/org/eclipse/swt/program/Program.java @@ -14,6 +14,7 @@ package org.eclipse.swt.program; import org.eclipse.swt.internal.carbon.CFRange; import org.eclipse.swt.internal.carbon.LSApplicationParameters; import org.eclipse.swt.internal.carbon.OS; +import org.eclipse.swt.internal.cocoa.Cocoa; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; @@ -86,199 +87,75 @@ public static Program findProgram (String extension) { * @return an array of extensions */ public static String [] getExtensions () { - return new String [] { - // From System-Declared Uniform Type Identifiers - ".txt", - ".rtf", - ".html", - ".htm", - ".xml", - ".c", - ".m", - ".cp", ".cpp", ".c++", ".cc", ".cxx", - ".mm", - ".h", - ".hpp", - ".h++", - ".hxx", - ".java", - ".jav", - ".s", - ".r", - ".defs", - ".mig", - ".exp", - ".js", - ".jscript", - ".javascript", - ".sh", - ".command", - ".csh", - ".pl", - ".pm", - ".py", - ".rb", - ".rbw", - ".php", - ".php3", - ".php4", - ".ph3", - ".ph4", - ".phtml", - ".jnlp", - ".applescript", - ".scpt", - ".o", - ".exe", - ".dll", - ".class", - ".jar", - ".qtz", - ".gtar", - ".tar", - ".gz", - ".gzip", - ".tgz", - ".hqx", - ".bin", - ".vcf", - ".vcard", - ".jpg", - ".jpeg", - ".jp2", - ".tif", - ".tiff", - ".pic", - ".pct", - ".pict", - ".pntg", - ".png", - ".xbm", - ".qif", - ".qtif", - ".icns", - ".mov", - ".qt", - ".avi", - ".vfw", - ".mpg", - ".mpeg", - ".m75", - ".m15", - ".mp4", - ".3gp", - ".3gpp", - ".3g2", - ".3gp2", - ".mp3", - ".m4a", - ".m4p", - ".m4b", - ".au", - ".ulw", - ".snd", - ".aifc", - ".aiff", - ".aif", - ".caf", - ".bundle", - ".app", - ".plugin", - ".mdimporter", - ".wdgt", - ".cpio", - ".zip", - ".framework", - ".rtfd", - ".dfont", - ".otf", - ".ttf", - ".ttc", - ".suit", - ".pfb", - ".pfa", - ".icc", - ".icm", - ".pf", - ".pdf", - ".ps", - ".eps", - ".psd", - ".ai", - ".gif", - ".bmp", - ".ico", - ".doc", - ".xls", - ".ppt", - ".wav", - ".wave", - ".asf", - ".wm", - ".wmv", - ".wmp", - ".wma", - ".asx", - ".wmx", - ".wvx", - ".wax", - ".key", - ".kth", - ".tga", - ".sgi", - ".exr", - ".fpx", - ".jfx", - ".efx", - ".sd2", - ".rm", - ".ram", - ".ra", - ".smil", - ".sit", - ".sitx", - // Others - ".plist", - ".nib", - ".lproj", - // iChat - ".iPhoto", - // iChat - ".iChat", - ".chat", - // acrobat reader - ".rmf", - ".xfdf", - ".fdf", - // Chess - ".game", - ".pgn", - // iCal - ".ics", - ".vcs", - ".aplmodel", - ".icbu", - ".icalevent", - ".icaltodo", - // Mail - ".mailhold", - ".mbox", - ".imapmbox", - ".emlx", - ".mailextract", - // Sherlock - ".sherlock", - // Stickies - ".tpl", - // System Preferences - ".prefPane", - ".sliderSaver", - ".saver", - // Console - ".log", - // Grapher - ".gcx", - }; + final String CFBundleDocumentTypesStr = "CFBundleDocumentTypes"; + char [] chars = new char[CFBundleDocumentTypesStr.length()]; + CFBundleDocumentTypesStr.getChars(0, chars.length, chars, 0); + int CFBundleDocumentTypes = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length); + + final String CFBundleTypeExtensionsStr = "CFBundleTypeExtensions"; + chars = new char[CFBundleTypeExtensionsStr.length()]; + CFBundleTypeExtensionsStr.getChars(0, chars.length, chars, 0); + int CFBundleTypeExtensions = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, chars, chars.length); + + int folders = Cocoa.NSSearchPathForDirectoriesInDomains (Cocoa.NSAllApplicationsDirectory, Cocoa.NSAllDomainsMask, true); + int folderCount = OS.CFArrayGetCount(folders); + int supportedDocumentTypes = OS.CFSetCreateMutable(OS.kCFAllocatorDefault, 0, OS.kCFTypeSetCallBacks()); + for (int i = 0; i < folderCount; i++) { + int string = OS.CFArrayGetValueAtIndex(folders, i); + int folderUrl = OS.CFURLCreateWithFileSystemPath(OS.kCFAllocatorDefault, string, OS.kCFURLPOSIXPathStyle, true); + if (folderUrl != 0) { + int bundlesArray = OS.CFBundleCreateBundlesFromDirectory(OS.kCFAllocatorDefault, folderUrl, 0); + if (bundlesArray != 0) { + int bundleCount = OS.CFArrayGetCount(bundlesArray); + for (int j = 0; j < bundleCount; j++) { + int bundleRef = OS.CFArrayGetValueAtIndex(bundlesArray, j); + if (bundleRef == 0) continue; + int documentTypes = OS.CFBundleGetValueForInfoDictionaryKey(bundleRef, CFBundleDocumentTypes); + if (documentTypes != 0) { + int count = OS.CFArrayGetCount(documentTypes); + for (int k = 0; k < count; k++) { + int documentType = OS.CFArrayGetValueAtIndex(documentTypes, k); + if (documentType == 0) continue; + int[] value = new int[1]; + if (OS.CFDictionaryGetValueIfPresent(documentType, CFBundleTypeExtensions, value)) { + if (value[0] != 0) { + int extCount = OS.CFArrayGetCount(value[0]); + for (int x = 0; x < extCount; x++) { + int ext = OS.CFArrayGetValueAtIndex(value[0], x); + OS.CFSetAddValue(supportedDocumentTypes, ext); + } + } + } + } + } + } + OS.CFRelease(bundlesArray); + } + OS.CFRelease(folderUrl); + } + } + OS.CFRelease(CFBundleDocumentTypes); + OS.CFRelease(CFBundleTypeExtensions); + + int s = OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, new char[]{'*'}, 1); + OS.CFSetRemoveValue(supportedDocumentTypes, s); + OS.CFRelease(s); + + int count = OS.CFSetGetCount(supportedDocumentTypes); + String[] extensions = new String[count]; + int [] values = new int[count]; + OS.CFSetGetValues(supportedDocumentTypes, values); + for (int i = 0; i < count; i++) { + int ext = values[i]; + int length = OS.CFStringGetLength(ext); + char[] buffer = new char[length]; + CFRange range = new CFRange(); + range.length = length; + OS.CFStringGetCharacters(ext, range, buffer); + extensions[i] = "." + new String(buffer); + } + OS.CFRelease(supportedDocumentTypes); + return extensions; } /** |