Source Code Cross Referenced for CommentsFeedbackWindow.java in  » Database-Client » DBBrowser » org » dbbrowser » ui » 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 » DBBrowser » org.dbbrowser.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.dbbrowser.ui;
002:
003:        import infrastructure.internationalization.InternationalizationManager;
004:        import infrastructure.propertymanager.PropertyManager;
005:        import infrastructure.logging.Log;
006:        import javax.swing.*;
007:        import java.awt.event.ActionListener;
008:        import java.awt.event.ActionEvent;
009:        import java.awt.*;
010:        import java.util.List;
011:        import java.util.ArrayList;
012:        import org.dbbrowser.ui.widget.Button;
013:        import org.dbbrowser.ui.panel.ButtonsPanel;
014:        import org.dbbrowser.util.MailException;
015:        import org.dbbrowser.util.MailManager;
016:
017:        /**
018:         * A window which can be used by the user to enter commnets/feedback.  The user click on send to send the comment/feedback
019:         */
020:        public class CommentsFeedbackWindow implements  ActionListener {
021:            private static final String COMMENTS_FEEDBACK_ICON_FILENAME = PropertyManager
022:                    .getInstance()
023:                    .getProperty(
024:                            "dbbrowser-ui-dbbrowser-window-help-comments-feedback-menu-icon");
025:
026:            private static final String COMMENTS_FEEDBACK_WINDOW_TITLE = InternationalizationManager
027:                    .getInstance()
028:                    .getMessage(
029:                            "dbbrowser-ui",
030:                            "dbbrowser-ui-dbbrowser-window-help-menu-comments-feedback-label",
031:                            null);
032:            private static final String MESSAGE_NOT_SENT_ERROR_MESSAGE = InternationalizationManager
033:                    .getInstance()
034:                    .getMessage(
035:                            "dbbrowser-ui",
036:                            "dbbrowser-ui-comments-feedback-window-message-not-sent-label",
037:                            null);
038:            private static final String COMMENTS_NOT_ENTERED_ERROR_MESSAGE = InternationalizationManager
039:                    .getInstance()
040:                    .getMessage(
041:                            "dbbrowser-ui",
042:                            "dbbrowser-ui-comments-feedback-window-comments-is-mandatory-in-comment-feedback-label",
043:                            null);
044:            private static final String DESTINATION_ADDRESS_LABEL = InternationalizationManager
045:                    .getInstance()
046:                    .getMessage(
047:                            "dbbrowser-ui",
048:                            "dbbrowser-ui-comments-feedback-window-destination-email-label",
049:                            null);
050:            private static final String EMAIL_ADDRESS_LABEL = InternationalizationManager
051:                    .getInstance()
052:                    .getMessage(
053:                            "dbbrowser-ui",
054:                            "dbbrowser-ui-comments-feedback-window-email-address-label",
055:                            null);
056:            private static final String SUBJECT_LABEL = InternationalizationManager
057:                    .getInstance()
058:                    .getMessage(
059:                            "dbbrowser-ui",
060:                            "dbbrowser-ui-comments-feedback-window-subject-label",
061:                            null);
062:            private static final String COMMENTS_FEEDBACK_LABEL = InternationalizationManager
063:                    .getInstance()
064:                    .getMessage(
065:                            "dbbrowser-ui",
066:                            "dbbrowser-ui-comments-feedback-window-comments-feedback-label",
067:                            null);
068:            private static final String SEND_BUTTON_LABEL = InternationalizationManager
069:                    .getInstance()
070:                    .getMessage(
071:                            "dbbrowser-ui",
072:                            "dbbrowser-ui-comments-feedback-window-send-button-label",
073:                            null);
074:
075:            private JFrame frame = new JFrame();
076:            private JTextField textFieldForDestinationEmailAddress = null;
077:            private JTextField textFieldForEmailAddress = null;
078:            private JTextField textFieldForSubject = null;
079:            private JTextArea textAreaForCommentsFeedback = null;
080:
081:            /**
082:             * Constructer
083:             */
084:            public CommentsFeedbackWindow() {
085:                initialize();
086:            }
087:
088:            /**
089:             * Show the UI
090:             */
091:            public void show() {
092:                this .frame.show();
093:            }
094:
095:            public void actionPerformed(ActionEvent e) {
096:                //Get the values entered by the user
097:                String sendersEmailAddress = this .textFieldForEmailAddress
098:                        .getText();
099:                String subject = this .textFieldForSubject.getText();
100:                String comments = this .textAreaForCommentsFeedback.getText();
101:
102:                //Only comments is mandatory
103:                if ((comments != null) && (!"".equals(comments))) {
104:                    try {
105:                        Log.getInstance().debugMessage(
106:                                "Trying to send email...",
107:                                this .getClass().getName());
108:                        MailManager.sendEmail(sendersEmailAddress, subject,
109:                                comments);
110:                        Log.getInstance().debugMessage("Message sent",
111:                                this .getClass().getName());
112:                        this .frame.pack();
113:                        this .frame.dispose();
114:                        this .frame = null;
115:                    } catch (MailException exc) {
116:                        Log.getInstance().fatalMessage(
117:                                "Message not sent - " + exc.getMessage(),
118:                                this .getClass().getName());
119:                        JOptionPane.showMessageDialog(null,
120:                                MESSAGE_NOT_SENT_ERROR_MESSAGE + " - "
121:                                        + exc.getMessage(),
122:                                COMMENTS_FEEDBACK_WINDOW_TITLE,
123:                                JOptionPane.ERROR_MESSAGE);
124:                    }
125:                } else {
126:                    JOptionPane.showMessageDialog(null,
127:                            COMMENTS_NOT_ENTERED_ERROR_MESSAGE,
128:                            COMMENTS_FEEDBACK_WINDOW_TITLE,
129:                            JOptionPane.ERROR_MESSAGE);
130:                }
131:            }
132:
133:            private void initialize() {
134:                this .frame.setTitle(COMMENTS_FEEDBACK_WINDOW_TITLE);
135:                this .frame.setSize(600, 400);
136:                this .frame.setLocationRelativeTo(null);
137:                this .frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
138:                this .frame.setIconImage((new ImageIcon(
139:                        COMMENTS_FEEDBACK_ICON_FILENAME)).getImage());
140:
141:                //Setup the widgets
142:                JLabel labelForDestinationEmailAddress = new JLabel(
143:                        DESTINATION_ADDRESS_LABEL);
144:                textFieldForDestinationEmailAddress = new JTextField(
145:                        "DBBrowser");
146:                textFieldForDestinationEmailAddress.setEditable(false);
147:                JLabel labelForEmailAddress = new JLabel(EMAIL_ADDRESS_LABEL);
148:                textFieldForEmailAddress = new JTextField();
149:                JLabel labelForSubject = new JLabel(SUBJECT_LABEL);
150:                textFieldForSubject = new JTextField();
151:                textAreaForCommentsFeedback = new JTextArea();
152:
153:                //Add widgets to the panel
154:                JPanel p = new JPanel(new GridLayout(3, 2));
155:                p.add(labelForDestinationEmailAddress);
156:                p.add(textFieldForDestinationEmailAddress);
157:                p.add(labelForEmailAddress);
158:                p.add(textFieldForEmailAddress);
159:                p.add(labelForSubject);
160:                p.add(textFieldForSubject);
161:
162:                this .frame.getContentPane().setLayout(
163:                        new BoxLayout(this .frame.getContentPane(),
164:                                BoxLayout.PAGE_AXIS));
165:                this .frame.getContentPane().add(p);
166:
167:                JPanel panelForComments = new JPanel();
168:                panelForComments.setPreferredSize(new Dimension(
169:                        panelForComments.getMinimumSize().width, 600));
170:                panelForComments.setLayout(new BoxLayout(panelForComments,
171:                        BoxLayout.PAGE_AXIS));
172:                this .textAreaForCommentsFeedback.setLineWrap(true);
173:                JScrollPane paneForCommentsFeedback = new JScrollPane(
174:                        this .textAreaForCommentsFeedback);
175:                paneForCommentsFeedback
176:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
177:                panelForComments.add(paneForCommentsFeedback);
178:                panelForComments.setBorder(BorderFactory
179:                        .createTitledBorder(COMMENTS_FEEDBACK_LABEL));
180:                this .frame.getContentPane().add(panelForComments);
181:
182:                Button buttonToSendMessage = new Button(SEND_BUTTON_LABEL,
183:                        this , SEND_BUTTON_LABEL, new ImageIcon(
184:                                COMMENTS_FEEDBACK_ICON_FILENAME), Boolean.TRUE);
185:                List listOfButtons = new ArrayList();
186:                listOfButtons.add(buttonToSendMessage);
187:                ButtonsPanel buttonsPanel = new ButtonsPanel(listOfButtons);
188:                this.frame.getContentPane().add(buttonsPanel);
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.