Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Edit readonly files(How to get rid of ...)
Edit readonly files [message #509932] Mon, 25 January 2010 19:36 Go to next message
Kitesurfer () is currently offline Kitesurfer ()Friend
Messages: 84
Registered: December 2009
Member
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 ?
Re: Edit readonly files [message #541301 is a reply to message #509932] Sat, 19 June 2010 18:18 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 1
Registered: June 2010
Junior Member
I'm having the same problem.
Did you or anyone else find a solution?

Thanks a lot!
Best regards
Michael
Re: Edit readonly files [message #541314 is a reply to message #541301] Sat, 19 June 2010 21:21 Go to previous messageGo to next message
Kitesurfer () is currently offline Kitesurfer ()Friend
Messages: 84
Registered: December 2009
Member
No I got no reaction at all ... a bit irritating as this is www.eclipse.org

[Updated on: Sat, 19 June 2010 21:22]

Report message to a moderator

Re: Edit readonly files [message #545512 is a reply to message #509932] Thu, 08 July 2010 06:39 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3801
Registered: July 2009
Senior Member
Kitesurfer wrote:
> 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
provider.

HTH
Dani
Re: Edit readonly files [message #673463 is a reply to message #545512] Mon, 23 May 2011 17:47 Go to previous messageGo to next message
Kitesurfer () is currently offline Kitesurfer ()Friend
Messages: 84
Registered: December 2009
Member
Hi,

I'm at the point implementing this ... so I coded beneath in the editor (which extends AbstractDecoratedTextEditor) :

@Override
protected void validateState(IEditorInput newInput)
{
MessageDialog.openInformation(
null,
"validateState", //$NON-NLS-1$
"in"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

}

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) (f.e. after typing the 'A') when I'm in validateState ?

Thx.
Re: Edit readonly files [message #673572 is a reply to message #673463] Tue, 24 May 2011 06:59 Go to previous messageGo to next message
Kiran  is currently offline Kiran Friend
Messages: 1
Registered: May 2011
Junior Member
I am new to eclipse world, I was using Carbide, which is based on eclipse. I was thinking of creating an extension for it.

Please let me know if there is any way where I can create an extension/plugin so that when I open a file which is readonly, I can handle it instead of the default behaviour? In my case, I should convert the file from readonly to writable, but should also mark it as edited by a source depot tool.

Kindly tell me if this can be done.

Thanks,
Kiran
Re: Edit readonly files [message #673708 is a reply to message #673572] Tue, 24 May 2011 14:12 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3243
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

Google is your friend.

You might try vogella.de for help in writing your first plug-in.

On 24-May-11 00:59, Kiran wrote:
> I am new to eclipse world, I was using Carbide, which is based on
> eclipse. I was thinking of creating an extension for it.
>
> Please let me know if there is any way where I can create an
> extension/plugin so that when I open a file which is readonly, I can
> handle it instead of the default behaviour? In my case, I should convert
> the file from readonly to writable, but should also mark it as edited by
> a source depot tool.
> Kindly tell me if this can be done.
>
> Thanks,
> Kiran
Previous Topic:permission error in eclipse
Next Topic:.Jar file problems with a mac
Goto Forum:
  


Current Time: Fri Nov 21 16:47:19 GMT 2014

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

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