1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.application.views.common.pagemode;
20
21 import org.springframework.beans.factory.annotation.Autowired;
22
23 import com.hack23.cia.service.api.ApplicationManager;
24 import com.hack23.cia.web.impl.ui.application.action.PageActionEventHelper;
25 import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.AdminChartDataManager;
26 import com.hack23.cia.web.impl.ui.application.views.common.formfactory.api.FormFactory;
27 import com.hack23.cia.web.impl.ui.application.views.common.gridfactory.api.GridFactory;
28 import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory;
29 import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageLinkFactory;
30 import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
31 import com.vaadin.server.Sizeable.Unit;
32 import com.vaadin.ui.HorizontalLayout;
33 import com.vaadin.ui.TabSheet;
34 import com.vaadin.ui.TabSheet.Tab;
35 import com.vaadin.ui.VerticalLayout;
36
37
38
39
40 public abstract class AbstractPageModContentFactoryImpl implements PageModeContentFactory {
41
42
43 public static final String GENERAL_PAGE_MODE_PAGE_VISIT = "General Page Mode Page Visit";
44
45
46 public static final String CURRENT_PAGE_VISIT_HISTORY = "Current Page Visit History";
47
48
49 @Autowired
50 private ApplicationManager applicationManager;
51
52
53 @Autowired
54 private ApplicationMenuItemFactory menuItemFactory;
55
56
57 @Autowired
58 private GridFactory gridFactory;
59
60
61 @Autowired
62 private FormFactory formFactory;
63
64
65 @Autowired
66 private PageLinkFactory pageLinkFactory;
67
68
69 @Autowired
70 private PageActionEventHelper pageActionEventHelper;
71
72
73 @Autowired
74 private AdminChartDataManager adminChartDataManager;
75
76
77
78
79 protected AbstractPageModContentFactoryImpl() {
80 super();
81 }
82
83
84
85
86
87
88
89
90 protected final String getPageId(final String parameters) {
91 if (parameters != null) {
92 final int pageNr = getPageNr(parameters);
93 final String cleanedString = parameters.replace("[" + pageNr + "]", "");
94
95 return cleanedString.substring(cleanedString.lastIndexOf('/') + "/".length(), cleanedString.length());
96 } else {
97 return "";
98 }
99 }
100
101
102
103
104
105
106
107
108 protected final int getPageNr(final String parameters) {
109 String pageNrValue;
110 if (parameters != null && parameters.contains("[") && parameters.contains("]")) {
111 pageNrValue = parameters.substring(parameters.indexOf('[') + 1, parameters.lastIndexOf(']'));
112 } else {
113 pageNrValue = "";
114 }
115
116 int pageNr = 1;
117
118 if (pageNrValue.length() > 0) {
119 pageNr = Integer.parseInt(pageNrValue);
120 }
121 return pageNr;
122 }
123
124
125
126
127
128
129 protected final ApplicationManager getApplicationManager() {
130 return applicationManager;
131 }
132
133
134
135
136
137
138 protected final ApplicationMenuItemFactory getMenuItemFactory() {
139 return menuItemFactory;
140 }
141
142
143
144
145
146
147 protected final GridFactory getGridFactory() {
148 return gridFactory;
149 }
150
151
152
153
154
155
156 protected final FormFactory getFormFactory() {
157 return formFactory;
158 }
159
160
161
162
163
164
165 protected final PageLinkFactory getPageLinkFactory() {
166 return pageLinkFactory;
167 }
168
169
170
171
172
173
174 protected final PageActionEventHelper getPageActionEventHelper() {
175 return pageActionEventHelper;
176 }
177
178
179
180
181
182
183 protected final VerticalLayout createPanelContent() {
184 final VerticalLayout panelContent = new VerticalLayout();
185 panelContent.setMargin(true);
186 panelContent.setWidth(100, Unit.PERCENTAGE);
187 panelContent.setHeight(100, Unit.PERCENTAGE);
188 panelContent.setStyleName("Header");
189 return panelContent;
190 }
191
192
193
194
195
196
197
198
199
200
201
202 protected final void createPageVisitHistory(final String pageName, final String pageId,
203 final VerticalLayout panelContent) {
204
205 final TabSheet tabsheet = new TabSheet();
206 tabsheet.setWidth(100, Unit.PERCENTAGE);
207 tabsheet.setHeight(100, Unit.PERCENTAGE);
208
209 panelContent.addComponent(tabsheet);
210 panelContent.setExpandRatio(tabsheet, ContentRatio.LARGE);
211
212 final HorizontalLayout tabContentPageItemRankHistory = new HorizontalLayout();
213 tabContentPageItemRankHistory.setWidth(100, Unit.PERCENTAGE);
214 tabContentPageItemRankHistory.setHeight(100, Unit.PERCENTAGE);
215 final Tab tabPageItemRankHistory = tabsheet.addTab(tabContentPageItemRankHistory);
216
217 tabPageItemRankHistory.setCaption(CURRENT_PAGE_VISIT_HISTORY);
218 adminChartDataManager.createApplicationActionEventPageElementDailySummaryChart(tabContentPageItemRankHistory,
219 pageName, pageId);
220
221 final HorizontalLayout tabContentPageModeSummary = new HorizontalLayout();
222 tabContentPageModeSummary.setWidth(100, Unit.PERCENTAGE);
223 tabContentPageModeSummary.setHeight(100, Unit.PERCENTAGE);
224 final Tab tabPageModeSummary = tabsheet.addTab(tabContentPageModeSummary);
225 tabPageModeSummary.setCaption(GENERAL_PAGE_MODE_PAGE_VISIT);
226
227 adminChartDataManager.createApplicationActionEventPageModeDailySummaryChart(tabContentPageModeSummary,
228 pageName);
229
230 }
231
232 }