KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > person > search > PersonStartsWithQuickSearch


1 /*
2  * Created on Dec 15, 2004
3  * by alex
4  *
5  */

6 package com.nightlabs.ipanema.person.search;
7
8 import com.nightlabs.ipanema.person.PersonStruct;
9 import com.nightlabs.ipanema.person.util.PersonSearchFilter;
10 import com.nightlabs.ipanema.person.util.PersonSearchFilterItem;
11 import com.nightlabs.ipanema.person.util.TextPersonSearchFilterItem;
12 import com.nightlabs.jdo.search.SearchFilter;
13 import com.nightlabs.jdo.search.SearchFilterItem;
14 import com.nightlabs.jdo.search.SearchResultFetcher;
15
16 /**
17  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
18  */

19 public class PersonStartsWithQuickSearch extends PersonQuickSearch {
20
21     
22     private String JavaDoc startWithNeedle;
23     
24     /**
25      * Construct a PersonQuickSearch for persons begining with startWithNeedle.<br/>
26      * The resultFetcher will be called when the quick-button is pressed.<br/>
27      * If buttonText is not null or an empty string this will be the Buttons text,
28      * otherwise the startWithNeedle will be used.
29      *
30      * @param buttonText
31      * @param resultFetcher
32      * @param startWithNeedle
33      */

34     public PersonStartsWithQuickSearch(String JavaDoc buttonText, SearchResultFetcher resultFetcher, String JavaDoc startWithNeedle) {
35         super(buttonText, resultFetcher);
36         this.startWithNeedle = startWithNeedle;
37         if ((buttonText == null) || buttonText.equals("")) {
38             setButtonText(startWithNeedle);
39         }
40     }
41     
42     /**
43      * Construct a PersonQuickSearch for persons begining with startWithNeedle.<br/>
44      * The resultFetcher will be called when the quick-button is pressed.
45      *
46      * @param resultFetcher
47      * @param startWithNeedle
48      */

49     public PersonStartsWithQuickSearch(SearchResultFetcher resultFetcher, String JavaDoc startWithNeedle) {
50         super(startWithNeedle,resultFetcher);
51         this.startWithNeedle = startWithNeedle;
52     }
53     
54     /**
55      * Overrides and adds TextPersonSearchFilter for PersonalData/Name and PersonalData/Company to
56      * begin with startWithNeedle.
57      *
58      * @see com.nightlabs.jdo.search.SearchFilterProvider#getPersonSearchFilter()
59      */

60     public SearchFilter getSearchFilter() {
61         PersonSearchFilter filter = super.getPersonSearchFilter(false);
62         // add Name filter
63
PersonSearchFilterItem item = new TextPersonSearchFilterItem(PersonStruct.PERSONALDATA_NAME,SearchFilterItem.MATCHTYPE_BEGINSWITH,startWithNeedle);
64         filter.addSearchFilterItem(item);
65         // add Company filter
66
item = new TextPersonSearchFilterItem(PersonStruct.PERSONALDATA_COMPANY,SearchFilterItem.MATCHTYPE_BEGINSWITH,startWithNeedle);
67         filter.addSearchFilterItem(item);
68         return filter;
69     }
70 }
71
Popular Tags