具有CFBundleDocumentTypes的JavaApplicationStub [英] JavaApplicationStub with CFBundleDocumentTypes

查看:121
本文介绍了具有CFBundleDocumentTypes的JavaApplicationStub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CFBundleDocumentTypes将自定义文件扩展名与我的应用程序关联.据我所知,这似乎是有效的"-当我双击文件时,JavaApplicationStub会启动我的应用程序.但是,没有通过我在Java中设置的ApplicationListener事件注册任何回调.

I'm trying to use CFBundleDocumentTypes to associate a custom file extension with my application. As far as I can tell, this seems to "work" -- JavaApplicationStub launches my application when I double click the file. However, no callback is registered through the ApplicationListener events I setup in java.

我使用了设置中列出的代码默认文件关联Mac OS X Java Package Maker安装程序进行文件关联,并且文件关联本身看起来不错,但似乎是试图启动文件的应用程序存根,因此失败.

I used the code listed in Set Default file association Mac OS X Java Package Maker Installer to do the file association, and the file association itself appears fine, but it seems as if it is the application stub trying to launch the file, and thus fails.

我将Apple ApplicatinListener代码添加到了我的Java应用程序中(类似于 http://developer.apple.com/mac/library/documentation/Java/Reference/1.5.0/appledoc/api/index .html?com/apple/eawt/Application.html ),但似乎我的应用程序从未收到过回电.

I added the Apple ApplicatinListener code to my java application at (similar to http://developer.apple.com/mac/library/documentation/Java/Reference/1.5.0/appledoc/api/index.html?com/apple/eawt/Application.html) but it doesn't seem like my application ever gets a call back.

代码类似于

Application.getApplication().addApplicationListener(
  new ApplicationAdapter() { 
    public void handleOpenFile(ApplicationEvent evt) {
      //some logging message here that I never get
    }
  }
);

我也许应该提到我也在使用SWT ...

I should perhaps mention that I'm also using SWT...

任何帮助将不胜感激

推荐答案

很遗憾,您不能同时使用SWT和eAWT的ApplicationListener.请参见 SWT错误. SWT需要从JVM中的Apple进行更改,然后我必须更改SWT才能使用它.

Unfortunately you can't use the SWT and the eAWT's ApplicationListener at the same time. See this SWT bug. The SWT needs a change from Apple in the JVM, and then I have to change the SWT to use it.

但是,由于您对打开文件事件感兴趣,因此您现在可以完全在所有平台上的SWT中进行此操作.在3.6 SWT中,有一个新事件SWT.OpenDocument,当双击您应用程序的文件时将触发该事件.参见此博客文章并搜索"SWT.OpenDocument".

Since you are interested in an open file event, though, you can now do that entirely in SWT across all platforms. In the 3.6 SWT there is a new event SWT.OpenDocument that will fire when a file for your app is double-clicked. See this blog post and search for "SWT.OpenDocument".

这篇关于具有CFBundleDocumentTypes的JavaApplicationStub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