001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.portlet;
016    
017    import java.util.HashMap;
018    import java.util.Map;
019    
020    import javax.portlet.WindowState;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class WindowStateFactory {
026    
027            public static WindowState getWindowState(String name) {
028                    return _instance._getWindowState(name);
029            }
030    
031            private WindowStateFactory() {
032                    _windowStates = new HashMap<String, WindowState>();
033    
034                    _windowStates.put(_NORMAL, LiferayWindowState.NORMAL);
035                    _windowStates.put(_MAXIMIZED, LiferayWindowState.MAXIMIZED);
036                    _windowStates.put(_MINIMIZED, LiferayWindowState.MINIMIZED);
037                    _windowStates.put(_EXCLUSIVE, LiferayWindowState.EXCLUSIVE);
038                    _windowStates.put(_POP_UP, LiferayWindowState.POP_UP);
039            }
040    
041            private WindowState _getWindowState(String name) {
042                    WindowState windowState = _windowStates.get(name);
043    
044                    if (windowState == null) {
045                            windowState = new WindowState(name);
046                    }
047    
048                    return windowState;
049            }
050    
051            private static final String _EXCLUSIVE =
052                    LiferayWindowState.EXCLUSIVE.toString();
053    
054            private static final String _MAXIMIZED = WindowState.MAXIMIZED.toString();
055    
056            private static final String _MINIMIZED = WindowState.MINIMIZED.toString();
057    
058            private static final String _NORMAL = WindowState.NORMAL.toString();
059    
060            private static final String _POP_UP = LiferayWindowState.POP_UP.toString();
061    
062            private static WindowStateFactory _instance = new WindowStateFactory();
063    
064            private Map<String, WindowState> _windowStates;
065    
066    }