Jump to: navigation, search

Difference between revisions of "FAQ How do I enable global actions such as Cut, Paste, and Print in my editor?"

(See Also:: fixed link)
(See Also)
 
Line 25: Line 25:
 
[[FAQ How do I hook into global actions, such as Copy and Delete?]]
 
[[FAQ How do I hook into global actions, such as Copy and Delete?]]
  
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+
{{Template:FAQ_Tagline}}

Latest revision as of 13:57, 30 May 2013

Your editor's IEditorActionBarContributor, defined in the editor definition in the plugin.xml file, is responsible for enabling global actions. Whenever your editor becomes the active part, the method setActiveEditor is called on the action bar contributor. This is where you can retarget the global actions for your editor. Keep in mind that each editor type has only one editor action bar contributor, so you need to update your actions to reflect the current editor. In this example, the global Print action is being retargeted to the active editor:

   IAction print = ...;
   public void setActiveEditor(IEditorPart part) {
      IActionBars bars= getActionBars();
      if (bars == null)
         return;
      print.setEditor(part);
      bars.setGlobalActionHandler(
         IWorkbenchActionConstants.PRINT, print);
      bars.updateActionBars();
   }


See Also

FAQ How do I hook into global actions, such as Copy and Delete?


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.