View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.util.mvc.utils;
35  
36  import fr.paris.lutece.portal.service.i18n.I18nService;
37  
38  import java.util.Locale;
39  
40  
41  /**
42   * MVCMessageBox
43   */
44  public class MVCMessageBox
45  {
46      public static final int INFO = 0;
47      public static final int QUESTION = 1;
48      public static final int WARNING = 2;
49      public static final int ERROR = 3;
50      private int _nStyle;
51      private String _strTitle;
52      private String _strMessage;
53      private String _strLabelButton1;
54      private String _strUrlButton1;
55      private String _strLabelKeyButton1;
56      private String _strLabelButton2;
57      private String _strUrlButton2;
58      private String _strLabelKeyButton2;
59      private String _strTemplate;
60      private String _strTitleKey;
61      private String _strMessageKey;
62  
63      /**
64       * @return the style
65       */
66      public int getStyle(  )
67      {
68          return _nStyle;
69      }
70  
71      /**
72       * @param nStyle the style to set
73       */
74      public void setStyle( int nStyle )
75      {
76          _nStyle = nStyle;
77      }
78  
79      /**
80       * @return the title
81       */
82      public String getTitle(  )
83      {
84          return _strTitle;
85      }
86  
87      /**
88       * @param strTitle the title to set
89       */
90      public void setTitle( String strTitle )
91      {
92          _strTitle = strTitle;
93      }
94  
95      /**
96       * @return the message
97       */
98      public String getMessage(  )
99      {
100         return _strMessage;
101     }
102 
103     /**
104      * @param strMessage the message to set
105      */
106     public void setMessage( String strMessage )
107     {
108         _strMessage = strMessage;
109     }
110 
111     /**
112      * @return the strLabelButton1
113      */
114     public String getLabelButton1(  )
115     {
116         return _strLabelButton1;
117     }
118 
119     /**
120      * @param strLabelButton1 the strLabelButton1 to set
121      */
122     public void setLabelButton1( String strLabelButton1 )
123     {
124         _strLabelButton1 = strLabelButton1;
125     }
126 
127     /**
128      * @return the  strUrlButton1
129      */
130     public String getUrlButton1(  )
131     {
132         return _strUrlButton1;
133     }
134 
135     /**
136      * @param  strUrlButton1 the  strUrlButton1 to set
137      */
138     public void setUrlButton1( String strUrlButton1 )
139     {
140         _strUrlButton1 = strUrlButton1;
141     }
142 
143     /**
144      * @return the label
145      */
146     public String getLabelButton2(  )
147     {
148         return _strLabelButton2;
149     }
150 
151     /**
152      * @param strLabelButton2 the label to set
153      */
154     public void setLabelButton2( String strLabelButton2 )
155     {
156         _strLabelButton2 = strLabelButton2;
157     }
158 
159     /**
160      * @return the  strUrlButton2
161      */
162     public String getUrlButton2(  )
163     {
164         return _strUrlButton2;
165     }
166 
167     /**
168      * @param  strUrlButton2 the  strUrlButton2 to set
169      */
170     public void setUrlButton2( String strUrlButton2 )
171     {
172         _strUrlButton2 = strUrlButton2;
173     }
174 
175     /**
176      * @return the _strLabelKeyButton1
177      */
178     public String getLabelKeyButton1(  )
179     {
180         return _strLabelKeyButton1;
181     }
182 
183     /**
184      * @param strLabelKeyButton1 the _strLabelKeyButton1 to set
185      */
186     public void setLabelKeyButton1( String strLabelKeyButton1 )
187     {
188         _strLabelKeyButton1 = strLabelKeyButton1;
189     }
190 
191     /**
192      * @return the _strLabelKeyButton2
193      */
194     public String getLabelKeyButton2(  )
195     {
196         return _strLabelKeyButton2;
197     }
198 
199     /**
200      * @param strLabelKeyButton2 the _strLabelKeyButton2 to set
201      */
202     public void setLabelKeyButton2( String strLabelKeyButton2 )
203     {
204         _strLabelKeyButton2 = strLabelKeyButton2;
205     }
206 
207     /**
208      * @return the _strTemplate
209      */
210     public String getTemplate(  )
211     {
212         return _strTemplate;
213     }
214 
215     /**
216      * @param strTemplate the _strTemplate to set
217      */
218     public void setTemplate( String strTemplate )
219     {
220         _strTemplate = strTemplate;
221     }
222 
223     /**
224      * @return the Title key
225      */
226     public String getTitleKey(  )
227     {
228         return _strTitleKey;
229     }
230 
231     /**
232      * @param strTitleKey the Title key to set
233      */
234     public void setTitleKey( String strTitleKey )
235     {
236         this._strTitleKey = strTitleKey;
237     }
238 
239     /**
240      * @return the Message key
241      */
242     public String getMessageKey(  )
243     {
244         return _strMessageKey;
245     }
246 
247     /**
248      * @param strMessageKey the Message key to set
249      */
250     public void setMessageKey( String strMessageKey )
251     {
252         this._strMessageKey = strMessageKey;
253     }
254 
255     /**
256      * Localize value if value's key found
257      * @param locale The locale
258      */
259     public void localize( Locale locale )
260     {
261         _strTitle = ( _strTitleKey != null ) ? I18nService.getLocalizedString( _strTitleKey, locale ) : _strTitle;
262         _strMessage = ( _strMessageKey != null ) ? I18nService.getLocalizedString( _strMessageKey, locale ) : _strMessage;
263         _strLabelButton1 = ( _strLabelKeyButton1 != null )
264             ? I18nService.getLocalizedString( _strLabelKeyButton1, locale ) : _strLabelButton1;
265         _strLabelButton2 = ( _strLabelKeyButton2 != null )
266             ? I18nService.getLocalizedString( _strLabelKeyButton2, locale ) : _strLabelButton2;
267     }
268 }