ActionBarContributor with a multi page editor [message #77863] |
Mon, 05 May 2003 03:19  |
Eclipse User |
|
|
|
Originally posted by: lauri.pesonen.iki.fi
Might be that this is more of an Eclipse issue than a GEF issue...
I have a multi page editor where one of the pages is a
GraphicalEditorWithPalette. I've bound an ActionBarContributor to the multi
page editor via the plugin.xml file (contributorClass attribute in the
editor tag). The ActionBarContributor adds global action keys for undoing,
redoing, printing, and adds a menu for zooming in and out.
My problem is that the actions are available although the multi page editor
tab that is currently active is not the GEF editor. I.e. I can activate
Undo (both from the menu and from via CTRL-Z) in one of my other editors
which will e.g. undo the last node move that I did in the GEF editor.
The contributor is requested from the multi page editor by calling its
getAdapter() method with ActionRegistry.class as an attribute. I delegate
this call to my GEF editor which returns the ActionRegistry.
I noticed that the ActionBarContributor.setActiveEditor() method is not
called when I switch between the multi page editor tabs, so I cannot
provide the contributor with different action registries for different
editor pages.U
--
Lauri
|
|
|
[jface] Re: ActionBarContributor with a multi page editor [message #77880 is a reply to message #77863] |
Mon, 05 May 2003 12:02   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
When you switch pages, you could re-map your global action handlers by
calling setActiveEditor again in the actionbar contributor. You could also
write your own code to (re)register global action handlers at any time/place
whenever the users "context" changes, such as pages.
You would probably have to override getAdapter on your multipage editor to
call getAdapter on the active page. Then, whenever pages change, the
actionregistry would come from the active page. GEF action bar contributor
is not that significant, and you may be better off writing your own from
scratch.
"Lauri Pesonen" <lauri.pesonen@iki.fi> wrote in message
news:gfofzntj1wj.fsf@elan.cs.hut.fi...
>
> Might be that this is more of an Eclipse issue than a GEF issue...
>
> I have a multi page editor where one of the pages is a
> GraphicalEditorWithPalette. I've bound an ActionBarContributor to the
multi
> page editor via the plugin.xml file (contributorClass attribute in the
> editor tag). The ActionBarContributor adds global action keys for undoing,
> redoing, printing, and adds a menu for zooming in and out.
>
> My problem is that the actions are available although the multi page
editor
> tab that is currently active is not the GEF editor. I.e. I can activate
> Undo (both from the menu and from via CTRL-Z) in one of my other editors
> which will e.g. undo the last node move that I did in the GEF editor.
>
> The contributor is requested from the multi page editor by calling its
> getAdapter() method with ActionRegistry.class as an attribute. I delegate
> this call to my GEF editor which returns the ActionRegistry.
>
> I noticed that the ActionBarContributor.setActiveEditor() method is not
> called when I switch between the multi page editor tabs, so I cannot
> provide the contributor with different action registries for different
> editor pages.U
>
> --
> Lauri
|
|
|
Re: [jface] Re: ActionBarContributor with a multi page editor [message #78254 is a reply to message #77880] |
Wed, 07 May 2003 05:28   |
Eclipse User |
|
|
|
Originally posted by: lauri.pesonen.iki.fi
"Randy Hudson" <none@us.ibm.com> writes:
> When you switch pages, you could re-map your global action handlers by
> calling setActiveEditor again in the actionbar contributor. You could also
> write your own code to (re)register global action handlers at any time/place
> whenever the users "context" changes, such as pages.
>
> You would probably have to override getAdapter on your multipage editor to
> call getAdapter on the active page. Then, whenever pages change, the
> actionregistry would come from the active page. GEF action bar contributor
> is not that significant, and you may be better off writing your own from
> scratch.
Did some more digging. Now I have a working solution.
Changing the pages on a multi page editor does not trigger
setActiveEditor() calls for an EditorActionContributor. MultiPageEditorPart
has specific logic for calling the setActivePage() method on a
MultiPageEditorActionContributor. For this the editor part uses instanceof
to make sure the contributor is really is an instance of MPEAC. This means
that my action contributor needs to inherit MPEAC. So I cannot use the GEF
ActionBarContributor in any case.
So, I wrote my own action contributor which inherits MPEAC. This was not
hard once I understood how the setActiveEditor/Page() method is supposed to
work (i.e. editors that do not want to use the existing menu / key bindings
have to remap all bindings to null). This way my MultiPAgeEditorPArt does
not have to know anything about ActionRegistries or anything else related
to that and all logic can be written in the specific editor pages, which is
a lot cleaner than having to rely on the MultiPageEditorPart to delegate
calls to the correct editor page.
My only problem at the moment is with menu and toolbar entries, more
specifically Zooming. I guess that menu and toolbar contributions are
editor specific (editor here meaning the editor tabs on the top of the
editor view). I.e. changing the editor page in a multi page editor cannot
affect menu and toolbar contributions. I'd like to disable the zoom related
operations when the GEF editor page is not active. Also, currently my zoom
combobox is disabled. I think its lacking a reference to the ZoomManager,
and I have no idea where to get that.
But this is getting off topic for this NG. So if anyone has any
contributions or questions, please get in touch with me via private email.
--
Lauri
|
|
|
Re: [jface] Re: ActionBarContributor with a multi page editor [message #78324 is a reply to message #78254] |
Wed, 07 May 2003 11:30   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
You are going to have the same problem for all RetargetActions.
ZoomInRetargetAction is just like Copy, Delete, Paste, Undo, etc. A
RetargetAction obtains it's "target" from the active part. But in the case
of MPE, you need to re-register the global action each time the active page
changes. This is because the active part does *not* change. So, when you
switch pages, re-map all global actions to their corresponding handlers on
the current page. In the case of Zoom, remap zoom to NULL.
> My only problem at the moment is with menu and toolbar entries, more
> specifically Zooming. I guess that menu and toolbar contributions are
> editor specific (editor here meaning the editor tabs on the top of the
> editor view). I.e. changing the editor page in a multi page editor cannot
> affect menu and toolbar contributions. I'd like to disable the zoom
related
> operations when the GEF editor page is not active. Also, currently my zoom
> combobox is disabled. I think its lacking a reference to the ZoomManager,
> and I have no idea where to get that.
>
> But this is getting off topic for this NG. So if anyone has any
> contributions or questions, please get in touch with me via private email.
>
> --
> Lauri
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05152 seconds