001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.core.admin.ui;
023:
024: import org.jboss.portal.core.model.portal.PortalObject;
025: import org.jboss.portal.theme.ThemeConstants;
026:
027: import javax.faces.application.FacesMessage;
028: import javax.faces.context.FacesContext;
029: import javax.faces.event.AbortProcessingException;
030: import javax.faces.event.ActionEvent;
031:
032: /**
033: * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
034: * @version $Revision: 8785 $
035: */
036: public class ThemeBean {
037:
038: /** . */
039: private final PortalObject portalObject;
040:
041: /** . */
042: private String layoutName;
043:
044: /** . */
045: private String themeName;
046:
047: /** . */
048: private String renderSetName;
049:
050: /** . */
051: private String windowRendererName;
052:
053: /** . */
054: private String decorationRendererName;
055:
056: /** . */
057: private String portletRendererName;
058:
059: public ThemeBean(PortalObject portalObject) {
060: this .portalObject = portalObject;
061: this .layoutName = portalObject
062: .getDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
063: this .themeName = portalObject
064: .getDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME);
065: this .renderSetName = portalObject
066: .getDeclaredProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
067: this .windowRendererName = portalObject
068: .getDeclaredProperty(ThemeConstants.PORTAL_PROP_WINDOW_RENDERER);
069: this .decorationRendererName = portalObject
070: .getDeclaredProperty(ThemeConstants.PORTAL_PROP_DECORATION_RENDERER);
071: this .portletRendererName = portalObject
072: .getDeclaredProperty(ThemeConstants.PORTAL_PROP_PORTLET_RENDERER);
073: }
074:
075: public PortalObject getPortalObject() {
076: return portalObject;
077: }
078:
079: public String getLayoutName() {
080: return layoutName;
081: }
082:
083: public void setLayoutName(String layoutName) {
084: this .layoutName = "".equals(layoutName) ? null : layoutName;
085: }
086:
087: public String getThemeName() {
088: return themeName;
089: }
090:
091: public void setThemeName(String themeName) {
092: this .themeName = "".equals(themeName) ? null : themeName;
093: }
094:
095: public String getRenderSetName() {
096: return renderSetName;
097: }
098:
099: public void setRenderSetName(String renderSetName) {
100: this .renderSetName = "".equals(renderSetName) ? null
101: : renderSetName;
102: }
103:
104: public String getWindowRendererName() {
105: return windowRendererName;
106: }
107:
108: public void setWindowRendererName(String windowRendererName) {
109: this .windowRendererName = "".equals(windowRendererName) ? null
110: : windowRendererName;
111: }
112:
113: public String getDecorationRendererName() {
114: return decorationRendererName;
115: }
116:
117: public void setDecorationRendererName(String decorationRendererName) {
118: this .decorationRendererName = "".equals(decorationRendererName) ? null
119: : decorationRendererName;
120: }
121:
122: public String getPortletRendererName() {
123: return portletRendererName;
124: }
125:
126: public void setPortletRendererName(String portletRendererName) {
127: this .portletRendererName = "".equals(portletRendererName) ? null
128: : portletRendererName;
129: }
130:
131: public void execute(ActionEvent actionEvent)
132: throws AbortProcessingException {
133: boolean successful = true;
134:
135: //
136: switch (portalObject.getType()) {
137: case PortalObject.TYPE_CONTEXT:
138: case PortalObject.TYPE_PORTAL:
139: case PortalObject.TYPE_PAGE:
140: portalObject.setDeclaredProperty(
141: ThemeConstants.PORTAL_PROP_LAYOUT, this .layoutName);
142: portalObject.setDeclaredProperty(
143: ThemeConstants.PORTAL_PROP_THEME, this .themeName);
144: portalObject.setDeclaredProperty(
145: ThemeConstants.PORTAL_PROP_RENDERSET,
146: this .renderSetName);
147: break;
148: case PortalObject.TYPE_WINDOW:
149: portalObject.setDeclaredProperty(
150: ThemeConstants.PORTAL_PROP_WINDOW_RENDERER,
151: this .windowRendererName);
152: portalObject.setDeclaredProperty(
153: ThemeConstants.PORTAL_PROP_DECORATION_RENDERER,
154: this .decorationRendererName);
155: portalObject.setDeclaredProperty(
156: ThemeConstants.PORTAL_PROP_PORTLET_RENDERER,
157: this .portletRendererName);
158: break;
159: default:
160: successful = false;
161: }
162:
163: //
164: if (successful) {
165: String stringMessage = null;
166: switch (this .portalObject.getType()) {
167: case PortalObject.TYPE_PORTAL:
168: stringMessage = "Theme has been correctly updated on the portal named: "
169: + portalObject.getName();
170: break;
171: case PortalObject.TYPE_PAGE:
172: stringMessage = "Theme has been correctly updated on the page named: "
173: + portalObject.getName();
174: break;
175: case PortalObject.TYPE_WINDOW:
176: stringMessage = "Theme has been correctly updated on the window named: "
177: + portalObject.getName();
178: break;
179: }
180:
181: //
182: if (stringMessage != null) {
183: FacesMessage message = new FacesMessage(
184: FacesMessage.SEVERITY_INFO, stringMessage,
185: stringMessage);
186: FacesContext.getCurrentInstance().addMessage("status",
187: message);
188: }
189: } else {
190: String stringMessage = "Unknown object type, please file a Jira issue: http://jira.jboss.org";
191: FacesMessage message = new FacesMessage(
192: FacesMessage.SEVERITY_ERROR, stringMessage,
193: stringMessage);
194: FacesContext.getCurrentInstance().addMessage("error",
195: message);
196: }
197: }
198: }
|