Source Code Cross Referenced for LoginFrame.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » 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 » jmagallanes 1.0 » com.calipso.reportgenerator.userinterface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.userinterface;
002:
003:        import com.calipso.reportgenerator.common.InfoException;
004:        import com.calipso.reportgenerator.common.ShowExceptionMessageDialog;
005:
006:        import javax.swing.*;
007:        import java.awt.*;
008:        import java.awt.event.ActionListener;
009:        import java.awt.event.ActionEvent;
010:
011:        /**
012:         * Diálogo para validar el usuario
013:         */
014:        public class LoginFrame extends JDialog {
015:
016:            private JPanel mainPanel;
017:            private JPanel southPanel;
018:            private JPanel centerPanel;
019:            private JLabel userNameLabel;
020:            private JTextField userNameText;
021:            private JLabel passwordLabel;
022:            private JPasswordField passwordText;
023:            private JButton okButton;
024:            private JButton cancelButton;
025:
026:            private LoginValidator validator;
027:            private int loginResult;
028:            private boolean cancelled;
029:
030:            /**
031:             * Inicializa el
032:             * @param defaultUserName
033:             * @param validator
034:             */
035:            public LoginFrame(String defaultUserName, LoginValidator validator) {
036:                setModal(true);
037:                createControls();
038:                setSize(240, 110);
039:                java.awt.Dimension screenSize = java.awt.Toolkit
040:                        .getDefaultToolkit().getScreenSize();
041:                setLocation((screenSize.width - 240) / 2,
042:                        (screenSize.height - 110) / 2);
043:                setTitle(com.calipso.reportgenerator.common.LanguageTraslator
044:                        .traslate("296"));
045:                this .validator = validator;
046:                loginResult = -1;
047:                getUserNameText().setText(defaultUserName);
048:            }
049:
050:            public LoginValidator getValidator() {
051:                return validator;
052:            }
053:
054:            public void setValidator(LoginValidator validator) {
055:                this .validator = validator;
056:            }
057:
058:            public int getLoginResult() {
059:                return loginResult;
060:            }
061:
062:            public void setLoginResult(int loginResult) {
063:                this .loginResult = loginResult;
064:            }
065:
066:            private void createControls() {
067:                getContentPane().add(createMainPanel());
068:            }
069:
070:            private Component createMainPanel() {
071:                mainPanel = new JPanel(new BorderLayout());
072:                mainPanel.add(createCenterPanel(), BorderLayout.CENTER);
073:                mainPanel.add(createSouthPanel(), BorderLayout.SOUTH);
074:                return mainPanel;
075:            }
076:
077:            private Component createSouthPanel() {
078:                FlowLayout layout = new FlowLayout(FlowLayout.RIGHT);
079:                southPanel = new JPanel(layout);
080:                okButton = new JButton(
081:                        com.calipso.reportgenerator.common.LanguageTraslator
082:                                .traslate("112"));
083:                cancelButton = new JButton(
084:                        com.calipso.reportgenerator.common.LanguageTraslator
085:                                .traslate("113"));
086:                okButton.addActionListener(new ActionListener() {
087:                    public void actionPerformed(ActionEvent e) {
088:                        try {
089:                            validateLogin();
090:                        } catch (Exception er) {
091:                            ShowExceptionMessageDialog
092:                                    .initExceptionDialogMessage(
093:                                            com.calipso.reportgenerator.common.LanguageTraslator
094:                                                    .traslate("295"), er);
095:                        }
096:                        setVisible(false);
097:                    }
098:                });
099:
100:                cancelButton.addActionListener(new ActionListener() {
101:                    public void actionPerformed(ActionEvent e) {
102:                        cancelLogin();
103:                    }
104:                });
105:
106:                southPanel.add(okButton);
107:                southPanel.add(cancelButton);
108:                return southPanel;
109:            }
110:
111:            private void cancelLogin() {
112:                loginResult = -1;
113:                cancelled = true;
114:                setVisible(false);
115:            }
116:
117:            private void validateLogin() throws InfoException {
118:                loginResult = getValidator().validate(getUserName(),
119:                        getPassword());
120:            }
121:
122:            private String getPassword() {
123:                return new String(passwordText.getPassword());
124:            }
125:
126:            private String getUserName() {
127:                return userNameText.getText();
128:            }
129:
130:            private Component createCenterPanel() {
131:                centerPanel = new JPanel(new GridLayout(2, 2));
132:                userNameLabel = new JLabel(
133:                        com.calipso.reportgenerator.common.LanguageTraslator
134:                                .traslate("297"));
135:                userNameText = new JTextField();
136:                passwordLabel = new JLabel(
137:                        com.calipso.reportgenerator.common.LanguageTraslator
138:                                .traslate("298"));
139:                passwordText = new JPasswordField();
140:
141:                centerPanel.add(userNameLabel);
142:                centerPanel.add(userNameText);
143:                centerPanel.add(passwordLabel);
144:                centerPanel.add(passwordText);
145:
146:                return centerPanel;
147:            }
148:
149:            public JTextField getUserNameText() {
150:                return userNameText;
151:            }
152:
153:            public boolean login() {
154:                setVisible(true);
155:                return connected();
156:            }
157:
158:            private boolean connected() {
159:                return getValidator().getConnected();
160:            }
161:
162:            private boolean cancelled() {
163:                return cancelled;
164:            }
165:
166:            public static void login(ReportLoginValidator validator)
167:                    throws InfoException {
168:                login("", validator);
169:            }
170:
171:            public static void login(String defaultUserName,
172:                    LoginValidator validator) throws InfoException {
173:                LoginFrame loginFrame = new LoginFrame(defaultUserName,
174:                        validator);
175:                if (!loginFrame.login()) {
176:                    if (loginFrame.cancelled()) {
177:                        throw new InfoException(
178:                                com.calipso.reportgenerator.common.LanguageTraslator
179:                                        .traslate("299"));
180:                    } else {
181:                        throw new InfoException(
182:                                com.calipso.reportgenerator.common.LanguageTraslator
183:                                        .traslate("300"));
184:                    }
185:                }
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.