Home » Eclipse Projects » Eclipse Platform » How to make one page on a Multi-Page read-only ?
How to make one page on a Multi-Page read-only ? [message #326694] |
Fri, 28 March 2008 15:37  |
Eclipse User |
|
|
|
Originally posted by: marcio.debarros.gmail.com
Hi,
I have a MultiPage that implements a FormEditor, and it has 4 pages.
Three of these pages are form pages and have sub-sets of the model, and
the last page is a plain text editor, which has the complete model in a
XML format. All changes to the model must be made through one of the
form pages, and once the Save button is pressed, it should update the
XML text. However the users should be able to see the text based page,
but can not type or make changes directly to it.
Any suggestion on how can I do that ?
Thanks,
--MD.
|
|
| |
Re: How to make one page on a Multi-Page read-only ? [message #326752 is a reply to message #326729] |
Mon, 31 March 2008 11:17   |
Eclipse User |
|
|
|
Originally posted by: marcio.debarros.gmail.com
Eric Rizzo wrote:
> Marcio DeBarros wrote:
>> Hi,
>>
>> I have a MultiPage that implements a FormEditor, and it has 4 pages.
>> Three of these pages are form pages and have sub-sets of the model,
>> and the last page is a plain text editor, which has the complete model
>> in a XML format. All changes to the model must be made through one of
>> the form pages, and once the Save button is pressed, it should update
>> the XML text. However the users should be able to see the text based
>> page, but can not type or make changes directly to it.
>
> It would depend on what class implements that text editor - I would
> imagine whatever it is, it has a read-only or editable property that can
> be set...
>
> Eric
Hi Eric,
The class is org.eclipse.ui.editors.text.TextEditor, the only two
methods that make a reference to a read-only state are:
isEditorInputReadOnly() and isEditorInputModifiable() inherited from
AbstractTextEditor. I also looked at the IEditorInput hierarchy and
there is nothing there as well. But I am not sure if the EditorInput is
the answer for me, because what I am trying to do is to prevent changes
to be made from that specific page, while the file (EditorInput) can be
modified.
It is like if on the plugin.xml editor you could make and save changes
from to the file from the Extensions tab, but could only see, not even
type on the plugin.xml tab.
|
|
|
Re: How to make one page on a Multi-Page read-only ? [message #326765 is a reply to message #326752] |
Mon, 31 March 2008 21:56   |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
Marcio DeBarros wrote:
> Eric Rizzo wrote:
>> Marcio DeBarros wrote:
>>> Hi,
>>>
>>> I have a MultiPage that implements a FormEditor, and it has 4 pages.
>>> Three of these pages are form pages and have sub-sets of the model,
>>> and the last page is a plain text editor, which has the complete
>>> model in a XML format. All changes to the model must be made through
>>> one of the form pages, and once the Save button is pressed, it should
>>> update the XML text. However the users should be able to see the text
>>> based page, but can not type or make changes directly to it.
>>
>> It would depend on what class implements that text editor - I would
>> imagine whatever it is, it has a read-only or editable property that
>> can be set...
>>
>> Eric
>
>
> Hi Eric,
>
> The class is org.eclipse.ui.editors.text.TextEditor, the only two
> methods that make a reference to a read-only state are:
>
> isEditorInputReadOnly() and isEditorInputModifiable() inherited from
> AbstractTextEditor. I also looked at the IEditorInput hierarchy and
> there is nothing there as well. But I am not sure if the EditorInput is
> the answer for me, because what I am trying to do is to prevent changes
> to be made from that specific page, while the file (EditorInput) can be
> modified.
Would it be enough for you to subclass TextEditor and override one of
those methods or isEditable() to return false?
It is kind of a brute-force approach, but might be the most
straightforward approach. From looking at the implementations of those
methods, it looks like the other way is to get knee deep into document
providers.
Hope this helps,
Eric
|
|
|
Re: How to make one page on a Multi-Page read-only ? [message #326796 is a reply to message #326765] |
Tue, 01 April 2008 10:08  |
Eclipse User |
|
|
|
Originally posted by: marcio.debarros.gmail.com
Eric Rizzo wrote:
> Marcio DeBarros wrote:
>> Eric Rizzo wrote:
>>> Marcio DeBarros wrote:
>>>> Hi,
>>>>
>>>> I have a MultiPage that implements a FormEditor, and it has 4 pages.
>>>> Three of these pages are form pages and have sub-sets of the model,
>>>> and the last page is a plain text editor, which has the complete
>>>> model in a XML format. All changes to the model must be made through
>>>> one of the form pages, and once the Save button is pressed, it
>>>> should update the XML text. However the users should be able to see
>>>> the text based page, but can not type or make changes directly to it.
>>>
>>> It would depend on what class implements that text editor - I would
>>> imagine whatever it is, it has a read-only or editable property that
>>> can be set...
>>>
>>> Eric
>>
>>
>> Hi Eric,
>>
>> The class is org.eclipse.ui.editors.text.TextEditor, the only two
>> methods that make a reference to a read-only state are:
>>
>> isEditorInputReadOnly() and isEditorInputModifiable() inherited from
>> AbstractTextEditor. I also looked at the IEditorInput hierarchy and
>> there is nothing there as well. But I am not sure if the EditorInput
>> is the answer for me, because what I am trying to do is to prevent
>> changes to be made from that specific page, while the file
>> (EditorInput) can be modified.
>
> Would it be enough for you to subclass TextEditor and override one of
> those methods or isEditable() to return false?
>
> It is kind of a brute-force approach, but might be the most
> straightforward approach. From looking at the implementations of those
> methods, it looks like the other way is to get knee deep into document
> providers.
>
> Hope this helps,
> Eric
I took an approach similar do what you suggested by extending TextEditor
and then creating two methods disablePage() and enablePage(), inside
each method is call: getSourceViewer().setEditable(true || false);
Then from the main editor before the text page goes in focus I disable
it, and enable it for all the others.
Thanks for your help Eric.
--Marcio.
|
|
|
Goto Forum:
Current Time: Mon Apr 14 22:29:56 EDT 2025
Powered by FUDForum. Page generated in 0.02922 seconds
|