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.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.CommonsViews;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.PageMode;
29  import com.vaadin.ui.Layout;
30  import com.vaadin.ui.MenuBar;
31  import com.vaadin.ui.Panel;
32  import com.vaadin.ui.VerticalLayout;
33  
34  /**
35   * The Class MainViewPageVisitHistoryPageModContentFactoryImpl.
36   */
37  @Component
38  public final class MainViewPageVisitHistoryPageModContentFactoryImpl extends AbstractPageModContentFactoryImpl {
39  
40  	/** The Constant CITIZEN_INTELLIGENCE_AGENCY_MAIN. */
41  	private static final String CITIZEN_INTELLIGENCE_AGENCY_MAIN = "Citizen Intelligence Agency::Main";
42  
43  	/** The Constant NAME. */
44  	public static final String NAME = CommonsViews.MAIN_VIEW_NAME;
45  
46  	/**
47  	 * Instantiates a new main view page visit history page mod content factory
48  	 * impl.
49  	 */
50  	public MainViewPageVisitHistoryPageModContentFactoryImpl() {
51  		super();
52  	}
53  
54  	@Override
55  	public boolean matches(final String page, final String parameters) {
56  		return NAME.equals(page)
57  				&& (!StringUtils.isEmpty(parameters) && parameters.contains(PageMode.PAGEVISITHISTORY.toString()));
58  	}
59  
60  	@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
61  	@Override
62  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
63  		final VerticalLayout content = createPanelContent();
64  
65  		final String pageId = getPageId(parameters);
66  
67  		panel.setCaption(CITIZEN_INTELLIGENCE_AGENCY_MAIN);
68  
69  		getMenuItemFactory().createMainPageMenuBar(menuBar);
70  
71  		createPageVisitHistory(NAME,pageId,content);
72  
73  		panel.setCaption(CITIZEN_INTELLIGENCE_AGENCY_MAIN);
74  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_MAIN_VIEW, ApplicationEventGroup.USER,
75  				CommonsViews.MAIN_VIEW_NAME, parameters, pageId);
76  
77  
78  		return content;
79  
80  	}
81  
82  }