@SuppressWarnings("unchecked")
// varargs and generics doesn't mix well!
protected SWTBotMenu contextMenu(final Control control, final String text) {
Matcher<MenuItem> withMnemonic = withMnemonic(text);
final Matcher<MenuItem> matcher = allOf(widgetOfType(MenuItem.class), withMnemonic);
final ContextMenuFinder menuFinder = new ContextMenuFinder(control);
new SWTBot().waitUntil(new DefaultCondition() {
public String getFailureMessage() {
return "Could not find context menu with text: " + text; //$NON-NLS-1$
}
public boolean test() throws Exception {
return !menuFinder.findMenus(matcher).isEmpty();
}
});
return new SWTBotMenu(menuFinder.findMenus(matcher).get(0), matcher);
}