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.CommitteeMenuItemFactory;
26  import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.CommitteeRankingMenuItemFactory;
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.CommitteePageMode;
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 CommitteeMenuItemFactoryImpl.
39   */
40  @Service
41  public final class CommitteeMenuItemFactoryImpl extends AbstractMenuItemFactoryImpl implements CommitteeMenuItemFactory {
42  
43  	/** The Constant COMMITTEE_RANKING_TEXT. */
44  	private static final String COMMITTEE_RANKING_TEXT = "Committee Ranking";
45  
46  	/** The Constant DOCUMENT_HISTORY_TEXT. */
47  	private static final String DOCUMENT_HISTORY_TEXT = "Document history";
48  
49  	/** The Constant INDICATORS_TEXT. */
50  	private static final String INDICATORS_TEXT = "Indicators";
51  
52  	/** The Constant CHARTS_TEXT. */
53  	private static final String CHARTS_TEXT = "Charts";
54  
55  	/** The Constant ROLE_GHANT_TEXT. */
56  	private static final String ROLE_GHANT_TEXT = "RoleGhant";
57  
58  	/** The Constant MEMBER_HISTORY_TEXT. */
59  	private static final String MEMBER_HISTORY_TEXT = "Member History";
60  
61  	/** The Constant CURRENT_MEMBERS_TEXT. */
62  	private static final String CURRENT_MEMBERS_TEXT = "Current Members";
63  
64  	/** The Constant ROLES_TEXT. */
65  	private static final String ROLES_TEXT = "Roles";
66  
67  	/** The Constant DOCUMENTS_TEXT. */
68  	private static final String DOCUMENTS_TEXT = "Documents";
69  
70  	/** The Constant DECISION_TYPE_DAILY_SUMMARY_TEXT. */
71  	private static final String DECISION_TYPE_DAILY_SUMMARY_TEXT = "Decision Type Daily Summary";
72  
73  	/** The Constant DECISION_SUMMARY_TEXT. */
74  	private static final String DECISION_SUMMARY_TEXT = "Decision Summary";
75  
76  	/** The Constant BALLOT_DECISION_SUMMARY_TEXT. */
77  	private static final String BALLOT_DECISION_SUMMARY_TEXT = "Ballot Decision Summary";
78  
79  	/** The Constant BALLOTS_TEXT. */
80  	private static final String BALLOTS_TEXT = "Ballots";
81  
82  	/** The Constant DOCUMENT_ACTIVITY_TEXT. */
83  	private static final String DOCUMENT_ACTIVITY_TEXT = "Document Activity";
84  
85  	/** The Constant OVERVIEW_TEXT. */
86  	private static final String OVERVIEW_TEXT = "Overview";
87  
88  	/** The Constant PAGE_VISIT_HISTORY_TEXT. */
89  	private static final String PAGE_VISIT_HISTORY_TEXT = "Page Visit History";
90  
91  	/** The committee ranking menu item factory. */
92  	@Autowired
93  	private CommitteeRankingMenuItemFactory committeeRankingMenuItemFactory;
94  
95  	/** The application menu item factory. */
96  	@Autowired
97  	private ApplicationMenuItemFactory applicationMenuItemFactory;
98  
99  
100 	/**
101 	 * Instantiates a new committee menu item factory impl.
102 	 */
103 	public CommitteeMenuItemFactoryImpl() {
104 		super();
105 	}
106 
107 	@Override
108 	public void createCommitteeeMenuBar(final MenuBar menuBar, final String pageId) {
109 		initApplicationMenuBar(menuBar);
110 
111 		applicationMenuItemFactory.addRankingMenu(menuBar);
112 
113 		committeeRankingMenuItemFactory.createCommitteeRankingTopics(menuBar.addItem(COMMITTEE_RANKING_TEXT, FontAwesome.GROUP, null));
114 
115 		final MenuItem committeeItem = menuBar.addItem("Committee "+ pageId, FontAwesome.GROUP,null);
116 
117 
118 		committeeItem.addItem(OVERVIEW_TEXT, FontAwesome.GROUP,
119 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.OVERVIEW, pageId));
120 		committeeItem.addItem(CHARTS_TEXT, FontAwesome.GROUP,
121 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.CHARTS, pageId));
122 		committeeItem.addItem(INDICATORS_TEXT, FontAwesome.GROUP,
123 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.INDICATORS, pageId));
124 
125 		final MenuItem rolesItem = committeeItem.addItem(ROLES_TEXT, FontAwesome.GROUP, null);
126 
127 		rolesItem.addItem(CURRENT_MEMBERS_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
128 				CommitteePageMode.CURRENT_MEMBERS.toString(), pageId));
129 
130 		rolesItem.addItem(MEMBER_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
131 				CommitteePageMode.MEMBERHISTORY.toString(), pageId));
132 
133 		rolesItem.addItem(ROLE_GHANT_TEXT, FontAwesome.GROUP,
134 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, CommitteePageMode.ROLEGHANT.toString(), pageId));
135 
136 		final MenuItem documentItem = committeeItem.addItem(DOCUMENTS_TEXT, FontAwesome.GROUP, null);
137 
138 		documentItem.addItem(DOCUMENT_ACTIVITY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
139 				CommitteePageMode.DOCUMENTACTIVITY.toString(), pageId));
140 
141 		documentItem.addItem(DOCUMENT_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
142 				CommitteePageMode.DOCUMENT_HISTORY.toString(), pageId));
143 
144 		final MenuItem ballotItem = committeeItem.addItem(BALLOTS_TEXT, FontAwesome.GROUP, null);
145 
146 		ballotItem.addItem(BALLOT_DECISION_SUMMARY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
147 				CommitteePageMode.BALLOTDECISIONSUMMARY.toString(), pageId));
148 
149 		ballotItem.addItem(DECISION_SUMMARY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
150 				CommitteePageMode.DECISIONSUMMARY.toString(), pageId));
151 
152 		ballotItem.addItem(DECISION_TYPE_DAILY_SUMMARY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(
153 				UserViews.COMMITTEE_VIEW_NAME, CommitteePageMode.DECISIONTYPEDAILYSUMMARY.toString(), pageId));
154 
155 		committeeItem.addItem(PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP,
156 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.PAGEVISITHISTORY, pageId));
157 
158 	}
159 
160 	@Override
161 	public void createOverviewPage(final VerticalLayout panelContent, final String pageId) {
162 		final GridLayout grid = createGridLayout(panelContent);
163 
164 		createButtonLink(grid,OVERVIEW_TEXT, FontAwesome.GROUP,
165 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.OVERVIEW, pageId), "Default description");
166 		createButtonLink(grid,CHARTS_TEXT, FontAwesome.GROUP,
167 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.CHARTS, pageId), "Default description");
168 		createButtonLink(grid,INDICATORS_TEXT, FontAwesome.GROUP,
169 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.INDICATORS, pageId), "Default description");
170 
171 
172 		createButtonLink(grid,CURRENT_MEMBERS_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
173 				CommitteePageMode.CURRENT_MEMBERS.toString(), pageId), "Default description");
174 
175 		createButtonLink(grid,MEMBER_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
176 				CommitteePageMode.MEMBERHISTORY.toString(), pageId), "Default description");
177 
178 		createButtonLink(grid,ROLE_GHANT_TEXT, FontAwesome.GROUP,
179 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, CommitteePageMode.ROLEGHANT.toString(), pageId), "Default description");
180 
181 
182 		createButtonLink(grid,DOCUMENT_ACTIVITY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
183 				CommitteePageMode.DOCUMENTACTIVITY.toString(), pageId), "Default description");
184 
185 		createButtonLink(grid,DOCUMENT_HISTORY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
186 				CommitteePageMode.DOCUMENT_HISTORY.toString(), pageId), "Default description");
187 
188 
189 		createButtonLink(grid,BALLOT_DECISION_SUMMARY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
190 				CommitteePageMode.BALLOTDECISIONSUMMARY.toString(), pageId), "Default description");
191 
192 		createButtonLink(grid,DECISION_SUMMARY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME,
193 				CommitteePageMode.DECISIONSUMMARY.toString(), pageId), "Default description");
194 
195 		createButtonLink(grid,DECISION_TYPE_DAILY_SUMMARY_TEXT, FontAwesome.GROUP, new PageModeMenuCommand(
196 				UserViews.COMMITTEE_VIEW_NAME, CommitteePageMode.DECISIONTYPEDAILYSUMMARY.toString(), pageId), "Default description");
197 
198 		createButtonLink(grid,PAGE_VISIT_HISTORY_TEXT, FontAwesome.GROUP,
199 				new PageModeMenuCommand(UserViews.COMMITTEE_VIEW_NAME, PageMode.PAGEVISITHISTORY, pageId), "Default description");
200 
201 
202 	}
203 
204 
205 }