【问题标题】:RCP E4 Statusbar is to smallRCP E4 状态栏太小
【发布时间】:2017-09-14 21:03:46
【问题描述】:

我为我的 e4 rcp 应用程序创建了一个状态栏,但状态栏太小了。

在我的 Appliication.e4xmi 中配置了以下内容:

修剪的窗口 -> TrimBars -> 窗口修剪(底部) -> 工具栏 -> 工具控件(链接到我的 StatusBar 类)

链接状态栏类:

public class StatusBar {

private Label label;

@Inject
private IEventBroker eventBroker;
public static final String STATUSBAR = "statusbar";

@Inject
@Optional
public void getEvent(@UIEventTopic(STATUSBAR) String message) {
    updateInterface(message);
}

@PostConstruct
public void createControls(Composite parent) {
    label = new Label(parent, SWT.LEFT);
    label.setBackground(parent.getBackground());
}

public void updateInterface(String message) {
    try {
        Display.getDefault().asyncExec(new Runnable() {
            @Override
            public void run() {
                try {
                    label.setText(message);
                } catch (Exception e) {
                    logger.error(e.fillInStackTrace());
                }
            }
        });
    } catch (Exception exception) {
        logger.error(exception.fillInStackTrace());
    }
}

View of the Statusbar

【问题讨论】:

  • 太小了怎么办?不够深?不够长?
  • 状态栏高度太小了。

标签: swt rcp e4


【解决方案1】:

ToolControl 不需要 Toolbar。将 ToolControl 作为 Trim Bar 的直接子级。

将标签放入复合材料中以使其布局正确:

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

  body.setLayout(new GridLayout());

  Label label = new Label(body, SWT.LEFT);

  label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

   ....
}

您可能还想在 e4xmi 的 ToolControl 定义中指定标记值stretch,以使控件使用修剪栏中所有可用的水平空间。

【讨论】:

  • 这不起作用,如果我在正文上定义 LayoutData,状态栏的高度正确,但我得到一个 classcastexecption: java.lang.ClassCastException: org.eclipse.swt.layout.GridData无法转换为 org.eclipse.swt.layout.FillData
  • 我错过了您将 ToolControl 放在工具栏中 - 您不需要这样做。将 ToolControl 作为 Trim Bar 的子级,不需要 Toolbar。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-27
  • 2018-10-19
  • 1970-01-01
相关资源
最近更新 更多