Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Hook into SaveAction
Hook into SaveAction [message #323841] Wed, 09 January 2008 15:43 Go to next message
Eclipse UserFriend
Originally posted by: nclauwers.gmail.com

Hey all,

First of all I'm completely new to making plugins for eclipse.
I want to make a plugin when eclipse starts it just hooks into the global
save command and for example displays an awt messagebox whenever the user
saves a document(.java, .egl doesn't matter).
I've searched for a couple of hours but I couldn't find a working solution.

I've tried to make an extending class from SaveAction and overriding the
run method and then adding it via setGlobalActionHandler method. but
whatever I try, my run method isn't executed.

I also tried to search for the save action via
getGlobalActionHandler(ActionFactory.SAVE.getId()) and I always get a null
value back. Although he can find the COPY command. I also tried to
override the COPY command and he doesn't execute my run method either.

I hope someone can help me.
Thanks in advance,
Niels
Re: Hook into SaveAction [message #323855 is a reply to message #323841] Thu, 10 January 2008 09:12 Go to previous messageGo to next message
Eclipse UserFriend
The ActionFactory.SAVE action isn't a retargetable action, which is why
setGlobalActionHandler(*) doesn't work. ActionFactory.COPY is a
RetargetAction.

You might look at how JDT does save actions (as provided under
Window>Preferences>Java>Editors>Save Actions).

The other thing you could do is add an IExecutionListener via the
ICommandService. preExecute(*) will get called with the save command id
(org.eclipse.ui.file.save, I think)

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm
Re: Hook into SaveAction [message #323856 is a reply to message #323855] Thu, 10 January 2008 09:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nclauwers.gmail.com

Thanks a lot Paul for your help.
I will look into this.
At the moment I solved my problem by making a builder and programmatically
adding the builder to the project.

Niels
Re: Hook into SaveAction [message #323870 is a reply to message #323841] Thu, 10 January 2008 12:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Niels wrote:
> Hey all,
>
> First of all I'm completely new to making plugins for eclipse.
> I want to make a plugin when eclipse starts it just hooks into the
> global save command and for example displays an awt messagebox whenever
> the user saves a document(.java, .egl doesn't matter).
> I've searched for a couple of hours but I couldn't find a working solution.
>
> I've tried to make an extending class from SaveAction and overriding the
> run method and then adding it via setGlobalActionHandler method. but
> whatever I try, my run method isn't executed.

Would it be close enough for you to add a IResourceChangeListener to the
Workspace and respond to events that way?

Hope this helps,
Eric
Re: Hook into SaveAction [message #323892 is a reply to message #323870] Fri, 11 January 2008 08:13 Go to previous message
Eclipse UserFriend
Originally posted by: nclauwers.gmail.com

No, because I only need to execute when they push save or at certain
builds.

Niels
Previous Topic:Automate updating bundle version numbers
Next Topic:Adding stacked views to an existing perspective via "perspectiveExtensions"
Goto Forum:
  


Current Time: Wed Jul 16 21:49:55 EDT 2025

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

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

Back to the top