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 14:15 Go to next message
Markus Wiederkehr is currently offline Markus Wiederkehr
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 05:50 Go to previous message
Sopot Cela is currently offline Sopot Cela
Messages: 589
Registered: December 2010
Senior Member

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 Apr 17 11:28:15 EDT 2014

Powered by FUDForum. Page generated in 0.02892 seconds