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) && state.equals(WindowState.MAXIMIZED.toString())) {
048 return true;
049 }
050 else {
051 return false;
052 }
053 }
054
055 public static boolean isPopUp(HttpServletRequest request) {
056 String state = _getWindowState(request);
057
058 if ((state != null) && state.equals(POP_UP.toString())) {
059 return true;
060 }
061 else {
062 return false;
063 }
064 }
065
066 public static boolean isWindowStatePreserved(
067 WindowState oldWindowState, WindowState newWindowState) {
068
069
070
071 if ((newWindowState != null) &&
072 newWindowState.equals(LiferayWindowState.EXCLUSIVE)) {
073
074 return true;
075 }
076
077
078
079 if ((oldWindowState != null) &&
080 oldWindowState.equals(LiferayWindowState.POP_UP)) {
081
082 return false;
083 }
084 else {
085 return true;
086 }
087 }
088
089 public LiferayWindowState(String name) {
090 super(name);
091 }
092
093 private static String _getWindowState(HttpServletRequest request) {
094 WindowState windowState = (WindowState)request.getAttribute(
095 WebKeys.WINDOW_STATE);
096
097 if (windowState != null) {
098 return windowState.toString();
099 }
100
101 return request.getParameter("p_p_state");
102 }
103
104 }