jface.preference.FileFieldEditor 无法指定新文件
我正在 Eclipse (3.5.2) 应用程序中设置一系列首选项,但 FileFieldEditor 出现问题。我想允许用户指定一个日志文件来打印输出。通常,这将是一个新文件。但是当我使用 FileFieldEditor 的文件选择对话框时,它抱怨该文件不存在(“值必须是现有文件”)。有没有办法在不扩展 FileFieldEditor 类的情况下抑制此错误并让 Java 创建该文件(如果该文件不存在)?谢谢!
I'm setting up a series of preferences in my Eclipse (3.5.2) application and I'm having a problem with the FileFieldEditor. I want to allow the user to specify a log file to print output to. Often, this will be a new file. But when I use the file select dialog with FileFieldEditor, it complains that the file doesn't exists ("Value must be an existing file"). Is there a way, without extending the FileFieldEditor class, to suppress this error and have Java create that file if it doesn't exist? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我查看
的源代码时org.eclipse.jface.preference.FileFieldEditor
,唯一的解决方案是扩展它并编写您自己的FileFieldEditor
版本,其中:changePressed ()
方法,以便即使文件不存在也保留文件路径,checkState()
方法以避免出现该错误消息。所以我在这里没有找到避免使用
FileFieldEditor
扩展的方法。When I look the source code of
org.eclipse.jface.preference.FileFieldEditor
, the only solution would be to extend it and write your own version of aFileFieldEditor
, with:changePressed()
method in order to keep the file path even if the file does not existscheckState()
method in order to avoid that error message.So I do not see a way to avoid that
FileFieldEditor
extension here.