I create a statusbar for my e4 rcp application but the statusbar is to small.
In my Appliication.e4xmi is the following configured:
Trimmed Window -> TrimBars -> Window Trim (Bottom) -> Toolbar -> Tool Control (link to my StatusBar class)
Linked StatusBar class:
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());
}
}
You don't need a Toolbar
for a ToolControl
. Put the ToolControl as the immediate child of the Trim Bar.
Put the label in a composite to get it layed out properly:
@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));
....
}
You may also want to specify a tag value of stretch
in ToolControl definiton in the e4xmi to make the control use all available horizontal space in the trim bar.