Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Set a editor to non-editable
Set a editor to non-editable [message #302656] Wed, 26 April 2006 11:58
Eclipse UserFriend
Originally posted by: riad.djemili.gmail.com

Hello,

I'm having the following problem: I want to disable/enable the editing
capability of any text editor if a specific event occurs. In other
words: I want to do a setEditable(false/true) on any text editor that
the user might currently be working with. The resource of the editor
should still be displayed, but be in a kind of read-only state.

I tried to do this by using the method setEditable on the viewer inside
of the editor. This doesn't work though, because by tracing the code I
found out that the editor performs a sanity check in specific time
intervals. In this sanity check he calls isEditable(Object input) on the
DocumentProvider of the editor and resets the editable-state of the
viewer, therefore reseting my formerly set state.

I thought of three other solutions:

1) Using a custom DocumentProvider on which I implement my custom
isEditable-method. My DocumentProvider would just implement that one
method and forward all other calls to the regular DocumentProvider for
that Editor.

The problem is that this is supposed to work with all possible Editors
for text documents (e.g. *.java, *.txt, *.cpp etc.). If I just put my
custom DocumentProvider in the DocumentProviderRegistry I can't access
the former DocumentProvider anymore and don't know to who I'd have to do
the forwarding.

2) Set the editor resource to read-only by setting new file attributes.
This might work, but I noticed that when the user tries to edit a
read-only file, he gets prompted with a dialog that asks him, if he
wants to disable the read-only state. I don't want this to happen.

Is there some way to disable that dialog?

3) Listen to all keyboard inputs or document changes on the specific
editor and cancel them if the editor shouldn't be editable. I'm not sure
if this possible though.

Is it actually possible to veto a documentChanged event?

-

Okay, I hope this wasn't too complicated and that I made my problem
clear. If you can contribute with any ideas or pointers, I'd be very
thankful. I'm relatively new to the Eclipse platform, so please excuse
if I overlooked something obvious. Thanks for reading my post!

Greetings,
Riad
Previous Topic:Find & Install takes forever
Next Topic:Accessing plugin data
Goto Forum:
  


Current Time: Thu Jun 19 18:46:59 EDT 2025

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

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

Back to the top