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.CommitteeRankingMenuItemFactory;
26  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.CountryMenuItemFactory;
27  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.MinistryRankingMenuItemFactory;
28  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.ParliamentMenuItemFactory;
29  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PartyRankingMenuItemFactory;
30  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.PoliticianRankingMenuItemFactory;
31  import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
32  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
33  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
34  import com.vaadin.server.FontAwesome;
35  import com.vaadin.ui.GridLayout;
36  import com.vaadin.ui.MenuBar;
37  import com.vaadin.ui.MenuBar.MenuItem;
38  import com.vaadin.ui.VerticalLayout;
39  
40  /**
41   * The Class ApplicationMenuItemFactoryImpl.
42   */
43  @Service
44  public final class ApplicationMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
45  		implements ApplicationMenuItemFactory {
46  
47  	/** The Constant COMMAND_PARLIAMENT_RANKING_OVERVIEW. */
48  	private static final PageModeMenuCommand COMMAND_PARLIAMENT_RANKING_OVERVIEW = new PageModeMenuCommand(UserViews.PARLIAMENT_RANKING_VIEW_NAME,
49  			PageMode.OVERVIEW);
50  
51  	/** The Constant COMMAND_COUNTRY_RANKING_OVERVIEW. */
52  	private static final PageModeMenuCommand COMMAND_COUNTRY_RANKING_OVERVIEW = new PageModeMenuCommand(UserViews.COUNTRY_RANKING_VIEW_NAME,
53  			PageMode.OVERVIEW);
54  
55  	/** The Constant COMMAND_MINISTRY_RANKING_OVERVIEW. */
56  	private static final PageModeMenuCommand COMMAND_MINISTRY_RANKING_OVERVIEW = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
57  			PageMode.OVERVIEW);
58  
59  	/** The Constant COMMAND_MINISTRY_RANKING_DATAGRID. */
60  	private static final PageModeMenuCommand COMMAND_MINISTRY_RANKING_DATAGRID = new PageModeMenuCommand(UserViews.MINISTRY_RANKING_VIEW_NAME,
61  			PageMode.DATAGRID);
62  
63  
64  	/** The Constant COMMAND_COMMITTEE_RANKING_OVERVIEW. */
65  	private static final PageModeMenuCommand COMMAND_COMMITTEE_RANKING_OVERVIEW = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
66  			PageMode.OVERVIEW);
67  
68  	/** The Constant COMMAND_COMMITTEE_RANKING_DATAGRID. */
69  	private static final PageModeMenuCommand COMMAND_COMMITTEE_RANKING_DATAGRID = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
70  			PageMode.DATAGRID);
71  
72  	/** The Constant COMMAND_PARTY_RANKING_OVERVIEW. */
73  	private static final PageModeMenuCommand COMMAND_PARTY_RANKING_OVERVIEW = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME,
74  			PageMode.OVERVIEW);
75  
76  	/** The Constant COMMAND_PARTY_RANKING_DATAGRID. */
77  	private static final PageModeMenuCommand COMMAND_PARTY_RANKING_DATAGRID = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME,
78  			PageMode.DATAGRID);
79  
80  
81  	/** The Constant COMMAND_POLITICIAN_RANKING_OVERVIEW. */
82  	private static final PageModeMenuCommand COMMAND_POLITICIAN_RANKING_OVERVIEW = new PageModeMenuCommand(UserViews.POLITICIAN_RANKING_VIEW_NAME,
83  			PageMode.OVERVIEW);
84  
85  	/** The Constant COMMAND_POLITICIAN_RANKING_DATAGRID. */
86  	private static final PageModeMenuCommand COMMAND_POLITICIAN_RANKING_DATAGRID = new PageModeMenuCommand(UserViews.POLITICIAN_RANKING_VIEW_NAME,
87  			PageMode.DATAGRID);
88  
89  
90  
91  	/** The Constant POLITICIAN_RANKING. */
92  	private static final String POLITICIAN_RANKING = "Politician Ranking";
93  
94  	/** The Constant PARTY_RANKING. */
95  	private static final String PARTY_RANKING = "Party Ranking";
96  
97  	/** The Constant MINISTRY_RANKING. */
98  	private static final String MINISTRY_RANKING = "Ministry Ranking";
99  
100 	/** The Constant COMMITTEE_RANKING_TEXT. */
101 	private static final String COMMITTEE_RANKING_TEXT = "Committee Ranking";
102 
103 	/** The Constant RANKING_TEXT. */
104 	private static final String RANKING_TEXT = "Ranking";
105 
106 	/** The Constant POLITICIAN_RANKING_LINK_TEXT. */
107 	private static final String POLITICIAN_RANKING_LINK_TEXT = POLITICIAN_RANKING;
108 
109 	/** The Constant PARTY_RANKING_LINK_TEXT. */
110 	private static final String PARTY_RANKING_LINK_TEXT = PARTY_RANKING;
111 
112 	/** The Constant COMMITTEE_RANKING_LINK_TEXT. */
113 	private static final String COMMITTEE_RANKING_LINK_TEXT = COMMITTEE_RANKING_TEXT;
114 
115 	/** The Constant MINISTRY_RANKING_LINK_TEXT. */
116 	private static final String MINISTRY_RANKING_LINK_TEXT = MINISTRY_RANKING;
117 
118 	/** The Constant COUNTRY_RANKING_LINK_TEXT. */
119 	private static final String COUNTRY_RANKING_LINK_TEXT = "Country Ranking";
120 
121 	/** The Constant PARLIAMENT_RANKING_LINK_TEXT. */
122 	private static final String PARLIAMENT_RANKING_LINK_TEXT = "Parliament Ranking";
123 
124 	/** The Constant MINISTRIES_LINK_TEXT. */
125 	private static final String MINISTRIES_LINK_TEXT = "Ministries";
126 
127 	/** The Constant COMMITTEES_LINK_TEXT. */
128 	private static final String COMMITTEES_LINK_TEXT = "Committees";
129 
130 	/** The Constant PARTIES_LINK_TEXT. */
131 	private static final String PARTIES_LINK_TEXT = "Parties";
132 
133 	/** The Constant POLITICIANS_LINK_TEXT. */
134 	private static final String POLITICIANS_LINK_TEXT = "Politicians";
135 
136 
137 	/** The politician ranking menu item factory. */
138 	@Autowired
139 	private PoliticianRankingMenuItemFactory politicianRankingMenuItemFactory;
140 
141 	/** The party ranking menu item factory. */
142 	@Autowired
143 	private PartyRankingMenuItemFactory partyRankingMenuItemFactory;
144 
145 	/** The committee ranking menu item factory. */
146 	@Autowired
147 	private CommitteeRankingMenuItemFactory committeeRankingMenuItemFactory;
148 
149 	/** The ministry ranking menu item factory. */
150 	@Autowired
151 	private MinistryRankingMenuItemFactory ministryRankingMenuItemFactory;
152 
153 	/** The country menu item factory. */
154 	@Autowired
155 	private CountryMenuItemFactory countryMenuItemFactory;
156 
157 	/** The parliament menu item factory. */
158 	@Autowired
159 	private ParliamentMenuItemFactory parliamentMenuItemFactory;
160 
161 	/**
162 	 * Instantiates a new application menu item factory impl.
163 	 */
164 	public ApplicationMenuItemFactoryImpl() {
165 		super();
166 	}
167 
168 	@Override
169 	public MenuBar createMainPageMenuBar(final MenuBar menuBar) {
170 		initApplicationMenuBar(menuBar);
171 
172 		addRankingMenu(menuBar);
173 
174 		return menuBar;
175 	}
176 
177 	@Override
178 	public void addRankingMenu(final MenuBar menuBar) {
179 
180 		final MenuItem rankingsMenuItem = menuBar.addItem(RANKING_TEXT, FontAwesome.AREA_CHART, null);
181 
182 		final MenuItem countryMenuItem = rankingsMenuItem.addItem(COUNTRY_RANKING_LINK_TEXT,FontAwesome.FLAG, COMMAND_COUNTRY_RANKING_OVERVIEW);
183 
184 		countryMenuItemFactory.createCountryTopicMenu(countryMenuItem);
185 
186 		final MenuItem parliamentMenuItem = rankingsMenuItem.addItem(PARLIAMENT_RANKING_LINK_TEXT,FontAwesome.INSTITUTION, COMMAND_PARLIAMENT_RANKING_OVERVIEW);
187 
188 		parliamentMenuItemFactory.createParliamentTopicMenu(parliamentMenuItem);
189 
190 		final MenuItem politicianMenuItem = rankingsMenuItem.addItem(POLITICIAN_RANKING_LINK_TEXT,FontAwesome.USER, COMMAND_POLITICIAN_RANKING_OVERVIEW);
191 
192 		politicianRankingMenuItemFactory.createPoliticianRankingTopics(politicianMenuItem);
193 
194 		final MenuItem partynMenuItem = rankingsMenuItem.addItem(PARTY_RANKING_LINK_TEXT, FontAwesome.GROUP,COMMAND_PARTY_RANKING_OVERVIEW);
195 
196 		partyRankingMenuItemFactory.createPartyRankingTopics(partynMenuItem);
197 
198 		final MenuItem committeeMenuItem = rankingsMenuItem.addItem(COMMITTEE_RANKING_LINK_TEXT,FontAwesome.GROUP, COMMAND_COMMITTEE_RANKING_OVERVIEW);
199 
200 		committeeRankingMenuItemFactory.createCommitteeRankingTopics(committeeMenuItem);
201 
202 		final MenuItem ministryMenuItem = rankingsMenuItem.addItem(MINISTRY_RANKING_LINK_TEXT,FontAwesome.GROUP, COMMAND_MINISTRY_RANKING_OVERVIEW);
203 
204 		ministryRankingMenuItemFactory.createMinistryRankingTopics(ministryMenuItem);
205 
206 	}
207 
208 	@Override
209 	public void createOverviewPage(final VerticalLayout panelContent) {
210 		final GridLayout grid = createGridLayout(panelContent);
211 
212 		createButtonLink(grid,COUNTRY_RANKING_LINK_TEXT,FontAwesome.FLAG, COMMAND_COUNTRY_RANKING_OVERVIEW,"View indicators for Sweden, find data by topic or source.");
213 
214 		createButtonLink(grid,PARLIAMENT_RANKING_LINK_TEXT,FontAwesome.INSTITUTION, COMMAND_PARLIAMENT_RANKING_OVERVIEW,"Charts over parlimentary ballots and document activity");
215 
216 		createButtonLink(grid,POLITICIAN_RANKING_LINK_TEXT,FontAwesome.USER, COMMAND_POLITICIAN_RANKING_OVERVIEW,"Overview");
217 
218 		createButtonLink(grid,POLITICIANS_LINK_TEXT,FontAwesome.USER, COMMAND_POLITICIAN_RANKING_DATAGRID,"Politican Experience Summary");
219 
220 
221 		createButtonLink(grid,PARTY_RANKING_LINK_TEXT, FontAwesome.GROUP,COMMAND_PARTY_RANKING_OVERVIEW,"Overview");
222 
223 		createButtonLink(grid,PARTIES_LINK_TEXT, FontAwesome.GROUP,COMMAND_PARTY_RANKING_DATAGRID,"Political Work Summary");
224 
225 
226 		createButtonLink(grid,COMMITTEE_RANKING_LINK_TEXT,FontAwesome.GROUP, COMMAND_COMMITTEE_RANKING_OVERVIEW,"Overview");
227 
228 		createButtonLink(grid,COMMITTEES_LINK_TEXT,FontAwesome.GROUP, COMMAND_COMMITTEE_RANKING_DATAGRID,"Political Work Summary");
229 
230 
231 		createButtonLink(grid,MINISTRY_RANKING_LINK_TEXT,FontAwesome.GROUP, COMMAND_MINISTRY_RANKING_OVERVIEW,"Overview");
232 
233 		createButtonLink(grid,MINISTRIES_LINK_TEXT,FontAwesome.GROUP, COMMAND_MINISTRY_RANKING_DATAGRID,"Political Work Summary");
234 
235 
236 	}
237 
238 }