KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > wsrp > component > UIOfferedPortlet


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.wsrp.component;
6
7 import java.util.* ;
8 import javax.faces.context.FacesContext ;
9
10 import org.apache.commons.logging.Log;
11 import org.exoplatform.faces.FacesConstants;
12 import org.exoplatform.faces.core.component.*;
13 import org.exoplatform.faces.core.component.model.*;
14 import org.exoplatform.services.wsrp.type.*;
15
16 /**
17  * @email: tuan08@users.sourceforge.net
18  * @version: $Id: UIOfferedPortlet.java,v 1.9 2004/06/30 19:54:42 tuan08 Exp $
19  */

20 public class UIOfferedPortlet extends UIGrid implements Node{
21   protected static Log log_ = getLog("org.exoplatform.portlets.wsrp") ;
22   private static Parameter[] backParams_ =
23       { new Parameter(FacesConstants.ACTION, "back") };
24   
25   private Cell portletHandle_ ;
26   private Cell groupId_ ;
27   private Cell title_ ;
28   private Cell shortTitle_ ;
29   private Cell displayName_ ;
30   private Cell keywords_ ;
31   private Cell markupTypes_ ;
32   private Cell userCategories_ ;
33   private Cell userProfileItems_ ;
34   private Cell usesMethodGet_ ;
35   private Cell defaultMarkupSecure_ ;
36   private Cell onlySecure_ ;
37   private Cell userContextStoredInSession_ ;
38   private Cell templatesStoredInSession_ ;
39   private Cell hasUserSpecificState_ ;
40   private Cell doesUrlTemplateProcessing_ ;
41   private Cell extensions_ ;
42    
43   public UIOfferedPortlet(ResourceBundle res) {
44     setId("offered-portlet-detail");
45
46     portletHandle_ = new Cell("") ;
47     groupId_ = new Cell("") ;
48     title_ = new Cell("") ;
49     shortTitle_ = new Cell("") ;
50     displayName_ = new Cell("") ;
51     keywords_ = new Cell("") ;
52     markupTypes_ = new Cell("") ;
53     userCategories_ = new Cell("") ;
54     userProfileItems_ = new Cell("") ;
55     usesMethodGet_ = new Cell("") ;
56     defaultMarkupSecure_ = new Cell("") ;
57     onlySecure_ = new Cell("") ;
58     userContextStoredInSession_ = new Cell("") ;
59     templatesStoredInSession_ = new Cell("") ;
60     hasUserSpecificState_ = new Cell("") ;
61     doesUrlTemplateProcessing_ = new Cell("") ;
62     extensions_ = new Cell("") ;
63    
64     String JavaDoc backButton = "#{UIOfferedPortlet.button.back}" ;
65     setClazz("UIOfferedPortlet") ;
66     add(new HeaderRow().
67         add(new Cell("#{UIOfferedPortlet.header.offered-portlet-detail}").
68             addHeight("30").addColspan("2"))) ;
69     add(new Row().
70         add(new LabelCell("#{UIOfferedPortlet.label.portlet-handle}")).
71         add(portletHandle_));
72     add(new Row().
73         add(new LabelCell("#{UIOfferedPortlet.label.group-id}")).
74         add(groupId_));
75     add(new Row().
76         add(new LabelCell("#{UIOfferedPortlet.label.title}")).
77         add(title_));
78     add(new Row().
79         add(new LabelCell("#{UIOfferedPortlet.label.short-title}")).
80         add(shortTitle_));
81     add(new Row().
82         add(new LabelCell("#{UIOfferedPortlet.label.display-name}")).
83         add(displayName_));
84     add(new Row().
85         add(new LabelCell("#{UIOfferedPortlet.label.keywords}")).
86         add(keywords_));
87     add(new Row().
88         add(new LabelCell("#{UIOfferedPortlet.label.markup-types}")).
89         add(markupTypes_));
90     add(new Row().
91         add(new LabelCell("#{UIOfferedPortlet.label.user-categories}")).
92         add(userCategories_));
93     add(new Row().
94         add(new LabelCell("#{UIOfferedPortlet.label.user-profile-items}")).
95         add(userProfileItems_));
96     add(new Row().
97         add(new LabelCell("#{UIOfferedPortlet.label.uses-method-get}")).
98         add(usesMethodGet_));
99     add(new Row().
100         add(new LabelCell("#{UIOfferedPortlet.label.default-markup-secure}")).
101         add(defaultMarkupSecure_));
102     add(new Row().
103         add(new LabelCell("#{UIOfferedPortlet.label.only-secure}")).
104         add(onlySecure_));
105     add(new Row().
106         add(new LabelCell("#{UIOfferedPortlet.label.user-context-stored-in-session}")).
107         add(userContextStoredInSession_));
108     add(new Row().
109         add(new LabelCell("#{UIOfferedPortlet.label.templates-stored-in-session}")).
110         add(templatesStoredInSession_));
111     add(new Row().
112         add(new LabelCell("#{UIOfferedPortlet.label.user-specific-state}")).
113         add(hasUserSpecificState_));
114     add(new Row().
115         add(new LabelCell("#{UIOfferedPortlet.label.url-template-processing}")).
116         add(doesUrlTemplateProcessing_));
117     add(new Row().
118         add(new LabelCell("#{UIOfferedPortlet.label.extensions}")).
119         add(extensions_));
120   }
121   
122   public void populate(PortletDescription desc) {
123     StringBuffer JavaDoc value = new StringBuffer JavaDoc() ;
124     portletHandle_.setValue(desc.getPortletHandle()) ;
125     groupId_.setValue(desc.getGroupID()) ;
126     title_.setValue(getValue(desc.getTitle())) ;
127     shortTitle_.setValue(getValue(desc.getShortTitle())) ;
128     displayName_.setValue(getValue(desc.getDisplayName())) ;
129     
130     LocalizedString[] keywords = desc.getKeywords() ;
131     if(keywords != null){
132       for (int i = 0; i < keywords.length; i++) {
133         value.append(getValue(keywords[i])).append(" ");
134       }
135     }
136     keywords_.setValue(value.toString()) ;
137     
138     MarkupType[] types = desc.getMarkupTypes() ;
139     value.setLength(0) ;
140     for (int i = 0; i < types.length; i++) {
141       value.append(types[i].getMimeType()).append(" ");
142     }
143     markupTypes_.setValue(value.toString()) ;
144
145     String JavaDoc[] userCategories = desc.getUserCategories() ;
146     if( userCategories != null) {
147       value.setLength(0) ;
148       for (int i = 0; i < userCategories.length; i++) {
149         value.append(userCategories[i]).append(" ");
150       }
151       userCategories_.setValue(value.toString()) ;
152     } else {
153       userCategories_.setValue("") ;
154     }
155     
156     String JavaDoc[] userProfileItems = desc.getUserProfileItems() ;
157     if( userProfileItems != null) {
158       value.setLength(0) ;
159       for (int i = 0; i < userProfileItems.length; i++) {
160         value.append(userProfileItems[i]).append(" ");
161       }
162       userProfileItems_.setValue(value.toString()) ;
163     } else {
164       userProfileItems_.setValue("") ;
165     }
166
167     usesMethodGet_.setValue(desc.getUsesMethodGet().toString()) ;
168     if(desc.getDefaultMarkupSecure() != null)
169       defaultMarkupSecure_.setValue(desc.getDefaultMarkupSecure().toString()) ;
170     if(desc.getOnlySecure() != null)
171       onlySecure_.setValue(desc.getOnlySecure().toString()) ;
172     if(desc.getUserContextStoredInSession() != null)
173       userContextStoredInSession_.setValue(desc.getUserContextStoredInSession().toString());
174     if(desc.getTemplatesStoredInSession() != null)
175       templatesStoredInSession_.setValue(desc.getTemplatesStoredInSession().toString()) ;
176     if(desc.getHasUserSpecificState() != null)
177       hasUserSpecificState_.setValue(desc.getHasUserSpecificState().toString()) ;
178     if(desc.getDoesUrlTemplateProcessing() != null)
179       doesUrlTemplateProcessing_.setValue(desc.getDoesUrlTemplateProcessing().toString()) ;
180
181     extensions_.setValue("N/A") ;
182   }
183   
184   public String JavaDoc getComponentType() { return COMPONENT_TYPE; }
185
186   private String JavaDoc getValue(LocalizedString s) {
187     if (s == null) return "" ;
188     else return s.getValue() ;
189   }
190
191   public String JavaDoc getName() {
192     return "";
193   }
194
195   public String JavaDoc getIcon() {
196     return "no-icon";
197   }
198
199   public String JavaDoc getDescription() {
200     return "no-description";
201   }
202
203 }
204
Popular Tags