001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.mail.gui.search;
019:
020: import java.text.MessageFormat;
021: import java.util.Iterator;
022: import java.util.List;
023: import java.util.ResourceBundle;
024:
025: import javax.swing.ImageIcon;
026: import javax.swing.JComponent;
027:
028: import org.columba.core.gui.search.api.IResultPanel;
029: import org.columba.core.search.api.IResultEvent;
030: import org.columba.core.search.api.ISearchResult;
031: import org.columba.mail.resourceloader.IconKeys;
032: import org.columba.mail.resourceloader.MailImageLoader;
033:
034: public class CriteriaResultPanel implements IResultPanel {
035:
036: private ResourceBundle bundle;
037:
038: private String providerTechnicalName;
039:
040: private String criteriaTechnicalName;
041:
042: private ResultList list;
043:
044: public CriteriaResultPanel(String providerTechnicalName,
045: String criteriaTechnicalName) {
046: super ();
047:
048: this .criteriaTechnicalName = criteriaTechnicalName;
049: this .providerTechnicalName = providerTechnicalName;
050:
051: bundle = ResourceBundle
052: .getBundle("org.columba.mail.i18n.search");
053:
054: list = new ResultList();
055:
056: }
057:
058: public String getSearchCriteriaTechnicalName() {
059: return criteriaTechnicalName;
060: }
061:
062: public String getProviderTechnicalName() {
063: return providerTechnicalName;
064: }
065:
066: public JComponent getView() {
067: return list;
068: }
069:
070: public ImageIcon getIcon() {
071: return MailImageLoader.getSmallIcon(IconKeys.MESSAGE_READ);
072: }
073:
074: public String getTitle(String searchTerm) {
075: String result = MessageFormat.format(bundle
076: .getString(criteriaTechnicalName + "_title"),
077: new Object[] { searchTerm });
078: return result;
079: }
080:
081: public String getDescription(String searchTerm) {
082: String result = MessageFormat.format(bundle
083: .getString(criteriaTechnicalName + "_description"),
084: new Object[] { searchTerm });
085: return result;
086: }
087:
088: public void resultArrived(IResultEvent event) {
089: if (!event.getProviderName().equals(this .providerTechnicalName))
090: return;
091: if (!event.getSearchCriteria().getTechnicalName().equals(
092: this .criteriaTechnicalName))
093: return;
094:
095: List<ISearchResult> result = event.getSearchResults();
096:
097: Iterator<ISearchResult> it = result.iterator();
098: while (it.hasNext()) {
099: list.add(it.next());
100: }
101:
102: list.revalidate();
103: }
104:
105: public void clearSearch(IResultEvent event) {
106:
107: }
108:
109: public void reset(IResultEvent event) {
110: list.clear();
111: }
112:
113: public void finished(IResultEvent event) {
114: }
115:
116: }
|