001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet;
022:
023: import com.liferay.portal.kernel.portlet.LiferayPortletMode;
024: import com.liferay.portal.kernel.portlet.LiferayWindowState;
025: import com.liferay.portal.kernel.util.ReleaseInfo;
026:
027: import java.util.ArrayList;
028: import java.util.Collections;
029: import java.util.Enumeration;
030: import java.util.List;
031: import java.util.Properties;
032:
033: import javax.portlet.PortalContext;
034: import javax.portlet.PortletMode;
035: import javax.portlet.WindowState;
036:
037: /**
038: * <a href="PortalContextImpl.java.html"><b><i>View Source</i></b></a>
039: *
040: * @author Brian Wing Shun Chan
041: *
042: */
043: public class PortalContextImpl implements PortalContext {
044:
045: static Properties props = new Properties();
046: static List portletModes = new ArrayList();
047: static List windowStates = new ArrayList();
048:
049: static {
050: portletModes.add(PortletMode.EDIT);
051: portletModes.add(PortletMode.HELP);
052: portletModes.add(PortletMode.VIEW);
053: portletModes.add(LiferayPortletMode.ABOUT);
054: portletModes.add(LiferayPortletMode.CONFIG);
055: portletModes.add(LiferayPortletMode.EDIT_DEFAULTS);
056: portletModes.add(LiferayPortletMode.PREVIEW);
057: portletModes.add(LiferayPortletMode.PRINT);
058:
059: windowStates.add(WindowState.MAXIMIZED);
060: windowStates.add(WindowState.MINIMIZED);
061: windowStates.add(WindowState.NORMAL);
062: windowStates.add(LiferayWindowState.EXCLUSIVE);
063: windowStates.add(LiferayWindowState.POP_UP);
064: }
065:
066: public static boolean isSupportedPortletMode(PortletMode portletMode) {
067: Enumeration enu = Collections.enumeration(portletModes);
068:
069: while (enu.hasMoreElements()) {
070: PortletMode supported = (PortletMode) enu.nextElement();
071:
072: if (supported.equals(portletMode)) {
073: return true;
074: }
075: }
076:
077: return false;
078: }
079:
080: public static boolean isSupportedWindowState(WindowState windowState) {
081: Enumeration enu = Collections.enumeration(windowStates);
082:
083: while (enu.hasMoreElements()) {
084: WindowState supported = (WindowState) enu.nextElement();
085:
086: if (supported.equals(windowState)) {
087: return true;
088: }
089: }
090:
091: return false;
092: }
093:
094: public String getPortalInfo() {
095: return ReleaseInfo.getReleaseInfo();
096: }
097:
098: public String getProperty(String name) {
099: return props.getProperty(name);
100: }
101:
102: public Enumeration getPropertyNames() {
103: return props.propertyNames();
104: }
105:
106: public Enumeration getSupportedPortletModes() {
107: return Collections.enumeration(portletModes);
108: }
109:
110: public Enumeration getSupportedWindowStates() {
111: return Collections.enumeration(windowStates);
112: }
113:
114: }
|