View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of 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   * MVCMessageBox
42   */
43  public class MVCMessageBox
44  {
45      public static final int INFO = 0;
46      public static final int QUESTION = 1;
47      public static final int WARNING = 2;
48      public static final int ERROR = 3;
49      private int _nStyle;
50      private String _strTitle;
51      private String _strMessage;
52      private String _strLabelButton1;
53      private String _strUrlButton1;
54      private String _strLabelKeyButton1;
55      private String _strLabelButton2;
56      private String _strUrlButton2;
57      private String _strLabelKeyButton2;
58      private String _strTemplate;
59      private String _strTitleKey;
60      private String _strMessageKey;
61  
62      /**
63       * @return the style
64       */
65      public int getStyle( )
66      {
67          return _nStyle;
68      }
69  
70      /**
71       * @param nStyle
72       *            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
89       *            the title to set
90       */
91      public void setTitle( String strTitle )
92      {
93          _strTitle = strTitle;
94      }
95  
96      /**
97       * @return the message
98       */
99      public String getMessage( )
100     {
101         return _strMessage;
102     }
103 
104     /**
105      * @param strMessage
106      *            the message to set
107      */
108     public void setMessage( String strMessage )
109     {
110         _strMessage = strMessage;
111     }
112 
113     /**
114      * @return the strLabelButton1
115      */
116     public String getLabelButton1( )
117     {
118         return _strLabelButton1;
119     }
120 
121     /**
122      * @param strLabelButton1
123      *            the strLabelButton1 to set
124      */
125     public void setLabelButton1( String strLabelButton1 )
126     {
127         _strLabelButton1 = strLabelButton1;
128     }
129 
130     /**
131      * @return the strUrlButton1
132      */
133     public String getUrlButton1( )
134     {
135         return _strUrlButton1;
136     }
137 
138     /**
139      * @param strUrlButton1
140      *            the strUrlButton1 to set
141      */
142     public void setUrlButton1( String strUrlButton1 )
143     {
144         _strUrlButton1 = strUrlButton1;
145     }
146 
147     /**
148      * @return the label
149      */
150     public String getLabelButton2( )
151     {
152         return _strLabelButton2;
153     }
154 
155     /**
156      * @param strLabelButton2
157      *            the label to set
158      */
159     public void setLabelButton2( String strLabelButton2 )
160     {
161         _strLabelButton2 = strLabelButton2;
162     }
163 
164     /**
165      * @return the strUrlButton2
166      */
167     public String getUrlButton2( )
168     {
169         return _strUrlButton2;
170     }
171 
172     /**
173      * @param strUrlButton2
174      *            the strUrlButton2 to set
175      */
176     public void setUrlButton2( String strUrlButton2 )
177     {
178         _strUrlButton2 = strUrlButton2;
179     }
180 
181     /**
182      * @return the _strLabelKeyButton1
183      */
184     public String getLabelKeyButton1( )
185     {
186         return _strLabelKeyButton1;
187     }
188 
189     /**
190      * @param strLabelKeyButton1
191      *            the _strLabelKeyButton1 to set
192      */
193     public void setLabelKeyButton1( String strLabelKeyButton1 )
194     {
195         _strLabelKeyButton1 = strLabelKeyButton1;
196     }
197 
198     /**
199      * @return the _strLabelKeyButton2
200      */
201     public String getLabelKeyButton2( )
202     {
203         return _strLabelKeyButton2;
204     }
205 
206     /**
207      * @param strLabelKeyButton2
208      *            the _strLabelKeyButton2 to set
209      */
210     public void setLabelKeyButton2( String strLabelKeyButton2 )
211     {
212         _strLabelKeyButton2 = strLabelKeyButton2;
213     }
214 
215     /**
216      * @return the _strTemplate
217      */
218     public String getTemplate( )
219     {
220         return _strTemplate;
221     }
222 
223     /**
224      * @param strTemplate
225      *            the _strTemplate to set
226      */
227     public void setTemplate( String strTemplate )
228     {
229         _strTemplate = strTemplate;
230     }
231 
232     /**
233      * @return the Title key
234      */
235     public String getTitleKey( )
236     {
237         return _strTitleKey;
238     }
239 
240     /**
241      * @param strTitleKey
242      *            the Title key to set
243      */
244     public void setTitleKey( String strTitleKey )
245     {
246         this._strTitleKey = strTitleKey;
247     }
248 
249     /**
250      * @return the Message key
251      */
252     public String getMessageKey( )
253     {
254         return _strMessageKey;
255     }
256 
257     /**
258      * @param strMessageKey
259      *            the Message key to set
260      */
261     public void setMessageKey( String strMessageKey )
262     {
263         this._strMessageKey = strMessageKey;
264     }
265 
266     /**
267      * Localize value if value's key found
268      * 
269      * @param locale
270      *            The locale
271      */
272     public void localize( Locale locale )
273     {
274         _strTitle = ( _strTitleKey != null ) ? I18nService.getLocalizedString( _strTitleKey, locale ) : _strTitle;
275         _strMessage = ( _strMessageKey != null ) ? I18nService.getLocalizedString( _strMessageKey, locale ) : _strMessage;
276         _strLabelButton1 = ( _strLabelKeyButton1 != null ) ? I18nService.getLocalizedString( _strLabelKeyButton1, locale ) : _strLabelButton1;
277         _strLabelButton2 = ( _strLabelKeyButton2 != null ) ? I18nService.getLocalizedString( _strLabelKeyButton2, locale ) : _strLabelButton2;
278     }
279 }