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.admin.system.pagemode;
20
21 import java.util.Arrays;
22
23 import org.springframework.security.access.annotation.Secured;
24 import org.springframework.stereotype.Component;
25
26 import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
27 import com.hack23.cia.model.internal.application.system.impl.LanguageData;
28 import com.hack23.cia.model.internal.application.system.impl.LanguageData_;
29 import com.hack23.cia.service.api.DataContainer;
30 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
31 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
32 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.AdminViews;
33 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
34 import com.vaadin.data.util.BeanItem;
35 import com.vaadin.data.util.BeanItemContainer;
36 import com.vaadin.ui.Layout;
37 import com.vaadin.ui.MenuBar;
38 import com.vaadin.ui.Panel;
39 import com.vaadin.ui.VerticalLayout;
40
41
42
43
44 @Component
45 public final class AdminLanguagePageModContentFactoryImpl extends AbstractAdminSystemPageModContentFactoryImpl {
46
47
48 private static final String ADMIN_LANGUAGE = "Admin Language";
49
50
51 public static final String NAME = AdminViews.ADMIN_LANGUAGE_VIEW_NAME;
52
53
54
55
56 public AdminLanguagePageModContentFactoryImpl() {
57 super();
58 }
59
60 @Override
61 public boolean matches(final String page, final String parameters) {
62 return NAME.equals(page);
63 }
64
65 @Secured({ "ROLE_ADMIN" })
66 @Override
67 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
68 final VerticalLayout content = createPanelContent();
69
70 final String pageId = getPageId(parameters);
71 final int pageNr= getPageNr(parameters);
72
73
74 getMenuItemFactory().createMainPageMenuBar(menuBar);
75
76 LabelFactory.createHeader2Label(content,ADMIN_LANGUAGE);
77
78 final DataContainer<LanguageData, Long> dataContainer = getApplicationManager()
79 .getDataContainer(LanguageData.class);
80
81 final BeanItemContainer<LanguageData> politicianDocumentDataSource = new BeanItemContainer<>(LanguageData.class,
82 dataContainer.getPageOrderBy(pageNr,DEFAULT_RESULTS_PER_PAGE,LanguageData_.languageName));
83
84 createPagingControls(content,NAME,pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
85
86 getGridFactory().createBasicBeanItemGrid(content,
87 politicianDocumentDataSource, "LanguageData",
88 new String[] { "hjid", "languageName", "modelObjectVersion" }, new String[] { "hjid", "modelObjectId","modelObjectVersion", "createdDate","lastModifiedDate" },
89 new PageItemPropertyClickListener(AdminViews.ADMIN_LANGUAGE_VIEW_NAME, "hjid"), null, null);
90
91 if (pageId != null && !pageId.isEmpty()) {
92
93 final LanguageData languageData = dataContainer.load(Long.valueOf(pageId));
94
95 if (languageData != null) {
96
97 getFormFactory().addFormPanelTextFields(content, new BeanItem<>(languageData), LanguageData.class,
98 Arrays.asList(new String[] { "languageName", "createdDate","lastModifiedDate" ,"languageEnabled" }));
99 }
100 }
101
102 getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_LANGUAGE_VIEW, ApplicationEventGroup.ADMIN,
103 NAME, null, pageId);
104
105 return content;
106
107 }
108
109 }