/* Table showing Tool Items */
Composite tableContainer = new Composite(container, SWT.NONE);
tableContainer.setLayout(LayoutUtils.createGridLayout(1, 0, 0));
tableContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
CTable cTable = new CTable(tableContainer, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
fItemViewer = new TableViewer(cTable.getControl());
fItemViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
fItemViewer.getTable().setHeaderVisible(false);
((GridData) fItemViewer.getTable().getLayoutData()).heightHint = fItemViewer.getTable().getItemHeight() * 24;
fItemViewer.getTable().setFocus();
fItemViewer.getTable().setData(ApplicationWorkbenchWindowAdvisor.FOCUSLESS_SCROLL_HOOK, new Object());
/* Custom Owner Drawn Category */
if (!OwlUI.isHighContrast()) {
fItemViewer.getControl().addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
ToolBarItem item = (ToolBarItem) event.item.getData();
if (item.item == CoolBarItem.SEPARATOR) {
Scrollable scrollable = (Scrollable) event.widget;
GC gc = event.gc;
Rectangle area = scrollable.getClientArea();
Rectangle rect = event.getBounds();
/* Paint the selection beyond the end of last column */
OwlUI.codExpandRegion(event, scrollable, gc, area);
/* Draw Gradient Rectangle */
Color oldForeground = gc.getForeground();
Color oldBackground = gc.getBackground();
/* Gradient */
gc.setBackground(fSeparatorBg);
gc.fillRectangle(0, rect.y, area.width, rect.height);
/* Top / Bottom Line */
gc.setForeground(fSeparatorBorderFg);
gc.drawLine(0, rect.y + rect.height - 1, area.width, rect.y + rect.height - 1);
gc.drawLine(0, rect.y, area.width, rect.y);
gc.setForeground(oldForeground);
gc.setBackground(oldBackground);
/* Mark as Background being handled */
event.detail &= ~SWT.BACKGROUND;
}
}
});
}
TableColumn nameCol = new TableColumn(fItemViewer.getTable(), SWT.NONE);
CColumnLayoutData data = new CColumnLayoutData(Size.FILL, 100);
cTable.manageColumn(nameCol, data, Messages.CustomizeToolbarDialog_VISIBLE_ITEMS, null, null, false, false);
/* ContentProvider returns all selected Items */
fItemViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
int[] itemIds = fPreferences.getIntegers(DefaultPreferences.TOOLBAR_ITEMS);