KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > util > I18nOptionPane


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * I18nOptionPane.java
28  *
29  * Created on 15/05/2004
30  *
31  */

32
33 package it.businesslogic.ireport.util;
34
35 import java.awt.Component JavaDoc;
36
37 import javax.swing.Icon JavaDoc;
38 import javax.swing.JOptionPane JavaDoc;
39
40 /**
41  * A internacionalization support for all static methods of JOptionPane.
42  *
43  * @author Egon
44  *
45  */

46 public class I18nOptionPane {
47
48     /**
49      * Couldn't be instancied.
50      */

51     private I18nOptionPane() {
52         super();
53     }
54
55     /**
56      * Brings up an internal confirmation dialog panel. The dialog is a information-message dialog titled "Message".
57      *
58      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
59      * @param messageCID message country identification for a message to be displayed.
60      */

61     public static void showInternalMessageDialog(Component JavaDoc parentComponent, String JavaDoc messageCID){
62         
63         String JavaDoc message = messageCID;
64         
65         if(messageCID != null){
66             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
67         }
68         
69         JOptionPane.showInternalMessageDialog(parentComponent, message);
70     }
71
72     /**
73      * Brings up an internal dialog panel that displays a message using a default icon determined by the messageType parameter.
74      * @param parentComponent the parent Component for the dialog
75      * @param messageCID message country identification for a message to be displayed.
76      * @param titleCID message country identification for the String to display in the dialog title bar
77      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
78      */

79     public static void showInternalMessageDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc titleCID, int messageType){
80         
81         String JavaDoc message = messageCID;
82         
83         if(messageCID != null){
84             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
85         }
86         
87         String JavaDoc title = titleCID;
88         if(titleCID != null){
89             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
90         }
91
92         JOptionPane.showInternalMessageDialog(parentComponent, message, title, messageType);
93     }
94
95     /**
96      * Brings up a dialog displaying a message, specifying all parameters.
97      * @param parentComponent the parent Component for the dialog
98      * @param messageCID message country identification for a message to be displayed.
99      * @param titleCID message country identification for the String to display in the dialog title bar
100      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
101      * @param icon the icon to display in the dialog
102      */

103     public static void showInternalMessageDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc titleCID, int messageType, Icon JavaDoc icon){
104         
105         String JavaDoc message = messageCID;
106         if(messageCID != null){
107             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
108         }
109         
110         String JavaDoc title = titleCID;
111         if(titleCID != null){
112             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
113         }
114
115         JOptionPane.showInternalMessageDialog(parentComponent, message, title, messageType, icon);
116     }
117
118
119     /**
120      * Brings up an internal dialog panel with the options Yes, No and Cancel; with the title, Select an Option.
121      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
122      * @param messageCID message country identification for a message to be displayed.
123      */

124     public static int showInternalConfirmDialog(Component JavaDoc parentComponent,
125                                         String JavaDoc messageCID)
126     {
127
128         String JavaDoc message = messageCID;
129         if(messageCID != null){
130             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
131         }
132         
133         return JOptionPane.showInternalConfirmDialog(parentComponent, message);
134     }
135
136     /**
137      * Brings up a internal dialog panel where the number of choices is determined by the optionType parameter.
138      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
139      * @param messageCID message country identification for a message to be displayed.
140      * @param titleCID message country identification for the String to display in the dialog title bar
141      * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
142      */

143     public static int showInternalConfirmDialog(Component JavaDoc parentComponent,
144                                         String JavaDoc messageCID, String JavaDoc titleCID,
145                                         int optionType)
146     {
147
148         String JavaDoc message = messageCID;
149         if(messageCID != null){
150             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
151         }
152         
153         String JavaDoc title = titleCID;
154         if(titleCID != null){
155             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
156         }
157
158         return JOptionPane.showInternalConfirmDialog(parentComponent, message, title, optionType);
159     }
160     
161     /**
162      * Brings up an internal dialog panel where the number of choices is determined by the optionType parameter, where the messageType parameter determines the icon to display. The messageType parameter is primarily used to supply a default icon from the Look and Feel.
163      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
164      * @param messageCID message country identification for a message to be displayed.
165      * @param titleCID message country identification for the String to display in the dialog title bar
166      * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
167      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
168      */

