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:
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
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.