Source Code Cross Referenced for Dialogs.java in  » Database-Client » ViennaSQL » uk » co » whisperingwind » framework » 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 » Database Client » ViennaSQL » uk.co.whisperingwind.framework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         ** $Id: Dialogs.java,v 1.1 2000/10/26 08:34:34 mrw Exp $
003:         **
004:         ** Mike Wilson, July 2000, mrw@whisperingwind.co.uk
005:         **
006:         ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
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 as published by
010:         ** the Free Software Foundation; either version 2 of the License, or
011:         ** (at your option) any later version.
012:         ** 
013:         ** This program is distributed in the hope that it will be useful,
014:         ** but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         ** GNU General Public License for more details.
017:         ** 
018:         ** You should have received a copy of the GNU Library General
019:         ** Public License along with this library; if not, write to the
020:         ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
021:         ** Boston, MA  02111-1307  USA.
022:         */
023:
024:        package uk.co.whisperingwind.framework;
025:
026:        import java.lang.reflect.InvocationTargetException;
027:        import javax.swing.JOptionPane;
028:        import javax.swing.SwingUtilities;
029:
030:        /**
031:         ** Class contains static methods to display JOptionPane message
032:         ** dialogs. In all cases, the JOptionPane dialog is opened in the
033:         ** event dispatch thread.
034:         */
035:
036:        public class Dialogs {
037:            /**
038:             ** Show an error dialog.
039:             */
040:
041:            public static void showError(String title, String text) {
042:                MessageHelper messageHelper = new MessageHelper(title, text,
043:                        JOptionPane.ERROR_MESSAGE);
044:
045:                if (SwingUtilities.isEventDispatchThread()) {
046:                    messageHelper.run();
047:                } else {
048:                    try {
049:                        SwingUtilities.invokeAndWait(messageHelper);
050:                    } catch (InterruptedException ex) {
051:                        // Do nothing
052:                    } catch (InvocationTargetException ex) {
053:                        // Do nothing
054:                    }
055:                }
056:            }
057:
058:            /**
059:             ** Show a warning dialog.
060:             */
061:
062:            public static void showWarning(String title, String text) {
063:                MessageHelper messageHelper = new MessageHelper(title, text,
064:                        JOptionPane.WARNING_MESSAGE);
065:
066:                if (SwingUtilities.isEventDispatchThread()) {
067:                    messageHelper.run();
068:                } else {
069:                    try {
070:                        SwingUtilities.invokeAndWait(messageHelper);
071:                    } catch (InterruptedException ex) {
072:                        // Do nothing
073:                    } catch (InvocationTargetException ex) {
074:                        // Do nothing
075:                    }
076:                }
077:            }
078:
079:            /**
080:             ** Show an information dialog.
081:             */
082:
083:            public static void showInformation(String title, String text) {
084:                MessageHelper messageHelper = new MessageHelper(title, text,
085:                        JOptionPane.INFORMATION_MESSAGE);
086:
087:                if (SwingUtilities.isEventDispatchThread()) {
088:                    messageHelper.run();
089:                } else {
090:                    try {
091:                        SwingUtilities.invokeAndWait(messageHelper);
092:                    } catch (InterruptedException ex) {
093:                        // Do nothing
094:                    } catch (InvocationTargetException ex) {
095:                        // Do nothing
096:                    }
097:                }
098:            }
099:
100:            /**
101:             ** Show a yes/no/cancel dialog and return the result.
102:             */
103:
104:            public static int getConfirm(String title, String text) {
105:                ConfirmHelper confirmHelper = new ConfirmHelper(title, text,
106:                        JOptionPane.YES_NO_CANCEL_OPTION);
107:
108:                if (SwingUtilities.isEventDispatchThread()) {
109:                    confirmHelper.run();
110:                } else {
111:                    try {
112:                        SwingUtilities.invokeAndWait(confirmHelper);
113:                    } catch (InterruptedException ex) {
114:                        // Do nothing
115:                    } catch (InvocationTargetException ex) {
116:                        // Do nothing
117:                    }
118:                }
119:
120:                return confirmHelper.get();
121:            }
122:
123:            /**
124:             ** Show an option dialog and return the result.
125:             */
126:
127:            public static int getOption(String title, String text,
128:                    Object[] options, Object defaultOption) {
129:                OptionHelper optionHelper = new OptionHelper(title, text,
130:                        options, defaultOption);
131:
132:                if (SwingUtilities.isEventDispatchThread()) {
133:                    optionHelper.run();
134:                } else {
135:                    try {
136:                        SwingUtilities.invokeAndWait(optionHelper);
137:                    } catch (InterruptedException ex) {
138:                        // Do nothing
139:                    } catch (InvocationTargetException ex) {
140:                        // Do nothing
141:                    }
142:                }
143:
144:                return optionHelper.get();
145:            }
146:
147:            /**
148:             ** Superclass of message and confirm helpers.
149:             */
150:
151:            private static class Helper {
152:                protected String title = null;
153:                protected String text = null;
154:                protected int type = 0;
155:
156:                protected Helper(String title, String text, int type) {
157:                    this .title = title;
158:                    this .text = text;
159:                    this .type = type;
160:                }
161:            }
162:
163:            /**
164:             ** Message display helper class. Each message dialog uses an
165:             ** instance of this which it passes to invokeAndWait to make sure
166:             ** JOptionPane is called from the event thread.
167:             */
168:
169:            private static class MessageHelper extends Helper implements 
170:                    Runnable {
171:                public MessageHelper(String title, String text, int type) {
172:                    super (title, text, type);
173:                }
174:
175:                public void run() {
176:                    JOptionPane.showMessageDialog(null, text, title, type);
177:                }
178:            }
179:
180:            private static class ConfirmHelper extends Helper implements 
181:                    Runnable {
182:                private int result = 0;
183:
184:                public ConfirmHelper(String title, String text, int type) {
185:                    super (title, text, type);
186:                }
187:
188:                public void run() {
189:                    result = JOptionPane.showConfirmDialog(null, text, title,
190:                            type);
191:                }
192:
193:                public int get() {
194:                    return result;
195:                }
196:            }
197:
198:            private static class OptionHelper extends Helper implements 
199:                    Runnable {
200:                private int result = 0;
201:                Object[] options = null;
202:                Object defaultOption = null;
203:
204:                public OptionHelper(String title, String text,
205:                        Object[] options, Object defaultOption) {
206:                    super (title, text, 0);
207:                    this .options = options;
208:                    this .defaultOption = defaultOption;
209:                }
210:
211:                public void run() {
212:                    result = JOptionPane.showOptionDialog(null, text, title,
213:                            JOptionPane.DEFAULT_OPTION,
214:                            JOptionPane.WARNING_MESSAGE, null, options,
215:                            defaultOption);
216:                }
217:
218:                public int get() {
219:                    return result;
220:                }
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.