Source Code Cross Referenced for CalendarSearchProvider.java in  » Mail-Clients » columba-1.4 » org » columba » calendar » 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.calendar.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.columba.calendar.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.api.gui.frame.IFrameMediator;
012:        import org.columba.calendar.model.api.IComponent;
013:        import org.columba.calendar.model.api.IComponentInfo;
014:        import org.columba.calendar.model.api.IEventInfo;
015:        import org.columba.calendar.model.api.ITodoInfo;
016:        import org.columba.calendar.store.CalendarStoreFactory;
017:        import org.columba.calendar.store.api.ICalendarStore;
018:        import org.columba.calendar.ui.search.BasicResultPanel;
019:        import org.columba.core.gui.search.StringCriteriaRenderer;
020:        import org.columba.core.gui.search.api.ICriteriaRenderer;
021:        import org.columba.core.gui.search.api.IResultPanel;
022:        import org.columba.core.resourceloader.IconKeys;
023:        import org.columba.core.resourceloader.ImageLoader;
024:        import org.columba.core.search.SearchCriteria;
025:        import org.columba.core.search.api.ISearchCriteria;
026:        import org.columba.core.search.api.ISearchProvider;
027:        import org.columba.core.search.api.ISearchRequest;
028:        import org.columba.core.search.api.ISearchResult;
029:
030:        public class CalendarSearchProvider implements  ISearchProvider {
031:
032:            public static final String CRITERIA_SUMMARY_CONTAINS = "summary_contains";
033:
034:            private ResourceBundle bundle;
035:
036:            private int totalResultCount = 0;
037:
038:            public CalendarSearchProvider() {
039:                bundle = ResourceBundle
040:                        .getBundle("org.columba.calendar.i18n.search");
041:            }
042:
043:            public String getTechnicalName() {
044:                return "CalendarSearchProvider";
045:            }
046:
047:            public String getName() {
048:                return bundle.getString("provider_title");
049:            }
050:
051:            public String getDescription() {
052:                return bundle.getString("provider_description");
053:            }
054:
055:            public ImageIcon getIcon() {
056:                return ImageLoader.getSmallIcon(IconKeys.CALENDAR);
057:            }
058:
059:            public List<ISearchCriteria> getAllCriteria(String searchTerm) {
060:                List<ISearchCriteria> list = new Vector<ISearchCriteria>();
061:
062:                list.add(getCriteria(
063:                        CalendarSearchProvider.CRITERIA_SUMMARY_CONTAINS,
064:                        searchTerm));
065:
066:                return list;
067:            }
068:
069:            public IResultPanel getComplexResultPanel() {
070:                return new ComplexResultPanel(getTechnicalName());
071:            }
072:
073:            public ISearchCriteria getCriteria(String technicalName,
074:                    String searchTerm) {
075:                String title = MessageFormat.format(bundle
076:                        .getString(technicalName + "_title"),
077:                        new Object[] { searchTerm });
078:                String name = bundle.getString(technicalName + "_name");
079:                String description = MessageFormat.format(bundle
080:                        .getString(technicalName + "_description"),
081:                        new Object[] { searchTerm });
082:
083:                return new SearchCriteria(technicalName, name, title,
084:                        description);
085:            }
086:
087:            public ICriteriaRenderer getCriteriaRenderer(
088:                    String criteriaTechnicalName) {
089:                ICriteriaRenderer r = null;
090:                if (criteriaTechnicalName
091:                        .equals(CalendarSearchProvider.CRITERIA_SUMMARY_CONTAINS)) {
092:                    r = new StringCriteriaRenderer(getCriteria(
093:                            CalendarSearchProvider.CRITERIA_SUMMARY_CONTAINS,
094:                            ""), this );
095:                }
096:
097:                return r;
098:            }
099:
100:            public ISearchCriteria getDefaultCriteria(String searchTerm) {
101:                return getCriteria(
102:                        CalendarSearchProvider.CRITERIA_SUMMARY_CONTAINS,
103:                        searchTerm);
104:            }
105:
106:            public IResultPanel getResultPanel(
107:                    String searchCriteriaTechnicalName) {
108:                return new BasicResultPanel(getTechnicalName(),
109:                        searchCriteriaTechnicalName);
110:            }
111:
112:            public int getTotalResultCount() {
113:                return totalResultCount;
114:            }
115:
116:            public boolean hasSingleCriteriaSearchResult() {
117:                throw new IllegalArgumentException("not implemented yet");
118:            }
119:
120:            public List<ISearchResult> query(String searchTerm,
121:                    String searchCriteriaTechnicalName, boolean searchInside,
122:                    int startIndex, int resultCount) {
123:
124:                if (searchTerm == null)
125:                    throw new IllegalArgumentException("searchTerm == null");
126:                if (searchCriteriaTechnicalName == null)
127:                    throw new IllegalArgumentException(
128:                            "searchCriteriaTechnicalName == null");
129:
130:                List<ISearchResult> result = new Vector<ISearchResult>();
131:
132:                ICalendarStore store = CalendarStoreFactory.getInstance()
133:                        .getLocaleStore();
134:
135:                if (searchCriteriaTechnicalName
136:                        .equals(CalendarSearchProvider.CRITERIA_SUMMARY_CONTAINS)) {
137:
138:                    Iterator<String> it = store.findBySummary(searchTerm);
139:                    while (it.hasNext()) {
140:                        String id = it.next();
141:                        IComponentInfo c = store.get(id);
142:
143:                        if (c.getType().equals(IComponent.TYPE.EVENT)) {
144:                            IEventInfo event = (IEventInfo) c;
145:
146:                            result.add(new CalendarSearchResult(event
147:                                    .getEvent().getSummary(), event.getEvent()
148:                                    .getLocation(), SearchResultBuilder
149:                                    .createURI(event.getCalendar(), event
150:                                            .getId()), c.getComponent()));
151:                        } else if (c.getType().equals(IComponent.TYPE.TODO)) {
152:                            ITodoInfo todo = (ITodoInfo) c;
153:
154:                            result.add(new CalendarSearchResult(todo.getTodo()
155:                                    .getSummary(), todo.getTodo()
156:                                    .getDescription(),
157:                                    SearchResultBuilder.createURI(todo
158:                                            .getCalendar(), todo.getId()), c
159:                                            .getComponent()));
160:                        } else
161:                            throw new IllegalArgumentException(
162:                                    "unsupported component type " + c.getType());
163:
164:                    }
165:                }
166:
167:                return result;
168:            }
169:
170:            public List<ISearchResult> query(List<ISearchRequest> list,
171:                    boolean matchAll, boolean searchInside, int startIndex,
172:                    int resultCount) {
173:                Vector<ISearchResult> v = new Vector<ISearchResult>();
174:                Iterator<ISearchRequest> it = list.listIterator();
175:                while (it.hasNext()) {
176:                    ISearchRequest request = it.next();
177:
178:                    List<ISearchResult> result = query(request.getSearchTerm(),
179:                            request.getCriteria(), searchInside, startIndex,
180:                            resultCount);
181:
182:                    v.addAll(result);
183:                }
184:
185:                return v;
186:
187:            }
188:
189:            public void showAllResults(IFrameMediator mediator,
190:                    String searchTerm, String searchCriteriaTechnicalName) {
191:                throw new IllegalArgumentException("not implemented yet");
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.