How to add Perspective Bar Switcher to pure eclipse 4 rcp application

前端 未结 1 1561
情话喂你
情话喂你 2020-12-21 07:42

I have created a pure Eclipse e4 rich client platform application application model. I created multiple perspectives using perspective stack, but I am unable to switch other

相关标签:
1条回答
  • 2020-12-21 08:41

    EPartService.switchPerspective will do the actual switch, but you will have to design and implement the UI.

    You could use a ToolBar in the window Trim Bar with buttons for each perspective. Alternatively a Combo as a Tool Control with a list of the perspectives, it is up to you.

    To put a control at the right of a Trim Bar you need to add two Tool Control objects to the trim. Something like:

    The first Tool Control is just a spacer to fill the center of the bar.

    On the tags tab for the control add the word stretch to tell e4 to stretch this control over as much space as possible:

    You will also have to specify a class for the control. This just needs to create an empty Composite to occupy the space. For example:

    public class SpacerControl
    {
      @PostConstruct
      public void postConstruct(final Composite parent)
      {
        Composite body = new Composite(parent, SWT.NONE);
    
        body.setLayout(new FillLayout());
      }
    }
    

    The second Tool Control will contain your Combo control for the perspective switch. Something like:

    public class ComboControl
    {
      @PostConstruct
      public void createGui(final Composite parent)
      {
        Combo combo = new Combo(parent, SWT.READ_ONLY);
    
        ... initialize Combo, add listeners, ....
      }
    }
    

    This should end up looking something like this:

    0 讨论(0)
提交回复
热议问题