Source Code Cross Referenced for AdministrationProject.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » admin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » org.objectweb.salome_tmf.ihm.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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