1
14
15 package com.liferay.portal.kernel.portlet;
16
17 import com.liferay.portal.kernel.util.WebKeys;
18
19 import javax.portlet.WindowState;
20
21 import javax.servlet.http.HttpServletRequest;
22
23
29 public class LiferayWindowState extends WindowState {
30
31 public static final WindowState EXCLUSIVE = new WindowState("exclusive");
32
33 public static final WindowState POP_UP = new WindowState("pop_up");
34
35 public static boolean isExclusive(HttpServletRequest request) {
36 String state = _getWindowState(request);
37
38 if ((state != null) && (state.equals(EXCLUSIVE.toString()))) {
39 return true;
40 }
41 else {
42 return false;
43 }
44 }
45
46 public static boolean isMaximized(HttpServletRequest request) {
47 String state = _getWindowState(request);
48
49 if ((state != null) &&
50 (state.equals(WindowState.MAXIMIZED.toString()))) {
51
52 return true;
53 }
54 else {
55 return false;
56 }
57 }
58
59 public static boolean isPopUp(HttpServletRequest request) {
60 String state = _getWindowState(request);
61
62 if ((state != null) && (state.equals(POP_UP.toString()))) {
63 return true;
64 }
65 else {
66 return false;
67 }
68 }
69
70 public static boolean isWindowStatePreserved(
71 WindowState oldWindowState, WindowState newWindowState) {
72
73
75 if ((newWindowState != null) &&
76 (newWindowState.equals(LiferayWindowState.EXCLUSIVE))) {
77
78 return true;
79 }
80
81
83 if ((oldWindowState != null) &&
84 (oldWindowState.equals(LiferayWindowState.POP_UP))) {
85
86 return false;
87 }
88 else {
89 return true;
90 }
91 }
92
93 public LiferayWindowState(String name) {
94 super(name);
95 }
96
97 private static String _getWindowState(HttpServletRequest request) {
98 WindowState windowState = (WindowState)request.getAttribute(
99 WebKeys.WINDOW_STATE);
100
101 if (windowState != null) {
102 return windowState.toString();
103 }
104
105 return request.getParameter("p_p_state");
106 }
107
108 }