KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > faces > component > UIPage


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.portal.faces.component;
6
7 import java.util.List JavaDoc;
8 import java.util.ResourceBundle JavaDoc;
9 import org.exoplatform.commons.utils.ExpressionUtil;
10 import org.exoplatform.portal.PortalConstants;
11 import org.exoplatform.portal.faces.listener.page.PageActionListener;
12 import org.exoplatform.services.portal.model.Component;
13 import org.exoplatform.services.portal.model.Container;
14 import org.exoplatform.services.portal.model.Page;
15 import org.exoplatform.services.portal.skin.SkinConfigService;
16 import org.exoplatform.services.portal.skin.model.Style;
17
18 /**
19  * Fri, May 30, 2003 @
20  * @author : Mestrallet Benjamin
21  * @email: benjmestrallet@users.sourceforge.net
22  * @author: Tuan Nguyen
23  * @email: tuan08@users.sourceforge.net
24  * @version: $Id: UIPage.java,v 1.6 2004/09/26 19:14:42 tuan08 Exp $
25  */

26 public class UIPage extends UIContainer {
27   final static public String JavaDoc DEFAULT_PAGE_RENDERER = "PageRowRenderer" ;
28   
29   private Page componentModel_ ;
30   private UIPortlet maximizedPortlet_ ;
31   private boolean dirty_ ;
32   private String JavaDoc error_ = null ;
33
34   public UIPage() {
35     
36   }
37   
38   public UIPage(Page config, String JavaDoc defaultStyle) {
39     componentModel_ = config ;
40     initBasicComponent(config, defaultStyle) ;
41     List JavaDoc childrenConfig = config.getChildren() ;
42     initChildren(childrenConfig, config.getPageId()) ;
43     registerListeners();
44   }
45   
46   private void registerListeners() {
47     addActionListener(PageActionListener.class, PortalConstants.SAVE_PAGE_ACTION) ;
48   }
49   
50   protected String JavaDoc getIdPrefix() { return "page" ; }
51   public String JavaDoc getFamily() { return "org.exoplatform.portal.faces.component.UIPage" ; }
52   protected String JavaDoc getSkinName() { return "default" ; }
53   
54   /**Override default setDirty in UIBasicComponent*/
55   public void setComponentDirty(boolean b) { dirty_ = b ; }
56   public boolean isDirty() { return dirty_ ; }
57   
58   public Component getComponentModel() { return componentModel_ ; }
59   public Page getPageModel() { return componentModel_ ; }
60   public Page getEditablePageModel() {
61     if(!modified_) {
62         componentModel_ = (Page)componentModel_.softCloneObject() ;
63     }
64     return componentModel_ ;
65   }
66   
67   public String JavaDoc getViewPermission() { return componentModel_.getViewPermission() ;}
68   public String JavaDoc getEditPermission() { return componentModel_.getEditPermission() ;}
69   public String JavaDoc getOwner() { return componentModel_.getOwner() ;}
70   
71   public String JavaDoc getError() { return error_ ;}
72   public void setError(String JavaDoc error) { error_ = error ; }
73   
74   public UIPortlet getMaximizedPortlet() { return maximizedPortlet_ ; }
75   public void setMaximizedPortlet(UIPortlet uiPortlet) { maximizedPortlet_ = uiPortlet ; }
76
77   protected String JavaDoc getDefaultRendererType() { return DEFAULT_PAGE_RENDERER ; }
78
79   protected Style getDecoratorStyle(SkinConfigService service, String JavaDoc renderer, String JavaDoc style) {
80     return service.getPageDecoratorStyle(renderer, style);
81   }
82   
83   public void setComponentMode(int mode) {
84     if(mode == UIBasicComponent.COMPONENT_EDIT_MODE && !hasComponentAdminRole()) {
85       mode = UIBasicComponent.COMPONENT_VIEW_MODE ;
86     }
87     mode_ = mode ;
88     List JavaDoc children = getChildren() ;
89     for(int i = 0; i < children.size(); i++) {
90       UIBasicComponent uiChild = (UIBasicComponent) children.get(i) ;
91       uiChild.setComponentMode(mode) ;
92     }
93   }
94   
95   public void buildTreeModel(Container parent) {
96     componentModel_.getChildren().clear() ;
97     List JavaDoc uichildren = getChildren() ;
98     for(int i = 0; i < uichildren.size(); i++) {
99         UIBasicComponent uiChild =(UIBasicComponent) uichildren.get(i) ;
100         uiChild.buildTreeModel(componentModel_) ;
101     }
102     if(parent != null) parent.getChildren().add(componentModel_) ;
103   }
104   
105   public void changeLocale(ResourceBundle JavaDoc res) {
106     String JavaDoc title = componentModel_.getTitle() ;
107     if(title == null) {
108       displayTitle_ = getId() ;
109     } else {
110       displayTitle_ = ExpressionUtil.getExpressionValue(res, componentModel_.getTitle()) ;
111     }
112   }
113 }
Popular Tags