1
edit
Changes
no edit summary
=== 21. Show Data in Application ===21.1 Columns data in a JFace table can be hold in <code>ModelProvider</code> and it is defined via instances of <code>TableViewerColumn</code> object:<br/>
<code>viewer.setInput(ModelProvider.INSTANCE.getStudents());</code><br/>
and
<code>TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);</code>
Private variable: <br/>
<code>private TableViewer viewer;</code><br/>
</pre><br/>
Add the same functionality for other three columns
[[Image: Create1.png | 400px]]<br/>
=== 32. Add Edit Cell Data Option ===32.1 To make the column editable you need to define an object of type <code>EditingSupport/<code> on your TableColumnViewer.32.2 Create new class for each column that extends <code>EditingSupport</code> class:
<pre>
package cs.ecl.rcp.simplercp.edit;
}
</pre><br/>
Add the following line at the end of the <code>LabelProvider</code> is set:<br/>
<code>col.setEditingSupport(new IdEditingSupport(viewer));</code><br/>
[[Image: Create2.png | 400px]]<br/>
=== 43. Add Sorting Option ===43.1 Create a new Class <code>StudentViewerComparator.java</code> put it in package <code>sorter</code>:<br/>
<pre>
package cs.ecl.rcp.simplercp.sorter;
}
</pre><br/>
<code>private StudentViewerComparator comparator;</code><br/>
<pre>
comparator = new StudentViewerComparator();
viewer.setComparator(comparator);
</pre><br/>
<code>column.addSelectionListener(getSelectionAdapter(column, colNumber));</code><br/>
<pre>
private SelectionAdapter getSelectionAdapter(final TableColumn column, final int index) {
}
</pre><br/>
There will also appear a sort-direction in the top of the column:<br/>
[[Image: Create3.png | 400px]]<br/>
=== 54. Add Filter(Search) Option ===54.1 Create new class that extends <code>ViewerFilter</code>. This class uses case-insensitive filtering:<br/>
<pre>
package cs.ecl.rcp.simplercp.filter;
}
</pre><br/>
<code>private StudentFilter filter;</code><br/>
<pre>
filter = new StudentFilter();
viewer.addFilter(filter);
</pre><br/>
[[Image: Create4.png | 400px]]<br/>
=== 65. Add Highlights to Search ===65.1 Create a new helper class and put it in <code>util</code> package. <br/>
Method in this class use logic that is case-insensitive, because filter is case-insensitive:<br/>
<pre>
}
</pre><br/>
Following is the code for the first column, other columns need to be changed in similar way:<br/>
<pre>
col.setEditingSupport(new IdEditingSupport(viewer));
</pre><br/>
[[Image: Create5.png | 400px]]