tags:

views:

431

answers:

1

Hi, I think there are default SAVE and CANCEL buttons associated with editors in Eclipse RCP. How do we make these buttons appear on an editor.

I take it that these buttons are invisible by default and may be there is some superclass method that needs to be overridden to make the SAVE CANCEL buttons appear on editor. I remember of having heard of such a thing. (I may be wrong though)

In any case, how do we achieve this? (PS: I am not looking for a custom SWT button and name it 'SAVE'. I am looking for a default SAVE button that is associated with the editor(if there is such a thing)).

+1  A: 

The buttons are not directly related to your editors.
You must, as described there):

  • Add menu contribution with the commandId set to the standard command id which can be found in IWorkbenchActionDefinitionIds e.g. org.eclipse.ui.file.save

  • Create a command in ApplicationActionBarAdvisor.makeActions and register it.

:

protected void makeActions(final IWorkbenchWindow window) {
  // Creates the actions and registers them.
  // Registering is needed to ensure that key bindings work.
  // The corresponding commands keybindings are defined in the plugin.xml
  // file.
  // Registering also provides automatic disposal of the actions when
  // the window is closed.
  saveAction = ActionFactory.SAVE.create(window);
  register(saveAction);
}
  • Add dirty flag in Editor part and implement isDirty(), setDirty() and clean() methods.
VonC

related questions