Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to programmatically invoke Save All command?
How to programmatically invoke Save All command? [message #331024] Thu, 21 August 2008 14:50 Go to next message
Eclipse UserFriend
Originally posted by: nick.allen.onlinehome.de

Hi,

In my plug-in I have registered a number of command handlers that invoke
OS commands. I would like to ensure that all files in Eclipse have been
saved to disk before doing so (to make sure the commands work on the
most recent data).

Can anyone point me in the right direction?

Thanks,

Nicholas Allen
Re: How to programmatically invoke Save All command? [message #331026 is a reply to message #331024] Thu, 21 August 2008 15:13 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
I found this by looking at ActionFactory.SAVE_ALL, going to the
SaveAllAction and looking at it's run method.

Call WorkbenchPage.saveAllEditors()

Francis

Nicholas Allen wrote:
> Hi,
>
> In my plug-in I have registered a number of command handlers that invoke
> OS commands. I would like to ensure that all files in Eclipse have been
> saved to disk before doing so (to make sure the commands work on the
> most recent data).
>
> Can anyone point me in the right direction?
>
> Thanks,
>
> Nicholas Allen


--
*new* Common Navigator Framework section in:
3.4RC4 Platform Plugin Developer Guide (Programmer's Guide)
http://help.eclipse.org/ganymede/topic/org.eclipse.platform. doc.isv/guide/cnf.htm
http://dev.eclipse.org/blogs/francis
http://wiki.eclipse.org/Common_Navigator_Framework
http://wiki.eclipse.org/Common_Navigator_Framework_Use_Cases


You have brains in your head.
You have feet in your shoes.
- Dr Seuss, Oh the Places You'll Go


Re: How to programmatically invoke Save All command? [message #331029 is a reply to message #331026] Thu, 21 August 2008 16:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nick.allen.onlinehome.de

Thanks for the feedback. saveAllEditors is not a static method so how do
I obtain a pointer to an IWorkbenchPage from with my command handler
execute method? I'm sorry if that is a silly question - I am completely
new to Eclipse plugins.

Thanks,

Nick

Francis Upton (News) wrote:
> I found this by looking at ActionFactory.SAVE_ALL, going to the
> SaveAllAction and looking at it's run method.
>
> Call WorkbenchPage.saveAllEditors()
>
> Francis
>
> Nicholas Allen wrote:
>> Hi,
>>
>> In my plug-in I have registered a number of command handlers that invoke
>> OS commands. I would like to ensure that all files in Eclipse have been
>> saved to disk before doing so (to make sure the commands work on the
>> most recent data).
>>
>> Can anyone point me in the right direction?
>>
>> Thanks,
>>
>> Nicholas Allen
>
>
Re: How to programmatically invoke Save All command? [message #331030 is a reply to message #331029] Thu, 21 August 2008 16:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: nick.allen.onlinehome.de

Sorry - I think I worked it out!

IWorkbenchWindow workbenchWindow =
HandlerUtil.getActiveWorkbenchWindowChecked(event);

workbenchWindow.getActivePage().saveAllEditors(true);
Re: How to programmatically invoke Save All command? [message #331219 is a reply to message #331030] Thu, 28 August 2008 14:24 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Nicholas Allen wrote:
> Sorry - I think I worked it out!
>
> IWorkbenchWindow workbenchWindow =
> HandlerUtil.getActiveWorkbenchWindowChecked(event);
>
> workbenchWindow.getActivePage().saveAllEditors(true);

That will call the programmatic APIs. The other way is to simply invoke
the org.eclipse.ui.file.saveAll command using the IHandlerService.

You can use the workbenchWindow.getService(IHandlerService.class) to
retrieve it. The advantage of calling the command is that any command
execution listeners are notified.

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


Previous Topic:Perspective bar programmatically
Next Topic:How to get notified when Eclipse renames or deletes a file in the workspace?
Goto Forum:
  


Current Time: Mon Dec 30 17:02:43 GMT 2024

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

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

Back to the top