Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » SaveAll Action(Cannot customize SaveAll command handling)
SaveAll Action [message #512122] Wed, 03 February 2010 20:37 Go to next message
Anand Kelkar is currently offline Anand Kelkar
Messages: 1
Registered: February 2010
Junior Member
Hello All,

In my application I need to customize behavior on SaveAll for my editors (EMF based). I tried to use my custom handler and use the extension point for command handlers. In my handler I can get other commands like Close or CloseAll to work but somehow the SaveAll does not work. The isEnabled() method gets called but the infrastructure does not call execute() for my handler.

It simply gets list of dirty parts through the SaveAll action and calls the doSave() of each of dirty editors. Is there a way to have custom behavior for the SaveAll operation.

Thanks for your help

Regards,
Anand
Re: SaveAll Action [message #512424 is a reply to message #512122] Thu, 04 February 2010 22:12 Go to previous messageGo to next message
Rollie  is currently offline Rollie
Messages: 5
Registered: November 2009
Junior Member
Anand,

I am not sure if this will work, but you might try setting the save all handler in a plugin ui activator. I would try something like the following snippet of code in the start() method of a plugin activator:

ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
Command saveall = service.getCommand("org.eclipse.ui.file.saveAll");
saveall.setHandler(handler);

Good luck,
Rollie
Re: SaveAll Action [message #512568 is a reply to message #512424] Fri, 05 February 2010 09:10 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Rollie wrote:
> ICommandService service = (ICommandService)
> PlatformUI.getWorkbench().getService(ICommandService.class);
> Command saveall = service.getCommand("org.eclipse.ui.file.saveAll");
> saveall.setHandler(handler);

Yeah, that's not a good idea ... any change in the global application
state can cause your handler to be replaced by the real one.

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: SaveAll Action [message #512569 is a reply to message #512122] Fri, 05 February 2010 09:11 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Anand Kelkar wrote:
> Hello All,
>
> In my application I need to customize behavior on SaveAll for my editors

You are creating and setting the SaveAll action in your
ApplicationActionBarAdvisor, when you use
org.eclipse.ui.actions.ActionFactory.SAVE_ALL

If you want to replace that with your own action, just don't use that one.

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/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: SaveAll Action [message #512607 is a reply to message #512569] Fri, 05 February 2010 10:35 Go to previous message
Rollie  is currently offline Rollie
Messages: 5
Registered: November 2009
Junior Member
Anand,

If you just need to perform some processing before the SAVE-ALL command is executed, you can hookup up an execution listener to the command service using the following code:

ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
service.addExecutionListener(executionListener);

Make sure your execution listener implements IExecutionListener, and then place your code in the preExecute method. Be sure to check the command ID for "org.eclipse.ui.file.saveAll" to ensure that the command about to execute is the save-all command. This should give you a hook into save-all without overriding the Eclipse save-all handler.

Hope this helps,
Rollie
Previous Topic:Multiple Different Editors for a Single Resource
Next Topic:influencing progress monitor of a launch configuration
Goto Forum:
  


Current Time: Sat Aug 30 14:46:30 EDT 2014

Powered by FUDForum. Page generated in 0.01959 seconds