169     public static int showInternalConfirmDialog(Component JavaDoc parentComponent,
170                                         String JavaDoc messageCID, String JavaDoc titleCID,
171                                         int optionType, int messageType)
172     {
173
174         String JavaDoc message = messageCID;
175         if(messageCID != null){
176             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
177         }
178         
179         String JavaDoc title = titleCID;
180         if(titleCID != null){
181             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
182         }
183
184         return JOptionPane.showInternalConfirmDialog(parentComponent, message, title, optionType, messageType);
185     }
186     
187     /**
188      * Brings up an internal dialog panel with a specified icon, where the number of choices is determined by the optionType parameter. The messageType parameter is primarily used to supply a default icon from the look and feel.
189      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
190      * @param messageCID message country identification for a message to be displayed.
191      * @param titleCID message country identification for the String to display in the dialog title bar
192      * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
193      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
194      * @param icon the icon to display in the dialog
195      */

196     public static int showInternalConfirmDialog(Component JavaDoc parentComponent,
197                                         String JavaDoc messageCID, String JavaDoc titleCID,
198                                         int optionType, int messageType, Icon JavaDoc icon)
199     {
200
201         String JavaDoc message = messageCID;
202         if(messageCID != null){
203             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
204         }
205         
206         String JavaDoc title = titleCID;
207         if(titleCID != null){
208             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
209         }
210
211         return JOptionPane.showInternalConfirmDialog(parentComponent, message, title, optionType, messageType, icon);
212     }
213     
214     /**
215      * Brings up an internal dialog panel with a specified icon, where the initial choice is determined by the initialValue parameter and the number of choices is determined by the optionType parameter.
216      * If optionType is YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the Look and Feel.
217      *
218      * The messageType parameter is primarily used to supply a default icon from the look and feel.
219      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
220      * @param messageCID message country identification for a message to be displayed.
221      * @param titleCID message country identification for a title to be displayed.
222      * @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
223      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
224      * @param icon the icon to display in the dialog
225      * @param optionsCID an array of message CIDs indicating the possible choices the user can make
226      * @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
227      * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog
228      */

229     public static int showInternalOptionDialog(Component JavaDoc parentComponent,
230                                        String JavaDoc messageCID,
231                                        String JavaDoc titleCID,
232                                        int optionType,
233                                        int messageType,
234                                        Icon JavaDoc icon,
235                                        String JavaDoc[] optionsCID,
236                                        String JavaDoc initialCIDValue)
237         {
238     
239         String JavaDoc message = messageCID;
240         if(messageCID != null){
241             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
242         }
243                                     
244         String JavaDoc title = titleCID;
245         if(titleCID != null){
246             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
247         }
248                                         
249         String JavaDoc initialValue = initialCIDValue;
250         if(initialCIDValue != null){
251             initialValue = it.businesslogic.ireport.util.I18n.getString(initialCIDValue, initialCIDValue);
252         }
253
254         String JavaDoc[] options = optionsCID;
255         if(optionsCID != null){
256             for(int i = 0; i < optionsCID.length; i++){
257                 if (optionsCID[i] != null){
258                     options[i] = it.businesslogic.ireport.util.I18n.getString(optionsCID[i], optionsCID[i]);
259                 }
260             }
261         }
262                                         
263         return JOptionPane.showInternalOptionDialog(parentComponent, message, title, optionType, messageType, icon, options, initialValue);
264     }
265
266     /**
267      * Shows an internal question-message dialog requesting input from the user parented to parentComponent. The dialog is displayed in the Component's frame, and is usually positioned below the Component.
268      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
269      * @param messageCID message country identification for a message to be displayed.
270      * @return
271      */

272     public static String JavaDoc showInternalInputDialog(Component JavaDoc parentComponent, String JavaDoc messageCID){
273         
274         String JavaDoc message = messageCID;
275         if(messageCID != null){
276             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
277         }
278         
279         return JOptionPane.showInternalInputDialog(parentComponent, message);
280     }
281
282     /**
283      * Prompts the user for input in a blocking internal dialog where the initial selection, possible selections, and all other options can be specified. The user will able to choose from selectionValues, where null implies the user can input whatever they wish, usually by means of a JTextField. initialSelectionValue is the initial value to prompt the user with. It is up to the UI to decide how best to represent the selectionValues, but usually a JComboBox, JList, or JTextField will be used.
284      * @param parentComponent the parent Component for the dialog
285      * @param messageCID message country identification for a message to be displayed.
286      * @param titleCID message country identification for the String to display in the dialog title bar
287      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
288      * @param icon the Icon image to display
289      * @param selectionCIDValues message country identifications for an array of strings that gives the possible selections
290      * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
291      * @return
292      */

