Home
Tom Schindl edited this page Jan 16, 2015
·
8 revisions
XGrid is a feature rich multi UI-Toolkit Grid/Table framework to display and edit business data in a table like structure as of today only a SWT implementation is available but implementation for JavaFX would be fairly easy to implement.
- Java8 friendly API with
@FunctionalInterface
APIs when ever possible - Flexible yet simple formatting of cell data
- Autofilter like you know them from Excel / OpenOffice
- Built-in sorting based on columns
- Easy integration into e4 applications
All components are OSGi bundles but the basic widget components are able to run outside an OSGi container
- Bundles which do not require OSGi
- at.bestsolution.framework.grid: Is the basic API definition which is widget toolkit neutral
- at.bestsolution.framework.grid.swt: Is the SWT implementation of the XGrid API
- at.bestsolution.framework.grid.model: Definition of the configuration model allowing to configure XGrid through an EMF configuration file instead of API calls
- at.bestsolution.framework.grid.emf: Configures a XGrid instance through a configuration model instance
- Bundles which require OSGi
- at.bestsolution.framework.grid.component: API to integrate an XGrid into an OSGi application framework
- at.bestsolution.framework.grid.component.e4: Implementation of the API to integrate into an e4 application
- at.bestsolution.framework.grid.component.emf: Implementation to configure a XGrid component through the EMF configuration model from above
- at.bestsolution.framework.grid.swt.e4: Implementation to create an XGrid instance in an e4 SWT application
public class GridSetupHelper {
public static void configurePersonGrid(XGridTable<Person> t) {
{
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");
}
}
// ....
}
public class GridSetupHelper {
// ....
public static void configurePersonGrid(XGridTable<Person> t, MGridConfigurationSet currentConfig) {
EmfGridTableConfigurator.configure(table, currentConfig);
}
}
public class SampleSWT {
public void createGrid(Composite parent) {
XGridTable<Person> t = new SWTGridTable<>(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
GridSetupHelper.configurePersonGrid(t);
t.contentProviderProperty().set(new ListGridContentProvider<Person>(getPersonList()));
}
}
public class MyGridUIComponent {
@PostConstruct
public void createGridUI(XGridFactory factory) {
XGridTable<Person> t = factory.createGridTable();
GridSetupHelper.configurePersonGrid(t);
t.contentProviderProperty().set(new ListGridContentProvider<Person>(getPersonList()));
}
}
In your Application.e4xmi
<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" ... elementId="org.eclipse.e4.ide.application">
....
<children xsi:type="basic:PartStack">
<children
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>
....
And to load the content from the sample:platform:.....
XMI you need to supply an OSGi-Service of type XGridContentProviderProvider
which might look like this:
public class SampleContentProviderProvider implements XGridContentProviderProvider {
@Override
public boolean applies(String descriptor) {
if( descriptor.equals("sample:platform:/plugin/at.bestsolution.framework.grid.e4.sample/sampledata/sampleData.xmi") ) {
return true;
}
return false;
}
@Override
public <R> XGridContentProvider<R> getContentProvider(String descriptor) {
URI uri = URI.createURI(descriptor.substring("sample:".length()));
ResourceSet set = new ResourceSetImpl();
Resource resource = set.getResource(uri, true);
return new EListGridContentProvider<R>(
resource.getContents().get(0),PersonPackage.Literals.ROOT__PERSONS);
}
}