2017-09-14 129 views
1

我为我的e4 rcp应用程序创建一个状态栏,但状态栏很小。RCP E4状态栏是小的

以我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

+0

太小,以什么方式?不够深?不够长? –

+0

状态栏的高度很小。 – Darksmilie

回答

0

你并不需要一个ToolControl一个Toolbar。将ToolControl作为修剪栏的直接子元素。

把标签中的复合得到它奠定了正确:

@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指定的stretch在ToolControl definiton标签值,使控制使用所有可用的水平空间在修剪栏中。

+0

这不起作用,如果我在body上定义LayoutData,状态栏有正确的高度,但我得到一个classcastexecption: java.lang.ClassCastException:org.eclipse.swt.layout.GridData不能转换为org .eclipse.swt.layout.FillData – Darksmilie

+0

我错过了将ToolControl放在工具栏中 - 你不需要这样做。将ToolControl作为修剪栏的子项,不需要工具栏。 –

+0

工作,谢谢。 – Darksmilie