View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package com.hack23.cia.web.views.components.panels;
6   
7   import thinwire.ui.Component;
8   import thinwire.ui.Panel;
9   import thinwire.ui.TabFolder;
10  import thinwire.ui.TabSheet;
11  import thinwire.ui.layout.TableLayout;
12  
13  import com.hack23.cia.model.application.dto.common.UserSessionDTO;
14  import com.hack23.cia.model.application.impl.common.Agency;
15  
16  /***
17   * The Class SimpleComponentPanel.
18   */
19  public class SimpleComponentPanel extends Panel {
20  
21  	/*** The tab folder. */
22  	private final TabFolder tabFolder = new TabFolder();
23  	
24  	/*** The user session dto. */
25  	private UserSessionDTO userSessionDTO;
26  	
27      /***
28       * Instantiates a new simple component panel.
29       *
30       * @param title the title
31       * @param titleImage the title image
32       * @param component the component
33       */
34      public SimpleComponentPanel(final String title, final String titleImage,
35              final Component component) {
36          super();
37  
38          setLayout(new TableLayout(new double[][] { { 0 }, // Column Widths
39                  { 0 } }, // Row Heights
40                  1, // Margin around edge of container
41                  5)); // Spacing between cells
42  
43          final TabSheet componentTabSheet = new TabSheet();
44          tabFolder.getChildren().add(componentTabSheet);
45          componentTabSheet.setText(title);
46          componentTabSheet.setImage(titleImage);
47          componentTabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
48                  // Widths
49                  { 0 } }, // Row Heights
50                  1, // Margin around edge of container
51                  5)); // Spacing between cells
52  
53          component.setLimit("0,0"); //$NON-NLS-1$
54          componentTabSheet.getChildren().add(component);
55  
56          tabFolder.setLimit("0,0,1,1");
57          getChildren().add(tabFolder);
58      }
59  
60      /***
61       * Instantiates a new simple component panel.
62       *
63       * @param title the title
64       * @param titleImage the title image
65       * @param component the component
66       * @param title2 the title2
67       * @param titleImage2 the title image2
68       * @param component2 the component2
69       * @param userSessionDTO the user session dto
70       */
71      public SimpleComponentPanel(final String title, final String titleImage,
72      		final Component component,final String title2, final String titleImage2,
73      		final Component component2,final UserSessionDTO userSessionDTO) {
74      	this(title,titleImage,component);
75  		this.userSessionDTO = userSessionDTO;
76      	addComponentPanel(title2, titleImage2, component2);
77      	 tabFolder.getChildren().add(createTabFolderCitizenOperation(userSessionDTO));
78      }
79  
80      
81  	/***
82  	 * Adds the component panel.
83  	 *
84  	 * @param title the title
85  	 * @param titleImage the title image
86  	 * @param component the component
87  	 */
88      public final void addComponentPanel(final String title, final String titleImage,
89              final Component component) {
90  
91          final TabSheet componentTabSheet = new TabSheet();
92          tabFolder.getChildren().add(componentTabSheet);
93          componentTabSheet.setText(title);
94          componentTabSheet.setImage(titleImage);
95          componentTabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
96                  // Widths
97                  { 0 } }, // Row Heights
98                  1, // Margin around edge of container
99                  5)); // Spacing between cells
100 
101         component.setLimit("0,0"); //$NON-NLS-1$
102         componentTabSheet.getChildren().add(component);        
103     }    
104     
105     /***
106      * Creates the tab folder citizen operation.
107      *
108      * @param userSessionDTO the user session dto
109      * @return the tab sheet
110      */
111     private TabSheet createTabFolderCitizenOperation(final UserSessionDTO userSessionDTO) {
112     	  this.userSessionDTO = userSessionDTO;
113 		final TabSheet tabSheet = new TabSheet();
114 
115           tabSheet.setText(userSessionDTO
116                   .getLanguageResource(Agency.LanguageContentKey.CITIZEN_OPERATION));
117           tabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
118                   // Widths
119                   { 0 } }, // Row Heights
120                   1, // Margin around edge of container
121                   5)); // Spacing between cells
122 
123           final TabFolder tabFolder = new TabFolder();
124           tabFolder.setLimit("0,0"); //$NON-NLS-1$
125 
126           tabFolder.getChildren().add(
127                   createTabFolderGrading());
128           tabFolder.getChildren().add(
129                   createTabFolderForum());
130           tabFolder.getChildren().add(
131                   createTabFolderOpinions());
132           tabFolder.getChildren().add(
133                   createTabFolderShortComment());
134           tabFolder.getChildren().add(
135                   createTabFolderVote());
136           
137           tabFolder.setCurrentIndex(0);
138           tabSheet.getChildren().add(tabFolder);
139         
140         return tabSheet;
141 	}
142 
143 	/***
144 	 * Creates the tab folder forum.
145 	 *
146 	 * @return the tab sheet
147 	 */
148 	private TabSheet createTabFolderForum() {     
149 		final TabSheet tabSheet = new TabSheet();
150 
151 	        tabSheet.setText(userSessionDTO
152 	                .getLanguageResource(Agency.LanguageContentKey.FORUM));
153 	        tabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
154 	                // Widths
155 	                { 0 } }, // Row Heights
156 	                1, // Margin around edge of container
157 	                5)); // Spacing between cells
158 	        
159 	        return tabSheet;
160 	}
161 
162 
163 	/***
164 	 * Creates the tab folder grading.
165 	 *
166 	 * @return the tab sheet
167 	 */
168 	private TabSheet createTabFolderGrading() {
169 		final TabSheet tabSheet = new TabSheet();
170 
171         tabSheet.setText(userSessionDTO
172                 .getLanguageResource(Agency.LanguageContentKey.GRADING));
173         tabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
174                 // Widths
175                 { 0 } }, // Row Heights
176                 1, // Margin around edge of container
177                 5)); // Spacing between cells
178         
179         return tabSheet;
180 	}
181 
182 	/***
183 	 * Creates the tab folder opinions.
184 	 *
185 	 * @return the tab sheet
186 	 */
187 	private TabSheet createTabFolderOpinions() {
188 		final TabSheet tabSheet = new TabSheet();
189 
190         tabSheet.setText(userSessionDTO
191                 .getLanguageResource(Agency.LanguageContentKey.OPINIONS));
192         tabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
193                 // Widths
194                 { 0 } }, // Row Heights
195                 1, // Margin around edge of container
196                 5)); // Spacing between cells
197         
198         return tabSheet;
199 	}
200 
201 	/***
202 	 * Creates the tab folder short comment.
203 	 *
204 	 * @return the tab sheet
205 	 */
206 	private TabSheet createTabFolderShortComment() {
207 		final TabSheet tabSheet = new TabSheet();
208 
209         tabSheet.setText(userSessionDTO
210                 .getLanguageResource(Agency.LanguageContentKey.SHORT_COMMENT));
211         tabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
212                 // Widths
213                 { 0 } }, // Row Heights
214                 1, // Margin around edge of container
215                 5)); // Spacing between cells
216         
217         return tabSheet;
218 	}
219 
220     /***
221      * Creates the tab folder vote.
222      *
223      * @return the tab sheet
224      */
225     private TabSheet createTabFolderVote() {
226 		final TabSheet tabSheet = new TabSheet();
227 
228         tabSheet.setText(userSessionDTO
229                 .getLanguageResource(Agency.LanguageContentKey.VOTE));
230         tabSheet.setLayout(new TableLayout(new double[][] { { 0 }, // Column
231                 // Widths
232                 { 0 } }, // Row Heights
233                 1, // Margin around edge of container
234                 5)); // Spacing between cells
235         
236         return tabSheet;
237 	}
238 
239     
240     
241 }