1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.portlet;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import javax.portlet.WindowState;
21  
22  /**
23   * <a href="WindowStateFactory.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class WindowStateFactory {
28  
29      public static WindowState getWindowState(String name) {
30          return _instance._getWindowState(name);
31      }
32  
33      private WindowStateFactory() {
34          _windowStates = new HashMap<String, WindowState>();
35  
36          _windowStates.put(_NORMAL, LiferayWindowState.NORMAL);
37          _windowStates.put(_MAXIMIZED, LiferayWindowState.MAXIMIZED);
38          _windowStates.put(_MINIMIZED, LiferayWindowState.MINIMIZED);
39          _windowStates.put(_EXCLUSIVE, LiferayWindowState.EXCLUSIVE);
40          _windowStates.put(_POP_UP, LiferayWindowState.POP_UP);
41      }
42  
43      private WindowState _getWindowState(String name) {
44          WindowState windowState = _windowStates.get(name);
45  
46          if (windowState == null) {
47              windowState = new WindowState(name);
48          }
49  
50          return windowState;
51      }
52  
53      private static final String _NORMAL = WindowState.NORMAL.toString();
54  
55      private static final String _MAXIMIZED = WindowState.MAXIMIZED.toString();
56  
57      private static final String _MINIMIZED = WindowState.MINIMIZED.toString();
58  
59      private static final String _EXCLUSIVE =
60          LiferayWindowState.EXCLUSIVE.toString();
61  
62      private static final String _POP_UP = LiferayWindowState.POP_UP.toString();
63  
64      private static WindowStateFactory _instance = new WindowStateFactory();
65  
66      private Map<String, WindowState> _windowStates;
67  
68  }