简体   繁体   中英

On Mac OS X opening my document by double clicking at the document fails if my application is not already running

On Mac OS X opening my document by double clicking at the document fails if my application is not already running

When launching my drawing application by double clicking at a document Finder shows a dialog which says:

The document "test.jdwg" could not be opened. Application "jDraft" cannot open files in the "jDraft Document" format.

在此处输入图片说明

This message dialog appears before my application has time to even put up its splash screen, however the application is launched in the background (I see the splash screen) and when I double click again at the document my application correctly opens it.

As a background this application has been working (in this respect) for years. This problem appeared now when I'm trying to use the JWrapper to package my application.

Following is Info.plist for my application.

I suspect this maybe related to the way JWrapper lauches or forks the JVM to run the application ... hard to tell because JWrapper is closed source and thus pretty much beyond debuggin.

Has anyone managed to make file associations work with JWrapper on Mac OS X?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleName</key>
    <string>jDraft</string>
    <key>CFBundleIdentifier</key>
    <string>jwrapper.osx.jDraft</string>
    <key>CFBundleVersion</key>
    <string>43568712</string>
    <key>CFBundleAllowMixedLocalizations</key>
    <string>true</string>
    <key>CFBundleExecutable</key>
    <string>osxwrapper</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>LSUIElement</key>
    <true/>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleIconFile</key>
    <string>AppLogo.icns</string>
    <key>NSHighResolutionCapable</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>jDraft Drawing 2</string>
            <key>LSHandlerRank</key>
            <string>Default</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleTypeIconFile</key>
            <string>jDraft-doc-jdwg.icns</string>
            <key>CFBundleTypeExtensions</key>
            <array>
                <string>jdwg</string>
            </array>
            <key>CFBundleTypeOSTypes</key>
            <array>
                <string>jdwg</string>
            </array>
        </dict>
    </array>
</dict>
</plist>

I think I can confirm this is a JWrapper issue and one that cannot be satisfactorily solve at this point in time.

I copied all the stuff from the JWrapper produced bundle to my original app bundle which does not have this problem (by amazing luck there are no conflicting file names!).

My app still worked beautifully.

I then changed this one attribute in the 'Info.plist'

<key>CFBundleExecutable</key>
<string>JavaApplicationStub</string>

to

<key>CFBundleExecutable</key>
<string>osxwrapper</string>

and the problem becomes back, meaning that I get the 'cannot open' dialog while the application launches.

So my conclusion is that this is not Mac OS / Finder that is doing this and putting up the dialog but it is the JWrapper osxwrapper that puts up the dialog and fails to pass the document to my Java code or swallows the 'open document event'.

I also tried the osxlauncher executable in that the JWrapper puts into the .app/Contents/MacOS folder -- same result.

Maybe there is a way to tell osxwrapper that my application can open these document but I have not been able to find any documentation. Or maybe this is a not supported feature, which would be a serious omission in an otherwise great product.

Either way it would be nice to get a definitive answer from JWrapper people so that I could stop wasting my time with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM