Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem adding a drop down ToolItem in a ToolBarManager
Problem adding a drop down ToolItem in a ToolBarManager [message #453594] Thu, 07 April 2005 20:52 Go to next message
Eclipse UserFriend
Originally posted by: Jeremy_21117.hotmail.com

Hello all,

I have been trying to create a drop down item in a tool bar that I am
controlling with a JFace ToolBarManager with little to no success.

Here is the first route I took:

modeMenu = new MenuManager("Select Mode");

//One Table
ActionContributionItem oneTableCI = new ActionContributionItem(new
OneTableAction());
oneTableCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
modeMenu.add(oneTableCI);

// Two Table Top/Bottom
ActionContributionItem topBottomCI = new ActionContributionItem(new
TopBottomAction());
topBottomCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
modeMenu.add(topBottomCI);

// Two Table Left/Right
ActionContributionItem leftRightCI = new ActionContributionItem(new
LeftRightAction());
leftRightCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
modeMenu.add(leftRightCI);

modeBarManager.add(modeMenu);

It just doesn't appear. Everything else in the ToolBar appears just
fine... but my drop down is missing. I tried using the fill method, I
tried using all the create menu methods, even the ones that didn't seem to
make sense, etc. I am even forcing the manager to update later on in the
method.

So, I decided to bypass the manager and work right on the controls, even
though that defeats the purpose of the manager in the first place.


// ToolItem ti = new
ToolItem(modeBarManager.createControl(cmp),SWT.DROP_DOWN);
// String textString = "";
// String imageString = "";
// if (layout == SEARCH_LAYOUT){
// textString ="Search Mode";
// imageString = "smartmatch/layout.gif";
// }else if (layout == TOP_BOTTOM_LAYOUT){
// textString = "Match Mode Top/Bottom Layout";
// imageString = "smartmatch/layout_vert.gif";
// }else if (layout == LEFT_RIGHT_LAYOUT){
// textString = "Match Mode Left Right Layout";
// imageString = "smartmatch/layout_horiz.gif";
// }
//
// ti.setText(textString);
// ti.setImage(RCPGlobal.getImageRegistry().get(imageString));


Nothing appears because later I am calling this method:

modeBarManager.update(true);

If I disable that, my ToolItem appears but none of my contribution items
do.

If I call it, the reason my ToolItem does not appear is in the
ToolBarManager's update method.

So, I added the ToolItem after making the update call as the last thing I
did... I guess I have a workaround but is there some way to do this in
jface rather than directly working on the controls? It just feels like I
went through the effort of adding the manager only having to go back to
working on the underlying controls.

Any advice/thoughts would be appreciated.
Re: Problem adding a drop down ToolItem in a ToolBarManager [message #453751 is a reply to message #453594] Fri, 08 April 2005 15:51 Go to previous message
Eclipse UserFriend
Originally posted by: Jeremy_21117.hotmail.com

I figured out how to resolve this issue, so I am posting my solution in
case anybody else runs into this problem and needs to search on it.

The first step, is to create a class that extends off of Action.

In the constructor, you need to call the superconstructor

super(title,Action.AS_DROP_DOWN_MENU);

You will also need to call

this.setMenuCreator(menuCreator);

where menuCreator is a class you have created that implements IMenuCreator
Previous Topic:How to change the color/font/image of treenode
Next Topic:browser.setText() with relative links
Goto Forum:
  


Current Time: Tue Mar 09 05:19:23 GMT 2021

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

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

Back to the top