如何实现“另存为”。我们部分的功能 [英] How to implement "Save As" functionality for our Part
问题描述
我正在创建E4 RCP应用程序,因为我只有一部分。我想为我的部件实现另存为功能,因为它是为编辑器实现的(例如:Java文件编辑器)。
要求:
- 当用户单击我的零件时,应启用另存为选项。
- 当用户单击另存为时选项应该运行我的代码,以便我可以做我想做的事。
所以我的问题是我应该怎么做,是吗必须实现任何扩展点或其他任何扩展点。 ?
在纯e4应用程序中,没有对另存为的内置支持,因此您需要自己对此进行编码。 / p>
要与 @Persist
对Save的支持保持一致,我建议您使用批注进行操作,将其称为 @PersistAs
:
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface PersistAs
{
}
您将必须以常规方式为另存为以及处理程序和菜单项添加命令定义。
保存处理程序就像这样:
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART)最终MPart部分)
{
对象客户端= part.getObject();
ContextInjectionFactory.invoke(client,PersistAs.class,part.getContext());
}
您可能会:
@PersistAs
public void saveAs()
{
//您另存为代码
}
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. ?
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
}
这篇关于如何实现“另存为”。我们部分的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!