如何添加透视栏切换器到纯eclipse 4 rcp应用程序 [英] How to add Perspective Bar Switcher to pure eclipse 4 rcp application

查看:284
本文介绍了如何添加透视栏切换器到纯eclipse 4 rcp应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个纯Eclipse e4富客户端应用程序应用程序模型。我使用透视堆栈创建了多个透视图,但是我无法切换其他透视图,因为Eclipse e4中没有默认透视栏或切换器图标。如何在纯Eclipse e4中实现透视切换器?

解决方案

EPartService.switchPerspective 将执行实际的切换,但是您必须设计和实现UI。



您可以使用 ToolBar 在每个透视的按钮中的修剪条栏中。或者,组合作为工具控制,具有透视图列表,由您自己决定。



要在Trim Bar右侧放置一个控件,您需要添加两个Tool Control对象到trim。例如:





第一个工具控件只是一个



在控件的标签选项卡上添加单词 stretch 来告诉e4尽可能多地扩展这个控制:





您还必须为控件指定一个类。这只需要创建一个空的复合来占据空间。例如:

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

body.setLayout(new FillLayout());
}
}

第二个工具控件将包含您的Combo控件透视开关类似的东西:

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

...初始化Combo,添加听众,...
}
}

这应该是这样的:




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 perspective because there is no default perspective bar or switcher icon present in Eclipse e4. How to implement a perspective switcher in pure Eclipse e4?

解决方案

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:

这篇关于如何添加透视栏切换器到纯eclipse 4 rcp应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