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 org.directdemocracyportal.democracy.web.views.dialogs;
6   
7   import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
8   import org.directdemocracyportal.democracy.web.ImageConstants;
9   import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
10  
11  import thinwire.ui.Image;
12  import thinwire.ui.Label;
13  import thinwire.ui.Panel;
14  import thinwire.ui.layout.TableLayout;
15  
16  
17  /***
18   * The Class ErrorMessageBox.
19   */
20  public class ErrorMessageBox extends Panel
21  {
22      
23      /*** The error message. */
24      private Label errorMessage = new Label();
25  
26      /***
27       * Instantiates a new error message box.
28       */
29      public ErrorMessageBox() {
30          super();
31          setVisible(false);
32          setLayout(new TableLayout(new double[][] { {16, 200}, // Column Widths
33                  { 16 } }, // Row Heights
34                  2, // Margin around edge of container
35                  4)); // Spacing between cells
36  
37          Image errorImage = new Image(ImageConstants.ACTION_ERROR);
38          errorImage.setSize(ImageConstants.ICON_SIZE, ImageConstants.ICON_SIZE);
39          errorImage.setLimit("0,0");
40          getChildren().add(errorImage);
41  
42          errorMessage.setLimit("1,0");
43          errorMessage.setSize(200, 16);
44          getChildren().add(errorMessage);
45      }
46  
47      /***
48       * Display error message.
49       *
50       * @param message the message
51       */
52      public void displayErrorMessage(String message) {
53          errorMessage.setText(" " + ApplicationMessageHolder
54                  .getMessage(MessageConstans.ERROR_MESSAGE) + " : " + message);
55          setVisible(true);
56      }
57  }