0

My application have an Editor and some View extend ViewPart. In the Editor I can create a Save action like this

Action action = (Action) ActionFactory.SAVE.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());

and the add action in a ToolBar. I can control this SAVE action by Override isDirty() and doSave() method. And my question is:

  1. Can I add a SAVE ActionFactory in a ViewPart?
  2. How can I Override SAVE method in ViewPart?
  3. Is there any other way to do it?

My View look like this:

    GridLayout layoutProperties = new GridLayout(2, false);
    layoutProperties.marginHeight = 0;
    layoutProperties.marginWidth = 0;
    propertiesVersion.setLayout(layoutProperties);
    propertiesVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    toolkitProperties = new FormToolkit(propertiesVersion.getDisplay());
    sectionProperties = toolkitProperties.createSection(propertiesVersion, Section.TITLE_BAR);
    sectionProperties.setText("Version Properties");
    sectionProperties.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 0));
    //some Label and Text here
gamo
  • 1,549
  • 7
  • 24
  • 36

1 Answers1

0

For an RCP you normally create the Save action in your ActionBarAdvisor with something like:

@Override
protected void makeActions(IWorkbenchWindow window) 
{
  saveAction = ActionFactory.SAVE.create(window);
  register(saveAction);

  ... more ...
}

The save action will then work with any part that implements ISaveablePart, it is this interface that defines isDirty, doSave, ... So if you implement this in your view part you will get save support.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • After spend a morning with google I found out a way just seem like your. Any thank you for your answer. I will mark this as a correct answer. – gamo Nov 06 '14 at 09:17