01: package tijmp.ui;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05: import tijmp.filter.CommonArrayFilter;
06: import tijmp.filter.ExactFilter;
07: import tijmp.filter.Filter;
08: import tijmp.filter.NotFilter;
09: import tijmp.filter.OrFilter;
10: import tijmp.filter.RecursiveFilter;
11:
12: /** A class to handle the current filter.
13: */
14: public class FilterConfig {
15: private Filter filter;
16: private List<FilterListener> fls = new ArrayList<FilterListener>();
17: private static String[] defaultRemoved = { "java.", "javax.",
18: "sun.", "tijmp." };
19:
20: public FilterConfig() {
21: setDefaultFilter();
22: }
23:
24: public void setDefaultFilter() {
25: RecursiveFilter rj1 = new RecursiveFilter(defaultRemoved[0]);
26: RecursiveFilter rj2 = new RecursiveFilter(defaultRemoved[1]);
27: OrFilter o = new OrFilter(rj1, rj2);
28: for (int i = 2; i < defaultRemoved.length; i++) {
29: RecursiveFilter r = new RecursiveFilter(defaultRemoved[i]);
30: o = new OrFilter(r, o);
31: }
32: CommonArrayFilter caf = new CommonArrayFilter();
33: o = new OrFilter(caf, o);
34: filter = new NotFilter(o);
35: ExactFilter sf = new ExactFilter(String.class);
36: filter = new OrFilter(filter, sf);
37: fireFilterChanged();
38: }
39:
40: public Filter getFilter() {
41: return filter;
42: }
43:
44: public void setFilter(Filter filter) {
45: this .filter = filter;
46: fireFilterChanged();
47: }
48:
49: private void fireFilterChanged() {
50: for (FilterListener fl : fls)
51: fl.filterChanged(filter);
52: }
53:
54: public void addFilterListener(FilterListener fl) {
55: fls.add(fl);
56: }
57:
58: public void removeFilterListener(FilterListener fl) {
59: fls.remove(fl);
60: }
61: }
|