|Edit readonly files [message #675842]
||Wed, 01 June 2011 12:59
| Kitesurfer ()
Registered: December 2009
I've made a plugin with a custom editor (extends TextEditor).|
When I open a readonly-file in this editor, and alter something, a messagebox comes up asking: "File is read-only. Do you wish to make it writable" ... I always click on "No" ... from that time on nothing can be altered in the editor.
How can I get rid of this messagebox and always have the editor in read-only mode when I open a read-only file ?
The message comes from the default file modification validator which is
used for unshared files. The easiest way to change this for your editor
is to use overwrite
and not call validateState(...) on the extension. Note that you should
only override the case where the file's project is not shared since for
those cases you probably want the validation done by the repository
Action:I coded beneath in the editor (which extends AbstractDecoratedTextEditor) :
protected void validateState(IEditorInput newInput)
Now everytime I change something (f.e. type 'A') in the editor, or save it, I get the messagedialog ... so that's good.
I know how to check if the editted-file is read-only.
But now, how do I prevent that something is changed in the editor(text) ? what do I have to code in validateState ?
Powered by FUDForum
. Page generated in 0.04016 seconds