Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » ActionBarContributor with a multi page editor
ActionBarContributor with a multi page editor [message #77863] Mon, 05 May 2003 07:19 Go to next message
Eclipse UserFriend
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 16:02 Go to previous messageGo to next message
Eclipse UserFriend
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 09:28 Go to previous messageGo to next message
Eclipse UserFriend
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 15:30 Go to previous messageGo to next message
Eclipse UserFriend
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
[jface] Re: ActionBarContributor with a multi page editor [message #82409 is a reply to message #77880] Thu, 05 June 2003 16:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tprumbs.atsistemas.com

I tried to do what Randy said, but my MultiPageEditor is now loosing
the global actions like undo/redo when I use the Properties-View to
change my model. The model and the view is updated, but I don't have
access to the undo/redo actions anymore.

I use a GraphicalEditorWithPalette. The model is changed by the Eclipse
Properties-View - just like in the gef.logic example. Only since I use a
MultiPageEditor I have the above problem.

I have allready created my own ActionBarContributor which now extends
MultiPageEditorActionBarContributor. I overwrote setActivePage() like
this:

public void setActivePage(IEditorPart activeEditor) {
setActiveEditor(activeEditor);
}

and in my MultipageEditor I overwrote getAdapter() like this:

public Object getAdapter(Class adapter) {
if (ActionRegistry.class.equals(adapter) && getActiveEditor() != null) {
return getActiveEditor().getAdapter(adapter);
} else {
return null;
}
}

Could someone please give me some hints what I'm doing wrong?
Do I miss anything?!?

Thanks in advance!
Thorsten


"Randy Hudson" <none@us.ibm.com> escribi
Re: [jface] Re: ActionBarContributor with a multi page editor [message #82436 is a reply to message #82409] Thu, 05 June 2003 17:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Thorsten Prumbs" <tprumbs@atsistemas.com> wrote in message
news:bbnsi1$c35$1@rogue.oti.com...
> I tried to do what Randy said, but my MultiPageEditor is now loosing
> the global actions like undo/redo when I use the Properties-View to
> change my model. The model and the view is updated, but I don't have
> access to the undo/redo actions anymore.

This is default behavior in Eclipse. The Properties View is not your Editor,
just like the Task View, and therefore must contribute its own global action
handlers. You can see the same behavior in the Logic example.

The solution is to get the IPageSite, and register undo action handlers for
the global undo retarget actions.
Re: [jface] Re: ActionBarContributor with a multi page editor [message #698326 is a reply to message #78324] Tue, 19 July 2011 09:19 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
Hello,

I am facing a similar problem where I have a GEF editor as one of the pages in a MPE. I have registered some "RetargetAction" and some "AlignmentRetargetAction. But when i run it in a Multi Page editor, the selection event is not fired and hence the actionbar items are disabled. Any thoughts how i could resolve this?

Thanks in advance for help.

Regards,
Murthy
Re: [jface] Re: ActionBarContributor with a multi page editor [message #698855 is a reply to message #698326] Wed, 20 July 2011 11:28 Go to previous message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
I was able to resolve this issue by correctly firing the selectionChanged(...) method from my graphicalEditor. Please refer http://www.eclipse.org/forums/index.php/t/221444/ for details.

Best Regards,
Murthy
Previous Topic:Two-finger zoom on Mac
Next Topic:Traversing while in GEF direct edit
Goto Forum:
  


Current Time: Thu Apr 25 00:52:46 GMT 2024

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

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

Back to the top