1 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 23 public class UISummary extends UISearcher { 24 private MessageIndexerPlugin plugin_ ; 25 26 public UISummary(IndexingService service, 27 UIMessages uiMessages) throws Exception { 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 { 36 Searcher searcher = plugin_.getSearcher() ; 37 return searcher ; 38 } 39 40 protected UIComponent customizeUIAdvancedSearch(IndexingService service) throws Exception { 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 { 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 { 57 this.setRenderedComponent(UIAdvancedSearch.class) ; 58 } 59 60 public void viewDocument(Document doc) throws Exception { 61 String 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 { 75 UIMessages uiMessages = 76 (UIMessages)getChildComponentOfType(UIMessages.class) ; 77 uiMessages.changeFolder(folder) ; 78 setRenderedComponent(UIMessages.class) ; 79 } 80 81 public void update() throws Exception { 82 UIMessages uiMessages = (UIMessages)getChildComponentOfType(UIMessages.class) ; 83 uiMessages.update() ; 84 } 85 } | Popular Tags |