问题
I'm creating E4 RCP application in that I have one part. I want to implement "Save As" functionality for my Part, as it is implemented for Editors (Like:Java file Editor).
Requirements:
- When user click on my part "Save As" option should be enable.
- When user click on "Save As" option my code should run so that I can do what I want.
So my question is for this what should I do, is I have to implement any extension point or any this else. ?
回答1:
In a pure e4 application there is no built in support for Save As so you will need to code this yourself.
To be consistent with the @Persist
support for Save I would suggest doing this with an annotation, lets call it @PersistAs
:
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface PersistAs
{
}
You will have to add a command definition for 'save as' along with a handler and menu items in the usual way.
The handler for Save As would look something like:
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) final MPart part)
{
Object client = part.getObject();
ContextInjectionFactory.invoke(client, PersistAs.class, part.getContext());
}
and in your part you would have:
@PersistAs
public void saveAs()
{
// You save as code
}
回答2:
In Eclipse 3 compatibility mode you implement the doSaveAs
and isSaveAsAllowed
methods in your EditorPart
.
来源:https://stackoverflow.com/questions/19535342/how-to-implement-save-as-functionality-for-our-part