diff options
author | Silenio Quarti | 2010-04-22 18:16:49 +0000 |
---|---|---|
committer | Silenio Quarti | 2010-04-22 18:16:49 +0000 |
commit | 9b7d88df3143db20609e02dbededa54d6651de22 (patch) | |
tree | 9099620bccfdb10a4a9378d51d25de0f7cb3292b /bundles/org.eclipse.swt | |
parent | 227bfd90a9d77f14c654baa1ea3b2eacb8c15a44 (diff) | |
download | eclipse.platform.swt-9b7d88df3143db20609e02dbededa54d6651de22.tar.gz eclipse.platform.swt-9b7d88df3143db20609e02dbededa54d6651de22.tar.xz eclipse.platform.swt-9b7d88df3143db20609e02dbededa54d6651de22.zip |
Bug 305124 - [Program] Eclipse can not open resource files in external editor
Diffstat (limited to 'bundles/org.eclipse.swt')
5 files changed, 113 insertions, 8 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 bc0521861b..dd6c2e2432 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 @@ -9711,6 +9711,25 @@ fail: } #endif +#ifndef NO_LSCopyItemAttribute +JNIEXPORT jint JNICALL OS_NATIVE(LSCopyItemAttribute) + (JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2, jintArray arg3) +{ + jbyte *lparg0=NULL; + jint *lparg3=NULL; + jint rc = 0; + OS_NATIVE_ENTER(env, that, LSCopyItemAttribute_FUNC); + if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail; + if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail; + rc = (jint)LSCopyItemAttribute((const FSRef *)lparg0, (LSRolesMask)arg1, (CFStringRef)arg2, (CFTypeRef *)lparg3); +fail: + if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0); + if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0); + OS_NATIVE_EXIT(env, that, LSCopyItemAttribute_FUNC); + return rc; +} +#endif + #ifndef NO_LSFindApplicationForInfo JNIEXPORT jint JNICALL OS_NATIVE(LSFindApplicationForInfo) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jintArray arg4) @@ -13585,6 +13604,18 @@ fail: } #endif +#ifndef NO_UTTypeConformsTo +JNIEXPORT jboolean JNICALL OS_NATIVE(UTTypeConformsTo) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jboolean rc = 0; + OS_NATIVE_ENTER(env, that, UTTypeConformsTo_FUNC); + rc = (jboolean)UTTypeConformsTo((CFStringRef)arg0, (CFStringRef)arg1); + OS_NATIVE_EXIT(env, that, UTTypeConformsTo_FUNC); + return rc; +} +#endif + #ifndef NO_UTTypeCreateAllIdentifiersForTag JNIEXPORT jint JNICALL OS_NATIVE(UTTypeCreateAllIdentifiersForTag) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2) @@ -13609,6 +13640,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(UTTypeCreatePreferredIdentifierForTag) } #endif +#ifndef NO_UTTypeEqual +JNIEXPORT jboolean JNICALL OS_NATIVE(UTTypeEqual) + (JNIEnv *env, jclass that, jint arg0, jint arg1) +{ + jboolean rc = 0; + OS_NATIVE_ENTER(env, that, UTTypeEqual_FUNC); + rc = (jboolean)UTTypeEqual((CFStringRef)arg0, (CFStringRef)arg1); + OS_NATIVE_EXIT(env, that, UTTypeEqual_FUNC); + return rc; +} +#endif + #ifndef NO_UnionRect JNIEXPORT void JNICALL OS_NATIVE(UnionRect) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jobject arg2) @@ -13860,6 +13903,18 @@ JNIEXPORT jint JNICALL OS_NATIVE(kHIViewWindowContentID) } #endif +#ifndef NO_kLSItemContentType +JNIEXPORT jint JNICALL OS_NATIVE(kLSItemContentType) + (JNIEnv *env, jclass that) +{ + jint rc = 0; + OS_NATIVE_ENTER(env, that, kLSItemContentType_FUNC); + rc = (jint)kLSItemContentType; + OS_NATIVE_EXIT(env, that, kLSItemContentType_FUNC); + return rc; +} +#endif + #ifndef NO_kPMDocumentFormatPDF JNIEXPORT jint JNICALL OS_NATIVE(kPMDocumentFormatPDF) (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 2f981e250e..be92b38a3b 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 = 1006; -int OS_nativeFunctionCallCount[1006]; +int OS_nativeFunctionCount = 1010; +int OS_nativeFunctionCallCount[1010]; char * OS_nativeFunctionNames[] = { "AECoerceDesc", "AECountItems", @@ -691,6 +691,7 @@ char * OS_nativeFunctionNames[] = { "LMGetKbdType", "LSCopyAllRoleHandlersForContentType", "LSCopyDisplayNameForRef", + "LSCopyItemAttribute", "LSFindApplicationForInfo", "LSGetApplicationForInfo", "LSOpenApplication", @@ -976,8 +977,10 @@ char * OS_nativeFunctionNames[] = { "TrackDrag", "TrackMouseLocationWithOptions", "UCKeyTranslate", + "UTTypeConformsTo", "UTTypeCreateAllIdentifiersForTag", "UTTypeCreatePreferredIdentifierForTag", + "UTTypeEqual", "UnionRect", "UnionRgn", "UpdateDataBrowserItems", @@ -998,6 +1001,7 @@ char * OS_nativeFunctionNames[] = { "kFontPanelAttributeValuesKey", "kFontPanelAttributesKey", "kHIViewWindowContentID", + "kLSItemContentType", "kPMDocumentFormatPDF", "kPMGraphicsContextCoreGraphics", "kUTTagClassFilenameExtension", 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 2f941d006f..338e659e74 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 @@ -699,6 +699,7 @@ typedef enum { LMGetKbdType_FUNC, LSCopyAllRoleHandlersForContentType_FUNC, LSCopyDisplayNameForRef_FUNC, + LSCopyItemAttribute_FUNC, LSFindApplicationForInfo_FUNC, LSGetApplicationForInfo_FUNC, LSOpenApplication_FUNC, @@ -984,8 +985,10 @@ typedef enum { TrackDrag_FUNC, TrackMouseLocationWithOptions_FUNC, UCKeyTranslate_FUNC, + UTTypeConformsTo_FUNC, UTTypeCreateAllIdentifiersForTag_FUNC, UTTypeCreatePreferredIdentifierForTag_FUNC, + UTTypeEqual_FUNC, UnionRect_FUNC, UnionRgn_FUNC, UpdateDataBrowserItems_FUNC, @@ -1006,6 +1009,7 @@ typedef enum { kFontPanelAttributeValuesKey_FUNC, kFontPanelAttributesKey_FUNC, kHIViewWindowContentID_FUNC, + kLSItemContentType_FUNC, kPMDocumentFormatPDF_FUNC, kPMGraphicsContextCoreGraphics_FUNC, kUTTagClassFilenameExtension_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 f83faf820c..c2f4283158 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 @@ -1092,6 +1092,8 @@ public static final native int kFontPanelAttributeSizesKey(); /** @method flags=const */ public static final native int kFontPanelAttributeValuesKey(); /** @method flags=const */ +public static final native int kLSItemContentType(); +/** @method flags=const */ public static final native int kUTTagClassFilenameExtension(); /** @method flags=const address */ public static final native int kHIViewWindowContentID(); @@ -3981,6 +3983,13 @@ public static final native int LSFindApplicationForInfo(int inCreator, int inBun */ public static final native int LSCopyAllRoleHandlersForContentType(int inContentType, int inRoleMask); /** + * @param inItem cast=(const FSRef *) + * @param inRoles cast=(LSRolesMask) + * @param inAttributeName cast=(CFStringRef) + * @param outValue cast=(CFTypeRef *) + */ +public static final native int LSCopyItemAttribute (byte[] inItem, int inRoles, int inAttributeName, int[] outValue); +/** * @param inType cast=(OSType) * @param inCreator cast=(OSType) * @param inExtension cast=(CFStringRef) @@ -5339,6 +5348,11 @@ public static final native int TrackDrag(int theDrag, EventRecord theEvent, int */ public static final native int TrackMouseLocationWithOptions(int inPort, int inOptions, double inTime, Point outPt, int [] outModifiers, short[] outResult); /** + * @param inUTI cast=(CFStringRef) + * @param inConformsToUTI cast=(CFStringRef) + */ +public static final native boolean UTTypeConformsTo(int inUTI, int inConformsToUTI); +/** * @param inTagClass cast=(CFStringRef) * @param inTag cast=(CFStringRef) * @param inConformingToUTI cast=(CFStringRef) @@ -5351,6 +5365,11 @@ public static final native int UTTypeCreatePreferredIdentifierForTag(int inTagCl */ public static final native int UTTypeCreateAllIdentifiersForTag(int inTagClass, int inTag, int inConformingToUTI); /** + * @param inUTI1 cast=(CFStringRef) + * @param inUTI2 cast=(CFStringRef) + */ +public static final native boolean UTTypeEqual(int inUTI1, int inUTI2); +/** * @param srcA flags=no_out * @param srcB flags=no_out * @param dst flags=no_in 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 9e5985cfdb..8e86a7e2c2 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 @@ -257,9 +257,7 @@ static int getURL(String fileName) { static boolean isExecutable (String fileName) { boolean result = false; - char[] chars = new char[fileName.length()]; - fileName.getChars(0, chars.length, chars, 0); - int str = OS.CFStringCreateWithCharacters(0, chars, chars.length); + int str = createCFString(fileName); if (str != 0) { int fileManager = Cocoa.objc_msgSend(Cocoa.C_NSFileManager, Cocoa.S_defaultManager); int ptr = OS.malloc (1); @@ -267,17 +265,42 @@ static boolean isExecutable (String fileName) { if (fileManager != 0 && Cocoa.objc_msgSend(fileManager, Cocoa.S_fileExistsAtPath_isDirectory, str, ptr) != 0) { byte[] isDirectory = new byte[1]; OS.memmove(isDirectory, ptr, 1); - if (isDirectory[0] == 0) { - result = Cocoa.objc_msgSend(fileManager, Cocoa.S_isExecutableFileAtPath, str) != 0; + if (isDirectory[0] == 0 && Cocoa.objc_msgSend (fileManager, Cocoa.S_isExecutableFileAtPath, str) != 0) { + int url = OS.CFURLCreateWithFileSystemPath(OS.kCFAllocatorDefault, str, OS.kCFURLPOSIXPathStyle, false); + if (url != 0) { + byte[] fsRef = new byte[80]; + if (OS.CFURLGetFSRef(url, fsRef)) { + int [] type = new int[1]; + OS.LSCopyItemAttribute(fsRef, OS.kLSRolesAll, OS.kLSItemContentType(), type); + if (type[0] != 0) { + int exeUti = createCFString("public.unix-executable"); //$NON-NLS-1$ + result = OS.UTTypeConformsTo(type[0], exeUti); + OS.CFRelease(exeUti); + if (!result) { + int scriptUti = createCFString("public.shell-script"); //$NON-NLS-1$ + result = OS.UTTypeEqual(type[0], scriptUti); + OS.CFRelease(scriptUti); + } + OS.CFRelease(type[0]); + } + } + OS.CFRelease(url); + } } } + OS.free(ptr); } - OS.free(ptr); OS.CFRelease(str); } return result; } +static int createCFString(String string) { + char [] buffer = new char[string.length()]; + string.getChars(0, buffer.length, buffer, 0); + return OS.CFStringCreateWithCharacters(OS.kCFAllocatorDefault, buffer, buffer.length); +} + /** * Launches the operating system executable associated with the file or * URL (http:// or https://). If the file is an executable then the |