Menu

#19 Add filtering capabilities to Traceabilty tab

1.1.0
closed
8
2011-09-20
2011-06-08
No

Background

Crow allows to set the traces between different elements by using the "Traceability" tab
in the Edit-dialog. This works fine except the situation when the list of potentially traced
elements grows large. Therefore, user needs to scroll that list to find the traced element,
and there's no abilty neither to sort it, nor to filter.

This has to be improved by introducing the fitering capability to the Edit-dialog.

Steps to implement

1. Extend AbstractEditElementDialog

- extend method addList so that it adds a text field between the label and the list. Example

CRS:
[i] [..........................] <----
+------------------------------+
| |
| |
| |
| |
| |
| |
+------------------------------+

TRS:
[i] [..........................] <----
+------------------------------+
| |
| |
| |
| |
| |
| |
+------------------------------+

- [i] should be a filter-icon (attached).
- put this icon to lib/images.jar/images (next to other icons)
- extend ResourceManager with corresponding field and a static getter for the filter-icon

- when user enters or changes the text in that textfield, the list below should be updated
dynamically (as the text is changed) so that it shows only items that match the entered expression
- the expression should support wildcards, similar to the P4 Changelists-filtering tasks
- use WildCardRegex class to convert wildcards to regexps
- you should also add "*" to the beginning and to the end of the entered expression before
matching it with the list items
- for this purpose, you should add a Document Listener to the text field. Example:

txtFilter.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent arg0) {
updateFilter(arg0);
}
public void insertUpdate(DocumentEvent arg0) {
updateFilter(arg0);
}
public void removeUpdate(DocumentEvent arg0) {
updateFilter(arg0);
}
protected void updateTemplates(DocumentEvent arg0) {
String expr = arg0.getDocument().getText(0, arg0.getDocument().getLength());
// process expr ...
}
});

- when a filter is clear (no text entered), the list should naturally show all available items

2. Create FilteredListModel for traceability lists

- the method AbstractEditElementDialog.createTracePanel() creates all lists and list models for them
- currently, DefaultListModel is used which is not capable of filtering its elements
- the common approach to filtered lists is to create a separate class i.e. FilteredListModel which
should keep the DefaultListModel as one of its members
- when the ListModel is asked for elements, it should apply a filter to the original (un-filtered)
DefaultListModel and return only those elements that match the filter (or just call methods of
DefaultListModel in case if a filter expression is empty)
- watch the performance. Most likely it is worth caching the prepared Matcher inside the model.
- additional optimization may be required in future
- consider extending your new model-class from AbstractListModel and store it in package u.o.l.Crow.View

3. DefaultListModel-cleanup

- currently the whole applications expects that the traceability-lists (lstTrs, lstCrs, etc.) have a
model of class DefaultListModel
- however, after your changes, it won't be so.
- please carefully replace all references from DefaultListModel to AbstractListModel or FilteredListModel
where the traceability lists are processed
- caution: do not touch other places where DefaultListModel is used - for example, all attachment-related
stuff should be kept as it is.

Discussion

  • Sergey Borodavkin

    filter-icon [i]

     
  • Aleksandr

    Aleksandr - 2011-06-10

    Fixed

     
  • Sergey Borodavkin

    SVN revisions 43, 41, 40, 39, 38 , 36, 35

     
  • Sergey Borodavkin

    • status: open --> closed
     

Log in to post a comment.