Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Action contribution for embedded text editors in editors ?
Action contribution for embedded text editors in editors ? [message #131354] Wed, 17 September 2003 19:40 Go to next message
Eclipse UserFriend
Hello there,

I have a problematic question concerning text editors embedded in
'standard' eclipse editors.

What I have is an AbstractTextEditor instantiated as a control
within a top-level editor.
This is of course not the recommended way to use the editors,
but the top-level editor needs to present some fields along with
a script to be edited. The inner editor is given a custom
EditorInput, and is initialized using the top-level editor site.

e.g.

class InnerEditor extends AbstractTextEditor {

public InnerEditor( IEditorSite site,
InnerEditorInput input,
Composite parent ) {
...
setRulerContextMenuId( "#InnerRulerContext" );
init( site, input );
createPartControl( parent );
}
...
}

I really need to be an AbstractTextEditor to benefit of
actions bindings, rulers & markers management,
for example to set tasks & bookmarks within the inner editor.

Then I need to contribute actions to the inner editor
ruler context menu, from a different plugin.
(otherwise I would have done it in the rulerContextMenuAboutToShow()
of InnerEditor, but it would be too simple ;-)

So I have an InnerActionDelegate extending AbstractRulerActionDelegate,
declared as following in the plugin.xml:

<extension
point="org.eclipse.ui.popupMenus">
<viewerContribution
id="InnerPopupActions"
targetID="#InnerRulerContext">
<action
label="XXXXX"
id="mycompany.InnerActionDelegate"
class="InnerActionDelegate"
menubarPath="whatever">
</action>
</viewerContribution>
</extension>

The issue is that the delegate setActiveEditor(IAction,IEditorPart)
with the editor part of the toplevel editor, which is not by itself
an ITextEditor, so the AbstractRulerActionDelegate is not able
to fetch the ruler and initialize properly the action.

I can circumvent this by overriding setActiveEditor, and replacing
the targetEditor by the inner editor through typecasts and lookup
in the controls. This works as long as I only have only one inner
editor per top-level editor; but this is not gonna be the case,
and it is a bit (more) kludgy.

I can also do a fake part activation on the inner editor by
registering on focus or mouse events on the inner editor ruler,
but I feel it rather dangerous to fire a part activated event
for an editor which is not a real top-level editor...

So, does someone have an idea on how to bind the actions for the
inner editor in a simple and (almost) clean way ?

Thanks in advance,

--Steve
Re: Action contribution for embedded text editors in editors ? [message #132134 is a reply to message #131354] Thu, 18 September 2003 10:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: simon.ibm.oti.lab

Open a bug report against platform - ui

Simon :-)

"Eric Estievenart" <eric.estievenart@peregrine.com> wrote in message
news:oprvn319lk9ck0a6@localhost...
>
> Hello there,
>
> I have a problematic question concerning text editors embedded in
> 'standard' eclipse editors.
>
> What I have is an AbstractTextEditor instantiated as a control
> within a top-level editor.
> This is of course not the recommended way to use the editors,
> but the top-level editor needs to present some fields along with
> a script to be edited. The inner editor is given a custom
> EditorInput, and is initialized using the top-level editor site.
>
> e.g.
>
> class InnerEditor extends AbstractTextEditor {
>
> public InnerEditor( IEditorSite site,
> InnerEditorInput input,
> Composite parent ) {
> ...
> setRulerContextMenuId( "#InnerRulerContext" );
> init( site, input );
> createPartControl( parent );
> }
> ...
> }
>
> I really need to be an AbstractTextEditor to benefit of
> actions bindings, rulers & markers management,
> for example to set tasks & bookmarks within the inner editor.
>
> Then I need to contribute actions to the inner editor
> ruler context menu, from a different plugin.
> (otherwise I would have done it in the rulerContextMenuAboutToShow()
> of InnerEditor, but it would be too simple ;-)
>
> So I have an InnerActionDelegate extending AbstractRulerActionDelegate,
> declared as following in the plugin.xml:
>
> <extension
> point="org.eclipse.ui.popupMenus">
> <viewerContribution
> id="InnerPopupActions"
> targetID="#InnerRulerContext">
> <action
> label="XXXXX"
> id="mycompany.InnerActionDelegate"
> class="InnerActionDelegate"
> menubarPath="whatever">
> </action>
> </viewerContribution>
> </extension>
>
> The issue is that the delegate setActiveEditor(IAction,IEditorPart)
> with the editor part of the toplevel editor, which is not by itself
> an ITextEditor, so the AbstractRulerActionDelegate is not able
> to fetch the ruler and initialize properly the action.
>
> I can circumvent this by overriding setActiveEditor, and replacing
> the targetEditor by the inner editor through typecasts and lookup
> in the controls. This works as long as I only have only one inner
> editor per top-level editor; but this is not gonna be the case,
> and it is a bit (more) kludgy.
>
> I can also do a fake part activation on the inner editor by
> registering on focus or mouse events on the inner editor ruler,
> but I feel it rather dangerous to fire a part activated event
> for an editor which is not a real top-level editor...
>
> So, does someone have an idea on how to bind the actions for the
> inner editor in a simple and (almost) clean way ?
>
> Thanks in advance,
>
> --Steve
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
Re: Action contribution for embedded text editors in editors ? [message #139630 is a reply to message #132134] Sat, 04 October 2003 13:31 Go to previous message
Eclipse UserFriend
Adding further info here for people who may be interested.
I finally solved the issue, and indeed it does not seem to be
a bug.
I updated the top-level editor so that it can provide
editor sites to the inner editors, and manage the selection
like the MultiPageEditor does. I just had to make specific
implementations of the following classes :
- IEditorSite -> InnerEditorSite
- ISelectionProvider -> MultiEditSelectionProvider
and all the stuff in the top-level editor which
behaves mostly like the MultiPageEditor.

It is after all not so tricky and works quite well,
except maybe still some selection issues I have to
investigate, but the top-level editor even works
embedded in a MultiPageEditor (and we could even think
of putting a multipage editor in an inner editor site,
but juste for the fun because it would be ugly ;-)

Maybe the base jface framework could provide base
classes providing such kind of behaviour, but for now
I'm quite happy with it !

-- Steve - Eclipse rulezzzzzzz :-)



On Thu, 18 Sep 2003 10:53:19 -0400, Simon Arsenault <simon@ibm.oti.lab>
wrote:

> Open a bug report against platform - ui
>
> Simon :-)
>
> "Eric Estievenart" <eric.estievenart@peregrine.com> wrote in message
> news:oprvn319lk9ck0a6@localhost...
>>
>> Hello there,
>>
>> I have a problematic question concerning text editors embedded in
>> 'standard' eclipse editors.
>>
>> What I have is an AbstractTextEditor instantiated as a control
>> within a top-level editor.
>> This is of course not the recommended way to use the editors,
>> but the top-level editor needs to present some fields along with
>> a script to be edited. The inner editor is given a custom
>> EditorInput, and is initialized using the top-level editor site.
>>
>> e.g.
>>
>> class InnerEditor extends AbstractTextEditor {
>>
>> public InnerEditor( IEditorSite site,
>> InnerEditorInput input,
>> Composite parent ) {
>> ...
>> setRulerContextMenuId( "#InnerRulerContext" );
>> init( site, input );
>> createPartControl( parent );
>> }
>> ...
>> }
>>
>> I really need to be an AbstractTextEditor to benefit of
>> actions bindings, rulers & markers management,
>> for example to set tasks & bookmarks within the inner editor.
>>
>> Then I need to contribute actions to the inner editor
>> ruler context menu, from a different plugin.
>> (otherwise I would have done it in the rulerContextMenuAboutToShow()
>> of InnerEditor, but it would be too simple ;-)
>>
>> So I have an InnerActionDelegate extending AbstractRulerActionDelegate,
>> declared as following in the plugin.xml:
>>
>> <extension
>> point="org.eclipse.ui.popupMenus">
>> <viewerContribution
>> id="InnerPopupActions"
>> targetID="#InnerRulerContext">
>> <action
>> label="XXXXX"
>> id="mycompany.InnerActionDelegate"
>> class="InnerActionDelegate"
>> menubarPath="whatever">
>> </action>
>> </viewerContribution>
>> </extension>
>>
>> The issue is that the delegate setActiveEditor(IAction,IEditorPart)
>> with the editor part of the toplevel editor, which is not by itself
>> an ITextEditor, so the AbstractRulerActionDelegate is not able
>> to fetch the ruler and initialize properly the action.
>>
>> I can circumvent this by overriding setActiveEditor, and replacing
>> the targetEditor by the inner editor through typecasts and lookup
>> in the controls. This works as long as I only have only one inner
>> editor per top-level editor; but this is not gonna be the case,
>> and it is a bit (more) kludgy.
>>
>> I can also do a fake part activation on the inner editor by
>> registering on focus or mouse events on the inner editor ruler,
>> but I feel it rather dangerous to fire a part activated event
>> for an editor which is not a real top-level editor...
>>
>> So, does someone have an idea on how to bind the actions for the
>> inner editor in a simple and (almost) clean way ?
>>
>> Thanks in advance,
>>
>> --Steve
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>



--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Previous Topic:Can I browse the Internet from within Eclipse (v3 Beta)
Next Topic:How to display call stack for exceptions thrown from event loop?
Goto Forum:
  


Current Time: Sun Jun 08 02:43:57 EDT 2025

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

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

Back to the top