The table support layer builds on the model adapter and standard converters to offer easy to set up table support.
If you read the feature list and are new to SWT/JFace, you might wonder why there is no component supporting all this stuff out of the box.
A lot of people wonder, that's why I started RCPForms.
The Sandbox example delivered with RCPForms has a class SandboxTablePart which demonstrates most of the features of the TableSupport layer. This is a definitive must to get an idea how it works.
A table example is shown below. An RCPCheckboxTable is created and added to a section using a builder.
The wrapper automatically creates a CheckboxTableViewer, which is configured using the main class of the Table Support Layer, TableUtil.
You pass a list of column configurations, which define header text, property to display in the column, size, alignment, if the column should use additional space when the table is resized and the cell editor type.
Everything else is handled by the table support layer, which is a lot if you know SWT and JFace,
since plain swt tables which support editing are quite ugly to use.
The input should be a WritableList, since this list can fire change notifications; if you want to use a plain list, you need to handle refresh yourself.
private void createTableViewer(final GridBuilder sf) { RCPCheckboxTable table = new RCPCheckboxTable("Table:"); sf.addLine(table); TableViewer tableViewer = (TableViewer) table.getViewer(); TableUtil.configureTableViewer(tableViewer, new ColumnConfiguration[]{ new ColumnConfiguration("Name", TestModel.P_Name, 100, SWT.LEFT, false, ECellEditorType.TEXT).setGrabHorizontal(true), new ColumnConfiguration("Birthdate", TestModel.P_BirthDate, 80, SWT.LEFT, false, ECellEditorType.TEXT), new ColumnConfiguration("Gender", TestModel.P_Gender, 60, SWT.LEFT, net.sf.rcpforms.test.TestModel.Gender.values()), new ColumnConfiguration("Overdraw", TestModel.P_OverdrawAccount, 50, SWT.CENTER, false, ECellEditorType.CHECK),}, TestModel.class, true); WritableList list = new WritableList(); list.add(new TestModel("Schmitz", 55)); list.add(new TestModel("Meier", 33)); tableViewer.setInput(list); }
All the tedious setup you have to do to get an editable table using JFace is done by TableUtil.configureTableViewer() based on the declarative column configurations: