I'm developing a plug-in for a Eclipse RCP application. In this plug-in I want to set a text message and an icon in the trim status bar.
Considering my circumstances, I think I can scrap the following approaches:
The ActionBarAdvisor approach seems to require the main application to set the status bar content. This is not suitable as the plug-in should be able to be independent to the application and vice versa.
The StatusLineContributionItem seems to be bound to a certain view. In my case, the content has to be set globally for the whole application regardless of the currently selected view.
This leaves us to the Contributing to the Status Bar/Trim in Eclipse RCP approach. I've set up a small sample implementation following this approach:
The plugin.xml implementation:
<menuContribution
allPopups="false"
locationURI="toolbar:org.eclipse.ui.trim.status">
<toolbar
id="mypackage.toolbarContribution">
<control
class="mypackage.StatusBarContribution">
</control>
</toolbar>
</menuContribution>
And the class implementation:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
public class StatusBarContribution extends WorkbenchWindowControlContribution {
protected Composite composite = null;
@Override
protected Control createControl(Composite parent) {
FillLayout layout = new FillLayout(SWT.HORIZONTAL);
layout.marginHeight = 0;
layout.marginWidth = 0;
composite = new Composite(parent, SWT.NO_TRIM | SWT.BORDER);
composite.setLayout(layout);
Text text = new Text(composite, SWT.NONE);
text.setText("foo");
return composite;
}
}
But this only gives me a small slice of text in the status bar:
I purposely set
composite = new Composite(parent, SWT.NO_TRIM | SWT.BORDER);
to be able to see the layout margins:
As you can see, the created composite height is way to low to display the text correctly:
So, am I missing here something - e.g. using another margin property or SWT bit style?