Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Find controls when GMF context menu is displayed
Find controls when GMF context menu is displayed [message #981219] Mon, 12 November 2012 08:48 Go to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi all,

I try to select an entry from the context menu that gmf displays after creating a connection between two model elements. However I do not get matched any widget as long as I have the context menu displayed.

index.php/fa/12305/0/



For testing I have the follwing statement running without any problem (3 items are matched) as long as the context menu does not show up.

List<Tree> items = bot.getFinder().findControls(WidgetMatcherFactory.widgetOfType(Tree.class));



Now whenever context menu shows up this statement does not match any single widget. I tried this with TabbedPropertiesList, MenuEntry etc. I always have the same result.

Any idea?

Ralph
  • Attachment: menu.png
    (Size: 7.39KB, Downloaded 329 times)
Re: Find controls when GMF context menu is displayed [message #981377 is a reply to message #981219] Mon, 12 November 2012 11:10 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 769
Registered: July 2009
Location: Grenoble, France
Senior Member
On 11/12/2012 09:48 AM, Ralph Gerbig wrote:
> Now whenever context menu shows up this statement does not match any single widget. I tried this with TabbedPropertiesList, MenuEntry etc. I always have the same result.
>
> Any idea?

The contextMenu probably does not get closed correctly.
This is for sure a bug. Can you please report it with a simple testcase
(using a dummy diagram)?

--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Find controls when GMF context menu is displayed [message #981384 is a reply to message #981377] Mon, 12 November 2012 11:18 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi Mickael,

Thanks for your quick response! The bug is not after the context menu is displayed it is while displaying. I assume that while the context menu is displayed I would find the menu entries with something thing like this statement:

List<MenuEntry> items = bot.getFinder().findControls(WidgetMatcherFactory.widgetOfType(MenuEntry.class));


This statment did not return any result. Hence, I tried to do it with statements of which I was sure that there should be an result(the Tree example mentioned above). These examples did not return a result while the context menu was open too.

My problem is that I cannot click on such a context menu button because SWTBot finder does not seem to find any widget while this dialog is open. Is there a way to locate the bug a bit closer when I want to open a bug report?

Ralph
Re: Find controls when GMF context menu is displayed [message #981400 is a reply to message #981384] Mon, 12 November 2012 11:30 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 769
Registered: July 2009
Location: Grenoble, France
Senior Member
On 11/12/2012 12:18 PM, Ralph Gerbig wrote:
> My problem is that I cannot click on such a context menu button because
> SWTBot finder does not seem to find any widget while this dialog is
> open. Is there a way to locate the bug a bit closer when I want to open
> a bug report?

I'm not sure what you mean by contextMenu then... contextMenu does not
have button nor widgets, they have menus instead (contextMenu are menu
displayed with right-click).
In case of context menu as "right-clicks", then when a contextMenu is
open you cannot perform any other operation since it has the focus. When
you right-click on something, it sends a right-click event that opens
the contextMenu. When you perform any other UI operation, the
contextMenu is generally first closed and then your event is processed
normally. Maybe in your case, you need to explicitly close the menu...

In case you're speaking about widgets on a draw2d diagram, then SWTBot
does not support them. SWTBot APIs don't have draw2d concepts.
However, you can perform some mouse move and click operations on a
draw2d diagram.

I don't understand what you mean by "locate the bug a bit closer".

Cheers
--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Find controls when GMF context menu is displayed [message #982603 is a reply to message #981400] Tue, 13 November 2012 09:08 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi Mickael,

what you see in the screenshot is a GMF PopupMenu (http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.gmp/org.eclipse.gmf.runtime/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/menus/PopupMenu.java?view=markup&revision=1.3&root=Modeling_Project) which uses SWT Menus. Hence, I would assume that

editor.bot().menu("Class.field");


would work. This does not find any widget.

With "locate bug closer" I asked for a hint on where to look for what is going wrong.

Ralph

[Updated on: Tue, 13 November 2012 09:09]

Report message to a moderator

Re: Find controls when GMF context menu is displayed [message #982667 is a reply to message #982603] Tue, 13 November 2012 10:08 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 769
Registered: July 2009
Location: Grenoble, France
Senior Member
On 11/13/2012 10:09 AM, Ralph Gerbig wrote:
> Hi Mickael,
>
> what you see in the screenshot is a GMF PopupMenu

Sorry, I missed the attachment in original mail. Now I saw it,
understand clearly what you are meaning ;)


> editor.bot().menu("Class.field");

I'd try, with part being the SWTBotGefEditPart you want to right-click:

part.select() or part.click() then

gefEditor.getSWTBotGefViewe().clickContextMenu("Class.field"), or
gefEditor.getSWTBotGefViewe().getCanvas().contextMenu("Class.field").click()

The Canvas is a SWT widget so SWTBotGefFigureCanvas inherits from
AbstractSWTBot.

HTH,
--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Find controls when GMF context menu is displayed [message #984263 is a reply to message #982667] Wed, 14 November 2012 14:51 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi Mickael,

this does not work either. I think the problem is that this menu is not coming from a right click but from the GMF Graphical Node Edit Policy while creating a link. I use the follwing commands to get until the menu is displayed:

Point targetPoint = target.getFigure().getBounds().getCenter();
target.getFigure().translateToAbsolute(targetPoint);
		
editor.activateTool("Role");		
editor.drag(sourceLabel, targetPoint.x(), targetPoint.y());

editor.bot().sleep(1000);
//Try here to click on the presse menu


I printed out all menus that are available via

	editor.bot().menu(editor.bot().activeShell(), new BaseMatcher<MenuItem>() {

			@Override
			public boolean matches(Object item) {
				System.out.println(item.toString());
				return true;
			}

			@Override
			public void describeTo(Description description) {
				// TODO Auto-generated method stub
				
			}
		}, 0);


but this displays all menus except the menu items displayed after creating the connction. Is it possible that these are displayed on a different shell or thread to which SWTBot does not have access?

Ralph
Re: Find controls when GMF context menu is displayed [message #987585 is a reply to message #984263] Tue, 27 November 2012 09:22 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 769
Registered: July 2009
Location: Grenoble, France
Senior Member
Is it same use-case as
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389156 ?

--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Find controls when GMF context menu is displayed [message #987588 is a reply to message #987585] Tue, 27 November 2012 09:35 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 697
Registered: November 2009
Senior Member
Hi Mickael,

it is very close. The problem in the bug the context menu is opened by using a palette tool. In my case it is opened by using the connection handles which are displayed when hovering over an edit part. I assume that when solving one of the to problems we get the second problem solved for free.

Ralph
Previous Topic:Eclipse Juno Reporting
Next Topic:Accessing the menu of a palette tool that creates more than one figure
Goto Forum:
  


Current Time: Thu Nov 27 04:41:34 GMT 2014

Powered by FUDForum. Page generated in 0.02713 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software