jface.preference.FileFieldEditor无法指定新文件 [英] jface.preference.FileFieldEditor can't specify a new file

查看:107
本文介绍了jface.preference.FileFieldEditor无法指定新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse(3.5.2)应用程序中设置了一系列首选项,而且我遇到了FileFieldEditor的问题。我想允许用户指定一个日志文件来打印输出。通常这将是一个新的文件。但是当我使用FileFieldEditor的文件选择对话框时,它会抱怨该文件不存在(值必须是现有文件)。有没有一种方法,没有扩展FileFieldEditor类,以抑制此错误,并且Java创建该文件(如果不存在)?谢谢!

解决方案

当我查看 org.eclipse.jface.preference.FileFieldEditor ,唯一的解决方案是扩展它,并且编写自己的版本的 FileFieldEditor ,其中包含:




  • 覆盖 changePressed()方法,以便保留文件路径,即使文件不存在

  • 覆盖 checkState()方法以避免该错误消息。



所以我没有办法避免在这里 FileFieldEditor 扩展。


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!

解决方案

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 a FileFieldEditor, with:

  • an overwritten changePressed() method in order to keep the file path even if the file does not exists
  • an overwritten checkState() method in order to avoid that error message.

So I do not see a way to avoid that FileFieldEditor extension here.

这篇关于jface.preference.FileFieldEditor无法指定新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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