Source Code Cross Referenced for PortletWindowAspect.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » layout » renderer » aspect » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » apache lenya 2.0 » org.apache.cocoon.portal.layout.renderer.aspect.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.portal.layout.renderer.aspect.impl;
018:
019:        import javax.portlet.PortletMode;
020:        import javax.portlet.WindowState;
021:        import javax.servlet.ServletConfig;
022:        import javax.servlet.http.HttpServletRequest;
023:
024:        import org.apache.avalon.framework.context.Context;
025:        import org.apache.avalon.framework.context.ContextException;
026:        import org.apache.avalon.framework.context.Contextualizable;
027:        import org.apache.avalon.framework.parameters.ParameterException;
028:        import org.apache.avalon.framework.parameters.Parameters;
029:        import org.apache.cocoon.portal.PortalService;
030:        import org.apache.cocoon.portal.coplet.CopletInstanceData;
031:        import org.apache.cocoon.portal.coplet.adapter.impl.PortletAdapter;
032:        import org.apache.cocoon.portal.layout.Layout;
033:        import org.apache.cocoon.portal.layout.impl.CopletLayout;
034:        import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
035:        import org.apache.cocoon.portal.pluto.PortletURLProviderImpl;
036:        import org.apache.cocoon.portal.pluto.om.PortletWindowImpl;
037:        import org.apache.cocoon.servlet.CocoonServlet;
038:        import org.apache.cocoon.xml.XMLUtils;
039:        import org.apache.pluto.om.portlet.PortletDefinition;
040:        import org.apache.pluto.om.window.PortletWindow;
041:        import org.apache.pluto.services.PortletContainerEnvironment;
042:        import org.apache.pluto.services.information.DynamicInformationProvider;
043:        import org.apache.pluto.services.information.InformationProviderService;
044:        import org.xml.sax.ContentHandler;
045:        import org.xml.sax.SAXException;
046:
047:        /**
048:         * This aspect draws a portlet window for a JSR-168 implementation.
049:         * 
050:         * <h2>Example XML:</h2>
051:         * <pre>
052:         *   &lt;window&gt;
053:         *     &lt;title&gt;title&lt;/title&gt;
054:         *     &lt;maximize-uri&gt;event&lt;/maximize-uri&gt;
055:         *     &lt;minimize-uri&gt;event&lt;/minimize-uri&gt;
056:         *     &lt;fullscreen-uri&gt;event&lt;/fullscreen-uri&gt;
057:         *     &lt;edit-uri&gt;event&lt;/edit-uri&gt;
058:         *     &lt;help-uri&gt;event&lt;/help-uri&gt;
059:         *     &lt;view-uri&gt;event&lt;/view-uri&gt;
060:         *     &lt;!-- output of following renderers --&gt;
061:         *   &lt;/window&gt;
062:         * </pre>
063:         * 
064:         * <h2>Applicable to:</h2>
065:         * <ul>
066:         *  <li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
067:         * </ul>
068:         * 
069:         * <h2>Parameters</h2>
070:         * <table><tbody>
071:         * <tr><th>root-tag</th><td>Should a root tag surrounding the following output
072:         *  be generated?</td><td></td><td>boolean</td><td><code>true</code></td></tr>
073:         * <tr><th>tag-name</th><td>Name of the root tag if requested.
074:         *  </td><td></td><td>String</td><td><code>"window"</code></td></tr>
075:         * </tbody></table>
076:         * 
077:         * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
078:         * 
079:         * @version CVS $Id: PortletWindowAspect.java 433543 2006-08-22 06:22:54Z crossley $
080:         */
081:        public final class PortletWindowAspect extends AbstractAspect implements 
082:                Contextualizable {
083:
084:            /** The environment */
085:            protected PortletContainerEnvironment environment;
086:
087:            /* (non-Javadoc)
088:             * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
089:             */
090:            public void contextualize(Context context) throws ContextException {
091:                try {
092:                    // now get the portal manager
093:                    ServletConfig servletConfig = (ServletConfig) context
094:                            .get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
095:                    PortletAdapter portalManager = (PortletAdapter) servletConfig
096:                            .getServletContext().getAttribute(
097:                                    PortletAdapter.class.getName());
098:                    if (portalManager != null) {
099:                        this .environment = portalManager
100:                                .getPortletContainerEnvironment();
101:                    }
102:                } catch (ContextException ignore) {
103:                    // we ignore the context exception
104:                    // this avoids startup errors if the portal is configured for the CLI
105:                    // environment
106:                    this 
107:                            .getLogger()
108:                            .warn(
109:                                    "The JSR-168 support is disabled as the servlet context is not available.",
110:                                    ignore);
111:                }
112:            }
113:
114:            /* (non-Javadoc)
115:             * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext, org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
116:             */
117:            public void toSAX(RendererAspectContext context, Layout layout,
118:                    PortalService service, ContentHandler contenthandler)
119:                    throws SAXException {
120:                final PreparedConfiguration config = (PreparedConfiguration) context
121:                        .getAspectConfiguration();
122:                final CopletInstanceData copletInstanceData = ((CopletLayout) layout)
123:                        .getCopletInstanceData();
124:
125:                if (config.rootTag) {
126:                    XMLUtils.startElement(contenthandler, config.tagName);
127:                }
128:                final PortletWindow window = (PortletWindow) copletInstanceData
129:                        .getTemporaryAttribute("window");
130:                if (window == null) {
131:                    // no portlet window, so use a default behaviour
132:                    XMLUtils.createElement(contenthandler, "title",
133:                            copletInstanceData.getTitle());
134:                } else {
135:                    if (((PortletWindowImpl) window).getLayout() == null) {
136:                        ((PortletWindowImpl) window)
137:                                .setLayout((CopletLayout) layout);
138:                    }
139:
140:                    String title = (String) copletInstanceData
141:                            .getTemporaryAttribute("dynamic-title");
142:                    if (title == null) {
143:                        final PortletDefinition def = window.getPortletEntity()
144:                                .getPortletDefinition();
145:                        try {
146:                            title = def.getDisplayName(
147:                                    def.getLanguageSet().getDefaultLocale())
148:                                    .getDisplayName();
149:                        } catch (Exception ignore) {
150:                            title = copletInstanceData.getTitle();
151:                        }
152:                    }
153:                    XMLUtils.createElement(contenthandler, "title", title);
154:
155:                    if (this .environment != null) {
156:                        InformationProviderService ips = (InformationProviderService) this .environment
157:                                .getContainerService(InformationProviderService.class);
158:                        DynamicInformationProvider dip = ips
159:                                .getDynamicProvider((HttpServletRequest) context
160:                                        .getObjectModel()
161:                                        .get("portlet-request"));
162:
163:                        // Sizing
164:                        final String wsString = (String) copletInstanceData
165:                                .getTemporaryAttribute("window-state");
166:                        WindowState ws;
167:                        if (wsString != null) {
168:                            ws = new WindowState(wsString);
169:                        } else {
170:                            ws = WindowState.NORMAL;
171:                        }
172:
173:                        if (!ws.equals(WindowState.MINIMIZED)
174:                                && !ws.equals(WindowState.MAXIMIZED)) {
175:                            PortletURLProviderImpl url = (PortletURLProviderImpl) dip
176:                                    .getPortletURLProvider(window);
177:                            url.clearParameters();
178:                            url.setWindowState(WindowState.MINIMIZED);
179:
180:                            XMLUtils.createElement(contenthandler,
181:                                    "minimize-uri", url.toString());
182:                        }
183:
184:                        if (!ws.equals(WindowState.NORMAL)) {
185:                            PortletURLProviderImpl url = (PortletURLProviderImpl) dip
186:                                    .getPortletURLProvider(window);
187:                            url.clearParameters();
188:                            url.setWindowState(WindowState.NORMAL);
189:                            XMLUtils.createElement(contenthandler,
190:                                    "maximize-uri", url.toString());
191:                        }
192:
193:                        if (!ws.equals(WindowState.MAXIMIZED)) {
194:                            PortletURLProviderImpl url = (PortletURLProviderImpl) dip
195:                                    .getPortletURLProvider(window);
196:                            url.clearParameters();
197:                            url.setWindowState(WindowState.MAXIMIZED);
198:                            XMLUtils.createElement(contenthandler,
199:                                    "fullscreen-uri", url.toString());
200:                        }
201:
202:                        // portlet modes
203:                        final String pmString = (String) copletInstanceData
204:                                .getTemporaryAttribute("portlet-mode");
205:                        PortletMode pm;
206:                        if (pmString == null) {
207:                            pm = PortletMode.VIEW;
208:                        } else {
209:                            pm = new PortletMode(pmString);
210:                        }
211:                        if (!pm.equals(PortletMode.EDIT)) {
212:                            PortletURLProviderImpl url = (PortletURLProviderImpl) dip
213:                                    .getPortletURLProvider(window);
214:                            url.clearParameters();
215:                            url.setPortletMode(PortletMode.EDIT);
216:                            XMLUtils.createElement(contenthandler, "edit-uri",
217:                                    url.toString());
218:                        }
219:                        if (!pm.equals(PortletMode.HELP)) {
220:                            PortletURLProviderImpl url = (PortletURLProviderImpl) dip
221:                                    .getPortletURLProvider(window);
222:                            url.clearParameters();
223:                            url.setPortletMode(PortletMode.HELP);
224:                            XMLUtils.createElement(contenthandler, "help-uri",
225:                                    url.toString());
226:                        }
227:                        if (!pm.equals(PortletMode.VIEW)) {
228:                            PortletURLProviderImpl url = (PortletURLProviderImpl) dip
229:                                    .getPortletURLProvider(window);
230:                            url.clearParameters();
231:                            url.setPortletMode(PortletMode.VIEW);
232:                            XMLUtils.createElement(contenthandler, "view-uri",
233:                                    url.toString());
234:                        }
235:                    }
236:                }
237:
238:                context.invokeNext(layout, service, contenthandler);
239:
240:                if (config.rootTag) {
241:                    XMLUtils.endElement(contenthandler, config.tagName);
242:                }
243:            }
244:
245:            protected static class PreparedConfiguration {
246:                public String tagName;
247:                public boolean rootTag;
248:
249:                public void takeValues(PreparedConfiguration from) {
250:                    this .tagName = from.tagName;
251:                    this .rootTag = from.rootTag;
252:                }
253:            }
254:
255:            /* (non-Javadoc)
256:             * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect#prepareConfiguration(org.apache.avalon.framework.parameters.Parameters)
257:             */
258:            public Object prepareConfiguration(Parameters configuration)
259:                    throws ParameterException {
260:                PreparedConfiguration pc = new PreparedConfiguration();
261:                pc.tagName = configuration.getParameter("tag-name", "window");
262:                pc.rootTag = configuration.getParameterAsBoolean("root-tag",
263:                        true);
264:                return pc;
265:            }
266:
267:        }
www_.j_a___va2_s___.___c__o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.