Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to make an editor readonly
How to make an editor readonly [message #336240] Tue, 02 June 2009 20:25 Go to next message
Eclipse UserFriend
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 #336241 is a reply to message #336240] Wed, 03 June 2009 06:58 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Sergey Klimov wrote:
> Hi,
>
> How to show a file in the editor in readonly mode without changing its
> readonly attribute?
From the UI there's no other way than that.

Dani
>
> Thanks in advance,
> Sergey Klimov
Re: How to make an editor readonly [message #336251 is a reply to message #336240] Wed, 03 June 2009 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

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
Re: How to make an editor readonly [message #336256 is a reply to message #336251] Wed, 03 June 2009 19:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bulklodd.yandex.ru

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
>
Re: How to make an editor readonly [message #336280 is a reply to message #336256] Thu, 04 June 2009 22:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wim.jongman.gmail.com

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
>>
Re: How to make an editor readonly [message #336312 is a reply to message #336280] Fri, 05 June 2009 18:41 Go to previous message
Eclipse UserFriend
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
>>>
>
Previous Topic:CollapseAll Action(Ctrl+Shift+Numpad_Divide) is specific to java editor
Next Topic:How to tailor the Conext menu of text editor?
Goto Forum:
  


Current Time: Fri Apr 19 09:47:20 GMT 2024

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

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

Back to the top