1
14
15 package com.liferay.portlet;
16
17 import com.liferay.portal.kernel.portlet.LiferayPortletMode;
18 import com.liferay.portal.kernel.portlet.LiferayWindowState;
19 import com.liferay.portal.kernel.util.ReleaseInfo;
20
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.Enumeration;
24 import java.util.List;
25 import java.util.Properties;
26
27 import javax.portlet.PortalContext;
28 import javax.portlet.PortletMode;
29 import javax.portlet.WindowState;
30
31
36 public class PortalContextImpl implements PortalContext {
37
38 static Properties properties = new Properties();
39 static List<PortletMode> portletModes = new ArrayList<PortletMode>();
40 static List<WindowState> windowStates = new ArrayList<WindowState>();
41
42 static {
43 properties.setProperty(
44 MARKUP_HEAD_ELEMENT_SUPPORT, Boolean.TRUE.toString());
45
46 portletModes.add(PortletMode.EDIT);
47 portletModes.add(PortletMode.HELP);
48 portletModes.add(PortletMode.VIEW);
49 portletModes.add(LiferayPortletMode.ABOUT);
50 portletModes.add(LiferayPortletMode.CONFIG);
51 portletModes.add(LiferayPortletMode.EDIT_DEFAULTS);
52 portletModes.add(LiferayPortletMode.PREVIEW);
53 portletModes.add(LiferayPortletMode.PRINT);
54
55 windowStates.add(WindowState.MAXIMIZED);
56 windowStates.add(WindowState.MINIMIZED);
57 windowStates.add(WindowState.NORMAL);
58 windowStates.add(LiferayWindowState.EXCLUSIVE);
59 windowStates.add(LiferayWindowState.POP_UP);
60 }
61
62 public static boolean isSupportedPortletMode(PortletMode portletMode) {
63 Enumeration<PortletMode> enu = Collections.enumeration(portletModes);
64
65 while (enu.hasMoreElements()) {
66 PortletMode supported = enu.nextElement();
67
68 if (supported.equals(portletMode)) {
69 return true;
70 }
71 }
72
73 return false;
74 }
75
76 public static boolean isSupportedWindowState(WindowState windowState) {
77 Enumeration<WindowState> enu = Collections.enumeration(windowStates);
78
79 while (enu.hasMoreElements()) {
80 WindowState supported = enu.nextElement();
81
82 if (supported.equals(windowState)) {
83 return true;
84 }
85 }
86
87 return false;
88 }
89
90 public String getPortalInfo() {
91 return ReleaseInfo.getReleaseInfo();
92 }
93
94 public String getProperty(String name) {
95 return properties.getProperty(name);
96 }
97
98 public Enumeration<String> getPropertyNames() {
99 return (Enumeration<String>)properties.propertyNames();
100 }
101
102 public Enumeration<PortletMode> getSupportedPortletModes() {
103 return Collections.enumeration(portletModes);
104 }
105
106 public Enumeration<WindowState> getSupportedWindowStates() {
107 return Collections.enumeration(windowStates);
108 }
109
110 }