Open main menu

CDOT Wiki β

Changes

Teams Winter 2011/team1/RCP/Create RPC Application

1,598 bytes added, 12:49, 4 March 2011
no edit summary
return selectionAdapter;
}
</pre></br/>
4.6 Run the application. Click on a column header, the table should be sorted according to the content of this column.<br/>
There will also appear a sort-direction in the top of the column:<br/>
=== 5. Add Filter(Search) Option ===
5.1 Create new class that extends <code>ViewerFilter</code>:<br/> <pre> package cs.ecl.rcp.simplercp.filter;  import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerFilter;  import cs.ecl.rcp.simplercp.model.*;  public class StudentFilter extends ViewerFilter { private String searchString;  public void setSearchText(String s) { // Search must be a substring of the existing value this.searchString = ".*" + s + ".*"; }  @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (searchString == null || searchString.length() == 0) { return true; } Student s = (Student) element; if (s.getFirstName().toLowerCase().matches(searchString.toLowerCase())) { return true; } if (s.getLastName().toLowerCase().matches(searchString.toLowerCase())) { return true; } if (s.getProgram().toLowerCase().matches(searchString.toLowerCase())) { return true; } if (s.getId().matches(searchString)) { return true; }  return false; } } </pre><br/>5.2 Create a new private variable in the <code>StudentView</code> class: <code>private StudentFilter filter;</code><br/>5.3 Add the filter to <code>createPartControl()</code> method:<br/> <pre> filter = new StudentFilter(); viewer.addFilter(filter); </pre><br/>5.4 Run the application. Search for the student:<br/>[[Image: Create4.png | 400px]]<br/> === 6. Add Highlights to Search ===6.1
1
edit