Alex Rivera | Logout

Override Eclipse File > Save Action

Asked 2011-05-05T14:48:56.770
11

I am trying to override the Eclipse File > Save menu action to add some functionality. I have tried the following things

a) Create a new action and add it to the global action handler

actionBars.setGlobalActionHandler(ActionFactory.SAVE.getId(), mySaveAction); actionRegistry.registerAction(action);

b) Create a new handler and override the save command

<extension point="org.eclipse.ui.handlers">
<handler commandId="org.eclipse.ui.file.save"
  class="com.diagrams.ui.SaveFileHandler">
<enabledWhen> 
  <with variable="activePartId">
  <equals 
    value="com.diagrams.editors.MultiPageEditor" />
  </with>
</enabledWhen>
<activeWhen>
  <with variable="activePartId">
  <equals 
  value="com.diagrams.editors.MultiPageEditor" />
  </with>
</activeWhen>
</handler>
</extension> 

With both these approaches I have been able to override the Keyboard Ctrl+S functionality but the "File > Save" menu seem to work differently.

Would really appreciate any help, Thanks

Edit
Report

1 Answer

0

It might have something to do with the activePartId being different when the main menu is selected versus a keystroke or using the right-click menu. Have you looked at other extension points?

answered 2011-05-05T15:17:49.847

Your Answer