Home » Eclipse Projects » SWTBot » What Widget is that?(Button? DropDownList? List? Tree?)
| | | | | | |
Re: What Widget is that? [message #547731 is a reply to message #547361] |
Mon, 19 July 2010 13:52 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
On 10-07-16 09:12 AM, Caio Bulgarelli wrote:
> Ohhh nice!
>
> I didn't know this feature of SWTBot!
>
> Thanks a lot Pascal and Ketan for the tip! It's very usefull
>
> So... I was using the Spy View from PDE,
> but ... now, using this SpyView (from SWTBot Plugin)
>
> I got this:
>
>
>>>>>>
>
> Location: //Shell/-1//Composite/4//Composite/0//Composite/21//Composit
> e/0//FigureCanvas/0
>
> Layout Information: FigureCanvas {}
> Style: HORIZONTAL | VERTICAL | NO_BACKGROUND | NO_REDRAW_RESIZE |
> LEFT_TO_RIGHT Layout Data: null
> Bounds: Rectangle {0, 0, 572, 271}
>
>
> Children: 0
>
> Siblings: 1
> [*]FigureCanvas {}: Layout Data: null
>
> Parent Tree:
> Composite {}[0]@
> Layout: FillLayout
> LayoutData: null
> Composite {}[21]@
> Layout: FillLayout
> LayoutData: null
> Composite {}[0]@
> Layout: null
> LayoutData: null
> Composite {}[4]@
> Layout: StackLayout
> LayoutData: null
> Shell {MOTODEV Studio for A...}[-1]@
> Layout: TrimLayout
> LayoutData: null
>
>
>>>>>>>
>
> So, what is this FigureCanvas and how can use it?
>
Ouch, though luck. FigureCanvas is a widget on which you draw something:
you can draw rectangle, circle, all kinds of things. It's not really a
widget you can interact with using regular SWTBot API.
Although, I think it might be related to GEF's TreeViewer, so you could
interact with it using GEF support in SWTBot
(org.eclipse.swtbot.eclipse.gef packages), but I've only used it with a
GraphicalViewer. Maybe Mariot has more insight for that part though...
Mariot?
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
| | |
Re: What Widget is that? [message #549399 is a reply to message #548950] |
Mon, 26 July 2010 14:54 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
On 10-07-23 10:10 AM, Ketan Padegaonkar wrote:
>
> On 7/23/10 6:40 AM, Caio Bulgarelli wrote:
>> I'm trying to use and create an object of FigureCanvas, in order to use
>> it posteriorly.
>>
>> So... I needed to import:
>>
>> import org.eclipse.draw2d.FigureCanvas;
>>
>> and initialize it
>>
>> FigureCanvas f = new FigureCanvas( (Composite)
>> bot.viewByTitle("Snippets").getWidget() );
>>
>> However, the parameter of FigureCanvas must be a "Composite" ... and the
>> code above doesn't work.
>>
>> So... Does anyone have any ideas?
>>
>
> I don't understand GEF much, but AFAIK. This is tricky and will create a
> canvas, but since SWTBot is running on a non-ui thread, you'd likely get
> a SWT Thread error.
>
> Perhaps someone with a bit more of GEF/Draw2d needs to pitch in ?
>
Oops, a bit of misunderstanding here. FigureCanvas is the actual widget;
it's like a Button or a a Combo, or anything else. FigureCanvas
subclasses Canvas, on which you can draw ANYTHING; much like a Button
you can click on it and a ComboBox you make a choice. The FigureCanvas,
on the other hand, draws Figure (which is draw2d API).
To "use" a FigureCanvas in SWTBot, you need the proper Mock object; much
like Button and SWTBotButton, Combo and SWTBotCombo.
SWTBotGefFigureCanvas is the mock object you are looking for, but it
should not be part of SWTBot's API IMHO. The only thing you can do with
it is interact using the mouse and keyboard: move the mouse there,
left-click, move the mouse elsewhere, etc. which is not a very stable
method to unit testing. You can start using that for quick testing if
you want though...
To make your tests more reliable, you should use Edit parts' Mock
objects: SWTBotGefEditPart. The mechanics are a bit different then
regular SWTBot testing though. To obtain a reference to a
SWTBotGefEditPart (BEP for short, please), you can't simply create one
using the constructor (which is package private anyway), you need a
SWTBotGefEditor. To create a SWTBotGefEditor, you need a
IEditorReference; this means that you need an eclipse editor. A common
way to create a SWTBotGefEditor is:
SWTWorkbenchBot bot = new SWTWorkbenchBot();
SWTBotEditor temp = bot.editorByTitle("Snippets");
SWTBotGefEditor editor = new SWTBotGefEditor(temp.getReference(), new
SWTGefBot());
There! You have a reference to the editor, you can access BEP!
SWTBotGefEditPart part = editor.getEditPart("General");
part.click();
Now, you might have noticed that I spoke about EDITOR, not VIEW. Simple:
there is currently no support for view-based GEF viewers. It should be
quite simple to implement though. I suspect that the thing you use is a
view, so the above method MIGHT NOT WORK. I've opened a bug/feature
request on this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=320912
Hope this helps.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
| | |
Re: What Widget is that? [message #549935 is a reply to message #549922] |
Wed, 28 July 2010 13:47 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
On 10-07-28 09:37 AM, John Ormerod wrote:
> These 'buttons' look like Nebula PShelfItems - see:
> http://www.eclipse.org/nebula/widgets/pshelf/pshelf.php
>
> The PShelf extends org.eclipse.swt.widgets.Canvas, and the PShelfItem
> extends org.eclipse.swt.widgets.Item.
>
> This could explain why the SWTBotSpy is finding Canvas. I guess in terms
> of clicking a 'button' so that the shelf item expands, you could be
> looking to grab the Item object.
>
> At this very moment, I have an RCP client in which a single PShelfItem
> is effectively providing the View title bar. My PShelfItem gets its
> items from a jFace TableViewer. I have found that I can bypass the
> PShelf and select a TableItem directly.
>
> However, at some point I am going to want to expand a PShelfItem, so, in
> the absence of PShelf support in SWTBot, I'll watch this space with
> interest to see if a solution emerges.
>
> Regards, John
It does kinda look like that, but the Spy view is indicating a
FigureCanvas, not a Canvas. And FigureCanvas is dra2d API.
And, AFAIK, the spy view would of shown the proper class name (Location:
//Shell/-1//Composite/4//Composite/0//Composite/21//Composit
e/0//PShelf/0 ) if it really was a PShelf.
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
| |
Goto Forum:
Current Time: Thu Sep 26 00:45:13 GMT 2024
Powered by FUDForum. Page generated in 0.05042 seconds
|