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.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 CommitteeRankingMenuItemFactoryImpl.
38   */
39  @Service
40  public final class CommitteeRankingMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl
41  		implements CommitteeRankingMenuItemFactory {
42  
43  	/** The Constant COMMAND_PAGEVISIT_HISTORY. */
44  	private static final PageModeMenuCommand COMMAND_PAGEVISIT_HISTORY = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
45  			PageMode.PAGEVISITHISTORY);
46  
47  	/** The Constant COMMAND_ALL_COMMITTEES_BY_HEADCOUNT. */
48  	private static final PageModeMenuCommand COMMAND_ALL_COMMITTEES_BY_HEADCOUNT = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
49  			PageMode.CHARTS,ChartIndicators.ALLCOMMITTEESBYHEADCOUNT.toString());
50  
51  	/** The Constant COMMAND_COMMITTEES_BY_PARTY. */
52  	private static final PageModeMenuCommand COMMAND_COMMITTEES_BY_PARTY = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
53  			PageMode.CHARTS,ChartIndicators.COMMITTEESBYPARTY.toString());
54  
55  	/** The Constant COMMAND_CURRENT_COMMITTEES_BY_HEADCOUNT. */
56  	private static final PageModeMenuCommand COMMAND_CURRENT_COMMITTEES_BY_HEADCOUNT = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
57  			PageMode.CHARTS,ChartIndicators.CURRENTCOMMITTEESBYHEADCOUNT.toString());
58  
59  	/** The Constant COMMAND_CURRENT_COMMITTEES_BY_PARTY_HEADCOUNT. */
60  	private static final PageModeMenuCommand COMMAND_CURRENT_COMMITTEES_BY_PARTY_HEADCOUNT = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
61  			PageMode.CHARTS,ChartIndicators.CURRENTCOMMITTEESBYPARTYHEADCOUNT.toString());
62  
63  
64  	/** The Constant COMMAND_OVERVIEW. */
65  	private static final PageModeMenuCommand COMMAND_OVERVIEW = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
66  			PageMode.OVERVIEW);
67  
68  	/** The Constant COMMAND_DATAGRID. */
69  	private static final PageModeMenuCommand COMMAND_DATAGRID = new PageModeMenuCommand(UserViews.COMMITTEE_RANKING_VIEW_NAME,
70  			PageMode.DATAGRID);
71  
72  	/** The Constant ALL_COMMITTEES_TOTAL_MEMBERS. */
73  	private static final String ALL_COMMITTEES_TOTAL_MEMBERS = "All committees, total members";
74  
75  	/**
76  	 * The Constant
77  	 * CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES.
78  	 */
79  	private static final String CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES = "Current parties active in committees, total days served in committees";
80  
81  	/**
82  	 * The Constant CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS.
83  	 */
84  	private static final String CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS = "Current parties active in committees, current assignments";
85  
86  	/** The Constant CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_POLTICIAL_DAYS. */
87  	private static final String CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_POLTICIAL_DAYS = "Current and past member and summary of polticial days ";
88  
89  	/** The Constant CURRENT_COMMITTEES_CURRENT_MEMBERS_TEXT. */
90  	private static final String CURRENT_COMMITTEES_CURRENT_MEMBERS_TEXT = "Current committees, current members";
91  
92  	/** The Constant POLITICAL_WORK_SUMMARY_TEXT. */
93  	private static final String POLITICAL_WORK_SUMMARY_TEXT = "Political Work Summary";
94  
95  	/** The Constant COMMITTEE_RANKING_TEXT. */
96  	private static final String COMMITTEE_RANKING_TEXT = "Committee Ranking";
97  
98  	/** The Constant RANKING_LIST_BY_TOPIC_TEXT. */
99  	private static final String RANKING_LIST_BY_TOPIC_TEXT = "Ranking list by topic";
100 
101 	/** The Constant CHART_BY_TOPIC_TEXT. */
102 	private static final String CHART_BY_TOPIC_TEXT = "Chart by topic";
103 
104 	/** The Constant OVERVIEW_TEXT. */
105 	private static final String OVERVIEW_TEXT = "Overview";
106 
107 	/** The Constant PAGE_VISIT_HISTORY_TEXT. */
108 	private static final String PAGE_VISIT_HISTORY_TEXT = "Page Visit History";
109 
110 	/** The application menu item factory. */
111 	@Autowired
112 	private ApplicationMenuItemFactory applicationMenuItemFactory;
113 
114 	/**
115 	 * Instantiates a new committee ranking menu item factory impl.
116 	 */
117 	public CommitteeRankingMenuItemFactoryImpl() {
118 		super();
119 	}
120 
121 	/**
122 	 * Creates the committeee ranking menu bar.
123 	 *
124 	 * @param menuBar
125 	 *            the menu bar
126 	 */
127 	@Override
128 	public void createCommitteeeRankingMenuBar(final MenuBar menuBar) {
129 		initApplicationMenuBar(menuBar);
130 
131 		applicationMenuItemFactory.addRankingMenu(menuBar);
132 
133 		createCommitteeRankingTopics(menuBar.addItem(COMMITTEE_RANKING_TEXT, null, null));
134 	}
135 
136 	/**
137 	 * Creates the committee ranking topics.
138 	 *
139 	 * @param committeeMenuItem
140 	 *            the committee menu item
141 	 */
142 	@Override
143 	public void createCommitteeRankingTopics(final MenuItem committeeMenuItem) {
144 		committeeMenuItem.addItem(OVERVIEW_TEXT, FontAwesome.GROUP, COMMAND_OVERVIEW);
145 
146 		final MenuItem listByTopic = committeeMenuItem.addItem(RANKING_LIST_BY_TOPIC_TEXT, FontAwesome.GROUP, null);
147 
148 		final MenuItem listItem = listByTopic.addItem(POLITICAL_WORK_SUMMARY_TEXT,FontAwesome.GROUP, COMMAND_DATAGRID);
149 		listItem.setDescription(CURRENT_AND_PAST_MEMBER_AND_SUMMARY_OF_POLTICIAL_DAYS);
150 
151 		final MenuItem chartByTopic = committeeMenuItem.addItem(CHART_BY_TOPIC_TEXT, FontAwesome.GROUP, null);
152 
153 
154 		chartByTopic.addItem(CURRENT_COMMITTEES_CURRENT_MEMBERS_TEXT,FontAwesome.GROUP, COMMAND_CURRENT_COMMITTEES_BY_HEADCOUNT);
155 		chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS,FontAwesome.GROUP, COMMAND_COMMITTEES_BY_PARTY);
156 		chartByTopic.addItem(CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES,FontAwesome.GROUP, COMMAND_CURRENT_COMMITTEES_BY_PARTY_HEADCOUNT);
157 
158 		chartByTopic.addItem(ALL_COMMITTEES_TOTAL_MEMBERS,FontAwesome.GROUP, COMMAND_ALL_COMMITTEES_BY_HEADCOUNT);
159 
160 		committeeMenuItem.addItem(PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP, COMMAND_PAGEVISIT_HISTORY);
161 
162 	}
163 
164 	/**
165 	 * Creates the overview page.
166 	 *
167 	 * @param panelContent
168 	 *            the panel content
169 	 */
170 	@Override
171 	public void createOverviewPage(final VerticalLayout panelContent) {
172 		final GridLayout grid = createGridLayout(panelContent);
173 
174 
175 		createButtonLink(grid,POLITICAL_WORK_SUMMARY_TEXT,FontAwesome.GROUP, COMMAND_DATAGRID, "Default description");
176 		createButtonLink(grid,CURRENT_COMMITTEES_CURRENT_MEMBERS_TEXT,FontAwesome.GROUP, COMMAND_CURRENT_COMMITTEES_BY_HEADCOUNT, "Default description");
177 
178 		createButtonLink(grid,CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_CURRENT_ASSIGNMENTS,FontAwesome.GROUP, COMMAND_COMMITTEES_BY_PARTY, "Default description");
179 		createButtonLink(grid,CURRENT_PARTIES_ACTIVE_IN_COMMITTEES_TOTAL_DAYS_SERVED_IN_COMMITTEES,FontAwesome.GROUP, COMMAND_CURRENT_COMMITTEES_BY_PARTY_HEADCOUNT, "Default description");
180 		createButtonLink(grid,ALL_COMMITTEES_TOTAL_MEMBERS,FontAwesome.GROUP, COMMAND_ALL_COMMITTEES_BY_HEADCOUNT, "Default description");
181 
182 		createButtonLink(grid,PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP, COMMAND_PAGEVISIT_HISTORY, "Default description");
183 
184 	}
185 
186 
187 }