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   
6   package com.hack23.cia.web.views.components.panels;
7   
8   import thinwire.ui.Image;
9   import thinwire.ui.Label;
10  import thinwire.ui.Panel;
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  import com.hack23.cia.web.common.ImageConstants;
16  
17  /***
18   * The Class ErrorMessagePanel.
19   */
20  public class ErrorMessagePanel extends Panel {
21  
22      /*** The error message. */
23      private final Label errorMessage = new Label();
24      
25      /*** The user session dto. */
26      private final UserSessionDTO userSessionDTO;
27  
28      /***
29       * Instantiates a new error message panel.
30       *
31       * @param userSessionDTO the user session dto
32       * @param message the message
33       */
34      public ErrorMessagePanel(final UserSessionDTO userSessionDTO,final String message) {
35          super();
36          this.userSessionDTO = userSessionDTO;
37          setVisible(false);
38  
39          setLayout(new TableLayout(new double[][] { { 0, 0 }, // Column Widths
40                  { 0 } }, // Row Heights
41                  2, // Margin around edge of container
42                  4)); // Spacing between cells
43  
44          final Image errorImage = new Image(ImageConstants.ACTION_ERROR);
45          errorImage.setSize(ImageConstants.ICON_SIZE, ImageConstants.ICON_SIZE);
46          errorImage.setLimit("0,0"); //$NON-NLS-1$
47          getChildren().add(errorImage);
48  
49          errorMessage.setLimit("1,0"); //$NON-NLS-1$
50          getChildren().add(errorMessage);
51  
52          errorMessage.setText(" " //$NON-NLS-1$
53                  + userSessionDTO
54                          .getLanguageResource(Agency.LanguageContentKey.ERROR_MESSAGE) + " : " //$NON-NLS-1$
55                  + message);
56          setVisible(true);
57      }
58  }