简体   繁体   English

SWT FileDialog在使用Oracle Java 7的Mac OSX上无法正常运行

[英]SWT FileDialog does not work correctly on Mac OSX with Oracle Java 7

It seems file chooser dialogs are not working properly with SWT on Mac OSX 64-bit, with Oracle Java 7: 在Mac OSX 64位上,使用Oracle Java 7,文件选择器对话框似乎无法正常使用SWT:

FileDialog dlg = new FileDialog(shell, SWT.OPEN);
dlg.open();

One major problem is that file previews (the right-most pane that appears when selecting a file) does not work: the spinner does not stop, CPU usage increases. 一个主要问题是文件预览(选择文件时出现的最右侧窗格)不起作用:微调器不会停止,CPU使用率会增加。 Randomly, another issue is that folder contents appear empty. 随机地,另一个问题是文件夹内容显示为空。

Everything works fine with the official Apple Java 6 package. 使用官方Apple Java 6软件包,一切正常。 I tried several several versions of SWT (4.2.1, 4.2.2, 4.3, the beta 4.4 builds as well). 我尝试了几个版本的SWT(4.2.1,4.2.2,4.3,beta 4.4版本)。

Is anybody aware of a workaround? 有人知道解决方法吗? Could this be fixed at the SWT level, or is it a Java 7 issue? 这可以在SWT级别修复,还是Java 7问题?

I came across this issue also. 我也遇到过这个问题。 It appears to be a direct combination of the following (Java 7, Eclipse 3.7.2, and OSX 10.9) 它似乎是以下的直接组合(Java 7,Eclipse 3.7.2和OSX 10.9)

I found this explanation: https://bugs.eclipse.org/bugs/show_bug.cgi?id=420682 (Bug 420682 - In Indigo, Open File dialog only appears once in OS X Mavericks (10.9) ) 我发现了这个解释: https ://bugs.eclipse.org/bugs/show_bug.cgi?id = 420682(错误420682 - 在Indigo中,打开文件对话框仅在OS X Mavericks中出现一次(10.9))

I hope this helps you, but the basic message is as follows: 我希望这会对你有所帮助,但基本信息如下:

  • either upgrade to 4.x based RCP bundles, or at least 3.8.x 要么升级到基于4.x的RCP捆绑包,要么至少升级到3.8.x.
  • don't use Java 7 (I don;t recommend that one) 不要使用Java 7(我不推荐那个)

It seems the core of the issue is the -XstartOnFirstThread Java flag. 看来问题的核心是-XstartOnFirstThread Java标志。 One hack is to avoid using this flag, and implement the associated behavior (ie, starting SWT on the first thread) yourself. 一个黑客就是避免使用这个标志,并自己实现相关的行为(即,在第一个线程上启动SWT)。

Fortunately, a very helpful Eclipse contributor - Silenio Quarti - has done so, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=389486#c5 . 幸运的是,一个非常有用的Eclipse贡献者--Silenio Quarti - 已经这样做了,请参阅https://bugs.eclipse.org/bugs/show_bug.cgi?id=389486#c5 Caveat: To be integrated in a non-Mac IDE, this source needs to be refactored, and all references to org.eclipse.swt.internal.** must be done through reflection. 警告:要集成到非Mac IDE中,需要重构此源,并且必须通过反射完成对org.eclipse.swt.internal。**的所有引用。

Until Oracle and/or Apple fix the SDK version 7, this is the best and only workaround I've found thus far. 在Oracle和/或Apple修复SDK版本7之前,这是迄今为止我发现的最好和唯一的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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