Source Code Cross Referenced for AskNewUser.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » admin » 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 » Test Coverage » salome tmf » org.objectweb.salome_tmf.ihm.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SalomeTMF is a Test Management Framework
003:         * Copyright (C) 2005 France Telecom R&D
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *
019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.ihm.admin;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Container;
028:        import java.awt.Dimension;
029:        import java.awt.FlowLayout;
030:        import java.awt.Frame;
031:        import java.awt.event.ActionEvent;
032:        import java.awt.event.ActionListener;
033:
034:        import javax.swing.Box;
035:        import javax.swing.BoxLayout;
036:        import javax.swing.JButton;
037:        import javax.swing.JDialog;
038:        import javax.swing.JLabel;
039:        import javax.swing.JOptionPane;
040:        import javax.swing.JPanel;
041:        import javax.swing.JPasswordField;
042:        import javax.swing.JTextField;
043:
044:        import org.objectweb.salome_tmf.data.AdminVTData;
045:        import org.objectweb.salome_tmf.data.User;
046:        import org.objectweb.salome_tmf.ihm.languages.Language;
047:
048:        /**
049:         * Classe qui permet d'afficher une fenêtre demandant d'entrer les
050:         * informations pour les nouveaux utilisateurs
051:         */
052:        public class AskNewUser extends JDialog {
053:
054:            /**
055:             * Le Field permettant de récupérer le login
056:             */
057:            private JTextField loginField;
058:
059:            /**
060:             * Le Field permettant de récupérer le prénom
061:             */
062:            private JTextField firstNameField;
063:
064:            /**
065:             * Le Field permettant de récupérer le nom
066:             */
067:            private JTextField lastNameField;
068:
069:            /**
070:             * Le Field permettant de récupérer l'email
071:             */
072:            private JTextField emailField;
073:
074:            /**
075:             * Le Field permettant de récupérer la numéro de téléphone
076:             */
077:            private JTextField phoneField;
078:
079:            /**
080:             * Le Field permettant de récupérer le mot de passe
081:             */
082:            private JPasswordField pwdField;
083:
084:            /**
085:             * L'utilisateur créé
086:             */
087:            private User user;
088:
089:            /**
090:             * Le mot de passe par défaut pour le nouvel utilisateur
091:             */
092:            private char[] password;
093:
094:            boolean newUser = false;
095:            String oldUserLogin = "";
096:
097:            AdminVTData pAdminVTData;
098:
099:            /******************************************************************************/
100:            /** 							CONSTRUCTEUR								***/
101:            /******************************************************************************/
102:
103:            /**
104:             * Constructeur de la fenêtre.
105:             * @param textToBePrompt chaîne correspondant à la demande.
106:             */
107:            public AskNewUser(User oldUser, Frame owner, AdminVTData adminVTData) {
108:
109:                super (owner, true);
110:                this .pAdminVTData = adminVTData;
111:
112:                if (oldUser == null) {
113:                    newUser = true;
114:                } else {
115:                    oldUserLogin = oldUser.getLoginFromModel();
116:                }
117:
118:                loginField = new JTextField(10);
119:                firstNameField = new JTextField(10);
120:                lastNameField = new JTextField(10);
121:                emailField = new JTextField(10);
122:                phoneField = new JTextField(10);
123:                pwdField = new JPasswordField(10);
124:                JPanel page = new JPanel();
125:
126:                JLabel obligation = new JLabel(Language.getInstance().getText(
127:                        "*_:_champ_obligatoire"));
128:
129:                JLabel loginLabel = new JLabel(Language.getInstance().getText(
130:                        "Login*_:"));
131:                JLabel lastNameLabel = new JLabel(Language.getInstance()
132:                        .getText("Nom*_:"));
133:                JLabel firstNameLabel = new JLabel(Language.getInstance()
134:                        .getText("Prénom*_:"));
135:                JLabel emailLabel = new JLabel(Language.getInstance().getText(
136:                        "Email*_:"));
137:                JLabel phoneLabel = new JLabel(Language.getInstance().getText(
138:                        "Téléphone_:_"));
139:                JLabel pwdLabel = new JLabel(Language.getInstance().getText(
140:                        "Mot_de_passe*_:_"));
141:
142:                JPanel allField = new JPanel();
143:                allField.setLayout(new BoxLayout(allField, BoxLayout.Y_AXIS));
144:                allField.add(Box.createVerticalGlue());
145:                allField.add(loginField);
146:                allField.add(Box.createRigidArea(new Dimension(1, 15)));
147:                allField.add(lastNameField);
148:                allField.add(Box.createRigidArea(new Dimension(1, 15)));
149:                allField.add(firstNameField);
150:                allField.add(Box.createRigidArea(new Dimension(1, 15)));
151:                allField.add(emailField);
152:                allField.add(Box.createRigidArea(new Dimension(1, 15)));
153:                allField.add(phoneField);
154:                if (newUser) {
155:                    allField.add(Box.createRigidArea(new Dimension(1, 15)));
156:                    allField.add(pwdField);
157:                }
158:
159:                JPanel giveName = new JPanel();
160:                giveName.setLayout(new BoxLayout(giveName, BoxLayout.Y_AXIS));
161:                giveName.add(Box.createVerticalGlue());
162:                giveName.add(loginLabel);
163:                giveName.add(Box.createRigidArea(new Dimension(1, 20)));
164:                giveName.add(lastNameLabel);
165:                giveName.add(Box.createRigidArea(new Dimension(1, 20)));
166:                giveName.add(firstNameLabel);
167:                giveName.add(Box.createRigidArea(new Dimension(1, 20)));
168:                giveName.add(emailLabel);
169:                giveName.add(Box.createRigidArea(new Dimension(1, 20)));
170:                giveName.add(phoneLabel);
171:                if (newUser) {
172:                    giveName.add(Box.createRigidArea(new Dimension(1, 20)));
173:                    giveName.add(pwdLabel);
174:                }
175:
176:                JPanel textPanel = new JPanel();
177:                textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS));
178:
179:                textPanel.add(giveName);
180:                textPanel.add(allField);
181:
182:                JButton okButton = new JButton(Language.getInstance().getText(
183:                        "Valider"));
184:                okButton.setToolTipText(Language.getInstance().getText(
185:                        "Valider"));
186:                okButton.addActionListener(new ActionListener() {
187:                    public void actionPerformed(ActionEvent e) {
188:                        boolean ok = true;
189:                        user = new User("", "");
190:                        if ((!loginField.getText().trim().equals(""))
191:                                && (!loginField.getText().trim().equals(""))) {
192:                            if ((!pAdminVTData.containsLoginInModel(loginField
193:                                    .getText().trim()))
194:                                    || (oldUserLogin.equals(loginField
195:                                            .getText().trim()))) {
196:                                user.setLoginInModel(loginField.getText()
197:                                        .trim());
198:                                if (!lastNameField.getText().equals("")) {
199:                                    user.setLastNameInModel(lastNameField
200:                                            .getText());
201:                                    if (!firstNameField.getText().equals("")) {
202:                                        user.setFirstNameInModel(firstNameField
203:                                                .getText());
204:                                        if (!emailField.getText().equals("")) {
205:                                            user.setEmailInModel(emailField
206:                                                    .getText());
207:                                            if (pwdField.getPassword().length != 0) {
208:                                                password = pwdField
209:                                                        .getPassword();
210:                                            } else if (newUser) {
211:                                                warning(
212:                                                        pwdField,
213:                                                        Language
214:                                                                .getInstance()
215:                                                                .getText(
216:                                                                        "Vous_devez_entrer_un_mot_de_passe_par_défaut_!"));
217:                                                ok = false;
218:                                            }
219:                                        } else {
220:                                            warning(
221:                                                    emailField,
222:                                                    Language
223:                                                            .getInstance()
224:                                                            .getText(
225:                                                                    "Vous_devez_entrer_un_email_!"));
226:                                            ok = false;
227:                                        }
228:                                    } else {
229:                                        warning(
230:                                                firstNameField,
231:                                                Language
232:                                                        .getInstance()
233:                                                        .getText(
234:                                                                "Vous_devez_entrer_un_prénom_!"));
235:                                        ok = false;
236:                                    }
237:                                } else {
238:                                    warning(
239:                                            lastNameField,
240:                                            Language
241:                                                    .getInstance()
242:                                                    .getText(
243:                                                            "Vous_devez_entrer_un_nom_!"));
244:                                    ok = false;
245:                                }
246:                            } else {
247:                                JOptionPane.showMessageDialog(AskNewUser.this ,
248:                                        Language.getInstance().getText(
249:                                                "Ce_login_existe_déjà_!"),
250:                                        Language.getInstance().getText(
251:                                                "Erreur_!"),
252:                                        JOptionPane.ERROR_MESSAGE);
253:                                ok = false;
254:                            }
255:                        } else {
256:                            warning(loginField, Language.getInstance().getText(
257:                                    "Vous_devez_entrer_un_nom_de_login_!"));
258:                            ok = false;
259:                        }
260:                        if (phoneField.getText() != "") {
261:                            user.setPhoneNumberInModel(phoneField.getText());
262:                        }
263:                        if (ok)
264:                            AskNewUser.this .dispose();
265:                    }
266:                });
267:
268:                JButton cancelButton = new JButton(Language.getInstance()
269:                        .getText("Annuler"));
270:                cancelButton.setToolTipText(Language.getInstance().getText(
271:                        "Annuler"));
272:                cancelButton.addActionListener(new ActionListener() {
273:                    public void actionPerformed(ActionEvent e) {
274:                        user = null;
275:                        password = null;
276:                        AskNewUser.this .dispose();
277:                    }
278:                });
279:
280:                JPanel buttonPanel = new JPanel();
281:                buttonPanel.setLayout(new BorderLayout());
282:                buttonPanel.add(okButton, BorderLayout.NORTH);
283:                buttonPanel.add(cancelButton, BorderLayout.SOUTH);
284:
285:                JPanel obligationPanel = new JPanel(new FlowLayout(
286:                        FlowLayout.RIGHT));
287:                obligationPanel.add(obligation);
288:
289:                page.add(textPanel, BorderLayout.WEST);
290:                page.add(Box.createRigidArea(new Dimension(40, 10)),
291:                        BorderLayout.CENTER);
292:                page.add(buttonPanel, BorderLayout.EAST);
293:
294:                Container contentPaneFrame = this .getContentPane();
295:                contentPaneFrame.add(page, BorderLayout.CENTER);
296:                contentPaneFrame.add(obligationPanel, BorderLayout.SOUTH);
297:
298:                initData(oldUser);
299:                if (oldUser != null) {
300:                    this .setTitle(Language.getInstance().getText(
301:                            "Modifier_un_utilisateur"));
302:                } else {
303:                    this .setTitle(Language.getInstance().getText(
304:                            "Créer_un_nouvel_utilisateur"));
305:                }
306:
307:                //this.setLocation(400,300);
308:                this .setLocationRelativeTo(this .getParent());
309:                this .pack();
310:                this .setVisible(true);
311:            } // Fin du constructeur AskName/1
312:
313:            /******************************************************************************/
314:            /** 							METHODES PUBLIQUES							***/
315:            /******************************************************************************/
316:
317:            /**
318:             * Récupère le nouvel utilisateur
319:             * @return
320:             */
321:            public User getUser() {
322:                return user;
323:            } // Fin de la méthode getUser/0
324:
325:            private void initData(User oldUser) {
326:                if (oldUser != null) {
327:                    user = oldUser;
328:                    loginField.setText(oldUser.getLoginFromModel());
329:                    firstNameField.setText(oldUser.getFirstNameFromModel());
330:                    lastNameField.setText(oldUser.getLastNameFromModel());
331:                    emailField.setText(oldUser.getEmailFromModel());
332:                    phoneField.setText(oldUser.getPhoneNumberFromModel());
333:
334:                } else {
335:                    user = new User("", "");
336:                }
337:            }
338:
339:            /**
340:             * Affiche une fenêtre de warning para rapport au field passé en paramètre
341:             * avec le message passé en paramètre
342:             * @param field le field concerné
343:             * @param msg message à afficher
344:             */
345:            public void warning(JTextField field, String msg) {
346:                field.selectAll();
347:                JOptionPane.showMessageDialog(AskNewUser.this , msg, Language
348:                        .getInstance().getText("Erreur_!"),
349:                        JOptionPane.ERROR_MESSAGE);
350:                field.requestFocusInWindow();
351:            } // Fin de la méthode warning/2
352:
353:            /**
354:             * Retourne le mot de passe
355:             * @return le mot de passe
356:             */
357:            public char[] getPassword() {
358:                return password;
359:            } // Fin de la méthode getPassword/0
360:        } // Fin de la classe AskNewUser
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.