Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » RCP Testing -- Contribution Identities
RCP Testing -- Contribution Identities [message #1699458] Wed, 24 June 2015 12:42 Go to next message
Joaquin Morcate is currently offline Joaquin MorcateFriend
Messages: 52
Registered: March 2010
Member
Hi all,

How can I assign an identity to a toolbar button that has been added using extension points, i.e. by a menu contribution like in the following example?

   <extension
         point="org.eclipse.ui.menus">
       <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
         <toolbar
               id="net.morcate.mypackage.toolbar"
               label="Neighborhood Toolbar">
            <command
                  commandId="org.eclipse.ui.views.showView"
                  icon="icons/primary.png"
                  id="net.morcate.mypackage.showView"
                  label="Neighborhood"
                  style="push"
                  tooltip="Show Neighborhood">
               <parameter
                     name="org.eclipse.ui.views.showView.viewId"
                     value="net.morcate.mypackage.viewer">
               </parameter>
            </command>
         </toolbar>
      </menuContribution>
   </extension>



Thank you very much
Re: RCP Testing -- Contribution Identities [message #1699483 is a reply to message #1699458] Wed, 24 June 2015 14:33 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

I'm not understanding what you're looking for as you have it in your example: your <command> has an id "net.morcate.mypackage.showView". So you can do an "after=net.morcate.mypackage.showView" in your location URIs.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: RCP Testing -- Contribution Identities [message #1699592 is a reply to message #1699483] Thu, 25 June 2015 09:44 Go to previous messageGo to next message
Joaquin Morcate is currently offline Joaquin MorcateFriend
Messages: 52
Registered: March 2010
Member
Thanks Brian for your reply.

The previous XML fragment will 'produce' a button in the main toolbar of my application. My problem is that the button doesn't have an id that I can use to find it later when running my SWTBot tests. At the moment, I just go through the buttons checking the tooltip text. But this seems too brittle to me. I would prefer to be able to assign an id as I can do with other widget that I build programmatically.


Thank you again
Re: RCP Testing -- Contribution Identities [message #1699676 is a reply to message #1699592] Thu, 25 June 2015 18:34 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

Hmm, I see your point. I think you'll need to write an SWTBot Finder that knows how to traverse E4-level concepts: the org.eclipse.ui.menus extension point is used to populate E4-level toolbars.

org.eclipse.swtbot.e4.finder has a MenuFinder and ContextMenuFinder but they are actually SWT-based rather than E4-based, so they're not perfect exemplars to follow. Each of the E4 UI Elements (MUIElement) generally have a corresponding SWT widget that you can obtain using MUIElement#getWidget(). Each of these widgets has a back pointer to the MUIElement using the widget's data dictionary using the key AbstractPartRenderer.OWNING_ME = "modelElement".

So you can get the current MWindow, verify it's a MTrimmedWindow, and check its MTrimmedWindow > getTrimBars(). And then iterate over the contents looking for MHandledItems whose elementId matches the "id" or whose command matches the "commandId" (whichever you want).

And then contribute it back to SWTBot

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Selecting a Part from a Part Stack
Next Topic:How to test context or popup Menus for a Composite.
Goto Forum:
  


Current Time: Mon Sep 24 11:05:53 GMT 2018

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

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

Back to the top