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