Source Code Cross Referenced for XOptionPane.java in  » Workflow-Engines » osbl-1_0 » org » osbl » client » wings » 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 » Workflow Engines » osbl 1_0 » org.osbl.client.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.osbl.client.wings;
002:
003:        import org.wings.*;
004:        import org.wings.plaf.OptionPaneCG;
005:        import org.wings.resource.ResourceManager;
006:        import org.wings.border.SBorder;
007:        import org.wings.border.SEmptyBorder;
008:        import org.apache.commons.logging.Log;
009:        import org.apache.commons.logging.LogFactory;
010:        import org.osbl.client.wings.XButton;
011:        import org.osbl.client.wings.shell.Client;
012:
013:        import javax.swing.*;
014:        import java.awt.*;
015:        import java.awt.event.ActionEvent;
016:        import java.awt.event.ActionListener;
017:        import java.util.StringTokenizer;
018:
019:        /**
020:         * An immodal dialog contentPane offering several options for selection (like Yes/No, etc.)
021:         *
022:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
023:         * @version $Revision: 2752 $
024:         */
025:        public class XOptionPane extends SDialog implements  ActionListener {
026:            private final transient static Log log = LogFactory
027:                    .getLog(XOptionPane.class);
028:
029:            /**
030:             * Actionb Performed Value if Yes is Choosen
031:             */
032:            public static final String YES_ACTION = "YES";
033:
034:            /**
035:             * Action Performed Value if No is choosen
036:             */
037:            public static final String NO_ACTION = "NO";
038:
039:            /**
040:             * Action Performed Value if Ok is choosen
041:             */
042:            public static final String OK_ACTION = "OK";
043:
044:            /**
045:             * Action Performed Value if Cancel is choosen
046:             */
047:            public static final String CANCEL_ACTION = "CANCEL";
048:
049:            /**
050:             * Action Performed Value Unknow
051:             */
052:            public static final String UNKNOWN_ACTION = "UNKNOWN";
053:
054:            /**
055:             * Return value if Ok is choosen
056:             */
057:            public static final int OK_OPTION = JOptionPane.OK_OPTION;
058:
059:            /**
060:             * Return value if Cancel is choosen
061:             */
062:            public static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION;
063:
064:            /**
065:             * Return Value if Yes is choosen
066:             */
067:            public static final int YES_OPTION = JOptionPane.YES_OPTION;
068:
069:            /**
070:             * Return value if no is choosen
071:             */
072:            public static final int NO_OPTION = JOptionPane.NO_OPTION;
073:
074:            public static final int RESET_OPTION = 999;
075:
076:            /**
077:             * Type meaning look and feel should not supply any options -- only
078:             * use the options from the JOptionPane.
079:             */
080:            public static final int DEFAULT_OPTION = JOptionPane.DEFAULT_OPTION;
081:
082:            /**
083:             * Used for showConfirmDialog.
084:             */
085:            public static final int OK_CANCEL_OPTION = JOptionPane.OK_CANCEL_OPTION;
086:
087:            /**
088:             * Used for showConfirmDialog.
089:             */
090:            public static final int OK_CANCEL_RESET_OPTION = OK_CANCEL_OPTION + 1000;
091:
092:            /**
093:             * Used for showConfirmDialog.
094:             */
095:            public static final int YES_NO_OPTION = JOptionPane.YES_NO_OPTION;
096:
097:            /**
098:             * Used for showConfirmDialog.
099:             */
100:            public static final int YES_NO_RESET_OPTION = YES_NO_OPTION + 1000;
101:
102:            /**
103:             * Used for showConfirmDialog.
104:             */
105:            public static final int YES_NO_CANCEL_OPTION = JOptionPane.YES_NO_CANCEL_OPTION;
106:
107:            /**
108:             * Used for showConfirmDialog.
109:             */
110:            public static final int YES_NO_CANCEL_RESET_OPTION = YES_NO_CANCEL_OPTION + 1000;
111:
112:            //
113:            // Message types. Used UI to determine the kind of icon to display,
114:            // and possibly what behavior to give based on the type.
115:            //
116:            /*
117:             * Error messages.
118:             */
119:            public static final int ERROR_MESSAGE = javax.swing.JOptionPane.ERROR_MESSAGE;
120:            /*
121:             * Information messages.
122:             */
123:            public static final int INFORMATION_MESSAGE = javax.swing.JOptionPane.INFORMATION_MESSAGE;
124:            /*
125:             * Warning messages.
126:             */
127:            public static final int WARNING_MESSAGE = javax.swing.JOptionPane.WARNING_MESSAGE;
128:            /*
129:             * Questions.
130:             */
131:            public static final int QUESTION_MESSAGE = javax.swing.JOptionPane.QUESTION_MESSAGE;
132:            /*
133:             * No icon.
134:             */
135:            public static final int PLAIN_MESSAGE = javax.swing.JOptionPane.PLAIN_MESSAGE;
136:
137:            /**
138:             * ContentPane with border layout.
139:             */
140:            private final SContainer contents = new SPanel(new SBorderLayout());
141:
142:            /**
143:             * Die Message des OptionPanes wird hier rein getan.
144:             */
145:            private final SContainer optionData = new SPanel(
146:                    new SFlowDownLayout());
147:
148:            /**
149:             * Die Message des OptionPanes wird hier rein getan.
150:             */
151:            private final SContainer images = new SPanel();
152:
153:            /**
154:             * Panel with Option Buttons
155:             */
156:            protected final SContainer optionButtons = new SPanel(
157:                    new SFlowLayout(SConstants.RIGHT));
158:
159:            /**
160:             * OK Button
161:             */
162:            protected final XButton optionOK = createLocalizedButton("ok");
163:
164:            /**
165:             * Cancel Button
166:             */
167:            protected final XButton optionCancel = createLocalizedButton("cancel");
168:
169:            /**
170:             * Yes Button
171:             */
172:            protected final XButton optionYes = createLocalizedButton("yes");
173:
174:            /**
175:             * No Button
176:             */
177:            protected final XButton optionNo = createLocalizedButton("no");
178:
179:            final SBorder empty = new SEmptyBorder(new Insets(6, 24, 6, 24));
180:
181:            /**
182:             * Icon for Inform Dialog
183:             */
184:            private static final SIcon messageImage = (SIcon) ResourceManager
185:                    .getObject("SOptionPane.messageIcon", SIcon.class);
186:
187:            /**
188:             * Icon for Input Dialog
189:             */
190:            private static final SIcon questionImage = (SIcon) ResourceManager
191:                    .getObject("SOptionPane.questionIcon", SIcon.class);
192:
193:            /**
194:             * Icon for Show Confirm Dialog
195:             */
196:            private static final SIcon yesnoImage = (SIcon) ResourceManager
197:                    .getObject("SOptionPane.yesnoIcon", SIcon.class);
198:
199:            /**
200:             * Icon for Error Dialog
201:             */
202:            private static final SIcon errorImage = (SIcon) ResourceManager
203:                    .getObject("SOptionPane.errorIcon", SIcon.class);
204:
205:            // The label that contains the option pane image.
206:            protected final SLabel imageLabel = new SLabel();
207:
208:            /**
209:             * The chosen option
210:             *
211:             * @see #OK_OPTION
212:             * @see #YES_OPTION
213:             * @see #CANCEL_OPTION
214:             * @see #NO_OPTION
215:             */
216:            protected Object selected = null;
217:
218:            /*
219:             * Icon used in pane.
220:             */
221:            protected SIcon icon;
222:
223:            /*
224:             * Message to display.
225:             */
226:            protected Object message;
227:
228:            /*
229:             * Options to display to the user.
230:             */
231:            protected Object[] options;
232:
233:            /*
234:             * Value that should be initialy selected in options.
235:             */
236:            protected Object initialValue;
237:
238:            /*
239:             * Message type.
240:             */
241:            protected int messageType;
242:            private Object inputValue;
243:
244:            /**
245:             * Default Constructor for <code>XOptionPane</code>
246:             * Against the Standard Swing Implementation there is no Standard Message
247:             */
248:            public XOptionPane() {
249:                this (null);
250:            }
251:
252:            /*
253:             * Creates a instance of <code>XOptionPane</code> with a message
254:             *
255:             * @param message the <code>Object</code> to display
256:             */
257:            public XOptionPane(Object message) {
258:                this (message, PLAIN_MESSAGE);
259:            }
260:
261:            /*
262:             * Creates an instance of <code>XOptionPane</code> to display a message
263:             * with the specified message and the default options,
264:             *
265:             * @param message the <code>Object</code> to display
266:             * @param messageType the type of message to be displayed:
267:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
268:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
269:             */
270:            public XOptionPane(Object message, int messageType) {
271:                this (message, messageType, DEFAULT_OPTION);
272:            }
273:
274:            /**
275:             * Creates an instance of <code>JOptionPane</code> to display a message
276:             * with the specified message type and options.
277:             *
278:             * @param message     the <code>Object</code> to display
279:             * @param messageType the type of message to be displayed:
280:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
281:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
282:             * @param optionType  the options to display in the pane:
283:             *                    DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
284:             *                    OK_CANCEL_OPTION
285:             */
286:            public XOptionPane(Object message, int messageType, int optionType) {
287:                this (message, messageType, optionType, null);
288:            }
289:
290:            /**
291:             * Creates an instance of <code>JOptionPane</code> to display a message
292:             * with the specified message type, options, and icon.
293:             *
294:             * @param message     the <code>Object</code> to display
295:             * @param messageType the type of message to be displayed:
296:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
297:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
298:             * @param optionType  the options to display in the pane:
299:             *                    DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
300:             *                    OK_CANCEL_OPTION
301:             * @param icon        the <code>Icon</code> image to display
302:             */
303:            public XOptionPane(Object message, int messageType, int optionType,
304:                    SIcon icon) {
305:                this (message, messageType, optionType, icon, null);
306:            }
307:
308:            /**
309:             * Creates an instance of JOptionPane to display a message
310:             * with the specified message type, icon, and options.
311:             * None of the options is initially selected.
312:             * <p/>
313:             * The options objects should contain either instances of
314:             * <code>Component</code>s, (which are added directly) or
315:             * <code>Strings</code> (which are wrapped in a <code>JButton</code>).
316:             * If you provide <code>Component</code>s, you must ensure that when the
317:             * <code>Component</code> is clicked it messages <code>setValue</code>
318:             * in the created <code>JOptionPane</code>.
319:             *
320:             * @param message     the <code>Object</code> to display
321:             * @param messageType the type of message to be displayed:
322:             *                    ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
323:             *                    QUESTION_MESSAGE, or PLAIN_MESSAGE
324:             * @param optionType  the options to display in the pane:
325:             *                    DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
326:             *                    OK_CANCEL_OPTION; only meaningful if the
327:             *                    <code>options</code> parameter is <code>null</code>
328:             * @param icon        the <code>Icon</code> image to display
329:             * @param options     the choices the user can select
330:             */
331:            public XOptionPane(Object message, int messageType, int optionType,
332:                    SIcon icon, Object[] options) {
333:                this (message, messageType, optionType, icon, options, null);
334:            }
335:
336:            /**
337:             * Creates an instance of <code>JOptionPane</code> to display a message
338:             * with the specified message type, icon, and options, with the
339:             * initially-selected option specified.
340:             *
341:             * @param message      the <code>Object</code> to display
342:             * @param messageType  the type of message to be displayed:
343:             *                     ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
344:             *                     QUESTION_MESSAGE, or PLAIN_MESSAGE
345:             * @param optionType   the options to display in the pane:
346:             *                     DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION
347:             *                     OK_CANCEL_OPTION; only meaningful if the
348:             *                     <code>options</code> parameter is <code>null</code>
349:             * @param icon         the Icon image to display
350:             * @param options      the choices the user can select
351:             * @param initialValue the choice that is initially selected
352:             */
353:            public XOptionPane(Object message, int messageType, int optionType,
354:                    SIcon icon, Object[] options, Object initialValue) {
355:                this .message = message;
356:                this .options = options;
357:                this .initialValue = initialValue;
358:                this .icon = icon;
359:                SGridLayout layout = new SGridLayout(1);
360:                setLayout(layout);
361:                initPanel();
362:                setOptionType(optionType);
363:                setMessageType(messageType);
364:                // value = UNINITIALIZED_VALUE;
365:                // inputValue = UNINITIALIZED_VALUE;
366:                setStyle("SOptionPane");
367:            }
368:
369:            public void setCG(OptionPaneCG cg) {
370:                super .setCG(cg);
371:            }
372:
373:            public Object getInputValue() {
374:                return inputValue;
375:            }
376:
377:            private void initPanel() {
378:                //setHorizontalAlignment(SConstants.LEFT);
379:                ((SFlowLayout) optionButtons.getLayout()).setHgap(8);
380:                optionButtons.add(optionOK, "OK");
381:                optionButtons.add(optionYes, "YES");
382:                optionButtons.add(optionCancel, "CANCEL");
383:                optionButtons.add(optionNo, "NO");
384:                optionButtons.setPreferredSize(SDimension.FULLWIDTH);
385:                optionButtons.setBorder(new SEmptyBorder(8, 0, 0, 0));
386:
387:                imageLabel.setBorder(new SEmptyBorder(0, 0, 0, 8));
388:                images.add(imageLabel);
389:                imageLabel.setToolTipText(null);
390:
391:                optionData.setPreferredSize(SDimension.FULLWIDTH);
392:                //((SFlowLayout) optionData.getLayout()).setVgap(8);
393:
394:                contents.add(optionData, SBorderLayout.CENTER);
395:                contents.add(images, SBorderLayout.WEST);
396:                contents.setPreferredSize(SDimension.FULLWIDTH);
397:
398:                add(contents);
399:                add(optionButtons);
400:            }
401:
402:            /**
403:             * Generic Button creation
404:             */
405:            protected XButton createLocalizedButton(String key) {
406:                XButton b = new XButton(Client.getInstance()
407:                        .getResourceProvider().getMessage(
408:                                "org.osbl.client.wings.XOptionPane." + key));
409:                b.setName(getName() + "$" + key);
410:                b.addActionListener(this );
411:                return b;
412:            }
413:
414:            public void actionPerformed(ActionEvent e) {
415:                log.debug("action " + e);
416:                hide();
417:                selected = e.getSource();
418:
419:                if (e.getSource() == optionOK) {
420:                    fireActionPerformed(OK_ACTION);
421:                } else if (e.getSource() == optionYes) {
422:                    fireActionPerformed(YES_ACTION);
423:                } else if (e.getSource() == optionCancel) {
424:                    fireActionPerformed(CANCEL_ACTION);
425:                } else if (e.getSource() == optionNo) {
426:                    fireActionPerformed(NO_ACTION);
427:                } else {
428:                    fireActionPerformed(UNKNOWN_ACTION);
429:                }
430:            }
431:
432:            protected void fireActionPerformed(String pActionCommand) {
433:                if (pActionCommand != null)
434:                    super .fireActionPerformed(pActionCommand);
435:            }
436:
437:            protected void resetOptions() {
438:                optionOK.setVisible(false);
439:                optionYes.setVisible(false);
440:                optionCancel.setVisible(false);
441:                optionNo.setVisible(false);
442:            }
443:
444:            SContainer customButtons = null;
445:
446:            public void setOptions(Object[] options) {
447:                resetOptions();
448:
449:                if (customButtons == null)
450:                    customButtons = new SPanel();
451:
452:                for (int i = 0; i < options.length; i++) {
453:                    if (options[i] instanceof  SComponent) {
454:                        if (options[i] instanceof  SAbstractButton)
455:                            ((SAbstractButton) options[i])
456:                                    .addActionListener(this );
457:                        customButtons.add((SComponent) options[i]);
458:                    } else {
459:                        SButton b = new SButton(options[i].toString());
460:                        b.addActionListener(this );
461:                        customButtons.add(b);
462:                    }
463:                }
464:
465:                add(customButtons);
466:            }
467:
468:            /**
469:             * Sets the option pane's message type.
470:             * Dependent to the MessageType there wil be displayed a different Message Label
471:             *
472:             * @param newType an integer specifying the kind of message to display:
473:             *                ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
474:             *                QUESTION_MESSAGE, or PLAIN_MESSAGE
475:             *                <p/>
476:             *                description: The option pane's message type.
477:             */
478:            public void setMessageType(int newType) {
479:                switch (newType) {
480:                case ERROR_MESSAGE: {
481:                    imageLabel.setIcon(errorImage);
482:                    imageLabel.setToolTipText(Client.getInstance()
483:                            .getResourceProvider().getMessage(
484:                                    "org.osbl.client.wings.XOptionPane.error"));
485:                    break;
486:                }
487:                case INFORMATION_MESSAGE: {
488:                    imageLabel.setIcon(messageImage);
489:                    imageLabel
490:                            .setToolTipText(Client
491:                                    .getInstance()
492:                                    .getResourceProvider()
493:                                    .getMessage(
494:                                            "org.osbl.client.wings.XOptionPane.information"));
495:                    break;
496:                }
497:                case WARNING_MESSAGE: {
498:                    imageLabel.setIcon(yesnoImage);
499:                    imageLabel
500:                            .setToolTipText(Client
501:                                    .getInstance()
502:                                    .getResourceProvider()
503:                                    .getMessage(
504:                                            "org.osbl.client.wings.XOptionPane.warning"));
505:                    break;
506:                }
507:                case QUESTION_MESSAGE: {
508:                    imageLabel.setIcon(questionImage);
509:                    imageLabel
510:                            .setToolTipText(Client
511:                                    .getInstance()
512:                                    .getResourceProvider()
513:                                    .getMessage(
514:                                            "org.osbl.client.wings.XOptionPane.question"));
515:                    break;
516:                }
517:                case PLAIN_MESSAGE:
518:                default: {
519:                    imageLabel.setIcon(null);
520:                    imageLabel.setToolTipText(null);
521:                }
522:                }
523:
524:                messageType = newType;
525:            }
526:
527:            /**
528:             * Returns the message type.
529:             *
530:             * @return an integer specifying the message type
531:             * @see #setMessageType
532:             */
533:            public int getMessageType() {
534:                return messageType;
535:            }
536:
537:            public void setOptionType(int newType) {
538:                resetOptions();
539:
540:                switch (newType) {
541:                case DEFAULT_OPTION:
542:                    optionOK.setVisible(true);
543:                    optionOK.requestFocus();
544:                    break;
545:
546:                case OK_CANCEL_OPTION:
547:                    optionOK.setVisible(true);
548:                    optionOK.requestFocus();
549:                    optionCancel.setVisible(true);
550:                    break;
551:
552:                case OK_CANCEL_RESET_OPTION:
553:                    optionOK.setVisible(true);
554:                    optionOK.requestFocus();
555:                    optionCancel.setVisible(true);
556:                    break;
557:
558:                case YES_NO_OPTION:
559:                    optionYes.setVisible(true);
560:                    optionYes.requestFocus();
561:                    optionNo.setVisible(true);
562:                    break;
563:
564:                case YES_NO_RESET_OPTION:
565:                    optionYes.setVisible(true);
566:                    optionYes.requestFocus();
567:                    optionNo.setVisible(true);
568:                    break;
569:
570:                case YES_NO_CANCEL_OPTION:
571:                    optionYes.setVisible(true);
572:                    optionYes.requestFocus();
573:                    optionNo.setVisible(true);
574:                    optionCancel.setVisible(true);
575:                    break;
576:
577:                case YES_NO_CANCEL_RESET_OPTION:
578:                    optionYes.setVisible(true);
579:                    optionYes.requestFocus();
580:                    optionNo.setVisible(true);
581:                    optionCancel.setVisible(true);
582:                    break;
583:                }
584:            }
585:
586:            public void showOption(SComponent c, String title, Object message) {
587:                if (title != null)
588:                    setTitle(title);
589:
590:                optionData.removeAll();
591:                if (message instanceof  SComponent) {
592:                    optionData.add((SComponent) message);
593:                } else {
594:                    StringTokenizer stt = new StringTokenizer(message
595:                            .toString(), "\n");
596:                    while (stt.hasMoreElements()) {
597:                        optionData
598:                                .add(new SLabel(stt.nextElement().toString()));
599:                    }
600:                }
601:                show(c);
602:            }
603:
604:            public void showPlainMessage(SComponent parent, Object message,
605:                    String title) {
606:                showOption(parent, title, message);
607:
608:                setOptionType(XOptionPane.DEFAULT_OPTION);
609:                setMessageType(XOptionPane.PLAIN_MESSAGE);
610:            }
611:
612:            public void showQuestion(SComponent parent, Object message,
613:                    String title) {
614:                showOption(parent, title, message);
615:
616:                setOptionType(XOptionPane.OK_CANCEL_OPTION);
617:                setMessageType(XOptionPane.QUESTION_MESSAGE);
618:            }
619:
620:            public void showInput(SComponent parent, Object message,
621:                    SComponent inputElement, String title) {
622:                showOption(parent, title, message);
623:                optionData.add(inputElement);
624:                inputValue = inputElement;
625:
626:                setOptionType(XOptionPane.OK_CANCEL_OPTION);
627:                setMessageType(XOptionPane.QUESTION_MESSAGE);
628:            }
629:
630:            public void showYesNo(SComponent parent, Object question,
631:                    String title) {
632:                showOption(parent, title, question);
633:                setOptionType(YES_NO_OPTION);
634:                setMessageType(XOptionPane.QUESTION_MESSAGE);
635:            }
636:
637:            public void showQuestion(SComponent parent, Object question,
638:                    String title, int type) {
639:                showOption(parent, title, question);
640:                setOptionType(type);
641:                setMessageType(XOptionPane.QUESTION_MESSAGE);
642:            }
643:
644:            // -------------------------------------------------------------------
645:            // MESSAGE DIALOGS
646:            // -------------------------------------------------------------------
647:
648:            public static void showMessageDialog(SComponent parent,
649:                    Object message) {
650:                showMessageDialog(parent, message, null,
651:                        XOptionPane.INFORMATION_MESSAGE, null);
652:            }
653:
654:            public static void showMessageDialog(SComponent parent,
655:                    Object message, String title) {
656:                showMessageDialog(parent, message, title,
657:                        XOptionPane.INFORMATION_MESSAGE, null);
658:            }
659:
660:            public static void showMessageDialog(SComponent parent,
661:                    Object message, ActionListener al) {
662:                showMessageDialog(parent, message, null,
663:                        XOptionPane.INFORMATION_MESSAGE, al);
664:            }
665:
666:            public static void showMessageDialog(SComponent parent,
667:                    Object message, String title, int messageType,
668:                    ActionListener al) {
669:                XOptionPane p = new XOptionPane();
670:
671:                p.showOption(parent, title, message);
672:                p.setMessageType(messageType);
673:                p.addActionListener(al);
674:            }
675:
676:            // -------------------------------------------------------------------
677:            // PLAIN MESSAGE DIALOGS
678:            // -------------------------------------------------------------------
679:
680:            public static void showPlainMessageDialog(SComponent parent,
681:                    Object message) {
682:                showPlainMessageDialog(parent, message, null, null);
683:            }
684:
685:            public static void showPlainMessageDialog(SComponent parent,
686:                    Object message, String title) {
687:                showPlainMessageDialog(parent, message, title, null);
688:            }
689:
690:            public static void showPlainMessageDialog(SComponent parent,
691:                    Object message, ActionListener al) {
692:                showPlainMessageDialog(parent, message, null, al);
693:            }
694:
695:            public static void showPlainMessageDialog(SComponent parent,
696:                    Object message, String title, ActionListener al) {
697:                XOptionPane p = new XOptionPane();
698:
699:                p.showOption(parent, title, message);
700:                p.setMessageType(XOptionPane.PLAIN_MESSAGE);
701:                p.addActionListener(al);
702:            }
703:
704:            // -------------------------------------------------------------------
705:            // INPUT DIALOGS
706:            // -------------------------------------------------------------------
707:
708:            public static void showInputDialog(SComponent parent,
709:                    Object question, String title, SComponent inputElement,
710:                    ActionListener al) {
711:                showInputDialog(parent, question, title,
712:                        XOptionPane.QUESTION_MESSAGE, inputElement, al);
713:            }
714:
715:            public static void showInputDialog(SComponent parent,
716:                    Object question, String title, int messageType,
717:                    SComponent inputElement, ActionListener al) {
718:                XOptionPane p = new XOptionPane();
719:
720:                p.showInput(parent, question, inputElement, title);
721:                p.setMessageType(messageType);
722:                p.addActionListener(al);
723:            }
724:
725:            // -------------------------------------------------------------------
726:            // QUESTION DIALOGS
727:            // -------------------------------------------------------------------
728:
729:            public static void showQuestionDialog(SComponent parent,
730:                    Object question, String title, ActionListener al) {
731:                XOptionPane p = new XOptionPane();
732:
733:                p.showQuestion(parent, question, title);
734:                p.setMessageType(XOptionPane.QUESTION_MESSAGE);
735:                p.addActionListener(al);
736:            }
737:
738:            // -------------------------------------------------------------------
739:            // PLAIN QUESTION DIALOGS
740:            // -------------------------------------------------------------------
741:
742:            public static void showPlainQuestionDialog(SComponent parent,
743:                    Object question, String title, ActionListener al) {
744:                XOptionPane p = new XOptionPane();
745:
746:                p.showQuestion(parent, question, title);
747:                p.setMessageType(XOptionPane.PLAIN_MESSAGE);
748:                p.addActionListener(al);
749:            }
750:
751:            // -------------------------------------------------------------------
752:            // CONFIRM DIALOGS
753:            // -------------------------------------------------------------------
754:
755:            public static void showConfirmDialog(SComponent parent,
756:                    Object message, String title) {
757:                showConfirmDialog(parent, message, title, 0, null);
758:            }
759:
760:            public static void showConfirmDialog(SComponent parent,
761:                    Object message, String title, ActionListener al) {
762:                showConfirmDialog(parent, message, title, 0, al);
763:            }
764:
765:            public static void showConfirmDialog(SComponent parent,
766:                    Object message, String title, int type) {
767:                showConfirmDialog(parent, message, title, type, null);
768:            }
769:
770:            public static void showConfirmDialog(SComponent parent,
771:                    Object message, String title, int type, ActionListener al) {
772:                showConfirmDialog(parent, message, title, type, al, null);
773:            }
774:
775:            public static void showConfirmDialog(SComponent parent,
776:                    Object message, String title, int type, ActionListener al,
777:                    SLayoutManager layout) {
778:                XOptionPane p = new XOptionPane();
779:
780:                if (layout != null) {
781:                    p.optionButtons.setLayout(layout);
782:                } // end of if ()
783:
784:                p.showQuestion(parent, message, title, type);
785:                p.addActionListener(al);
786:            }
787:
788:            // -------------------------------------------------------------------
789:            // YES-NO DIALOGS
790:            // -------------------------------------------------------------------
791:
792:            public static void showYesNoDialog(SComponent parent,
793:                    Object question, String title, ActionListener al) {
794:                XOptionPane p = new XOptionPane();
795:                p.addActionListener(al);
796:
797:                p.showYesNo(parent, question, title);
798:            }
799:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.