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.user.party.pagemode;
20  
21  import org.apache.commons.lang3.StringUtils;
22  import org.springframework.security.access.annotation.Secured;
23  import org.springframework.stereotype.Component;
24  
25  import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
26  import com.hack23.cia.web.impl.ui.application.action.ViewAction;
27  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
29  import com.vaadin.ui.Layout;
30  import com.vaadin.ui.MenuBar;
31  import com.vaadin.ui.Panel;
32  import com.vaadin.ui.TextArea;
33  import com.vaadin.ui.VerticalLayout;
34  
35  /**
36   * The Class PartyRankingOverviewPageModContentFactoryImpl.
37   */
38  @Component
39  public final class PartyRankingOverviewPageModContentFactoryImpl extends AbstractPartyRankingPageModContentFactoryImpl {
40  
41  	/** The Constant NAME. */
42  	public static final String NAME = UserViews.PARTY_RANKING_VIEW_NAME;
43  
44  	/** The Constant OVERVIEW. */
45  	private static final String OVERVIEW = "overview";
46  
47  
48  	/**
49  	 * Instantiates a new party ranking overview page mod content factory impl.
50  	 */
51  	public PartyRankingOverviewPageModContentFactoryImpl() {
52  		super();
53  	}
54  
55  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
56  	@Override
57  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
58  		final VerticalLayout panelContent = createPanelContent();
59  
60  		getPartyRankingMenuItemFactory().createPartyRankingMenuBar(menuBar);
61  
62  		final String pageId = getPageId(parameters);
63  
64  		panelContent.addComponent(createDescription());
65  
66  		getPartyRankingMenuItemFactory().createOverviewPage(panelContent);
67  
68  		panel.setCaption(OVERVIEW + parameters);
69  
70  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
71  				parameters, pageId);
72  
73  		return panelContent;
74  
75  	}
76  
77  	/**
78  	 * Creates the description.
79  	 *
80  	 * @return the text area
81  	 */
82  	private static TextArea createDescription() {
83  		final TextArea totalpartytoplistLabel = new TextArea(
84  				"Party Ranking by topic",
85  				"Time served in Parliament:ALL:CURRENT:"
86  						+ "\nTime served in Committees:ALL:CURRENT:"
87  						+ "\nTime served in Government:ALL:CURRENT:"
88  						+ "\nTop document author NR:ALL:YEAR:CURRENT:*FILTER:DocumnetType"
89  						+ "\nTop document author SIZE:YEAR:ALL:CURRENT:*FILTER:DocumnetType"
90  
91  						+ "\nTop votes NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
92  						+ "\nTop vote winner NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
93  						+ "\nTop vote party rebel NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
94  						+ "\nTop vote presence NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart"
95  						+ "\nSearch by name");
96  		totalpartytoplistLabel.setSizeFull();
97  		totalpartytoplistLabel.setStyleName("Level2Header");
98  		return totalpartytoplistLabel;
99  	}
100 
101 
102 	@Override
103 	public boolean matches(final String page, final String parameters) {
104 		return NAME.equals(page) && (StringUtils.isEmpty(parameters) || parameters.contains(PageMode.OVERVIEW.toString()));
105 	}
106 
107 
108 }