1 5 package org.exoplatform.portal.faces.component; 6 7 import java.util.List ; 8 import java.util.ResourceBundle ; 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 26 public class UIPage extends UIContainer { 27 final static public String DEFAULT_PAGE_RENDERER = "PageRowRenderer" ; 28 29 private Page componentModel_ ; 30 private UIPortlet maximizedPortlet_ ; 31 private boolean dirty_ ; 32 private String error_ = null ; 33 34 public UIPage() { 35 36 } 37 38 public UIPage(Page config, String defaultStyle) { 39 componentModel_ = config ; 40 initBasicComponent(config, defaultStyle) ; 41 List 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 getIdPrefix() { return "page" ; } 51 public String getFamily() { return "org.exoplatform.portal.faces.component.UIPage" ; } 52 protected String getSkinName() { return "default" ; } 53 54 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 getViewPermission() { return componentModel_.getViewPermission() ;} 68 public String getEditPermission() { return componentModel_.getEditPermission() ;} 69 public String getOwner() { return componentModel_.getOwner() ;} 70 71 public String getError() { return error_ ;} 72 public void setError(String error) { error_ = error ; } 73 74 public UIPortlet getMaximizedPortlet() { return maximizedPortlet_ ; } 75 public void setMaximizedPortlet(UIPortlet uiPortlet) { maximizedPortlet_ = uiPortlet ; } 76 77 protected String getDefaultRendererType() { return DEFAULT_PAGE_RENDERER ; } 78 79 protected Style getDecoratorStyle(SkinConfigService service, String renderer, String 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 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 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 res) { 106 String title = componentModel_.getTitle() ; 107 if(title == null) { 108 displayTitle_ = getId() ; 109 } else { 110 displayTitle_ = ExpressionUtil.getExpressionValue(res, componentModel_.getTitle()) ; 111 } 112 } 113 } | Popular Tags |