[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: AbstractTextEditor.isEditable() returns true on read-only files
|
- From: jbognar@xxxxxxxxxx (James Bognar)
- Date: 12 Sep 2001 17:02:53 GMT
- Newsgroups: eclipse.tools
- Organization: http://www.eclipse.org
- User-agent: NewsPortal 0.23
Is there any way to get the behavior from build 129 with the current API?
I need to be able to display the contents of a file and not have the user
be able to modify it.
If the current behavior on read-only files is going to stay, can a method
'setEditable()' be added to the API for IResource objects?
erich gamma wrote:
> There were different reasons for this change:
> * make the read-only treatment of the eclipse
> more consistent with
> other editors. Most editors allow you to edit a
> file even when it is read-only on disk.
> * versioning systems are using the read-only state
> to indicate that a file is not checked out.
> Consider the following scenario:
> 1) the user opens a read-only file in an editor
> 2) decides to check it out the file in the file system
> (file is changed to read-write).
> ->the user has to close and reopen the editor to be
> able to change the file.
> --erich
> James Bognar wrote:
> > I've noticed a change in behavior between the 129 and 135 drops in
> > AbstractTextEditor. I have java source files in my workspace which are
> > supposed to be read-only and uneditable. In the 129 drop, when I set the
> > IFile object to read-only, the Java Editor would not allow the user to
> > modify the contents of the file, and this was the behavior I wanted. Now
> > in 135, the user DOES have the ability to change the contents, even if the
> > file is read-only (although the user still isn't allowed to save the
> > modified contents).
> > Here are the relevant lines that were changed in
> > AbstractTextEditor.isEditable():
> > WAS:
> > IStorage storage= storageInput.getStorage();
> > return (storage != null && !storage.isReadOnly());
> > IS:
> > IStorage storage= storageInput.getStorage();
> > return (storage != null && (storageInput instanceof IFileEditorInput ||
> > !storage.isReadOnly()));
> > Why the change? And is there any way to make the file uneditable again?
> > Also, why do we prompt a user with a 'Save Resource' dialog box when
> > closing an editor on a read-only file?
> > And the error dialog box that is displayed when a user tries to save a
> > read-only file could probably look a little better. Right now the dialog
> > box makes it look like there is a bug in Eclipse (contains the words 'Core
> > Exception'), instead of looking like a user error.
> > Thanx.