/* Load and Add Items */
int[] items = fPreferences.getIntegers(DefaultPreferences.TOOLBAR_ITEMS);
if (items == null || items.length == 0)
items = new int[] { CoolBarItem.SPACER.ordinal() };
ToolBarManager currentToolBar = new ToolBarManager(mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL ? (SWT.FLAT | SWT.RIGHT) : SWT.FLAT);
for (int id : items) {
final CoolBarItem item = CoolBarItem.values()[id];
if (item != null) {
/* Separator: Start a new Toolbar */
if (item == CoolBarItem.SEPARATOR) {
fManager.add(currentToolBar);
currentToolBar = new ToolBarManager(mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL ? (SWT.FLAT | SWT.RIGHT) : SWT.FLAT);
}
/* Spacer */
else if (item == CoolBarItem.SPACER) {
ActionContributionItem contribItem = new ActionContributionItem(new Action("") { //$NON-NLS-1$
@Override
public boolean isEnabled() {
return false;
}
});
currentToolBar.add(contribItem);
}
/* Any other Item */
else {
ActionContributionItem contribItem = new CoolBarActionContributionitem(item, getAction(item, mode, currentToolBar));
contribItem.setId(item.getId());
if (mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL || mode == CoolBarMode.IMAGE_TEXT_VERTICAL)
contribItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
/* Add to Toolbar */
currentToolBar.add(contribItem);
}
}
}
/* Add latest Toolbar Manager to Coolbar too */