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.system.pagemode;
20  
21  import org.springframework.security.access.annotation.Secured;
22  import org.springframework.stereotype.Component;
23  
24  import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
25  import com.hack23.cia.web.impl.ui.application.action.ViewAction;
26  import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
27  import com.hack23.cia.web.impl.ui.application.views.common.viewnames.AdminViews;
28  import com.vaadin.server.ExternalResource;
29  import com.vaadin.ui.BrowserFrame;
30  import com.vaadin.ui.Layout;
31  import com.vaadin.ui.MenuBar;
32  import com.vaadin.ui.Panel;
33  import com.vaadin.ui.VerticalLayout;
34  
35  /**
36   * The Class AdminMonitoringPageModContentFactoryImpl.
37   */
38  @Component
39  public final class AdminMonitoringPageModContentFactoryImpl extends AbstractAdminSystemPageModContentFactoryImpl {
40  
41  	/** The Constant MONITORING_CONTEXT_PATH. */
42  	private static final String MONITORING_CONTEXT_PATH = "./monitoring";
43  
44  	/** The Constant ADMIN_MONITORING. */
45  	private static final String ADMIN_MONITORING = "Admin Monitoring";
46  
47  	/** The Constant NAME. */
48  	public static final String NAME = AdminViews.ADMIN_MONITORING_VIEW_NAME;
49  
50  	/**
51  	 * Instantiates a new admin agency page mod content factory impl.
52  	 */
53  	public AdminMonitoringPageModContentFactoryImpl() {
54  		super();
55  	}
56  
57  	@Override
58  	public boolean matches(final String page, final String parameters) {
59  		return NAME.equals(page);
60  	}
61  
62  	@Secured({ "ROLE_ADMIN" })
63  	@Override
64  	public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
65  		final VerticalLayout content = createPanelContent();
66  
67  		final String pageId = getPageId(parameters);
68  
69  		getMenuItemFactory().createMainPageMenuBar(menuBar);
70  
71  		final BrowserFrame browser = new BrowserFrame(ADMIN_MONITORING, new ExternalResource(MONITORING_CONTEXT_PATH));
72  		browser.setSizeFull();
73  
74  		content.addComponent(browser);
75  		content.setExpandRatio(browser, ContentRatio.FULL_SIZE);
76  
77  		getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_MONITORING_VIEW, ApplicationEventGroup.ADMIN,
78  				NAME, null, pageId);
79  
80  		return content;
81  
82  	}
83  
84  }