/* Create Item */
final SearchConditionItem item = new SearchConditionItem(itemContainer, SWT.NONE, condition, fFieldsToExclude);
item.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
/* Create Button Box */
final ToolBar buttonBar = new ToolBar(itemContainer, SWT.FLAT);
buttonBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
/* Button to add Condition */
ToolItem addButton = new ToolItem(buttonBar, SWT.DROP_DOWN);
addButton.setImage(fAddIcon);
addButton.setDisabledImage(fAddDisabledIcon);
addButton.setToolTipText(Messages.SearchConditionList_ADD_CONDITION);
/* Add Menu */
final Menu conditionMenu = new Menu(buttonBar);
createConditionMenu(conditionMenu, item);
addButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.detail == SWT.ARROW) {
Rectangle rect = item.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height);
pt = buttonBar.toDisplay(pt);
conditionMenu.setLocation(pt.x, pt.y);
conditionMenu.setVisible(true);
} else
onAdd(item);
}
});
buttonBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
conditionMenu.dispose();
}
});