Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » GEF GraphicalViewer within a dialog(GEF GraphicalViewer within a dialog - Please help)
GEF GraphicalViewer within a dialog [message #558833] Tue, 14 September 2010 15:00 Go to next message
Barry Dresdner is currently offline Barry DresdnerFriend
Messages: 75
Registered: July 2009
Member
Hi, I have a dialog that displays a GEF ScrollingGraphicalViewer within a dialog. Can someone please tell me how I can access the edit parts using SWTBot? Is this even possible? Thanks, Barry.
Re: GEF GraphicalViewer within a dialog [message #558852 is a reply to message #558833] Tue, 14 September 2010 15:21 Go to previous messageGo to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
Barry Dresdner a écrit :
> Hi, I have a dialog that displays a GEF ScrollingGraphicalViewer within
> a dialog. Can someone please tell me how I can access the edit parts
> using SWTBot? Is this even possible? Thanks, Barry.

Hi Barry,

Have a look to the trunk on svn. I recently integrated a patch that add a SWTBotGefViewer to wrap any GEF viewer.
So you should be able to access them :).

Regards,

Mariot
Re: GEF GraphicalViewer within a dialog [message #558904 is a reply to message #558852] Tue, 14 September 2010 19:55 Go to previous messageGo to next message
Barry Dresdner is currently offline Barry DresdnerFriend
Messages: 75
Registered: July 2009
Member
Hi Mariot,
Thanks for your quick response. Forgive my ignorance, but I have never downloaded SWTBot straight from SVN. Should I be using the repository in http://swtbot4gef.googlecode.com/svn ? If so, I do not see SWTBotGefViewer. Regards, Barry
Re: GEF GraphicalViewer within a dialog [message #559100 is a reply to message #558904] Wed, 15 September 2010 15:28 Go to previous messageGo to next message
Barry Dresdner is currently offline Barry DresdnerFriend
Messages: 75
Registered: July 2009
Member
Hi Mariot,
I believe I now have the latest source - Revision 603. I found the SWTBotGefViewer class, so I believe I am on the right track. Now as I mentioned, my Gef Viewer is embedded within a dialog. I see method in SWTGefBot gefViewer, that takes the title of a workbench part as an argument. Is there another way to get the viewer? perhaps I am missing something here. Thanks again, Barry
Re: GEF GraphicalViewer within a dialog [message #559137 is a reply to message #559100] Wed, 15 September 2010 17:25 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
On 10-09-15 11:28 AM, Barry Dresdner wrote:
> Hi Mariot,
> I believe I now have the latest source - Revision 603. I found the
> SWTBotGefViewer class, so I believe I am on the right track. Now as I
> mentioned, my Gef Viewer is embedded within a dialog. I see method in
> SWTGefBot gefViewer, that takes the title of a workbench part as an
> argument. Is there another way to get the viewer? perhaps I am missing
> something here. Thanks again, Barry

You don't necessarily need to use the SWTGetBot#gefViewer method to use
a SWTBotGefViewer; these method are there to help when the viewer is
embedded in an editor or view. Even then, it's a best-effort attempt and
the editor or view must respect a certain contract for it to work
(namely, getAdapter(GraphicalViewer.class) must return the required
GraphicalViewer).

In your case, you need to find yourself the GraphicalViewer and
construct a new instance of SWTBotGefViewer. The hard part is getting
hold of the GraphicalViewer, because it is not a widget... and I mean,
really hard. The only solution I see requires you to modify the
application under test a little. You will need to attach the
GraphicalViewer as the data field of a widget. For example, let's say
you have a custom dialog, in its createContents() method you could do:

getShell().setData(graphicalViewer);

then, in your tests, you could do:

final SWTBotShell shell = bot.shell("");
GraphicalViewer graphicalViewer = syncExec(new Result<GraphicalViewer>()
{
public GraphicalViewer run()
{
return (GraphicalViewer) shell.widget.getData();
}
});
SWTBotGefViewer viewer = new SWTBotGefViewer(graphicalViewer);

If you can't modify your application or can't attach the viewer to a
widget, then I really have no clue how you could achieve it...

Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: GEF GraphicalViewer within a dialog [message #559146 is a reply to message #559137] Wed, 15 September 2010 18:47 Go to previous messageGo to next message
Barry Dresdner is currently offline Barry DresdnerFriend
Messages: 75
Registered: July 2009
Member
Hi Pascal, That actually works beautifully! And it was not hard at all (at least in my case) to implement. Many thanks for your suggestion and best regards, Barry
Re: GEF GraphicalViewer within a dialog [message #559290 is a reply to message #559146] Thu, 16 September 2010 09:36 Go to previous messageGo to next message
Mariot Chauvin is currently offline Mariot ChauvinFriend
Messages: 174
Registered: July 2009
Senior Member
Hi Barry,

Great that you solve your problem.
Sorry for the delay of my response.

Regards,

Mariot

Barry Dresdner a écrit :
> Hi Pascal, That actually works beautifully! And it was not hard at all
> (at least in my case) to implement. Many thanks for your suggestion and
> best regards, Barry
Re: GEF GraphicalViewer within a dialog [message #559308 is a reply to message #559290] Thu, 16 September 2010 10:49 Go to previous message
Barry Dresdner is currently offline Barry DresdnerFriend
Messages: 75
Registered: July 2009
Member
No apologies necessary, I am impressed with you guys. One last question, do you know when these changes will be made available in the Helios Update Site? Thanks.
Previous Topic:activate cell editor in tree column
Next Topic:Close and open the workbench in a test
Goto Forum:
  


Current Time: Mon Nov 24 21:54:21 GMT 2014

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

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