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.admin.datasummary.pagemode;
20  
21  import org.springframework.beans.factory.annotation.Autowired;
22  import org.springframework.security.access.annotation.Secured;
23  import org.springframework.stereotype.Component;
24  
25  import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
26  import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
27  import com.hack23.cia.web.impl.ui.application.views.common.tablefactory.TableFactory;
28  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.AdminViews;
29  import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.RefreshDataViewsClickListener;
30  import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.UpdateSearchIndexClickListener;
31  import com.vaadin.server.FontAwesome;
32  import com.vaadin.ui.Button;
33  import com.vaadin.ui.Layout;
34  import com.vaadin.ui.MenuBar;
35  import com.vaadin.ui.Panel;
36  import com.vaadin.ui.Table;
37  import com.vaadin.ui.VerticalLayout;
38  
39  /**
40   * The Class DataSummaryOverviewPageModContentFactoryImpl.
41   */
42  @Component
43  public final class DataSummaryOverviewPageModContentFactoryImpl extends AbstractDataSummaryPageModContentFactoryImpl {
44  
45  	/** The Constant NAME. */
46  	public static final String NAME = AdminViews.ADMIN_DATA_SUMMARY_VIEW_NAME;
47  
48  	/** The Constant UPDATE_SEARCH_INDEX. */
49  	private static final String UPDATE_SEARCH_INDEX = "Update Search Index";
50  
51  	/** The Constant REFRESH_VIEWS. */
52  	private static final String REFRESH_VIEWS = "Refresh Views";
53  
54  	/** The Constant ADMIN_DATA_SUMMARY. */
55  	private static final String ADMIN_DATA_SUMMARY = "Admin Data Summary";
56  
57  	/** The table factory. */
58  	@Autowired
59  	private TableFactory tableFactory;
60  
61  	/**
62  	 * Instantiates a new data summary overview page mod content factory impl.
63  	 */
64  	public DataSummaryOverviewPageModContentFactoryImpl() {
65  		super();
66  	}
67  
68  	@Override
69  	public boolean matches(final String page, final String parameters) {
70  		return NAME.equals(page);
71  	}
72  
73  	@Secured({ "ROLE_ADMIN" })
74  	@Override
75  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
76  		final VerticalLayout content = createPanelContent();
77  
78  		getMenuItemFactory().createMainPageMenuBar(menuBar);
79  
80  		LabelFactory.createHeader2Label(content,ADMIN_DATA_SUMMARY);
81  
82  		final Table createDataSummaryTable = tableFactory.createDataSummaryTable();
83  		content.addComponent(createDataSummaryTable);
84  		content.setExpandRatio(createDataSummaryTable, ContentRatio.LARGE);
85  
86  		content.setSizeFull();
87  		content.setMargin(false);
88  		content.setSpacing(true);
89  
90  		final Button refreshViewsButton = new Button(REFRESH_VIEWS,FontAwesome.REFRESH);
91  
92  		refreshViewsButton.addClickListener(new RefreshDataViewsClickListener());
93  
94  		content.addComponent(refreshViewsButton);
95  		content.setExpandRatio(refreshViewsButton, ContentRatio.SMALL);
96  
97  		final Button updateSearchIndexButton = new Button(UPDATE_SEARCH_INDEX,FontAwesome.REFRESH);
98  
99  		updateSearchIndexButton.addClickListener(new UpdateSearchIndexClickListener());
100 
101 		content.addComponent(updateSearchIndexButton);
102 		content.setExpandRatio(updateSearchIndexButton, ContentRatio.SMALL);
103 
104 		return content;
105 
106 	}
107 
108 }