Question

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:

  1. When user click on my part "Save As" option should be enable.
  2. 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. ?

Was it helpful?

Solution

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
}

OTHER TIPS

In Eclipse 3 compatibility mode you implement the doSaveAs and isSaveAsAllowed methods in your EditorPart.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top