001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Jean-Marc Orliaguet, Chalmers 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.theme.rendering; 016 017import java.net.URL; 018 019import org.nuxeo.theme.Manager; 020import org.nuxeo.theme.elements.Element; 021import org.nuxeo.theme.elements.ThemeElement; 022import org.nuxeo.theme.engines.EngineType; 023import org.nuxeo.theme.formats.Format; 024import org.nuxeo.theme.models.Info; 025import org.nuxeo.theme.models.Model; 026import org.nuxeo.theme.templates.TemplateEngineType; 027import org.nuxeo.theme.themes.ThemeManager; 028import org.nuxeo.theme.uids.Identifiable; 029 030public class RenderingInfo implements Info, Identifiable { 031 032 private String markup = ""; 033 034 private Model model; 035 036 private Element element; 037 038 private Format format; 039 040 private Integer uid; 041 042 private String name; 043 044 private URL themeUrl; 045 046 private boolean dirty = false; 047 048 public RenderingInfo() { 049 } 050 051 public RenderingInfo(Element element, URL themeUrl) { 052 this.element = element; 053 this.themeUrl = themeUrl; 054 uid = element.getUid(); 055 } 056 057 public RenderingInfo createCopy() { 058 RenderingInfo clone = new RenderingInfo(element, themeUrl); 059 clone.setDirty(dirty); 060 return clone; 061 } 062 063 public Model getModel() { 064 return model; 065 } 066 067 public void setModel(Model model) { 068 this.model = model; 069 } 070 071 public String getMarkup() { 072 return markup; 073 } 074 075 public void setMarkup(String markup) { 076 this.markup = markup; 077 } 078 079 public Integer getUid() { 080 return uid; 081 } 082 083 public void setUid(Integer uid) { 084 this.uid = uid; 085 } 086 087 public EngineType getEngine() { 088 return ThemeManager.getEngineByUrl(themeUrl); 089 } 090 091 public String getViewMode() { 092 return ThemeManager.getViewModeByUrl(themeUrl); 093 } 094 095 public String getCollection() { 096 return ThemeManager.getCollectionNameByUrl(themeUrl); 097 } 098 099 public URL getThemeUrl() { 100 return themeUrl; 101 } 102 103 public Element getElement() { 104 return element; 105 } 106 107 public void setFormat(Format format) { 108 this.format = format; 109 } 110 111 public Format getFormat() { 112 return format; 113 } 114 115 public boolean isDirty() { 116 return dirty; 117 } 118 119 public void setDirty(boolean dirty) { 120 this.dirty = dirty; 121 } 122 123 public String getName() { 124 return name; 125 } 126 127 public void setName(String name) { 128 this.name = name; 129 } 130 131 public ThemeElement getTheme() { 132 return Manager.getThemeManager().getThemeByUrl(themeUrl); 133 } 134 135 public TemplateEngineType getTemplateEngine() { 136 return ThemeManager.getTemplateEngineByUrl(themeUrl); 137 } 138 139 public boolean isRenderingPostponed(boolean cache) { 140 return cache && isDirty(); 141 } 142 143}