1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.context;
21
22 import org.apache.myfaces.tobago.config.Configurable;
23 import org.apache.myfaces.tobago.layout.Measure;
24
25 import javax.faces.context.FacesContext;
26 import java.util.ArrayList;
27 import java.util.List;
28
29
30
31
32 @Deprecated
33 public class ResourceManagerUtil {
34
35 private ResourceManagerUtil() {
36
37 }
38
39
40
41
42 @Deprecated
43 public static String getProperty(FacesContext facesContext, String bundle, String key) {
44 return ResourceManagerFactory.getResourceManager(facesContext).getProperty(facesContext, bundle, key);
45 }
46
47
48
49
50 @Deprecated
51 public static String getPropertyNotNull(FacesContext facesContext, String bundle, String key) {
52 String result = ResourceManagerFactory.getResourceManager(facesContext).getProperty(facesContext, bundle, key);
53 if (result == null) {
54 return "???" + key + "???";
55 } else {
56 return result;
57 }
58 }
59
60
61
62
63
64 public static String getImageWithPath(FacesContext facesContext, String name) {
65 return facesContext.getExternalContext().getRequestContextPath()
66 + ResourceManagerFactory.getResourceManager(facesContext).getImage(facesContext, name);
67 }
68
69
70
71
72
73 public static String getImageWithPath(FacesContext facesContext, String name, boolean ignoreMissing) {
74 String image = ResourceManagerFactory.getResourceManager(facesContext).getImage(facesContext, name, ignoreMissing);
75 if (image == null) {
76 return null;
77 } else {
78 return facesContext.getExternalContext().getRequestContextPath() + image;
79 }
80 }
81
82
83
84
85 @Deprecated
86 public static List<String> getStyles(FacesContext facesContext, String name) {
87 String contextPath = facesContext.getExternalContext().getRequestContextPath();
88 String[] styles = ResourceManagerFactory.getResourceManager(facesContext).getStyles(facesContext, name);
89 return addContextPath(styles, contextPath);
90 }
91
92
93
94
95 @Deprecated
96 private static List<String> addContextPath(String[] strings, String contextPath) {
97 List<String> withContext = new ArrayList<String>(strings.length);
98 for (String string : strings) {
99 withContext.add(contextPath + string);
100 }
101 return withContext;
102 }
103
104
105
106
107 @Deprecated
108 public static List<String> getScripts(FacesContext facesContext, String name) {
109 String contextPath = facesContext.getExternalContext().getRequestContextPath();
110 String[] scripts = ResourceManagerFactory.getResourceManager(facesContext).getScripts(facesContext, name);
111 return addContextPath(scripts, contextPath);
112 }
113
114
115
116
117 @Deprecated
118 public static String getScriptsAsJSArray(FacesContext facesContext, String[] names) {
119 List<String> fileNames = new ArrayList<String>();
120 for (String name : names) {
121 fileNames.addAll(getScripts(facesContext, name));
122 }
123 return toJSArray(fileNames);
124 }
125
126
127
128
129 @Deprecated
130 public static String getStylesAsJSArray(FacesContext facesContext, String[] names) {
131 List<String> fileNames = new ArrayList<String>();
132 for (String name : names) {
133 fileNames.addAll(getStyles(facesContext, name));
134 }
135 return toJSArray(fileNames);
136 }
137
138
139
140
141 @Deprecated
142 public static String toJSArray(List<String> list) {
143 StringBuilder sb = new StringBuilder();
144 for (String name : list) {
145 if (sb.length() > 0) {
146 sb.append(", ");
147 }
148 sb.append('\'');
149 sb.append(name);
150 sb.append('\'');
151 }
152 return "[" + sb.toString() + "]";
153 }
154
155
156
157
158 @Deprecated
159 public static String getDisabledImageWithPath(FacesContext facesContext, String image) {
160 String filename = ResourceUtils.addPostfixToFilename(image, "Disabled");
161 return getImageWithPath(facesContext, filename, true);
162 }
163
164
165
166
167 @Deprecated
168 public static String getBlankPage(FacesContext facesContext) {
169 return ResourceManagerUtils.getBlankPage(facesContext);
170 }
171
172
173
174
175 @Deprecated
176 public static String getPageWithoutContextPath(FacesContext facesContext, String name) {
177 return ResourceManagerFactory.getResourceManager(facesContext).getImage(facesContext, name);
178 }
179
180
181
182
183 @Deprecated
184 public static Measure getThemeMeasure(FacesContext facesContext, Configurable configurable, String name) {
185 return ResourceManagerUtils.getThemeMeasure(facesContext, configurable, name);
186 }
187
188
189
190
191 @Deprecated
192 public static boolean isAbsoluteResource(String value) {
193 return ResourceManagerUtils.isAbsoluteResource(value);
194 }
195
196 }