Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to properly implement Save As...?
How to properly implement Save As...? [message #909200] Thu, 06 September 2012 18:15 Go to next message
Markus Wiederkehr is currently offline Markus WiederkehrFriend
Messages: 17
Registered: August 2012
Junior Member
This is what I came up with:

public class SaveAsHandler {
	public static final String TAG = "com.example.saveAsTag"; //$NON-NLS-1$

	@CanExecute
	public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MDirtyable dirtyable) {
		return dirtyable != null;
	}

	@Execute
	void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_PART) MPart part) {
		final IEclipseContext saveAsContext = context.createChild();
		saveAsContext.set(TAG, Boolean.TRUE);

		Object clientObject = part.getObject();
		ContextInjectionFactory.invoke(clientObject, Persist.class, saveAsContext, null);

		saveAsContext.dispose();
	}
}

In my @Perist-annotated save method I check for the existence of the save-as tag in the context and proceed accordingly.

Is this how it is supposed to be done?
Re: How to properly implement Save As...? [message #909542 is a reply to message #909200] Fri, 07 September 2012 09:50 Go to previous message
Eclipse UserFriend
I don't think that there is a "how it should be done" but if it works (and by just looking at it it does) it is pretty nice and concise.
Previous Topic:Non singlton workspace
Next Topic:Org.eclipse.equinox.launcher plug in error
Goto Forum:
  


Current Time: Thu Mar 28 10:39:40 GMT 2024

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

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

Back to the top