Today I am happy being able to talk for the first time about a new component we’ve been developing for quite some time.
Before going into technical details, I’d like to point out that the development of features currently available has been sponsored by ITBH who agreed to have all sources released under the Apache license Version 2.0, that allows free usage in commercial products as long as the license terms are respected.
What is XGrid
XGrid is a feature rich Grid-Control, that can be set up using an imperative language like Java, but also by an EMF model in declarative fashion. In the current version, XGrid comes with built-in features like filtering or sorting and we are looking for funding of further developement (e.g. PDF export?). If you are interested, please contact us by email.

Where do I get it from
XGrid is developed in a public github-repository and we are using the github infrastructure for bugtracking and documentation.
In case you miss a feature, please file a ticket and maybe consider, if you can support the development by funding it like ITBH did.
The XGrid design
At the root, XGrid is nothing more but a set of interfaces completely agnostic to the underlying UI toolkit, so it is possible, to use the same configuration and API regardless if you are developing an SWT, JavaFX, … application. At the moment, the only implementation of the XGrid API is for SWT, based on the excellent Nebula Grid control, that BestSolution.at has been maintaining for many years.
XGrid follows two key design patterns: On the one hand, @FunctionalInterface types are accepted almost everywhere in the API and on the other hand, Java8 features should be integrated including for example type annotations for NullAnalysis.
Sample usage
You are able to use XGrid by using its java API
public abstract class MyPersonGrid {
public void setup() {
XGridTable<Person> t = createControl();
{
XGridColumn<Person, String> c = t.createColumn("firstname",
p -> p.getFirstname());
c.labelProperty().set("Firstname");
}
{
XGridColumn<Person, String> c = t.createColumn("lastname",
p -> p.getLastname());
c.labelProperty().set("Lastname");
}
{
DateFormat f = DateFormat.getDateInstance();
XGridColumn<Person, Date> c = t.createColumn("birthday",
p -> p.getBirthdate());
c.textFunctionProperty().set((p,b) -> f.format(b));
c.labelProperty().set("Birthday");
}
t.contentProviderProperty().set(
new ListGridContentProvider<Person>(getPersonList()));
}
protected abstract XGridTable<Person> createControl();
}
public class MySWTPersonGrid extends MyPersonGrid {
protected XGridTable<Person> createControl() {
return new SWTGridTable<>(s,
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
}
}
Like in day to day work, we often see that setting up controls like a grid based on Java is very cumbersome, and if you for example want to display different configurations based for example on user privileges, your code gets very complex quickly and maintainances becomes much more difficult.
Due to this, XGrid comes with an optional component that allows you to configure a grid instance by an EMF model, bringing the additional benefit of being able to load the application model from anywhere. So you can even update your XGrid component without deploying a new version of your application. Simply put the configurations on a remote server and fetch them from there.
Setting up a grid based on a configuration is nothing more than
public abstract class MyPersonGrid {
URL configUrl = ....;
private MGridConfigurationSet getConfig() {
Resource resourceModel = new XMIResourceImpl();
try(InputStream in = url.openStream()) {
resourceModel.load(in, null);
MGrid config = (MGrid) resourceModel.getContents().get(0);
return config.getDefaultConfiguration();
} catch(IOException e) {
throw new RuntimeException(e);
}
}
public void setup() {
XGridTable<Person> t = createControl();
MGridConfigurationSet c = getConfig();
EmfGridTableConfigurator.configure(t, c);
}
}
public class MySWTPersonGrid extends MyPersonGrid {
protected XGridTable<Person> createControl() {
return new SWTGridTable<>(s,
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
}
}
What is XGridComponent
While XGrid is a pure Grid-Control, XGridComponent is a higher level element that collects the low-level features of XGrid and allows them to be integrated into a framework like Eclipse 4, where for example the grid selection is published automatically by an ESelectionService and the IEventBroker.
Besides this, we put a lot of attention on remaining framework neutral. Because of this, the XGridComponent implementation does not have any framework dependencies and expects itself to be configured through a dependency injection (DI) framework.
By default we ship an integration for e4, that can be used like this in your application model:
<application:Application>
<!-- .... -->
<children xsi:type="basic:PartStack">
<children xsi:type="basic:Part"
contributionURI="bundleclass://at.bestsolution.framework.grid.component/at.bestsolution.framework.grid.component.XGridTableComponent">
<persistedState
key="xgrid.configuration"
value="emf-resource:platform:/plugin/at.bestsolution.framework.grid.e4.sample/config/sampleConfig.xmi"/>
<persistedState
key="xgrid.content"
value="sample:platform:/plugin/at.bestsolution.framework.grid.e4.sample/sampledata/sampleData.xmi"/>
</children>
</children>
<!-- .... -->
</application:Application>
What’s next?
As already pointed out, the initial development of XGrid was funded by ITBH and they deserve all our respect for funding such a useful component.
At the moment, we are looking for additional funding for XGrid, allowing us to add additional, cool features like the ones below:
- Editing support
- XGrid-SWT is already fast but speed could be improved tremendously
by using the Grids visibility feature
- ODF, Excel & PDF export
- JavaFX support
Just drop a note if you are interested in one of these or have further ideas on XGrid – we are looking forward to extend/adapt XGrid for you!