KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > search > CriteriaResultPanel


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.mail.gui.search;
19
20 import java.text.MessageFormat JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23 import java.util.ResourceBundle JavaDoc;
24
25 import javax.swing.ImageIcon JavaDoc;
26 import javax.swing.JComponent JavaDoc;
27
28 import org.columba.core.gui.search.api.IResultPanel;
29 import org.columba.core.search.api.IResultEvent;
30 import org.columba.core.search.api.ISearchResult;
31 import org.columba.mail.resourceloader.IconKeys;
32 import org.columba.mail.resourceloader.MailImageLoader;
33
34 public class CriteriaResultPanel implements IResultPanel {
35
36     private ResourceBundle JavaDoc bundle;
37
38     private String JavaDoc providerTechnicalName;
39
40     private String JavaDoc criteriaTechnicalName;
41
42     private ResultList list;
43
44     public CriteriaResultPanel(String JavaDoc providerTechnicalName,
45             String JavaDoc criteriaTechnicalName) {
46         super();
47
48         this.criteriaTechnicalName = criteriaTechnicalName;
49         this.providerTechnicalName = providerTechnicalName;
50
51         bundle = ResourceBundle.getBundle("org.columba.mail.i18n.search");
52
53         list = new ResultList();
54
55     }
56
57     public String JavaDoc getSearchCriteriaTechnicalName() {
58         return criteriaTechnicalName;
59     }
60
61     public String JavaDoc getProviderTechnicalName() {
62         return providerTechnicalName;
63     }
64
65     public JComponent JavaDoc getView() {
66         return list;
67     }
68
69     public ImageIcon JavaDoc getIcon() {
70         return MailImageLoader.getSmallIcon(IconKeys.MESSAGE_READ);
71     }
72
73     public String JavaDoc getTitle(String JavaDoc searchTerm) {
74         String JavaDoc result = MessageFormat.format(bundle
75                 .getString(criteriaTechnicalName + "_title"),
76                 new Object JavaDoc[] { searchTerm });
77         return result;
78     }
79
80     public String JavaDoc getDescription(String JavaDoc searchTerm) {
81         String JavaDoc result = MessageFormat.format(bundle
82                 .getString(criteriaTechnicalName + "_description"),
83                 new Object JavaDoc[] { searchTerm });
84         return result;
85     }
86
87     public void resultArrived(IResultEvent event) {
88         if (!event.getProviderName().equals(this.providerTechnicalName))
89             return;
90         if (!event.getSearchCriteria().getTechnicalName().equals(
91                 this.criteriaTechnicalName))
92             return;
93
94         List JavaDoc<ISearchResult> result = event.getSearchResults();
95
96         Iterator JavaDoc<ISearchResult> it = result.iterator();
97         while (it.hasNext()) {
98             list.add(it.next());
99         }
100
101         list.revalidate();
102     }
103
104     public void clearSearch(IResultEvent event) {
105
106     }
107
108     public void reset(IResultEvent event) {
109         list.clear();
110     }
111
112     public void finished(IResultEvent event) {
113     }
114
115 }
116
Popular Tags