private void addDropdown(RuleAction.Choices choices) { final ToolItem combo = new ToolItem(mLayoutToolBar, SWT.DROP_DOWN); URL iconUrl = choices.getIconUrl(); if (iconUrl != null) { combo.setImage(IconFactory.getInstance().getIcon(iconUrl)); combo.setToolTipText(choices.getTitle()); } else { combo.setText(choices.getTitle()); } combo.setData(choices); Listener menuListener = new Listener() { @Override public void handleEvent(Event event) { Menu menu = new Menu(mLayoutToolBar.getShell(), SWT.POP_UP); RuleAction.Choices choices = (Choices) combo.getData(); List<URL> icons = choices.getIconUrls(); List<String> titles = choices.getTitles(); List<String> ids = choices.getIds(); String current = choices.getCurrent() != null ? choices.getCurrent() : ""; // $NON-NLS-1$ for (int i = 0; i < titles.size(); i++) { String title = titles.get(i); final String id = ids.get(i); URL itemIconUrl = icons != null && icons.size() > 0 ? icons.get(i) : null; MenuItem item = new MenuItem(menu, SWT.CHECK); item.setText(title); if (itemIconUrl != null) { Image itemIcon = IconFactory.getInstance().getIcon(itemIconUrl); item.setImage(itemIcon); } boolean selected = id.equals(current); if (selected) { item.setSelection(true); } item.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { RuleAction.Choices choices = (Choices) combo.getData(); choices.getCallback().action(choices, getSelectedNodes(), id, null); updateSelection(); } }); } Rectangle bounds = combo.getBounds(); Point location = new Point(bounds.x, bounds.y + bounds.height); location = combo.getParent().toDisplay(location); menu.setLocation(location.x, location.y); menu.setVisible(true); } }; combo.addListener(SWT.Selection, menuListener); }