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
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 877
Registered: January 2012
Senior Member

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.

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


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 Feb 09 01:03:04 GMT 2023

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

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

Back to the top