Source Code Cross Referenced for ExecutionView.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » main » 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.main 
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.main;
0025:
0026:        import java.awt.BorderLayout;
0027:        import java.awt.Color;
0028:        import java.awt.Cursor;
0029:        import java.awt.Dimension;
0030:        import java.awt.GridLayout;
0031:        import java.awt.event.ActionEvent;
0032:        import java.awt.event.ActionListener;
0033:        import java.io.File;
0034:        import java.io.FileNotFoundException;
0035:        import java.sql.Time;
0036:        import java.text.SimpleDateFormat;
0037:        import java.util.ArrayList;
0038:        import java.util.GregorianCalendar;
0039:        import java.util.HashMap;
0040:        import java.util.Hashtable;
0041:
0042:        import javax.swing.BorderFactory;
0043:        import javax.swing.Box;
0044:        import javax.swing.BoxLayout;
0045:        import javax.swing.JButton;
0046:        import javax.swing.JMenu;
0047:        import javax.swing.JMenuBar;
0048:        import javax.swing.JMenuItem;
0049:        import javax.swing.JOptionPane;
0050:        import javax.swing.JPanel;
0051:        import javax.swing.JScrollPane;
0052:        import javax.swing.JTable;
0053:        import javax.swing.ListSelectionModel;
0054:        import javax.swing.event.ListSelectionEvent;
0055:        import javax.swing.event.ListSelectionListener;
0056:
0057:        import org.java.plugin.Extension;
0058:        import org.objectweb.salome_tmf.api.Api;
0059:        import org.objectweb.salome_tmf.api.ApiConstants;
0060:        import org.objectweb.salome_tmf.api.Permission;
0061:        import org.objectweb.salome_tmf.api.Util;
0062:        import org.objectweb.salome_tmf.data.Campaign;
0063:        import org.objectweb.salome_tmf.data.DataConstants;
0064:        import org.objectweb.salome_tmf.data.Execution;
0065:        import org.objectweb.salome_tmf.data.ExecutionResult;
0066:        import org.objectweb.salome_tmf.data.Script;
0067:        import org.objectweb.salome_tmf.ihm.languages.Language;
0068:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0069:        import org.objectweb.salome_tmf.ihm.main.datawrapper.TestMethods;
0070:        import org.objectweb.salome_tmf.ihm.models.ExecutionResultMouseListener;
0071:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
0072:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0073:        import org.objectweb.salome_tmf.plugins.UICompCst;
0074:        import org.objectweb.salome_tmf.plugins.core.ScriptEngine;
0075:
0076:        public class ExecutionView extends JPanel implements  ApiConstants,
0077:                DataConstants, ActionListener {
0078:
0079:            /**
0080:             * Table des exécutions
0081:             */
0082:            static JTable executionTable;
0083:
0084:            /**
0085:             * Table des détails des exécutions
0086:             */
0087:            JTable detailsExecutionTable;
0088:
0089:            /**
0090:             * Bouton pour lancer une ex?cution
0091:             */
0092:            static JButton launchExecution;
0093:
0094:            /**
0095:             * Bouton pour avoir le détails des résultats sur les tests
0096:             */
0097:            JButton resultExecution;
0098:
0099:            /**
0100:             * Bouton pour gérer les anomalies d'un résultat d'exécution
0101:             */
0102:            JButton defectResultExecution;
0103:            /**
0104:             * Bouton pour supprimer une ex?cution
0105:             */
0106:            static JButton deleteExecution;
0107:
0108:            /**
0109:             * Bouton pour modifier une ex?cution
0110:             */
0111:            static JButton modifyExecutionButton;
0112:
0113:            /**
0114:             * Bouton pour supprimer une ex?cution
0115:             */
0116:            static JButton deleteExecutionResult;
0117:
0118:            /**
0119:             * Bouton pour reprendre une ex?cution
0120:             */
0121:            static JButton continueExecution;
0122:
0123:            static JButton relancerExecution;
0124:            /**
0125:             * Bouton pour g?rer les attachements d'une ex?cution
0126:             */
0127:            JButton attachExecutionResultButton;
0128:
0129:            /**
0130:             * Bouton pour g?rer les attachements d'un r?sultat d'ex?cution
0131:             */
0132:            JButton attachExecutionButton;
0133:            /**
0134:             * Bouton pour ajouter une nouvelle ex?cution
0135:             */
0136:            static JButton addExecution;
0137:
0138:            /**
0139:             *
0140:             */
0141:            //private boolean automatic_finished;
0142:            static JMenu modifyScriptMenu;
0143:            static JMenuItem initScriptItem;
0144:            static JMenuItem postScriptItem;
0145:            static JMenuItem setUpPreEngineItem;
0146:            static JMenuItem setUpPostEngineItem;
0147:            static JMenuBar modifyScriptMenuBar;
0148:
0149:            //static JMenu commitMenu;
0150:            static JMenuItem commitInitScriptItem;
0151:            static JMenuItem commitPostScriptItem;
0152:            //static JMenuBar commitMenuBar;
0153:
0154:            HashMap modifyPreScriptMap;
0155:            HashMap modifyPostScriptMap;
0156:
0157:            File importFile;
0158:
0159:            TableSorter sorter;
0160:            TableSorter detailsSorter;
0161:            boolean forModif = false;
0162:
0163:            /******************************************************************************/
0164:            /**									CONSTRUCTEUR							 **/
0165:            /******************************************************************************/
0166:            public ExecutionView() {
0167:
0168:                executionTable = new JTable();
0169:                detailsExecutionTable = new JTable();
0170:
0171:                addExecution = new JButton(Language.getInstance().getText(
0172:                        "Ajouter"));
0173:                addExecution.setToolTipText(Language.getInstance().getText(
0174:                        "Ajouter_une_exécution"));
0175:                addExecution.addActionListener(this );
0176:
0177:                launchExecution = new JButton(Language.getInstance().getText(
0178:                        "Lancer"));
0179:                launchExecution.setToolTipText(Language.getInstance().getText(
0180:                        "Lancer_l'exécution"));
0181:                launchExecution.addActionListener(this );
0182:
0183:                resultExecution = new JButton(Language.getInstance().getText(
0184:                        "Détails"));
0185:                resultExecution.setToolTipText(Language.getInstance().getText(
0186:                        "Détails_sur_les_résultats_de_l'exécution"));
0187:                resultExecution.setEnabled(false);
0188:                resultExecution.addActionListener(this );
0189:
0190:                defectResultExecution = new JButton(Language.getInstance()
0191:                        .getText("Anomalies"));
0192:                defectResultExecution.setEnabled(false);
0193:                defectResultExecution.addActionListener(this );
0194:
0195:                modifyExecutionButton = new JButton(Language.getInstance()
0196:                        .getText("Modifier"));
0197:                modifyExecutionButton.setToolTipText(Language.getInstance()
0198:                        .getText("Modifier_une_exécution"));
0199:                modifyExecutionButton.setEnabled(false);
0200:                modifyExecutionButton.addActionListener(this );
0201:
0202:                deleteExecution = new JButton(Language.getInstance().getText(
0203:                        "Supprimer"));
0204:                deleteExecution.setToolTipText(Language.getInstance().getText(
0205:                        "Supprimer_une_exécution"));
0206:                deleteExecution.setEnabled(false);
0207:                deleteExecution.addActionListener(this );
0208:
0209:                deleteExecutionResult = new JButton(Language.getInstance()
0210:                        .getText("Supprimer"));
0211:                deleteExecutionResult.setToolTipText(Language.getInstance()
0212:                        .getText("Supprimer_un_résultat_d'exécution"));
0213:                deleteExecutionResult.setEnabled(false);
0214:                deleteExecutionResult.addActionListener(this );
0215:
0216:                continueExecution = new JButton(Language.getInstance().getText(
0217:                        "Reprendre"));
0218:                continueExecution.setToolTipText(Language.getInstance()
0219:                        .getText("Reprendre_une_exécution"));
0220:                continueExecution.setEnabled(false);
0221:                continueExecution.addActionListener(this );
0222:
0223:                relancerExecution = new JButton(Language.getInstance().getText(
0224:                        "Reexecuter"));
0225:                relancerExecution.setToolTipText(Language.getInstance()
0226:                        .getText("Reexecuter_une_exécution"));
0227:                relancerExecution.setEnabled(false);
0228:                relancerExecution.addActionListener(this );
0229:
0230:                attachExecutionButton = new JButton(Language.getInstance()
0231:                        .getText("Attachements"));
0232:                attachExecutionButton.setEnabled(false);
0233:                attachExecutionButton.addActionListener(this );
0234:
0235:                attachExecutionResultButton = new JButton(Language
0236:                        .getInstance().getText("Attachements"));
0237:                attachExecutionResultButton.setEnabled(false);
0238:                attachExecutionResultButton.addActionListener(this );
0239:
0240:                //commitMenu = new JMenu("Actualiser Script");
0241:                commitInitScriptItem = new JMenuItem(Language.getInstance()
0242:                        .getText("Actualiser_pre-Script"));
0243:                commitInitScriptItem.addActionListener(this );
0244:
0245:                commitPostScriptItem = new JMenuItem(Language.getInstance()
0246:                        .getText("Actualiser_post-Script"));
0247:                commitPostScriptItem.addActionListener(this );
0248:
0249:                //commitMenu.add(commitInitScriptItem);
0250:                //commitMenu.add(commitPostScriptItem);
0251:                //commitMenuBar = new JMenuBar();
0252:                //commitMenuBar.add(commitMenu);
0253:
0254:                //commitMenu.setEnabled(false);
0255:
0256:                modifyScriptMenu = new JMenu(Language.getInstance().getText(
0257:                        "Script"));
0258:                initScriptItem = new JMenuItem(Language.getInstance().getText(
0259:                        "Modifier_le_pre-Script"));
0260:                initScriptItem.addActionListener(this );
0261:
0262:                postScriptItem = new JMenuItem(Language.getInstance().getText(
0263:                        "Modifier_le_post-Script"));
0264:                postScriptItem.addActionListener(this );
0265:
0266:                setUpPostEngineItem = new JMenuItem(Language.getInstance()
0267:                        .getText("SetUp_Post-script"));
0268:                setUpPostEngineItem.addActionListener(this );
0269:                setUpPreEngineItem = new JMenuItem(Language.getInstance()
0270:                        .getText("SetUp_Pre-script"));
0271:                setUpPreEngineItem.addActionListener(this );
0272:
0273:                modifyScriptMenu.add(initScriptItem);
0274:                modifyScriptMenu.add(commitInitScriptItem);
0275:                modifyScriptMenu.add(setUpPreEngineItem);
0276:
0277:                modifyScriptMenu.add(postScriptItem);
0278:                modifyScriptMenu.add(commitPostScriptItem);
0279:                modifyScriptMenu.add(setUpPostEngineItem);
0280:
0281:                modifyScriptMenuBar = new JMenuBar();
0282:                modifyScriptMenuBar.add(modifyScriptMenu);
0283:                modifyScriptMenu.setEnabled(false);
0284:
0285:                launchExecution.setEnabled(false);
0286:                deleteExecution.setEnabled(false);
0287:                resultExecution.setEnabled(false);
0288:
0289:                //JPanel executionButtonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
0290:                JPanel executionButtonsPanel = new JPanel(new GridLayout(1, 6));
0291:                executionButtonsPanel.add(addExecution);
0292:                executionButtonsPanel.add(modifyExecutionButton);
0293:                executionButtonsPanel.add(deleteExecution);
0294:                executionButtonsPanel.add(launchExecution);
0295:                executionButtonsPanel.add(attachExecutionButton);
0296:                executionButtonsPanel.add(modifyScriptMenuBar);
0297:                //executionButtonsPanel.add(commitMenuBar);
0298:
0299:                executionButtonsPanel.setBorder(BorderFactory
0300:                        .createRaisedBevelBorder());
0301:
0302:                // Mapping entre objets graphiques et constantes
0303:                SalomeTMFContext.getInstance().addToUIComponentsMap(
0304:                        UICompCst.CAMP_EXECUTIONS_BUTTONS_PANEL,
0305:                        executionButtonsPanel);
0306:                // Add this component as static component
0307:                UICompCst.staticUIComps
0308:                        .add(UICompCst.CAMP_EXECUTIONS_BUTTONS_PANEL);
0309:
0310:                //JPanel executionResultButtonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
0311:                JPanel executionResultButtonsPanel = new JPanel(new GridLayout(
0312:                        1, 6));
0313:                executionResultButtonsPanel.add(resultExecution);
0314:                executionResultButtonsPanel.add(continueExecution);
0315:                executionResultButtonsPanel.add(relancerExecution);
0316:                executionResultButtonsPanel.add(defectResultExecution);
0317:                executionResultButtonsPanel.add(attachExecutionResultButton);
0318:                executionResultButtonsPanel.add(deleteExecutionResult);
0319:                executionResultButtonsPanel.setBorder(BorderFactory
0320:                        .createRaisedBevelBorder());
0321:
0322:                // Mapping entre objets graphiques et constantes
0323:                SalomeTMFContext.getInstance().addToUIComponentsMap(
0324:                        UICompCst.CAMP_EXECUTION_RESULTS_BUTTONS_PANEL,
0325:                        executionResultButtonsPanel);
0326:                // Add this component as static component
0327:                UICompCst.staticUIComps
0328:                        .add(UICompCst.CAMP_EXECUTION_RESULTS_BUTTONS_PANEL);
0329:
0330:                sorter = new TableSorter(DataModel.getExecutionTableModel());
0331:                executionTable.setModel(sorter);
0332:                sorter.setTableHeader(executionTable.getTableHeader());
0333:                //		executionTable.setModel(DataModel.getExecutionTableModel());
0334:                executionTable
0335:                        .setPreferredScrollableViewportSize(new Dimension(600,
0336:                                200));
0337:                executionTable
0338:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0339:                executionTable.getColumnModel().getColumn(0).setMaxWidth(18);
0340:                executionTable.getColumnModel().getColumn(0).setWidth(18);
0341:                executionTable.getColumnModel().getColumn(0).setMinWidth(18);
0342:                executionTable.getColumnModel().getColumn(0).setPreferredWidth(
0343:                        18);
0344:                executionTable.getColumnModel().getColumn(0)
0345:                        .setResizable(false);
0346:
0347:                // Mapping entre objets graphiques et constantes
0348:                SalomeTMFContext.getInstance().addToUIComponentsMap(
0349:                        UICompCst.CAMP_EXECUTIONS_TABLE, executionTable);
0350:                // Add this component as static component
0351:                UICompCst.staticUIComps.add(UICompCst.CAMP_EXECUTIONS_TABLE);
0352:
0353:                JScrollPane tablePane = new JScrollPane(executionTable);
0354:                tablePane.setBorder(BorderFactory.createTitledBorder(
0355:                        BorderFactory.createLineBorder(Color.BLACK), Language
0356:                                .getInstance().getText("Exécutions")));
0357:
0358:                ListSelectionModel rowSM = executionTable.getSelectionModel();
0359:                rowSM.addListSelectionListener(new ListSelectionListener() {
0360:                    public void valueChanged(ListSelectionEvent e) {
0361:                        if (e.getValueIsAdjusting())
0362:                            return;
0363:                        Util.log("[ExcecutionView] Event is " + e);
0364:                        int selectedRowIndex = executionTable.getSelectedRow();
0365:
0366:                        if (selectedRowIndex != -1) {
0367:                            //Execution exec = DataModel.getCurrentCampaign().getExecution(selectedRowIndex);
0368:                            //System.out.println("Get Execution "+ (String)sorter.getValueAt(selectedRowIndex,1) +" for current campaign "+ DataModel.getCurrentCampaign().getNameFromModel());
0369:                            Execution exec = DataModel.getCurrentCampaign()
0370:                                    .getExecutionFromModel(
0371:                                            (String) sorter.getValueAt(
0372:                                                    selectedRowIndex, 1));
0373:                            //System.out.println("Execution is " + exec);
0374:                            if (exec == null) {
0375:                                return;
0376:                            }
0377:                            DataModel.setObservedExecution(exec);
0378:                            DataModel.getExecutionResultTableModel()
0379:                                    .clearTable();
0380:                            if (Permission.canExecutCamp())
0381:                                launchExecution.setEnabled(true);
0382:                            if (Permission.canExecutCamp())
0383:                                deleteExecution.setEnabled(true);
0384:                            attachExecutionButton.setEnabled(true);
0385:                            if (Permission.canUpdateCamp()
0386:                                    || Permission.canExecutCamp())
0387:                                modifyExecutionButton.setEnabled(true);
0388:                            if ((Permission.canUpdateCamp() || Permission
0389:                                    .canExecutCamp())
0390:                                    && (exec.getPreScriptFromModel() != null || exec
0391:                                            .getPostScriptFromModel() != null)) {
0392:                                modifyScriptMenuBar.setEnabled(true);
0393:                                modifyScriptMenu.setEnabled(true);
0394:                                if (exec.getPreScriptFromModel() != null) {
0395:                                    initScriptItem.setEnabled(true);
0396:                                    setUpPreEngineItem.setEnabled(true);
0397:                                } else {
0398:                                    initScriptItem.setEnabled(false);
0399:                                    setUpPreEngineItem.setEnabled(false);
0400:                                }
0401:                                if (exec.getPostScriptFromModel() != null) {
0402:                                    postScriptItem.setEnabled(true);
0403:                                    setUpPostEngineItem.setEnabled(true);
0404:                                } else {
0405:                                    postScriptItem.setEnabled(false);
0406:                                    setUpPostEngineItem.setEnabled(false);
0407:                                }
0408:                            } else {
0409:                                modifyScriptMenuBar.setEnabled(false);
0410:                                modifyScriptMenu.setEnabled(false);
0411:                            }
0412:                            if (Api.isConnected()
0413:                                    && Permission.canUpdateCamp()
0414:                                    && isCommitablePreScript((String) executionTable
0415:                                            .getModel().getValueAt(
0416:                                                    selectedRowIndex, 1))) {
0417:                                commitInitScriptItem.setEnabled(true);
0418:                            } else {
0419:                                commitInitScriptItem.setEnabled(false);
0420:                            }
0421:                            if (Api.isConnected()
0422:                                    && Permission.canUpdateCamp()
0423:                                    && isCommitablePostScript((String) executionTable
0424:                                            .getModel().getValueAt(
0425:                                                    selectedRowIndex, 1))) {
0426:                                commitPostScriptItem.setEnabled(true);
0427:                            } else {
0428:                                commitPostScriptItem.setEnabled(false);
0429:                            }
0430:
0431:                            for (int i = 0; i < exec
0432:                                    .getExecutionResultListFromModel().size(); i++) {
0433:                                ArrayList resultList = new ArrayList();
0434:                                resultList.add(((ExecutionResult) exec
0435:                                        .getExecutionResultListFromModel().get(
0436:                                                i)).getNameFromModel());
0437:                                Util
0438:                                        .log("[ExecutionView] try to format : "
0439:                                                + ((ExecutionResult) exec
0440:                                                        .getExecutionResultListFromModel()
0441:                                                        .get(i))
0442:                                                        .getExecutionDateFromModel()
0443:                                                        .toString()
0444:                                                + "  "
0445:                                                + ((ExecutionResult) exec
0446:                                                        .getExecutionResultListFromModel()
0447:                                                        .get(i))
0448:                                                        .getTimeFromModel()
0449:                                                        .toString());
0450:                                SimpleDateFormat formater = new SimpleDateFormat(
0451:                                        "dd/MM/yyyy");
0452:                                resultList
0453:                                        .add(formater
0454:                                                .format(
0455:                                                        ((ExecutionResult) exec
0456:                                                                .getExecutionResultListFromModel()
0457:                                                                .get(i))
0458:                                                                .getExecutionDateFromModel())
0459:                                                .toString()
0460:                                                + "  "
0461:                                                + ((ExecutionResult) exec
0462:                                                        .getExecutionResultListFromModel()
0463:                                                        .get(i))
0464:                                                        .getTimeFromModel()
0465:                                                        .toString());
0466:                                resultList.add(((ExecutionResult) exec
0467:                                        .getExecutionResultListFromModel().get(
0468:                                                i)).getTesterFromModel());
0469:                                resultList.add(((ExecutionResult) exec
0470:                                        .getExecutionResultListFromModel().get(
0471:                                                i))
0472:                                        .getExecutionStatusFromModel());
0473:                                resultList.add(((ExecutionResult) exec
0474:                                        .getExecutionResultListFromModel().get(
0475:                                                i)).getFormatedStatFromModel(
0476:                                        Language.getInstance().getText(
0477:                                                "Initial_SUCCES"), Language
0478:                                                .getInstance().getText(
0479:                                                        "Initial_ECHEC"),
0480:                                        Language.getInstance().getText(
0481:                                                "Initial_INCON")));
0482:
0483:                                DataModel.getExecutionResultTableModel()
0484:                                        .addRow(resultList);
0485:                            }
0486:                        } else {
0487:                            //launchExecution.setEnabled(false);
0488:                            deleteExecution.setEnabled(false);
0489:                            attachExecutionButton.setEnabled(false);
0490:                            modifyExecutionButton.setEnabled(false);
0491:                            modifyScriptMenuBar.setEnabled(false);
0492:                            initScriptItem.setEnabled(false);
0493:                            setUpPreEngineItem.setEnabled(false);
0494:                            postScriptItem.setEnabled(false);
0495:                            setUpPostEngineItem.setEnabled(false);
0496:                            commitInitScriptItem.setEnabled(false);
0497:                            commitPostScriptItem.setEnabled(false);
0498:                            modifyScriptMenu.setEnabled(false);
0499:                        }
0500:                    }
0501:                });
0502:
0503:                detailsSorter = new TableSorter(DataModel
0504:                        .getExecutionResultTableModel());
0505:                detailsExecutionTable.setModel(detailsSorter);
0506:                detailsSorter.setTableHeader(detailsExecutionTable
0507:                        .getTableHeader());
0508:                //		detailsExecutionTable.setModel(DataModel.getExecutionResultTableModel());
0509:                detailsExecutionTable
0510:                        .setPreferredScrollableViewportSize(new Dimension(600,
0511:                                200));
0512:                detailsExecutionTable
0513:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0514:                detailsExecutionTable
0515:                        .addMouseListener(new ExecutionResultMouseListener());
0516:
0517:                // Mapping entre objets graphiques et constantes
0518:                SalomeTMFContext.getInstance().addToUIComponentsMap(
0519:                        UICompCst.CAMP_EXECUTION_RESULTS_TABLE,
0520:                        detailsExecutionTable);
0521:                // Add this component as static component
0522:                UICompCst.staticUIComps
0523:                        .add(UICompCst.CAMP_EXECUTION_RESULTS_TABLE);
0524:
0525:                JScrollPane detailsTablePane = new JScrollPane(
0526:                        detailsExecutionTable);
0527:                detailsTablePane.setBorder(BorderFactory.createTitledBorder(
0528:                        BorderFactory.createLineBorder(Color.BLACK), Language
0529:                                .getInstance().getText("Résultats")));
0530:
0531:                ListSelectionModel detailsRowSM = detailsExecutionTable
0532:                        .getSelectionModel();
0533:                detailsRowSM
0534:                        .addListSelectionListener(new ListSelectionListener() {
0535:                            public void valueChanged(ListSelectionEvent e) {
0536:                                if (e.getValueIsAdjusting())
0537:                                    return;
0538:                                //Util.log(Language.getInstance().getText("Execution_result_tab_listener"));
0539:
0540:                                int selectedRowIndex = detailsExecutionTable
0541:                                        .getSelectedRow();
0542:                                if (selectedRowIndex != -1) {
0543:                                    resultExecution.setEnabled(true);
0544:                                    defectResultExecution.setEnabled(true);
0545:                                    if (Permission.canExecutCamp()) {
0546:                                        deleteExecutionResult.setEnabled(true);
0547:                                    }
0548:                                    attachExecutionResultButton
0549:                                            .setEnabled(true);
0550:
0551:                                    DataModel
0552:                                            .setObervedExecutionResult(DataModel
0553:                                                    .getObservedExecution()
0554:                                                    .getExecutionResultFromModel(
0555:                                                            (String) detailsSorter
0556:                                                                    .getValueAt(
0557:                                                                            selectedRowIndex,
0558:                                                                            0)));
0559:                                    if (DataModel
0560:                                            .getObservedExecution()
0561:                                            .getExecutionResultFromModel(
0562:                                                    (String) detailsSorter
0563:                                                            .getValueAt(
0564:                                                                    selectedRowIndex,
0565:                                                                    0))
0566:                                            .getExecutionStatusFromModel()
0567:                                            .equals(INCOMPLETED)
0568:                                            || DataModel
0569:                                                    .getObservedExecution()
0570:                                                    .getExecutionResultFromModel(
0571:                                                            (String) detailsSorter
0572:                                                                    .getValueAt(
0573:                                                                            selectedRowIndex,
0574:                                                                            0))
0575:                                                    .getExecutionStatusFromModel()
0576:                                                    .equals(INTERRUPT)) {
0577:                                        if (Permission.canExecutCamp()) {
0578:                                            continueExecution.setText(Language
0579:                                                    .getInstance().getText(
0580:                                                            "Reprendre"));
0581:                                            continueExecution.setEnabled(true);
0582:                                            relancerExecution.setEnabled(false);
0583:                                            forModif = false;
0584:                                        }
0585:                                    } else {
0586:                                        if (Api.isLockExecutedTest()) {
0587:                                            continueExecution.setText(Language
0588:                                                    .getInstance().getText(
0589:                                                            "Reprendre"));
0590:                                            continueExecution.setEnabled(false);
0591:                                            relancerExecution.setEnabled(false);
0592:                                            forModif = false;
0593:                                        } else {
0594:                                            //change label bouton
0595:                                            continueExecution.setText(Language
0596:                                                    .getInstance().getText(
0597:                                                            "Modifier"));
0598:                                            continueExecution.setEnabled(true);
0599:                                            forModif = true;
0600:                                            relancerExecution.setEnabled(true);
0601:
0602:                                        }
0603:                                    }
0604:                                } else {
0605:                                    attachExecutionResultButton
0606:                                            .setEnabled(false);
0607:                                    resultExecution.setEnabled(false);
0608:                                    defectResultExecution.setEnabled(false);
0609:                                    continueExecution.setEnabled(false);
0610:                                    relancerExecution.setEnabled(false);
0611:                                    deleteExecutionResult.setEnabled(false);
0612:                                }
0613:
0614:                            }
0615:                        });
0616:
0617:                JPanel executionPanel = new JPanel(new BorderLayout());
0618:                executionPanel.add(executionButtonsPanel, BorderLayout.NORTH);
0619:                executionPanel.add(tablePane, BorderLayout.CENTER);
0620:
0621:                JPanel resultPanel = new JPanel(new BorderLayout());
0622:                resultPanel
0623:                        .add(executionResultButtonsPanel, BorderLayout.NORTH);
0624:                resultPanel.add(detailsTablePane, BorderLayout.CENTER);
0625:
0626:                initData();
0627:
0628:                this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
0629:                this .add(executionPanel);
0630:                this .add(Box.createRigidArea(new Dimension(1, 10)));
0631:                this .add(resultPanel);
0632:
0633:            } // Fin du constructeur ExecutionView/0
0634:
0635:            public static JTable getTable() {
0636:                return executionTable;
0637:            }
0638:
0639:            /**
0640:             *
0641:             *
0642:             */
0643:            public static void giveAccessToIhmExecutionView() {
0644:                if (!Permission.canExecutCamp()) {
0645:                    deleteExecution.setEnabled(false);
0646:                    deleteExecutionResult.setEnabled(false);
0647:                }
0648:                if (!Permission.canCreateCamp() && !Permission.canExecutCamp()) {
0649:                    addExecution.setEnabled(false);
0650:                }
0651:                if (!Permission.canUpdateCamp() && !Permission.canExecutCamp()) {
0652:                    modifyExecutionButton.setEnabled(false);
0653:                    modifyScriptMenuBar.setEnabled(false);
0654:                    //commitMenuBar.setEnabled(false);
0655:                }
0656:                if (!Permission.canExecutCamp()) {
0657:                    launchExecution.setEnabled(false);
0658:                    continueExecution.setEnabled(false);
0659:                    relancerExecution.setEnabled(false);
0660:                }
0661:            }
0662:
0663:            private boolean isCommitablePreScript(String execName) {
0664:                Execution exec = DataModel.getCurrentCampaign()
0665:                        .getExecutionFromModel(execName);
0666:                Boolean bool = (Boolean) modifyPreScriptMap.get(exec);
0667:                if (bool == null) {
0668:                    return false;
0669:                }
0670:                return bool.booleanValue();
0671:            }
0672:
0673:            private boolean isCommitablePostScript(String execName) {
0674:                Execution exec = DataModel.getCurrentCampaign()
0675:                        .getExecutionFromModel(execName);
0676:                Boolean bool = (Boolean) modifyPostScriptMap.get(exec);
0677:                if (bool == null) {
0678:                    return false;
0679:                }
0680:                return bool.booleanValue();
0681:            }
0682:
0683:            private void initData() {
0684:                modifyPreScriptMap = new HashMap();
0685:                modifyPostScriptMap = new HashMap();
0686:                for (int i = 0; i < executionTable.getModel().getRowCount(); i++) {
0687:                    modifyPreScriptMap.put(executionTable.getModel()
0688:                            .getValueAt(i, 0), new Boolean(false));
0689:                    modifyPostScriptMap.put(executionTable.getModel()
0690:                            .getValueAt(i, 0), new Boolean(false));
0691:                }
0692:            }
0693:
0694:            private void modifyScript(String type) {
0695:                int selectedRow = executionTable.getSelectedRow();
0696:                if (selectedRow != -1) {
0697:                    Execution exec = DataModel.getCurrentCampaign()
0698:                            .getExecutionFromModel(
0699:                                    (String) executionTable.getModel()
0700:                                            .getValueAt(selectedRow, 1));
0701:                    try {
0702:                        Cursor c = new Cursor(Cursor.WAIT_CURSOR);
0703:                        ExecutionView.this .setCursor(c);
0704:                    } catch (Exception ex) {
0705:                        ex.printStackTrace();
0706:                        return;
0707:                    }
0708:                    try {
0709:                        Script pScript = null;
0710:                        String plugSeting = "";
0711:                        Hashtable param = new Hashtable();
0712:                        param.put("salome_projectName", DataModel
0713:                                .getCurrentProject().getNameFromModel());
0714:                        param.put("salome_ProjectObject", DataModel
0715:                                .getCurrentProject());
0716:                        param.put("salome_debug", new Boolean(true));
0717:                        param.put(Language.getInstance().getText(
0718:                                "salome_CampagneName"), "");
0719:                        param.put("salome_ExecName", exec.getNameFromModel()); // Add MM
0720:                        param.put("salome_environmentName", "");
0721:                        param.put("salome_TestName", "");
0722:                        param.put("salome_SuiteTestName", "");
0723:                        param.put("salome_FamilyName", "");
0724:                        param.put("testLog", "");
0725:                        param.put("Verdict", "");
0726:                        int plugScriptType;
0727:                        String fileScript = null;
0728:
0729:                        if (type.equals(PRE_SCRIPT)) {
0730:                            pScript = exec.getPreScriptFromModel();
0731:                            plugScriptType = ScriptEngine.PRE_SCRIPT;
0732:                        } else {
0733:                            pScript = exec.getPostScriptFromModel();
0734:                            plugScriptType = ScriptEngine.POST_SCRIPT;
0735:
0736:                        }
0737:                        if (pScript == null) {
0738:                            JOptionPane
0739:                                    .showMessageDialog(
0740:                                            ExecutionView.this ,
0741:                                            Language
0742:                                                    .getInstance()
0743:                                                    .getText(
0744:                                                            "Impossible_de_récupérer_le_fichier_depuis_la_base."),
0745:                                            Language.getInstance().getText(
0746:                                                    "Erreur_!"),
0747:                                            JOptionPane.ERROR_MESSAGE);
0748:                            return;
0749:                        }
0750:                        plugSeting = pScript.getPlugArgFromModel();
0751:
0752:                        if (Api.isConnected()) {
0753:                            //importFile = ConnectionData.getCampTestSelect().getScriptOfExecution(DataModel.getCurrentCampaign().getName(),exec.getName(), pScript.getName(), type);
0754:                            //importFile = exec.getExecScriptFromDB(pScript.getNameFromModel(), type);
0755:                            importFile = exec.getExecScriptFromDB(type);
0756:                            fileScript = Tools.speedpurge(importFile
0757:                                    .getAbsolutePath());
0758:                        } else {
0759:                            fileScript = Tools.speedpurge(pScript
0760:                                    .getNameFromModel());
0761:                        }
0762:
0763:                        if (fileScript != null) {
0764:                            ScriptEngine pEngine = pScript
0765:                                    .getScriptEngine(
0766:                                            (Extension) SalomeTMFContext
0767:                                                    .getInstance().associatedExtension
0768:                                                    .get(pScript
0769:                                                            .getScriptExtensionFromModel()),
0770:                                            SalomeTMFContext.getInstance().urlSalome,
0771:                                            SalomeTMFContext.getInstance().jpf);
0772:                            if (pEngine != null) {
0773:                                pEngine.editScript(fileScript, plugScriptType,
0774:                                        pScript, param, plugSeting);
0775:                                //inter.eval("desktop(\""+ Tools.speedpurge(importFile.getAbsolutePath())+ "\");");
0776:                            } else {
0777:                                JOptionPane
0778:                                        .showMessageDialog(
0779:                                                ExecutionView.this ,
0780:                                                Language
0781:                                                        .getInstance()
0782:                                                        .getText(
0783:                                                                "Impossible_d'initialiser_le_plugin_du_scrit"),
0784:                                                Language.getInstance().getText(
0785:                                                        "Erreur_!"),
0786:                                                JOptionPane.ERROR_MESSAGE);
0787:                            }
0788:                        } else {
0789:                            JOptionPane
0790:                                    .showMessageDialog(
0791:                                            ExecutionView.this ,
0792:                                            Language
0793:                                                    .getInstance()
0794:                                                    .getText(
0795:                                                            "Impossible_de_récupérer_le_fichier_depuis_la_base."),
0796:                                            Language.getInstance().getText(
0797:                                                    "Erreur_!"),
0798:                                            JOptionPane.ERROR_MESSAGE);
0799:                        }
0800:                    } catch (Exception ex) {
0801:                        JOptionPane
0802:                                .showMessageDialog(
0803:                                        ExecutionView.this ,
0804:                                        Language
0805:                                                .getInstance()
0806:                                                .getText(
0807:                                                        "Erreur_pour_lancer_l'éditeur_de_script_:_\n")
0808:                                                + ex.getMessage(), Language
0809:                                                .getInstance().getText(
0810:                                                        "Erreur_!"),
0811:                                        JOptionPane.ERROR_MESSAGE);
0812:                    }
0813:
0814:                    try {
0815:                        Cursor c = new Cursor(Cursor.DEFAULT_CURSOR);
0816:                        ExecutionView.this .setCursor(c);
0817:                    } catch (Exception ee) {
0818:                        ee.printStackTrace();
0819:                    }
0820:                    //commitMenu.setEnabled(true);
0821:                    if (type.equals(PRE_SCRIPT)) {
0822:                        commitInitScriptItem.setEnabled(true);
0823:                        commitPostScriptItem.setEnabled(false);
0824:                        modifyPreScriptMap.put(exec, new Boolean(true));
0825:                    } else {
0826:                        commitPostScriptItem.setEnabled(true);
0827:                        commitInitScriptItem.setEnabled(false);
0828:                        modifyPostScriptMap.put(exec, new Boolean(true));
0829:                    }
0830:
0831:                }
0832:            }
0833:
0834:            private void commitScript(String type) {
0835:                if (Api.isConnected()) {
0836:                    int selectedRow = executionTable.getSelectedRow();
0837:                    if (selectedRow != -1) {
0838:                        Execution exec = DataModel.getCurrentCampaign()
0839:                                .getExecutionFromModel(
0840:                                        (String) executionTable.getModel()
0841:                                                .getValueAt(selectedRow, 1));
0842:                        int transNumber = -1;
0843:                        try {
0844:                            // BdD
0845:                            transNumber = Api.beginTransaction(10,
0846:                                    ApiConstants.UPDATE_ATTACHMENT);
0847:                            //Date date = new Date(importFile.lastModified());
0848:                            /*ConnectionData.getCampTestUpdate().updateScriptForExecution(DataModel.getCurrentCampaign().getName(), exec.getName(), type, importFile.getAbsolutePath());
0849:                             ConnectionData.getCampTestUpdate().updateScriptDateForExecution(DataModel.getCurrentCampaign().getName(), exec.getName(), type, importFile.getName(), date);
0850:                             ConnectionData.getCampTestUpdate().updateScriptLengthForExecution(DataModel.getCurrentCampaign().getName(), exec.getName(), type, importFile.getName(), importFile.length());*/
0851:                            if (type.equals(PRE_SCRIPT)) {
0852:                                Script initScript = exec
0853:                                        .getPreScriptFromModel();
0854:                                initScript.updateInDB(importFile);
0855:                                /*initScript.updateContentInDB(importFile.getAbsolutePath());
0856:                                 initScript.updateDateInDB(date);
0857:                                 initScript.updateLengthInDB(importFile.length());
0858:                                 */
0859:                            } else {
0860:                                Script postScript = exec
0861:                                        .getPostScriptFromModel();
0862:                                postScript.updateInDB(importFile);
0863:                                /*postScript.updateContentInDB(importFile.getAbsolutePath());
0864:                                 postScript.updateDateInDB(date);
0865:                                 postScript.updateLengthInDB(importFile.length());
0866:                                 */
0867:                            }
0868:                            Api.commitTrans(transNumber);
0869:                            transNumber = -1;
0870:                            // IHM
0871:                            if (type.equals(PRE_SCRIPT)) {
0872:                                modifyPreScriptMap
0873:                                        .put(exec, new Boolean(false));
0874:                                commitInitScriptItem.setEnabled(false);
0875:
0876:                            } else {
0877:                                modifyPostScriptMap.put(exec,
0878:                                        new Boolean(false));
0879:                                commitPostScriptItem.setEnabled(false);
0880:
0881:                            }
0882:
0883:                            JOptionPane
0884:                                    .showMessageDialog(
0885:                                            ExecutionView.this ,
0886:                                            Language
0887:                                                    .getInstance()
0888:                                                    .getText(
0889:                                                            "Le_fichier_a_été_correctement_archivé."),
0890:                                            Language.getInstance().getText(
0891:                                                    "Info..."),
0892:                                            JOptionPane.INFORMATION_MESSAGE);
0893:                            //}
0894:                        } catch (FileNotFoundException fe) {
0895:                            fe.printStackTrace();
0896:                            Api.forceRollBackTrans(transNumber);
0897:                            JOptionPane
0898:                                    .showMessageDialog(
0899:                                            ExecutionView.this ,
0900:                                            Language
0901:                                                    .getInstance()
0902:                                                    .getText(
0903:                                                            "Impossible_de_trouver_le_fichier!\n_Vous_pouvez_l'importer_en_cliquant_sur_le_bouton_\"Modifier\""),
0904:                                            Language.getInstance().getText(
0905:                                                    "Erreur_!"),
0906:                                            JOptionPane.ERROR_MESSAGE);
0907:                        } catch (Exception exception) {
0908:                            Api.forceRollBackTrans(transNumber);
0909:                            Tools.ihmExceptionView(exception);
0910:                        }
0911:
0912:                    }
0913:                } else {
0914:                    JOptionPane
0915:                            .showMessageDialog(
0916:                                    ExecutionView.this ,
0917:                                    Language
0918:                                            .getInstance()
0919:                                            .getText(
0920:                                                    "Impossible_!\nVous_n'êtes_pas_connecté_à_la_base."),
0921:                                    Language.getInstance().getText("Erreur_!"),
0922:                                    JOptionPane.ERROR_MESSAGE);
0923:                }
0924:
0925:            }
0926:
0927:            public void actionPerformed(ActionEvent e) {
0928:                Object source = e.getSource();
0929:                if (source.equals(addExecution)) {
0930:                    addExecutionPerformed(e);
0931:                } else if (source.equals(launchExecution)) {
0932:                    launchExecutionPerformed(e);
0933:                } else if (source.equals(resultExecution)) {
0934:                    resultExecutionPerformed(e);
0935:                } else if (source.equals(modifyExecutionButton)) {
0936:                    modifyExecutionPerformed(e);
0937:                } else if (source.equals(deleteExecution)) {
0938:                    deleteExecutionPerformed(e);
0939:                } else if (source.equals(deleteExecutionResult)) {
0940:                    deleteExecutionResultPerformed(e);
0941:                } else if (source.equals(continueExecution)) {
0942:                    continueExecutionPerformed(e, forModif);
0943:                } else if (source.equals(relancerExecution)) {
0944:                    reloadExecutionPerformed(e);
0945:                } else if (source.equals(attachExecutionButton)) {
0946:                    attachExecutionPerformed(e);
0947:                } else if (source.equals(attachExecutionResultButton)) {
0948:                    attachExecutionResultPerformed(e);
0949:                } else if (source.equals(initScriptItem)) {
0950:                    modifyinitScriptPerformed(e);
0951:                } else if (source.equals(postScriptItem)) {
0952:                    modifypostScriptPerformed(e);
0953:                } else if (source.equals(commitPostScriptItem)) {
0954:                    commitPostScriptPerformed(e);
0955:                } else if (source.equals(commitInitScriptItem)) {
0956:                    commitInitScriptPerformed(e);
0957:                } else if (source.equals(setUpPostEngineItem)) {
0958:                    setUpEnginePerformed(e, POST_SCRIPT);
0959:                } else if (source.equals(setUpPreEngineItem)) {
0960:                    setUpEnginePerformed(e, PRE_SCRIPT);
0961:                } else if (source.equals(defectResultExecution)) {
0962:                    defectResultExecutionPerformed(e);
0963:                }
0964:            }
0965:
0966:            void defectResultExecutionPerformed(ActionEvent e) {
0967:                new AnomalieDialog();
0968:            }
0969:
0970:            public void setUpEnginePerformed(ActionEvent e, String type) {
0971:                Script pScript = null;
0972:                int selectedRow = executionTable.getSelectedRow();
0973:                Execution exec;
0974:                if (selectedRow != -1) {
0975:                    exec = DataModel.getCurrentCampaign()
0976:                            .getExecutionFromModel(
0977:                                    (String) executionTable.getModel()
0978:                                            .getValueAt(selectedRow, 1));
0979:
0980:                } else {
0981:                    return;
0982:                }
0983:
0984:                if (type.equals(PRE_SCRIPT)) {
0985:                    pScript = exec.getPreScriptFromModel();
0986:                } else {
0987:                    pScript = exec.getPostScriptFromModel();
0988:                }
0989:                ScriptEngine pEngine = pScript
0990:                        .getScriptEngine((Extension) SalomeTMFContext
0991:                                .getInstance().associatedExtension.get(pScript
0992:                                .getScriptExtensionFromModel()),
0993:                                SalomeTMFContext.getInstance().urlSalome,
0994:                                SalomeTMFContext.getInstance().jpf);
0995:                if (pEngine != null) {
0996:                    String oldplugArg = pScript.getPlugArgFromModel();
0997:                    String plugArg = pEngine.modifyEngineAgument(pScript);
0998:                    if (oldplugArg.equals(plugArg)) {
0999:                        return;
1000:                    }
1001:                    try {
1002:                        pScript.updatePlugArgInDBAndModel(plugArg);
1003:                        JOptionPane
1004:                                .showMessageDialog(
1005:                                        ExecutionView.this ,
1006:                                        Language
1007:                                                .getInstance()
1008:                                                .getText(
1009:                                                        "Le_fichier_a_été_correctement_archivé."),
1010:                                        Language.getInstance().getText(
1011:                                                "Info..."),
1012:                                        JOptionPane.INFORMATION_MESSAGE);
1013:                    } catch (Exception exception) {
1014:                        exception.printStackTrace();
1015:                        pScript.updatePlugArgInModel(oldplugArg);
1016:                        Tools.ihmExceptionView(exception);
1017:                    }
1018:                } else {
1019:                    JOptionPane
1020:                            .showMessageDialog(
1021:                                    ExecutionView.this ,
1022:                                    Language
1023:                                            .getInstance()
1024:                                            .getText(
1025:                                                    "Impossible_d'initialiser_le_plugin_du_scrit"),
1026:                                    Language.getInstance().getText("Erreur_!"),
1027:                                    JOptionPane.ERROR_MESSAGE);
1028:                }
1029:            }
1030:
1031:            public void addExecutionPerformed(ActionEvent e) {
1032:                if (DataModel.getCurrentCampaign().getTestListFromModel()
1033:                        .size() == 0) {
1034:                    JOptionPane
1035:                            .showMessageDialog(
1036:                                    ExecutionView.this ,
1037:                                    Language
1038:                                            .getInstance()
1039:                                            .getText(
1040:                                                    "Vous_ne_pouvez_pas_créer_d'exécution_pour_cette_campagne_car_elle_ne_contient_aucun_test_!"),
1041:                                    Language.getInstance().getText("Erreur..."),
1042:                                    JOptionPane.ERROR_MESSAGE);
1043:                } else {
1044:
1045:                    AskNewExecution askNewExecution = new AskNewExecution(null);
1046:                    if (askNewExecution.getExecution() != null) {
1047:                        try {
1048:
1049:                            // BdD 
1050:                            Execution exec = askNewExecution.getExecution();
1051:                            //exec.addInBDAndModel(DataModel.getCurrentUser(), DataModel.getCurrentCampaign(), askNewExecution.getInitScriptFile(), askNewExecution.getRestitutionScriptFile());
1052:                            DataModel
1053:                                    .getCurrentCampaign()
1054:                                    .addExecutionInDBAndModel(
1055:                                            exec,
1056:                                            DataModel.getCurrentUser(),
1057:                                            askNewExecution.getInitScriptFile(),
1058:                                            askNewExecution
1059:                                                    .getRestitutionScriptFile());
1060:
1061:                            // IHM
1062:                            ArrayList executionData = new ArrayList();
1063:                            executionData.add(new Boolean(false));
1064:                            executionData.add(askNewExecution.getExecution()
1065:                                    .getNameFromModel());
1066:                            executionData.add(askNewExecution.getExecution()
1067:                                    .getEnvironmentFromModel());
1068:                            executionData.add(askNewExecution.getExecution()
1069:                                    .getDataSetFromModel());
1070:                            executionData.add(askNewExecution.getExecution()
1071:                                    .getCreationDateFromModel());
1072:                            executionData.add(askNewExecution.getExecution()
1073:                                    .getAttachmentMapFromModel().keySet());
1074:                            executionData.add("");
1075:                            DataModel.getExecutionTableModel().addRow(
1076:                                    executionData);
1077:                            executionTable.getColumnModel().getColumn(0)
1078:                                    .setMaxWidth(18);
1079:
1080:                        } catch (Exception exception) {
1081:                            exception.printStackTrace();
1082:                            Tools.ihmExceptionView(exception);
1083:                        }
1084:                    }
1085:                }
1086:            }
1087:
1088:            public void launchExecutionPerformed(ActionEvent e) {
1089:                if (DataModel.getCurrentCampaign() != null) {
1090:                    try {
1091:                        if (!DataModel.getCurrentCampaign().isValideModel()) {
1092:                            SalomeTMFContext.getInstance().showMessage(
1093:                                    Language.getInstance().getText(
1094:                                            "Update_data"),
1095:                                    Language.getInstance().getText("Erreur_!"),
1096:                                    JOptionPane.ERROR_MESSAGE);
1097:                            return;
1098:                        }
1099:                    } catch (Exception e1) {
1100:                        Tools.ihmExceptionView(e1);
1101:                        SalomeTMFContext.getInstance().showMessage(
1102:                                Language.getInstance().getText("Update_data"),
1103:                                Language.getInstance().getText("Erreur_!"),
1104:                                JOptionPane.ERROR_MESSAGE);
1105:                        return;
1106:                    }
1107:
1108:                    if (DataModel.getCurrentCampaign().getTestListFromModel()
1109:                            .size() > 0) {
1110:                        DataModel.getSelectedExecution().clear();
1111:                        for (int k = 0; k < DataModel.getExecutionTableModel()
1112:                                .getRowCount(); k++) {
1113:                            if (((Boolean) sorter.getValueAt(k, 0))
1114:                                    .booleanValue()) {
1115:                                DataModel.addSelectedExecution(DataModel
1116:                                        .getCurrentCampaign()
1117:                                        .getExecutionFromModel(
1118:                                                (String) sorter
1119:                                                        .getValueAt(k, 1)));
1120:                            }
1121:                        }
1122:
1123:                        ArrayList pListExec = DataModel.getSelectedExecution();
1124:                        try {
1125:                            int nbExec = pListExec.size();
1126:                            for (int i = 0; i < nbExec; i++) {
1127:                                Execution pExec = (Execution) pListExec.get(i);
1128:                                if (!pExec.isValideModel()) {
1129:                                    SalomeTMFContext.getInstance().showMessage(
1130:                                            Language.getInstance().getText(
1131:                                                    "Update_data"),
1132:                                            Language.getInstance().getText(
1133:                                                    "Erreur_!"),
1134:                                            JOptionPane.ERROR_MESSAGE);
1135:                                    return;
1136:                                }
1137:                            }
1138:                        } catch (Exception e1) {
1139:                            e1.printStackTrace();
1140:                            Tools.ihmExceptionView(e1);
1141:                            SalomeTMFContext.getInstance().showMessage(
1142:                                    Language.getInstance().getText(
1143:                                            "Update_data"),
1144:                                    Language.getInstance().getText("Erreur_!"),
1145:                                    JOptionPane.ERROR_MESSAGE);
1146:                            return;
1147:                        }
1148:                        OptionExecDialog pOptionExecDialog = new OptionExecDialog(
1149:                                SalomeTMFContext.getInstance().getSalomeFrame(),
1150:                                false, false, true);
1151:                        if (pOptionExecDialog.isOkSelected()) {
1152:                            TestMethods.runExecution(DataModel
1153:                                    .getSelectedExecution(), this , false,
1154:                                    pOptionExecDialog.isAssignedTestSelected());
1155:                        }
1156:                    } else {
1157:                        JOptionPane
1158:                                .showMessageDialog(
1159:                                        ExecutionView.this ,
1160:                                        Language
1161:                                                .getInstance()
1162:                                                .getText(
1163:                                                        "Il_n'y_a_aucun_test_dans_la_campagne_!"),
1164:                                        Language.getInstance().getText(
1165:                                                "Attention_!"),
1166:                                        JOptionPane.WARNING_MESSAGE);
1167:                    }
1168:                }
1169:                /*
1170:                 if (DataModel.getCurrentCampaign() != null) {
1171:                 // La campagne doit contenir au moins un test
1172:                  if (DataModel.getCurrentCampaign().getTestList().size() > 0) {
1173:                  // L'ex?cution affich?e ? l'?cran
1174:                   //int selectedRowIndex = executionTable.getSelectedRow();
1175:                    // Mise ? jour de la liste des ex?cutions ? jouer
1176:                     DataModel.getSelectedExecution().clear();
1177:                     
1178:                     for (int k = 0; k < DataModel.getExecutionTableModel().getRowCount(); k++) {
1179:                     if (((Boolean)sorter.getValueAt(k,0)).booleanValue()) {
1180:                     //DataModel.addSelectedExecution(DataModel.getCurrentCampaign().getExecution(k));
1181:                      DataModel.addSelectedExecution(DataModel.getCurrentCampaign().getExecution((String)sorter.getValueAt(k,1)));
1182:                      }
1183:                      }
1184:                      // il doit y avoir au moins une ex?cution s?lectionn?e
1185:                       if (DataModel.getSelectedExecution().size() > 0) {
1186:                       // table des attachements ? supprimer
1187:                        HashMap attachToBeSuppress = new HashMap();
1188:                        String message = "";
1189:                        for (int i = 0;  i < DataModel.getSelectedExecution().size(); i ++) { // FOR 1
1190:                        HashSet setOfParam = new HashSet();
1191:                        // R?cup?ration de tous les param?tres de la campagne
1192:                         for (int k = 0; k < DataModel.getCurrentCampaign().getTestList().size(); k++) {
1193:                         Test test = (Test)DataModel.getCurrentCampaign().getTestList().get(k);
1194:                         for (int j = 0; j < test.getParameterList().size(); j++) {
1195:                         setOfParam.add(test.getParameterList().get(j));
1196:                         }
1197:                         }
1198:                         // On v?rifie que tous les param?tres ont une valuation;
1199:                          ArrayList notValuedParamList = new ArrayList();
1200:                          message = TestMethods.notValuedParamListInDataSet(setOfParam, ((Execution)DataModel.getSelectedExecution().get(i)).getDataSet(), notValuedParamList);
1201:                          if (notValuedParamList.size() > 0) {
1202:                          message = "Les paramêtres :\n" + message + "de l'exécution <" +  ((Execution)DataModel.getSelectedExecution().get(i)).getName() + "> ne sont pas valués.";
1203:                          }
1204:                          }
1205:                          if (!message.equals("")) {
1206:                          JOptionPane.showMessageDialog(ExecutionView.this,
1207:                          "Attention !\n" + message,
1208:                          "Attention !",
1209:                          JOptionPane.INFORMATION_MESSAGE);
1210:                          }
1211:                          
1212:                          CallExecThread precCallExecThread = null;
1213:                          // on parcourt la liste des ex?cutions s?lectionn?es
1214:                           //for (int i = 0;  i < DataModel.getSelectedExecution().size(); i ++) { // FOR 1
1215:                            for (int i = DataModel.getSelectedExecution().size()-1; i >= 0 ; i --) { // FOR 1
1216:                            
1217:                            // Execution courante
1218:                             Execution exec = (Execution)DataModel.getSelectedExecution().get(i);
1219:                             Api.log(">>>>EXEC LANCEE = " + exec.getName());
1220:                             // R?sultat d'ex?cution final
1221:                              ExecutionResult finalExecResult = new ExecutionResult();
1222:                              finalExecResult.setNumberOfFail(0);
1223:                              finalExecResult.setNumberOfSuccess(0);
1224:                              finalExecResult.setNumberOfUnknow(0);
1225:                              finalExecResult.setName(exec.getName() + "_" + exec.getExecutionResultList().size());
1226:                              finalExecResult.setExecutionDate(new Date(GregorianCalendar.getInstance().getTimeInMillis()));
1227:                              finalExecResult.setTester(DataModel.getCurrentUser().getLastName() + " " + DataModel.getCurrentUser().getFirstName());
1228:                              
1229:                              Tools.initExecutionResultMap(DataModel.getCurrentCampaign().getTestList(), finalExecResult, exec.getCampagne());
1230:                              
1231:                              
1232:                              //Liste des r?sultats d'ex?cutions de chaque sous-liste
1233:                               // Liste des tests group?s en sous-listes (manuels/automatiques)
1234:                                Vector pAllTestToExecute = new Vector();
1235:                                ArrayList splittedListOfTest = Tools.getListOfTestManualOrAutomatic(DataModel.getCurrentCampaign().getTestList(), null, pAllTestToExecute);
1236:                                // ADD
1237:                                 //automatic_finished = false;
1238:                                  Vector listExec = new Vector();
1239:                                  //END ADD
1240:                                   // On parcourt la liste des sous-listes
1241:                                    for (int h =0; h < splittedListOfTest.size(); h++) {
1242:                                    if (((ArrayList)splittedListOfTest.get(h)).get(0) instanceof ManualTest) {
1243:                                    // Sous liste de tests manuels
1244:                                     listExec.add(new ManualExecution((ArrayList)splittedListOfTest.get(h), exec, finalExecResult));
1245:                                     
1246:                                     } else {
1247:                                     //Sous liste de tests automatiques
1248:                                      ArrayList automaticTestList = (ArrayList)splittedListOfTest.get(h);
1249:                                      listExec.add(new AutomaticExecution(automaticTestList, exec, finalExecResult));
1250:                                      }
1251:                                      }
1252:                                      //ADD
1253:                                       //precCallExecThread = new callExecThread(listExec, exec, splittedListOfTest, selectedRowIndex, attachToBeSuppress, true, finalExecResult, precCallExecThread, pAllTestToExecute.toArray());
1254:                                        precCallExecThread = new CallExecThread(listExec, exec, splittedListOfTest, true, finalExecResult, precCallExecThread, pAllTestToExecute.toArray(), this, false);
1255:                                        
1256:                                        //precCallExecThread.start();
1257:                                         // lancer le thread
1258:                                          //
1259:                                           } // FIN FOR 1
1260:                                           precCallExecThread.start();
1261:                                           } else {
1262:                                           JOptionPane.showMessageDialog(ExecutionView.this,
1263:                                           "Vous devez sélectionner au moins une exécution...",
1264:                                           "Attention !",
1265:                                           JOptionPane.WARNING_MESSAGE);
1266:                                           }
1267:                                           } else {
1268:                                           JOptionPane.showMessageDialog(ExecutionView.this,
1269:                                           "Il n'y a aucun test dans la campagne !",
1270:                                           "Attention !",
1271:                                           JOptionPane.WARNING_MESSAGE);
1272:                                           }
1273:                                           }*/
1274:            }
1275:
1276:            public void resultExecutionPerformed(ActionEvent e) {
1277:                int detailsSelectedRowIndex = detailsExecutionTable
1278:                        .getSelectedRow();
1279:                int execSelectedRowIndex = executionTable.getSelectedRow();
1280:                if (execSelectedRowIndex != -1 && detailsSelectedRowIndex != -1) {
1281:                    new ExecutionResultView(DataModel
1282:                            .getObservedExecutionResult().getNameFromModel(),
1283:                            DataModel.getObservedExecutionResult());
1284:                }
1285:            }
1286:
1287:            public void modifyExecutionPerformed(ActionEvent e) {
1288:                int selectedIndex = executionTable.getSelectedRow();
1289:                if (selectedIndex != -1) {
1290:                    Execution exec = DataModel.getCurrentCampaign()
1291:                            .getExecutionFromModel(
1292:                                    (String) executionTable.getModel()
1293:                                            .getValueAt(selectedIndex, 1));
1294:                    // Conservation des anciennes valeurs
1295:
1296:                    /*HashMap oldAttachMap = new HashMap();
1297:                     Set keysSetOld = exec.getAttachmentMapFromModel().keySet();
1298:                     for (Iterator iter = keysSetOld.iterator(); iter.hasNext();) {
1299:                     Object elem = iter.next();
1300:                     oldAttachMap.put(elem, exec.getAttachmentMapFromModel().get(elem));
1301:                     }*/
1302:
1303:                    HashMap oldAttachMap = exec
1304:                            .getCopyOfAttachmentMapFromModel();
1305:
1306:                    Script oldInitScript = exec.getPreScriptFromModel();
1307:                    Script oldPostScript = exec.getPostScriptFromModel();
1308:                    String oldExecName = exec.getNameFromModel();
1309:                    if (exec.getExecutionResultListFromModel().size() != 0) {
1310:                        JOptionPane
1311:                                .showMessageDialog(
1312:                                        ExecutionView.this ,
1313:                                        Language
1314:                                                .getInstance()
1315:                                                .getText(
1316:                                                        "Cette_exécution_possède_des_résultats.\n")
1317:                                                + Language
1318:                                                        .getInstance()
1319:                                                        .getText(
1320:                                                                "Vous_ne_pourrez_modifier_que_ses_attachements!"),
1321:                                        Language.getInstance().getText(
1322:                                                "Avertissement_!"),
1323:                                        JOptionPane.WARNING_MESSAGE);
1324:                    }
1325:                    AskNewExecution askNewExecution = new AskNewExecution(exec);
1326:                    if (oldInitScript == null) {
1327:                        initScriptItem.setEnabled(false);
1328:                        setUpPreEngineItem.setEnabled(false);
1329:                        //commitInitScriptItem.setEnabled(false);
1330:                    } else {
1331:                        initScriptItem.setEnabled(true);
1332:                        setUpPreEngineItem.setEnabled(true);
1333:                    }
1334:
1335:                    if (oldPostScript == null) {
1336:                        postScriptItem.setEnabled(false);
1337:                        setUpPostEngineItem.setEnabled(false);
1338:                        //commitPostScriptItem.setEnabled(false);
1339:                    } else {
1340:                        postScriptItem.setEnabled(true);
1341:                        setUpPostEngineItem.setEnabled(true);
1342:                    }
1343:                    if (askNewExecution.getExecution() != null) {
1344:                        Execution pExec = askNewExecution.getExecution();
1345:                        int transNumber = -1;
1346:                        try {
1347:
1348:                            // BdD
1349:                            transNumber = Api.beginTransaction(10,
1350:                                    ApiConstants.UPDATE_EXECUTION);
1351:                            String newName = pExec.getNameFromModel();
1352:                            pExec.updateNameInModel(oldExecName);
1353:                            pExec.updateNameInDBAndModel(newName);
1354:                            pExec.updateDatasetInDBAndModel(pExec
1355:                                    .getDataSetFromModel());
1356:                            pExec.updateEnvInDBAndModel(pExec
1357:                                    .getEnvironmentFromModel());
1358:                            if (pExec.getPreScriptFromModel() != null) {
1359:                                if (!pExec.getPreScriptFromModel().equals(
1360:                                        oldInitScript)) {
1361:                                    if (oldInitScript != null) {
1362:                                        //pExec.deleteScriptFromDB(oldInitScript.getNameFromModel(), PRE_SCRIPT);
1363:                                        pExec.deleteScriptInDB(PRE_SCRIPT);
1364:                                    }
1365:                                    //pExec.addPreScriptInBddAndModel(pExec.getPreScriptFromModel(),askNewExecution.getInitScriptFile());
1366:                                    pExec
1367:                                            .addPreScriptInDBAndModel(
1368:                                                    pExec
1369:                                                            .getPreScriptFromModel(),
1370:                                                    askNewExecution
1371:                                                            .getInitScriptFile());
1372:                                    initScriptItem.setEnabled(true);
1373:                                    setUpPreEngineItem.setEnabled(true);
1374:                                }
1375:                            } else if (oldInitScript != null) {
1376:                                //pExec.deleteScriptFromDB(oldInitScript.getNameFromModel(), PRE_SCRIPT);
1377:                                pExec.deleteScriptInDB(PRE_SCRIPT);
1378:                                initScriptItem.setEnabled(false);
1379:                                setUpPreEngineItem.setEnabled(false);
1380:                            }
1381:                            if (askNewExecution.getExecution()
1382:                                    .getPostScriptFromModel() != null) {
1383:                                if (!pExec.getPostScriptFromModel().equals(
1384:                                        oldPostScript)) {
1385:                                    if (oldPostScript != null) {
1386:                                        //pExec.deleteScriptFromDB(oldPostScript.getNameFromModel(), POST_SCRIPT);
1387:                                        pExec.deleteScriptInDB(POST_SCRIPT);
1388:                                    }
1389:                                    //pExec.addPostScriptInBddAndModel(pExec.getPostScriptFromModel(), askNewExecution.getRestitutionScriptFile());
1390:                                    pExec
1391:                                            .addPreScriptInDBAndModel(
1392:                                                    pExec
1393:                                                            .getPostScriptFromModel(),
1394:                                                    askNewExecution
1395:                                                            .getRestitutionScriptFile());
1396:                                    postScriptItem.setEnabled(true);
1397:                                    setUpPostEngineItem.setEnabled(true);
1398:                                }
1399:                            } else if (oldPostScript != null) {
1400:                                //pExec.deleteScriptFromDB(oldPostScript.getNameFromModel(), POST_SCRIPT);
1401:                                pExec.deleteScriptInDB(POST_SCRIPT);
1402:                                postScriptItem.setEnabled(false);
1403:                                setUpPostEngineItem.setEnabled(false);
1404:                            }
1405:
1406:                            /* Les attachement */
1407:                            pExec.updateAttachement(oldAttachMap);
1408:
1409:                            Api.commitTrans(transNumber);
1410:                            transNumber = -1;
1411:                            // IHM
1412:                            if (!initScriptItem.isEnabled()
1413:                                    && !postScriptItem.isEnabled()) {
1414:                                modifyScriptMenu.setEnabled(false);
1415:                            } else {
1416:                                modifyScriptMenu.setEnabled(true);
1417:                            }
1418:                            executionTable.getModel().setValueAt(
1419:                                    pExec.getNameFromModel(), selectedIndex, 1);
1420:                            executionTable.getModel().setValueAt(
1421:                                    pExec.getEnvironmentFromModel(),
1422:                                    selectedIndex, 2);
1423:                            executionTable.getModel().setValueAt(
1424:                                    pExec.getDataSetFromModel(), selectedIndex,
1425:                                    3);
1426:                            executionTable.getModel().setValueAt(
1427:                                    pExec.getCreationDateFromModel(),
1428:                                    selectedIndex, 4);
1429:                            executionTable.getModel().setValueAt(
1430:                                    pExec.getAttachmentMapFromModel().keySet(),
1431:                                    selectedIndex, 5);
1432:                            executionTable.getColumnModel().getColumn(0)
1433:                                    .setMaxWidth(18);
1434:                        } catch (Exception exception) {
1435:                            exception.printStackTrace();
1436:                            Api.forceRollBackTrans(transNumber);
1437:                            Tools.ihmExceptionView(exception);
1438:                        }
1439:
1440:                    } else {
1441:                        /* Annulation de la modif */
1442:                        exec.setAttachmentMapInModel(oldAttachMap);
1443:                    }
1444:                    commitPostScriptItem.setEnabled(false);
1445:                    commitInitScriptItem.setEnabled(false);
1446:                } // if selecetd
1447:            }
1448:
1449:            public void deleteExecutionPerformed(ActionEvent e) {
1450:                //int selectedRowIndex = executionTable.getSelectedRow();
1451:                int[] selectedRows = executionTable.getSelectedRows();
1452:                Object[] options = { Language.getInstance().getText("Oui"),
1453:                        Language.getInstance().getText("Non") };
1454:                int choice = JOptionPane
1455:                        .showOptionDialog(
1456:                                ExecutionView.this ,
1457:                                Language
1458:                                        .getInstance()
1459:                                        .getText(
1460:                                                "Etes_vous_sûr_de_vouloir_supprimer_toutes_les_exécutions_sélectionnées_?"),
1461:                                Language.getInstance().getText("Attention_!"),
1462:                                JOptionPane.YES_NO_OPTION,
1463:                                JOptionPane.QUESTION_MESSAGE, null, options,
1464:                                options[1]);
1465:                if (choice == JOptionPane.YES_OPTION) {
1466:                    //if (selectedRowIndex != -1) {
1467:                    for (int selectedRowIndex = selectedRows.length - 1; selectedRowIndex >= 0; selectedRowIndex--) {
1468:                        //Execution exec = DataModel.getObservedExecution();
1469:                        //Execution exec = DataModel.getCurrentCampaign().getExecution((String)sorter.getValueAt(selectedRowIndex, 1));
1470:                        Execution exec = DataModel.getCurrentCampaign()
1471:                                .getExecutionFromModel(
1472:                                        (String) sorter.getValueAt(
1473:                                                selectedRows[selectedRowIndex],
1474:                                                1));
1475:                        if (exec != null) {
1476:                            try {
1477:                                // BdD
1478:                                DataModel.getCurrentCampaign()
1479:                                        .deleteExecutionInDBAndModel(exec);
1480:                                //exec.deleteInBddAndModel();
1481:
1482:                                // IHM
1483:                                DataModel
1484:                                        .getExecutionTableModel()
1485:                                        .removeData(
1486:                                                sorter
1487:                                                        .modelIndex(selectedRows[selectedRowIndex]));
1488:                                executionTable.getColumnModel().getColumn(0)
1489:                                        .setMaxWidth(18);
1490:                                DataModel.getExecutionResultTableModel()
1491:                                        .clearTable();
1492:
1493:                            } catch (Exception exception) {
1494:                                exception.printStackTrace();
1495:                                Tools.ihmExceptionView(exception);
1496:                            }
1497:
1498:                        }
1499:                    }
1500:                }
1501:            }
1502:
1503:            public void deleteExecutionResultPerformed(ActionEvent e) {
1504:                //int selectedRowIndex = detailsExecutionTable.getSelectedRow();
1505:                int[] selectedRows = detailsExecutionTable.getSelectedRows();
1506:                Object[] options = { Language.getInstance().getText("Oui"),
1507:                        Language.getInstance().getText("Non") };
1508:                int choice = JOptionPane
1509:                        .showOptionDialog(
1510:                                ExecutionView.this ,
1511:                                Language
1512:                                        .getInstance()
1513:                                        .getText(
1514:                                                "Etes_vous_sûr_de_vouloir_supprimer_tous_les_résultats_d'exécution_sélectionnés_?"),
1515:                                Language.getInstance().getText("Attention_!"),
1516:                                JOptionPane.YES_NO_OPTION,
1517:                                JOptionPane.QUESTION_MESSAGE, null, options,
1518:                                options[1]);
1519:                if (choice == JOptionPane.YES_OPTION) {
1520:                    //if (selectedRowIndex != -1) {
1521:                    for (int selectedRowIndex = selectedRows.length - 1; selectedRowIndex >= 0; selectedRowIndex--) {
1522:                        //ExecutionResult execResult = DataModel.getObservedExecutionResult();
1523:                        //ExecutionResult execResult = DataModel.getObservedExecution().getExecutionResult((String)detailsSorter.getValueAt(selectedRowIndex, 0));
1524:                        ExecutionResult execResult = DataModel
1525:                                .getObservedExecution()
1526:                                .getExecutionResultFromModel(
1527:                                        (String) detailsSorter.getValueAt(
1528:                                                selectedRows[selectedRowIndex],
1529:                                                0));
1530:                        if (execResult != null) {
1531:                            try {
1532:                                // BdD
1533:                                DataModel.getObservedExecution()
1534:                                        .deleteExecutionResultInDBAndModel(
1535:                                                execResult);
1536:                                //execResult.deleteFromDB();
1537:
1538:                                // IHM
1539:                                //DataModel.getExecutionResultTableModel().removeData(detailsSorter.modelIndex(selectedRows[selectedRowIndex]));
1540:                                //DataModel.getObservedExecution().removeExecutionResult(execResult);
1541:
1542:                            } catch (Exception exception) {
1543:                                Tools.ihmExceptionView(exception);
1544:                            }
1545:                        }
1546:                    }
1547:                    // IHM
1548:                    DataModel.getExecutionResultTableModel().clearTable();
1549:                    Execution exec = DataModel.getObservedExecution();
1550:                    if (exec == null) {
1551:                        return;
1552:                    }
1553:                    for (int i = 0; i < exec.getExecutionResultListFromModel()
1554:                            .size(); i++) {
1555:                        ArrayList resultList = new ArrayList();
1556:                        resultList.add(((ExecutionResult) exec
1557:                                .getExecutionResultListFromModel().get(i))
1558:                                .getNameFromModel());
1559:                        Util.log("[ExecutionView] try to format : "
1560:                                + ((ExecutionResult) exec
1561:                                        .getExecutionResultListFromModel().get(
1562:                                                i)).getExecutionDateFromModel()
1563:                                        .toString()
1564:                                + "  "
1565:                                + ((ExecutionResult) exec
1566:                                        .getExecutionResultListFromModel().get(
1567:                                                i)).getTimeFromModel()
1568:                                        .toString());
1569:                        SimpleDateFormat formater = new SimpleDateFormat(
1570:                                "dd/MM/yyyy");
1571:                        resultList
1572:                                .add(formater
1573:                                        .format(
1574:                                                ((ExecutionResult) exec
1575:                                                        .getExecutionResultListFromModel()
1576:                                                        .get(i))
1577:                                                        .getExecutionDateFromModel())
1578:                                        .toString()
1579:                                        + "  "
1580:                                        + ((ExecutionResult) exec
1581:                                                .getExecutionResultListFromModel()
1582:                                                .get(i)).getTimeFromModel()
1583:                                                .toString());
1584:                        resultList.add(((ExecutionResult) exec
1585:                                .getExecutionResultListFromModel().get(i))
1586:                                .getTesterFromModel());
1587:                        resultList.add(((ExecutionResult) exec
1588:                                .getExecutionResultListFromModel().get(i))
1589:                                .getExecutionStatusFromModel());
1590:                        resultList.add(((ExecutionResult) exec
1591:                                .getExecutionResultListFromModel().get(i))
1592:                                .getFormatedStatFromModel(Language
1593:                                        .getInstance()
1594:                                        .getText("Initial_SUCCES"),
1595:                                        Language.getInstance().getText(
1596:                                                "Initial_ECHEC"), Language
1597:                                                .getInstance().getText(
1598:                                                        "Initial_INCON")));
1599:
1600:                        DataModel.getExecutionResultTableModel().addRow(
1601:                                resultList);
1602:                    }
1603:                }
1604:            }
1605:
1606:            void reloadExecutionPerformed(ActionEvent e) {
1607:                int detailsSelectedRowIndex = detailsExecutionTable
1608:                        .getSelectedRow();
1609:                //boolean toBeContinued = true;
1610:                if (detailsSelectedRowIndex != -1) {
1611:                    // L'exécution affichée à l'écran
1612:                    // Execution courante
1613:                    Execution exec = DataModel.getObservedExecution();
1614:                    ExecutionResult finalExecResult = DataModel
1615:                            .getObservedExecutionResult();
1616:
1617:                    try {
1618:                        if (exec != null && finalExecResult != null) {
1619:                            Campaign pCamp = exec.getCampagneFromModel();
1620:                            if (finalExecResult.getNbOfTestWithStat() != pCamp
1621:                                    .getTestListFromModel().size()) {
1622:                                SalomeTMFContext.getInstance().showMessage(
1623:                                        Language.getInstance().getText(
1624:                                                "resexec_non_valid"),
1625:                                        Language.getInstance().getText(
1626:                                                "Attention_!"),
1627:                                        JOptionPane.WARNING_MESSAGE);
1628:                                return;
1629:                            }
1630:                        }
1631:                        if (!DataModel.getCurrentCampaign().isValideModel()) {
1632:                            SalomeTMFContext.getInstance().showMessage(
1633:                                    Language.getInstance().getText(
1634:                                            "Update_data"),
1635:                                    Language.getInstance().getText("Erreur_!"),
1636:                                    JOptionPane.ERROR_MESSAGE);
1637:                            return;
1638:                        }
1639:
1640:                        if (!exec.isValideModel()) {
1641:                            SalomeTMFContext.getInstance().showMessage(
1642:                                    Language.getInstance().getText(
1643:                                            "Update_data"),
1644:                                    Language.getInstance().getText("Erreur_!"),
1645:                                    JOptionPane.ERROR_MESSAGE);
1646:                            return;
1647:                        }
1648:                        if (!finalExecResult.existeInBase()) {
1649:                            SalomeTMFContext.getInstance().showMessage(
1650:                                    Language.getInstance().getText(
1651:                                            "Update_data"),
1652:                                    Language.getInstance().getText("Erreur_!"),
1653:                                    JOptionPane.ERROR_MESSAGE);
1654:                            return;
1655:                        }
1656:
1657:                    } catch (Exception e1) {
1658:                        Tools.ihmExceptionView(e1);
1659:                        SalomeTMFContext.getInstance().showMessage(
1660:                                Language.getInstance().getText("Update_data"),
1661:                                Language.getInstance().getText("Erreur_!"),
1662:                                JOptionPane.ERROR_MESSAGE);
1663:                        return;
1664:                    }
1665:
1666:                    if (exec != null && finalExecResult != null) {
1667:                        OptionExecDialog pOptionExecDialog = new OptionExecDialog(
1668:                                SalomeTMFContext.getInstance().getSalomeFrame(),
1669:                                true, false, true);
1670:                        if (pOptionExecDialog.isOkSelected()) {
1671:                            /* Copie the final resul */
1672:                            try {
1673:                                ExecutionResult copy_finalExecResult = finalExecResult
1674:                                        .cloneInDB(
1675:                                                pOptionExecDialog
1676:                                                        .ischeckWithOutSuccesSelected(),
1677:                                                DataModel.getCurrentUser());
1678:                                //Rajouter dans le tableau
1679:                                updateIHMTable(true, exec, copy_finalExecResult);
1680:                                detailsExecutionTable.getSelectedRow();
1681:                                int ligne = detailsExecutionTable.getRowCount() - 1;
1682:                                //System.out.println("--------------------ligne - 1 = " + ligne);
1683:                                if (ligne > -1) {
1684:                                    detailsExecutionTable
1685:                                            .setRowSelectionInterval(ligne,
1686:                                                    ligne);
1687:                                }
1688:
1689:                                TestMethods
1690:                                        .continueExecution(
1691:                                                exec,
1692:                                                copy_finalExecResult,
1693:                                                this ,
1694:                                                false,
1695:                                                true,
1696:                                                pOptionExecDialog
1697:                                                        .isAssignedTestSelected(),
1698:                                                true);
1699:                            } catch (Exception ex) {
1700:                                ex.printStackTrace();
1701:                            }
1702:                        }
1703:                    } else {
1704:                        SalomeTMFContext.getInstance().showMessage(
1705:                                Language.getInstance().getText("Update_data"),
1706:                                Language.getInstance().getText("Erreur_!"),
1707:                                JOptionPane.ERROR_MESSAGE);
1708:                    }
1709:
1710:                }
1711:            }
1712:
1713:            public void continueExecutionPerformed(ActionEvent e,
1714:                    boolean forModif) {
1715:                int detailsSelectedRowIndex = detailsExecutionTable
1716:                        .getSelectedRow();
1717:                //boolean toBeContinued = true;
1718:                if (detailsSelectedRowIndex != -1) {
1719:                    // L'exécution affichée à l'écran
1720:                    // Execution courante
1721:                    Execution exec = DataModel.getObservedExecution();
1722:                    ExecutionResult finalExecResult = DataModel
1723:                            .getObservedExecutionResult();
1724:
1725:                    try {
1726:                        if (exec != null && finalExecResult != null) {
1727:                            //* Si l'execution n'est pas terminé
1728:                            if (!finalExecResult.getExecutionStatusFromModel()
1729:                                    .equals(ApiConstants.INCOMPLETED)) {
1730:                                Campaign pCamp = exec.getCampagneFromModel();
1731:                                if (finalExecResult.getNbOfTestWithStat() != pCamp
1732:                                        .getTestListFromModel().size()) {
1733:                                    SalomeTMFContext.getInstance().showMessage(
1734:                                            Language.getInstance().getText(
1735:                                                    "resexec_non_valid"),
1736:                                            Language.getInstance().getText(
1737:                                                    "Attention_!"),
1738:                                            JOptionPane.WARNING_MESSAGE);
1739:                                    return;
1740:                                }
1741:                            }
1742:                        }
1743:                        if (!DataModel.getCurrentCampaign().isValideModel()) {
1744:                            SalomeTMFContext.getInstance().showMessage(
1745:                                    Language.getInstance().getText(
1746:                                            "Update_data"),
1747:                                    Language.getInstance().getText("Erreur_!"),
1748:                                    JOptionPane.ERROR_MESSAGE);
1749:                            return;
1750:                        }
1751:
1752:                        if (!exec.isValideModel()) {
1753:                            SalomeTMFContext.getInstance().showMessage(
1754:                                    Language.getInstance().getText(
1755:                                            "Update_data"),
1756:                                    Language.getInstance().getText("Erreur_!"),
1757:                                    JOptionPane.ERROR_MESSAGE);
1758:                            return;
1759:                        }
1760:                        if (!finalExecResult.existeInBase()) {
1761:                            SalomeTMFContext.getInstance().showMessage(
1762:                                    Language.getInstance().getText(
1763:                                            "Update_data"),
1764:                                    Language.getInstance().getText("Erreur_!"),
1765:                                    JOptionPane.ERROR_MESSAGE);
1766:                            return;
1767:                        }
1768:
1769:                    } catch (Exception e1) {
1770:                        e1.printStackTrace();
1771:                        Tools.ihmExceptionView(e1);
1772:                        SalomeTMFContext.getInstance().showMessage(
1773:                                Language.getInstance().getText("Update_data"),
1774:                                Language.getInstance().getText("Erreur_!"),
1775:                                JOptionPane.ERROR_MESSAGE);
1776:                        return;
1777:                    }
1778:
1779:                    if (exec != null && finalExecResult != null) {
1780:                        OptionExecDialog pOptionExecDialog = new OptionExecDialog(
1781:                                SalomeTMFContext.getInstance().getSalomeFrame(),
1782:                                false, !forModif, true);
1783:                        if (pOptionExecDialog.isOkSelected()) {
1784:                            TestMethods.continueExecution(exec,
1785:                                    finalExecResult, this , false,
1786:                                    pOptionExecDialog
1787:                                            .isTestWihtoutResSelected(),
1788:                                    pOptionExecDialog.isAssignedTestSelected(),
1789:                                    forModif);
1790:                        }
1791:                    } else {
1792:                        SalomeTMFContext.getInstance().showMessage(
1793:                                Language.getInstance().getText("Update_data"),
1794:                                Language.getInstance().getText("Erreur_!"),
1795:                                JOptionPane.ERROR_MESSAGE);
1796:                    }
1797:
1798:                }
1799:            }
1800:
1801:            public void attachExecutionPerformed(ActionEvent e) {
1802:                HashMap oldMap = DataModel.getObservedExecution()
1803:                        .getCopyOfAttachmentMapFromModel();
1804:
1805:                //AttachmentViewWindow attachViewWindow = new AttachmentViewWindow(SalomeTMF.ptrSalomeTMF, EXECUTION, DataModel.getObservedExecution(), null, null, null);
1806:                AttachmentViewWindow attachViewWindow = new AttachmentViewWindow(
1807:                        SalomeTMFContext.getBaseIHM(), EXECUTION, DataModel
1808:                                .getObservedExecution());
1809:
1810:                if (!attachViewWindow.cancelPerformed) {
1811:                    int transNumber = -1;
1812:                    try {
1813:                        // BdD
1814:                        transNumber = Api.beginTransaction(10,
1815:                                ApiConstants.UPDATE_ATTACHMENT);
1816:                        DataModel.getObservedExecution().updateAttachement(
1817:                                oldMap);
1818:
1819:                        Api.commitTrans(transNumber);
1820:                        transNumber = -1;
1821:                        // IHM
1822:                        sorter.setValueAt(DataModel.getObservedExecution()
1823:                                .getAttachmentMapFromModel().keySet(),
1824:                                executionTable.getSelectedRow(), 5);
1825:
1826:                    } catch (Exception exception) {
1827:                        exception.printStackTrace();
1828:                        Api.forceRollBackTrans(transNumber);
1829:                        DataModel.getObservedExecution()
1830:                                .setAttachmentMapInModel(oldMap);
1831:                        Tools.ihmExceptionView(exception);
1832:                    }
1833:                }
1834:            }
1835:
1836:            public void attachExecutionResultPerformed(ActionEvent e) {
1837:                HashMap oldMap = DataModel.getObservedExecutionResult()
1838:                        .getCopyOfAttachmentMapFromModel();
1839:
1840:                //AttachmentViewWindow attachViewWindow = new AttachmentViewWindow(SalomeTMF.ptrSalomeTMF, EXECUTION_RESULT, DataModel.getObservedExecutionResult(), null ,null, null);
1841:                AttachmentViewWindow attachViewWindow = new AttachmentViewWindow(
1842:                        SalomeTMFContext.getBaseIHM(), EXECUTION_RESULT,
1843:                        DataModel.getObservedExecutionResult());
1844:
1845:                if (!attachViewWindow.cancelPerformed) {
1846:
1847:                    int transNumber = -1;
1848:                    try {
1849:                        // BdD
1850:                        Util
1851:                                .log("[ExecutionView:attachExecutionResultPerformed] : UPDATE_ATTACHMENT IN BDD");
1852:                        transNumber = Api.beginTransaction(10,
1853:                                ApiConstants.UPDATE_ATTACHMENT);
1854:                        DataModel.getObservedExecutionResult()
1855:                                .updateAttachement(oldMap);
1856:
1857:                        Api.commitTrans(transNumber);
1858:                    } catch (Exception exception) {
1859:                        exception.printStackTrace();
1860:                        Api.forceRollBackTrans(transNumber);
1861:                        DataModel.getObservedExecutionResult()
1862:                                .setAttachmentMapInModel(oldMap);
1863:                        Tools.ihmExceptionView(exception);
1864:                    }
1865:                } else {
1866:
1867:                }
1868:            }
1869:
1870:            public void modifyinitScriptPerformed(ActionEvent e) {
1871:                modifyScript(PRE_SCRIPT);
1872:            }
1873:
1874:            public void modifypostScriptPerformed(ActionEvent e) {
1875:                modifyScript(POST_SCRIPT);
1876:            }
1877:
1878:            public void commitInitScriptPerformed(ActionEvent e) {
1879:                commitScript(PRE_SCRIPT);
1880:            }
1881:
1882:            public void commitPostScriptPerformed(ActionEvent e) {
1883:                commitScript(POST_SCRIPT);
1884:            }
1885:
1886:            /*private int findIndexOfExcution(Execution pExec){
1887:            	Util.log("[ExecutionView:findIndexOfExcution] : try to find " + pExec.getNameFromModel() + " in executionTable");
1888:            	int ret = -1;
1889:            	boolean continu = true;
1890:            	int size = executionTable.getModel().getRowCount();
1891:            	int i = 0;
1892:            	while (continu && i < size ){
1893:            		String name = (String) executionTable.getModel().getValueAt(i,1);
1894:            		Util.log("[ExecutionView:findIndexOfExcution] : compare" + pExec.getNameFromModel() + " and " + name);
1895:            		
1896:            		if (name.equals(pExec.getNameFromModel())){
1897:            			ret = i;
1898:            			continu = false;
1899:            		} else {
1900:            			i++;
1901:            		}
1902:            	}
1903:            	return ret;
1904:            	
1905:            }*/
1906:
1907:            public void updateIHMTable(boolean newLaunch, Execution exec,
1908:                    ExecutionResult finalExecResult) {
1909:                if (newLaunch) {
1910:                    if (finalExecResult.getTimeFromModel() == null) {
1911:                        finalExecResult.setTimeInModel(new Time(
1912:                                GregorianCalendar.getInstance()
1913:                                        .getTimeInMillis()));
1914:                    }
1915:                    //int selectedRowIndex = findIndexOfExcution(exec);
1916:                    int[] selectedRows = executionTable.getSelectedRows();
1917:                    if (selectedRows.length == 1) {
1918:                        int selectedRowIndex = selectedRows[0];
1919:                        if ((selectedRowIndex != -1)
1920:                                && (exec.getNameFromModel().equals(sorter
1921:                                        .getValueAt(selectedRowIndex, 1)))) {
1922:                            ArrayList resultList = new ArrayList();
1923:                            // la table des r?sultats d'ex?cutions
1924:                            resultList.add(finalExecResult.getNameFromModel());
1925:                            SimpleDateFormat formater = new SimpleDateFormat(
1926:                                    "dd/MM/yyyy");
1927:                            resultList
1928:                                    .add(formater
1929:                                            .format(
1930:                                                    finalExecResult
1931:                                                            .getExecutionDateFromModel())
1932:                                            .toString()
1933:                                            + "  "
1934:                                            + finalExecResult
1935:                                                    .getTimeFromModel()
1936:                                                    .toString());
1937:                            resultList
1938:                                    .add(finalExecResult.getTesterFromModel());
1939:                            resultList.add(finalExecResult
1940:                                    .getExecutionStatusFromModel());
1941:                            resultList.add(finalExecResult
1942:                                    .getFormatedStatFromModel(Language
1943:                                            .getInstance().getText(
1944:                                                    "Initial_SUCCES"), Language
1945:                                            .getInstance().getText(
1946:                                                    "Initial_ECHEC"), Language
1947:                                            .getInstance().getText(
1948:                                                    "Initial_INCON")));
1949:                            DataModel.getExecutionResultTableModel().addRow(
1950:                                    resultList);
1951:                            // La table des ex?cutions
1952:                            sorter.setValueAt(finalExecResult
1953:                                    .getExecutionDateFromModel().toString(),
1954:                                    selectedRowIndex, 6);
1955:                        }
1956:                    }
1957:                } else {
1958:                    detailsSorter.setValueAt(finalExecResult
1959:                            .getTesterFromModel(), detailsExecutionTable
1960:                            .getSelectedRow(), 2);
1961:                    detailsSorter.setValueAt(finalExecResult
1962:                            .getExecutionStatusFromModel(),
1963:                            detailsExecutionTable.getSelectedRow(), 3);
1964:                    detailsSorter.setValueAt(finalExecResult
1965:                            .getFormatedStatFromModel(Language.getInstance()
1966:                                    .getText("Initial_SUCCES"), Language
1967:                                    .getInstance().getText("Initial_ECHEC"),
1968:                                    Language.getInstance().getText(
1969:                                            "Initial_INCON")),
1970:                            detailsExecutionTable.getSelectedRow(), 4);
1971:                }
1972:
1973:                int detailsTableIndex = detailsExecutionTable.getSelectedRow();
1974:                //System.out.println("--------------------detailsTableIndex = " + detailsTableIndex);
1975:                if (detailsTableIndex != -1
1976:                        && finalExecResult.getNameFromModel().equals(
1977:                                detailsSorter.getValueAt(detailsTableIndex, 0))
1978:                        && finalExecResult.getExecutionStatusFromModel()
1979:                                .equals(FINISHED)) {
1980:                    if (Api.isLockExecutedTest()) {
1981:                        continueExecution.setText(Language.getInstance()
1982:                                .getText("Reprendre"));
1983:                        continueExecution.setEnabled(false);
1984:                        relancerExecution.setEnabled(false);
1985:                        forModif = false;
1986:                    } else {
1987:                        //change label
1988:                        continueExecution.setText(Language.getInstance()
1989:                                .getText("Modifier"));
1990:                        continueExecution.setEnabled(true);
1991:                        relancerExecution.setEnabled(true);
1992:                        forModif = true;
1993:                    }
1994:                }
1995:            }
1996:
1997:        } // Fin de la classe ExecutionView
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.