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