1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.kernel.portlet;
16  
17  import javax.portlet.WindowState;
18  
19  import javax.servlet.http.HttpServletRequest;
20  
21  /**
22   * <a href="LiferayWindowState.java.html"><b><i>View Source</i></b></a>
23   *
24   * @author Brian Wing Shun Chan
25   */
26  public class LiferayWindowState extends WindowState {
27  
28      public final static WindowState EXCLUSIVE = new WindowState("exclusive");
29  
30      public final static WindowState POP_UP = new WindowState("pop_up");
31  
32      public static boolean isExclusive(HttpServletRequest request) {
33          String state = request.getParameter("p_p_state");
34  
35          if ((state != null) && (state.equals(EXCLUSIVE.toString()))) {
36              return true;
37          }
38          else {
39              return false;
40          }
41      }
42  
43      public static boolean isMaximized(HttpServletRequest request) {
44          String state = request.getParameter("p_p_state");
45  
46          if ((state != null) &&
47              (state.equals(WindowState.MAXIMIZED.toString()))) {
48  
49              return true;
50          }
51          else {
52              return false;
53          }
54      }
55  
56      public static boolean isPopUp(HttpServletRequest request) {
57          String state = request.getParameter("p_p_state");
58  
59          if ((state != null) && (state.equals(POP_UP.toString()))) {
60              return true;
61          }
62          else {
63              return false;
64          }
65      }
66  
67      public static boolean isWindowStatePreserved(
68          WindowState oldWindowState, WindowState newWindowState) {
69  
70          // Changes to EXCLUSIVE are always preserved
71  
72          if ((newWindowState != null) &&
73              (newWindowState.equals(LiferayWindowState.EXCLUSIVE))) {
74  
75              return true;
76          }
77  
78          // Some window states are automatically preserved
79  
80          if ((oldWindowState != null) &&
81              (oldWindowState.equals(LiferayWindowState.POP_UP))) {
82  
83              return false;
84          }
85          else {
86              return true;
87          }
88      }
89  
90      public LiferayWindowState(String name) {
91          super(name);
92      }
93  
94  }