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


001:        package com.calipso.reportgenerator.usermanager;
002:
003:        import com.calipso.reportgenerator.common.LanguageTraslator;
004:        import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
005:        import com.calipso.reportgenerator.common.InfoException;
006:
007:        import javax.swing.*;
008:        import java.awt.event.ActionListener;
009:        import java.awt.event.ActionEvent;
010:        import java.awt.*;
011:        import java.io.File;
012:
013:        /**
014:         *
015:         * User: eslosse
016:         * Date: 22-sep-2005
017:         * Time: 11:57:38
018:         *
019:         */
020:
021:        /**
022:         * Representa el Frame para validacion de usuarios
023:         */
024:
025:        public class UserManagerLoginFrame extends JDialog implements 
026:                ActionListener {
027:
028:            protected JPasswordField pfUser;
029:            private static JTextField tfName;
030:            private JButton btAccept;
031:            private JButton btCancel;
032:            private String defaultUserName;
033:            private boolean hasCanceled;
034:            private File file;
035:            private ReportGeneratorConfiguration reportGeneratorConfiguration;
036:            private UserManager userManager;
037:
038:            /**
039:             * Crea una instancia de <code>UserLoginFrame</code>
040:             * @param owner
041:             * @param title
042:             * @param modal
043:             * @param defaultUserName
044:             * @throws java.awt.HeadlessException
045:             */
046:            public UserManagerLoginFrame(Frame owner, String title,
047:                    boolean modal, String defaultUserName,
048:                    ReportGeneratorConfiguration reportGeneratorConfiguration,
049:                    UserManager userManager) throws HeadlessException,
050:                    InfoException {
051:
052:                super (owner, title, modal);
053:                this .reportGeneratorConfiguration = reportGeneratorConfiguration;
054:                this .userManager = userManager;
055:                file = new File(reportGeneratorConfiguration
056:                        .getUsersRepositoryPath());
057:
058:                Image icon = reportGeneratorConfiguration.getImage("ICON");
059:                if (icon != null && owner != null) {
060:                    owner.setIconImage(icon);
061:                }
062:                this .defaultUserName = defaultUserName;
063:                hasCanceled = false;
064:                createComponents();
065:            }
066:
067:            /**
068:             * Crea los componentes graficos
069:             */
070:            protected void createComponents() {
071:                getContentPane().setLayout(new BorderLayout());
072:                getContentPane().add(createNorthPanel(), BorderLayout.CENTER);
073:                getContentPane().add(createSouthPanel(), BorderLayout.SOUTH);
074:                java.awt.Dimension screenSize = java.awt.Toolkit
075:                        .getDefaultToolkit().getScreenSize();
076:                setLocation((screenSize.width - 250) / 2,
077:                        (screenSize.height - 200) / 2);
078:                setSize(new Dimension(250, 110));
079:                //show();
080:            }
081:
082:            /**
083:             * Crea el panel del sur
084:             * @return
085:             */
086:            protected JComponent createSouthPanel() {
087:                FlowLayout layout = new FlowLayout(FlowLayout.RIGHT);
088:                JPanel pnlSouth = new JPanel(layout);
089:                btAccept = new JButton(LanguageTraslator.traslate("112"));
090:                btAccept.addActionListener(this );
091:                btCancel = new JButton(LanguageTraslator.traslate("113"));
092:                btCancel.addActionListener(this );
093:                pnlSouth.add(btAccept);
094:                pnlSouth.add(btCancel);
095:                return pnlSouth;
096:            }
097:
098:            /**
099:             * Crea el panel del norte
100:             * @return
101:             */
102:            protected JComponent createNorthPanel() {
103:                JPanel pnlNorth = new JPanel(new GridLayout(2, 2));
104:                JLabel label = new JLabel(LanguageTraslator.traslate("232"));
105:                tfName = new JTextField(defaultUserName);
106:                tfName.setEditable(false);
107:                pnlNorth.add(label);
108:                pnlNorth.add(tfName);
109:                label = new JLabel("Password");
110:                pfUser = new JPasswordField();
111:                pnlNorth.add(label);
112:                pnlNorth.add(pfUser);
113:                return pnlNorth;
114:            }
115:
116:            /**
117:             * Retorna valor que representa si el usuario
118:             * ha cancelado la validacion
119:             * @return
120:             */
121:            public boolean getHasCanceled() {
122:                return hasCanceled;
123:            }
124:
125:            /**
126:             * Devuelve el nombre de usuario
127:             * @return
128:             */
129:            public static String getUserName() {
130:                return tfName.getText().trim();
131:            }
132:
133:            /**
134:             * Retorna el campo para ingresar el password
135:             * @return
136:             */
137:            public JPasswordField getPfUser() {
138:                return pfUser;
139:            }
140:
141:            /**
142:             * Devuelve el boton accept del panel
143:             * @return
144:             */
145:            protected JButton getBtAccept() {
146:                return btAccept;
147:            }
148:
149:            /**
150:             * Devuelve la contrasena de usuario.
151:             * @return
152:             */
153:            public String getUserPasswd() {
154:                return new String(pfUser.getPassword());
155:            }
156:
157:            /**
158:             * Metodo que devuelve si la validacion ha sido o no
159:             * satisfactoria en caso de que el usuario no
160:             * haya cancelado la validacion.
161:             * @return
162:             */
163:            public boolean login() throws InfoException {
164:                boolean result = false;
165:                int intentos = 0;
166:                if (!file.exists()) {
167:                    throw new InfoException(LanguageTraslator.traslate("19"));
168:                }
169:                for (int i = 0; i < 3; i++) {
170:                    setVisible(true);
171:                    if (this .getHasCanceled()) {
172:                        return false;
173:                    }
174:                    String userName = this .getUserName();
175:                    String userPassword = this .getUserPasswd();
176:                    result = userManager.validate(this .getUserName(), this 
177:                            .getUserPasswd());
178:                    if (result == false) {
179:                        intentos++;
180:                        JOptionPane.showMessageDialog(this , LanguageTraslator
181:                                .traslate("451"));
182:                    } else {
183:                        return true;
184:                    }
185:                }
186:                if (intentos == 3) {
187:                    JOptionPane.showMessageDialog(this , LanguageTraslator
188:                            .traslate("300"));
189:                }
190:                return result;
191:            }
192:
193:            public void actionPerformed(ActionEvent e) {
194:                if (e.getSource() == btAccept) {
195:                    dispose();
196:                } else {
197:                    hasCanceled = true;
198:                    dispose();
199:                }
200:            }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.