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.PartyRankingMenuItemFactory;
26  import com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand;
27  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.ChartIndicators;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
29  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
30  import com.vaadin.server.FontAwesome;
31  import com.vaadin.ui.GridLayout;
32  import com.vaadin.ui.MenuBar;
33  import com.vaadin.ui.MenuBar.MenuItem;
34  import com.vaadin.ui.VerticalLayout;
35  
36  /**
37   * The Class PartyRankingMenuItemFactoryImpl.
38   */
39  @Service
40  public final class PartyRankingMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements PartyRankingMenuItemFactory {
41  
42  	/** The Constant COMMAND_PAGEVISITHISTORY. */
43  	private static final PageModeMenuCommand COMMAND_PAGEVISITHISTORY = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.PAGEVISITHISTORY);
44  
45  	/** The Constant COMMAND_CHARTS_ALL_PARTIES. */
46  	private static final PageModeMenuCommand COMMAND_CHARTS_ALL_PARTIES = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.CHARTS,ChartIndicators.ALLPARTIES.toString());
47  
48  	/** The Constant COMMAND_CHARTS_CURRENT_COMMITTEES. */
49  	private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_COMMITTEES = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.CHARTS,ChartIndicators.CURRENTCOMMITTEES.toString());
50  
51  	/** The Constant COMMAND_CHARTS_CURRENT_GOVERNMENT_PARTIES. */
52  	private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_GOVERNMENT_PARTIES = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.CHARTS,ChartIndicators.CURRENTGOVERMENTPARTIES.toString());
53  
54  	/** The Constant COMMAND_CHARTS_CURRENT_PARTIES. */
55  	private static final PageModeMenuCommand COMMAND_CHARTS_CURRENT_PARTIES = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.CHARTS,ChartIndicators.CURRENTPARTIES.toString());
56  
57  	/** The Constant COMMAND_DATAGRID. */
58  	private static final PageModeMenuCommand COMMAND_DATAGRID = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.DATAGRID);
59  
60  	/** The Constant COMMAND_OVERVIEW. */
61  	private static final PageModeMenuCommand COMMAND_OVERVIEW = new PageModeMenuCommand(UserViews.PARTY_RANKING_VIEW_NAME, PageMode.OVERVIEW);
62  
63  	/** The Constant PARTY_RANKING. */
64  	private static final String PARTY_RANKING = "Party Ranking";
65  
66  	/** The Constant ALL_PARTIES_TOTAL_DAYS_SERVED_IN_PARLIAMENT. */
67  	private static final String ALL_PARTIES_TOTAL_DAYS_SERVED_IN_PARLIAMENT = "All parties, total days served in parliament";
68  
69  	/** The Constant CURRENT_PARTIES_ACTIVE_IN_PARLIAMENT_HEAD_COUNT. */
70  	private static final String CURRENT_PARTIES_ACTIVE_IN_PARLIAMENT_HEAD_COUNT = "Current parties active in parliament, head count";
71  
72  	/**
73  	 * The Constant
74  	 * PARTY_BY_TOTAL_MEMBERS_BASED_ON_ROLES_IN_DEPARTMENTS_COMMITTEES_AND_PARLIAMENT.
75  	 */
76  	private static final String PARTY_BY_TOTAL_MEMBERS_BASED_ON_ROLES_IN_DEPARTMENTS_COMMITTEES_AND_PARLIAMENT = "Party by total members, based on roles in departments, committees and parliament";
77  
78  	/** The Constant TOTAL_MEMBERS. */
79  	private static final String TOTAL_MEMBERS = "Total members";
80  
81  	/** The Constant CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_HEAD_COUNT. */
82  	private static final String CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_HEAD_COUNT = "Current parties active in committees, head count";
83  
84  	/** The Constant CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT. */
85  	private static final String CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT = "Current parties active in ministries, head count";
86  
87  	/** The Constant RANKING_LIST_BY_TOPIC_TEXT. */
88  	private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";
89  
90  	/** The Constant CHART_BY_TOPIC_TEXT. */
91  	private static final String CHART_BY_TOPIC_TEXT = "Chart by topic";
92  
93  	/** The Constant OVERVIEW_TEXT. */
94  	private static final String OVERVIEW_TEXT = "Overview";
95  
96  	/** The Constant PAGE_VISIT_HISTORY_TEXT. */
97  	private static final String PAGE_VISIT_HISTORY_TEXT = "Page Visit History";
98  
99  	/** The application menu item factory. */
100 	@Autowired
101 	private ApplicationMenuItemFactory applicationMenuItemFactory;
102 
103 
104 	/**
105 	 * Instantiates a new party ranking menu item factory impl.
106 	 */
107 	public PartyRankingMenuItemFactoryImpl() {
108 		super();
109 	}
110 
111 
112 	@Override
113 	public void createPartyRankingMenuBar(final MenuBar menuBar) {
114 		initApplicationMenuBar(menuBar);
115 
116 		applicationMenuItemFactory.addRankingMenu(menuBar);
117 
118 		createPartyRankingTopics(menuBar.addItem(PARTY_RANKING, FontAwesome.GROUP,null));
119 
120 	}
121 
122 
123 	@Override
124 	public void createPartyRankingTopics(final MenuItem partynMenuItem) {
125 
126 		partynMenuItem.addItem(OVERVIEW_TEXT, FontAwesome.GROUP,
127 				COMMAND_OVERVIEW);
128 
129 		final MenuItem listByTopic = partynMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, FontAwesome.GROUP, null);
130 
131 		final MenuItem listItem = listByTopic.addItem(TOTAL_MEMBERS,FontAwesome.GROUP,
132 				COMMAND_DATAGRID);
133 		listItem.setDescription(PARTY_BY_TOTAL_MEMBERS_BASED_ON_ROLES_IN_DEPARTMENTS_COMMITTEES_AND_PARLIAMENT);
134 
135 		final MenuItem chartByTopic = partynMenuItem.addItem(CHART_BY_TOPIC_TEXT, FontAwesome.GROUP, null);
136 
137 
138 		chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT,FontAwesome.GROUP,
139 				COMMAND_CHARTS_CURRENT_GOVERNMENT_PARTIES);
140 
141 		chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_HEAD_COUNT,FontAwesome.GROUP,
142 				COMMAND_CHARTS_CURRENT_COMMITTEES);
143 
144 		chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_PARLIAMENT_HEAD_COUNT,FontAwesome.GROUP,
145 				COMMAND_CHARTS_CURRENT_PARTIES);
146 		chartByTopic.addItem(ALL_PARTIES_TOTAL_DAYS_SERVED_IN_PARLIAMENT,FontAwesome.GROUP,
147 				COMMAND_CHARTS_ALL_PARTIES);
148 
149 		partynMenuItem.addItem(PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP,
150 				COMMAND_PAGEVISITHISTORY);
151 	}
152 
153 
154 	@Override
155 	public void createOverviewPage(final VerticalLayout panelContent) {
156 		final GridLayout grid = createGridLayout(panelContent);
157 
158 		createButtonLink(grid,TOTAL_MEMBERS,FontAwesome.GROUP,
159 				COMMAND_DATAGRID, "Default description");
160 		createButtonLink(grid,CURRENT_PARTIES_ACTIVE_IN_MINISTRIES_HEAD_COUNT_TEXT,FontAwesome.GROUP,
161 				COMMAND_CHARTS_CURRENT_GOVERNMENT_PARTIES, "Default description");
162 
163 		createButtonLink(grid,CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_HEAD_COUNT,FontAwesome.GROUP,
164 				COMMAND_CHARTS_CURRENT_COMMITTEES, "Default description");
165 		createButtonLink(grid,CURRENT_PARTIES_ACTIVE_IN_PARLIAMENT_HEAD_COUNT,FontAwesome.GROUP,
166 				COMMAND_CHARTS_CURRENT_PARTIES, "Default description");
167 		createButtonLink(grid,ALL_PARTIES_TOTAL_DAYS_SERVED_IN_PARLIAMENT,FontAwesome.GROUP,
168 				COMMAND_CHARTS_ALL_PARTIES, "Default description");
169 
170 		createButtonLink(grid,PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP,
171 				COMMAND_PAGEVISITHISTORY, "Default description");
172 
173 	}
174 
175 
176 }