Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » how to select a textviewer in the active shell?
how to select a textviewer in the active shell? [message #552271] Wed, 11 August 2010 14:33 Go to next message
Alexander Malic is currently offline Alexander MalicFriend
Messages: 29
Registered: July 2009
Junior Member
i am able to open the shell via a menu, but i'm unable to select the textviewer (because of global font-size settings) in the shell.

any clues?

thanks in advance,
alex
Re: how to select a textviewer in the active shell? [message #552286 is a reply to message #552271] Wed, 11 August 2010 15:06 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
On 10-08-11 10:33 AM, Alexander Malic wrote:
> i am able to open the shell via a menu, but i'm unable to select the
> textviewer (because of global font-size settings) in the shell.
>
> any clues?
>
> thanks in advance,
> alex

TextViewer is a JFace component, it's not a Widget. You can only select
Widget because they are in SWT's widget tree. You can view JFace
components as a series of listeners on the widget. So, since it's a
TextViewer, you should probably search for a Text instead.

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

*Because performance matters.*
Re: how to select a textviewer in the active shell? [message #552296 is a reply to message #552271] Wed, 11 August 2010 15:37 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 8/11/10 7:33 AM, Alexander Malic wrote:
> i am able to open the shell via a menu, but i'm unable to select the
> textviewer (because of global font-size settings) in the shell.
>
> any clues?


Perhaps this link might be of help:

http://wiki.eclipse.org/SWTBot/FAQ#Can_I_get_more_details_on _a_particular_widget.3F

--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot
Re: how to select a textviewer in the active shell? [message #552582 is a reply to message #552271] Thu, 12 August 2010 17:14 Go to previous messageGo to next message
Alexander Malic is currently offline Alexander MalicFriend
Messages: 29
Registered: July 2009
Junior Member
first thanx a lot for your help. i was able to find a solution!

i almost finished now my automated gui test for one testcase. now i have following problem. i have an editor with sections. one section has a toolbar embedded. i'd like to trigger one of its actions, but i'm not able to find it.

here's an example how the action is added to the section

private void addToolbar(Section section) {
    ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
    ToolBar toolbar = toolBarManager.createControl(section);

    Action myAction = new Action("My Tooltip", MyPlugin.getImageDescriptor(Icons.MY_ICON)) {
        public void run() {
            // do something
        }
    };
    myAction.setDescription("Some Decription");
    toolBarManager.add(myAction);
    
    toolBarManager.update(true);
    section.setTextClient(toolbar);
}


can you please give me a hint, how to trigger that action?

here's what EclipseSpy View tells me
Location: 
//Shell/-1//Composite/4//Composite/0//Composite/6//Composite/0//Composite/0//CTabFolder/0//MyFormToolkit$1/0//Form/0//LayoutComposite/1//Section/0//ToolBar/1

Layout Information: 
ToolBar {}
    Style: HORIZONTAL | FLAT | LEFT_TO_RIGHT 
    Layout Data: null
    Bounds: Rectangle {162, 3, 77, 22}


Children: 4
    ToolItem {}
    ToolItem {}
    ToolItem {}
    ToolItem {}

Siblings: 3
       Label {My Title}: Layout Data: null
    [*]ToolBar {}: Layout Data: null
       LayoutComposite {}: Layout Data: null

Parent Tree:
Section {My Title}[0]@
     Layout: ExpandableComposite$ExpandableLayout
     LayoutData: FormData
    LayoutComposite {}[1]@
         Layout: FormLayout
         LayoutData: null
        Form {My Title}[0]@
             Layout: Form$FormLayout
             LayoutData: null
             {My Title}[0]@
                 Layout: ScrolledCompositeLayout
                 LayoutData: null
                CTabFolder {}[0]@
                     Layout: CTabFolderLayout
                     LayoutData: null
                    Composite {}[0]@
                         Layout: FillLayout
                         LayoutData: null
                        Composite {}[0]@
                             Layout: FillLayout
                             LayoutData: null
                            Composite {}[6]@
                                 Layout: null
                                 LayoutData: null
                                Composite {}[0]@
                                     Layout: null
                                     LayoutData: null
                                    Composite {}[4]@
                                         Layout: StackLayout
                                         LayoutData: null
                                        Shell {My Title}[-1]@
                                             Layout: TrimLayout
                                             LayoutData: null


btw: i didn't start a new topic since it's a very special case
Re: how to select a textviewer in the active shell? [message #553978 is a reply to message #552271] Thu, 19 August 2010 14:53 Go to previous message
Alexander Malic is currently offline Alexander MalicFriend
Messages: 29
Registered: July 2009
Junior Member
solved it!!!

here's the code (i got working)
protected void executeActionByToolTip(String toolTip) {
	Object o = instanceOf(ToolItem.class);
	Matcher<Widget> matcher = (Matcher<Widget>) o;

	Object o2 = withTooltip(toolTip);
	Matcher<Widget> matcher2 = (Matcher<Widget>) o2;

	final ToolItem toolItem = (ToolItem) bot.activeEditor().bot().widget(allOf(matcher, matcher2));
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {
			Object data = toolItem.getData();
			Action action = (Action) ((ActionContributionItem) data).getAction();
			action.run();
		}
	});
}


better solutions are allways welcome
Previous Topic:Contract Job Offered - SWTBOT Tester/Developer
Next Topic:How to select a menu on a popup menu with SWTBOT?
Goto Forum:
  


Current Time: Fri Mar 29 15:30:51 GMT 2024

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

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

Back to the top