| LiferayWindowState.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.portal.kernel.portlet;
24
25 import javax.portlet.WindowState;
26
27 import javax.servlet.http.HttpServletRequest;
28
29 /**
30 * <a href="LiferayWindowState.java.html"><b><i>View Source</i></b></a>
31 *
32 * @author Brian Wing Shun Chan
33 *
34 */
35 public class LiferayWindowState extends WindowState {
36
37 public final static WindowState EXCLUSIVE = new WindowState("exclusive");
38
39 public final static WindowState POP_UP = new WindowState("pop_up");
40
41 public static boolean isExclusive(HttpServletRequest request) {
42 String state = request.getParameter("p_p_state");
43
44 if ((state != null) && (state.equals(EXCLUSIVE.toString()))) {
45 return true;
46 }
47 else {
48 return false;
49 }
50 }
51
52 public static boolean isMaximized(HttpServletRequest request) {
53 String state = request.getParameter("p_p_state");
54
55 if ((state != null) &&
56 (state.equals(WindowState.MAXIMIZED.toString()))) {
57
58 return true;
59 }
60 else {
61 return false;
62 }
63 }
64
65 public static boolean isPopUp(HttpServletRequest request) {
66 String state = request.getParameter("p_p_state");
67
68 if ((state != null) && (state.equals(POP_UP.toString()))) {
69 return true;
70 }
71 else {
72 return false;
73 }
74 }
75
76 public static boolean isWindowStatePreserved(
77 WindowState oldWindowState, WindowState newWindowState) {
78
79 // Changes to EXCLUSIVE are always preserved
80
81 if ((newWindowState != null) &&
82 (newWindowState.equals(LiferayWindowState.EXCLUSIVE))) {
83
84 return true;
85 }
86
87 // Some window states are automatically preserved
88
89 if ((oldWindowState != null) &&
90 (oldWindowState.equals(LiferayWindowState.POP_UP))) {
91
92 return false;
93 }
94 else {
95 return true;
96 }
97 }
98
99 public LiferayWindowState(String name) {
100 super(name);
101 }
102
103 }