293     public static String JavaDoc showInternalInputDialog(Component JavaDoc parentComponent,
294                                          String JavaDoc messageCID,
295                                          String JavaDoc titleCID,
296                                          int messageType,
297                                          Icon JavaDoc icon,
298                                          String JavaDoc[] selectionCIDValues,
299                                          String JavaDoc initialSelectionCIDValue)
300     {
301         
302         String JavaDoc message = messageCID;
303         if(messageCID != null){
304             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
305         }
306         
307         String JavaDoc title = titleCID;
308         if(titleCID != null){
309             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
310         }
311
312         String JavaDoc initialSelectionValue = initialSelectionCIDValue;
313         if(initialSelectionCIDValue != null){
314             initialSelectionValue = it.businesslogic.ireport.util.I18n.getString(initialSelectionCIDValue, initialSelectionCIDValue);
315         }
316
317         String JavaDoc[] selectionValues = selectionCIDValues;
318         if(selectionCIDValues != null){
319             for(int i = 0; i < selectionCIDValues.length; i++){
320                 if (selectionCIDValues[i] != null){
321                     selectionValues[i] = it.businesslogic.ireport.util.I18n.getString(selectionCIDValues[i], selectionCIDValues[i]);
322                 }
323             }
324         }
325
326         return (String JavaDoc) JOptionPane.showInternalInputDialog(parentComponent, message, title, messageType, icon, selectionValues, initialSelectionValue);
327     }
328
329     /**
330      * Brings up an information-message dialog titled with the message associated with the Country ID resource bundle.
331      *
332      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
333      * @param messageCID message country identification for a message to be displayed.
334      */

335     public static void showMessageDialog(Component JavaDoc parentComponent, String JavaDoc messageCID){
336         
337         String JavaDoc message = messageCID;
338         
339         if(messageCID != null){
340             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
341         }
342         
343         JOptionPane.showMessageDialog(parentComponent, message);
344     }
345
346     /**
347      * Shows an internal dialog requesting input from the user parented to parentComponent with the dialog having the title title and message type messageType.
348      * @param parentComponent the parent Component for the dialog
349      * @param messageCID message country identification for a message to be displayed.
350      * @param titleCID message country identification for the String to display in the dialog title bar
351      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
352      * @return
353      */

354     public static String JavaDoc showInternalInputDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc titleCID, int messageType){
355
356         String JavaDoc message = messageCID;
357         if(messageCID != null){
358             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
359         }
360         
361         String JavaDoc title = titleCID;
362         if(titleCID != null){
363             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
364         }
365
366         return JOptionPane.showInternalInputDialog(parentComponent, message, title, messageType);
367     }
368
369
370     /**
371      * Brings up a dialog that displays a message using a default icon determined by the messageType parameter.
372      * @param parentComponent the parent Component for the dialog
373      * @param messageCID message country identification for a message to be displayed.
374      * @param titleCID message country identification for the String to display in the dialog title bar
375      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
376      */

377     public static void showMessageDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc titleCID, int messageType){
378         
379         String JavaDoc message = messageCID;
380         
381         if(messageCID != null){
382             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
383         }
384         
385         String JavaDoc title = titleCID;
386         if(titleCID != null){
387             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
388         }
389
390         JOptionPane.showMessageDialog(parentComponent, message, title, messageType);
391     }
392
393     /**
394      * Brings up a dialog displaying a message, specifying all parameters.
395      * @param parentComponent the parent Component for the dialog
396      * @param messageCID message country identification for a message to be displayed.
397      * @param titleCID message country identification for the String to display in the dialog title bar
398      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
399      * @param icon the icon to display in the dialog
400      */

