1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.wcm.webui;
18
19 import java.util.Iterator;
20 import java.util.concurrent.ConcurrentHashMap;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.exoplatform.container.xml.InitParams;
24 import org.exoplatform.container.xml.PropertiesParam;
25
26
27
28
29
30
31
32 public class WebUIPropertiesConfigService {
33
34
35 public final static String SCV_POPUP_SIZE_EDIT_PORTLET_MODE = "SCV.popup.size.in.edit.portlet.mode";
36
37
38 public final static String SCV_POPUP_SIZE_QUICK_EDIT = "SCV.popup.size.in.quickdedit";
39
40
41 public final static String CLV_POPUP_SIZE_EDIT_PORTLET_MODE = "CLV.popup.size.in.edit.portlet.mode";
42
43
44 public final static String CLV_POPUP_SIZE_QUICK_EDIT = "CLV.popup.size.in.quickedit";
45
46
47 private ConcurrentHashMap<String,Object> propertiesMap = new ConcurrentHashMap<String,Object>();
48
49
50
51
52
53
54 @SuppressWarnings("unchecked")
55 public WebUIPropertiesConfigService(InitParams params) {
56 for(Iterator iterator = params.getPropertiesParamIterator();iterator.hasNext();) {
57 PropertiesParam propertiesParam = (PropertiesParam)iterator.next();
58 if(SCV_POPUP_SIZE_EDIT_PORTLET_MODE.equalsIgnoreCase(propertiesParam.getName())) {
59 PopupWindowProperties properties = readPropertiesFromXML(propertiesParam);
60 propertiesMap.put(SCV_POPUP_SIZE_EDIT_PORTLET_MODE,properties);
61 }else if(SCV_POPUP_SIZE_QUICK_EDIT.equals(propertiesParam.getName())) {
62 PopupWindowProperties properties = readPropertiesFromXML(propertiesParam);
63 propertiesMap.put(SCV_POPUP_SIZE_QUICK_EDIT,properties);
64 }else if(CLV_POPUP_SIZE_QUICK_EDIT.equals(propertiesParam.getName())) {
65 PopupWindowProperties properties = readPropertiesFromXML(propertiesParam);
66 propertiesMap.put(CLV_POPUP_SIZE_QUICK_EDIT,properties);
67 }else if(CLV_POPUP_SIZE_EDIT_PORTLET_MODE.equals(propertiesParam.getName())) {
68 PopupWindowProperties properties = readPropertiesFromXML(propertiesParam);
69 propertiesMap.put(CLV_POPUP_SIZE_EDIT_PORTLET_MODE,properties);
70 }
71 }
72 }
73
74
75
76
77
78
79
80
81 public Object getProperties(String name) {
82 return propertiesMap.get(name);
83 }
84
85
86
87
88
89
90
91
92 private PopupWindowProperties readPropertiesFromXML(PropertiesParam param) {
93 PopupWindowProperties properties = new PopupWindowProperties();
94 String width = param.getProperty(PopupWindowProperties.WIDTH);
95 String height = param.getProperty(PopupWindowProperties.HEIGHT);
96 if(width != null && StringUtils.isNumeric(width)) {
97 properties.setWidth(Integer.parseInt(width));
98 }
99 if(height != null && StringUtils.isNumeric(height)) {
100 properties.setHeight(Integer.parseInt(height));
101 }
102 return properties;
103 }
104
105
106
107
108 public static class PopupWindowProperties {
109
110
111 public final static String WIDTH = "width";
112
113
114 public final static String HEIGHT = "height";
115
116
117 private int width = 500;
118
119
120 private int height = 300;
121
122
123
124
125
126
127 public int getWidth() { return width; }
128
129
130
131
132
133
134 public void setWidth(int width) { this.width = width;}
135
136
137
138
139
140
141 public int getHeight() { return height; }
142
143
144
145
146
147
148 public void setHeight(int height) { this.height = height; }
149 }
150 }