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


0001:        /*
0002:         * SalomeTMF is a Test Management Framework
0003:         * Copyright (C) 2005 France Telecom R&D
0004:         *
0005:         * This library is free software; you can redistribute it and/or
0006:         * modify it under the terms of the GNU Lesser General Public
0007:         * License as published by the Free Software Foundation; either
0008:         * version 2 of the License, or (at your option) any later version.
0009:         *
0010:         * This library is distributed in the hope that it will be useful,
0011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013:         * Lesser General Public License for more details.
0014:         *
0015:         * You should have received a copy of the GNU Lesser General Public
0016:         * License along with this library; if not, write to the Free Software
0017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018:         *
0019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
0020:         *
0021:         * Contact: mikael.marche@rd.francetelecom.com
0022:         */
0023:
0024:        package org.objectweb.salome_tmf.ihm;
0025:
0026:        import java.awt.BorderLayout;
0027:        import java.awt.Color;
0028:        import java.awt.Component;
0029:        import java.awt.Container;
0030:        import java.awt.Dimension;
0031:        import java.awt.FlowLayout;
0032:        import java.awt.Font;
0033:        import java.awt.GridLayout;
0034:        import java.awt.event.ActionEvent;
0035:        import java.awt.event.ActionListener;
0036:        import java.net.MalformedURLException;
0037:        import java.net.URL;
0038:        import java.util.ArrayList;
0039:        import java.util.HashSet;
0040:        import java.util.Iterator;
0041:        import java.util.Locale;
0042:        import java.util.Observable;
0043:        import java.util.Observer;
0044:        import java.util.Vector;
0045:
0046:        import javax.swing.BorderFactory;
0047:        import javax.swing.Box;
0048:        import javax.swing.BoxLayout;
0049:        import javax.swing.ButtonGroup;
0050:        import javax.swing.DefaultListModel;
0051:        import javax.swing.JApplet;
0052:        import javax.swing.JButton;
0053:        import javax.swing.JLabel;
0054:        import javax.swing.JList;
0055:        import javax.swing.JOptionPane;
0056:        import javax.swing.JPanel;
0057:        import javax.swing.JPasswordField;
0058:        import javax.swing.JRadioButton;
0059:        import javax.swing.JScrollPane;
0060:        import javax.swing.JTabbedPane;
0061:        import javax.swing.JTable;
0062:        import javax.swing.JTextArea;
0063:        import javax.swing.ListSelectionModel;
0064:        import javax.swing.LookAndFeel;
0065:        import javax.swing.UIManager;
0066:        import javax.swing.event.ListSelectionEvent;
0067:        import javax.swing.event.ListSelectionListener;
0068:
0069:        import org.objectweb.salome_tmf.api.Api;
0070:        import org.objectweb.salome_tmf.api.ApiConstants;
0071:        import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
0072:        import org.objectweb.salome_tmf.api.api2ihm.AdminVT;
0073:        import org.objectweb.salome_tmf.data.AdminProjectData;
0074:        import org.objectweb.salome_tmf.data.ConnectionData;
0075:        import org.objectweb.salome_tmf.data.DataConstants;
0076:        import org.objectweb.salome_tmf.data.Group;
0077:        import org.objectweb.salome_tmf.data.Project;
0078:        import org.objectweb.salome_tmf.data.User;
0079:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
0080:        import org.objectweb.salome_tmf.ihm.languages.Language;
0081:        import org.objectweb.salome_tmf.ihm.models.GroupListRenderer;
0082:        import org.objectweb.salome_tmf.ihm.models.MyTableModel;
0083:        import org.objectweb.salome_tmf.ihm.models.UserDescriptionCaretListener;
0084:        import org.objectweb.salome_tmf.ihm.models.UserListRenderer;
0085:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0086:
0087:        /**
0088:         * Classe représentant la fenêtre d'administration d'un projet.
0089:         * @author teaml039
0090:         * @version 0.1
0091:         */
0092:        public class AdministrationProject extends JApplet implements 
0093:                ApiConstants, DataConstants, IHMConstants, Observer {
0094:
0095:            boolean problemURL = false;
0096:
0097:            /**
0098:             * Les onglets d'administration
0099:             */
0100:            JTabbedPane tabs;
0101:
0102:            /**
0103:             * Fenêtre totale
0104:             */
0105:            JPanel projectSupervision;
0106:
0107:            /**
0108:             * Vue droite de la fenêtre
0109:             */
0110:            JPanel projectView;
0111:
0112:            /**
0113:             * Vue pour le changement de mot de passe
0114:             */
0115:            JPanel pwdView;
0116:
0117:            /**
0118:             * Vue pour la gestion des utilisateurs
0119:             */
0120:            JPanel userView;
0121:
0122:            /**
0123:             * Vue pour la gestion des groupes
0124:             */
0125:            JPanel groupView;
0126:
0127:            // field utilisés pour le changement de mot de passe
0128:            /**
0129:             * Ancien mot de passe
0130:             */
0131:            JPasswordField oldPassword;
0132:
0133:            /**
0134:             * Nouveau mot de passe : premier
0135:             */
0136:            JPasswordField newPasswordFirst;
0137:
0138:            /**
0139:             * Nouveau mot de passe : second
0140:             */
0141:            JPasswordField newPasswordSecond;
0142:
0143:            /**
0144:             * Modèle regroupant les groupes pour la liste
0145:             */
0146:            DefaultListModel groupListModel;
0147:
0148:            /**
0149:             * la liste des groupes
0150:             */
0151:            JList groupList;
0152:
0153:            /**
0154:             * Liste des utilisateurs ne faisant pas partie du groupe
0155:             */
0156:            DefaultListModel notMemberListModel;
0157:
0158:            /**
0159:             * Liste des utilisateurs du groupe
0160:             */
0161:            DefaultListModel memberListModel;
0162:
0163:            /**
0164:             * Liste des groupes dont un utilisateur est membre
0165:             */
0166:            JList memberOf;
0167:
0168:            /**
0169:             * Liste des groupes dont un utilisateur n'est pas membre
0170:             */
0171:            JList notMemberOf;
0172:
0173:            /**
0174:             * Le modèle de données de la table des utilisateurs
0175:             */
0176:            MyTableModel usersTableModel;
0177:
0178:            /**
0179:             * La table des utilisateurs
0180:             */
0181:            JTable table;
0182:
0183:            /**
0184:             * Bouton pour supprimer un utilisateur
0185:             */
0186:            JButton deleteUserButton;
0187:
0188:            /**
0189:             * Champ pour entrer le prénom
0190:             */
0191:            JLabel firstNameLabel;
0192:
0193:            /**
0194:             * Champ pour entrer le nom de famille
0195:             */
0196:            JLabel lastNameLabel;
0197:
0198:            /**
0199:             * Champ pour entrer l'email
0200:             */
0201:            JLabel emailLabel;
0202:
0203:            /**
0204:             * Champ pour entrer le numéro de téléphone
0205:             */
0206:            JLabel phoneLabel;
0207:
0208:            /**
0209:             * L'utilisateur sélectionné
0210:             */
0211:            User selectedUser;
0212:
0213:            /**
0214:             * Ligne de l'utilisateur selectionné
0215:             */
0216:            private int userSelectedRow;
0217:
0218:            /**
0219:             * Modèle de données de la liste des utilisateurs ne faisant pas aprtie du
0220:             * groupe
0221:             */
0222:            DefaultListModel outGroupListModel;
0223:            /**
0224:             * Modèle de données de la liste des utilisateurs du groupe
0225:             */
0226:            DefaultListModel inGroupListModel;
0227:
0228:            /**
0229:             * Liste des utilisateurs du groupe
0230:             */
0231:            JList inGrouplist;
0232:
0233:            /**
0234:             * Liste des utilisateurs ne faisant pas partie du groupe
0235:             */
0236:            JList outGrouplist;
0237:
0238:            /**
0239:             * Bouton pour modifier un groupe
0240:             */
0241:            JButton renameButton;
0242:
0243:            /**
0244:             * Ligne du groupe sélectionné dans la liste des groupes de la vue des
0245:             * groupes
0246:             */
0247:            private int groupSelectedRow;
0248:
0249:            /**
0250:             * Bouton pour supprimer un groupe
0251:             */
0252:            JButton groupDeleteButton;
0253:
0254:            /**
0255:             * Le nom du projet courant
0256:             */
0257:            JLabel projectName;
0258:
0259:            /**
0260:             * Description d'un groupe
0261:             */
0262:            JTextArea groupDescriptionArea;
0263:
0264:            JButton modifyButton;
0265:
0266:            JButton viewButton;
0267:
0268:            JTextArea userDescriptionArea;
0269:            /******************************************************************************/
0270:            /** 							METHODES PUBLIQUES							***/
0271:            /******************************************************************************/
0272:            /* dbClosed = true if connection to database is close normaly (no reload or back from browser) */
0273:            boolean dbClosed = true;
0274:            /* reload = true if applet is start again from same JVM (reload or back from browser) */
0275:            static boolean reload = false;
0276:
0277:            /**
0278:             * Méthode d'initialisation de l'applet
0279:             */
0280:            public void init() {
0281:                System.runFinalization();
0282:                System.gc();
0283:                if (reload) {
0284:                    Api.closeConnection();
0285:                    dbClosed = true;
0286:                } else {
0287:                    reload = true;
0288:                }
0289:                Api.setUrlBase(getDocumentBase());
0290:                Language.getInstance().setLocale(
0291:                        new Locale(Api.getUsedLocale()));
0292:                try {
0293:                    Class lnfClass = Class.forName(UIManager
0294:                            .getSystemLookAndFeelClassName());
0295:                    LookAndFeel newLAF = (LookAndFeel) (lnfClass.newInstance());
0296:                    UIManager.setLookAndFeel(newLAF);
0297:                } catch (Exception exc) {
0298:                    System.err.println("Error loading L&F: " + exc);
0299:                }
0300:
0301:                tabs = new JTabbedPane();
0302:
0303:                projectSupervision = new JPanel(new BorderLayout());
0304:
0305:                projectView = new JPanel(new BorderLayout());
0306:
0307:                pwdView = new JPanel(new BorderLayout());
0308:
0309:                userView = new JPanel(new BorderLayout());
0310:
0311:                groupView = new JPanel();
0312:
0313:                // field utilisés pour le changement de mot de passe
0314:                oldPassword = new JPasswordField(20);
0315:
0316:                newPasswordFirst = new JPasswordField(20);
0317:
0318:                newPasswordSecond = new JPasswordField(20);
0319:
0320:                groupListModel = new DefaultListModel();
0321:
0322:                groupList = new JList(groupListModel);
0323:
0324:                notMemberListModel = new DefaultListModel();
0325:
0326:                memberListModel = new DefaultListModel();
0327:
0328:                memberOf = new JList(memberListModel);
0329:
0330:                notMemberOf = new JList(notMemberListModel);
0331:
0332:                usersTableModel = new MyTableModel();
0333:
0334:                table = new JTable();
0335:
0336:                deleteUserButton = new JButton(Language.getInstance().getText(
0337:                        "Supprimer"));
0338:
0339:                firstNameLabel = new JLabel(Language.getInstance().getText(
0340:                        "Prénom_:_"));
0341:
0342:                lastNameLabel = new JLabel(Language.getInstance().getText(
0343:                        "Nom_:_"));
0344:
0345:                emailLabel = new JLabel(Language.getInstance().getText(
0346:                        "Email_:_"));
0347:
0348:                phoneLabel = new JLabel(Language.getInstance().getText(
0349:                        "Téléphone_:_"));
0350:
0351:                userSelectedRow = 0;
0352:
0353:                outGroupListModel = new DefaultListModel();
0354:                inGroupListModel = new DefaultListModel();
0355:
0356:                inGrouplist = new JList(inGroupListModel);
0357:
0358:                outGrouplist = new JList(outGroupListModel);
0359:
0360:                renameButton = new JButton(Language.getInstance().getText(
0361:                        "Modifier"));
0362:
0363:                groupSelectedRow = 0;
0364:
0365:                groupDeleteButton = new JButton(Language.getInstance().getText(
0366:                        "Supprimer"));
0367:
0368:                projectName = new JLabel();
0369:
0370:                groupDescriptionArea = new JTextArea();
0371:
0372:                // Onglets
0373:                tabs.addTab(Language.getInstance().getText(
0374:                        "Administration_d'un_projet"), projectSupervision);
0375:                tabs.setPreferredSize(new Dimension(500, 500));
0376:
0377:                projectName.setFont(new Font(null, Font.BOLD, 18));
0378:                JPanel projectNamePanel = new JPanel(new BorderLayout());
0379:                projectNamePanel.add(BorderLayout.NORTH, projectName);
0380:
0381:                JRadioButton changePwdProjectButton = new JRadioButton(Language
0382:                        .getInstance().getText("Changer_le_mot_de_passe"));
0383:                changePwdProjectButton.addActionListener(new ActionListener() {
0384:                    public void actionPerformed(ActionEvent e) {
0385:                        projectView.removeAll();
0386:                        projectView.add(pwdView, BorderLayout.CENTER);
0387:                        projectView.validate();
0388:                        projectView.repaint();
0389:
0390:                    }
0391:                });
0392:
0393:                JRadioButton usersProjectButton = new JRadioButton(Language
0394:                        .getInstance().getText("Gérer_les_utilisateurs"));
0395:                usersProjectButton.addActionListener(new ActionListener() {
0396:                    public void actionPerformed(ActionEvent e) {
0397:                        projectView.removeAll();
0398:                        projectView.add(userView, BorderLayout.CENTER);
0399:                        projectView.validate();
0400:                        projectView.repaint();
0401:                    }
0402:                });
0403:
0404:                JRadioButton groupsProjectButton = new JRadioButton(Language
0405:                        .getInstance().getText("Gérer_les_groupes"));
0406:                groupsProjectButton.addActionListener(new ActionListener() {
0407:                    public void actionPerformed(ActionEvent e) {
0408:                        projectView.removeAll();
0409:                        projectView.add(groupView, BorderLayout.CENTER);
0410:                        projectView.validate();
0411:                        projectView.repaint();
0412:
0413:                    }
0414:                });
0415:
0416:                JButton backButton = new JButton(Language.getInstance()
0417:                        .getText("Quitter"));
0418:                backButton.addActionListener(new ActionListener() {
0419:                    public void actionPerformed(ActionEvent e) {
0420:                        quit(true);
0421:                    }
0422:                });
0423:
0424:                //on regroupe les radio buttons.
0425:                ButtonGroup adminProjectButtonGroup = new ButtonGroup();
0426:                adminProjectButtonGroup.add(changePwdProjectButton);
0427:                adminProjectButtonGroup.add(usersProjectButton);
0428:                adminProjectButtonGroup.add(groupsProjectButton);
0429:
0430:                JPanel radioProjectPanel = new JPanel(new GridLayout(0, 1));
0431:
0432:                radioProjectPanel.add(projectNamePanel);
0433:                radioProjectPanel
0434:                        .add(Box.createRigidArea(new Dimension(1, 40)));
0435:                radioProjectPanel.add(changePwdProjectButton);
0436:                radioProjectPanel
0437:                        .add(Box.createRigidArea(new Dimension(1, 15)));
0438:                radioProjectPanel.add(usersProjectButton);
0439:                radioProjectPanel
0440:                        .add(Box.createRigidArea(new Dimension(1, 15)));
0441:                radioProjectPanel.add(groupsProjectButton);
0442:
0443:                JPanel testPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
0444:                testPanel.add(radioProjectPanel);
0445:
0446:                JPanel radioProjectPanelAll = new JPanel(new BorderLayout());
0447:                radioProjectPanelAll.add(testPanel);
0448:                radioProjectPanelAll.add(backButton, BorderLayout.SOUTH);
0449:
0450:                //radioProjectPanel.setBorder(BorderFactory.createRaisedBevelBorder());
0451:                radioProjectPanelAll.setBorder(BorderFactory
0452:                        .createRaisedBevelBorder());
0453:
0454:                // On remplit le panel adminVoiceTesting
0455:                projectSupervision.add(BorderLayout.WEST, radioProjectPanelAll);
0456:
0457:                AdminProjectData.initData();
0458:                createChangePwdView();
0459:                createUsersViewForOneProject();
0460:                createGroupsViewForOneProject();
0461:                projectView.removeAll();
0462:
0463:                projectSupervision.add(BorderLayout.CENTER, projectView);
0464:                projectSupervision.validate();
0465:
0466:                Container cp = this .getContentPane();
0467:                cp.add(tabs);
0468:            } // Fin de la méthode init/0
0469:
0470:            /**
0471:             * Méthode appelée à chaque chargement de la page
0472:             */
0473:            public void start() {
0474:                if (Api.isAlreadyConnected) {
0475:                    JOptionPane
0476:                            .showMessageDialog(
0477:                                    AdministrationProject.this ,
0478:                                    Language
0479:                                            .getInstance()
0480:                                            .getText(
0481:                                                    "Vous_avez_déjà_une_session_Salomé_ouverte_avec_ce_navigateur.\n")
0482:                                            + Language
0483:                                                    .getInstance()
0484:                                                    .getText(
0485:                                                            "Une_seule_session_est_autorisée_par_navigateur_afin_d'éviter_les_conflits_!"),
0486:                                    Language.getInstance().getText("Erreur_!"),
0487:                                    JOptionPane.ERROR_MESSAGE);
0488:                    quit(false);
0489:                    Api.isAlreadyConnected = true;
0490:                } else {
0491:                    super .start();
0492:                    Api.openConnection(getDocumentBase());
0493:                    dbClosed = false;
0494:                    String[] params = Tools
0495:                            .chooseProjectAndUser(getDocumentBase());
0496:                    if ((params[0] == null) || (params[0].equals(""))) {
0497:                        JOptionPane.showMessageDialog(
0498:                                AdministrationProject.this ,
0499:                                Language.getInstance().getText(
0500:                                        "Probleme_dans_l'URL_saisie_!"),
0501:                                Language.getInstance().getText("Erreur_!"),
0502:                                JOptionPane.ERROR_MESSAGE);
0503:                        problemURL = true;
0504:                        //Api.closeConnection();
0505:                        quit(true);
0506:                    } else {
0507:                        initDataVoiceTesting(params[0], params[1]);
0508:                        Api.addObservers(this );
0509:                        projectName.setText(AdminProjectData
0510:                                .getCurrentProject().getName());
0511:                    }
0512:                }
0513:            } // Fin de la méthode start/0
0514:
0515:            /**
0516:             * Méthode appelé à la fermeture de l'applet
0517:             */
0518:            public void stop() {
0519:                System.out.println("Applet stop");
0520:
0521:                /*if (ConnectionData.isConnected()) {
0522:                    Api.closeConnection();
0523:                }*/
0524:            }
0525:
0526:            /**
0527:             * Méthode qui créer l'écran permettant de changer le mot de passe.
0528:             */
0529:            public void createChangePwdView() {
0530:                projectView.removeAll();
0531:
0532:                JButton validateButton = new JButton(Language.getInstance()
0533:                        .getText("Valider"));
0534:                validateButton.setToolTipText(Language.getInstance().getText(
0535:                        "Valider"));
0536:                validateButton.addActionListener(new ActionListener() {
0537:                    public void actionPerformed(ActionEvent e) {
0538:                        if (ConnectionData.isConnected()) {
0539:                            String pass = ConnectionData.getAdminVTSelect()
0540:                                    .getUserPassword(
0541:                                            AdminProjectData
0542:                                                    .getCurrentProject()
0543:                                                    .getAdministrator()
0544:                                                    .getLogin());
0545:
0546:                            boolean _valid = false;
0547:                            try {
0548:                                _valid = org.objectweb.salome_tmf.api.MD5paswd
0549:                                        .testPassword(new String(oldPassword
0550:                                                .getPassword()).trim(), pass);
0551:                            } catch (Exception ex) {
0552:                            }
0553:                            if (_valid) {
0554:                                if (new String(newPasswordFirst.getPassword())
0555:                                        .trim().equals(
0556:                                                new String(newPasswordSecond
0557:                                                        .getPassword()).trim())) {
0558:                                    int transNumber = -1;
0559:                                    try {
0560:                                        transNumber = Api
0561:                                                .beginTransaction(Api.UPDATE_PASSWORD);
0562:                                        ConnectionData
0563:                                                .getAdminVTUpdate()
0564:                                                .updateAdminPassword(
0565:                                                        AdminProjectData
0566:                                                                .getCurrentProject()
0567:                                                                .getAdministrator()
0568:                                                                .getLogin(),
0569:                                                        new String(
0570:                                                                newPasswordSecond
0571:                                                                        .getPassword())
0572:                                                                .trim());
0573:                                        Api.commitTrans(transNumber);
0574:                                    } catch (Exception exception) {
0575:                                        Api.forceRollBackTrans(transNumber);
0576:                                        Tools.ihmExceptionView(exception
0577:                                                .toString());
0578:                                    }
0579:                                    if (Api.getException() == null
0580:                                            || Api.getException().size() == 0) {
0581:                                        oldPassword.setText("");
0582:                                        newPasswordFirst.setText("");
0583:                                        newPasswordSecond.setText("");
0584:                                        JOptionPane
0585:                                                .showMessageDialog(
0586:                                                        AdministrationProject.this ,
0587:                                                        Language
0588:                                                                .getInstance()
0589:                                                                .getText(
0590:                                                                        "Votre_mot_de_passe_a_été_modifié."),
0591:                                                        Language
0592:                                                                .getInstance()
0593:                                                                .getText(
0594:                                                                        "Succès_!"),
0595:                                                        JOptionPane.INFORMATION_MESSAGE);
0596:                                    }
0597:                                } else {
0598:                                    newPasswordFirst.setText("");
0599:                                    newPasswordSecond.setText("");
0600:                                    JOptionPane
0601:                                            .showMessageDialog(
0602:                                                    AdministrationProject.this ,
0603:                                                    Language
0604:                                                            .getInstance()
0605:                                                            .getText(
0606:                                                                    "Impossible_de_changer_le_mot_de_passe.\nVous_n'avez_pas_entrer_deux_fois_le_même_mot_de_passe."),
0607:                                                    Language
0608:                                                            .getInstance()
0609:                                                            .getText("Erreur_!"),
0610:                                                    JOptionPane.ERROR_MESSAGE);
0611:                                }
0612:                            } else {
0613:                                oldPassword.setText("");
0614:                                JOptionPane
0615:                                        .showMessageDialog(
0616:                                                AdministrationProject.this ,
0617:                                                Language
0618:                                                        .getInstance()
0619:                                                        .getText(
0620:                                                                "Impossible_de_changer_le_mot_de_passe.\nL'ancien_mot_de_passe_est_incorrect."),
0621:                                                Language.getInstance().getText(
0622:                                                        "Erreur_!"),
0623:                                                JOptionPane.ERROR_MESSAGE);
0624:                            }
0625:                        } else {
0626:                            JOptionPane
0627:                                    .showMessageDialog(
0628:                                            AdministrationProject.this ,
0629:                                            Language
0630:                                                    .getInstance()
0631:                                                    .getText(
0632:                                                            "Impossible_de_changer_le_mot_de_passe.\nVous_n'êtes_pas_connecter_à_la_base."),
0633:                                            Language.getInstance().getText(
0634:                                                    "Erreur_!"),
0635:                                            JOptionPane.ERROR_MESSAGE);
0636:                        }
0637:                    }
0638:                });
0639:
0640:                JButton cancelButton = new JButton(Language.getInstance()
0641:                        .getText("Annuler"));
0642:                cancelButton.setToolTipText(Language.getInstance().getText(
0643:                        "Annuler"));
0644:                cancelButton.addActionListener(new ActionListener() {
0645:                    public void actionPerformed(ActionEvent e) {
0646:                        oldPassword.setText("");
0647:                        newPasswordFirst.setText("");
0648:                        newPasswordSecond.setText("");
0649:
0650:                    }
0651:                });
0652:
0653:                JLabel oldQuestion = new JLabel(Language.getInstance().getText(
0654:                        "Entrez_votre_ancien_mot_de_passe_:"));
0655:
0656:                JLabel question = new JLabel(Language.getInstance().getText(
0657:                        "Entrez_votre_nouveau_mot_de_passe_:"));
0658:
0659:                JLabel confirmation = new JLabel(Language.getInstance()
0660:                        .getText("Confirmer_le_nouveau_mot_de_passe_:"));
0661:
0662:                JPanel textFieldPane = new JPanel();
0663:                textFieldPane.setLayout(new BoxLayout(textFieldPane,
0664:                        BoxLayout.Y_AXIS));
0665:                textFieldPane.add(oldPassword);
0666:                textFieldPane.add(Box.createRigidArea(new Dimension(1, 50)));
0667:                textFieldPane.add(newPasswordFirst);
0668:                textFieldPane.add(Box.createRigidArea(new Dimension(1, 50)));
0669:                textFieldPane.add(newPasswordSecond);
0670:
0671:                JPanel textPane = new JPanel();
0672:                textPane.setLayout(new BoxLayout(textPane, BoxLayout.Y_AXIS));
0673:                textPane.add(oldQuestion);
0674:                textPane.add(Box.createRigidArea(new Dimension(1, 50)));
0675:                textPane.add(question);
0676:                textPane.add(Box.createRigidArea(new Dimension(1, 50)));
0677:                textPane.add(confirmation);
0678:
0679:                JPanel textPaneAll = new JPanel(new FlowLayout(
0680:                        FlowLayout.CENTER));
0681:                textPaneAll.add(textPane);
0682:                textPaneAll.add(textFieldPane);
0683:                textPaneAll.setBorder(BorderFactory.createEmptyBorder(100, 10,
0684:                        10, 20));
0685:
0686:                JPanel buttonPanel = new JPanel(new FlowLayout(
0687:                        FlowLayout.CENTER));
0688:                buttonPanel.add(validateButton);
0689:                buttonPanel.add(cancelButton);
0690:
0691:                pwdView.setLayout(new BoxLayout(pwdView, BoxLayout.Y_AXIS));
0692:                pwdView.add(textPaneAll);
0693:                pwdView.add(buttonPanel);
0694:                pwdView.setBorder(BorderFactory.createRaisedBevelBorder());
0695:                pwdView.validate();
0696:            } // Fin de la classe createChangePwdView/0
0697:
0698:            /**
0699:             * Méthode qui permet de créer l'écran permettant de gérer les utilisateurs.
0700:             *
0701:             */
0702:            public void createUsersViewForOneProject() {
0703:
0704:                projectView.removeAll();
0705:                // Les boutons
0706:                JButton createButton = new JButton(Language.getInstance()
0707:                        .getText("Ajouter"));
0708:                createButton.setIcon(Tools.createAppletImageIcon(
0709:                        PATH_TO_ADD_PROJECT_ICON, ""));
0710:                createButton.setToolTipText(Language.getInstance().getText(
0711:                        "Ajouter_un_nouvel_utilisateur"));
0712:                createButton.addActionListener(new ActionListener() {
0713:                    public void actionPerformed(ActionEvent e) {
0714:                        AddUser addUser = new AddUser();
0715:                        if (addUser.getUserList() != null) {
0716:                            for (int i = 0; i < addUser.getUserList().size(); i++) {
0717:                                if (ConnectionData.isConnected()) {
0718:                                    int transNumber = -1;
0719:                                    try {
0720:                                        transNumber = Api
0721:                                                .beginTransaction(Api.INSERT_USER);
0722:                                        ConnectionData.getAdminProjectInsert()
0723:                                                .addUserToGroup(
0724:                                                        ((User) addUser
0725:                                                                .getUserList()
0726:                                                                .get(i))
0727:                                                                .getLogin(),
0728:                                                        GUESTNAME, "");
0729:                                        Api.commitTrans(transNumber);
0730:                                    } catch (Exception exception) {
0731:                                        Api.forceRollBackTrans(transNumber);
0732:                                        Tools.ihmExceptionView(exception
0733:                                                .toString());
0734:                                    }
0735:
0736:                                }
0737:                                if (Api.getException() == null
0738:                                        || Api.getException().size() == 0) {
0739:                                    ArrayList data = new ArrayList();
0740:                                    data.add(((User) addUser.getUserList().get(
0741:                                            i)).getLogin());
0742:                                    data.add(((User) addUser.getUserList().get(
0743:                                            i)).getLastName()
0744:                                            + " "
0745:                                            + ((User) addUser.getUserList()
0746:                                                    .get(i)).getFirstName());
0747:                                    usersTableModel.addRow(data);
0748:                                    AdminProjectData.addUser((User) addUser
0749:                                            .getUserList().get(i));
0750:                                    AdminProjectData
0751:                                            .addUserInGroup(
0752:                                                    (User) addUser
0753:                                                            .getUserList().get(
0754:                                                                    i),
0755:                                                    AdminProjectData
0756:                                                            .getCurrentProject()
0757:                                                            .getGroup(GUESTNAME));
0758:                                    if (groupList.getSelectedIndex() != -1
0759:                                            && groupList
0760:                                                    .getSelectedValue()
0761:                                                    .equals(
0762:                                                            AdminProjectData
0763:                                                                    .getGroup(GUESTNAME))) {
0764:                                        inGroupListModel.addElement(addUser
0765:                                                .getUserList().get(i));
0766:                                    } else {
0767:                                        outGroupListModel.addElement(addUser
0768:                                                .getUserList().get(i));
0769:                                    }
0770:                                }
0771:                            }
0772:                        }
0773:
0774:                    }
0775:                });
0776:
0777:                deleteUserButton.setToolTipText(Language.getInstance().getText(
0778:                        "Supprimer_un_utilisateur"));
0779:                deleteUserButton.setEnabled(false);
0780:                deleteUserButton.setIcon(Tools.createAppletImageIcon(
0781:                        PATH_TO_DELETE_ICON, ""));
0782:                deleteUserButton.addActionListener(new ActionListener() {
0783:                    public void actionPerformed(ActionEvent e) {
0784:                        if (selectedUser != null) {
0785:                            Object[] options = {
0786:                                    Language.getInstance().getText("Oui"),
0787:                                    Language.getInstance().getText("Non") };
0788:                            int choice = -1;
0789:                            choice = JOptionPane
0790:                                    .showOptionDialog(
0791:                                            AdministrationProject.this ,
0792:                                            Language
0793:                                                    .getInstance()
0794:                                                    .getText(
0795:                                                            "Etes_vous_sûr_de_vouloir_supprimer_l'utilisateur_<_")
0796:                                                    + selectedUser.getLogin()
0797:                                                    + " > ?", Language
0798:                                                    .getInstance().getText(
0799:                                                            "Attention_!"),
0800:                                            JOptionPane.YES_NO_OPTION,
0801:                                            JOptionPane.WARNING_MESSAGE, null,
0802:                                            options, options[1]);
0803:                            if (choice == JOptionPane.YES_OPTION) {
0804:
0805:                                Group group = AdminProjectData.getGroup(
0806:                                        selectedUser, ADMINNAME);
0807:                                if (group != null
0808:                                        && AdminProjectData
0809:                                                .getGroupUsers(group).size() == 1) {
0810:                                    JOptionPane
0811:                                            .showMessageDialog(
0812:                                                    AdministrationProject.this ,
0813:                                                    Language
0814:                                                            .getInstance()
0815:                                                            .getText(
0816:                                                                    "Impossible_!\nUn_projet_doit_avoir_au_moins_un_administrateur"),
0817:                                                    Language
0818:                                                            .getInstance()
0819:                                                            .getText("Erreur_!"),
0820:                                                    JOptionPane.ERROR_MESSAGE);
0821:                                } else {
0822:                                    if (ConnectionData.isConnected()) {
0823:                                        int transNumber = -1;
0824:                                        try {
0825:                                            transNumber = Api
0826:                                                    .beginTransaction(Api.DELETE_USER);
0827:                                            ConnectionData
0828:                                                    .getAdminProjectDelete()
0829:                                                    .deleteUserFromProject(
0830:                                                            selectedUser
0831:                                                                    .getLogin());
0832:                                            Api.commitTrans(transNumber);
0833:                                        } catch (Exception exception) {
0834:                                            Api.forceRollBackTrans(transNumber);
0835:                                            Tools.ihmExceptionView(exception
0836:                                                    .toString());
0837:                                        }
0838:                                    }
0839:                                    if (Api.getException() == null
0840:                                            || Api.getException().size() == 0) {
0841:                                        memberListModel.clear();
0842:                                        notMemberListModel.clear();
0843:                                        usersTableModel
0844:                                                .removeData(userSelectedRow);
0845:                                        AdminProjectData
0846:                                                .removeUserFromCurrentProject(selectedUser);
0847:                                        deleteUserButton.setEnabled(false);
0848:                                        if (inGroupListModel
0849:                                                .contains(selectedUser)) {
0850:                                            inGroupListModel
0851:                                                    .removeElement(selectedUser);
0852:                                        }
0853:                                        if (outGroupListModel
0854:                                                .contains(selectedUser)) {
0855:                                            outGroupListModel
0856:                                                    .removeElement(selectedUser);
0857:                                        }
0858:                                    }
0859:                                }
0860:                            }
0861:                        }
0862:                    }
0863:                });
0864:
0865:                JPanel buttonSet = new JPanel(new FlowLayout());
0866:                buttonSet.setAlignmentY(FlowLayout.LEFT);
0867:                buttonSet.add(createButton);
0868:                buttonSet.add(deleteUserButton);
0869:                buttonSet.setBorder(BorderFactory.createRaisedBevelBorder());
0870:
0871:                // La table des utilisateurs
0872:
0873:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0874:                        .getText("Login"));
0875:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0876:                        .getText("Nom_complet"));
0877:
0878:                table.setModel(usersTableModel);
0879:                table.setGridColor(Color.BLACK);
0880:                table
0881:                        .setPreferredScrollableViewportSize(new Dimension(300,
0882:                                600));
0883:                JScrollPane tablePane = new JScrollPane(table);
0884:                table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
0885:                tablePane.setBackground(new Color(255, 255, 153));
0886:
0887:                ListSelectionModel rowSM = table.getSelectionModel();
0888:                rowSM.addListSelectionListener(new ListSelectionListener() {
0889:                    public void valueChanged(ListSelectionEvent e) {
0890:                        //Ignore extra messages.
0891:
0892:                        ListSelectionModel lsm = (ListSelectionModel) e
0893:                                .getSource();
0894:                        if (lsm.isSelectionEmpty()) {
0895:                            deleteUserButton.setEnabled(false);
0896:
0897:                        } else {
0898:
0899:                            userSelectedRow = lsm.getMinSelectionIndex();
0900:
0901:                            //selectedRow is selected
0902:                            deleteUserButton.setEnabled(true);
0903:
0904:                            selectedUser = AdminProjectData
0905:                                    .getUser((String) usersTableModel
0906:                                            .getValueAt(userSelectedRow, 0));
0907:                            AdminProjectData.setCurrentUser(selectedUser);
0908:                            if (selectedUser != null) {
0909:                                memberListModel.clear();
0910:                                notMemberListModel.clear();
0911:
0912:                                lastNameLabel.setText(Language.getInstance()
0913:                                        .getText("Nom_:_")
0914:                                        + selectedUser.getLastName());
0915:                                firstNameLabel.setText(Language.getInstance()
0916:                                        .getText("Prénom_:_")
0917:                                        + selectedUser.getFirstName());
0918:                                emailLabel.setText(Language.getInstance()
0919:                                        .getText("Email_:_")
0920:                                        + selectedUser.getEmail());
0921:                                phoneLabel.setText(Language.getInstance()
0922:                                        .getText("Téléphone_:_")
0923:                                        + selectedUser.getPhoneNumber());
0924:                                userDescriptionArea.setText(selectedUser
0925:                                        .getDescription());
0926:                                HashSet groupSet = AdminProjectData
0927:                                        .getUserGroups(selectedUser);
0928:                                if (groupSet != null && groupSet.size() > 0) {
0929:                                    for (Iterator iter = groupSet.iterator(); iter
0930:                                            .hasNext();) {
0931:                                        memberListModel.addElement(iter.next());
0932:                                    }
0933:                                }
0934:                                for (int i = 0; i < AdminProjectData
0935:                                        .getGroupCount(); i++) {
0936:                                    if (AdminProjectData.getGroup(i) != null) {
0937:                                        if (!groupSet.contains(AdminProjectData
0938:                                                .getGroup(i))) {
0939:                                            notMemberListModel
0940:                                                    .addElement(AdminProjectData
0941:                                                            .getGroup(i));
0942:                                        }
0943:                                    }
0944:                                }
0945:                                notMemberOf.setSelectedIndex(0);
0946:                                memberOf.setSelectedIndex(0);
0947:
0948:                            }
0949:                        }
0950:                    }
0951:                });
0952:
0953:                JPanel users = new JPanel(new BorderLayout());
0954:                users.setLayout(new BoxLayout(users, BoxLayout.Y_AXIS));
0955:                users.add(tablePane);
0956:                users.add(Box.createRigidArea(new Dimension(1, 25)));
0957:                users.add(buttonSet);
0958:
0959:                users.setBorder(BorderFactory.createTitledBorder(BorderFactory
0960:                        .createLineBorder(Color.BLACK), Language.getInstance()
0961:                        .getText("Utilisateurs")));
0962:
0963:                // La liste des groupes où l'utilisateur est membre
0964:
0965:                memberOf
0966:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0967:                memberOf.setSelectedIndex(0);
0968:                memberOf.setCellRenderer(new GroupListRenderer());
0969:                memberOf.setVisibleRowCount(8);
0970:                JScrollPane memberListScrollPane = new JScrollPane(memberOf);
0971:                memberListScrollPane.setBorder(BorderFactory
0972:                        .createTitledBorder(BorderFactory
0973:                                .createLineBorder(Color.BLACK), Language
0974:                                .getInstance().getText("Appartient_à")));
0975:                memberListScrollPane.setPreferredSize(new Dimension(200, 180));
0976:
0977:                // La liste des groupes où l'utilisateur n'est pas membre
0978:                notMemberOf
0979:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0980:                notMemberOf.setSelectedIndex(0);
0981:                notMemberOf.setCellRenderer(new GroupListRenderer());
0982:                notMemberOf.setVisibleRowCount(8);
0983:                JScrollPane notMemberListScrollPane = new JScrollPane(
0984:                        notMemberOf);
0985:                notMemberListScrollPane.setBorder(BorderFactory
0986:                        .createTitledBorder(BorderFactory
0987:                                .createLineBorder(Color.BLACK), Language
0988:                                .getInstance().getText("N'appartient_pas_à")));
0989:                notMemberListScrollPane
0990:                        .setPreferredSize(new Dimension(200, 180));
0991:                JButton addOne = new JButton("<");
0992:                addOne.setToolTipText(Language.getInstance().getText(
0993:                        "Ajouter_un_groupe"));
0994:                addOne.addActionListener(new ActionListener() {
0995:                    public void actionPerformed(ActionEvent e) {
0996:                        if (table.getSelectedRow() != -1) {
0997:                            if (notMemberOf.getSelectedValue() == null) {
0998:                                JOptionPane
0999:                                        .showMessageDialog(
1000:                                                AdministrationProject.this ,
1001:                                                Language
1002:                                                        .getInstance()
1003:                                                        .getText(
1004:                                                                "Vous_devez_sélectionner_un_groupe_avant_de_procéder_à_cette_opération!"),
1005:                                                Language.getInstance().getText(
1006:                                                        "Erreur_!"),
1007:                                                JOptionPane.ERROR_MESSAGE);
1008:                            } else {
1009:                                if (ConnectionData.isConnected()) {
1010:                                    int transNumber = -1;
1011:                                    try {
1012:                                        transNumber = Api
1013:                                                .beginTransaction(Api.INSERT_USER_INTO_GROUP);
1014:                                        ConnectionData
1015:                                                .getAdminProjectInsert()
1016:                                                .addUserToGroup(
1017:                                                        selectedUser.getLogin(),
1018:                                                        ((Group) notMemberOf
1019:                                                                .getSelectedValue())
1020:                                                                .getName(),
1021:                                                        ((Group) notMemberOf
1022:                                                                .getSelectedValue())
1023:                                                                .getDescription());
1024:                                        Api.commitTrans(transNumber);
1025:                                    } catch (Exception exception) {
1026:                                        Api.forceRollBackTrans(transNumber);
1027:                                        Tools.ihmExceptionView(exception
1028:                                                .toString());
1029:                                    }
1030:                                }
1031:                                if (Api.getException() == null
1032:                                        || Api.getException().size() == 0) {
1033:                                    if (!memberListModel.contains(notMemberOf
1034:                                            .getSelectedValue())) {
1035:                                        memberListModel.addElement(notMemberOf
1036:                                                .getSelectedValue());
1037:                                    }
1038:                                    AdminProjectData.addUserInGroup(
1039:                                            selectedUser, (Group) notMemberOf
1040:                                                    .getSelectedValue());
1041:                                    if (AdminProjectData.getCurrentGroup() != null
1042:                                            && AdminProjectData
1043:                                                    .getCurrentGroup()
1044:                                                    .equals(
1045:                                                            notMemberOf
1046:                                                                    .getSelectedValue())) {
1047:                                        if (!inGroupListModel
1048:                                                .contains(selectedUser)) {
1049:                                            inGroupListModel
1050:                                                    .addElement(selectedUser);
1051:                                        }
1052:                                        outGroupListModel
1053:                                                .removeElement(selectedUser);
1054:                                    }
1055:                                    notMemberListModel
1056:                                            .removeElement(notMemberOf
1057:                                                    .getSelectedValue());
1058:
1059:                                    memberOf.setSelectedIndex(0);
1060:
1061:                                }
1062:                            }
1063:                        }
1064:                    }
1065:                });
1066:
1067:                JButton addAll = new JButton("<<");
1068:                addAll.setToolTipText(Language.getInstance().getText(
1069:                        "Ajouter_tous_les_groupes"));
1070:                addAll.addActionListener(new ActionListener() {
1071:                    public void actionPerformed(ActionEvent e) {
1072:                        if (table.getSelectedRow() != -1) {
1073:                            for (int i = 0; i < notMemberListModel.size(); i++) {
1074:                                Group group = (Group) notMemberListModel.get(i);
1075:                                if (ConnectionData.isConnected()) {
1076:                                    try {
1077:                                        int transNumber = Api
1078:                                                .beginTransaction(Api.INSERT_USER_INTO_GROUP);
1079:                                        ConnectionData
1080:                                                .getAdminProjectInsert()
1081:                                                .addUserToGroup(
1082:                                                        selectedUser.getLogin(),
1083:                                                        group.getName(),
1084:                                                        selectedUser
1085:                                                                .getDescription());
1086:                                        Api.commitTrans(transNumber);
1087:                                    } catch (Exception exception) {
1088:                                        Tools.ihmExceptionView(exception
1089:                                                .toString());
1090:                                    }
1091:
1092:                                }
1093:                                if (Api.getException() == null
1094:                                        || Api.getException().size() == 0) {
1095:                                    memberListModel.addElement(group);
1096:                                    AdminProjectData.addUserInGroup(
1097:                                            selectedUser, group);
1098:                                    if (AdminProjectData.getCurrentGroup() != null
1099:                                            && AdminProjectData
1100:                                                    .getCurrentGroup().equals(
1101:                                                            group)) {
1102:                                        if (!inGroupListModel
1103:                                                .contains(selectedUser)) {
1104:                                            inGroupListModel
1105:                                                    .addElement(selectedUser);
1106:                                        }
1107:                                        outGroupListModel
1108:                                                .removeElement(selectedUser);
1109:                                    }
1110:                                }
1111:                            }
1112:                            notMemberListModel.clear();
1113:                            memberOf.setSelectedIndex(0);
1114:                        }
1115:                    }
1116:                });
1117:
1118:                JButton removeOne = new JButton(">");
1119:                removeOne.setToolTipText(Language.getInstance().getText(
1120:                        "Retirer_un_groupe"));
1121:                removeOne.addActionListener(new ActionListener() {
1122:                    public void actionPerformed(ActionEvent e) {
1123:                        if (table.getSelectedRow() != -1) {
1124:                            if (memberOf.getSelectedValue() == null) {
1125:                                JOptionPane
1126:                                        .showMessageDialog(
1127:                                                AdministrationProject.this ,
1128:                                                Language
1129:                                                        .getInstance()
1130:                                                        .getText(
1131:                                                                "Vous_devez_sélectionner_un_groupe_avant_de_procéder_à_cette_opération!"),
1132:                                                Language.getInstance().getText(
1133:                                                        "Erreur_!"),
1134:                                                JOptionPane.ERROR_MESSAGE);
1135:                            } else {
1136:                                if (((Group) memberOf.getSelectedValue())
1137:                                        .getName().equals(ADMINNAME)
1138:                                        && AdminProjectData.getGroupUsers(
1139:                                                (Group) memberOf
1140:                                                        .getSelectedValue())
1141:                                                .size() == 1) {
1142:                                    JOptionPane
1143:                                            .showMessageDialog(
1144:                                                    AdministrationProject.this ,
1145:                                                    Language
1146:                                                            .getInstance()
1147:                                                            .getText(
1148:                                                                    "Impossible_!\nUn_projet_doit_avoir_au_moins_un_administrateur"),
1149:                                                    Language
1150:                                                            .getInstance()
1151:                                                            .getText("Erreur_!"),
1152:                                                    JOptionPane.ERROR_MESSAGE);
1153:                                } else {
1154:                                    if (ConnectionData.isConnected()) {
1155:                                        try {
1156:                                            int transNumber = Api
1157:                                                    .beginTransaction(Api.DELETE_USER_FROM_GROUP);
1158:                                            ConnectionData
1159:                                                    .getAdminProjectDelete()
1160:                                                    .deleteUserFromGroup(
1161:                                                            selectedUser
1162:                                                                    .getLogin(),
1163:                                                            ((Group) memberOf
1164:                                                                    .getSelectedValue())
1165:                                                                    .getName());
1166:                                            Api.commitTrans(transNumber);
1167:                                        } catch (Exception exception) {
1168:                                            Tools.ihmExceptionView(exception
1169:                                                    .toString());
1170:                                        }
1171:                                    }
1172:                                    if (Api.getException() == null
1173:                                            || Api.getException().size() == 0) {
1174:                                        AdminProjectData.removeUserFromGroup(
1175:                                                selectedUser, (Group) memberOf
1176:                                                        .getSelectedValue());
1177:                                        if (!notMemberListModel
1178:                                                .contains(memberOf
1179:                                                        .getSelectedValue())) {
1180:                                            notMemberListModel
1181:                                                    .addElement(memberOf
1182:                                                            .getSelectedValue());
1183:                                        }
1184:                                        if (AdminProjectData.getCurrentGroup() != null
1185:                                                && AdminProjectData
1186:                                                        .getCurrentGroup()
1187:                                                        .equals(
1188:                                                                memberOf
1189:                                                                        .getSelectedValue())) {
1190:                                            inGroupListModel
1191:                                                    .removeElement(selectedUser);
1192:                                            if (!outGroupListModel
1193:                                                    .contains(selectedUser)) {
1194:                                                outGroupListModel
1195:                                                        .addElement(selectedUser);
1196:                                            }
1197:                                        }
1198:                                        memberListModel.removeElement(memberOf
1199:                                                .getSelectedValue());
1200:                                    }
1201:                                }
1202:                            }
1203:                        }
1204:                    }
1205:                });
1206:
1207:                JButton removeAll = new JButton(">>");
1208:                removeAll.setToolTipText(Language.getInstance().getText(
1209:                        "Retirer_tous_les_groupes"));
1210:                removeAll.addActionListener(new ActionListener() {
1211:                    public void actionPerformed(ActionEvent e) {
1212:                        if (table.getSelectedRow() != -1) {
1213:
1214:                            Group admin = null;
1215:                            for (int i = 0; i < memberListModel.size(); i++) {
1216:                                Group group = (Group) memberListModel.get(i);
1217:                                if (group.getName().equals(ADMINNAME)
1218:                                        && AdminProjectData
1219:                                                .getGroupUsers(group).size() == 1) {
1220:                                    admin = group;
1221:                                    JOptionPane
1222:                                            .showMessageDialog(
1223:                                                    AdministrationProject.this ,
1224:                                                    Language
1225:                                                            .getInstance()
1226:                                                            .getText(
1227:                                                                    "Impossible_de_supprimer_l'utilisateur_du_groupe_\"Administrateur\"_!\n")
1228:                                                            + Language
1229:                                                                    .getInstance()
1230:                                                                    .getText(
1231:                                                                            "Un_projet_doit_avoir_au_moins_un_administrateur"),
1232:                                                    Language
1233:                                                            .getInstance()
1234:                                                            .getText("Erreur_!"),
1235:                                                    JOptionPane.ERROR_MESSAGE);
1236:                                } else {
1237:                                    if (ConnectionData.isConnected()) {
1238:                                        try {
1239:                                            int transNumber = Api
1240:                                                    .beginTransaction(Api.DELETE_USER_FROM_GROUP);
1241:                                            ConnectionData
1242:                                                    .getAdminProjectDelete()
1243:                                                    .deleteUserFromGroup(
1244:                                                            selectedUser
1245:                                                                    .getLogin(),
1246:                                                            group.getName());
1247:                                            Api.commitTrans(transNumber);
1248:                                        } catch (Exception exception) {
1249:                                            Tools.ihmExceptionView(exception
1250:                                                    .toString());
1251:                                        }
1252:                                    }
1253:                                    if (Api.getException() == null
1254:                                            || Api.getException().size() == 0) {
1255:
1256:                                        AdminProjectData.removeUserFromGroup(
1257:                                                selectedUser, group);
1258:                                        notMemberListModel.addElement(group);
1259:                                        if (AdminProjectData.getCurrentGroup() != null
1260:                                                && AdminProjectData
1261:                                                        .getCurrentGroup()
1262:                                                        .equals(group)) {
1263:                                            inGroupListModel
1264:                                                    .removeElement(selectedUser);
1265:                                            if (!outGroupListModel
1266:                                                    .contains(selectedUser)) {
1267:                                                outGroupListModel
1268:                                                        .addElement(selectedUser);
1269:                                            }
1270:                                        }
1271:                                    }
1272:                                }
1273:                            }
1274:                            memberListModel.clear();
1275:                            if (admin != null)
1276:                                memberListModel.addElement(admin);
1277:
1278:                        }
1279:                    }
1280:                });
1281:
1282:                JPanel moveButtons = new JPanel();
1283:                moveButtons.setLayout(new BoxLayout(moveButtons,
1284:                        BoxLayout.Y_AXIS));
1285:                moveButtons.setAlignmentX(Component.CENTER_ALIGNMENT);
1286:                moveButtons.add(addOne);
1287:                moveButtons.add(addAll);
1288:                moveButtons.add(Box.createRigidArea(new Dimension(1, 25)));
1289:                moveButtons.add(removeOne);
1290:                moveButtons.add(removeAll);
1291:
1292:                JPanel memberPanel = new JPanel();
1293:                memberPanel.setLayout(new BoxLayout(memberPanel,
1294:                        BoxLayout.X_AXIS));
1295:                memberPanel.add(memberListScrollPane);
1296:                memberPanel.add(Box.createRigidArea(new Dimension(20, 50)));
1297:                memberPanel.add(moveButtons);
1298:                memberPanel.add(Box.createRigidArea(new Dimension(20, 50)));
1299:                memberPanel.add(notMemberListScrollPane);
1300:
1301:                firstNameLabel = new JLabel(Language.getInstance().getText(
1302:                        "Prénom_:"));
1303:                lastNameLabel = new JLabel(Language.getInstance().getText(
1304:                        "Nom_:"));
1305:                emailLabel = new JLabel(Language.getInstance().getText(
1306:                        "Email_:"));
1307:                phoneLabel = new JLabel(Language.getInstance().getText(
1308:                        "Téléphone_:"));
1309:
1310:                JPanel textFieldPanel = new JPanel();
1311:                textFieldPanel.setLayout(new BoxLayout(textFieldPanel,
1312:                        BoxLayout.Y_AXIS));
1313:                textFieldPanel.add(Box.createRigidArea(new Dimension(20, 40)));
1314:                textFieldPanel.add(firstNameLabel);
1315:                textFieldPanel.add(Box.createRigidArea(new Dimension(20, 10)));
1316:                textFieldPanel.add(lastNameLabel);
1317:                textFieldPanel.add(Box.createRigidArea(new Dimension(20, 10)));
1318:                textFieldPanel.add(emailLabel);
1319:                textFieldPanel.add(Box.createRigidArea(new Dimension(20, 10)));
1320:                textFieldPanel.add(phoneLabel);
1321:
1322:                JPanel labelPanel = new JPanel();
1323:                labelPanel
1324:                        .setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS));
1325:                labelPanel.add(Box.createRigidArea(new Dimension(20, 40)));
1326:                labelPanel.add(firstNameLabel);
1327:                labelPanel.add(Box.createRigidArea(new Dimension(20, 10)));
1328:                labelPanel.add(lastNameLabel);
1329:                labelPanel.add(Box.createRigidArea(new Dimension(20, 10)));
1330:                labelPanel.add(emailLabel);
1331:                labelPanel.add(Box.createRigidArea(new Dimension(20, 10)));
1332:                labelPanel.add(phoneLabel);
1333:
1334:                JPanel textPaneAll = new JPanel(new FlowLayout(
1335:                        FlowLayout.CENTER));
1336:                textPaneAll.add(labelPanel);
1337:                textPaneAll.add(textFieldPanel);
1338:
1339:                userDescriptionArea = new JTextArea();
1340:                userDescriptionArea.setPreferredSize(new Dimension(100, 50));
1341:                JScrollPane descriptionScrollPane = new JScrollPane(
1342:                        userDescriptionArea);
1343:                descriptionScrollPane.setBorder(BorderFactory
1344:                        .createTitledBorder(BorderFactory
1345:                                .createLineBorder(Color.BLACK), Language
1346:                                .getInstance().getText("Description")));
1347:
1348:                userDescriptionArea
1349:                        .addCaretListener(new UserDescriptionCaretListener());
1350:
1351:                JPanel informations = new JPanel();
1352:                informations.setLayout(new BoxLayout(informations,
1353:                        BoxLayout.X_AXIS));
1354:                informations.add(textPaneAll);
1355:                informations.add(Box.createRigidArea(new Dimension(20, 10)));
1356:                informations.add(descriptionScrollPane);
1357:
1358:                JPanel properties = new JPanel();
1359:                properties
1360:                        .setLayout(new BoxLayout(properties, BoxLayout.Y_AXIS));
1361:                properties.add(memberPanel);
1362:                properties.add(Box.createRigidArea(new Dimension(1, 25)));
1363:                properties.add(informations);
1364:                properties.setBorder(BorderFactory.createTitledBorder(
1365:                        BorderFactory.createLineBorder(Color.BLACK), Language
1366:                                .getInstance().getText("Propriétés")));
1367:
1368:                JPanel jjjj = new JPanel(new BorderLayout());
1369:                jjjj.add(properties, BorderLayout.EAST);
1370:
1371:                JPanel usersViewPanel = new JPanel();
1372:                usersViewPanel.setLayout(new BoxLayout(usersViewPanel,
1373:                        BoxLayout.X_AXIS));
1374:
1375:                usersViewPanel.add(users);
1376:                usersViewPanel.add(Box.createRigidArea(new Dimension(10, 10)));
1377:                usersViewPanel.add(properties);
1378:                usersViewPanel.setBorder(BorderFactory.createEmptyBorder(20, 0,
1379:                        20, 0));
1380:                userView.add(usersViewPanel, BorderLayout.CENTER);
1381:
1382:            } // Fin de la méthode createUsersViewForOneProject/0
1383:
1384:            /**
1385:             * Méthode qui permet de créer l'écran permettant de gérer les groupes.
1386:             *
1387:             */
1388:            public void createGroupsViewForOneProject() {
1389:
1390:                projectView.removeAll();
1391:                groupView.setLayout(new BoxLayout(groupView, BoxLayout.Y_AXIS));
1392:
1393:                // Les boutons
1394:                JButton createButton = new JButton(Language.getInstance()
1395:                        .getText("Nouveau"));
1396:                createButton.setToolTipText(Language.getInstance().getText(
1397:                        "Créer_un_nouveau_groupe"));
1398:                createButton.addActionListener(new ActionListener() {
1399:                    public void actionPerformed(ActionEvent e) {
1400:                        AskNameAndDescription askParam = new AskNameAndDescription(
1401:                                GROUP,
1402:                                Language.getInstance()
1403:                                        .getText("Nouveau_groupe"),
1404:                                Language.getInstance().getText(
1405:                                        "Nouveau_groupe_:_"),
1406:                                javax.swing.JOptionPane
1407:                                        .getFrameForComponent(AdministrationProject.this ));
1408:                        Group group = askParam.getGroup();
1409:                        if (group != null) {
1410:                            if (ConnectionData.isConnected()) {
1411:                                int transNumber = -1;
1412:                                try {
1413:                                    transNumber = Api
1414:                                            .beginTransaction(Api.INSERT_GROUP);
1415:                                    ConnectionData.getAdminProjectInsert()
1416:                                            .addGroupToProject(group.getName(),
1417:                                                    group.getDescription());
1418:                                    Api.commitTrans(transNumber);
1419:                                } catch (Exception exception) {
1420:                                    Api.forceRollBackTrans(transNumber);
1421:                                    Tools
1422:                                            .ihmExceptionView(exception
1423:                                                    .toString());
1424:                                }
1425:
1426:                            }
1427:                            if (Api.getException() == null
1428:                                    || Api.getException().size() == 0) {
1429:                                AdminProjectData.addGroup(group);
1430:                                groupListModel.addElement(group);
1431:                                if (table.getSelectedRow() != -1) {
1432:                                    notMemberListModel.addElement(group);
1433:                                }
1434:                            }
1435:                        }
1436:                    }
1437:                });
1438:
1439:                renameButton.setToolTipText(Language.getInstance().getText(
1440:                        "Modifier_un_groupe"));
1441:                renameButton.setEnabled(false);
1442:                renameButton.addActionListener(new ActionListener() {
1443:                    public void actionPerformed(ActionEvent e) {
1444:                        Group group = (Group) groupList.getSelectedValue();
1445:                        String oldName = group.getName();
1446:                        String oldDescription = group.getDescription();
1447:                        AskNameAndDescription askParam = new AskNameAndDescription(
1448:                                GROUP,
1449:                                Language.getInstance().getText(
1450:                                        "Modifier_un_groupe"),
1451:                                Language.getInstance().getText(
1452:                                        "Nom_du_groupe_:_"),
1453:                                group,
1454:                                javax.swing.JOptionPane
1455:                                        .getFrameForComponent(AdministrationProject.this ));
1456:                        if (ConnectionData.isConnected()) {
1457:                            int transNumber = -1;
1458:                            try {
1459:                                transNumber = Api
1460:                                        .beginTransaction(Api.UPDATE_GROUP);
1461:                                ConnectionData.getAdminProjectUpdate()
1462:                                        .updateGroup(
1463:                                                oldName,
1464:                                                askParam.getGroup().getName(),
1465:                                                askParam.getGroup()
1466:                                                        .getDescription());
1467:                                Api.commitTrans(transNumber);
1468:                            } catch (Exception exception) {
1469:                                Api.forceRollBackTrans(transNumber);
1470:                                Tools.ihmExceptionView(exception.toString());
1471:                            }
1472:                        }
1473:                        if (Api.getException() == null
1474:                                || Api.getException().size() == 0) {
1475:                            groupDescriptionArea.setText(askParam.getGroup()
1476:                                    .getDescription());
1477:                            groupList.repaint();
1478:                        } else {
1479:                            group.setName(oldName);
1480:                            group.setDescription(oldDescription);
1481:                        }
1482:                    }
1483:                });
1484:
1485:                groupDeleteButton.setToolTipText(Language.getInstance()
1486:                        .getText("Supprimer_un_groupe"));
1487:                groupDeleteButton.setEnabled(false);
1488:                groupDeleteButton.addActionListener(new ActionListener() {
1489:                    public void actionPerformed(ActionEvent e) {
1490:                        int selectedIndex = groupList.getSelectedIndex();
1491:                        Group group = (Group) groupList.getSelectedValue();
1492:                        if (group != null) {
1493:                            Object[] options = {
1494:                                    Language.getInstance().getText("Oui"),
1495:                                    Language.getInstance().getText("Non") };
1496:                            int choice = -1;
1497:
1498:                            choice = JOptionPane
1499:                                    .showOptionDialog(
1500:                                            AdministrationProject.this ,
1501:                                            Language
1502:                                                    .getInstance()
1503:                                                    .getText(
1504:                                                            "Etes_vous_sûr_de_vouloir_supprimer_le_groupe_<_")
1505:                                                    + group.getName() + " > ?",
1506:                                            Language.getInstance().getText(
1507:                                                    "Attention_!"),
1508:                                            JOptionPane.YES_NO_OPTION,
1509:                                            JOptionPane.WARNING_MESSAGE, null,
1510:                                            options, options[1]);
1511:                            if (choice == JOptionPane.YES_OPTION) {
1512:                                if (ConnectionData.isConnected()) {
1513:                                    int transNumber = -1;
1514:                                    try {
1515:                                        transNumber = Api
1516:                                                .beginTransaction(Api.DELETE_GROUP);
1517:                                        ConnectionData.getAdminProjectDelete()
1518:                                                .deleteGroup(group.getName());
1519:                                        Api.commitTrans(transNumber);
1520:                                    } catch (Exception exception) {
1521:                                        Api.forceRollBackTrans(transNumber);
1522:                                        Tools.ihmExceptionView(exception
1523:                                                .toString());
1524:                                    }
1525:
1526:                                }
1527:                                if (Api.getException() == null
1528:                                        || Api.getException().size() == 0) {
1529:                                    groupListModel.remove(selectedIndex);
1530:                                    AdminProjectData.removeGroup(group);
1531:                                    for (int i = 0; i < group.getUserList()
1532:                                            .size(); i++) {
1533:                                        User user = (User) group.getUserList()
1534:                                                .get(i);
1535:                                        if (AdminProjectData
1536:                                                .getUserGroups(user) == null) {
1537:                                            if (ConnectionData.isConnected()) {
1538:                                                try {
1539:                                                    int transNumber = Api
1540:                                                            .beginTransaction(Api.INSERT_USER_INTO_GROUP);
1541:                                                    ConnectionData
1542:                                                            .getAdminProjectInsert()
1543:                                                            .addUserToGroup(
1544:                                                                    user
1545:                                                                            .getLogin(),
1546:                                                                    GUESTNAME,
1547:                                                                    user
1548:                                                                            .getDescription());
1549:                                                    Api
1550:                                                            .commitTrans(transNumber);
1551:                                                } catch (Exception exception) {
1552:                                                    Tools
1553:                                                            .ihmExceptionView(exception
1554:                                                                    .toString());
1555:                                                }
1556:
1557:                                            }
1558:                                            if (Api.getException() == null
1559:                                                    || Api.getException()
1560:                                                            .size() == 0) {
1561:                                                AdminProjectData
1562:                                                        .addUserInGroup(
1563:                                                                user,
1564:                                                                AdminProjectData
1565:                                                                        .getCurrentProject()
1566:                                                                        .getGroup(
1567:                                                                                GUESTNAME));
1568:                                                if (AdminProjectData
1569:                                                        .getCurrentUser() != null
1570:                                                        && group
1571:                                                                .getUserList()
1572:                                                                .contains(
1573:                                                                        AdminProjectData
1574:                                                                                .getCurrentUser())) {
1575:                                                    memberListModel
1576:                                                            .addElement(AdminProjectData
1577:                                                                    .getCurrentProject()
1578:                                                                    .getGroup(
1579:                                                                            GUESTNAME));
1580:                                                    notMemberListModel
1581:                                                            .removeElement(AdminProjectData
1582:                                                                    .getCurrentProject()
1583:                                                                    .getGroup(
1584:                                                                            GUESTNAME));
1585:                                                }
1586:
1587:                                            }
1588:                                        }
1589:                                    }
1590:                                    if (AdminProjectData.getCurrentUser() != null
1591:                                            && group.getUserList().contains(
1592:                                                    AdminProjectData
1593:                                                            .getCurrentUser())) {
1594:                                        memberListModel.removeElement(group);
1595:                                    }
1596:
1597:                                    inGroupListModel.clear();
1598:                                    outGroupListModel.clear();
1599:
1600:                                }
1601:                            }
1602:                        }
1603:                    }
1604:                });
1605:
1606:                JPanel buttonSet = new JPanel(new FlowLayout());
1607:                buttonSet.setAlignmentY(FlowLayout.LEFT);
1608:                buttonSet.add(createButton);
1609:                buttonSet.add(renameButton);
1610:                buttonSet.add(groupDeleteButton);
1611:
1612:                // Description du groupe
1613:
1614:                groupDescriptionArea.setPreferredSize(new Dimension(100, 50));
1615:                groupDescriptionArea.setEditable(false);
1616:                JScrollPane groupDescriptionScrollPane = new JScrollPane(
1617:                        groupDescriptionArea);
1618:                groupDescriptionScrollPane.setBorder(BorderFactory
1619:                        .createTitledBorder(BorderFactory
1620:                                .createLineBorder(Color.BLACK), Language
1621:                                .getInstance().getText("Description")));
1622:
1623:                // Permission
1624:                viewButton = new JButton(Language.getInstance().getText(
1625:                        "__Voir__"));
1626:                viewButton.setEnabled(false);
1627:                viewButton.setToolTipText(Language.getInstance().getText(
1628:                        "Visualiser_les_permissions"));
1629:                viewButton.addActionListener(new ActionListener() {
1630:                    public void actionPerformed(ActionEvent e) {
1631:                        new GroupAccess(
1632:                                false,
1633:                                (Group) groupList.getSelectedValue(),
1634:                                javax.swing.JOptionPane
1635:                                        .getFrameForComponent(AdministrationProject.this ),
1636:                                false);
1637:
1638:                    }
1639:                });
1640:
1641:                modifyButton = new JButton(Language.getInstance().getText(
1642:                        "Modifier"));
1643:                modifyButton.setEnabled(false);
1644:                modifyButton.setToolTipText(Language.getInstance().getText(
1645:                        "Modifier_les_permissions"));
1646:                modifyButton.addActionListener(new ActionListener() {
1647:                    public void actionPerformed(ActionEvent e) {
1648:                        GroupAccess groupAccess = new GroupAccess(
1649:                                true,
1650:                                (Group) groupList.getSelectedValue(),
1651:                                javax.swing.JOptionPane
1652:                                        .getFrameForComponent(AdministrationProject.this ),
1653:                                true);
1654:                        if (groupAccess.getObservedGroup() != null) {
1655:                            if (ConnectionData.isConnected()) {
1656:                                int transNumber = -1;
1657:                                try {
1658:                                    transNumber = Api
1659:                                            .beginTransaction(Api.UPDATE_PERMISSION);
1660:                                    boolean[] tab = ((Group) groupList
1661:                                            .getSelectedValue())
1662:                                            .getTestsPermissions();
1663:                                    int perm = 0;
1664:                                    if (tab[0])
1665:                                        perm |= AdminProject.ALLOW_CREATE_TEST;
1666:                                    if (tab[1])
1667:                                        perm |= AdminProject.ALLOW_UPDATE_TEST;
1668:                                    if (tab[2])
1669:                                        perm |= AdminProject.ALLOW_DELETE_TEST;
1670:                                    tab = ((Group) groupList.getSelectedValue())
1671:                                            .getCampaignPermissions();
1672:                                    if (tab[0])
1673:                                        perm |= AdminProject.ALLOW_CREATE_CAMP;
1674:                                    if (tab[1])
1675:                                        perm |= AdminProject.ALLOW_UPDATE_CAMP;
1676:                                    if (tab[2])
1677:                                        perm |= AdminProject.ALLOW_DELETE_CAMP;
1678:                                    if (tab[3])
1679:                                        perm |= AdminProject.ALLOW_EXECUT_CAMP;
1680:                                    ConnectionData
1681:                                            .getAdminProjectUpdate()
1682:                                            .updatePermission(
1683:                                                    ((Group) groupList
1684:                                                            .getSelectedValue())
1685:                                                            .getName(), perm);
1686:                                    Api.commitTrans(transNumber);
1687:                                } catch (Exception exception) {
1688:                                    Api.forceRollBackTrans(transNumber);
1689:                                    Tools
1690:                                            .ihmExceptionView(exception
1691:                                                    .toString());
1692:                                }
1693:                            } else {
1694:                                JOptionPane
1695:                                        .showMessageDialog(
1696:                                                AdministrationProject.this ,
1697:                                                Language
1698:                                                        .getInstance()
1699:                                                        .getText(
1700:                                                                "Impossible_de_changer_les_droits.\nVous_n'êtes_pas_connecté_à_la_base."),
1701:                                                Language.getInstance().getText(
1702:                                                        "Erreur_!"),
1703:                                                JOptionPane.ERROR_MESSAGE);
1704:                            }
1705:                        }
1706:                    }
1707:                });
1708:
1709:                JPanel permissionPanel = new JPanel();
1710:                permissionPanel.setLayout(new BoxLayout(permissionPanel,
1711:                        BoxLayout.Y_AXIS));
1712:                permissionPanel.setBorder(BorderFactory.createTitledBorder(
1713:                        BorderFactory.createLineBorder(Color.BLACK), Language
1714:                                .getInstance().getText("Permissions")));
1715:                permissionPanel.add(Box.createRigidArea(new Dimension(1, 10)));
1716:                permissionPanel.add(viewButton);
1717:                permissionPanel.add(Box.createRigidArea(new Dimension(1, 15)));
1718:                permissionPanel.add(modifyButton);
1719:                permissionPanel.add(Box.createRigidArea(new Dimension(1, 10)));
1720:
1721:                // La liste des groupes
1722:
1723:                groupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1724:                groupList.setSelectedIndex(0);
1725:                groupList.setCellRenderer(new GroupListRenderer());
1726:                groupList.setVisibleRowCount(10);
1727:                JScrollPane groupListScrollPane = new JScrollPane(groupList);
1728:
1729:                groupList.addListSelectionListener(new ListSelectionListener() {
1730:                    public void valueChanged(ListSelectionEvent e) {
1731:                        //Ignore extra messages.
1732:                        if (e.getValueIsAdjusting())
1733:                            return;
1734:                        groupSelectedRow = groupList.getSelectedIndex();
1735:                        if (groupSelectedRow != -1
1736:                                && groupSelectedRow < groupListModel.size()) {
1737:                            AdminProjectData.setCurrentGroup((Group) groupList
1738:                                    .getSelectedValue());
1739:                            if (!((Group) groupList.getSelectedValue())
1740:                                    .getName().equals(ADMINNAME)
1741:                                    && !((Group) groupList.getSelectedValue())
1742:                                            .getName().equals(DEVNAME)
1743:                                    && !((Group) groupList.getSelectedValue())
1744:                                            .getName().equals(GUESTNAME)) {
1745:                                renameButton.setEnabled(true);
1746:                                groupDeleteButton.setEnabled(true);
1747:                                modifyButton.setEnabled(true);
1748:
1749:                            } else {
1750:                                renameButton.setEnabled(false);
1751:                                groupDeleteButton.setEnabled(false);
1752:                                modifyButton.setEnabled(false);
1753:                            }
1754:                            viewButton.setEnabled(true);
1755:                            inGroupListModel.clear();
1756:                            outGroupListModel.clear();
1757:
1758:                            for (Iterator iter = AdminProjectData
1759:                                    .getGroupUsers(
1760:                                            (Group) groupList
1761:                                                    .getSelectedValue())
1762:                                    .iterator(); iter.hasNext();) {
1763:                                inGroupListModel.addElement(iter.next());
1764:                            }
1765:                            HashSet projectUsersSet = AdminProjectData
1766:                                    .getUsersOfCurrentProject();
1767:                            for (Iterator iter = projectUsersSet.iterator(); iter
1768:                                    .hasNext();) {
1769:                                User projectUser = (User) iter.next();
1770:                                if (!inGroupListModel.contains(projectUser)) {
1771:                                    outGroupListModel.addElement(projectUser);
1772:                                }
1773:                            }
1774:                            inGrouplist.setSelectedIndex(0);
1775:                            outGrouplist.setSelectedIndex(0);
1776:
1777:                            groupDescriptionArea.setText(((Group) groupList
1778:                                    .getSelectedValue()).getDescription());
1779:                        } else {
1780:                            viewButton.setEnabled(false);
1781:                            modifyButton.setEnabled(false);
1782:                            renameButton.setEnabled(false);
1783:                            groupDeleteButton.setEnabled(false);
1784:                        }
1785:                    }
1786:                });
1787:
1788:                JPanel groupPanel = new JPanel();
1789:                groupPanel
1790:                        .setLayout(new BoxLayout(groupPanel, BoxLayout.Y_AXIS));
1791:                groupPanel.add(groupListScrollPane);
1792:                groupPanel.add(buttonSet);
1793:
1794:                JPanel allGroup = new JPanel();
1795:                allGroup.setLayout(new BoxLayout(allGroup, BoxLayout.X_AXIS));
1796:                allGroup.add(groupPanel);
1797:                allGroup.add(Box.createRigidArea(new Dimension(30, 1)));
1798:                allGroup.add(permissionPanel);
1799:                allGroup.add(Box.createRigidArea(new Dimension(40, 1)));
1800:                allGroup.add(groupDescriptionScrollPane);
1801:                allGroup.setBorder(BorderFactory.createTitledBorder(
1802:                        BorderFactory.createLineBorder(Color.BLACK), Language
1803:                                .getInstance().getText("Groupes")));
1804:
1805:                //Création de la liste des utilisateurs
1806:                inGrouplist
1807:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
1808:                inGrouplist.setSelectedIndex(0);
1809:                inGrouplist.setCellRenderer(new UserListRenderer());
1810:                inGrouplist.setVisibleRowCount(5);
1811:                JScrollPane inGroupListScrollPane = new JScrollPane(inGrouplist);
1812:
1813:                inGroupListScrollPane.setBorder(BorderFactory
1814:                        .createTitledBorder(BorderFactory
1815:                                .createLineBorder(Color.BLACK), Language
1816:                                .getInstance().getText(
1817:                                        "Appartiennent_au_groupe")));
1818:
1819:                //Création de la liste des utilisateurs
1820:
1821:                outGrouplist
1822:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
1823:                outGrouplist.setSelectedIndex(0);
1824:                outGrouplist.setCellRenderer(new UserListRenderer());
1825:                outGrouplist.setVisibleRowCount(5);
1826:                JScrollPane outGroupListScrollPane = new JScrollPane(
1827:                        outGrouplist);
1828:                outGroupListScrollPane.setBorder(BorderFactory
1829:                        .createTitledBorder(BorderFactory
1830:                                .createLineBorder(Color.BLACK), Language
1831:                                .getInstance().getText(
1832:                                        "N'appartiennent_pas_au_groupe")));
1833:
1834:                // Boutons utilisateurs
1835:
1836:                JButton addOne = new JButton("<");
1837:                addOne.setToolTipText(Language.getInstance().getText(
1838:                        "Ajouter_un_utilisateur"));
1839:                addOne.addActionListener(new ActionListener() {
1840:                    public void actionPerformed(ActionEvent e) {
1841:                        if (groupList.getSelectedValue() != null) {
1842:                            if (outGrouplist.getSelectedValue() == null) {
1843:                                JOptionPane
1844:                                        .showMessageDialog(
1845:                                                AdministrationProject.this ,
1846:                                                Language
1847:                                                        .getInstance()
1848:                                                        .getText(
1849:                                                                "Vous_devez_sélectionner_un_utilisateur_avant_de_procéder_à_cette_opération!"),
1850:                                                Language.getInstance().getText(
1851:                                                        "Erreur_!"),
1852:                                                JOptionPane.ERROR_MESSAGE);
1853:                            } else {
1854:                                if (ConnectionData.isConnected()) {
1855:                                    try {
1856:                                        int transNumber = Api
1857:                                                .beginTransaction(Api.INSERT_USER_INTO_GROUP);
1858:                                        ConnectionData
1859:                                                .getAdminProjectInsert()
1860:                                                .addUserToGroup(
1861:                                                        ((User) outGrouplist
1862:                                                                .getSelectedValue())
1863:                                                                .getLogin(),
1864:                                                        ((Group) groupList
1865:                                                                .getSelectedValue())
1866:                                                                .getName(),
1867:                                                        ((User) outGrouplist
1868:                                                                .getSelectedValue())
1869:                                                                .getDescription());
1870:                                        Api.commitTrans(transNumber);
1871:                                    } catch (Exception exception) {
1872:                                        Tools.ihmExceptionView(exception
1873:                                                .toString());
1874:                                    }
1875:                                }
1876:                                if (Api.getException() == null
1877:                                        || Api.getException().size() == 0) {
1878:                                    if (!inGroupListModel.contains(outGrouplist
1879:                                            .getSelectedValue())) {
1880:                                        inGroupListModel
1881:                                                .addElement(outGrouplist
1882:                                                        .getSelectedValue());
1883:                                    }
1884:                                    AdminProjectData.addUserInGroup(
1885:                                            (User) outGrouplist
1886:                                                    .getSelectedValue(),
1887:                                            (Group) groupList
1888:                                                    .getSelectedValue());
1889:                                    if (AdminProjectData.getCurrentUser() != null
1890:                                            && AdminProjectData
1891:                                                    .getCurrentUser()
1892:                                                    .equals(
1893:                                                            outGrouplist
1894:                                                                    .getSelectedValue())) {
1895:                                        if (!memberListModel.contains(groupList
1896:                                                .getSelectedValue())) {
1897:                                            memberListModel
1898:                                                    .addElement(groupList
1899:                                                            .getSelectedValue());
1900:                                        }
1901:                                        notMemberListModel
1902:                                                .removeElement(groupList
1903:                                                        .getSelectedValue());
1904:                                    }
1905:                                    outGroupListModel
1906:                                            .removeElement(outGrouplist
1907:                                                    .getSelectedValue());
1908:                                    inGrouplist.setSelectedIndex(0);
1909:                                }
1910:                            }
1911:                        }
1912:                    }
1913:                });
1914:
1915:                JButton addAll = new JButton("<<");
1916:                addAll.setToolTipText(Language.getInstance().getText(
1917:                        "Ajouter_tous_les_utilisateurs"));
1918:                addAll.addActionListener(new ActionListener() {
1919:                    public void actionPerformed(ActionEvent e) {
1920:                        if (groupList.getSelectedValue() != null) {
1921:                            for (int i = 0; i < outGroupListModel.size(); i++) {
1922:                                User user = (User) outGroupListModel.get(i);
1923:                                if (ConnectionData.isConnected()) {
1924:                                    try {
1925:                                        int transNumber = Api
1926:                                                .beginTransaction(Api.INSERT_USER_INTO_GROUP);
1927:                                        ConnectionData
1928:                                                .getAdminProjectInsert()
1929:                                                .addUserToGroup(
1930:                                                        user.getLogin(),
1931:                                                        ((Group) groupList
1932:                                                                .getSelectedValue())
1933:                                                                .getName(),
1934:                                                        ((Group) groupList
1935:                                                                .getSelectedValue())
1936:                                                                .getDescription());
1937:                                        Api.commitTrans(transNumber);
1938:                                    } catch (Exception exception) {
1939:                                        Tools.ihmExceptionView(exception
1940:                                                .toString());
1941:                                    }
1942:                                }
1943:                                if (Api.getException() == null
1944:                                        || Api.getException().size() == 0) {
1945:                                    AdminProjectData.addUserInGroup(user,
1946:                                            (Group) groupList
1947:                                                    .getSelectedValue());
1948:                                    inGroupListModel.addElement(user);
1949:                                    if (AdminProjectData.getCurrentUser() != null
1950:                                            && AdminProjectData
1951:                                                    .getCurrentUser().equals(
1952:                                                            user)) {
1953:                                        if (!memberListModel.contains(groupList
1954:                                                .getSelectedValue())) {
1955:                                            memberListModel
1956:                                                    .addElement(groupList
1957:                                                            .getSelectedValue());
1958:                                        }
1959:                                        notMemberListModel
1960:                                                .removeElement(groupList
1961:                                                        .getSelectedValue());
1962:                                    }
1963:                                }
1964:                            }
1965:                            outGroupListModel.clear();
1966:                            inGrouplist.setSelectedIndex(0);
1967:                        }
1968:                    }
1969:                });
1970:
1971:                JButton removeOne = new JButton(">");
1972:                removeOne.setToolTipText(Language.getInstance().getText(
1973:                        "Retirer_un_utilisateur"));
1974:                removeOne.addActionListener(new ActionListener() {
1975:                    public void actionPerformed(ActionEvent e) {
1976:                        if (groupList.getSelectedValue() != null) {
1977:                            if (inGrouplist.getSelectedValue() == null) {
1978:                                JOptionPane
1979:                                        .showMessageDialog(
1980:                                                AdministrationProject.this ,
1981:                                                Language
1982:                                                        .getInstance()
1983:                                                        .getText(
1984:                                                                "Vous_devez_sélectionner_un_utilisateur_avant_de_procéder_à_cette_opération!"),
1985:                                                Language.getInstance().getText(
1986:                                                        "Erreur_!"),
1987:                                                JOptionPane.ERROR_MESSAGE);
1988:                            } else {
1989:                                if (((Group) groupList.getSelectedValue())
1990:                                        .getName().equals(ADMINNAME)
1991:                                        && AdminProjectData.getGroupUsers(
1992:                                                (Group) groupList
1993:                                                        .getSelectedValue())
1994:                                                .size() == 1) {
1995:                                    JOptionPane
1996:                                            .showMessageDialog(
1997:                                                    AdministrationProject.this ,
1998:                                                    Language
1999:                                                            .getInstance()
2000:                                                            .getText(
2001:                                                                    "Impossible_!\nUn_projet_doit_avoir_au_moins_un_administrateur"),
2002:                                                    Language
2003:                                                            .getInstance()
2004:                                                            .getText("Erreur_!"),
2005:                                                    JOptionPane.ERROR_MESSAGE);
2006:                                } else {
2007:                                    if (ConnectionData.isConnected()) {
2008:                                        try {
2009:                                            int transNumber = Api
2010:                                                    .beginTransaction(Api.DELETE_USER_FROM_GROUP);
2011:                                            ConnectionData
2012:                                                    .getAdminProjectDelete()
2013:                                                    .deleteUserFromGroup(
2014:                                                            ((User) inGrouplist
2015:                                                                    .getSelectedValue())
2016:                                                                    .getLogin(),
2017:                                                            ((Group) groupList
2018:                                                                    .getSelectedValue())
2019:                                                                    .getName());
2020:                                            Api.commitTrans(transNumber);
2021:                                        } catch (Exception exception) {
2022:                                            Tools.ihmExceptionView(exception
2023:                                                    .toString());
2024:                                        }
2025:                                    }
2026:                                    if (Api.getException() == null
2027:                                            || Api.getException().size() == 0) {
2028:                                        AdminProjectData.removeUserFromGroup(
2029:                                                (User) inGrouplist
2030:                                                        .getSelectedValue(),
2031:                                                (Group) groupList
2032:                                                        .getSelectedValue());
2033:                                        if (AdminProjectData.getCurrentUser() != null
2034:                                                && AdminProjectData
2035:                                                        .getCurrentUser()
2036:                                                        .equals(
2037:                                                                inGrouplist
2038:                                                                        .getSelectedValue())) {
2039:                                            memberListModel
2040:                                                    .removeElement(groupList
2041:                                                            .getSelectedValue());
2042:                                            if (!notMemberListModel
2043:                                                    .contains(groupList
2044:                                                            .getSelectedValue())) {
2045:                                                notMemberListModel
2046:                                                        .addElement(groupList
2047:                                                                .getSelectedValue());
2048:                                            }
2049:                                        }
2050:                                        if (!outGroupListModel
2051:                                                .contains(inGrouplist
2052:                                                        .getSelectedValue())) {
2053:                                            outGroupListModel
2054:                                                    .addElement(inGrouplist
2055:                                                            .getSelectedValue());
2056:                                        }
2057:                                        inGroupListModel
2058:                                                .removeElement(inGrouplist
2059:                                                        .getSelectedValue());
2060:                                    }
2061:                                }
2062:                            }
2063:                        }
2064:                    }
2065:                });
2066:
2067:                JButton removeAll = new JButton(">>");
2068:                removeAll.setToolTipText(Language.getInstance().getText(
2069:                        "Retirer_tous_les_utilisateurs"));
2070:                removeAll.addActionListener(new ActionListener() {
2071:                    public void actionPerformed(ActionEvent e) {
2072:                        if (((Group) groupList.getSelectedValue()).getName()
2073:                                .equals(ADMINNAME)) {
2074:                            JOptionPane
2075:                                    .showMessageDialog(
2076:                                            AdministrationProject.this ,
2077:                                            Language
2078:                                                    .getInstance()
2079:                                                    .getText(
2080:                                                            "Impossible_!\nUn_projet_doit_avoir_au_moins_un_administrateur"),
2081:                                            Language.getInstance().getText(
2082:                                                    "Erreur_!"),
2083:                                            JOptionPane.ERROR_MESSAGE);
2084:                        } else {
2085:                            for (int i = 0; i < inGroupListModel.size(); i++) {
2086:                                User user = (User) inGroupListModel.get(i);
2087:                                if (ConnectionData.isConnected()) {
2088:                                    try {
2089:                                        int transNumber = Api
2090:                                                .beginTransaction(Api.DELETE_USER_FROM_GROUP);
2091:
2092:                                        ConnectionData
2093:                                                .getAdminProjectDelete()
2094:                                                .deleteUserFromGroup(
2095:                                                        user.getLogin(),
2096:                                                        ((Group) groupList
2097:                                                                .getSelectedValue())
2098:                                                                .getName());
2099:                                        Api.commitTrans(transNumber);
2100:                                    } catch (Exception exception) {
2101:                                        Tools.ihmExceptionView(exception
2102:                                                .toString());
2103:                                    }
2104:
2105:                                }
2106:                                if (Api.getException() == null
2107:                                        || Api.getException().size() == 0) {
2108:
2109:                                    AdminProjectData.removeUserFromGroup(user,
2110:                                            (Group) groupList
2111:                                                    .getSelectedValue());
2112:                                    if (AdminProjectData.getCurrentUser() != null
2113:                                            && AdminProjectData
2114:                                                    .getCurrentUser().equals(
2115:                                                            user)) {
2116:                                        memberListModel.removeElement(groupList
2117:                                                .getSelectedValue());
2118:                                        if (!notMemberListModel
2119:                                                .contains(groupList
2120:                                                        .getSelectedValue())) {
2121:                                            notMemberListModel
2122:                                                    .addElement(groupList
2123:                                                            .getSelectedValue());
2124:                                        }
2125:                                    }
2126:                                    if (!outGroupListModel.contains(user)) {
2127:                                        outGroupListModel.addElement(user);
2128:                                    }
2129:                                }
2130:                            }
2131:                            inGroupListModel.clear();
2132:                        }
2133:                    }
2134:                });
2135:
2136:                JPanel moveButtons = new JPanel();
2137:                moveButtons.setLayout(new BoxLayout(moveButtons,
2138:                        BoxLayout.Y_AXIS));
2139:                moveButtons.setAlignmentX(Component.CENTER_ALIGNMENT);
2140:                moveButtons.add(addOne);
2141:                moveButtons.add(addAll);
2142:                moveButtons.add(Box.createRigidArea(new Dimension(1, 25)));
2143:                moveButtons.add(removeOne);
2144:                moveButtons.add(removeAll);
2145:
2146:                // Panel utilisateur
2147:                JPanel usersPanel = new JPanel();
2148:                usersPanel
2149:                        .setLayout(new BoxLayout(usersPanel, BoxLayout.X_AXIS));
2150:                usersPanel.add(inGroupListScrollPane);
2151:                usersPanel.add(Box.createRigidArea(new Dimension(20, 50)));
2152:                usersPanel.add(moveButtons);
2153:                usersPanel.add(Box.createRigidArea(new Dimension(20, 50)));
2154:                usersPanel.add(outGroupListScrollPane);
2155:                usersPanel.setBorder(BorderFactory.createTitledBorder(
2156:                        BorderFactory.createLineBorder(Color.BLACK), Language
2157:                                .getInstance().getText("Utilisateurs")));
2158:
2159:                groupView.setLayout(new BoxLayout(groupView, BoxLayout.Y_AXIS));
2160:                groupView.add(allGroup);
2161:                groupView.add(Box.createRigidArea(new Dimension(1, 15)));
2162:                groupView.add(usersPanel);
2163:                groupView.setBorder(BorderFactory.createEmptyBorder(30, 10, 10,
2164:                        10));
2165:
2166:            } // Fin de la méthode createGroupsViewForOneProject/0
2167:
2168:            /**
2169:             * Méthode d'initialisation des données à la connection sur la base de
2170:             * données.
2171:             */
2172:            private void initDataVoiceTesting(String projectName,
2173:                    String adminLogin) {
2174:                if (ConnectionData.isConnected()) {
2175:                    // Nettoyage du modèle de données
2176:                    AdminProjectData.clear();
2177:
2178:                    AdminVT aVT = Api.getInstanceOfAdminVT();
2179:
2180:                    ConnectionData.setAdminVTSelect(aVT.getAdminVTSelect());
2181:
2182:                    // On crée une instance pour les méthodes de sélection
2183:                    AdminProject aProject = Api.getInstanceOfAdminProject();
2184:                    aProject.setUser(adminLogin);
2185:
2186:                    ConnectionData.setAdminProjectSelect(aProject
2187:                            .getAdminProjectSelect());
2188:                    ConnectionData.getAdminProjectSelect().setProject(
2189:                            projectName);
2190:
2191:                    //	On cree une instance de la classe pour les methodes d'insertion
2192:                    ConnectionData.setAdminProjectInsert(aProject
2193:                            .getAdminProjectInsert());
2194:                    ConnectionData.getAdminProjectInsert().setProject(
2195:                            projectName);
2196:
2197:                    ConnectionData.setAdminProjectDelete(aProject
2198:                            .getAdminProjectDelete());
2199:                    ConnectionData.getAdminProjectDelete().setProject(
2200:                            projectName);
2201:
2202:                    ConnectionData.setAdminProjectUpdate(aProject
2203:                            .getAdminProjectUpdate());
2204:                    ConnectionData.getAdminProjectUpdate().setProject(
2205:                            projectName);
2206:
2207:                    // init du projet courant
2208:                    Project project = new Project();
2209:                    project.setName(projectName);
2210:                    AdminProjectData.setCurrentProject(project);
2211:
2212:                    User admin = new User();
2213:                    admin.setLogin(adminLogin);
2214:                    admin.setFirstName(ConnectionData.getAdminVTSelect()
2215:                            .getUserFirstName(adminLogin));
2216:                    admin.setLastName(ConnectionData.getAdminVTSelect()
2217:                            .getUserName(adminLogin));
2218:                    admin.setDescription(ConnectionData.getAdminVTSelect()
2219:                            .getUserDescription(adminLogin));
2220:                    admin.setEmail(ConnectionData.getAdminVTSelect()
2221:                            .getUserEmail(adminLogin));
2222:                    admin.setPhoneNumber(ConnectionData.getAdminVTSelect()
2223:                            .getUserTel(adminLogin));
2224:                    project.setAdministrator(admin);
2225:
2226:                    // Initialisation des utilisateurs
2227:
2228:                    Vector logins = ConnectionData.getAdminProjectSelect()
2229:                            .getAllProjectUsersLogin();
2230:
2231:                    //	System.out.println("Logins :" + logins);
2232:                    Vector completedNames = ConnectionData
2233:                            .getAdminProjectSelect()
2234:                            .getAllProjectUsersCompleteName();
2235:                    usersTableModel.clearTable();
2236:                    usersTableModel.addDataColumn(logins, 0);
2237:                    usersTableModel.addDataColumn(completedNames, 1);
2238:
2239:                    for (int i = 0; i < logins.size(); i++) {
2240:                        User user = new User();
2241:                        user.setLogin((String) logins.get(i));
2242:                        user.setFirstName(ConnectionData.getAdminVTSelect()
2243:                                .getUserFirstName((String) logins.get(i)));
2244:                        user.setLastName(ConnectionData.getAdminVTSelect()
2245:                                .getUserName((String) logins.get(i)));
2246:                        user.setDescription(ConnectionData.getAdminVTSelect()
2247:                                .getUserDescription((String) logins.get(i)));
2248:                        user.setPhoneNumber(ConnectionData.getAdminVTSelect()
2249:                                .getUserTel((String) logins.get(i)));
2250:                        user.setEmail(ConnectionData.getAdminVTSelect()
2251:                                .getUserEmail((String) logins.get(i)));
2252:                        AdminProjectData.addUser(user);
2253:                    }
2254:
2255:                    Vector usersNotInProject = ConnectionData
2256:                            .getAdminProjectSelect().getOtherUsersForProject();
2257:                    for (int j = 0; j < usersNotInProject.size(); j++) {
2258:                        User user = new User();
2259:                        user.setLogin((String) usersNotInProject.get(j));
2260:                        user.setFirstName(ConnectionData.getAdminVTSelect()
2261:                                .getUserFirstName(
2262:                                        (String) usersNotInProject.get(j)));
2263:                        user
2264:                                .setLastName(ConnectionData.getAdminVTSelect()
2265:                                        .getUserName(
2266:                                                (String) usersNotInProject
2267:                                                        .get(j)));
2268:                        user.setDescription(ConnectionData.getAdminVTSelect()
2269:                                .getUserDescription(
2270:                                        (String) usersNotInProject.get(j)));
2271:                        user.setPhoneNumber(ConnectionData.getAdminVTSelect()
2272:                                .getUserTel((String) usersNotInProject.get(j)));
2273:                        user
2274:                                .setEmail(ConnectionData.getAdminVTSelect()
2275:                                        .getUserEmail(
2276:                                                (String) usersNotInProject
2277:                                                        .get(j)));
2278:                        AdminProjectData.addNotInProjectUser(user);
2279:                    }
2280:
2281:                    //Init des groupes du projet
2282:                    Vector groups = ConnectionData.getAdminProjectSelect()
2283:                            .getAllProjectGroupsName();
2284:
2285:                    groupListModel.clear();
2286:                    for (int i = 0; i < groups.size(); i++) {
2287:                        Group group = new Group();
2288:                        group.setName((String) groups.get(i));
2289:                        group.setDescription(ConnectionData
2290:                                .getAdminProjectSelect().getGroupDescription(
2291:                                        group.getName()));
2292:                        groupListModel.add(i, group);
2293:                        Vector usersOfGroup = ConnectionData
2294:                                .getAdminProjectSelect().getGroupUsers(
2295:                                        (String) groups.get(i));
2296:
2297:                        for (Iterator iter = usersOfGroup.iterator(); iter
2298:                                .hasNext();) {
2299:                            String userLogin = (String) iter.next();
2300:                            AdminProjectData.addUserInGroup(AdminProjectData
2301:                                    .getUser(userLogin), group);
2302:                        }
2303:                        //TODO 				group.setDescription(adminProjectSelect.)
2304:                        int permissions = ConnectionData
2305:                                .getAdminProjectSelect().getPermissionOfGroups(
2306:                                        group.getName());
2307:                        group
2308:                                .changeTestPermission(
2309:                                        0,
2310:                                        ((permissions & AdminProject.ALLOW_CREATE_TEST) == AdminProject.ALLOW_CREATE_TEST));
2311:                        group
2312:                                .changeTestPermission(
2313:                                        1,
2314:                                        ((permissions & AdminProject.ALLOW_UPDATE_TEST) == AdminProject.ALLOW_UPDATE_TEST));
2315:                        group
2316:                                .changeTestPermission(
2317:                                        2,
2318:                                        ((permissions & AdminProject.ALLOW_DELETE_TEST) == AdminProject.ALLOW_DELETE_TEST));
2319:                        group
2320:                                .changeCampaignPermission(
2321:                                        0,
2322:                                        ((permissions & AdminProject.ALLOW_CREATE_CAMP) == AdminProject.ALLOW_CREATE_CAMP));
2323:                        group
2324:                                .changeCampaignPermission(
2325:                                        1,
2326:                                        ((permissions & AdminProject.ALLOW_UPDATE_CAMP) == AdminProject.ALLOW_UPDATE_CAMP));
2327:                        group
2328:                                .changeCampaignPermission(
2329:                                        2,
2330:                                        ((permissions & AdminProject.ALLOW_DELETE_CAMP) == AdminProject.ALLOW_DELETE_CAMP));
2331:                        group
2332:                                .changeCampaignPermission(
2333:                                        3,
2334:                                        ((permissions & AdminProject.ALLOW_EXECUT_CAMP) == AdminProject.ALLOW_EXECUT_CAMP));
2335:                        AdminProjectData.getCurrentProject().addGroup(group);
2336:                    }
2337:                }
2338:
2339:            } // Fin de la méthode initDataVoiceTesting/0
2340:
2341:            public void update(Observable observable, Object obj) {
2342:                if (obj instanceof  Vector) {
2343:                    if (((Vector) obj).size() > 0)
2344:                        DataModel.apiExceptionView((Vector) obj);
2345:                }
2346:            }
2347:
2348:            public void destroy() {
2349:                Api.log("[AdministrationProjet] Destroy");
2350:                Api.isAlreadyConnected = false;
2351:                if (ConnectionData.isConnected() && !dbClosed) {
2352:                    Api.closeConnection();
2353:                    dbClosed = true;
2354:                }
2355:            }
2356:
2357:            public void quit(boolean do_recup) {
2358:                URL recup;
2359:                try {
2360:                    if (ConnectionData.isConnected()) {
2361:                        for (Iterator iter = AdminProjectData.getUsers()
2362:                                .iterator(); iter.hasNext();) {
2363:                            User user = (User) iter.next();
2364:                            if (AdminProjectData.getUserGroups(user) == null
2365:                                    || AdminProjectData.getUserGroups(user)
2366:                                            .size() == 0) {
2367:                                ConnectionData.getAdminProjectInsert()
2368:                                        .addUserToGroup(user.getLogin(),
2369:                                                GUESTNAME,
2370:                                                user.getDescription());
2371:                            }
2372:                        }
2373:                        if (!problemURL) {
2374:                            String[] tab = getDocumentBase().toString().split(
2375:                                    "[?=]");
2376:                            int idConn = Integer.parseInt(tab[2]);
2377:                            Api.deleteConnection(idConn);
2378:                        }
2379:                        Api.closeConnection();
2380:                        dbClosed = true;
2381:                    }
2382:                    /* récupère l'URL à partir du document courant et "page.html" */
2383:                    if (do_recup) {
2384:                        recup = new URL(getDocumentBase(), "index.html");
2385:                        /* Affiche le document après avoir recupérer le contexte courant */
2386:                        getAppletContext().showDocument(recup);
2387:                        repaint();
2388:                    } else {
2389:                        getAppletContext()
2390:                                .showDocument(
2391:                                        new URL(
2392:                                                "http://wiki.objectweb.org/salome-tmf"));
2393:                    }
2394:                } catch (MalformedURLException me) {
2395:                    me.printStackTrace();
2396:                }
2397:            }
2398:
2399:        } // Fin de la classe AdminProject
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.