401     public static void showMessageDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc titleCID, int messageType, Icon JavaDoc icon){
402         
403         String JavaDoc message = messageCID;
404         if(messageCID != null){
405             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
406         }
407         
408         String JavaDoc title = titleCID;
409         if(titleCID != null){
410             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
411         }
412
413         JOptionPane.showMessageDialog(parentComponent, message, title, messageType, icon);
414     }
415
416
417     /**
418      * Brings up a dialog with the options Yes, No and Cancel; with the title, Select an Option.
419      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
420      * @param messageCID message country identification for a message to be displayed.
421      */

422     public static int showConfirmDialog(Component JavaDoc parentComponent,
423                                         String JavaDoc messageCID)
424     {
425
426         String JavaDoc message = messageCID;
427         if(messageCID != null){
428             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
429         }
430         
431         return JOptionPane.showConfirmDialog(parentComponent, message);
432     }
433
434     /**
435      * Brings up a dialog where the number of choices is determined by the optionType parameter.
436      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
437      * @param messageCID message country identification for a message to be displayed.
438      * @param titleCID message country identification for the String to display in the dialog title bar
439      * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
440      */

441     public static int showConfirmDialog(Component JavaDoc parentComponent,
442                                         String JavaDoc messageCID, String JavaDoc titleCID,
443                                         int optionType)
444     {
445
446         String JavaDoc message = messageCID;
447         if(messageCID != null){
448             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
449         }
450         
451         String JavaDoc title = titleCID;
452         if(titleCID != null){
453             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
454         }
455
456         return JOptionPane.showConfirmDialog(parentComponent, message, title, optionType);
457     }
458
459     /**
460      * Brings up a dialog where the number of choices is determined by the optionType parameter, where the messageType parameter determines the icon to display. The messageType parameter is primarily used to supply a default icon from the Look and Feel.
461      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
462      * @param messageCID message country identification for a message to be displayed.
463      * @param titleCID message country identification for the String to display in the dialog title bar
464      * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
465      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
466      */

467     public static int showConfirmDialog(Component JavaDoc parentComponent,
468                                         String JavaDoc messageCID, String JavaDoc titleCID,
469                                         int optionType, int messageType)
470     {
471
472         String JavaDoc message = messageCID;
473         if(messageCID != null){
474             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
475         }
476         
477         String JavaDoc title = titleCID;
478         if(titleCID != null){
479             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
480         }
481
482         return JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageType);
483     }
484
485     /**
486      * Brings up a dialog with a specified icon, where the number of choices is determined by the optionType parameter. The messageType parameter is primarily used to supply a default icon from the look and feel.
487      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
488      * @param messageCID message country identification for a message to be displayed.
489      * @param titleCID message country identification for the String to display in the dialog title bar
490      * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
491      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
492      * @param icon the icon to display in the dialog
493      */

494     public static int showConfirmDialog(Component JavaDoc parentComponent,
495                                         String JavaDoc messageCID, String JavaDoc titleCID,
496                                         int optionType, int messageType, Icon JavaDoc icon)
497     {
498
499         String JavaDoc message = messageCID;
500         if(messageCID != null){
501             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
502         }
503         
504         String JavaDoc title = titleCID;
505         if(titleCID != null){
506             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
507         }
508
509         return JOptionPane.showConfirmDialog(parentComponent, message, title, optionType, messageType, icon);
510     }
511
512
513     /**
514      * Brings up a dialog with a specified icon, where the initial choice is determined by the initialValue parameter and the number of choices is determined by the optionType parameter.
515      * If optionType is YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the look and feel.
516      *
517      * The messageType parameter is primarily used to supply a default icon from the look and feel.
518      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
519      * @param messageCID message country identification for a message to be displayed.
520      * @param titleCID message country identification for a title to be displayed.
521      * @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
522      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
523      * @param icon the icon to display in the dialog
524      * @param optionsCID an array of message CIDs indicating the possible choices the user can make
525      * @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
526      * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog
527      */

