Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Selecting a Part from a Part Stack
Selecting a Part from a Part Stack [message #1698279] Fri, 12 June 2015 18:21 Go to next message
Evan LaHurd is currently offline Evan LaHurdFriend
Messages: 1
Registered: June 2015
Junior Member
I'm trying to test an Eclipse application that contains a Part Sash Container with two Part Stacks that contain various parts. I want to have a test that will start up the application, select one of the parts, and then proceed to manipulate the widgets. I've managed to do everything but figure out how to select a part from the Part Stack and make it active so that its widgets get instantiated. Is there any way to do this? Thanks in advance!
Re: Selecting a Part from a Part Stack [message #1698472 is a reply to message #1698279] Mon, 15 June 2015 20:56 Go to previous messageGo to next message
Eclipse UserFriend
Use the EPartService: #findPart() to find the part based on its id, and then #activate() to activate it. There is an EPartService instance for each MWindow.

Brian.
Re: Selecting a Part from a Part Stack [message #1699209 is a reply to message #1698472] Mon, 22 June 2015 15:38 Go to previous message
Patrik Suzzi is currently offline Patrik SuzziFriend
Messages: 2
Registered: February 2018
Junior Member
You need to get the service context and then get the current eclipse context from it.

After you have the context, and the needed services you can interact using an asyncExec .

public class E4SWTBot extends SWTBot(){

  private IEclipseContext serviceContext;
  private IEclipseContext context;

  public E4SWTBot(){
    serviceContext = E4Workbench.getServiceContext();
  }

  public EPartService getPartService(){
    context = serviceContext.getActiveLeaf();
    return context.get(EPartService.class);
  }

  public void selectPart(String partId){
    Display.getDefault().asyncExec(new Runnable(){
      public void run(){
        // get the part 
        MPart part = getPartService().findPart( partId );
        // Here your code to interact with part
        getPartService.activate(part);
      }
    });
  }

}


Check if it is needed to refer the active MWindow
Previous Topic:swtbot-how to change the facet version in Project Facets wizard
Next Topic:RCP Testing -- Contribution Identities
Goto Forum:
  


Current Time: Thu Apr 25 23:11:35 GMT 2024

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

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

Back to the top