Source Code Cross Referenced for Administration.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:        package org.objectweb.salome_tmf.ihm.admin;
0002:
0003:        import java.applet.Applet;
0004:        import java.awt.BorderLayout;
0005:        import java.awt.Color;
0006:        import java.awt.Container;
0007:        import java.awt.Dimension;
0008:        import java.awt.FlowLayout;
0009:        import java.awt.Font;
0010:        import java.awt.Frame;
0011:        import java.awt.GridLayout;
0012:        import java.awt.event.ActionEvent;
0013:        import java.awt.event.ActionListener;
0014:        import java.awt.event.WindowEvent;
0015:        import java.awt.event.WindowListener;
0016:        import java.lang.reflect.Method;
0017:        import java.net.MalformedURLException;
0018:        import java.net.URL;
0019:        import java.util.ArrayList;
0020:        import java.util.Enumeration;
0021:        import java.util.HashMap;
0022:        import java.util.Hashtable;
0023:        import java.util.Iterator;
0024:        import java.util.Locale;
0025:        import java.util.Map;
0026:        import java.util.Vector;
0027:
0028:        import javax.swing.BorderFactory;
0029:        import javax.swing.Box;
0030:        import javax.swing.BoxLayout;
0031:        import javax.swing.ButtonGroup;
0032:        import javax.swing.JApplet;
0033:        import javax.swing.JButton;
0034:        import javax.swing.JLabel;
0035:        import javax.swing.JOptionPane;
0036:        import javax.swing.JPanel;
0037:        import javax.swing.JPasswordField;
0038:        import javax.swing.JRadioButton;
0039:        import javax.swing.JScrollPane;
0040:        import javax.swing.JTabbedPane;
0041:        import javax.swing.JTable;
0042:        import javax.swing.ListSelectionModel;
0043:        import javax.swing.LookAndFeel;
0044:        import javax.swing.UIManager;
0045:        import javax.swing.event.ListSelectionEvent;
0046:        import javax.swing.event.ListSelectionListener;
0047:
0048:        import org.java.plugin.Extension;
0049:        import org.java.plugin.ExtensionPoint;
0050:        import org.java.plugin.PluginManager;
0051:        import org.objectweb.salome_tmf.api.Api;
0052:        import org.objectweb.salome_tmf.api.ApiConstants;
0053:        import org.objectweb.salome_tmf.api.JavaScriptUtils;
0054:        import org.objectweb.salome_tmf.api.MD5paswd;
0055:        import org.objectweb.salome_tmf.api.Util;
0056:        import org.objectweb.salome_tmf.data.AdminVTData;
0057:        import org.objectweb.salome_tmf.data.Project;
0058:        import org.objectweb.salome_tmf.data.User;
0059:        import org.objectweb.salome_tmf.ihm.IHMConstants;
0060:        import org.objectweb.salome_tmf.ihm.languages.Language;
0061:        import org.objectweb.salome_tmf.ihm.main.AdminLogin;
0062:        import org.objectweb.salome_tmf.ihm.models.MyTableModel;
0063:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0064:        import org.objectweb.salome_tmf.plugins.IPlugObject;
0065:        import org.objectweb.salome_tmf.plugins.JPFManager;
0066:        import org.objectweb.salome_tmf.plugins.UICompCst;
0067:        import org.objectweb.salome_tmf.plugins.core.Admin;
0068:        import org.objectweb.salome_tmf.plugins.core.Common;
0069:
0070:        public class Administration extends JApplet implements  IPlugObject,
0071:                ApiConstants, IHMConstants, ActionListener, WindowListener {
0072:
0073:            boolean problemURL = false;
0074:
0075:            JPasswordField oldPassword;
0076:            JPasswordField newPasswordFirst;
0077:            JPasswordField newPasswordSecond;
0078:
0079:            /**
0080:             * Les onglets d'administration
0081:             */
0082:            JTabbedPane tabs;
0083:
0084:            /**
0085:             * Le panel de la fenêtre dans son ensemble
0086:             */
0087:            JPanel adminVoiceTesting;
0088:
0089:            /**
0090:             * Vue pour changer les mots de passe
0091:             */
0092:            JPanel changePwdView;
0093:
0094:            /**
0095:             * Vue pour la gestion des projets
0096:             */
0097:            JPanel projectView;
0098:
0099:            /**
0100:             * Vue pour la gestion des utilisateurs
0101:             */
0102:            JPanel usersView;
0103:
0104:            /**
0105:             * Vue de droite de la fenêtre
0106:             */
0107:            JPanel adminView;
0108:
0109:            /**
0110:             * Vue de droite de la fenêtre pour le controle des sessions
0111:             */
0112:            AdminSessionPanel sessionView;
0113:            /**
0114:             * Modèle de données de la table des projets
0115:             */
0116:            MyTableModel projectTableModel;
0117:
0118:            /**
0119:             * Table des projets
0120:             */
0121:            JTable projectTable;
0122:
0123:            /**
0124:             * Modèle de données de la table des utilisateurs
0125:             */
0126:            MyTableModel usersTableModel;
0127:
0128:            /**
0129:             * Table des utilisateurs
0130:             */
0131:            JTable userTable;
0132:
0133:            /**
0134:             * Bouton pour supprimer un projet
0135:             */
0136:            JButton deleteProjectButton;
0137:
0138:            /**
0139:             * Bouton pour la suppression d'un utilisateur
0140:             */
0141:            JButton deleteUserButton;
0142:
0143:            /**
0144:             * Bouton pour le changement de mot de passe d'un utilisateur
0145:             */
0146:
0147:            Color normalColor;
0148:
0149:            Color freezeColor;
0150:
0151:            Color localColor;
0152:
0153:            JButton modifyProjectButton;
0154:            JButton createProjectButton;
0155:            JButton freezeButton;
0156:            JButton createUserButton;
0157:            JButton changeUserPwdButton;
0158:            JButton modifyUserButton;
0159:            JButton validateButton;
0160:            JButton cancelButton;
0161:            /**
0162:             * Mapping between UI components and constants defined in org.objectweb.salome_tmf.ihm.UICompCst
0163:             */
0164:            static Map UIComponentsMap;
0165:
0166:            public static Frame ptrFrame;
0167:
0168:            public static Hashtable associatedTestDriver;
0169:            public static Hashtable associatedScriptEngine;
0170:            public static Hashtable associatedExtension;
0171:            public static Vector bugTrackers;
0172:            public static Vector reqManagers;
0173:            public Vector xmlPrinters = new Vector();
0174:            public static JPFManager jpf;
0175:
0176:            public static URL urlAdmin = null;
0177:
0178:            URL recup;
0179:
0180:            /* dbClosed = true if connection to database is close normaly (no reload or back from browser) */
0181:            boolean closeDB = true;
0182:            /* reload = true if applet is start again from same JVM (reload or back from browser) */
0183:            //static boolean reload = false;
0184:            String adminSalome = null;
0185:            int idConn = -1;
0186:
0187:            static public AdminVTData pAdminVTData;
0188:            boolean standAlone = false;
0189:            static boolean exit = false;
0190:            /******************************************************************************/
0191:            /** 							METHODES PUBLIQUES							***/
0192:            /******************************************************************************/
0193:            JavaScriptUtils pJSUtils;
0194:
0195:            void onInit() {
0196:                standAlone = false;
0197:                if (connectToAPI()) {
0198:                    closeDB = true;
0199:                    initComponent();
0200:                    loadModel();
0201:                }
0202:                exit = false;
0203:            }
0204:
0205:            void onStart() {
0206:
0207:            }
0208:
0209:            void initComponent() {
0210:                System.runFinalization();
0211:                System.gc();
0212:
0213:                javax.swing.JOptionPane.getFrameForComponent(
0214:                        Administration.this ).addWindowListener(this );
0215:
0216:                Api.setUrlBase(getDocumentBase());
0217:                urlAdmin = getDocumentBase();
0218:
0219:                Language.getInstance().setLocale(
0220:                        new Locale(Api.getUsedLocale()));
0221:                ptrFrame = javax.swing.JOptionPane
0222:                        .getFrameForComponent(Administration.this );
0223:                try {
0224:                    Class lnfClass = Class.forName(UIManager
0225:                            .getSystemLookAndFeelClassName());
0226:                    LookAndFeel newLAF = (LookAndFeel) (lnfClass.newInstance());
0227:                    UIManager.setLookAndFeel(newLAF);
0228:                    Util.adaptFont();
0229:                } catch (Exception exc) {
0230:                    System.err.println("Error loading L&F: " + exc);
0231:                }
0232:
0233:                oldPassword = new JPasswordField(20);
0234:
0235:                newPasswordFirst = new JPasswordField(20);
0236:
0237:                newPasswordSecond = new JPasswordField(20);
0238:
0239:                tabs = new JTabbedPane();
0240:
0241:                adminVoiceTesting = new JPanel(new BorderLayout());
0242:
0243:                changePwdView = new JPanel(new BorderLayout());
0244:
0245:                projectView = new JPanel(new BorderLayout());
0246:
0247:                usersView = new JPanel(new BorderLayout());
0248:
0249:                sessionView = new AdminSessionPanel();
0250:
0251:                adminView = new JPanel(new BorderLayout());
0252:
0253:                projectTableModel = new MyTableModel();
0254:
0255:                usersTableModel = new MyTableModel();
0256:
0257:                userTable = new JTable();
0258:
0259:                associatedTestDriver = new Hashtable();
0260:                associatedScriptEngine = new Hashtable();
0261:                associatedExtension = new Hashtable();
0262:                bugTrackers = new Vector();
0263:                reqManagers = new Vector();
0264:
0265:                deleteProjectButton = new JButton(Language.getInstance()
0266:                        .getText("Supprimer"));
0267:
0268:                deleteUserButton = new JButton(Language.getInstance().getText(
0269:                        "Supprimer"));
0270:
0271:                changeUserPwdButton = new JButton(Language.getInstance()
0272:                        .getText("Changer_le_mot_de_passe"));
0273:
0274:                normalColor = new Color(204, 255, 204);
0275:                freezeColor = new Color(204, 204, 255);
0276:                localColor = Color.RED;
0277:
0278:                // Mapping between UI components and constants
0279:                UIComponentsMap = new HashMap();
0280:
0281:                // Onglets
0282:                tabs.addTab(Language.getInstance().getText(
0283:                        "Administration_SalomeTMF"), adminVoiceTesting);
0284:                tabs.setPreferredSize(new Dimension(500, 500));
0285:
0286:                //Create the radio buttons.
0287:                JRadioButton changePwdButton = new JRadioButton(Language
0288:                        .getInstance().getText("Changer_le_mot_de_passe"));
0289:                changePwdButton.addActionListener(new ActionListener() {
0290:                    public void actionPerformed(ActionEvent e) {
0291:                        adminView.removeAll();
0292:                        adminView.add(changePwdView, BorderLayout.CENTER);
0293:                        adminView.validate();
0294:                        adminView.repaint();
0295:                    }
0296:                });
0297:
0298:                JRadioButton projectButton = new JRadioButton(Language
0299:                        .getInstance().getText("Gérer_les_projets"));
0300:                projectButton.addActionListener(new ActionListener() {
0301:                    public void actionPerformed(ActionEvent e) {
0302:                        adminView.removeAll();
0303:                        adminView.add(projectView, BorderLayout.CENTER);
0304:                        adminView.validate();
0305:                        adminView.repaint();
0306:                    }
0307:                });
0308:
0309:                JRadioButton usersButton = new JRadioButton(Language
0310:                        .getInstance().getText("Gérer_les_utilisateurs"));
0311:                usersButton.addActionListener(new ActionListener() {
0312:                    public void actionPerformed(ActionEvent e) {
0313:                        adminView.removeAll();
0314:                        adminView.add(usersView, BorderLayout.CENTER);
0315:                        adminView.validate();
0316:                        adminView.repaint();
0317:                    }
0318:                });
0319:                //***************** Panel de controle des sessions *********************//
0320:                JRadioButton sessionButton = new JRadioButton(Language
0321:                        .getInstance().getText("Gerer_les_sessions"));
0322:                sessionButton.addActionListener(new ActionListener() {
0323:                    public void actionPerformed(ActionEvent e) {
0324:                        adminView.removeAll();
0325:                        adminView.add(sessionView, BorderLayout.CENTER);
0326:                        adminView.validate();
0327:                        adminView.repaint();
0328:                    }
0329:                });
0330:
0331:                //////////////////////////////////////////////////////////////////////////
0332:                //On groupe les radiobuttons
0333:                ButtonGroup adminButtonGroup = new ButtonGroup();
0334:                adminButtonGroup.add(changePwdButton);
0335:                adminButtonGroup.add(projectButton);
0336:                adminButtonGroup.add(usersButton);
0337:                adminButtonGroup.add(sessionButton);
0338:
0339:                JPanel radioPanel = new JPanel(new GridLayout(0, 1));
0340:                radioPanel.add(Box.createRigidArea(new Dimension(1, 40)));
0341:                radioPanel.add(changePwdButton);
0342:                radioPanel.add(Box.createRigidArea(new Dimension(1, 40)));
0343:                radioPanel.add(projectButton);
0344:                radioPanel.add(Box.createRigidArea(new Dimension(1, 40)));
0345:                radioPanel.add(usersButton);
0346:                radioPanel.add(Box.createRigidArea(new Dimension(1, 40)));
0347:                radioPanel.add(sessionButton);
0348:
0349:                JPanel testPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
0350:                testPanel.add(radioPanel);
0351:
0352:                JButton backButton = new JButton(Language.getInstance()
0353:                        .getText("Quitter"));
0354:                backButton.addActionListener(new ActionListener() {
0355:                    public void actionPerformed(ActionEvent e) {
0356:                        quit(true, true);
0357:                    }
0358:                });
0359:
0360:                JPanel radioPanelAll = new JPanel(new BorderLayout());
0361:                radioPanelAll.add(testPanel);
0362:                radioPanelAll.add(backButton, BorderLayout.SOUTH);
0363:                radioPanelAll
0364:                        .setBorder(BorderFactory.createRaisedBevelBorder());
0365:
0366:                //AdminProjectData.initData();
0367:                //AdminVTData.initData();
0368:                createChangePwdView();
0369:                createUsersView();
0370:                createProjectView();
0371:                adminView.removeAll();
0372:
0373:                // On remplit le panel adminVoiceTesting
0374:                adminVoiceTesting.add(BorderLayout.WEST, radioPanelAll);
0375:                adminVoiceTesting.add(BorderLayout.CENTER, adminView);
0376:
0377:                Container cp = this .getContentPane();
0378:                cp.add(tabs);
0379:            }
0380:
0381:            boolean connectToAPI() {
0382:                Util.log("[Administration->connectToAPI] open connection");
0383:                pJSUtils = new JavaScriptUtils(this );
0384:                if (Api.getNbConnect() > 0) {
0385:                    JOptionPane
0386:                            .showMessageDialog(
0387:                                    Administration.this ,
0388:                                    Language
0389:                                            .getInstance()
0390:                                            .getText(
0391:                                                    "Vous_avez_déjà_une_session_Salomé_ouverte_avec_ce_navigateur.\n")
0392:                                            + Language
0393:                                                    .getInstance()
0394:                                                    .getText(
0395:                                                            "Une_seule_session_est_autorisée_par_navigateur_afin_d'éviter_les_conflits_!"),
0396:                                    Language.getInstance().getText("Erreur_!"),
0397:                                    JOptionPane.ERROR_MESSAGE);
0398:                    quit(false, false);
0399:                    closeDB = false;
0400:                    return false;
0401:                } else {
0402:                    Api.openConnection(getDocumentBase());
0403:
0404:                    if (!Api.isConnected()) {
0405:                        JOptionPane.showMessageDialog(Administration.this ,
0406:                                "Can't connect to the database", Language
0407:                                        .getInstance().getText("Erreur_!"),
0408:                                JOptionPane.ERROR_MESSAGE);
0409:                        closeDB = false;
0410:                        quit(true, false);
0411:                        return false;
0412:                    }
0413:
0414:                    String[] params = new String[2];
0415:                    ;
0416:                    /* if (!Api.isIDE_DEV()) {
0417:                    	 params = Tools.chooseProjectAndUser(getDocumentBase());
0418:                    	 Util.log("[Administration.start()] conn. with project = " + params[0]);
0419:                    	 Util.log("[Administration.start()] conn. with user = " + params[1]);
0420:                     } else {
0421:                    	params = new String[2];
0422:                    	 params[0] = "ALL";
0423:                    	 params[1] = ADMIN_SALOME_NAME;
0424:                    	 
0425:                     }*/
0426:                    params[1] = pJSUtils.getLoginCookies();
0427:                    params[0] = pJSUtils.getProjectCookies();
0428:                    if ((params[0] == null) || (params[0].equals(""))) {
0429:                        AdminLogin dialog = new AdminLogin();
0430:                        dialog.setVisible(true);
0431:                        if (dialog.isLoged()) {
0432:                            params[0] = "ALL";
0433:                            params[1] = ADMIN_SALOME_NAME;
0434:                            standAlone = true;
0435:
0436:                            // Récupération du login et du mot de passe pour l'authentification
0437:                            try {
0438:                                Api.setStrUsername(ADMIN_SALOME_NAME);
0439:                                Api.setStrMD5Password(MD5paswd
0440:                                        .getEncodedPassword(dialog
0441:                                                .getSelectedPassword()));
0442:                            } catch (Exception e) {
0443:                                e.printStackTrace();
0444:                            }
0445:                        }
0446:                    }
0447:                    adminSalome = params[1];
0448:                    Api.initConnectionUser(params[0], params[1]);
0449:                    /*try {
0450:                     String[] tab = getDocumentBase().toString().split("[?=]");
0451:                     idConn = Integer.parseInt(tab[2]);
0452:                    } catch(Exception e){
0453:                     Util.log("[Administration->connectToAPI] WARNING idConn can't be found");
0454:                    }
0455:                    if ((params[0] == null)||(params[0].equals("")) || (!params[0].equals("ALL"))) {
0456:                     JOptionPane.showMessageDialog(Administration.this,
0457:                    		 Language.getInstance().getText("Probleme_dans_l'URL_saisie_!"),
0458:                    		 Language.getInstance().getText("Erreur_!"),
0459:                    		 JOptionPane.ERROR_MESSAGE);
0460:                    
0461:                     problemURL = true;	 
0462:                     closeDB = true;
0463:                     quit(true, true);
0464:                     return false;
0465:                    }*/
0466:                    return true;
0467:                }
0468:            }
0469:
0470:            void loadModel() {
0471:                loadSalomeData();
0472:                if (Api.isALLOW_PLUGINS()) {
0473:                    jpf = new JPFManager();
0474:                    jpf.startJPFInAdmin(this .getDocumentBase(),
0475:                            UIComponentsMap, this );
0476:                }
0477:
0478:            }
0479:
0480:            /**
0481:             * Méthode d'initialisation de l'applet
0482:             */
0483:            public void init() {
0484:                onInit();
0485:            }
0486:
0487:            /**
0488:             * Méthode appelée à chaque chargement de la page
0489:             */
0490:
0491:            public void start() {
0492:                onStart();
0493:            }
0494:
0495:            /**
0496:             * Méthode qui créer l'écran permettant de changer le mot de passe.
0497:             */
0498:            public void createChangePwdView() {
0499:                adminView.removeAll();
0500:
0501:                validateButton = new JButton(Language.getInstance().getText(
0502:                        "Valider"));
0503:                validateButton.setToolTipText(Language.getInstance().getText(
0504:                        "Valider"));
0505:                validateButton.addActionListener(this );
0506:
0507:                cancelButton = new JButton(Language.getInstance().getText(
0508:                        "Annuler"));
0509:                cancelButton.setToolTipText(Language.getInstance().getText(
0510:                        "Annuler"));
0511:                cancelButton.addActionListener(this );
0512:
0513:                JLabel oldQuestion = new JLabel(Language.getInstance().getText(
0514:                        "Entrez_votre_ancien_mot_de_passe_:"));
0515:                JLabel question = new JLabel(Language.getInstance().getText(
0516:                        "Entrez_votre_nouveau_mot_de_passe_:"));
0517:                JLabel confirmation = new JLabel(Language.getInstance()
0518:                        .getText("Confirmer_le_nouveau_mot_de_passe_:"));
0519:
0520:                JPanel textFieldPane = new JPanel();
0521:                textFieldPane.setLayout(new BoxLayout(textFieldPane,
0522:                        BoxLayout.Y_AXIS));
0523:                textFieldPane.add(oldPassword);
0524:                textFieldPane.add(Box.createRigidArea(new Dimension(1, 50)));
0525:                textFieldPane.add(newPasswordFirst);
0526:                textFieldPane.add(Box.createRigidArea(new Dimension(1, 50)));
0527:                textFieldPane.add(newPasswordSecond);
0528:
0529:                JPanel textPane = new JPanel();
0530:                textPane.setLayout(new BoxLayout(textPane, BoxLayout.Y_AXIS));
0531:                textPane.add(oldQuestion);
0532:                textPane.add(Box.createRigidArea(new Dimension(1, 50)));
0533:                textPane.add(question);
0534:                textPane.add(Box.createRigidArea(new Dimension(1, 50)));
0535:                textPane.add(confirmation);
0536:
0537:                JPanel textPaneAll = new JPanel(new FlowLayout(
0538:                        FlowLayout.CENTER));
0539:                textPaneAll.add(textPane);
0540:                textPaneAll.add(textFieldPane);
0541:
0542:                JPanel buttonPanel = new JPanel(new FlowLayout(
0543:                        FlowLayout.CENTER));
0544:                buttonPanel.add(validateButton);
0545:                buttonPanel.add(cancelButton);
0546:
0547:                JPanel labelSet = new JPanel();
0548:                labelSet.add(textPaneAll);
0549:                labelSet.setBorder(BorderFactory.createEmptyBorder(100, 10, 10,
0550:                        100));
0551:
0552:                changePwdView.setLayout(new BoxLayout(changePwdView,
0553:                        BoxLayout.Y_AXIS));
0554:                changePwdView.add(labelSet);
0555:                changePwdView.add(buttonPanel);
0556:                changePwdView
0557:                        .setBorder(BorderFactory.createRaisedBevelBorder());
0558:                changePwdView.validate();
0559:            }
0560:
0561:            /**
0562:             * Méthode qui permet de créer l'écran permettant de gérer les projets.
0563:             *
0564:             */
0565:            public void createProjectView() {
0566:
0567:                adminView.removeAll();
0568:
0569:                // Les boutons
0570:                createProjectButton = new JButton(Language.getInstance()
0571:                        .getText("Créer"));
0572:                createProjectButton.setToolTipText(Language.getInstance()
0573:                        .getText("Créer_un_nouveau_projet"));
0574:                createProjectButton.addActionListener(this );
0575:
0576:                modifyProjectButton = new JButton(Language.getInstance()
0577:                        .getText("Modifier"));
0578:                modifyProjectButton.setEnabled(false);
0579:                modifyProjectButton.setToolTipText(Language.getInstance()
0580:                        .getText("Modifier_un_projet"));
0581:                modifyProjectButton.addActionListener(this );
0582:
0583:                freezeButton = new JButton(Language.getInstance().getText(
0584:                        "Geler"));
0585:                freezeButton.setEnabled(false);
0586:                freezeButton.setToolTipText(Language.getInstance().getText(
0587:                        "Geler_un_projet"));
0588:                freezeButton.addActionListener(new ActionListener() {
0589:                    public void actionPerformed(ActionEvent e) {
0590:                        int selectedRow = projectTable.getSelectedRow();
0591:                        if (selectedRow != -1) {
0592:                            /*Project project = pAdminVTData.getProjectFromModel((String)projectTableModel.getValueAt(selectedRow,1));
0593:                             if (project.getLock() == null) {
0594:                             ProjectTableCellRenderer.setColor(selectedRow, freezeColor);
0595:                             projectTableModel.setValueAt(Tools.createAppletImageIcon(PATH_TO_FREEZED_PROJECT_ICON,""), selectedRow, 0);
0596:                             project.setLock(new Lock());
0597:                             } else {
0598:                             ProjectTableCellRenderer.setColor(selectedRow, normalColor);
0599:                             projectTableModel.setValueAt(Tools.createAppletImageIcon(PATH_TO_PROJECT_ICON,""), selectedRow, 0);
0600:                             project.setLock(null);
0601:                             }*/
0602:
0603:                        }
0604:                    }
0605:                });
0606:
0607:                deleteProjectButton.setToolTipText(Language.getInstance()
0608:                        .getText("Supprimer_un_projet"));
0609:                deleteProjectButton.setEnabled(false);
0610:                deleteProjectButton.addActionListener(this );
0611:
0612:                JPanel buttonSet = new JPanel(new FlowLayout());
0613:                buttonSet.setAlignmentY(FlowLayout.LEFT);
0614:                buttonSet.add(createProjectButton);
0615:                buttonSet.add(modifyProjectButton);
0616:                buttonSet.add(freezeButton);
0617:                buttonSet.add(deleteProjectButton);
0618:                buttonSet.setBorder(BorderFactory.createRaisedBevelBorder());
0619:                // Mapping entre composants graphiques et constantes
0620:                UIComponentsMap.put(
0621:                        UICompCst.ADMIN_PROJECT_MANAGEMENT_BUTTONS_PANEL,
0622:                        buttonSet);
0623:
0624:                // La table des projets
0625:                JLabel projectsTableLabel = new JLabel(Language.getInstance()
0626:                        .getText("Liste_des_projets_existants_:_"));
0627:                projectsTableLabel.setFont(new Font(null, Font.BOLD, 20));
0628:                projectsTableLabel.setSize(300, 60);
0629:
0630:                projectTableModel.addColumnNameAndColumn("");
0631:                projectTableModel.addColumnNameAndColumn(Language.getInstance()
0632:                        .getText("Nom_du_projet"));
0633:                projectTableModel.addColumnNameAndColumn(Language.getInstance()
0634:                        .getText("Administrateur"));
0635:                projectTableModel.addColumnNameAndColumn(Language.getInstance()
0636:                        .getText("Date_de_création"));
0637:                projectTableModel.addColumnNameAndColumn(Language.getInstance()
0638:                        .getText("Description"));
0639:
0640:                projectTable = new JTable();
0641:                //projectTable.setDefaultRenderer(String.class, new ProjectTableCellRenderer());
0642:                projectTable.setModel(projectTableModel);
0643:                projectTable.setPreferredScrollableViewportSize(new Dimension(
0644:                        600, 200));
0645:                projectTable
0646:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0647:
0648:                // Mapping between UI components and constants
0649:                UIComponentsMap.put(UICompCst.ADMIN_PROJECT_MANAGEMENT_TABLE,
0650:                        projectTable);
0651:
0652:                projectTable.setModel(projectTableModel);
0653:
0654:                JScrollPane tablePane = new JScrollPane(projectTable);
0655:
0656:                ListSelectionModel rowSMForUserTable = projectTable
0657:                        .getSelectionModel();
0658:                rowSMForUserTable
0659:                        .addListSelectionListener(new ListSelectionListener() {
0660:                            public void valueChanged(ListSelectionEvent e) {
0661:                                int[] selectedRows = projectTable
0662:                                        .getSelectedRows();
0663:                                if (selectedRows.length > 0) {
0664:                                    if (selectedRows.length == 1) {
0665:                                        modifyProjectButton.setEnabled(true);
0666:                                    } else {
0667:                                        modifyProjectButton.setEnabled(false);
0668:                                    }
0669:                                    deleteProjectButton.setEnabled(true);
0670:                                    freezeButton.setEnabled(true);
0671:                                } else {
0672:                                    deleteProjectButton.setEnabled(false);
0673:                                    modifyProjectButton.setEnabled(false);
0674:                                    freezeButton.setEnabled(false);
0675:                                }
0676:                            }
0677:                        });
0678:
0679:                JPanel center = new JPanel(new BorderLayout());
0680:                center.add(BorderLayout.NORTH, projectsTableLabel);
0681:                center.add(BorderLayout.CENTER, tablePane);
0682:                center.setBorder(BorderFactory
0683:                        .createEmptyBorder(20, 10, 10, 10));
0684:
0685:                projectView.add(BorderLayout.NORTH, buttonSet);
0686:                projectView.add(BorderLayout.CENTER, center);
0687:
0688:            } // Fin de la classe createProjectView/0
0689:
0690:            /**
0691:             * Méthode qui permet de créer l'écran permettant de gérer les utilisateurs.
0692:             *
0693:             */
0694:            public void createUsersView() {
0695:
0696:                // Les boutons
0697:                createUserButton = new JButton(Language.getInstance().getText(
0698:                        "Créer"));
0699:                createUserButton.setToolTipText(Language.getInstance().getText(
0700:                        "Créer_un_nouvel_utilisateur"));
0701:                createUserButton.addActionListener(this );
0702:
0703:                modifyUserButton = new JButton(Language.getInstance().getText(
0704:                        "Modifier"));
0705:                modifyUserButton.setToolTipText(Language.getInstance().getText(
0706:                        "Modifier_un_utilisateur"));
0707:                modifyUserButton.setEnabled(false);
0708:                modifyUserButton.addActionListener(this );
0709:
0710:                deleteUserButton.setToolTipText(Language.getInstance().getText(
0711:                        "Supprimer_un_utilisateur"));
0712:                deleteUserButton.setEnabled(false);
0713:                deleteUserButton.addActionListener(this );
0714:
0715:                changeUserPwdButton.setToolTipText(Language.getInstance()
0716:                        .getText("Changer_le_mot_de_passe"));
0717:                changeUserPwdButton.setEnabled(false);
0718:                changeUserPwdButton.addActionListener(this );
0719:
0720:                JPanel buttonSet = new JPanel(new FlowLayout());
0721:                buttonSet.setAlignmentY(FlowLayout.LEFT);
0722:                buttonSet.add(createUserButton);
0723:                buttonSet.add(modifyUserButton);
0724:                buttonSet.add(deleteUserButton);
0725:                buttonSet.add(changeUserPwdButton);
0726:                buttonSet.setBorder(BorderFactory.createRaisedBevelBorder());
0727:
0728:                // La table des projets
0729:                JLabel projectsTableLabel = new JLabel(Language.getInstance()
0730:                        .getText("Liste_des_utilisateurs_:_"));
0731:                projectsTableLabel.setFont(new Font(null, Font.BOLD, 20));
0732:                projectsTableLabel.setSize(300, 60);
0733:
0734:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0735:                        .getText("Login"));
0736:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0737:                        .getText("Nom"));
0738:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0739:                        .getText("Prénom"));
0740:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0741:                        .getText("Email"));
0742:                usersTableModel.addColumnNameAndColumn(Language.getInstance()
0743:                        .getText("Téléphone"));
0744:
0745:                userTable.setModel(usersTableModel);
0746:
0747:                userTable.setPreferredScrollableViewportSize(new Dimension(500,
0748:                        200));
0749:                JScrollPane tablePane = new JScrollPane(userTable);
0750:                userTable
0751:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0752:
0753:                ListSelectionModel rowSMForUserTable = userTable
0754:                        .getSelectionModel();
0755:                rowSMForUserTable
0756:                        .addListSelectionListener(new ListSelectionListener() {
0757:                            public void valueChanged(ListSelectionEvent e) {
0758:                                int[] selectedRows = userTable
0759:                                        .getSelectedRows();
0760:                                if (selectedRows.length > 0) {
0761:                                    if (selectedRows.length == 1) {
0762:                                        changeUserPwdButton.setEnabled(true);
0763:                                        modifyUserButton.setEnabled(true);
0764:                                    } else {
0765:                                        changeUserPwdButton.setEnabled(false);
0766:                                        modifyUserButton.setEnabled(false);
0767:                                    }
0768:                                    deleteUserButton.setEnabled(true);
0769:                                } else {
0770:                                    deleteUserButton.setEnabled(false);
0771:                                    changeUserPwdButton.setEnabled(false);
0772:                                    modifyUserButton.setEnabled(false);
0773:                                }
0774:                            }
0775:                        });
0776:
0777:                JPanel center = new JPanel(new BorderLayout());
0778:                center.add(BorderLayout.NORTH, projectsTableLabel);
0779:                center.add(BorderLayout.CENTER, tablePane);
0780:                center.setBorder(BorderFactory
0781:                        .createEmptyBorder(20, 10, 10, 10));
0782:
0783:                usersView.add(BorderLayout.NORTH, buttonSet);
0784:                usersView.add(BorderLayout.CENTER, center);
0785:            } // Fin de la méthode createUsersView/0
0786:
0787:            /**
0788:             * Méthode d'initialisation des données à la connection sur la base de
0789:             * données.
0790:             */
0791:            private void loadSalomeData() {
0792:                try {
0793:                    //DB
0794:                    pAdminVTData = new AdminVTData();
0795:
0796:                    pAdminVTData.loadData();
0797:                    //pAdminVTData.setUserAdminVTData(ADMIN_SALOME_NAME);
0798:                    pAdminVTData.setUserAdminVTData(adminSalome);
0799:                    //IHM
0800:                    usersTableModel.clearTable();
0801:                    ArrayList allUser = pAdminVTData.getAllUsersFromModel();
0802:                    Vector logins = new Vector();
0803:                    Vector names = new Vector();
0804:                    Vector firstNames = new Vector();
0805:                    Vector phones = new Vector();
0806:                    Vector emails = new Vector();
0807:
0808:                    //Vector descriptions = new Vector();
0809:
0810:                    for (int i = 0; i < allUser.size(); i++) {
0811:                        User pUser = (User) allUser.get(i);
0812:                        logins.add(pUser.getLoginFromModel());
0813:                        names.add(pUser.getLastNameFromModel());
0814:                        firstNames.add(pUser.getFirstNameFromModel());
0815:                        phones.add(pUser.getPhoneNumberFromModel());
0816:                        emails.add(pUser.getEmailFromModel());
0817:                    }
0818:                    usersTableModel.addDataColumn(logins, 0);
0819:                    usersTableModel.addDataColumn(names, 1);
0820:                    usersTableModel.addDataColumn(firstNames, 2);
0821:                    usersTableModel.addDataColumn(emails, 3);
0822:                    usersTableModel.addDataColumn(phones, 4);
0823:
0824:                    projectTableModel.clearTable();
0825:                    ArrayList allProjects = pAdminVTData
0826:                            .getProjectListFromModel();
0827:
0828:                    Vector projectNames = new Vector();
0829:                    Vector projectDescs = new Vector();
0830:                    Vector projectDate = new Vector();
0831:                    Vector projectAdminLogins = new Vector();
0832:                    int nbProj = allProjects.size();
0833:                    for (int i = 0; i < nbProj; i++) {
0834:                        Project pProject = (Project) allProjects.get(i);
0835:                        projectNames.add(pProject.getNameFromModel());
0836:                        projectDescs.add(pProject.getDescriptionFromModel());
0837:                        projectDate.add(pProject.getCreationDateFromModel());
0838:                        projectAdminLogins.add(pProject
0839:                                .getAdministratorFromModel()
0840:                                .getLoginFromModel());
0841:
0842:                    }
0843:
0844:                    projectTableModel.addDataColumn(projectNames, 1);
0845:                    projectTableModel.addDataColumn(projectAdminLogins, 2);
0846:                    projectTableModel.addDataColumn(projectDate, 3);
0847:                    projectTableModel.addDataColumn(projectDescs, 4);
0848:
0849:                    for (int i = 0; i < nbProj; i++) {
0850:                        projectTableModel.addValueAt(
0851:                                Tools.createAppletImageIcon(
0852:                                        PATH_TO_PROJECT_ICON, ""), i, 0);
0853:                    }
0854:
0855:                    projectTable.getColumnModel().getColumn(0).setMaxWidth(18);
0856:                    sessionView.loadDataFromDB();
0857:                } catch (Exception e) {
0858:                    e.printStackTrace();
0859:                    //ConnectionData.setConnected(false);
0860:                    JOptionPane
0861:                            .showMessageDialog(
0862:                                    Administration.this ,
0863:                                    Language
0864:                                            .getInstance()
0865:                                            .getText(
0866:                                                    "Impossible_de_se_connecter_à_la_base_:_on_travaille_en_local_!"),
0867:                                    Language.getInstance().getText("Erreur_!"),
0868:                                    JOptionPane.ERROR_MESSAGE);
0869:                }
0870:
0871:            } // Fin de la méthode initDataVoiceTesting/0
0872:
0873:            /**
0874:             *
0875:             * @param project
0876:             * @return
0877:             */
0878:            public int getIndexOfProject(Project project) {
0879:                for (int i = 0; i < projectTableModel.getRowCount(); i++) {
0880:                    if (projectTableModel.getValueAt(i, 1).equals(
0881:                            project.getNameFromModel())) {
0882:                        return i;
0883:                    }
0884:                }
0885:                return -1;
0886:            }
0887:
0888:            /*public void update(Observable observable, Object obj) {
0889:            	if (obj instanceof Vector) {
0890:            		if (((Vector)obj).size() > 0) DataModel.apiExceptionView((Vector)obj);
0891:            	}
0892:            }*/
0893:
0894:            public void destroy() {
0895:                Util.log("[Administration] Destroy");
0896:                //Api.isAlreadyConnected=false;
0897:                if (closeDB) {
0898:                    Api.closeConnection();
0899:                }
0900:                Util.log("[Administration] End Destroy");
0901:            }
0902:
0903:            public void quit(boolean do_recup, boolean doclose) {
0904:                Util.log("[Administration] Quit");
0905:                if (Api.isConnected() && doclose) {
0906:                    if (!problemURL && !Api.isIDE_DEV() && idConn != -1) {
0907:                        Api.deleteConnection(idConn);
0908:                    }
0909:                    closeDB = false;
0910:                    Api.closeConnection();
0911:                }
0912:                Frame ptrFrame = javax.swing.JOptionPane
0913:                        .getFrameForComponent(Administration.this );
0914:                ptrFrame.dispose();
0915:                ptrFrame = null;
0916:                System.gc();
0917:                System.runFinalization();
0918:
0919:                try {
0920:                    if (!standAlone) {
0921:                        if (do_recup) {
0922:                            /* récupère l'URL à partir du document courant et "page.html" */
0923:                            recup = new URL(getDocumentBase(), "index.html");
0924:                            /* Affiche le document après avoir recupérer le contexte courant */
0925:                            getAppletContext().showDocument(recup);
0926:                            repaint();
0927:                        } else {
0928:                            getAppletContext()
0929:                                    .showDocument(
0930:                                            new URL(
0931:                                                    "http://wiki.objectweb.org/salome-tmf"));
0932:                        }
0933:                    } else {
0934:                        if (pJSUtils != null) {
0935:                            pJSUtils.closeWindow();
0936:                        }
0937:                    }
0938:                } catch (MalformedURLException me) {
0939:                    recup = null;
0940:                    me.printStackTrace();
0941:                }
0942:                exit = true;
0943:            }
0944:
0945:            /*void closeWindow(){
0946:            	try {
0947:            		//Class classJSObject = Class.forName("sun.plugin.javascript.JSObject");	
0948:            		Class classJSObject = Class.forName("netscape.javascript.JSObject");
0949:            		Method meth_getWindow = classJSObject.getMethod("getWindow", new Class[] {Applet.class});
0950:            		Object pJSObject = meth_getWindow.invoke(null ,new Object[] {this});
0951:            		System.out.println("pJSObject = " + pJSObject);
0952:            		Method meth_call  = classJSObject.getMethod("call", new Class[] {String.class, Object[].class});
0953:            		meth_call.invoke(pJSObject, new Object[] {"close", null});
0954:            		
0955:            	} catch (Exception e) {
0956:            		e.printStackTrace();
0957:            	}
0958:            }*/
0959:
0960:            /**
0961:             * Methode qui renvoie l'objet graphique associ? ? une constante
0962:             * @return
0963:             * @param uiConst
0964:             */
0965:            public static Object getUIComponent(Integer uiConst) {
0966:                Object comp = null;
0967:                if (UIComponentsMap != null)
0968:                    comp = UIComponentsMap.get(uiConst);
0969:                return comp;
0970:            }
0971:
0972:            /******************************** IPlugObject Implementation ********************/
0973:            public Object associatedExtension(Object key, Object value) {
0974:                //implementation by Hastable
0975:                return associatedExtension.put(key, value);
0976:            }
0977:
0978:            public Object associatedScriptEngine(Object key, Object value) {
0979:                //implementation by Hastable
0980:                return associatedScriptEngine.put(key, value);
0981:            }
0982:
0983:            public Object associatedTestDriver(Object key, Object value) {
0984:                //implementation by Hastable
0985:                return associatedTestDriver.put(key, value);
0986:            }
0987:
0988:            public Object getAssociatedExtension(Object key) {
0989:                return associatedExtension.get(key);
0990:            }
0991:
0992:            public Object getAssociatedScriptEngine(Object key) {
0993:                return associatedScriptEngine.get(key);
0994:            }
0995:
0996:            public Object get1ssociatedTestDriver(Object key) {
0997:                return associatedTestDriver.get(key);
0998:            }
0999:
1000:            public void initExtsionTestDriver(ExtensionPoint ext) {
1001:                if (!ext.getConnectedExtensions().isEmpty()) {
1002:                    for (Iterator it = ext.getConnectedExtensions().iterator(); it
1003:                            .hasNext();) {
1004:                        try {
1005:                            Extension testDriverExt = (Extension) it.next();
1006:                            String extList = testDriverExt.getParameter(
1007:                                    "extensions").valueAsString();
1008:                            associatedTestDriver(testDriverExt, extList);
1009:                            associatedExtension(testDriverExt.getId(),
1010:                                    testDriverExt);
1011:                            Util.log("Add testDriverExt : "
1012:                                    + testDriverExt.getId());
1013:                        } catch (Exception e) {
1014:                            // TODO
1015:                            e.printStackTrace();
1016:                        }
1017:                    }
1018:                }
1019:            }
1020:
1021:            public void initExtsionScriptEngine(
1022:                    ExtensionPoint pExtsionScriptEngine) {
1023:                if (!pExtsionScriptEngine.getConnectedExtensions().isEmpty()) {
1024:                    for (Iterator it = pExtsionScriptEngine
1025:                            .getConnectedExtensions().iterator(); it.hasNext();) {
1026:                        try {
1027:                            Extension scriptEngineExt = (Extension) it.next();
1028:                            String extList = scriptEngineExt.getParameter(
1029:                                    "extensions").valueAsString();
1030:                            associatedScriptEngine(scriptEngineExt, extList);
1031:                            associatedExtension(scriptEngineExt.getId(),
1032:                                    scriptEngineExt);
1033:                            Util.log("Add ExtsionScriptEngine : "
1034:                                    + scriptEngineExt.getId());
1035:                        } catch (Exception e) {
1036:                            // TODO
1037:                            e.printStackTrace();
1038:                        }
1039:                    }
1040:                }
1041:            }
1042:
1043:            public void showMessage(String msg) {
1044:                //initExtsionScriptEngine
1045:            }
1046:
1047:            public void init_Component(PluginManager pluginManager,
1048:                    ExtensionPoint commonE, ExtensionPoint testE,
1049:                    ExtensionPoint scriptE, ExtensionPoint bugTrackE,
1050:                    ExtensionPoint reqMgr) {
1051:
1052:            }
1053:
1054:            public void addPlgToUICompList(Integer id, Common plugin) {
1055:
1056:            }
1057:
1058:            public URL getUrlBase() {
1059:                return urlAdmin;
1060:            }
1061:
1062:            public JPFManager getPluginManager() {
1063:                return jpf;
1064:            }
1065:
1066:            public void addXMLPrinterExtension(Object xmlPrinter) {
1067:                if (!xmlPrinters.contains(xmlPrinter)) {
1068:                    xmlPrinters.add(xmlPrinter);
1069:                }
1070:            }
1071:
1072:            public Vector getXMLPrintersExtension() {
1073:                return xmlPrinters;
1074:            }
1075:
1076:            /******************************** ActionListener Implemntation ******************/
1077:
1078:            public void actionPerformed(ActionEvent e) {
1079:                if (e.getSource().equals(deleteProjectButton)) {
1080:                    deleteProjectPerformed();
1081:                } else if (e.getSource().equals(modifyProjectButton)) {
1082:                    modifyProjectPerformed();
1083:                } else if (e.getSource().equals(validateButton)) {
1084:                    validatePerformed();
1085:                } else if (e.getSource().equals(cancelButton)) {
1086:                    cancelPerformed();
1087:                } else if (e.getSource().equals(createProjectButton)) {
1088:                    createProjectPerformed();
1089:                } else if (e.getSource().equals(createUserButton)) {
1090:                    createUserPerformed();
1091:                } else if (e.getSource().equals(modifyUserButton)) {
1092:                    modifyUserPerformed();
1093:                } else if (e.getSource().equals(deleteUserButton)) {
1094:                    deleteUserPerformed();
1095:                } else if (e.getSource().equals(changeUserPwdButton)) {
1096:                    changeUserPwdPerformed();
1097:                }
1098:            }
1099:
1100:            void changeUserPwdPerformed() {
1101:                AskName askName = new AskName(Language.getInstance().getText(
1102:                        "Nouveau_mot_de_passe_:_"), Language.getInstance()
1103:                        .getText("Changer_le_mot_de_passe"), Language
1104:                        .getInstance().getText("passe"), null,
1105:                        javax.swing.JOptionPane
1106:                                .getFrameForComponent(Administration.this ));
1107:                if (askName.getResult() != null) {
1108:                    if (Api.isConnected()) {
1109:                        int selectedIndex = userTable.getSelectedRow();
1110:                        if (selectedIndex != -1) {
1111:                            try {
1112:                                String userLogin = (String) usersTableModel
1113:                                        .getValueAt(selectedIndex, 0);
1114:                                User pUser = pAdminVTData
1115:                                        .getUserFromModel(userLogin);
1116:                                pUser.updatePasswordInDB(askName.getResult());
1117:                            } catch (Exception exception) {
1118:                                Tools.ihmExceptionView(exception);
1119:                            }
1120:                        }
1121:                    }
1122:                }
1123:            }
1124:
1125:            void deleteUserPerformed() {
1126:                int[] selectedRowsTab = userTable.getSelectedRows();
1127:                String message = "";
1128:                for (int i = selectedRowsTab.length - 1; i >= 0; i--) {
1129:                    message = message + " * "
1130:                            + usersTableModel.getValueAt(selectedRowsTab[i], 0);
1131:                    if (i == 0) {
1132:                        message = message + "?";
1133:                    } else {
1134:                        message = message + "\n";
1135:                    }
1136:                }
1137:                Object[] options = { Language.getInstance().getText("Oui"),
1138:                        Language.getInstance().getText("Non") };
1139:                int choice = JOptionPane
1140:                        .showOptionDialog(
1141:                                Administration.this ,
1142:                                Language
1143:                                        .getInstance()
1144:                                        .getText(
1145:                                                "Etes_vous_sûr_de_vouloir_supprimer_les_utilisateurs_:_\n")
1146:                                        + message, Language.getInstance()
1147:                                        .getText("Attention_!"),
1148:                                JOptionPane.YES_NO_OPTION,
1149:                                JOptionPane.QUESTION_MESSAGE, null, options,
1150:                                options[1]);
1151:                if (choice == JOptionPane.YES_OPTION) {
1152:                    for (int i = selectedRowsTab.length - 1; i >= 0; i--) {
1153:                        ArrayList projectsList = pAdminVTData
1154:                                .getProjectsWithThisUserAdminFromModel((String) usersTableModel
1155:                                        .getValueAt(selectedRowsTab[i], 0));
1156:                        ArrayList prjsWithUsrAsUniqueAdmin = new ArrayList();
1157:                        if (projectsList.size() > 0) {
1158:                            message = "";
1159:                            boolean prjWithUniqueAdmin = false;
1160:                            for (int k = projectsList.size() - 1; k >= 0; k--) {
1161:                                if (pAdminVTData
1162:                                        .getAdminCountFromModel((Project) projectsList
1163:                                                .get(k)) == 1) {
1164:                                    message = message
1165:                                            + " * "
1166:                                            + ((Project) projectsList.get(k))
1167:                                                    .getNameFromModel() + "\n";
1168:                                    prjsWithUsrAsUniqueAdmin.add(projectsList
1169:                                            .get(k));
1170:                                    prjWithUniqueAdmin = true;
1171:                                }
1172:                            }
1173:                            if (prjWithUniqueAdmin) {
1174:                                choice = JOptionPane
1175:                                        .showOptionDialog(
1176:                                                Administration.this ,
1177:                                                Language.getInstance().getText(
1178:                                                        "L'utilisateur_<")
1179:                                                        + (String) usersTableModel
1180:                                                                .getValueAt(
1181:                                                                        selectedRowsTab[i],
1182:                                                                        0)
1183:                                                        + Language
1184:                                                                .getInstance()
1185:                                                                .getText(
1186:                                                                        ">_est_le_seul_administrateur_des_projets_:_\n")
1187:                                                        + message
1188:                                                        + Language
1189:                                                                .getInstance()
1190:                                                                .getText(
1191:                                                                        "Sa_suppression_entrainera_la_suppression_des_projets_dans_leur_ensemble.\nEtes-vous_sûr_de_vouloir_supprimer_cet_utilisateur_?"),
1192:                                                Language.getInstance().getText(
1193:                                                        "Attention_!"),
1194:                                                JOptionPane.YES_NO_OPTION,
1195:                                                JOptionPane.QUESTION_MESSAGE,
1196:                                                null, options, options[1]);
1197:                                if (choice == JOptionPane.YES_OPTION) {
1198:                                    removeUserAtIndex(i, selectedRowsTab);
1199:                                    for (int k = prjsWithUsrAsUniqueAdmin
1200:                                            .size() - 1; k >= 0; k--) {
1201:                                        Project pProject = (Project) prjsWithUsrAsUniqueAdmin
1202:                                                .get(k);
1203:                                        projectTableModel
1204:                                                .removeData(getIndexOfProject(pProject));
1205:                                    }
1206:                                    removeUserAtIndex(i, selectedRowsTab);
1207:                                }
1208:                            } else {
1209:                                removeUserAtIndex(i, selectedRowsTab);
1210:                            }
1211:                        } else {
1212:                            removeUserAtIndex(i, selectedRowsTab);
1213:                        }
1214:                    }
1215:                }
1216:            }
1217:
1218:            void removeUserAtIndex(int i, int[] selectedRowsTab) {
1219:                try {
1220:                    String userLogin = (String) usersTableModel.getValueAt(
1221:                            selectedRowsTab[i], 0);
1222:                    User pUser = pAdminVTData.getUserFromModel(userLogin);
1223:                    pAdminVTData.delteUserInDBAndModel(pUser);
1224:                    if (usersTableModel.getRowCount() == 0) {
1225:                        deleteUserButton.setEnabled(false);
1226:                    }
1227:                    usersTableModel.removeData(selectedRowsTab[i]);
1228:                } catch (Exception exception) {
1229:                    Tools.ihmExceptionView(exception);
1230:                }
1231:            }
1232:
1233:            void modifyUserPerformed() {
1234:                int selectedRow = userTable.getSelectedRow();
1235:                if (selectedRow != -1) {
1236:                    User user = pAdminVTData
1237:                            .getUserFromModel((String) usersTableModel
1238:                                    .getValueAt(selectedRow, 0));
1239:                    AskNewUser askNewUser = new AskNewUser(user,
1240:                            javax.swing.JOptionPane
1241:                                    .getFrameForComponent(Administration.this ),
1242:                            pAdminVTData);
1243:                    if (askNewUser.getUser() != null) {
1244:                        if (Api.isConnected()) {
1245:                            try {
1246:                                User usr = askNewUser.getUser();
1247:                                user.updateInDBModel(usr.getLoginFromModel(),
1248:                                        usr.getLastNameFromModel(), usr
1249:                                                .getFirstNameFromModel(), usr
1250:                                                .getDescriptionFromModel(), usr
1251:                                                .getEmailFromModel(), usr
1252:                                                .getPhoneNumberFromModel());
1253:
1254:                                ArrayList data = new ArrayList();
1255:                                data.add(usr.getLoginFromModel());
1256:                                data.add(usr.getLastNameFromModel());
1257:                                data.add(usr.getFirstNameFromModel());
1258:                                data.add(usr.getEmailFromModel());
1259:                                data.add(usr.getPhoneNumberFromModel());
1260:                                usersTableModel.modifyData(data, selectedRow);
1261:
1262:                            } catch (Exception e) {
1263:                                Tools.ihmExceptionView(e);
1264:                            }
1265:                        }
1266:                    }
1267:                }
1268:            }
1269:
1270:            void createUserPerformed() {
1271:                AskNewUser askNewUser = new AskNewUser(null,
1272:                        javax.swing.JOptionPane
1273:                                .getFrameForComponent(Administration.this ),
1274:                        pAdminVTData);
1275:                if (askNewUser.getUser() != null) {
1276:                    if (pAdminVTData.containsLoginInModel(askNewUser.getUser()
1277:                            .getLoginFromModel())) {
1278:                        JOptionPane.showMessageDialog(Administration.this ,
1279:                                Language.getInstance().getText(
1280:                                        "Ce_login_existe_déjà_!"), Language
1281:                                        .getInstance().getText("Erreur_!"),
1282:                                JOptionPane.ERROR_MESSAGE);
1283:                    } else {
1284:                        try {
1285:                            User pUser = askNewUser.getUser();
1286:                            pUser.addInDB(new String(askNewUser.getPassword()));
1287:
1288:                            pAdminVTData.addUserInModel(pUser);
1289:                            ArrayList data = new ArrayList();
1290:                            data.add(pUser.getLoginFromModel());
1291:                            data.add(pUser.getLastNameFromModel());
1292:                            data.add(pUser.getFirstNameFromModel());
1293:                            data.add(pUser.getEmailFromModel());
1294:                            data.add(pUser.getPhoneNumberFromModel());
1295:                            usersTableModel.addRow(data);
1296:
1297:                        } catch (Exception exception) {
1298:                            Tools.ihmExceptionView(exception);
1299:                        }
1300:                    }
1301:                }
1302:
1303:            }
1304:
1305:            void createProjectPerformed() {
1306:                AskNewProject askProject = new AskNewProject(pAdminVTData,
1307:                        null, javax.swing.JOptionPane
1308:                                .getFrameForComponent(Administration.this ));
1309:                ArrayList data = new ArrayList();
1310:                Project pProject = askProject.getProject();
1311:                if (pProject != null) {
1312:
1313:                    try {
1314:                        if (!askProject.isFromProjet()) {
1315:                            pAdminVTData.addProjectInDBAndModel(pProject);
1316:                        } else {
1317:                            String fromProjectName = askProject
1318:                                    .getFromProjectName();
1319:                            pAdminVTData
1320:                                    .addProjectInDBAndModelByCopy(
1321:                                            pProject,
1322:                                            pAdminVTData
1323:                                                    .getProjectFromModel(fromProjectName),
1324:                                            askProject.isFromProjectSuites(),
1325:                                            askProject.isFromProjectCampaigns(),
1326:                                            askProject.isFromProjectUsers(),
1327:                                            askProject.isFromProjetGroups());
1328:                        }
1329:                        data.add(Tools.createAppletImageIcon(
1330:                                PATH_TO_PROJECT_ICON, ""));
1331:                        data.add(pProject.getNameFromModel().trim());
1332:                        data.add(pProject.getAdministratorFromModel()
1333:                                .getLoginFromModel());
1334:                        data
1335:                                .add(pProject.getCreationDateFromModel()
1336:                                        .toString());
1337:                        data.add(pProject.getDescriptionFromModel());
1338:                        projectTableModel.addRow(data);
1339:                        //ProjectTableCellRenderer.setColor(normalColor);
1340:                        projectTable.getColumnModel().getColumn(0).setMaxWidth(
1341:                                18);
1342:                        deleteProjectButton.setEnabled(true);
1343:                    } catch (Exception exception) {
1344:                        Tools.ihmExceptionView(exception);
1345:                    }
1346:                }
1347:            }
1348:
1349:            void cancelPerformed() {
1350:                oldPassword.setText(null);
1351:                newPasswordFirst.setText(null);
1352:                newPasswordSecond.setText(null);
1353:            }
1354:
1355:            void deleteProjectPerformed() {
1356:                int selectedRow = projectTable.getSelectedRow();
1357:                if (selectedRow != -1) {
1358:                    Object[] options = { Language.getInstance().getText("Oui"),
1359:                            Language.getInstance().getText("Non") };
1360:
1361:                    int choice = JOptionPane
1362:                            .showOptionDialog(
1363:                                    Administration.this ,
1364:                                    Language
1365:                                            .getInstance()
1366:                                            .getText(
1367:                                                    "Etes_vous_sûr_de_vouloir_supprimer_le_projet_:_")
1368:                                            + projectTableModel.getData(
1369:                                                    selectedRow).get(1),
1370:                                    Language.getInstance().getText(
1371:                                            "Attention_!"),
1372:                                    JOptionPane.YES_NO_OPTION,
1373:                                    JOptionPane.QUESTION_MESSAGE, null,
1374:                                    options, options[1]);
1375:                    if (choice == JOptionPane.YES_OPTION) {
1376:                        if (Api.isConnected()) {
1377:                            try {
1378:                                Project pProject = pAdminVTData
1379:                                        .getProjectFromModel((String) projectTableModel
1380:                                                .getValueAt(selectedRow, 1));
1381:                                pAdminVTData
1382:                                        .deleteProjectInDBAndModel(pProject);
1383:
1384:                                //Call delete project on plugin
1385:                                try {
1386:                                    Enumeration adminPlugins = associatedExtension
1387:                                            .elements();
1388:                                    while (adminPlugins.hasMoreElements()) {
1389:                                        Extension pluginExt = (Extension) adminPlugins
1390:                                                .nextElement();
1391:                                        if (pluginExt.getExtendedPointId()
1392:                                                .equals("Admin")) {
1393:                                            Admin plugin = (Admin) jpf
1394:                                                    .activateExtension(pluginExt);
1395:                                            plugin.onDeleteProject(pProject);
1396:                                        }
1397:                                    }
1398:                                } catch (Exception exception) {
1399:
1400:                                }
1401:                                projectTableModel.removeData(selectedRow);
1402:                                projectTable.getColumnModel().getColumn(0)
1403:                                        .setMaxWidth(18);
1404:                                if (projectTableModel.getRowCount() == 0) {
1405:                                    deleteProjectButton.setEnabled(false);
1406:                                }
1407:                            } catch (Exception exception) {
1408:                                Tools.ihmExceptionView(exception);
1409:                            }
1410:                        }
1411:                    }
1412:                }
1413:            }
1414:
1415:            void modifyProjectPerformed() {
1416:                int selectedRow = projectTable.getSelectedRow();
1417:                if (selectedRow != -1) {
1418:                    Project project = pAdminVTData
1419:                            .getProjectFromModel((String) projectTableModel
1420:                                    .getValueAt(selectedRow, 1));
1421:                    AskNewProject askProject = new AskNewProject(pAdminVTData,
1422:                            project, javax.swing.JOptionPane
1423:                                    .getFrameForComponent(Administration.this ));
1424:                    if (askProject.getProject() != null) {
1425:                        try {
1426:                            project.updateInDBAndModel(askProject.getProject()
1427:                                    .getNameFromModel(), askProject
1428:                                    .getProject().getDescriptionFromModel());
1429:
1430:                            ArrayList data = new ArrayList();
1431:                            data.add(Tools.createAppletImageIcon(
1432:                                    PATH_TO_PROJECT_ICON, ""));
1433:                            data.add(project.getNameFromModel().trim());
1434:                            data.add(project.getAdministratorFromModel()
1435:                                    .getLoginFromModel());
1436:                            data.add(project.getCreationDateFromModel()
1437:                                    .toString());
1438:                            data.add(project.getDescriptionFromModel());
1439:                            projectTableModel.modifyData(data, selectedRow);
1440:                            projectTable.getColumnModel().getColumn(0)
1441:                                    .setMaxWidth(18);
1442:                        } catch (Exception exception) {
1443:                            Tools.ihmExceptionView(exception);
1444:                        }
1445:                    }
1446:                }
1447:            }
1448:
1449:            void validatePerformed() {
1450:                if (Api.isConnected()) {
1451:                    User admin = pAdminVTData.getUserAdminVTData();
1452:                    boolean _valid = false;
1453:                    try {
1454:                        String pass = admin.getPasswordFromDB();
1455:                        _valid = org.objectweb.salome_tmf.api.MD5paswd
1456:                                .testPassword(new String(oldPassword
1457:                                        .getPassword()).trim(), pass);
1458:                    } catch (Exception ex) {
1459:                    }
1460:                    if (_valid) {
1461:                        if (new String(newPasswordFirst.getPassword()).trim()
1462:                                .equals(
1463:                                        new String(newPasswordSecond
1464:                                                .getPassword()).trim())) {
1465:                            try {
1466:                                admin
1467:                                        .updatePasswordInDB(new String(
1468:                                                newPasswordSecond.getPassword())
1469:                                                .trim());
1470:                                oldPassword.setText("");
1471:                                newPasswordFirst.setText("");
1472:                                newPasswordSecond.setText("");
1473:                                JOptionPane
1474:                                        .showMessageDialog(
1475:                                                Administration.this ,
1476:                                                Language
1477:                                                        .getInstance()
1478:                                                        .getText(
1479:                                                                "Votre_mot_de_passe_a_été_modifié."),
1480:                                                Language.getInstance().getText(
1481:                                                        "Succès_!"),
1482:                                                JOptionPane.INFORMATION_MESSAGE);
1483:                            } catch (Exception exception) {
1484:                                Tools.ihmExceptionView(exception);
1485:                            }
1486:
1487:                        } else {
1488:                            newPasswordFirst.setText("");
1489:                            newPasswordSecond.setText("");
1490:                            JOptionPane
1491:                                    .showMessageDialog(
1492:                                            Administration.this ,
1493:                                            Language
1494:                                                    .getInstance()
1495:                                                    .getText(
1496:                                                            "Impossible_de_changer_le_mot_de_passe.\nVous_n'avez_pas_entrer_deux_fois_le_même_mot_de_passe."),
1497:                                            Language.getInstance().getText(
1498:                                                    "Erreur_!"),
1499:                                            JOptionPane.ERROR_MESSAGE);
1500:                        }
1501:                    } else {
1502:                        oldPassword.setText("");
1503:                        JOptionPane
1504:                                .showMessageDialog(
1505:                                        Administration.this ,
1506:                                        Language
1507:                                                .getInstance()
1508:                                                .getText(
1509:                                                        "Impossible_de_changer_le_mot_de_passe.\nL'ancien_mot_de_passe_est_incorrect."),
1510:                                        Language.getInstance().getText(
1511:                                                "Erreur_!"),
1512:                                        JOptionPane.ERROR_MESSAGE);
1513:                    }
1514:                } else {
1515:                    JOptionPane
1516:                            .showMessageDialog(
1517:                                    Administration.this ,
1518:                                    Language
1519:                                            .getInstance()
1520:                                            .getText(
1521:                                                    "Impossible_de_changer_le_mot_de_passe.\nVous_n'êtes_pas_connecter_à_la_base."),
1522:                                    Language.getInstance().getText("Erreur_!"),
1523:                                    JOptionPane.ERROR_MESSAGE);
1524:                }
1525:            }
1526:
1527:            public void addBugTrackers(Object bugTracker) {
1528:                bugTrackers.add(bugTracker);
1529:            }
1530:
1531:            public Vector getBugTracker() {
1532:                return bugTrackers;
1533:            }
1534:
1535:            /*public void addJarToClassLoader(URL jar){
1536:            	Class pclC = null;
1537:            	try {
1538:            		pclC = (this.getClass().getClassLoader()).getClass();
1539:            		pclC.getMethod("addLocalJar", new Class[] { URL.class })
1540:            		.invoke(this.getClass().getClassLoader(),
1541:            				new Object[] { jar});
1542:            		} catch (Exception e){
1543:            			//pPluginClassLoader.AddJar(UrlLib);
1544:            		}
1545:            }*/
1546:            /***************** Windows Listener ***************/
1547:
1548:            public void windowClosing(WindowEvent e) {
1549:                if (!exit)
1550:                    quit(true, true);
1551:            }
1552:
1553:            public void windowActivated(WindowEvent e) {
1554:            }
1555:
1556:            public void windowClosed(WindowEvent e) {
1557:            }
1558:
1559:            public void windowDeactivated(WindowEvent e) {
1560:            }
1561:
1562:            public void windowDeiconified(WindowEvent e) {
1563:            }
1564:
1565:            public void windowIconified(WindowEvent e) {
1566:            }
1567:
1568:            public void windowOpened(WindowEvent e) {
1569:            }
1570:
1571:            public void addReqManager(Object reqManager) {
1572:                reqManagers.add(reqManager);
1573:            }
1574:
1575:            public Vector getReqManagers() {
1576:                return reqManagers;
1577:            }
1578:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.