528     public static int showOptionDialog(Component JavaDoc parentComponent,
529                                        String JavaDoc messageCID,
530                                        String JavaDoc titleCID,
531                                        int optionType,
532                                        int messageType,
533                                        Icon JavaDoc icon,
534                                        String JavaDoc[] optionsCID,
535                                        String JavaDoc initialCIDValue
536                                                                            )
537         {
538             String JavaDoc firstLine = "";
539             
540         return showOptionDialog(parentComponent,
541                                        messageCID,
542                                        titleCID,
543                                        optionType,
544                                        messageType,
545                                        icon,
546                                        optionsCID,
547                                        initialCIDValue,
548                                                                            firstLine);
549     }
550         
551         
552     /**
553      * Brings up a dialog with a specified icon, where the initial choice is determined by the initialValue parameter and the number of choices is determined by the optionType parameter.
554      * If optionType is YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the look and feel.
555      *
556      * The messageType parameter is primarily used to supply a default icon from the look and feel.
557      * @param parentComponent determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
558      * @param messageCID message country identification for a message to be displayed.
559      * @param titleCID message country identification for a title to be displayed.
560      * @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
561      * @param messageType an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
562      * @param icon the icon to display in the dialog
563      * @param optionsCID an array of message CIDs indicating the possible choices the user can make
564      * @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
565          * @param firstLine parameter is there to precede the messageCID with some situational information, like e.g. the name of a file.
566      * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog
567          *
568          * Typical usage for using the parameter firstLine:
569          * showOptionDialog(........, jfc.getSelectedFile().getPath() )
570      */

571     public static int showOptionDialog(Component JavaDoc parentComponent,
572                                        String JavaDoc messageCID,
573                                        String JavaDoc titleCID,
574                                        int optionType,
575                                        int messageType,
576                                        Icon JavaDoc icon,
577                                        String JavaDoc[] optionsCID,
578                                        String JavaDoc initialCIDValue,
579                                                                            String JavaDoc firstLine)
580         {
581     
582         String JavaDoc message = messageCID;
583         if(messageCID != null){
584             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
585         }
586                 // begin modification Robert lamping, may 3, 2005
587
if (firstLine != null || ! firstLine.equals("") ) {
588                     message = firstLine + "\n" + message;
589                 }
590                 // End modification
591

592         String JavaDoc title = titleCID;
593         if(titleCID != null){
594             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
595         }
596                                         
597         String JavaDoc initialValue = initialCIDValue;
598         if(initialCIDValue != null){
599             initialValue = it.businesslogic.ireport.util.I18n.getString(initialCIDValue, initialCIDValue);
600         }
601
602         String JavaDoc[] options = optionsCID;
603         if(optionsCID != null){
604             for(int i = 0; i < optionsCID.length; i++){
605                 if (optionsCID[i] != null){
606                     options[i] = it.businesslogic.ireport.util.I18n.getString(optionsCID[i], optionsCID[i]);
607                 }
608             }
609         }
610                                         
611         return JOptionPane.showOptionDialog(parentComponent, message, title, optionType, messageType, icon, options, initialValue);
612     }
613
614     /**
615      * Shows a question-message dialog requesting input from the user. The dialog uses the default frame, which usually means it is centered on the screen.
616      * @param messageCID message country identification for a message to be displayed.
617      * @return
618      */

619     public static String JavaDoc showInputDialog(String JavaDoc messageCID){
620         
621         String JavaDoc message = messageCID;
622         if(messageCID != null){
623             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
624         }
625         
626         return JOptionPane.showInputDialog(message);
627     }
628     
629     
630     /**
631      * Shows a question-message dialog requesting input from the user, with the input value initialized to initialSelectionValue. The dialog uses the default frame, which usually means it is centered on the screen.
632      * @param messageCID message country identification for a message to be displayed.
633      * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
634      * @return
635      */

636     public static String JavaDoc showInputDialog(String JavaDoc messageCID, String JavaDoc initialSelectionCIDValue){
637
638         String JavaDoc message = messageCID;
639         if(messageCID != null){
640             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
641         }
642         
643         String JavaDoc initialSelectionValue = initialSelectionCIDValue;
644         if(initialSelectionCIDValue != null){
645             initialSelectionValue = it.businesslogic.ireport.util.I18n.getString(initialSelectionCIDValue, initialSelectionCIDValue);
646         }
647
648         return JOptionPane.showInputDialog(message, initialSelectionValue);
649     }
650
651
652     /**
653      * Shows a question-message dialog requesting input from the user parented to parentComponent. The dialog is displayed on top of the Component's frame, and is usually positioned below the Component.
654      * @param messageCID message country identification for a message to be displayed.
655      * @param parentComponent the parent Component for the dialog
656      * @return
657      */

