Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Edit readonly files(Get rid of msgbox)
Edit readonly files [message #675842] Wed, 01 June 2011 16:59
Kitesurfer () is currently offline Kitesurfer ()Friend
Messages: 87
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
org.eclipse.ui.texteditor.AbstractTextEditor.validateState(I EditorInput)
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)
MessageDialog.openInformation(null,"validateState", "in");

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 ?
Previous Topic:Trouble with Target Definition File using Software Sites to define a target
Next Topic:Programmatic open Remote Search
Goto Forum:

Current Time: Mon Jul 26 21:06:14 GMT 2021

Powered by FUDForum. Page generated in 0.01684 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top