KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > communication > message > component > UISummary


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.communication.message.component;
6
7 import java.util.* ;
8 import javax.faces.component.UIComponent;
9 import org.apache.lucene.document.Document;
10 import org.exoplatform.container.PortalContainer;
11 import org.exoplatform.faces.core.component.model.SelectItem;
12 import org.exoplatform.faces.search.component.UISearchBar;
13 import org.exoplatform.faces.search.component.UISearcher;
14 import org.exoplatform.services.communication.message.*;
15 import org.exoplatform.services.indexing.IndexingService;
16 import org.exoplatform.services.indexing.Searcher;
17
18 /**
19  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
20  * @since Aug 27, 2004
21  * @version $Id: UISummary.java,v 1.4 2004/10/30 02:22:19 tuan08 Exp $
22  */

23 public class UISummary extends UISearcher {
24   private MessageIndexerPlugin plugin_ ;
25  
26   public UISummary(IndexingService service,
27                    UIMessages uiMessages) throws Exception JavaDoc {
28     super(service) ;
29     setId("UISearcher") ;
30     plugin_ = (MessageIndexerPlugin)service.getIndexerPlugin(MessageIndexerPlugin.IDENTIFIER) ;
31     getChildren().add(uiMessages) ;
32     this.setRenderedComponent(UIMessages.class) ;
33   }
34   
35   public Searcher getSearcher() throws Exception JavaDoc {
36     Searcher searcher = plugin_.getSearcher() ;
37     return searcher ;
38   }
39   
40   protected UIComponent customizeUIAdvancedSearch(IndexingService service) throws Exception JavaDoc {
41     MessageService mservice =
42       (MessageService) PortalContainer.getInstance().getComponentInstanceOfType(MessageService.class) ;
43     return new UIAdvancedSearch(mservice, service);
44   }
45   
46   protected UIComponent customizeUISearchBar(IndexingService service) throws Exception JavaDoc {
47     UISearchBar uiBar = new UISearchBar();
48     List options = new ArrayList() ;
49     options.add(new SelectItem("Search All", ""));
50     options.add(new SelectItem("By Subject", MessageIndexerPlugin.SUBJECT_FIELD));
51     options.add(new SelectItem("Message Body", MessageIndexerPlugin.BODY_FIELD));
52     uiBar.setSearchOptions(options) ;
53     return uiBar ;
54   }
55   
56   public void showAdvancedSearch() throws Exception JavaDoc {
57     this.setRenderedComponent(UIAdvancedSearch.class) ;
58   }
59   
60   public void viewDocument(Document doc) throws Exception JavaDoc {
61     String JavaDoc massageId = doc.getField(IndexingService.IDENTIFIER_FIELD).stringValue() ;
62     Message message = (Message)plugin_.getObject(null, massageId);
63     UIViewMessage uiView = (UIViewMessage) getSibling(UIViewMessage.class) ;
64     uiView.setMessage(message) ;
65     setRenderedSibling(UIViewMessage.class) ;
66   }
67   
68   public void changeAccount(UIAccount uiAccount) {
69     UIAdvancedSearch uiASearch =
70       (UIAdvancedSearch) getChildComponentOfType(UIAdvancedSearch.class);
71     uiASearch.changeAccount(uiAccount) ;
72   }
73   
74   public void changeFolder(Folder folder) throws Exception JavaDoc {
75     UIMessages uiMessages =
76       (UIMessages)getChildComponentOfType(UIMessages.class) ;
77     uiMessages.changeFolder(folder) ;
78     setRenderedComponent(UIMessages.class) ;
79   }
80   
81   public void update() throws Exception JavaDoc {
82     UIMessages uiMessages = (UIMessages)getChildComponentOfType(UIMessages.class) ;
83     uiMessages.update() ;
84   }
85 }
Popular Tags