Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Specifying *BOTH* Lable and Icon in Toolbar MenuContribution
Specifying *BOTH* Lable and Icon in Toolbar MenuContribution [message #327637] Sun, 27 April 2008 22:10 Go to next message
Stuart Pond is currently offline Stuart PondFriend
Messages: 27
Registered: July 2009
Junior Member
In Eclipse 3.3, I have noticed that any menuContribution to a toolbar that
contains a label and icon in the command only the icon gets displayed.

Is there anyway to display both a label and icon in a toolbar item menu
contribution?
Re: Specifying *BOTH* Lable and Icon in Toolbar MenuContribution [message #327639 is a reply to message #327637] Sun, 27 April 2008 22:15 Go to previous messageGo to next message
Peter Centgraf is currently offline Peter CentgrafFriend
Messages: 52
Registered: July 2009
Member
You need to specify the MODE_FORCE_TEXT mode on the IContributionItem,
or the ToolbarContributionManager will ignore the text by default. I
use this helper method so I can work with the Action API instead of
Contributions.

/**
* Snippet to add an IAction instance to a toolbar or menu manager with
* MODE_FORCE_TEXT.
*
* @param manager the toolbar or menu manager
* @param action the action to add
*/
public static void addItemWithText(IContributionManager manager,
IAction action, String groupId) {
ActionContributionItem contribution =
new ActionContributionItem(action);
contribution.setMode(ActionContributionItem.MODE_FORCE_TEXT) ;

if (groupId == null || "".equals(groupId)) {
manager.add(contribution);
}
else {
manager.appendToGroup(groupId, contribution);
}
}

--
Peter Centgraf
Re: Specifying *BOTH* Lable and Icon in Toolbar MenuContribution [message #327641 is a reply to message #327639] Mon, 28 April 2008 00:18 Go to previous messageGo to next message
Stuart Pond is currently offline Stuart PondFriend
Messages: 27
Registered: July 2009
Junior Member
Peter,

It is not clear how I would do this from the plugin.xml. I am trying to
define the maximum of my menu/toolbar contributions declaratively using the
new 3.3 menuContribution extensions.

Anyone have any luck with this?


"Peter Centgraf" <peter@centgraf.net> wrote in message
news:fv2ttv$2bi$1@build.eclipse.org...
> You need to specify the MODE_FORCE_TEXT mode on the IContributionItem, or
> the ToolbarContributionManager will ignore the text by default. I use
> this helper method so I can work with the Action API instead of
> Contributions.
>
> /**
> * Snippet to add an IAction instance to a toolbar or menu manager with
> * MODE_FORCE_TEXT.
> *
> * @param manager the toolbar or menu manager
> * @param action the action to add
> */
> public static void addItemWithText(IContributionManager manager,
> IAction action, String groupId) {
> ActionContributionItem contribution =
> new ActionContributionItem(action);
> contribution.setMode(ActionContributionItem.MODE_FORCE_TEXT) ;
>
> if (groupId == null || "".equals(groupId)) {
> manager.add(contribution);
> }
> else {
> manager.appendToGroup(groupId, contribution);
> }
> }
>
> --
> Peter Centgraf
Re: Specifying *BOTH* Lable and Icon in Toolbar MenuContribution [message #327764 is a reply to message #327641] Wed, 30 April 2008 23:08 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Stuart Pond wrote:
> Peter,
>
> It is not clear how I would do this from the plugin.xml. I am trying to
> define the maximum of my menu/toolbar contributions declaratively using the
> new 3.3 menuContribution extensions.
>
> Anyone have any luck with this?

That functionality is not available in actions or commands from the
plugin.xml until 3.4 (a new mode attribute was added to the extension
points like actionSets and menus).

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:Plugin.stop() called during disable or uninstalled?
Next Topic:getActivePage throws NullPointerException
Goto Forum:
  


Current Time: Fri Nov 08 22:32:05 GMT 2024

Powered by FUDForum. Page generated in 0.02451 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top