Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Can not set ContributionItem size for dynamic toolbar contributions
Can not set ContributionItem size for dynamic toolbar contributions [message #604874] Wed, 03 March 2010 19:22 Go to next message
ali Mising name is currently offline ali Mising nameFriend
Messages: 38
Registered: July 2009
Member
Hello community,

I need to find a way to create ContributionItem that are wider than the default square size.

I've created a number of custom classes that extend ContributionItem and are contributed to my RCP Workbench as dynamic toolbar items using the org.eclipse.ui.menu extension point.

Everything was working well for my square buttons... but I also have a requirement to create wider items.

Unfortunately my wider contributions are also being displayed as small, square items that are the same size of a typical 16 x 16 button icon. I've unsuccessfully tried specifying different ToolBar layouts and manually setting the size of the ToolBar and it's ToolItem Control, but the items remain square :x !

Does anyone know why this is happening and how I can fix it?

Here is a simple version of my "wide" contribution item...

package abc;

import org.eclipse.jface.action.ContributionItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class WideContributionItem extends ContributionItem {

@Override
public void fill(ToolBar toolBar, int index) {

toolBar.setLayout(new FormLayout());

Text wideText = new Text(toolBar, SWT.BORDER);
wideText.setText("This is a wide message");
wideText.setBounds(0, 0, 150, 60);

ToolItem wideToolItem = new ToolItem(toolBar, SWT.PUSH, index);
wideToolItem.setControl(wideText);

wideToolItem.setWidth(160);
toolBar.setSize(200, 70);
toolBar.layout(true, true);
}
}
...and here is the extension points that contribute it to my RCP Workbench:

<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="toolbar:org.eclipse.ui.trim.status">
<toolbar id="mytoolbarid">
<dynamic class="abc.WideContributionItem" id="abcd"/>
</toolbar>
</menuContribution>
</extension>
Can anyone help me find a solution to my problem?
Re: Can not set ContributionItem size for dynamic toolbar contributions [message #604880 is a reply to message #604874] Thu, 04 March 2010 04:46 Go to previous message
ali Mising name is currently offline ali Mising nameFriend
Messages: 38
Registered: July 2009
Member
I was able to fix this issue by adding the following code to the end of the fill method:
ToolBarManager toolBarManager = new ToolBarManager(toolBar);
toolBarManager.update(true);

Problem solved :d !
Previous Topic:Can not set ContributionItem size for dynamic toolbar contributions
Next Topic:[Standalone app] Standalone app not displaying widgets
Goto Forum:
  


Current Time: Thu Apr 25 17:28:33 GMT 2024

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

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

Back to the top