Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to set an editor unmodifiable?
How to set an editor unmodifiable? [message #497621] Fri, 13 November 2009 09:57 Go to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

I have to open arbitrary editors in my RCP app programmatically. But the
user mustn't modify the content. is it possible to set the editor
unmodifiable?
Re: How to set an editor unmodifiable? [message #497728 is a reply to message #497621] Fri, 13 November 2009 11:25 Go to previous messageGo to next message
Juan is currently offline Juan
Messages: 29
Registered: July 2009
Junior Member
Don't implement doSave().

Also do:
public boolean isDirty() {
return false;
}

In this way users never could save anything.

Good Luck!

Gilbert Mirenque escribió:
> I have to open arbitrary editors in my RCP app programmatically. But the
> user mustn't modify the content. is it possible to set the editor
> unmodifiable?
Re: How to set an editor unmodifiable? [message #497843 is a reply to message #497728] Fri, 13 November 2009 13:11 Go to previous messageGo to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

Yes this is the way how I can do it if I implement the editors by my
own. But the editors already exist and I can I don't know which editors
will be opened before.

> Don't implement doSave().
>
> Also do:
> public boolean isDirty() {
> return false;
> }
>
> In this way users never could save anything.
>
> Good Luck!
>
Re: How to set an editor unmodifiable? [message #497893 is a reply to message #497621] Fri, 13 November 2009 14:20 Go to previous messageGo to next message
Eclipse User
Originally posted by: wangqs_eclipse.yahoo.com

This is a multi-part message in MIME format.
--------------030904090906020500000805
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Can you take over the control of opening editor process? What's the way
of open the editor? Double click in eclipse view, e.g. Project explorer,
or via you own action?

I think it's possible if you can take over the opening process. Can you
let me know more details?

Q.S. Wang


Gilbert Mirenque wrote:
> I have to open arbitrary editors in my RCP app programmatically. But the
> user mustn't modify the content. is it possible to set the editor
> unmodifiable?


--------------030904090906020500000805
Content-Type: text/x-vcard; charset=utf-8;
name="wangqs_eclipse.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="wangqs_eclipse.vcf"

YmVnaW46dmNhcmQNCmVtYWlsO2ludGVybmV0Ondhbmdxc19lY2xpcHNlQHlh aG9vLmNvbQ0K
dXJsOmh0dHA6Ly93d3cubXllY2xpcHNlZGV2LmNvbQ0KdmVyc2lvbjoyLjEN CmVuZDp2Y2Fy
ZA0KDQo=
--------------030904090906020500000805--
Re: How to set an editor unmodifiable? [message #498077 is a reply to message #497893] Sat, 14 November 2009 09:21 Go to previous messageGo to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

Hi Wang,
yes I have control of opening the editor.

IWorkbenchPage page = window.getActivePage();
IEditorInput input = // generically determine input
String editorID = // determine id for input
IEditorPart editorPart = page.openEditor(input, newEditorID);

Input and id definitely belong together. I searched in the editorPart
for possibilities of setting it unmodifiable but without success. Do you
have an idea?
Re: How to set an editor unmodifiable? [message #498221 is a reply to message #497893] Mon, 16 November 2009 00:03 Go to previous messageGo to next message
Eclipse User
Originally posted by: formatzeh.gmx.de

Hi Wang, can you say something with the information a gave in my last post?
Re: How to set an editor unmodifiable? [message #498224 is a reply to message #498077] Mon, 16 November 2009 00:55 Go to previous messageGo to next message
Eclipse User
Originally posted by: wangqs_eclipse.yahoo.com

This is a multi-part message in MIME format.
--------------090104010507040702020107
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Gilbert,
Sorry I didn't check new group at weekend :)
I assume the input is an IFileEditorInput.

1. You need write a FileEditorInput wrapper.

2. File Wrapper which indicates all files as readonly.

The idea is that in the FileEditorInput wrapper delegates all the method
to the warpped FileEditorInput, but overwrite the getFile method. In the
getFile method, return the read only file wrapper.

Since all other methods are just delegating to the original one, it'll
not affect the normal file opening process. The only change is that all
files will be marked as read only, so that the editor will be read only
as well.

Hope this is clear.

Cheers
Q.S. Wang


Gilbert Mirenque wrote:
> Hi Wang,
> yes I have control of opening the editor.
>
> IWorkbenchPage page = window.getActivePage();
> IEditorInput input = // generically determine input
> String editorID = // determine id for input
> IEditorPart editorPart = page.openEditor(input, newEditorID);
>
> Input and id definitely belong together. I searched in the editorPart
> for possibilities of setting it unmodifiable but without success. Do you
> have an idea?


--
http://www.myeclipsedev.com/

--------------090104010507040702020107
Content-Type: text/x-vcard; charset=utf-8;
name="wangqs_eclipse.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="wangqs_eclipse.vcf"

YmVnaW46dmNhcmQNCmVtYWlsO2ludGVybmV0Ondhbmdxc19lY2xpcHNlQHlh aG9vLmNvbQ0K
dXJsOmh0dHA6Ly93d3cubXllY2xpcHNlZGV2LmNvbQ0KdmVyc2lvbjoyLjEN CmVuZDp2Y2Fy
ZA0KDQo=
--------------090104010507040702020107--
Re: How to set an editor unmodifiable? [message #498259 is a reply to message #498224] Mon, 16 November 2009 08:43 Go to previous message
Eclipse User
Originally posted by: formatzeh.gmx.de

Hi Wang,
yes this is clear. I imagined that it is possible with a wrapper but I
thought there is a setModifiable method or something similar anywhere ;)
Thanks so much.

best regards,
Gilbert


> Hi Gilbert,
> Sorry I didn't check new group at weekend :)
> I assume the input is an IFileEditorInput.
>
> 1. You need write a FileEditorInput wrapper.
>
> 2. File Wrapper which indicates all files as readonly.
>
> The idea is that in the FileEditorInput wrapper delegates all the method
> to the warpped FileEditorInput, but overwrite the getFile method. In the
> getFile method, return the read only file wrapper.
>
> Since all other methods are just delegating to the original one, it'll
> not affect the normal file opening process. The only change is that all
> files will be marked as read only, so that the editor will be read only
> as well.
>
> Hope this is clear.
>
> Cheers
> Q.S. Wang
>
>
> Gilbert Mirenque wrote:
>> Hi Wang,
>> yes I have control of opening the editor.
>>
>> IWorkbenchPage page = window.getActivePage();
>> IEditorInput input = // generically determine input
>> String editorID = // determine id for input
>> IEditorPart editorPart = page.openEditor(input, newEditorID);
>>
>> Input and id definitely belong together. I searched in the editorPart
>> for possibilities of setting it unmodifiable but without success. Do you
>> have an idea?
>
>
Previous Topic:How to set the editor title?
Next Topic:Workbench rearranging preview border
Goto Forum:
  


Current Time: Thu Oct 30 17:51:51 GMT 2014

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

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