View Javadoc
1   /*
2    * Copyright 2014 James Pether Sörling
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   *	$Id$
17   *  $HeadURL$
18  */
19  package com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl;
20  
21  import org.springframework.beans.factory.annotation.Autowired;
22  import org.springframework.stereotype.Service;
23  
24  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ApplicationMenuItemFactory;
25  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.MinistryMenuItemFactory;
26  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.MinistryRankingMenuItemFactory;
27  import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.MinistryPageMode;
29  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
30  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
31  import com.vaadin.server.FontAwesome;
32  import com.vaadin.ui.GridLayout;
33  import com.vaadin.ui.MenuBar;
34  import com.vaadin.ui.MenuBar.MenuItem;
35  import com.vaadin.ui.VerticalLayout;
36  
37  /**
38   * The Class MenuItemFactoryImpl.
39   */
40  @Service
41  public final class MinistryMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements MinistryMenuItemFactory {
42  
43  	/** The Constant GOVERNMENT_BODIES. */
44  	private static final String GOVERNMENT_BODIES = "Government bodies";
45  
46  	/** The Constant MINISTRY_RANKING. */
47  	private static final String MINISTRY_RANKING = "Ministry Ranking";
48  
49  	/** The Constant DOCUMENT_HISTORY_TEXT. */
50  	private static final String DOCUMENT_HISTORY_TEXT = "Document history";
51  
52  	/** The Constant INDICATORS_TEXT. */
53  	private static final String INDICATORS_TEXT = "Indicators";
54  
55  	/** The Constant CHARTS_TEXT. */
56  	private static final String CHARTS_TEXT = "Charts";
57  
58  	/** The Constant ROLE_GHANT_TEXT. */
59  	private static final String ROLE_GHANT_TEXT = "RoleGhant";
60  
61  	/** The Constant MEMBER_HISTORY_TEXT. */
62  	private static final String MEMBER_HISTORY_TEXT = "Member History";
63  
64  	/** The Constant CURRENT_MEMBERS_TEXT. */
65  	private static final String CURRENT_MEMBERS_TEXT = "Current Members";
66  
67  	/** The Constant ROLES_TEXT. */
68  	private static final String ROLES_TEXT = "Roles";
69  
70  	/** The Constant DOCUMENTS_TEXT. */
71  	private static final String DOCUMENTS_TEXT = "Documents";
72  
73  	/** The Constant DOCUMENT_ACTIVITY_TEXT. */
74  	private static final String DOCUMENT_ACTIVITY_TEXT = "Document Activity";
75  
76  	/** The Constant OVERVIEW_TEXT. */
77  	private static final String OVERVIEW_TEXT = "Overview";
78  
79  	/** The Constant PAGE_VISIT_HISTORY_TEXT. */
80  	private static final String PAGE_VISIT_HISTORY_TEXT = "Page Visit History";
81  
82  	/** The application menu item factory. */
83  	@Autowired
84  	private ApplicationMenuItemFactory applicationMenuItemFactory;
85  
86  	/** The ministry ranking menu item factory. */
87  	@Autowired
88  	private MinistryRankingMenuItemFactory ministryRankingMenuItemFactory;
89  
90  	/**
91  	 * Instantiates a new ministry menu item factory impl.
92  	 */
93  	public MinistryMenuItemFactoryImpl() {
94  		super();
95  	}
96  
97  	@Override
98  	public void createMinistryMenuBar(final MenuBar menuBar, final String pageId) {
99  		initApplicationMenuBar(menuBar);
100 
101 		applicationMenuItemFactory.addRankingMenu(menuBar);
102 
103 		ministryRankingMenuItemFactory.createMinistryRankingTopics(menuBar.addItem(MINISTRY_RANKING, FontAwesome.GROUP,null));
104 
105 		final MenuItem ministryItem = menuBar.addItem("Ministry "+ pageId, FontAwesome.GROUP,null);
106 
107 
108 		ministryItem.addItem(OVERVIEW_TEXT, FontAwesome.GROUP,
109 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.OVERVIEW, pageId));
110 		ministryItem.addItem(CHARTS_TEXT, FontAwesome.GROUP,
111 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.CHARTS, pageId));
112 		ministryItem.addItem(INDICATORS_TEXT, FontAwesome.GROUP,
113 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.INDICATORS, pageId));
114 
115 		final MenuItem rolesItem = ministryItem.addItem(ROLES_TEXT, FontAwesome.GROUP, null);
116 
117 		rolesItem.addItem(CURRENT_MEMBERS_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
118 				MinistryPageMode.CURRENTMEMBERS.toString(), pageId));
119 
120 		rolesItem.addItem(MEMBER_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
121 				MinistryPageMode.MEMBERHISTORY.toString(), pageId));
122 
123 		rolesItem.addItem(ROLE_GHANT_TEXT, FontAwesome.GROUP,
124 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, MinistryPageMode.ROLEGHANT.toString(), pageId));
125 
126 		rolesItem.addItem(GOVERNMENT_BODIES, FontAwesome.GROUP,
127 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, MinistryPageMode.GOVERNMENT_BODIES.toString(), pageId));
128 
129 
130 
131 		final MenuItem documentItem = ministryItem.addItem(DOCUMENTS_TEXT, FontAwesome.GROUP, null);
132 
133 		documentItem.addItem(DOCUMENT_ACTIVITY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
134 				MinistryPageMode.DOCUMENTACTIVITY.toString(), pageId));
135 
136 		documentItem.addItem(DOCUMENT_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
137 				MinistryPageMode.DOCUMENTHISTORY.toString(), pageId));
138 
139 		ministryItem.addItem(PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP,
140 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.PAGEVISITHISTORY, pageId));
141 
142 	}
143 
144 	@Override
145 	public void createOverviewPage(final VerticalLayout panelContent, final String pageId) {
146 		final GridLayout grid = createGridLayout(panelContent);
147 
148 		createButtonLink(grid,OVERVIEW_TEXT, FontAwesome.GROUP,
149 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.OVERVIEW, pageId), "Default description");
150 		createButtonLink(grid,CHARTS_TEXT, FontAwesome.GROUP,
151 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.CHARTS, pageId), "Default description");
152 		createButtonLink(grid,INDICATORS_TEXT, FontAwesome.GROUP,
153 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.INDICATORS, pageId), "Default description");
154 
155 		createButtonLink(grid,CURRENT_MEMBERS_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
156 				MinistryPageMode.CURRENTMEMBERS.toString(), pageId), "Default description");
157 
158 		createButtonLink(grid,MEMBER_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
159 				MinistryPageMode.MEMBERHISTORY.toString(), pageId), "Default description");
160 
161 		createButtonLink(grid,ROLE_GHANT_TEXT, FontAwesome.GROUP,
162 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, MinistryPageMode.ROLEGHANT.toString(), pageId), "Default description");
163 
164 		createButtonLink(grid,GOVERNMENT_BODIES, FontAwesome.GROUP,
165 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, MinistryPageMode.GOVERNMENT_BODIES.toString(), pageId), "Default description");
166 
167 
168 		createButtonLink(grid,DOCUMENT_ACTIVITY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
169 				MinistryPageMode.DOCUMENTACTIVITY.toString(), pageId), "Default description");
170 
171 		createButtonLink(grid,DOCUMENT_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME,
172 				MinistryPageMode.DOCUMENTHISTORY.toString(), pageId), "Default description");
173 
174 		createButtonLink(grid,PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP,
175 				new PageModeMenuCommand(UserViews.MINISTRY_VIEW_NAME, PageMode.PAGEVISITHISTORY, pageId), "Default description");
176 
177 
178 	}
179 
180 }