[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Problem with ToolBar

Hello!

when I post in the toolbar of the View - element Combo it is not stretched to the desired length, why, how to do it stretched to its normal length? (combo box now becomes the size of a button with an arrow)
Here's my code:


public class View4 extends ViewPart {

	@Override
	public void createPartControl(Composite parent) {
		contributeToActionBars();
	}

	private void contributeToActionBars() {
		IActionBars bars = getViewSite().getActionBars();
		fillLocalToolBar(bars.getToolBarManager());
		bars.updateActionBars();
	}

	private void fillLocalToolBar(IToolBarManager toolBarManager) {
		toolBarManager.add(new ComboTB("comboId"));
		toolBarManager.update(true);
	}

	private class ComboTB extends ContributionItem {

		public ComboTB(String id) {
			super(id);
		}

		@Override
		public void fill(ToolBar bar, int index) {
			ToolItem sep = new ToolItem(bar, SWT.SEPARATOR, index);
			Combo combo = new Combo(bar, SWT.READ_ONLY);
			for (int i = 0; i < 4; i++) {
				combo.add("Item " + i);
			}
			combo.pack();
			sep.setWidth(bar.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
			sep.setControl(combo);
			bar.pack(true);
			bar.layout(true, true);
		}
	}
}

Thanks for help.