Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make read only editor in Eclipse (Eclipse Plugin Development)

I'm wondering how to make a really read only eclipse editor.. My editor extends TextEditor, so when I reimplement method isEditable to always return false.

It's the easiest way, which prevents user from typing or deleting anything in the document opened in the editor. But you can still change content of the document for example by using find/replace. And this is not desired..

Is there any other aesy way how to arhieve this goal?

like image 885
Martin Lazar Avatar asked Jun 16 '09 12:06

Martin Lazar


People also ask

How do I change my eclipse from read only?

A plugin can do this. But I thought up a tricky one. Set all the files under that project as read-only, and make them only writable and controllable by Admin Group, then start eclipse without admin privilege. I've tested that the dialog won't show up.

What is text editor in Eclipse?

The text editor framework provides the abstract implementation of an Eclipse text editor. The File Buffers plug-in which introduces text file buffers for shared access to the content of a text file in form of an IDocument and and associated IAnnotationModel.


1 Answers

I wanted to use editor instead of viewer because the editor was already made, so I just used a 3rd party plugin..

I found my solution - maybee not very clean but does the job and is pretty easy so it wins

I've overriden theese methods:

@Override
public boolean isEditable() {
    return false;
}

@Override
public boolean isEditorInputModifiable() {
    return false;
}

@Override
public boolean isEditorInputReadOnly() {
    return true;
}

@Override
public boolean isDirty() {
    return false;
}
like image 163
Martin Lazar Avatar answered Nov 13 '22 00:11

Martin Lazar