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!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.