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.theme.page;
023:
024: import org.jboss.portal.Mode;
025: import org.jboss.portal.WindowState;
026: import org.jboss.portal.theme.render.renderer.ActionRendererContext;
027:
028: import java.util.Collection;
029: import java.util.Collections;
030: import java.util.Map;
031:
032: /**
033: * The window result represent the generated content of a window. It contains several kind of data : <li> <ul>the window
034: * title</ul> <ul>the window content</ul> <ul>a map of actions available for the window</ul> </li>
035: *
036: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
037: * @version $Revision: 8784 $
038: */
039: public class WindowResult {
040:
041: /** . */
042: private String title;
043:
044: /** . */
045: private String content;
046:
047: /** . */
048: private Map actions;
049:
050: /** . */
051: private final String headerContent;
052:
053: /** . */
054: private Map properties;
055:
056: /** . */
057: private final WindowState windowState;
058:
059: /** . */
060: private final Mode mode;
061:
062: /**
063: * Create a new WindowResult with the information about the renderered portlet. <p>A window result contains the the
064: * rendered markup fragment of the portlet, the title, a map of action urls to trigger mode and state changes, and
065: * the properties that were set as portlet response properties.</p>
066: *
067: * @param title the title to be displayed for this portlet in the rendered page
068: * @param content the rendered markup fragment of the portlet
069: * @param actions a map of actions possible for this portlet
070: * @param windowProperties the properties for this window
071: * @param headerChars content that needs to be injected into the header
072: * @see WindowResult.Action
073: */
074: public WindowResult(String title, String content, Map actions,
075: Map windowProperties, String headerChars,
076: WindowState windowState, Mode mode) {
077: this .title = title;
078: this .content = content;
079: this .actions = actions;
080: this .headerContent = headerChars;
081: this .properties = windowProperties;
082: this .windowState = windowState;
083: this .mode = mode;
084: }
085:
086: public String getTitle() {
087: return title;
088: }
089:
090: public String getContent() {
091: return content;
092: }
093:
094: public String getHeaderContent() {
095: return headerContent;
096: }
097:
098: public Mode getMode() {
099: return mode;
100: }
101:
102: public WindowState getWindowState() {
103: return windowState;
104: }
105:
106: public Collection getTriggerableActions(String familyName) {
107: return (Collection) actions.get(familyName);
108: }
109:
110: public Map getProperties() {
111: return properties;
112: }
113:
114: /**
115: * Represents an action that can be triggered.
116: * <p/>
117: * todo : add more stuff
118: *
119: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
120: */
121: public static class Action implements ActionRendererContext {
122: /** The origin of the action. */
123: private final String name;
124:
125: /** The origin of the action. */
126: private final String family;
127:
128: /** The action url. */
129: private final String url;
130:
131: /** Enabled or not. */
132: private final boolean enabled;
133:
134: public Action(String name, String family, String url,
135: boolean enabled) {
136: this .name = name;
137: this .family = family;
138: this .url = url;
139: this .enabled = enabled;
140: }
141:
142: public String getName() {
143: return name;
144: }
145:
146: public String getFamily() {
147: return family;
148: }
149:
150: public String getURL() {
151: return url;
152: }
153:
154: public boolean isEnabled() {
155: return enabled;
156: }
157:
158: public String getProperty(String name) {
159: return null;
160: }
161:
162: public Map getProperties() {
163: return Collections.EMPTY_MAP;
164: }
165: }
166: }
|