|
|
|
Re: MenuItem disposed [message #481229 is a reply to message #479388] |
Thu, 20 August 2009 08:16 |
Eclipse User |
|
|
|
Originally posted by: steve.monnier.obeo.fr
Hello!
I had the same problem using the tree on the outline view (but was working
on navigator view...).
In the contextMenu method in AbstractSWTBot, menuFinder.findMenus(matcher)
is called twice. Once in the waitUntil, and once to return the SWTBotMenu.
I have not found why but for some views the menuItem is disposed at the
second call.
As I wanted to click on a menu, I solved my problem by directly clicking
the menu when it is found. You can try this:
public void clickContextMenu(final SWTBotTreeItem treeItem, final String
text)
{
UIThreadRunnable.asyncExec(new VoidResult()
{
public void run()
{
Control control = treeItem.widget.getParent();
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
{
List<MenuItem> findMenus =
menuFinder.findMenus(matcher);
if (findMenus.size() > 0)
{
Iterator<MenuItem> iterator =
findMenus.iterator();
while (iterator.hasNext())
{
MenuItem menuItem = (MenuItem)
iterator.next();
if (!menuItem.isDisposed())
{
new SWTBotMenu(menuItem,
matcher).click();
}
}
}
return !findMenus.isEmpty();
}
});
}
});
}
I hope this can help you,
Steve
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01974 seconds