How to make an editor readonly [message #336240] |
Tue, 02 June 2009 16:25  |
Eclipse User |
|
|
|
Originally posted by: bulklodd.yandex.ru
Hi,
How to show a file in the editor in readonly mode without changing its
readonly attribute?
Thanks in advance,
Sergey Klimov
|
|
|
|
|
|
|
Re: How to make an editor readonly [message #336312 is a reply to message #336280] |
Fri, 05 June 2009 14:41  |
Eclipse User |
|
|
|
Originally posted by: bulklodd.yandex.ru
Hi Wim,
I've found out a clumsy way to do that
ITextEditor editor = (ITextEditor) page.getActiveEditor();
ITextViewer viewer =
(ITextViewer)editor.getAdapter(ITextOperationTarget.class);
if (viewer != null) {
viewer.setEditable(false);
}
without changing the readonly attribute, but it's really clumsy. At least it
a bit prevents from user modification.
Regards,
Sergey Klimov
"Wim Jongman" <wim.jongman@gmail.com> wrote in message
news:h09jkn$v06$2@build.eclipse.org...
> Hi Sergey,
>
> Can't you take a local copy of the file and make that read-only? What
> editor
> is called, is it your own editor or the defaul editor for the file type?
>
> Best Regards,
>
> Wim Jongman
> Posted with Salvo, the Eclipse based newsreader
>
>> I suppose the code will explain that better
>>
>> IFileStore fileStore =
>> EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
>> IWorkbenchPage page =
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>>
>> try {
>> IDE.openEditorOnFileStore( page, fileStore );
>> // I want to add some code here to prevent user from modifying the file
>> // I don't want to change file's attribute because it might be located
>> on samba server
>> // and this attribute might just not work
>> }
>>
>> Thanks in advance
>>
>> "Eric Rizzo" <eclipse-news@rizzoweb.com> wrote in message
>> news:h0690g$9sn$3@build.eclipse.org...
>>> Sergey Klimov wrote:
>>>> Hi,
>>>>
>>>> How to show a file in the editor in readonly mode without changing its
>>>> readonly attribute?
>>>
>>> Which editor? Specifically Java, or any editor in general?
>>>
>>> Eric
>>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03195 seconds