Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "FAQ How do I add actions to the toolbar?"

m (FAQ How do I add actions to the global toolbar? moved to FAQ How do I add actions to the toolbar?)
(See Also)
 
Line 40: Line 40:
 
Eclipse online article “Contributing Actions to the Eclipse Workbench”
 
Eclipse online article “Contributing Actions to the Eclipse Workbench”
  
<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:58, 30 May 2013

Actions are added to the workbench window&#146;s toolbar by using the org.eclipse.ui.actionSets extension point. Here is a sample action element that contributes an action to the workbench window toolbar:

   <action
      class="org.eclipse.faq.examples.actions.ToolBarAction"
      toolbarPath="Normal/exampleGroup"
      icon="icons/sample.gif"
      tooltip="Sample toolbar action">
   </action>


The class attribute is the fully qualified name of the action that will be run when the toolbar button is clicked. This class must implement the interface IWorkbenchWindowActionDelegate. The toolbarPath attribute has two segments&#151;the toolbar ID and the group ID&#151;separated by a slash (/) character. The toolbar ID is used to indicate which toolbar the action belongs to. This value isn&#146;t currently used because the platform defines only one toolbar, but the convention is to use the string Normal to represent the default toolbar. The group ID is used to place similar actions together. All actions with the same group ID will be placed in a fixed group in the toolbar. The string in the tooltip attribute is shown when the user hovers over the toolbar button.


You can specify many more attributes on your action, including criteria for when your action should be visible and when it should be enabled. However, the four attributes shown earlier are the minimum set you need for a toolbar action. Some of the other action attributes are discussed in other FAQs.


See Also

FAQ_What_is_an_action_set?

Platform Plug-in Developer Guide, under Reference > Extension Points Reference > org.eclipse.ui.actionSets, Eclipse online article &#147;Contributing Actions to the Eclipse Workbench&#148;


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.

Back to the top