Source Code Cross Referenced for I18nOptionPane.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » iReport 2.0.5 » it.businesslogic.ireport.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * I18nOptionPane.java
028:         * 
029:         * Created on 15/05/2004
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.util;
034:
035:        import java.awt.Component;
036:
037:        import javax.swing.Icon;
038:        import javax.swing.JOptionPane;
039:
040:        /**
041:         * A internacionalization support for all static methods of JOptionPane. 
042:         * 
043:         * @author Egon
044:         *
045:         */
046:        public class I18nOptionPane {
047:
048:            /**
049:             * Couldn't be instancied. 
050:             */
051:            private I18nOptionPane() {
052:                super ();
053:            }
054:
055:            /**
056:             * Brings up an internal confirmation dialog panel. The dialog is a information-message dialog titled "Message".  
057:             * 
058:             * @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
059:             * @param messageCID message country identification for a message to be displayed.
060:             */
061:            public static void showInternalMessageDialog(
062:                    Component parentComponent, String messageCID) {
063:
064:                String message = messageCID;
065:
066:                if (messageCID != null) {
067:                    message = it.businesslogic.ireport.util.I18n.getString(
068:                            messageCID, messageCID);
069:                }
070:
071:                JOptionPane.showInternalMessageDialog(parentComponent, message);
072:            }
073:
074:            /**
075:             * Brings up an internal dialog panel that displays a message using a default icon determined by the messageType parameter.  
076:             * @param parentComponent the parent Component for the dialog
077:             * @param messageCID message country identification for a message to be displayed.
078:             * @param titleCID message country identification for the String to display in the dialog title bar
079:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
080:             */
081:            public static void showInternalMessageDialog(
082:                    Component parentComponent, String messageCID,
083:                    String titleCID, int messageType) {
084:
085:                String message = messageCID;
086:
087:                if (messageCID != null) {
088:                    message = it.businesslogic.ireport.util.I18n.getString(
089:                            messageCID, messageCID);
090:                }
091:
092:                String title = titleCID;
093:                if (titleCID != null) {
094:                    title = it.businesslogic.ireport.util.I18n.getString(
095:                            titleCID, titleCID);
096:                }
097:
098:                JOptionPane.showInternalMessageDialog(parentComponent, message,
099:                        title, messageType);
100:            }
101:
102:            /**
103:             * Brings up a dialog displaying a message, specifying all parameters. 
104:             * @param parentComponent the parent Component for the dialog
105:             * @param messageCID message country identification for a message to be displayed.
106:             * @param titleCID message country identification for the String to display in the dialog title bar
107:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
108:             * @param icon the icon to display in the dialog
109:             */
110:            public static void showInternalMessageDialog(
111:                    Component parentComponent, String messageCID,
112:                    String titleCID, int messageType, Icon icon) {
113:
114:                String message = messageCID;
115:                if (messageCID != null) {
116:                    message = it.businesslogic.ireport.util.I18n.getString(
117:                            messageCID, messageCID);
118:                }
119:
120:                String title = titleCID;
121:                if (titleCID != null) {
122:                    title = it.businesslogic.ireport.util.I18n.getString(
123:                            titleCID, titleCID);
124:                }
125:
126:                JOptionPane.showInternalMessageDialog(parentComponent, message,
127:                        title, messageType, icon);
128:            }
129:
130:            /**
131:             * Brings up an internal dialog panel with the options Yes, No and Cancel; with the title, Select an Option.   
132:             * @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
133:             * @param messageCID message country identification for a message to be displayed.
134:             */
135:            public static int showInternalConfirmDialog(
136:                    Component parentComponent, String messageCID) {
137:
138:                String message = messageCID;
139:                if (messageCID != null) {
140:                    message = it.businesslogic.ireport.util.I18n.getString(
141:                            messageCID, messageCID);
142:                }
143:
144:                return JOptionPane.showInternalConfirmDialog(parentComponent,
145:                        message);
146:            }
147:
148:            /**
149:             * Brings up a internal dialog panel where the number of choices is determined by the optionType parameter.    
150:             * @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
151:             * @param messageCID message country identification for a message to be displayed.
152:             * @param titleCID message country identification for the String to display in the dialog title bar
153:             * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION  
154:             */
155:            public static int showInternalConfirmDialog(
156:                    Component parentComponent, String messageCID,
157:                    String titleCID, int optionType) {
158:
159:                String message = messageCID;
160:                if (messageCID != null) {
161:                    message = it.businesslogic.ireport.util.I18n.getString(
162:                            messageCID, messageCID);
163:                }
164:
165:                String title = titleCID;
166:                if (titleCID != null) {
167:                    title = it.businesslogic.ireport.util.I18n.getString(
168:                            titleCID, titleCID);
169:                }
170:
171:                return JOptionPane.showInternalConfirmDialog(parentComponent,
172:                        message, title, optionType);
173:            }
174:
175:            /**
176:             * 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.    
177:             * @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
178:             * @param messageCID message country identification for a message to be displayed.
179:             * @param titleCID message country identification for the String to display in the dialog title bar
180:             * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION  
181:             * @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
182:             */
183:            public static int showInternalConfirmDialog(
184:                    Component parentComponent, String messageCID,
185:                    String titleCID, int optionType, int messageType) {
186:
187:                String message = messageCID;
188:                if (messageCID != null) {
189:                    message = it.businesslogic.ireport.util.I18n.getString(
190:                            messageCID, messageCID);
191:                }
192:
193:                String title = titleCID;
194:                if (titleCID != null) {
195:                    title = it.businesslogic.ireport.util.I18n.getString(
196:                            titleCID, titleCID);
197:                }
198:
199:                return JOptionPane.showInternalConfirmDialog(parentComponent,
200:                        message, title, optionType, messageType);
201:            }
202:
203:            /**
204:             * 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.     
205:             * @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
206:             * @param messageCID message country identification for a message to be displayed.
207:             * @param titleCID message country identification for the String to display in the dialog title bar
208:             * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION  
209:             * @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
210:             * @param icon the icon to display in the dialog
211:             */
212:            public static int showInternalConfirmDialog(
213:                    Component parentComponent, String messageCID,
214:                    String titleCID, int optionType, int messageType, Icon icon) {
215:
216:                String message = messageCID;
217:                if (messageCID != null) {
218:                    message = it.businesslogic.ireport.util.I18n.getString(
219:                            messageCID, messageCID);
220:                }
221:
222:                String title = titleCID;
223:                if (titleCID != null) {
224:                    title = it.businesslogic.ireport.util.I18n.getString(
225:                            titleCID, titleCID);
226:                }
227:
228:                return JOptionPane.showInternalConfirmDialog(parentComponent,
229:                        message, title, optionType, messageType, icon);
230:            }
231:
232:            /**
233:             * 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. 
234:             * 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. 
235:             * 
236:             * The messageType parameter is primarily used to supply a default icon from the look and feel. 
237:             * @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
238:             * @param messageCID message country identification for a message to be displayed.
239:             * @param titleCID message country identification for a title to be displayed.
240:             * @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
241:             * @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
242:             * @param icon the icon to display in the dialog
243:             * @param optionsCID an array of message CIDs indicating the possible choices the user can make
244:             * @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
245:             * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog 
246:             */
247:            public static int showInternalOptionDialog(
248:                    Component parentComponent, String messageCID,
249:                    String titleCID, int optionType, int messageType,
250:                    Icon icon, String[] optionsCID, String initialCIDValue) {
251:
252:                String message = messageCID;
253:                if (messageCID != null) {
254:                    message = it.businesslogic.ireport.util.I18n.getString(
255:                            messageCID, messageCID);
256:                }
257:
258:                String title = titleCID;
259:                if (titleCID != null) {
260:                    title = it.businesslogic.ireport.util.I18n.getString(
261:                            titleCID, titleCID);
262:                }
263:
264:                String initialValue = initialCIDValue;
265:                if (initialCIDValue != null) {
266:                    initialValue = it.businesslogic.ireport.util.I18n
267:                            .getString(initialCIDValue, initialCIDValue);
268:                }
269:
270:                String[] options = optionsCID;
271:                if (optionsCID != null) {
272:                    for (int i = 0; i < optionsCID.length; i++) {
273:                        if (optionsCID[i] != null) {
274:                            options[i] = it.businesslogic.ireport.util.I18n
275:                                    .getString(optionsCID[i], optionsCID[i]);
276:                        }
277:                    }
278:                }
279:
280:                return JOptionPane.showInternalOptionDialog(parentComponent,
281:                        message, title, optionType, messageType, icon, options,
282:                        initialValue);
283:            }
284:
285:            /**
286:             * 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. 
287:             * @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
288:             * @param messageCID message country identification for a message to be displayed.
289:             * @return
290:             */
291:            public static String showInternalInputDialog(
292:                    Component parentComponent, String messageCID) {
293:
294:                String message = messageCID;
295:                if (messageCID != null) {
296:                    message = it.businesslogic.ireport.util.I18n.getString(
297:                            messageCID, messageCID);
298:                }
299:
300:                return JOptionPane.showInternalInputDialog(parentComponent,
301:                        message);
302:            }
303:
304:            /**
305:             * 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.  
306:             * @param parentComponent the parent Component for the dialog
307:             * @param messageCID message country identification for a message to be displayed.
308:             * @param titleCID message country identification for the String to display in the dialog title bar
309:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
310:             * @param icon the Icon image to display
311:             * @param selectionCIDValues  message country identifications for an array of strings that gives the possible selections
312:             * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
313:             * @return
314:             */
315:            public static String showInternalInputDialog(
316:                    Component parentComponent, String messageCID,
317:                    String titleCID, int messageType, Icon icon,
318:                    String[] selectionCIDValues, String initialSelectionCIDValue) {
319:
320:                String message = messageCID;
321:                if (messageCID != null) {
322:                    message = it.businesslogic.ireport.util.I18n.getString(
323:                            messageCID, messageCID);
324:                }
325:
326:                String title = titleCID;
327:                if (titleCID != null) {
328:                    title = it.businesslogic.ireport.util.I18n.getString(
329:                            titleCID, titleCID);
330:                }
331:
332:                String initialSelectionValue = initialSelectionCIDValue;
333:                if (initialSelectionCIDValue != null) {
334:                    initialSelectionValue = it.businesslogic.ireport.util.I18n
335:                            .getString(initialSelectionCIDValue,
336:                                    initialSelectionCIDValue);
337:                }
338:
339:                String[] selectionValues = selectionCIDValues;
340:                if (selectionCIDValues != null) {
341:                    for (int i = 0; i < selectionCIDValues.length; i++) {
342:                        if (selectionCIDValues[i] != null) {
343:                            selectionValues[i] = it.businesslogic.ireport.util.I18n
344:                                    .getString(selectionCIDValues[i],
345:                                            selectionCIDValues[i]);
346:                        }
347:                    }
348:                }
349:
350:                return (String) JOptionPane.showInternalInputDialog(
351:                        parentComponent, message, title, messageType, icon,
352:                        selectionValues, initialSelectionValue);
353:            }
354:
355:            /**
356:             * Brings up an information-message dialog titled with the message associated with the Country ID resource bundle. 
357:             * 
358:             * @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
359:             * @param messageCID message country identification for a message to be displayed.
360:             */
361:            public static void showMessageDialog(Component parentComponent,
362:                    String messageCID) {
363:
364:                String message = messageCID;
365:
366:                if (messageCID != null) {
367:                    message = it.businesslogic.ireport.util.I18n.getString(
368:                            messageCID, messageCID);
369:                }
370:
371:                JOptionPane.showMessageDialog(parentComponent, message);
372:            }
373:
374:            /**
375:             * Shows an internal dialog requesting input from the user parented to parentComponent with the dialog having the title title and message type messageType.    
376:             * @param parentComponent the parent Component for the dialog
377:             * @param messageCID message country identification for a message to be displayed.
378:             * @param titleCID message country identification for the String to display in the dialog title bar
379:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
380:             * @return
381:             */
382:            public static String showInternalInputDialog(
383:                    Component parentComponent, String messageCID,
384:                    String titleCID, int messageType) {
385:
386:                String message = messageCID;
387:                if (messageCID != null) {
388:                    message = it.businesslogic.ireport.util.I18n.getString(
389:                            messageCID, messageCID);
390:                }
391:
392:                String title = titleCID;
393:                if (titleCID != null) {
394:                    title = it.businesslogic.ireport.util.I18n.getString(
395:                            titleCID, titleCID);
396:                }
397:
398:                return JOptionPane.showInternalInputDialog(parentComponent,
399:                        message, title, messageType);
400:            }
401:
402:            /**
403:             * Brings up a dialog that displays a message using a default icon determined by the messageType parameter. 
404:             * @param parentComponent the parent Component for the dialog
405:             * @param messageCID message country identification for a message to be displayed.
406:             * @param titleCID message country identification for the String to display in the dialog title bar
407:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
408:             */
409:            public static void showMessageDialog(Component parentComponent,
410:                    String messageCID, String titleCID, int messageType) {
411:
412:                String message = messageCID;
413:
414:                if (messageCID != null) {
415:                    message = it.businesslogic.ireport.util.I18n.getString(
416:                            messageCID, messageCID);
417:                }
418:
419:                String title = titleCID;
420:                if (titleCID != null) {
421:                    title = it.businesslogic.ireport.util.I18n.getString(
422:                            titleCID, titleCID);
423:                }
424:
425:                JOptionPane.showMessageDialog(parentComponent, message, title,
426:                        messageType);
427:            }
428:
429:            /**
430:             * Brings up a dialog displaying a message, specifying all parameters. 
431:             * @param parentComponent the parent Component for the dialog
432:             * @param messageCID message country identification for a message to be displayed.
433:             * @param titleCID message country identification for the String to display in the dialog title bar
434:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
435:             * @param icon the icon to display in the dialog
436:             */
437:            public static void showMessageDialog(Component parentComponent,
438:                    String messageCID, String titleCID, int messageType,
439:                    Icon icon) {
440:
441:                String message = messageCID;
442:                if (messageCID != null) {
443:                    message = it.businesslogic.ireport.util.I18n.getString(
444:                            messageCID, messageCID);
445:                }
446:
447:                String title = titleCID;
448:                if (titleCID != null) {
449:                    title = it.businesslogic.ireport.util.I18n.getString(
450:                            titleCID, titleCID);
451:                }
452:
453:                JOptionPane.showMessageDialog(parentComponent, message, title,
454:                        messageType, icon);
455:            }
456:
457:            /**
458:             * Brings up a dialog with the options Yes, No and Cancel; with the title, Select an Option.  
459:             * @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
460:             * @param messageCID message country identification for a message to be displayed.
461:             */
462:            public static int showConfirmDialog(Component parentComponent,
463:                    String messageCID) {
464:
465:                String message = messageCID;
466:                if (messageCID != null) {
467:                    message = it.businesslogic.ireport.util.I18n.getString(
468:                            messageCID, messageCID);
469:                }
470:
471:                return JOptionPane.showConfirmDialog(parentComponent, message);
472:            }
473:
474:            /**
475:             * Brings up a dialog where the number of choices is determined by the optionType parameter.   
476:             * @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
477:             * @param messageCID message country identification for a message to be displayed.
478:             * @param titleCID message country identification for the String to display in the dialog title bar
479:             * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION  
480:             */
481:            public static int showConfirmDialog(Component parentComponent,
482:                    String messageCID, String titleCID, int optionType) {
483:
484:                String message = messageCID;
485:                if (messageCID != null) {
486:                    message = it.businesslogic.ireport.util.I18n.getString(
487:                            messageCID, messageCID);
488:                }
489:
490:                String title = titleCID;
491:                if (titleCID != null) {
492:                    title = it.businesslogic.ireport.util.I18n.getString(
493:                            titleCID, titleCID);
494:                }
495:
496:                return JOptionPane.showConfirmDialog(parentComponent, message,
497:                        title, optionType);
498:            }
499:
500:            /**
501:             * 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.   
502:             * @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
503:             * @param messageCID message country identification for a message to be displayed.
504:             * @param titleCID message country identification for the String to display in the dialog title bar
505:             * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION  
506:             * @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
507:             */
508:            public static int showConfirmDialog(Component parentComponent,
509:                    String messageCID, String titleCID, int optionType,
510:                    int messageType) {
511:
512:                String message = messageCID;
513:                if (messageCID != null) {
514:                    message = it.businesslogic.ireport.util.I18n.getString(
515:                            messageCID, messageCID);
516:                }
517:
518:                String title = titleCID;
519:                if (titleCID != null) {
520:                    title = it.businesslogic.ireport.util.I18n.getString(
521:                            titleCID, titleCID);
522:                }
523:
524:                return JOptionPane.showConfirmDialog(parentComponent, message,
525:                        title, optionType, messageType);
526:            }
527:
528:            /**
529:             * 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.    
530:             * @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
531:             * @param messageCID message country identification for a message to be displayed.
532:             * @param titleCID message country identification for the String to display in the dialog title bar
533:             * @param optionType an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION  
534:             * @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
535:             * @param icon the icon to display in the dialog
536:             */
537:            public static int showConfirmDialog(Component parentComponent,
538:                    String messageCID, String titleCID, int optionType,
539:                    int messageType, Icon icon) {
540:
541:                String message = messageCID;
542:                if (messageCID != null) {
543:                    message = it.businesslogic.ireport.util.I18n.getString(
544:                            messageCID, messageCID);
545:                }
546:
547:                String title = titleCID;
548:                if (titleCID != null) {
549:                    title = it.businesslogic.ireport.util.I18n.getString(
550:                            titleCID, titleCID);
551:                }
552:
553:                return JOptionPane.showConfirmDialog(parentComponent, message,
554:                        title, optionType, messageType, icon);
555:            }
556:
557:            /**
558:             * 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. 
559:             * 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. 
560:             *
561:             * The messageType parameter is primarily used to supply a default icon from the look and feel.
562:             * @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
563:             * @param messageCID message country identification for a message to be displayed.
564:             * @param titleCID message country identification for a title to be displayed.
565:             * @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
566:             * @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
567:             * @param icon the icon to display in the dialog
568:             * @param optionsCID an array of message CIDs indicating the possible choices the user can make
569:             * @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
570:             * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog 
571:             */
572:            public static int showOptionDialog(Component parentComponent,
573:                    String messageCID, String titleCID, int optionType,
574:                    int messageType, Icon icon, String[] optionsCID,
575:                    String initialCIDValue) {
576:                String firstLine = "";
577:
578:                return showOptionDialog(parentComponent, messageCID, titleCID,
579:                        optionType, messageType, icon, optionsCID,
580:                        initialCIDValue, firstLine);
581:            }
582:
583:            /**
584:             * 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. 
585:             * 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. 
586:             *
587:             * The messageType parameter is primarily used to supply a default icon from the look and feel.
588:             * @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
589:             * @param messageCID message country identification for a message to be displayed.
590:             * @param titleCID message country identification for a title to be displayed.
591:             * @param optionType an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTION
592:             * @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
593:             * @param icon the icon to display in the dialog
594:             * @param optionsCID an array of message CIDs indicating the possible choices the user can make
595:             * @param initialCIDValue the message CID that represents the default selection for the dialog; only meaningful if options is used; can be null
596:             * @param firstLine parameter is there to precede the messageCID with some situational information, like e.g. the name of a file.
597:             * @return an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the dialog 
598:             *
599:             * Typical usage for using the parameter firstLine:
600:             *      showOptionDialog(........, jfc.getSelectedFile().getPath() )
601:             */
602:            public static int showOptionDialog(Component parentComponent,
603:                    String messageCID, String titleCID, int optionType,
604:                    int messageType, Icon icon, String[] optionsCID,
605:                    String initialCIDValue, String firstLine) {
606:
607:                String message = messageCID;
608:                if (messageCID != null) {
609:                    message = it.businesslogic.ireport.util.I18n.getString(
610:                            messageCID, messageCID);
611:                }
612:                // begin modification Robert lamping, may 3, 2005
613:                if (firstLine != null || !firstLine.equals("")) {
614:                    message = firstLine + "\n" + message;
615:                }
616:                // End modification
617:
618:                String title = titleCID;
619:                if (titleCID != null) {
620:                    title = it.businesslogic.ireport.util.I18n.getString(
621:                            titleCID, titleCID);
622:                }
623:
624:                String initialValue = initialCIDValue;
625:                if (initialCIDValue != null) {
626:                    initialValue = it.businesslogic.ireport.util.I18n
627:                            .getString(initialCIDValue, initialCIDValue);
628:                }
629:
630:                String[] options = optionsCID;
631:                if (optionsCID != null) {
632:                    for (int i = 0; i < optionsCID.length; i++) {
633:                        if (optionsCID[i] != null) {
634:                            options[i] = it.businesslogic.ireport.util.I18n
635:                                    .getString(optionsCID[i], optionsCID[i]);
636:                        }
637:                    }
638:                }
639:
640:                return JOptionPane.showOptionDialog(parentComponent, message,
641:                        title, optionType, messageType, icon, options,
642:                        initialValue);
643:            }
644:
645:            /**
646:             * 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.
647:             * @param messageCID message country identification for a message to be displayed.
648:             * @return
649:             */
650:            public static String showInputDialog(String messageCID) {
651:
652:                String message = messageCID;
653:                if (messageCID != null) {
654:                    message = it.businesslogic.ireport.util.I18n.getString(
655:                            messageCID, messageCID);
656:                }
657:
658:                return JOptionPane.showInputDialog(message);
659:            }
660:
661:            /**
662:             * 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. 
663:             * @param messageCID message country identification for a message to be displayed.
664:             * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
665:             * @return
666:             */
667:            public static String showInputDialog(String messageCID,
668:                    String initialSelectionCIDValue) {
669:
670:                String message = messageCID;
671:                if (messageCID != null) {
672:                    message = it.businesslogic.ireport.util.I18n.getString(
673:                            messageCID, messageCID);
674:                }
675:
676:                String initialSelectionValue = initialSelectionCIDValue;
677:                if (initialSelectionCIDValue != null) {
678:                    initialSelectionValue = it.businesslogic.ireport.util.I18n
679:                            .getString(initialSelectionCIDValue,
680:                                    initialSelectionCIDValue);
681:                }
682:
683:                return JOptionPane.showInputDialog(message,
684:                        initialSelectionValue);
685:            }
686:
687:            /**
688:             * 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.
689:             * @param messageCID message country identification for a message to be displayed.
690:             * @param parentComponent the parent Component for the dialog
691:             * @return
692:             */
693:            public static String showInputDialog(Component parentComponent,
694:                    String messageCID) {
695:
696:                String message = messageCID;
697:                if (messageCID != null) {
698:                    message = it.businesslogic.ireport.util.I18n.getString(
699:                            messageCID, messageCID);
700:                }
701:
702:                return JOptionPane.showInputDialog(parentComponent, message);
703:            }
704:
705:            /**
706:             * 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.  
707:             * @param parentComponent the parent Component for the dialog
708:             * @param messageCID message country identification for a message to be displayed.
709:             * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
710:             * @return
711:             */
712:            public static String showInputDialog(Component parentComponent,
713:                    String messageCID, String initialSelectionCIDValue) {
714:
715:                String message = messageCID;
716:                if (messageCID != null) {
717:                    message = it.businesslogic.ireport.util.I18n.getString(
718:                            messageCID, messageCID);
719:                }
720:
721:                String initialSelectionValue = initialSelectionCIDValue;
722:                if (initialSelectionCIDValue != null) {
723:                    initialSelectionValue = it.businesslogic.ireport.util.I18n
724:                            .getString(initialSelectionCIDValue,
725:                                    initialSelectionCIDValue);
726:                }
727:
728:                return JOptionPane.showInputDialog(parentComponent, message,
729:                        initialSelectionValue);
730:            }
731:
732:            /**
733:             * Shows a dialog requesting input from the user parented to parentComponent with the dialog having the title title and message type messageType.   
734:             * @param parentComponent the parent Component for the dialog
735:             * @param messageCID message country identification for a message to be displayed.
736:             * @param titleCID message country identification for the String to display in the dialog title bar
737:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
738:             * @return
739:             */
740:            public static String showInputDialog(Component parentComponent,
741:                    String messageCID, String titleCID, int messageType) {
742:
743:                String message = messageCID;
744:                if (messageCID != null) {
745:                    message = it.businesslogic.ireport.util.I18n.getString(
746:                            messageCID, messageCID);
747:                }
748:
749:                String title = titleCID;
750:                if (titleCID != null) {
751:                    title = it.businesslogic.ireport.util.I18n.getString(
752:                            titleCID, titleCID);
753:                }
754:
755:                return JOptionPane.showInputDialog(parentComponent, message,
756:                        title, messageType);
757:            }
758:
759:            /**
760:             * 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. 
761:             * @param parentComponent the parent Component for the dialog
762:             * @param messageCID message country identification for a message to be displayed.
763:             * @param titleCID message country identification for the String to display in the dialog title bar
764:             * @param messageType the type of message that is to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
765:             * @param icon the Icon image to display
766:             * @param selectionCIDValues  message country identifications for an array of strings that gives the possible selections
767:             * @param initialSelectionCIDValue message country identification for the value used to initialize the input field.
768:             * @return
769:             */
770:            public static String showInputDialog(Component parentComponent,
771:                    String messageCID, String titleCID, int messageType,
772:                    Icon icon, String[] selectionCIDValues,
773:                    String initialSelectionCIDValue) {
774:
775:                String message = messageCID;
776:                if (messageCID != null) {
777:                    message = it.businesslogic.ireport.util.I18n.getString(
778:                            messageCID, messageCID);
779:                }
780:
781:                String title = titleCID;
782:                if (titleCID != null) {
783:                    title = it.businesslogic.ireport.util.I18n.getString(
784:                            titleCID, titleCID);
785:                }
786:
787:                String initialSelectionValue = initialSelectionCIDValue;
788:                if (initialSelectionCIDValue != null) {
789:                    initialSelectionValue = it.businesslogic.ireport.util.I18n
790:                            .getString(initialSelectionCIDValue,
791:                                    initialSelectionCIDValue);
792:                }
793:
794:                String[] selectionValues = selectionCIDValues;
795:                if (selectionCIDValues != null) {
796:                    for (int i = 0; i < selectionCIDValues.length; i++) {
797:                        if (selectionCIDValues[i] != null) {
798:                            selectionValues[i] = it.businesslogic.ireport.util.I18n
799:                                    .getString(selectionCIDValues[i],
800:                                            selectionCIDValues[i]);
801:                        }
802:                    }
803:                }
804:
805:                return (String) JOptionPane.showInputDialog(parentComponent,
806:                        message, title, messageType, icon, selectionValues,
807:                        initialSelectionValue);
808:            }
809:
810:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.