Can not set ContributionItem size for dynamic toolbar contributions [message #518136] |
Wed, 03 March 2010 03:50  |
Eclipse User |
|
|
|
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 !
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?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03210 seconds