Source Code Cross Referenced for ContactSearchProvider.java in  » Mail-Clients » columba-1.4 » org » columba » contact » search » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Mail Clients » columba 1.4 » org.columba.contact.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.columba.contact.search;
002:
003:        import java.text.MessageFormat;
004:        import java.util.Iterator;
005:        import java.util.List;
006:        import java.util.ResourceBundle;
007:        import java.util.Vector;
008:
009:        import javax.swing.ImageIcon;
010:
011:        import org.columba.addressbook.folder.AddressbookFolder;
012:        import org.columba.addressbook.folder.virtual.VirtualFolder;
013:        import org.columba.addressbook.gui.frame.AddressbookFrameMediator;
014:        import org.columba.addressbook.gui.search.BasicResultPanel;
015:        import org.columba.addressbook.gui.search.ComplexResultPanel;
016:        import org.columba.addressbook.model.IContactModel;
017:        import org.columba.api.gui.frame.IFrameMediator;
018:        import org.columba.api.plugin.PluginLoadingFailedException;
019:        import org.columba.core.gui.frame.FrameManager;
020:        import org.columba.core.gui.search.StringCriteriaRenderer;
021:        import org.columba.core.gui.search.api.ICriteriaRenderer;
022:        import org.columba.core.gui.search.api.IResultPanel;
023:        import org.columba.core.resourceloader.IconKeys;
024:        import org.columba.core.resourceloader.ImageLoader;
025:        import org.columba.core.search.SearchCriteria;
026:        import org.columba.core.search.api.ISearchCriteria;
027:        import org.columba.core.search.api.ISearchProvider;
028:        import org.columba.core.search.api.ISearchRequest;
029:        import org.columba.core.search.api.ISearchResult;
030:
031:        public class ContactSearchProvider implements  ISearchProvider {
032:            public static final String CRITERIA_DISPLAYNAME_CONTAINS = "displayname_contains";
033:
034:            public static final String CRITERIA_EMAIL_CONTAINS = "email_contains";
035:
036:            private ResourceBundle bundle;
037:
038:            private int totalResultCount = 0;
039:
040:            private VirtualFolder virtualFolder;
041:
042:            public ContactSearchProvider() {
043:                bundle = ResourceBundle
044:                        .getBundle("org.columba.addressbook.i18n.search");
045:            }
046:
047:            public String getTechnicalName() {
048:                return "ContactSearchProvider";
049:            }
050:
051:            public String getName() {
052:                return bundle.getString("provider_title");
053:            }
054:
055:            public String getDescription() {
056:                return bundle.getString("provider_description");
057:            }
058:
059:            public ImageIcon getIcon() {
060:                return ImageLoader.getSmallIcon(IconKeys.ADDRESSBOOK);
061:            }
062:
063:            public List<ISearchCriteria> getAllCriteria(String searchTerm) {
064:
065:                List<ISearchCriteria> list = new Vector<ISearchCriteria>();
066:
067:                list.add(getCriteria(
068:                        ContactSearchProvider.CRITERIA_EMAIL_CONTAINS,
069:                        searchTerm));
070:                list.add(getCriteria(
071:                        ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS,
072:                        searchTerm));
073:                return list;
074:            }
075:
076:            public IResultPanel getResultPanel(
077:                    String searchCriteriaTechnicalName) {
078:                return new BasicResultPanel(getTechnicalName(),
079:                        searchCriteriaTechnicalName);
080:            }
081:
082:            public IResultPanel getComplexResultPanel() {
083:                return new ComplexResultPanel(getTechnicalName());
084:            }
085:
086:            public ISearchCriteria getCriteria(String technicalName,
087:                    String searchTerm) {
088:                String title = MessageFormat.format(bundle
089:                        .getString(technicalName + "_title"),
090:                        new Object[] { searchTerm });
091:                String name = bundle.getString(technicalName + "_name");
092:                String description = MessageFormat.format(bundle
093:                        .getString(technicalName + "_description"),
094:                        new Object[] { searchTerm });
095:
096:                return new SearchCriteria(technicalName, name, title,
097:                        description);
098:            }
099:
100:            public List<ISearchResult> query(String searchTerm,
101:                    String criteriaTechnicalName, boolean searchInside,
102:                    int startIndex, int resultCount) {
103:                if (searchTerm == null)
104:                    throw new IllegalArgumentException("searchTerm == null");
105:                if (criteriaTechnicalName == null)
106:                    throw new IllegalArgumentException(
107:                            "criteriaTechnicalName == null");
108:
109:                List<ISearchResult> result = new Vector<ISearchResult>();
110:
111:                // create list of contact folders
112:                List<AddressbookFolder> v = SearchUtility
113:                        .createContactFolderList();
114:
115:                virtualFolder = new VirtualFolder();
116:                Iterator<AddressbookFolder> it = v.iterator();
117:                while (it.hasNext()) {
118:                    AddressbookFolder f = it.next();
119:                    String id = null;
120:
121:                    if (criteriaTechnicalName
122:                            .equals(ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS)) {
123:                        id = f.findByName(searchTerm);
124:                    } else if (criteriaTechnicalName
125:                            .equals(ContactSearchProvider.CRITERIA_EMAIL_CONTAINS)) {
126:                        id = f.findByEmailAddress(searchTerm);
127:                    }
128:
129:                    if (id != null) {
130:                        IContactModel model = f.get(id);
131:
132:                        result.add(new ContactSearchResult(model
133:                                .getSortString(), model.getPreferredEmail(),
134:                                SearchResultBuilder.createURI(f.getId(), id),
135:                                model));
136:
137:                        // remember search result
138:                        virtualFolder.add(f, id);
139:                    }
140:
141:                }
142:
143:                totalResultCount = result.size();
144:
145:                return result;
146:            }
147:
148:            public List<ISearchResult> query(List<ISearchRequest> list,
149:                    boolean matchAll, boolean searchInside, int startIndex,
150:                    int resultCount) {
151:                Vector<ISearchResult> v = new Vector<ISearchResult>();
152:                Iterator<ISearchRequest> it = list.listIterator();
153:                while (it.hasNext()) {
154:                    ISearchRequest request = it.next();
155:
156:                    List<ISearchResult> result = query(request.getSearchTerm(),
157:                            request.getCriteria(), searchInside, startIndex,
158:                            resultCount);
159:
160:                    v.addAll(result);
161:                }
162:
163:                return v;
164:            }
165:
166:            public int getTotalResultCount() {
167:                return totalResultCount;
168:            }
169:
170:            public void showAllResults(IFrameMediator mediator,
171:                    String searchTerm, String searchCriteriaTechnicalName) {
172:
173:                // ensure that we are currently in the contact component
174:                IFrameMediator newMediator = null;
175:                try {
176:                    newMediator = FrameManager.getInstance().switchView(
177:                            mediator.getContainer(), "Addressbook");
178:                } catch (PluginLoadingFailedException e) {
179:                    e.printStackTrace();
180:                }
181:
182:                // update folder selection
183:                ((AddressbookFrameMediator) newMediator).getTree()
184:                        .setSelectedFolder(virtualFolder);
185:            }
186:
187:            public ICriteriaRenderer getCriteriaRenderer(
188:                    String criteriaTechnicalName) {
189:                ICriteriaRenderer r = null;
190:                if (criteriaTechnicalName
191:                        .equals(ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS)) {
192:                    r = new StringCriteriaRenderer(
193:                            getCriteria(
194:                                    ContactSearchProvider.CRITERIA_DISPLAYNAME_CONTAINS,
195:                                    ""), this );
196:                } else if (criteriaTechnicalName
197:                        .equals(ContactSearchProvider.CRITERIA_EMAIL_CONTAINS)) {
198:                    r = new StringCriteriaRenderer(getCriteria(
199:                            ContactSearchProvider.CRITERIA_EMAIL_CONTAINS, ""),
200:                            this );
201:                }
202:
203:                return r;
204:            }
205:
206:            public ISearchCriteria getDefaultCriteria(String searchTerm) {
207:                return getCriteria(
208:                        ContactSearchProvider.CRITERIA_EMAIL_CONTAINS,
209:                        searchTerm);
210:            }
211:
212:            public boolean hasSingleCriteriaSearchResult() {
213:                // doesn't support search inside yet
214:                return false;
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.