View Javadoc

1   /*
2    * Copyright 2010 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: AbstractPanel.java 5440 2011-04-26 18:57:51Z pether $
17   *  $HeadURL: https://cia.svn.sourceforge.net/svnroot/cia/trunk/citizen-intelligence-agency/src/main/java/com/hack23/cia/web/impl/ui/page/common/panel/AbstractPanel.java $
18  */
19  package com.hack23.cia.web.impl.ui.page.common.panel;
20  
21  import org.slf4j.Logger;
22  import org.slf4j.LoggerFactory;
23  import org.vaadin.navigator7.NavigableApplication;
24  
25  import com.hack23.cia.service.api.ApplicationManager;
26  import com.hack23.cia.web.impl.ui.common.ApplicationUserState;
27  import com.hack23.cia.web.impl.ui.common.ApplicationUserStateHolder;
28  import com.vaadin.ui.Component;
29  import com.vaadin.ui.Panel;
30  
31  /**
32   * The Class AbstractPanel.
33   */
34  public abstract class AbstractPanel extends Panel {
35  
36  	/** The Constant serialVersionUID. */
37  	private static final long serialVersionUID = 1L;
38  
39  	/** The user state. */
40  	private final ApplicationUserState userState;
41  
42  	/** The application manager. */
43  	private final ApplicationManager applicationManager;
44  
45  	protected final static Logger LOGGER = LoggerFactory
46  	.getLogger(AbstractPanel.class);
47  
48  	/**
49  	 * Instantiates a new abstract panel.
50  	 */
51  	public AbstractPanel() {
52  		super();
53  		userState= ApplicationUserStateHolder.getUserState();
54  		applicationManager = ApplicationUserStateHolder.getUserState().getApplicationManager();
55  	}
56  
57  	/**
58  	 * Gets the application manager.
59  	 *
60  	 * @return the application manager
61  	 */
62  	protected final ApplicationManager getApplicationManager() {
63  		return applicationManager;
64  	}
65  
66  	/**
67  	 * Gets the user state.
68  	 *
69  	 * @return the user state
70  	 */
71  	protected final ApplicationUserState getUserState() {
72  		return userState;
73  	}
74  
75  	/* (non-Javadoc)
76  	 * @see com.hack23.cia.web.impl.ui.page.Page#navigateTo(java.lang.Class)
77  	 */
78  	/**
79  	 * Navigate to.
80  	 *
81  	 * @param page
82  	 *            the page
83  	 */
84  	protected final void navigateTo(final Class<? extends Component> page) {
85  		NavigableApplication.getCurrentNavigableAppLevelWindow().getNavigator().navigateTo(page);
86  
87  	}
88  
89  	/* (non-Javadoc)
90  	 * @see com.hack23.cia.web.impl.ui.page.Page#navigateTo(java.lang.Class, java.lang.String)
91  	 */
92  	/**
93  	 * Navigate to.
94  	 *
95  	 * @param page
96  	 *            the page
97  	 * @param params
98  	 *            the params
99  	 */
100 	protected final void navigateTo(final Class<? extends Component> page,final String params) {
101 		NavigableApplication.getCurrentNavigableAppLevelWindow().getNavigator().navigateTo(page,params);
102 	}
103 
104 	/**
105 	 * Translate from english.
106 	 *
107 	 * @param string
108 	 *            the string
109 	 * @return the string
110 	 */
111 	protected final String translateFromEnglish(final String string) {
112 		return userState.translateFromEnglish(string);
113 	}
114 
115 
116 }