Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » One ToggleGridAction for several GraphicalViewers
One ToggleGridAction for several GraphicalViewers [message #192210] Tue, 16 August 2005 13:16 Go to next message
Martijn van Steenbergen is currently offline Martijn van SteenbergenFriend
Messages: 16
Registered: July 2009
Junior Member
Greetings,

I currently have a MultiPageEditor (MPE) which always consists of one
text (source) editor and zero or more graphical editors. I want to
create a ToggleGridAction in the MPE's toolbar which 1) is enabled only
if the active page is a GraphicalEditor and 2) when enabled and clicked,
toggles the grid in the active GraphicalEditor. Currently, I have my own
implementation of ToggleGridAction, since the ToggleGridAction in GEF
doesn't (seem to) allow for switching GraphicalViewers after creation.
Is there a more elegant solution? Would it be an idea to make a
setGraphicalViewer() method on ToggleGridAction?

Regards,

Martijn.
Re: One ToggleGridAction for several GraphicalViewers [message #192390 is a reply to message #192210] Thu, 18 August 2005 16:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Retarget actions?

"Martijn van Steenbergen" <mvsteenbergen@eljakim.nl> wrote in message
news:ddsose$885$1@news.eclipse.org...
> Greetings,
>
> I currently have a MultiPageEditor (MPE) which always consists of one
> text (source) editor and zero or more graphical editors. I want to
> create a ToggleGridAction in the MPE's toolbar which 1) is enabled only
> if the active page is a GraphicalEditor and 2) when enabled and clicked,
> toggles the grid in the active GraphicalEditor. Currently, I have my own
> implementation of ToggleGridAction, since the ToggleGridAction in GEF
> doesn't (seem to) allow for switching GraphicalViewers after creation.
> Is there a more elegant solution? Would it be an idea to make a
> setGraphicalViewer() method on ToggleGridAction?
>
> Regards,
>
> Martijn.
Re: One ToggleGridAction for several GraphicalViewers [message #192425 is a reply to message #192390] Thu, 18 August 2005 17:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The toolbar is already displaying retarget actions since thats necessary
even for single page editors. So all you need to do is change the current
global action handler when the page changes, in the same way that changing
the active (top-level) editor currently does.

One hack that works with MPEs is to trick the editoractionabrcontributor
into thinking that the active editor has changed even though it hasn't, only
the active page has. Or you could just expose and call setActiveEditor
somehow in your EABC.

"Pratik Shah" <none@unknown.com> wrote in message
news:de2bp4$llc$1@news.eclipse.org...
> Retarget actions?
>
> "Martijn van Steenbergen" <mvsteenbergen@eljakim.nl> wrote in message
> news:ddsose$885$1@news.eclipse.org...
>> Greetings,
>>
>> I currently have a MultiPageEditor (MPE) which always consists of one
>> text (source) editor and zero or more graphical editors. I want to
>> create a ToggleGridAction in the MPE's toolbar which 1) is enabled only
>> if the active page is a GraphicalEditor and 2) when enabled and clicked,
>> toggles the grid in the active GraphicalEditor. Currently, I have my own
>> implementation of ToggleGridAction, since the ToggleGridAction in GEF
>> doesn't (seem to) allow for switching GraphicalViewers after creation.
>> Is there a more elegant solution? Would it be an idea to make a
>> setGraphicalViewer() method on ToggleGridAction?
>>
>> Regards,
>>
>> Martijn.
>
>
Re: One ToggleGridAction for several GraphicalViewers [message #192585 is a reply to message #192425] Sat, 20 August 2005 08:15 Go to previous message
Martijn van Steenbergen is currently offline Martijn van SteenbergenFriend
Messages: 16
Registered: July 2009
Junior Member
Randy Hudson wrote:
> The toolbar is already displaying retarget actions since thats necessary
> even for single page editors. So all you need to do is change the current
> global action handler when the page changes, in the same way that changing
> the active (top-level) editor currently does.
>
> One hack that works with MPEs is to trick the editoractionabrcontributor
> into thinking that the active editor has changed even though it hasn't, only
> the active page has. Or you could just expose and call setActiveEditor
> somehow in your EABC.

After 1.5 days of trying and testing and studying code I've managed to
get everything to work as intended, including zoom buttons, the
ZoomComboContributionItem (by setting the right ZoomManager each time
the page changes), and undo/redo, which even get forwarded correctly to
the text editor. I think the problem was that I simply had never heard
of RetargetActions before and didn't know how to use them. Using these
and resetting the global action handlers every time the page changes
then calling updateActionBars() seemed to do the trick. My text editor's
status line is fixed too. :)

Thank you both for your time and hints! Have a nice weekend.

Regards,

Martijn.
Previous Topic:ActionRegistry
Next Topic:"Folder" parts
Goto Forum:
  


Current Time: Mon Jan 13 11:43:34 GMT 2025

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

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

Back to the top