658     public static String JavaDoc showInputDialog(Component JavaDoc parentComponent, String JavaDoc messageCID){
659         
660         String JavaDoc message = messageCID;
661         if(messageCID != null){
662             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
663         }
664         
665         return JOptionPane.showInputDialog(parentComponent, message);
666     }
667     
668     /**
669      * Shows a question-message dialog requesting input from the user and parented to parentComponent. The input value will be initialized to initialSelectionValue. The dialog is displayed on top of the Component's frame, and is usually positioned below the Component.
670      * @param parentComponent the parent Component for the dialog
671      * @param messageCID message country identification for a message to be displayed.
672      * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
673      * @return
674      */

675     public static String JavaDoc showInputDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc initialSelectionCIDValue){
676
677         String JavaDoc message = messageCID;
678         if(messageCID != null){
679             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
680         }
681         
682         String JavaDoc initialSelectionValue = initialSelectionCIDValue;
683         if(initialSelectionCIDValue != null){
684             initialSelectionValue = it.businesslogic.ireport.util.I18n.getString(initialSelectionCIDValue, initialSelectionCIDValue);
685         }
686
687         return JOptionPane.showInputDialog(parentComponent, message, initialSelectionValue);
688     }
689     
690     /**
691      * Shows a dialog requesting input from the user parented to parentComponent with the dialog having the title title and message type messageType.
692      * @param parentComponent the parent Component for the dialog
693      * @param messageCID message country identification for a message to be displayed.
694      * @param titleCID message country identification for the String to display in the dialog title bar
695      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
696      * @return
697      */

698     public static String JavaDoc showInputDialog(Component JavaDoc parentComponent, String JavaDoc messageCID, String JavaDoc titleCID, int messageType){
699
700         String JavaDoc message = messageCID;
701         if(messageCID != null){
702             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
703         }
704         
705         String JavaDoc title = titleCID;
706         if(titleCID != null){
707             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
708         }
709
710         return JOptionPane.showInputDialog(parentComponent, message, title, messageType);
711     }
712     
713     
714     /**
715      * Prompts the user for input in a blocking dialog where the initial selection, possible selections, and all other options can be specified. The user will able to choose from selectionValues, where null implies the user can input whatever they wish, usually by means of a JTextField. initialSelectionValue is the initial value to prompt the user with. It is up to the UI to decide how best to represent the selectionValues, but usually a JComboBox, JList, or JTextField will be used.
716      * @param parentComponent the parent Component for the dialog
717      * @param messageCID message country identification for a message to be displayed.
718      * @param titleCID message country identification for the String to display in the dialog title bar
719      * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
720      * @param icon the Icon image to display
721      * @param selectionCIDValues message country identifications for an array of strings that gives the possible selections
722      * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
723      * @return
724      */

725     public static String JavaDoc showInputDialog(Component JavaDoc parentComponent,
726                                          String JavaDoc messageCID,
727                                          String JavaDoc titleCID,
728                                          int messageType,
729                                          Icon JavaDoc icon,
730                                          String JavaDoc[] selectionCIDValues,
731                                          String JavaDoc initialSelectionCIDValue)
732     {
733         
734         String JavaDoc message = messageCID;
735         if(messageCID != null){
736             message = it.businesslogic.ireport.util.I18n.getString(messageCID, messageCID);
737         }
738         
739         String JavaDoc title = titleCID;
740         if(titleCID != null){
741             title = it.businesslogic.ireport.util.I18n.getString(titleCID, titleCID);
742         }
743
744         String JavaDoc initialSelectionValue = initialSelectionCIDValue;
745         if(initialSelectionCIDValue != null){
746             initialSelectionValue = it.businesslogic.ireport.util.I18n.getString(initialSelectionCIDValue, initialSelectionCIDValue);
747         }
748
749         String JavaDoc[] selectionValues = selectionCIDValues;
750         if(selectionCIDValues != null){
751             for(int i = 0; i < selectionCIDValues.length; i++){
752                 if (selectionCIDValues[i] != null){
753                     selectionValues[i] = it.businesslogic.ireport.util.I18n.getString(selectionCIDValues[i], selectionCIDValues[i]);
754                 }
755             }
756         }
757
758         return (String JavaDoc) JOptionPane.showInputDialog(parentComponent, message, title, messageType, icon, selectionValues, initialSelectionValue);
759     }
760
761
762
763 }
764
Popular Tags