001
014
015 package com.liferay.portal.kernel.portlet;
016
017 import com.liferay.portal.kernel.util.WebKeys;
018
019 import javax.portlet.WindowState;
020
021 import javax.servlet.http.HttpServletRequest;
022
023
027 public class LiferayWindowState extends WindowState {
028
029 public static final WindowState EXCLUSIVE = new WindowState("exclusive");
030
031 public static final WindowState POP_UP = new WindowState("pop_up");
032
033 public static boolean isExclusive(HttpServletRequest request) {
034 String state = _getWindowState(request);
035
036 if ((state != null) && (state.equals(EXCLUSIVE.toString()))) {
037 return true;
038 }
039 else {
040 return false;
041 }
042 }
043
044 public static boolean isMaximized(HttpServletRequest request) {
045 String state = _getWindowState(request);
046
047 if ((state != null) &&
048 (state.equals(WindowState.MAXIMIZED.toString()))) {
049
050 return true;
051 }
052 else {
053 return false;
054 }
055 }
056
057 public static boolean isPopUp(HttpServletRequest request) {
058 String state = _getWindowState(request);
059
060 if ((state != null) && (state.equals(POP_UP.toString()))) {
061 return true;
062 }
063 else {
064 return false;
065 }
066 }
067
068 public static boolean isWindowStatePreserved(
069 WindowState oldWindowState, WindowState newWindowState) {
070
071
072
073 if ((newWindowState != null) &&
074 (newWindowState.equals(LiferayWindowState.EXCLUSIVE))) {
075
076 return true;
077 }
078
079
080
081 if ((oldWindowState != null) &&
082 (oldWindowState.equals(LiferayWindowState.POP_UP))) {
083
084 return false;
085 }
086 else {
087 return true;
088 }
089 }
090
091 public LiferayWindowState(String name) {
092 super(name);
093 }
094
095 private static String _getWindowState(HttpServletRequest request) {
096 WindowState windowState = (WindowState)request.getAttribute(
097 WebKeys.WINDOW_STATE);
098
099 if (windowState != null) {
100 return windowState.toString();
101 }
102
103 return request.getParameter("p_p_state");
104 }
105
106 }