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

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


0001:        /*
0002:         * SalomeTMF is a Test Management Framework
0003:         * Copyright (C) 2005 France Telecom R&D
0004:         *
0005:         * This library is free software; you can redistribute it and/or
0006:         * modify it under the terms of the GNU Lesser General Public
0007:         * License as published by the Free Software Foundation; either
0008:         * version 2 of the License, or (at your option) any later version.
0009:         *
0010:         * This library is distributed in the hope that it will be useful,
0011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013:         * Lesser General Public License for more details.
0014:         *
0015:         * You should have received a copy of the GNU Lesser General Public
0016:         * License along with this library; if not, write to the Free Software
0017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018:         *
0019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
0020:         *
0021:         * Contact: mikael.marche@rd.francetelecom.com
0022:         */
0023:
0024:        package org.objectweb.salome_tmf.ihm;
0025:
0026:        import java.awt.BorderLayout;
0027:        import java.awt.Color;
0028:        import java.awt.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.Date;
0036:        import java.sql.Time;
0037:        import java.text.SimpleDateFormat;
0038:        import java.util.ArrayList;
0039:        import java.util.Collection;
0040:        import java.util.GregorianCalendar;
0041:        import java.util.HashMap;
0042:        import java.util.Hashtable;
0043:        import java.util.Iterator;
0044:        import java.util.Set;
0045:        import java.util.Vector;
0046:
0047:        import javax.swing.BorderFactory;
0048:        import javax.swing.Box;
0049:        import javax.swing.BoxLayout;
0050:        import javax.swing.JButton;
0051:        import javax.swing.JMenu;
0052:        import javax.swing.JMenuBar;
0053:        import javax.swing.JMenuItem;
0054:        import javax.swing.JOptionPane;
0055:        import javax.swing.JPanel;
0056:        import javax.swing.JScrollPane;
0057:        import javax.swing.JTable;
0058:        import javax.swing.ListSelectionModel;
0059:        import javax.swing.event.ListSelectionEvent;
0060:        import javax.swing.event.ListSelectionListener;
0061:
0062:        import org.java.plugin.Extension;
0063:        import org.objectweb.salome_tmf.api.Api;
0064:        import org.objectweb.salome_tmf.api.ApiConstants;
0065:        import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
0066:        import org.objectweb.salome_tmf.data.Attachment;
0067:        import org.objectweb.salome_tmf.data.ConnectionData;
0068:        import org.objectweb.salome_tmf.data.DataConstants;
0069:        import org.objectweb.salome_tmf.data.Execution;
0070:        import org.objectweb.salome_tmf.data.ExecutionResult;
0071:        import org.objectweb.salome_tmf.data.FileAttachment;
0072:        import org.objectweb.salome_tmf.data.ProjectData;
0073:        import org.objectweb.salome_tmf.data.Script;
0074:        import org.objectweb.salome_tmf.data.UrlAttachment;
0075:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
0076:        import org.objectweb.salome_tmf.ihm.datawrapper.TestMethods;
0077:        import org.objectweb.salome_tmf.ihm.languages.Language;
0078:        import org.objectweb.salome_tmf.ihm.models.ExecutionResultMouseListener;
0079:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
0080:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0081:        import org.objectweb.salome_tmf.plugins.core.ScriptEngine;
0082:
0083:        public class ExecutionView extends JPanel implements  ApiConstants,
0084:                DataConstants, ActionListener {
0085:
0086:            /**
0087:             * Table des ex?cutions
0088:             */
0089:            static JTable executionTable;
0090:
0091:            /**
0092:             * Table des d?tails des ex?cutions
0093:             */
0094:            JTable detailsExecutionTable;
0095:
0096:            /**
0097:             * Bouton pour lancer une ex?cution
0098:             */
0099:            static JButton launchExecution;
0100:
0101:            /**
0102:             * Bouton pour avoir le d?tails des r?sultats sur les tests
0103:             */
0104:            JButton resultExecution;
0105:
0106:            /**
0107:             * Bouton pour supprimer une ex?cution
0108:             */
0109:            static JButton deleteExecution;
0110:
0111:            /**
0112:             * Bouton pour modifier une ex?cution
0113:             */
0114:            static JButton modifyExecutionButton;
0115:
0116:            /**
0117:             * Bouton pour supprimer une ex?cution
0118:             */
0119:            static JButton deleteExecutionResult;
0120:
0121:            /**
0122:             * Bouton pour reprendre une ex?cution
0123:             */
0124:            static JButton continueExecution;
0125:
0126:            /**
0127:             * Bouton pour g?rer les attachements d'une ex?cution
0128:             */
0129:            JButton attachExecutionResultButton;
0130:
0131:            /**
0132:             * Bouton pour g?rer les attachements d'un r?sultat d'ex?cution
0133:             */
0134:            JButton attachExecutionButton;
0135:            /**
0136:             * Bouton pour ajouter une nouvelle ex?cution
0137:             */
0138:            static JButton addExecution;
0139:
0140:            /**
0141:             *
0142:             */
0143:            //private boolean automatic_finished;
0144:            static JMenu modifyScriptMenu;
0145:            static JMenuItem initScriptItem;
0146:            static JMenuItem postScriptItem;
0147:            static JMenuItem setUpPreEngineItem;
0148:            static JMenuItem setUpPostEngineItem;
0149:            static JMenuBar modifyScriptMenuBar;
0150:
0151:            //static JMenu commitMenu;
0152:            static JMenuItem commitInitScriptItem;
0153:            static JMenuItem commitPostScriptItem;
0154:            //static JMenuBar commitMenuBar;
0155:
0156:            HashMap modifyPreScriptMap;
0157:            HashMap modifyPostScriptMap;
0158:
0159:            File importFile;
0160:
0161:            TableSorter sorter;
0162:            TableSorter detailsSorter;
0163:
0164:            /******************************************************************************/
0165:            /**									CONSTRUCTEUR							 **/
0166:            /******************************************************************************/
0167:            public ExecutionView() {
0168:
0169:                executionTable = new JTable();
0170:                detailsExecutionTable = new JTable();
0171:
0172:                addExecution = new JButton(Language.getInstance().getText(
0173:                        "Ajouter"));
0174:                addExecution.setToolTipText(Language.getInstance().getText(
0175:                        "Ajouter_une_exécution"));
0176:                addExecution.addActionListener(this );
0177:
0178:                launchExecution = new JButton(Language.getInstance().getText(
0179:                        "Lancer"));
0180:                launchExecution.setToolTipText(Language.getInstance().getText(
0181:                        "Lancer_l'exécution"));
0182:                launchExecution.addActionListener(this );
0183:
0184:                resultExecution = new JButton(Language.getInstance().getText(
0185:                        "Détails"));
0186:                resultExecution.setToolTipText(Language.getInstance().getText(
0187:                        "Détails_sur_les_résultats_de_l'exécution"));
0188:                resultExecution.setEnabled(false);
0189:                resultExecution.addActionListener(this );
0190:
0191:                modifyExecutionButton = new JButton(Language.getInstance()
0192:                        .getText("Modifier"));
0193:                modifyExecutionButton.setToolTipText(Language.getInstance()
0194:                        .getText("Modifier_une_exécution"));
0195:                modifyExecutionButton.setEnabled(false);
0196:                modifyExecutionButton.addActionListener(this );
0197:
0198:                deleteExecution = new JButton(Language.getInstance().getText(
0199:                        "Supprimer"));
0200:                deleteExecution.setToolTipText(Language.getInstance().getText(
0201:                        "Supprimer_une_exécution"));
0202:                deleteExecution.setEnabled(false);
0203:                deleteExecution.addActionListener(this );
0204:
0205:                deleteExecutionResult = new JButton(Language.getInstance()
0206:                        .getText("Supprimer"));
0207:                deleteExecutionResult.setToolTipText(Language.getInstance()
0208:                        .getText("Supprimer_un_résultat_d'exécution"));
0209:                deleteExecutionResult.setEnabled(false);
0210:                deleteExecutionResult.addActionListener(this );
0211:
0212:                continueExecution = new JButton(Language.getInstance().getText(
0213:                        "Reprendre"));
0214:                continueExecution.setToolTipText(Language.getInstance()
0215:                        .getText("Reprendre_une_exécution"));
0216:                continueExecution.setEnabled(false);
0217:                continueExecution.addActionListener(this );
0218:
0219:                attachExecutionButton = new JButton(Language.getInstance()
0220:                        .getText("Attachements"));
0221:                attachExecutionButton.setEnabled(false);
0222:                attachExecutionButton.addActionListener(this );
0223:
0224:                attachExecutionResultButton = new JButton(Language
0225:                        .getInstance().getText("Attachements"));
0226:                attachExecutionResultButton.setEnabled(false);
0227:                attachExecutionResultButton.addActionListener(this );
0228:
0229:                //commitMenu = new JMenu("Actualiser Script");
0230:                commitInitScriptItem = new JMenuItem(Language.getInstance()
0231:                        .getText("Actualiser_pre-Script"));
0232:                commitInitScriptItem.addActionListener(this );
0233:
0234:                commitPostScriptItem = new JMenuItem(Language.getInstance()
0235:                        .getText("Actualiser_post-Script"));
0236:                commitPostScriptItem.addActionListener(this );
0237:
0238:                //commitMenu.add(commitInitScriptItem);
0239:                //commitMenu.add(commitPostScriptItem);
0240:                //commitMenuBar = new JMenuBar();
0241:                //commitMenuBar.add(commitMenu);
0242:
0243:                //commitMenu.setEnabled(false);
0244:
0245:                modifyScriptMenu = new JMenu(Language.getInstance().getText(
0246:                        "Script"));
0247:                initScriptItem = new JMenuItem(Language.getInstance().getText(
0248:                        "Modifier_le_pre-Script"));
0249:                initScriptItem.addActionListener(this );
0250:
0251:                postScriptItem = new JMenuItem(Language.getInstance().getText(
0252:                        "Modifier_le_post-Script"));
0253:                postScriptItem.addActionListener(this );
0254:
0255:                setUpPostEngineItem = new JMenuItem(Language.getInstance()
0256:                        .getText("SetUp_Post-script"));
0257:                setUpPostEngineItem.addActionListener(this );
0258:                setUpPreEngineItem = new JMenuItem(Language.getInstance()
0259:                        .getText("SetUp_Pre-script"));
0260:                setUpPreEngineItem.addActionListener(this );
0261:
0262:                modifyScriptMenu.add(initScriptItem);
0263:                modifyScriptMenu.add(commitInitScriptItem);
0264:                modifyScriptMenu.add(setUpPreEngineItem);
0265:
0266:                modifyScriptMenu.add(postScriptItem);
0267:                modifyScriptMenu.add(commitPostScriptItem);
0268:                modifyScriptMenu.add(setUpPostEngineItem);
0269:
0270:                modifyScriptMenuBar = new JMenuBar();
0271:                modifyScriptMenuBar.add(modifyScriptMenu);
0272:                modifyScriptMenu.setEnabled(false);
0273:
0274:                launchExecution.setEnabled(false);
0275:                deleteExecution.setEnabled(false);
0276:                resultExecution.setEnabled(false);
0277:
0278:                //JPanel executionButtonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
0279:                JPanel executionButtonsPanel = new JPanel(new GridLayout(1, 6));
0280:                executionButtonsPanel.add(addExecution);
0281:                executionButtonsPanel.add(modifyExecutionButton);
0282:                executionButtonsPanel.add(deleteExecution);
0283:                executionButtonsPanel.add(launchExecution);
0284:                executionButtonsPanel.add(attachExecutionButton);
0285:                executionButtonsPanel.add(modifyScriptMenuBar);
0286:                //executionButtonsPanel.add(commitMenuBar);
0287:
0288:                executionButtonsPanel.setBorder(BorderFactory
0289:                        .createRaisedBevelBorder());
0290:
0291:                // Mapping entre objets graphiques et constantes
0292:                SalomeTMF.addToUIComponentsMap(
0293:                        UICompCst.CAMP_EXECUTIONS_BUTTONS_PANEL,
0294:                        executionButtonsPanel);
0295:                // Add this component as static component
0296:                UICompCst.staticUIComps
0297:                        .add(UICompCst.CAMP_EXECUTIONS_BUTTONS_PANEL);
0298:
0299:                //JPanel executionResultButtonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
0300:                JPanel executionResultButtonsPanel = new JPanel(new GridLayout(
0301:                        1, 4));
0302:                executionResultButtonsPanel.add(resultExecution);
0303:                executionResultButtonsPanel.add(continueExecution);
0304:                executionResultButtonsPanel.add(attachExecutionResultButton);
0305:                executionResultButtonsPanel.add(deleteExecutionResult);
0306:                executionResultButtonsPanel.setBorder(BorderFactory
0307:                        .createRaisedBevelBorder());
0308:
0309:                // Mapping entre objets graphiques et constantes
0310:                SalomeTMF.addToUIComponentsMap(
0311:                        UICompCst.CAMP_EXECUTION_RESULTS_BUTTONS_PANEL,
0312:                        executionResultButtonsPanel);
0313:                // Add this component as static component
0314:                UICompCst.staticUIComps
0315:                        .add(UICompCst.CAMP_EXECUTION_RESULTS_BUTTONS_PANEL);
0316:
0317:                sorter = new TableSorter(DataModel.getExecutionTableModel());
0318:                executionTable.setModel(sorter);
0319:                sorter.setTableHeader(executionTable.getTableHeader());
0320:                //		executionTable.setModel(DataModel.getExecutionTableModel());
0321:                executionTable
0322:                        .setPreferredScrollableViewportSize(new Dimension(600,
0323:                                200));
0324:                executionTable
0325:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0326:                executionTable.getColumnModel().getColumn(0).setMaxWidth(18);
0327:                executionTable.getColumnModel().getColumn(0).setWidth(18);
0328:                executionTable.getColumnModel().getColumn(0).setMinWidth(18);
0329:                executionTable.getColumnModel().getColumn(0).setPreferredWidth(
0330:                        18);
0331:                executionTable.getColumnModel().getColumn(0)
0332:                        .setResizable(false);
0333:
0334:                // Mapping entre objets graphiques et constantes
0335:                SalomeTMF.addToUIComponentsMap(UICompCst.CAMP_EXECUTIONS_TABLE,
0336:                        executionTable);
0337:                // Add this component as static component
0338:                UICompCst.staticUIComps.add(UICompCst.CAMP_EXECUTIONS_TABLE);
0339:
0340:                JScrollPane tablePane = new JScrollPane(executionTable);
0341:                tablePane.setBorder(BorderFactory.createTitledBorder(
0342:                        BorderFactory.createLineBorder(Color.BLACK), Language
0343:                                .getInstance().getText("Exécutions")));
0344:
0345:                ListSelectionModel rowSM = executionTable.getSelectionModel();
0346:                rowSM.addListSelectionListener(new ListSelectionListener() {
0347:                    public void valueChanged(ListSelectionEvent e) {
0348:                        if (e.getValueIsAdjusting())
0349:                            return;
0350:                        Api.log("Event is " + e);
0351:                        int selectedRowIndex = executionTable.getSelectedRow();
0352:
0353:                        if (selectedRowIndex != -1) {
0354:                            //Execution exec = DataModel.getCurrentCampaign().getExecution(selectedRowIndex);
0355:                            System.out.println("Get Execution "
0356:                                    + (String) sorter.getValueAt(
0357:                                            selectedRowIndex, 1)
0358:                                    + " for current campaign "
0359:                                    + DataModel.getCurrentCampaign().getName());
0360:                            Execution exec = DataModel.getCurrentCampaign()
0361:                                    .getExecution(
0362:                                            (String) sorter.getValueAt(
0363:                                                    selectedRowIndex, 1));
0364:                            System.out.println("Execution is " + exec);
0365:                            if (exec == null) {
0366:                                return;
0367:                            }
0368:                            DataModel.setObservedExecution(exec);
0369:                            DataModel.getExecutionResultTableModel()
0370:                                    .clearTable();
0371:                            if (AdminProject.canExecutCamp())
0372:                                launchExecution.setEnabled(true);
0373:                            if (AdminProject.canExecutCamp())
0374:                                deleteExecution.setEnabled(true);
0375:                            attachExecutionButton.setEnabled(true);
0376:                            if (AdminProject.canUpdateCamp()
0377:                                    || AdminProject.canExecutCamp())
0378:                                modifyExecutionButton.setEnabled(true);
0379:                            if ((AdminProject.canUpdateCamp() || AdminProject
0380:                                    .canExecutCamp())
0381:                                    && (exec.getInitScript() != null || exec
0382:                                            .getPostScript() != null)) {
0383:                                modifyScriptMenuBar.setEnabled(true);
0384:                                modifyScriptMenu.setEnabled(true);
0385:                                if (exec.getInitScript() != null) {
0386:                                    initScriptItem.setEnabled(true);
0387:                                    setUpPreEngineItem.setEnabled(true);
0388:                                } else {
0389:                                    initScriptItem.setEnabled(false);
0390:                                    setUpPreEngineItem.setEnabled(false);
0391:                                }
0392:                                if (exec.getPostScript() != null) {
0393:                                    postScriptItem.setEnabled(true);
0394:                                    setUpPostEngineItem.setEnabled(true);
0395:                                } else {
0396:                                    postScriptItem.setEnabled(false);
0397:                                    setUpPostEngineItem.setEnabled(false);
0398:                                }
0399:                            } else {
0400:                                modifyScriptMenuBar.setEnabled(false);
0401:                                modifyScriptMenu.setEnabled(false);
0402:                            }
0403:                            if (ConnectionData.isConnected()
0404:                                    && AdminProject.canUpdateCamp()
0405:                                    && isCommitablePreScript((String) executionTable
0406:                                            .getModel().getValueAt(
0407:                                                    selectedRowIndex, 1))) {
0408:                                commitInitScriptItem.setEnabled(true);
0409:                            } else {
0410:                                commitInitScriptItem.setEnabled(false);
0411:                            }
0412:                            if (ConnectionData.isConnected()
0413:                                    && AdminProject.canUpdateCamp()
0414:                                    && isCommitablePostScript((String) executionTable
0415:                                            .getModel().getValueAt(
0416:                                                    selectedRowIndex, 1))) {
0417:                                commitPostScriptItem.setEnabled(true);
0418:                            } else {
0419:                                commitPostScriptItem.setEnabled(false);
0420:                            }
0421:
0422:                            for (int i = 0; i < exec.getExecutionResultList()
0423:                                    .size(); i++) {
0424:                                ArrayList resultList = new ArrayList();
0425:                                resultList.add(((ExecutionResult) exec
0426:                                        .getExecutionResultList().get(i))
0427:                                        .getName());
0428:                                Api.log("try to format : "
0429:                                        + ((ExecutionResult) exec
0430:                                                .getExecutionResultList()
0431:                                                .get(i)).getExecutionDate()
0432:                                                .toString()
0433:                                        + "  "
0434:                                        + ((ExecutionResult) exec
0435:                                                .getExecutionResultList()
0436:                                                .get(i)).getTime().toString());
0437:                                SimpleDateFormat formater = new SimpleDateFormat(
0438:                                        "dd/MM/yyyy");
0439:                                resultList.add(formater.format(
0440:                                        ((ExecutionResult) exec
0441:                                                .getExecutionResultList()
0442:                                                .get(i)).getExecutionDate())
0443:                                        .toString()
0444:                                        + "  "
0445:                                        + ((ExecutionResult) exec
0446:                                                .getExecutionResultList()
0447:                                                .get(i)).getTime().toString());
0448:                                resultList.add(((ExecutionResult) exec
0449:                                        .getExecutionResultList().get(i))
0450:                                        .getTester());
0451:                                resultList.add(((ExecutionResult) exec
0452:                                        .getExecutionResultList().get(i))
0453:                                        .getExecutionStatus());
0454:                                resultList.add(((ExecutionResult) exec
0455:                                        .getExecutionResultList().get(i))
0456:                                        .getFormatedStat());
0457:
0458:                                DataModel.getExecutionResultTableModel()
0459:                                        .addRow(resultList);
0460:                            }
0461:                        } else {
0462:                            //launchExecution.setEnabled(false);
0463:                            deleteExecution.setEnabled(false);
0464:                            attachExecutionButton.setEnabled(false);
0465:                            modifyExecutionButton.setEnabled(false);
0466:                            modifyScriptMenuBar.setEnabled(false);
0467:                            initScriptItem.setEnabled(false);
0468:                            setUpPreEngineItem.setEnabled(false);
0469:                            postScriptItem.setEnabled(false);
0470:                            setUpPostEngineItem.setEnabled(false);
0471:                            commitInitScriptItem.setEnabled(false);
0472:                            commitPostScriptItem.setEnabled(false);
0473:                            modifyScriptMenu.setEnabled(false);
0474:                        }
0475:                    }
0476:                });
0477:
0478:                detailsSorter = new TableSorter(DataModel
0479:                        .getExecutionResultTableModel());
0480:                detailsExecutionTable.setModel(detailsSorter);
0481:                detailsSorter.setTableHeader(detailsExecutionTable
0482:                        .getTableHeader());
0483:                //		detailsExecutionTable.setModel(DataModel.getExecutionResultTableModel());
0484:                detailsExecutionTable
0485:                        .setPreferredScrollableViewportSize(new Dimension(600,
0486:                                200));
0487:                detailsExecutionTable
0488:                        .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
0489:                detailsExecutionTable
0490:                        .addMouseListener(new ExecutionResultMouseListener());
0491:
0492:                // Mapping entre objets graphiques et constantes
0493:                SalomeTMF.addToUIComponentsMap(
0494:                        UICompCst.CAMP_EXECUTION_RESULTS_TABLE,
0495:                        detailsExecutionTable);
0496:                // Add this component as static component
0497:                UICompCst.staticUIComps
0498:                        .add(UICompCst.CAMP_EXECUTION_RESULTS_TABLE);
0499:
0500:                JScrollPane detailsTablePane = new JScrollPane(
0501:                        detailsExecutionTable);
0502:                detailsTablePane.setBorder(BorderFactory.createTitledBorder(
0503:                        BorderFactory.createLineBorder(Color.BLACK), Language
0504:                                .getInstance().getText("Résultats")));
0505:
0506:                ListSelectionModel detailsRowSM = detailsExecutionTable
0507:                        .getSelectionModel();
0508:                detailsRowSM
0509:                        .addListSelectionListener(new ListSelectionListener() {
0510:                            public void valueChanged(ListSelectionEvent e) {
0511:                                if (e.getValueIsAdjusting())
0512:                                    return;
0513:                                Api.log(Language.getInstance().getText(
0514:                                        "Execution_result_tab_listener"));
0515:
0516:                                int selectedRowIndex = detailsExecutionTable
0517:                                        .getSelectedRow();
0518:                                if (selectedRowIndex != -1) {
0519:                                    resultExecution.setEnabled(true);
0520:                                    if (AdminProject.canExecutCamp())
0521:                                        deleteExecutionResult.setEnabled(true);
0522:                                    attachExecutionResultButton
0523:                                            .setEnabled(true);
0524:
0525:                                    DataModel
0526:                                            .setObervedExecutionResult(DataModel
0527:                                                    .getObservedExecution()
0528:                                                    .getExecutionResult(
0529:                                                            (String) detailsSorter
0530:                                                                    .getValueAt(
0531:                                                                            selectedRowIndex,
0532:                                                                            0)));
0533:                                    if (DataModel
0534:                                            .getObservedExecution()
0535:                                            .getExecutionResult(
0536:                                                    (String) detailsSorter
0537:                                                            .getValueAt(
0538:                                                                    selectedRowIndex,
0539:                                                                    0))
0540:                                            .getExecutionStatus().equals(
0541:                                                    INCOMPLETED)
0542:                                            || DataModel
0543:                                                    .getObservedExecution()
0544:                                                    .getExecutionResult(
0545:                                                            (String) detailsSorter
0546:                                                                    .getValueAt(
0547:                                                                            selectedRowIndex,
0548:                                                                            0))
0549:                                                    .getExecutionStatus()
0550:                                                    .equals(INTERRUPT)) {
0551:                                        if (AdminProject.canExecutCamp())
0552:                                            continueExecution.setEnabled(true);
0553:                                    } else {
0554:                                        continueExecution.setEnabled(false);
0555:                                    }
0556:                                } else {
0557:                                    attachExecutionResultButton
0558:                                            .setEnabled(false);
0559:                                    resultExecution.setEnabled(false);
0560:                                    continueExecution.setEnabled(false);
0561:                                    deleteExecutionResult.setEnabled(false);
0562:                                }
0563:
0564:                            }
0565:                        });
0566:
0567:                JPanel executionPanel = new JPanel(new BorderLayout());
0568:                executionPanel.add(executionButtonsPanel, BorderLayout.NORTH);
0569:                executionPanel.add(tablePane, BorderLayout.CENTER);
0570:
0571:                JPanel resultPanel = new JPanel(new BorderLayout());
0572:                resultPanel
0573:                        .add(executionResultButtonsPanel, BorderLayout.NORTH);
0574:                resultPanel.add(detailsTablePane, BorderLayout.CENTER);
0575:
0576:                initData();
0577:
0578:                this .setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
0579:                this .add(executionPanel);
0580:                this .add(Box.createRigidArea(new Dimension(1, 10)));
0581:                this .add(resultPanel);
0582:
0583:            } // Fin du constructeur ExecutionView/0
0584:
0585:            public static JTable getTable() {
0586:                return executionTable;
0587:            }
0588:
0589:            /**
0590:             *
0591:             *
0592:             */
0593:            public static void giveAccessToIhmExecutionView() {
0594:                if (!AdminProject.canExecutCamp()) {
0595:                    deleteExecution.setEnabled(false);
0596:                    deleteExecutionResult.setEnabled(false);
0597:                }
0598:                if (!AdminProject.canCreateCamp()
0599:                        && !AdminProject.canExecutCamp()) {
0600:                    addExecution.setEnabled(false);
0601:                }
0602:                if (!AdminProject.canUpdateCamp()
0603:                        && !AdminProject.canExecutCamp()) {
0604:                    modifyExecutionButton.setEnabled(false);
0605:                    modifyScriptMenuBar.setEnabled(false);
0606:                    //commitMenuBar.setEnabled(false);
0607:                }
0608:                if (!AdminProject.canExecutCamp()) {
0609:                    launchExecution.setEnabled(false);
0610:                    continueExecution.setEnabled(false);
0611:                }
0612:            }
0613:
0614:            private boolean isCommitablePreScript(String execName) {
0615:                Execution exec = DataModel.getCurrentCampaign().getExecution(
0616:                        execName);
0617:                Boolean bool = (Boolean) modifyPreScriptMap.get(exec);
0618:                if (bool == null) {
0619:                    return false;
0620:                }
0621:                return bool.booleanValue();
0622:            }
0623:
0624:            private boolean isCommitablePostScript(String execName) {
0625:                Execution exec = DataModel.getCurrentCampaign().getExecution(
0626:                        execName);
0627:                Boolean bool = (Boolean) modifyPostScriptMap.get(exec);
0628:                if (bool == null) {
0629:                    return false;
0630:                }
0631:                return bool.booleanValue();
0632:            }
0633:
0634:            private void initData() {
0635:                modifyPreScriptMap = new HashMap();
0636:                modifyPostScriptMap = new HashMap();
0637:                for (int i = 0; i < executionTable.getModel().getRowCount(); i++) {
0638:                    modifyPreScriptMap.put(executionTable.getModel()
0639:                            .getValueAt(i, 0), new Boolean(false));
0640:                    modifyPostScriptMap.put(executionTable.getModel()
0641:                            .getValueAt(i, 0), new Boolean(false));
0642:                }
0643:            }
0644:
0645:            private void modifyScript(String type) {
0646:                int selectedRow = executionTable.getSelectedRow();
0647:                if (selectedRow != -1) {
0648:                    Execution exec = DataModel.getCurrentCampaign()
0649:                            .getExecution(
0650:                                    (String) executionTable.getModel()
0651:                                            .getValueAt(selectedRow, 1));
0652:                    try {
0653:                        Cursor c = new Cursor(Cursor.WAIT_CURSOR);
0654:                        ExecutionView.this .setCursor(c);
0655:                    } catch (Exception ex) {
0656:                        ex.printStackTrace();
0657:                        return;
0658:                    }
0659:                    try {
0660:                        Script pScript = null;
0661:                        String plugSeting = "";
0662:                        Hashtable param = new Hashtable();
0663:                        param.put("salome_projectName", ProjectData
0664:                                .getCurrentProject().getName());
0665:                        param.put("salome_ProjectObject", ProjectData
0666:                                .getCurrentProject());
0667:                        param.put("salome_debug", new Boolean(true));
0668:                        param.put(Language.getInstance().getText(
0669:                                "salome_CampagneName"), "");
0670:                        param.put("salome_ExecName", exec.getName()); // Add MM
0671:                        param.put("salome_environmentName", "");
0672:                        param.put("salome_TestName", "");
0673:                        param.put("salome_SuiteTestName", "");
0674:                        param.put("salome_FamilyName", "");
0675:                        param.put("testLog", "");
0676:                        param.put("Verdict", "");
0677:                        int plugScriptType;
0678:                        String fileScript = null;
0679:
0680:                        if (type.equals(PRE_SCRIPT)) {
0681:                            pScript = exec.getInitScript();
0682:                            plugScriptType = ScriptEngine.PRE_SCRIPT;
0683:                        } else {
0684:                            pScript = exec.getPostScript();
0685:                            plugScriptType = ScriptEngine.POST_SCRIPT;
0686:
0687:                        }
0688:                        if (pScript == null) {
0689:                            JOptionPane
0690:                                    .showMessageDialog(
0691:                                            ExecutionView.this ,
0692:                                            Language
0693:                                                    .getInstance()
0694:                                                    .getText(
0695:                                                            "Impossible_de_récupérer_le_fichier_depuis_la_base."),
0696:                                            Language.getInstance().getText(
0697:                                                    "Erreur_!"),
0698:                                            JOptionPane.ERROR_MESSAGE);
0699:                            return;
0700:                        }
0701:                        plugSeting = pScript.getPlugArg();
0702:
0703:                        if (ConnectionData.isConnected()) {
0704:                            //importFile = ConnectionData.getCampTestSelect().getScriptOfExecution(DataModel.getCurrentCampaign().getName(),exec.getName(), pScript.getName(), type);
0705:                            importFile = exec.getExecScriptFromDB(pScript
0706:                                    .getName(), type);
0707:                            fileScript = Tools.speedpurge(importFile
0708:                                    .getAbsolutePath());
0709:                        } else {
0710:                            fileScript = Tools.speedpurge(pScript.getName());
0711:                        }
0712:
0713:                        if (fileScript != null) {
0714:                            ScriptEngine pEngine = pScript.getScriptEngine(
0715:                                    (Extension) SalomeTMF.associatedExtension
0716:                                            .get(pScript.getScriptExtension()),
0717:                                    SalomeTMF.urlSalome, SalomeTMF.jpf);
0718:                            if (pEngine != null) {
0719:                                pEngine.editScript(fileScript, plugScriptType,
0720:                                        pScript, param, plugSeting);
0721:                                //inter.eval("desktop(\""+ Tools.speedpurge(importFile.getAbsolutePath())+ "\");");
0722:                            } else {
0723:                                JOptionPane
0724:                                        .showMessageDialog(
0725:                                                ExecutionView.this ,
0726:                                                Language
0727:                                                        .getInstance()
0728:                                                        .getText(
0729:                                                                "Impossible_d'initialiser_le_plugin_du_scrit"),
0730:                                                Language.getInstance().getText(
0731:                                                        "Erreur_!"),
0732:                                                JOptionPane.ERROR_MESSAGE);
0733:                            }
0734:                        } else {
0735:                            JOptionPane
0736:                                    .showMessageDialog(
0737:                                            ExecutionView.this ,
0738:                                            Language
0739:                                                    .getInstance()
0740:                                                    .getText(
0741:                                                            "Impossible_de_récupérer_le_fichier_depuis_la_base."),
0742:                                            Language.getInstance().getText(
0743:                                                    "Erreur_!"),
0744:                                            JOptionPane.ERROR_MESSAGE);
0745:                        }
0746:                    } catch (Exception ex) {
0747:                        JOptionPane
0748:                                .showMessageDialog(
0749:                                        ExecutionView.this ,
0750:                                        Language
0751:                                                .getInstance()
0752:                                                .getText(
0753:                                                        "Erreur_pour_lancer_l'éditeur_de_script_:_\n")
0754:                                                + ex.getMessage(), Language
0755:                                                .getInstance().getText(
0756:                                                        "Erreur_!"),
0757:                                        JOptionPane.ERROR_MESSAGE);
0758:                    }
0759:
0760:                    try {
0761:                        Cursor c = new Cursor(Cursor.DEFAULT_CURSOR);
0762:                        ExecutionView.this .setCursor(c);
0763:                    } catch (Exception ee) {
0764:                        ee.printStackTrace();
0765:                    }
0766:                    //commitMenu.setEnabled(true);
0767:                    if (type.equals(PRE_SCRIPT)) {
0768:                        commitInitScriptItem.setEnabled(true);
0769:                        commitPostScriptItem.setEnabled(false);
0770:                        modifyPreScriptMap.put(exec, new Boolean(true));
0771:                    } else {
0772:                        commitPostScriptItem.setEnabled(true);
0773:                        commitInitScriptItem.setEnabled(false);
0774:                        modifyPostScriptMap.put(exec, new Boolean(true));
0775:                    }
0776:
0777:                }
0778:            }
0779:
0780:            private void commitScript(String type) {
0781:                if (ConnectionData.isConnected()) {
0782:                    int selectedRow = executionTable.getSelectedRow();
0783:                    if (selectedRow != -1) {
0784:                        Execution exec = DataModel.getCurrentCampaign()
0785:                                .getExecution(
0786:                                        (String) executionTable.getModel()
0787:                                                .getValueAt(selectedRow, 1));
0788:                        int transNumber = -1;
0789:                        try {
0790:                            // BdD
0791:                            transNumber = Api
0792:                                    .beginTransaction(Api.UPDATE_ATTACHMENT);
0793:                            Date date = new Date(importFile.lastModified());
0794:                            /*ConnectionData.getCampTestUpdate().updateScriptForExecution(DataModel.getCurrentCampaign().getName(), exec.getName(), type, importFile.getAbsolutePath());
0795:                            ConnectionData.getCampTestUpdate().updateScriptDateForExecution(DataModel.getCurrentCampaign().getName(), exec.getName(), type, importFile.getName(), date);
0796:                            ConnectionData.getCampTestUpdate().updateScriptLengthForExecution(DataModel.getCurrentCampaign().getName(), exec.getName(), type, importFile.getName(), importFile.length());*/
0797:                            if (type.equals(PRE_SCRIPT)) {
0798:                                Script initScript = exec.getInitScript();
0799:                                initScript.updateContentInDB(importFile
0800:                                        .getAbsolutePath());
0801:                                initScript.updateDateInDB(date);
0802:                                initScript
0803:                                        .updateLengthInDB(importFile.length());
0804:                            } else {
0805:                                Script postScript = exec.getPostScript();
0806:                                postScript.updateContentInDB(importFile
0807:                                        .getAbsolutePath());
0808:                                postScript.updateDateInDB(date);
0809:                                postScript
0810:                                        .updateLengthInDB(importFile.length());
0811:                            }
0812:                            Api.commitTrans(transNumber);
0813:
0814:                            // IHM
0815:                            if (type.equals(PRE_SCRIPT)) {
0816:                                modifyPreScriptMap
0817:                                        .put(exec, new Boolean(false));
0818:                                commitInitScriptItem.setEnabled(false);
0819:
0820:                            } else {
0821:                                modifyPostScriptMap.put(exec,
0822:                                        new Boolean(false));
0823:                                commitPostScriptItem.setEnabled(false);
0824:
0825:                            }
0826:
0827:                            JOptionPane
0828:                                    .showMessageDialog(
0829:                                            ExecutionView.this ,
0830:                                            Language
0831:                                                    .getInstance()
0832:                                                    .getText(
0833:                                                            "Le_fichier_a_été_correctement_archivé."),
0834:                                            Language.getInstance().getText(
0835:                                                    "Info..."),
0836:                                            JOptionPane.INFORMATION_MESSAGE);
0837:                            //}
0838:                        } catch (FileNotFoundException fe) {
0839:                            Api.forceRollBackTrans(transNumber);
0840:                            JOptionPane
0841:                                    .showMessageDialog(
0842:                                            ExecutionView.this ,
0843:                                            Language
0844:                                                    .getInstance()
0845:                                                    .getText(
0846:                                                            "Impossible_de_trouver_le_fichier!\n_Vous_pouvez_l'importer_en_cliquant_sur_le_bouton_\"Modifier\""),
0847:                                            Language.getInstance().getText(
0848:                                                    "Erreur_!"),
0849:                                            JOptionPane.ERROR_MESSAGE);
0850:                        } catch (Exception exception) {
0851:                            Api.forceRollBackTrans(transNumber);
0852:                            Tools.ihmExceptionView(exception.toString());
0853:                        }
0854:
0855:                    }
0856:                } else {
0857:                    JOptionPane
0858:                            .showMessageDialog(
0859:                                    ExecutionView.this ,
0860:                                    Language
0861:                                            .getInstance()
0862:                                            .getText(
0863:                                                    "Impossible_!\nVous_n'êtes_pas_connecté_à_la_base."),
0864:                                    Language.getInstance().getText("Erreur_!"),
0865:                                    JOptionPane.ERROR_MESSAGE);
0866:                }
0867:
0868:            }
0869:
0870:            public void actionPerformed(ActionEvent e) {
0871:                Object source = e.getSource();
0872:                if (source.equals(addExecution)) {
0873:                    addExecutionPerformed(e);
0874:                } else if (source.equals(launchExecution)) {
0875:                    launchExecutionPerformed(e);
0876:                } else if (source.equals(resultExecution)) {
0877:                    resultExecutionPerformed(e);
0878:                } else if (source.equals(modifyExecutionButton)) {
0879:                    modifyExecutionPerformed(e);
0880:                } else if (source.equals(deleteExecution)) {
0881:                    deleteExecutionPerformed(e);
0882:                } else if (source.equals(deleteExecutionResult)) {
0883:                    deleteExecutionResultPerformed(e);
0884:                } else if (source.equals(continueExecution)) {
0885:                    continueExecutionPerformed(e);
0886:                } else if (source.equals(attachExecutionButton)) {
0887:                    attachExecutionPerformed(e);
0888:                } else if (source.equals(attachExecutionResultButton)) {
0889:                    attachExecutionResultPerformed(e);
0890:                } else if (source.equals(initScriptItem)) {
0891:                    modifyinitScriptPerformed(e);
0892:                } else if (source.equals(postScriptItem)) {
0893:                    modifypostScriptPerformed(e);
0894:                } else if (source.equals(commitPostScriptItem)) {
0895:                    commitPostScriptPerformed(e);
0896:                } else if (source.equals(commitInitScriptItem)) {
0897:                    commitInitScriptPerformed(e);
0898:                } else if (source.equals(setUpPostEngineItem)) {
0899:                    setUpEnginePerformed(e, POST_SCRIPT);
0900:                } else if (source.equals(setUpPreEngineItem)) {
0901:                    setUpEnginePerformed(e, PRE_SCRIPT);
0902:                }
0903:            }
0904:
0905:            public void setUpEnginePerformed(ActionEvent e, String type) {
0906:                Script pScript = null;
0907:                int selectedRow = executionTable.getSelectedRow();
0908:                Execution exec;
0909:                if (selectedRow != -1) {
0910:                    exec = DataModel.getCurrentCampaign().getExecution(
0911:                            (String) executionTable.getModel().getValueAt(
0912:                                    selectedRow, 1));
0913:
0914:                } else {
0915:                    return;
0916:                }
0917:
0918:                if (type.equals(PRE_SCRIPT)) {
0919:                    pScript = exec.getInitScript();
0920:                } else {
0921:                    pScript = exec.getPostScript();
0922:                }
0923:                ScriptEngine pEngine = pScript.getScriptEngine(
0924:                        (Extension) SalomeTMF.associatedExtension.get(pScript
0925:                                .getScriptExtension()), SalomeTMF.urlSalome,
0926:                        SalomeTMF.jpf);
0927:                if (pEngine != null) {
0928:                    String oldplugArg = pScript.getPlugArg();
0929:                    String plugArg = pEngine.modifyEngineAgument(oldplugArg);
0930:
0931:                    try {
0932:                        pScript.updatePlugArgInDB(plugArg);
0933:                        pScript.setPlugArg(plugArg);
0934:                        JOptionPane
0935:                                .showMessageDialog(
0936:                                        ExecutionView.this ,
0937:                                        Language
0938:                                                .getInstance()
0939:                                                .getText(
0940:                                                        "Le_fichier_a_été_correctement_archivé."),
0941:                                        Language.getInstance().getText(
0942:                                                "Info..."),
0943:                                        JOptionPane.INFORMATION_MESSAGE);
0944:                    } catch (Exception exception) {
0945:                        pScript.setPlugArg(oldplugArg);
0946:                        Tools.ihmExceptionView(exception.toString());
0947:                    }
0948:                } else {
0949:                    JOptionPane
0950:                            .showMessageDialog(
0951:                                    ExecutionView.this ,
0952:                                    Language
0953:                                            .getInstance()
0954:                                            .getText(
0955:                                                    "Impossible_d'initialiser_le_plugin_du_scrit"),
0956:                                    Language.getInstance().getText("Erreur_!"),
0957:                                    JOptionPane.ERROR_MESSAGE);
0958:                }
0959:            }
0960:
0961:            public void addExecutionPerformed(ActionEvent e) {
0962:                if (DataModel.getCurrentCampaign().getTestList().size() == 0) {
0963:                    JOptionPane
0964:                            .showMessageDialog(
0965:                                    ExecutionView.this ,
0966:                                    Language
0967:                                            .getInstance()
0968:                                            .getText(
0969:                                                    "Vous_ne_pouvez_pas_créer_d'exécution_pour_cette_campagne_car_elle_ne_contient_aucun_test_!"),
0970:                                    Language.getInstance().getText("Erreur..."),
0971:                                    JOptionPane.ERROR_MESSAGE);
0972:                } else {
0973:
0974:                    AskNewExecution askNewExecution = new AskNewExecution(null);
0975:                    if (askNewExecution.getExecution() != null) {
0976:                        int transNumber = -1;
0977:                        try {
0978:                            /*String dataSetName = null;
0979:                            if (askNewExecution.getExecution().getDataSet() != null && !askNewExecution.getExecution().getDataSet().getName().equals("Aucun")) {
0980:                                dataSetName = askNewExecution.getExecution().getDataSet().getName();
0981:                            }*/
0982:
0983:                            // BdD 
0984:                            Execution exec = askNewExecution.getExecution();
0985:                            exec.addInBddAndModel(ProjectData.getCurrentUser(),
0986:                                    DataModel.getCurrentCampaign(),
0987:                                    askNewExecution.getInitScriptFile(),
0988:                                    askNewExecution.getRestitutionScriptFile());
0989:
0990:                            // IHM
0991:                            ArrayList executionData = new ArrayList();
0992:                            executionData.add(new Boolean(false));
0993:                            executionData.add(askNewExecution.getExecution()
0994:                                    .getName());
0995:                            executionData.add(askNewExecution.getExecution()
0996:                                    .getEnvironment());
0997:                            executionData.add(askNewExecution.getExecution()
0998:                                    .getDataSet());
0999:                            executionData.add(askNewExecution.getExecution()
1000:                                    .getCreationDate());
1001:                            executionData.add(askNewExecution.getExecution()
1002:                                    .getAttachmentMap().keySet());
1003:                            executionData.add("");
1004:                            DataModel.getExecutionTableModel().addRow(
1005:                                    executionData);
1006:                            executionTable.getColumnModel().getColumn(0)
1007:                                    .setMaxWidth(18);
1008:
1009:                        } catch (Exception exception) {
1010:                            Api.forceRollBackTrans(transNumber);
1011:                            Tools.ihmExceptionView(exception.toString());
1012:                        }
1013:                    }
1014:                }
1015:            }
1016:
1017:            public void launchExecutionPerformed(ActionEvent e) {
1018:                if (DataModel.getCurrentCampaign() != null) {
1019:                    if (DataModel.getCurrentCampaign().getTestList().size() > 0) {
1020:                        DataModel.getSelectedExecution().clear();
1021:                        for (int k = 0; k < DataModel.getExecutionTableModel()
1022:                                .getRowCount(); k++) {
1023:                            if (((Boolean) sorter.getValueAt(k, 0))
1024:                                    .booleanValue()) {
1025:                                DataModel.addSelectedExecution(DataModel
1026:                                        .getCurrentCampaign().getExecution(
1027:                                                (String) sorter
1028:                                                        .getValueAt(k, 1)));
1029:                            }
1030:                        }
1031:                        TestMethods.runExecution(DataModel
1032:                                .getSelectedExecution(), this , false);
1033:                    } else {
1034:                        JOptionPane
1035:                                .showMessageDialog(
1036:                                        ExecutionView.this ,
1037:                                        Language
1038:                                                .getInstance()
1039:                                                .getText(
1040:                                                        "Il_n'y_a_aucun_test_dans_la_campagne_!"),
1041:                                        Language.getInstance().getText(
1042:                                                "Attention_!"),
1043:                                        JOptionPane.WARNING_MESSAGE);
1044:                    }
1045:                }
1046:                /*
1047:                if (DataModel.getCurrentCampaign() != null) {
1048:                	// La campagne doit contenir au moins un test
1049:                	if (DataModel.getCurrentCampaign().getTestList().size() > 0) {
1050:                		// L'ex?cution affich?e ? l'?cran
1051:                		//int selectedRowIndex = executionTable.getSelectedRow();
1052:                		// Mise ? jour de la liste des ex?cutions ? jouer
1053:                		DataModel.getSelectedExecution().clear();
1054:                		
1055:                		for (int k = 0; k < DataModel.getExecutionTableModel().getRowCount(); k++) {
1056:                			if (((Boolean)sorter.getValueAt(k,0)).booleanValue()) {
1057:                				//DataModel.addSelectedExecution(DataModel.getCurrentCampaign().getExecution(k));
1058:                				DataModel.addSelectedExecution(DataModel.getCurrentCampaign().getExecution((String)sorter.getValueAt(k,1)));
1059:                			}
1060:                		}
1061:                		// il doit y avoir au moins une ex?cution s?lectionn?e
1062:                		if (DataModel.getSelectedExecution().size() > 0) {
1063:                			// table des attachements ? supprimer
1064:                			HashMap attachToBeSuppress = new HashMap();
1065:                			String message = "";
1066:                			for (int i = 0;  i < DataModel.getSelectedExecution().size(); i ++) { // FOR 1
1067:                				HashSet setOfParam = new HashSet();
1068:                				// R?cup?ration de tous les param?tres de la campagne
1069:                				for (int k = 0; k < DataModel.getCurrentCampaign().getTestList().size(); k++) {
1070:                					Test test = (Test)DataModel.getCurrentCampaign().getTestList().get(k);
1071:                					for (int j = 0; j < test.getParameterList().size(); j++) {
1072:                						setOfParam.add(test.getParameterList().get(j));
1073:                					}
1074:                				}
1075:                				// On v?rifie que tous les param?tres ont une valuation;
1076:                				ArrayList notValuedParamList = new ArrayList();
1077:                				message = TestMethods.notValuedParamListInDataSet(setOfParam, ((Execution)DataModel.getSelectedExecution().get(i)).getDataSet(), notValuedParamList);
1078:                				if (notValuedParamList.size() > 0) {
1079:                					message = "Les paramêtres :\n" + message + "de l'exécution <" +  ((Execution)DataModel.getSelectedExecution().get(i)).getName() + "> ne sont pas valués.";
1080:                				}
1081:                			}
1082:                			if (!message.equals("")) {
1083:                				JOptionPane.showMessageDialog(ExecutionView.this,
1084:                						"Attention !\n" + message,
1085:                						"Attention !",
1086:                						JOptionPane.INFORMATION_MESSAGE);
1087:                			}
1088:                			
1089:                			CallExecThread precCallExecThread = null;
1090:                			// on parcourt la liste des ex?cutions s?lectionn?es
1091:                			//for (int i = 0;  i < DataModel.getSelectedExecution().size(); i ++) { // FOR 1
1092:                			for (int i = DataModel.getSelectedExecution().size()-1; i >= 0 ; i --) { // FOR 1
1093:                				
1094:                				// Execution courante
1095:                				Execution exec = (Execution)DataModel.getSelectedExecution().get(i);
1096:                				Api.log(">>>>EXEC LANCEE = " + exec.getName());
1097:                				// R?sultat d'ex?cution final
1098:                				ExecutionResult finalExecResult = new ExecutionResult();
1099:                				finalExecResult.setNumberOfFail(0);
1100:                				finalExecResult.setNumberOfSuccess(0);
1101:                				finalExecResult.setNumberOfUnknow(0);
1102:                				finalExecResult.setName(exec.getName() + "_" + exec.getExecutionResultList().size());
1103:                				finalExecResult.setExecutionDate(new Date(GregorianCalendar.getInstance().getTimeInMillis()));
1104:                				finalExecResult.setTester(DataModel.getCurrentUser().getLastName() + " " + DataModel.getCurrentUser().getFirstName());
1105:                				
1106:                				Tools.initExecutionResultMap(DataModel.getCurrentCampaign().getTestList(), finalExecResult, exec.getCampagne());
1107:                				
1108:                				
1109:                				//Liste des r?sultats d'ex?cutions de chaque sous-liste
1110:                				// Liste des tests group?s en sous-listes (manuels/automatiques)
1111:                				Vector pAllTestToExecute = new Vector();
1112:                				ArrayList splittedListOfTest = Tools.getListOfTestManualOrAutomatic(DataModel.getCurrentCampaign().getTestList(), null, pAllTestToExecute);
1113:                				// ADD
1114:                				//automatic_finished = false;
1115:                				Vector listExec = new Vector();
1116:                				//END ADD
1117:                				// On parcourt la liste des sous-listes
1118:                				for (int h =0; h < splittedListOfTest.size(); h++) {
1119:                					if (((ArrayList)splittedListOfTest.get(h)).get(0) instanceof ManualTest) {
1120:                						// Sous liste de tests manuels
1121:                						listExec.add(new ManualExecution((ArrayList)splittedListOfTest.get(h), exec, finalExecResult));
1122:                						
1123:                					} else {
1124:                						//Sous liste de tests automatiques
1125:                						ArrayList automaticTestList = (ArrayList)splittedListOfTest.get(h);
1126:                						listExec.add(new AutomaticExecution(automaticTestList, exec, finalExecResult));
1127:                					}
1128:                				}
1129:                				//ADD
1130:                				//precCallExecThread = new callExecThread(listExec, exec, splittedListOfTest, selectedRowIndex, attachToBeSuppress, true, finalExecResult, precCallExecThread, pAllTestToExecute.toArray());
1131:                				precCallExecThread = new CallExecThread(listExec, exec, splittedListOfTest, true, finalExecResult, precCallExecThread, pAllTestToExecute.toArray(), this, false);
1132:                				
1133:                				//precCallExecThread.start();
1134:                				// lancer le thread
1135:                				//
1136:                			} // FIN FOR 1
1137:                			precCallExecThread.start();
1138:                		} else {
1139:                			JOptionPane.showMessageDialog(ExecutionView.this,
1140:                					"Vous devez sélectionner au moins une exécution...",
1141:                					"Attention !",
1142:                					JOptionPane.WARNING_MESSAGE);
1143:                		}
1144:                	} else {
1145:                		JOptionPane.showMessageDialog(ExecutionView.this,
1146:                				"Il n'y a aucun test dans la campagne !",
1147:                				"Attention !",
1148:                				JOptionPane.WARNING_MESSAGE);
1149:                	}
1150:                }*/
1151:            }
1152:
1153:            public void resultExecutionPerformed(ActionEvent e) {
1154:                int detailsSelectedRowIndex = detailsExecutionTable
1155:                        .getSelectedRow();
1156:                int execSelectedRowIndex = executionTable.getSelectedRow();
1157:                if (execSelectedRowIndex != -1 && detailsSelectedRowIndex != -1) {
1158:                    new ExecutionResultView(DataModel
1159:                            .getObservedExecutionResult().getName(), DataModel
1160:                            .getObservedExecutionResult());
1161:                }
1162:            }
1163:
1164:            public void modifyExecutionPerformed(ActionEvent e) {
1165:                int selectedIndex = executionTable.getSelectedRow();
1166:                if (selectedIndex != -1) {
1167:                    Execution exec = DataModel.getCurrentCampaign()
1168:                            .getExecution(
1169:                                    (String) executionTable.getModel()
1170:                                            .getValueAt(selectedIndex, 1));
1171:                    // Conservation des anciennes valeurs
1172:                    HashMap oldAttachMap = new HashMap();
1173:                    Set keysSetOld = exec.getAttachmentMap().keySet();
1174:                    for (Iterator iter = keysSetOld.iterator(); iter.hasNext();) {
1175:                        Object elem = iter.next();
1176:                        oldAttachMap.put(elem, exec.getAttachmentMap()
1177:                                .get(elem));
1178:                    }
1179:                    Script oldInitScript = exec.getInitScript();
1180:                    Script oldPostScript = exec.getPostScript();
1181:
1182:                    //String oldExecName = exec.getName();
1183:                    if (exec.getExecutionResultList().size() != 0) {
1184:                        JOptionPane
1185:                                .showMessageDialog(
1186:                                        ExecutionView.this ,
1187:                                        Language
1188:                                                .getInstance()
1189:                                                .getText(
1190:                                                        "Cette_exécution_possède_des_résultats.\n")
1191:                                                + Language
1192:                                                        .getInstance()
1193:                                                        .getText(
1194:                                                                "Vous_ne_pourrez_modifier_que_ses_attachements!"),
1195:                                        Language.getInstance().getText(
1196:                                                "Avertissement_!"),
1197:                                        JOptionPane.WARNING_MESSAGE);
1198:                    }
1199:                    AskNewExecution askNewExecution = new AskNewExecution(exec);
1200:                    if (oldInitScript == null) {
1201:                        initScriptItem.setEnabled(false);
1202:                        setUpPreEngineItem.setEnabled(false);
1203:                        //commitInitScriptItem.setEnabled(false);
1204:                    } else {
1205:                        initScriptItem.setEnabled(true);
1206:                        setUpPreEngineItem.setEnabled(true);
1207:                    }
1208:
1209:                    if (oldPostScript == null) {
1210:                        postScriptItem.setEnabled(false);
1211:                        setUpPostEngineItem.setEnabled(false);
1212:                        //commitPostScriptItem.setEnabled(false);
1213:                    } else {
1214:                        postScriptItem.setEnabled(true);
1215:                        setUpPostEngineItem.setEnabled(true);
1216:                    }
1217:                    if (askNewExecution.getExecution() != null) {
1218:                        Execution pExec = askNewExecution.getExecution();
1219:                        int transNumber = -1;
1220:                        try {
1221:                            /*String dataSetName = "";
1222:                            if (pExec.getDataSet() != null) {
1223:                                dataSetName = pExec.getDataSet().getName();
1224:                            }*/
1225:
1226:                            // BdD
1227:                            transNumber = Api
1228:                                    .beginTransaction(Api.UPDATE_EXECUTION);
1229:
1230:                            pExec.updateNameInBddAndModel(pExec.getName());
1231:                            pExec
1232:                                    .updateDatasetInBddAndModel(pExec
1233:                                            .getDataSet());
1234:                            pExec
1235:                                    .updateEnvInBddAndModel(pExec
1236:                                            .getEnvironment());
1237:                            if (pExec.getInitScript() != null) {
1238:                                if (!pExec.getInitScript()
1239:                                        .equals(oldInitScript)) {
1240:                                    if (oldInitScript != null) {
1241:                                        pExec.deleteScriptFromDB(oldInitScript
1242:                                                .getName(), PRE_SCRIPT);
1243:                                    }
1244:                                    //pExec.addScript2DB(pExec.getInitScript(),askNewExecution.getInitScriptFile());
1245:                                    pExec.addPreScriptInBddAndModel(pExec
1246:                                            .getInitScript(), askNewExecution
1247:                                            .getInitScriptFile());
1248:                                    initScriptItem.setEnabled(true);
1249:                                    setUpPreEngineItem.setEnabled(true);
1250:                                }
1251:                            } else if (oldInitScript != null) {
1252:                                pExec.deleteScriptFromDB(oldInitScript
1253:                                        .getName(), PRE_SCRIPT);
1254:
1255:                                initScriptItem.setEnabled(false);
1256:                                setUpPreEngineItem.setEnabled(false);
1257:                            }
1258:                            if (askNewExecution.getExecution().getPostScript() != null) {
1259:                                if (!pExec.getPostScript()
1260:                                        .equals(oldPostScript)) {
1261:                                    if (oldPostScript != null) {
1262:                                        pExec.deleteScriptFromDB(oldPostScript
1263:                                                .getName(), POST_SCRIPT);
1264:                                    }
1265:                                    //pExec.addScript2DB(pExec.getPostScript(), askNewExecution.getRestitutionScriptFile());
1266:                                    pExec.addPostScriptInBddAndModel(pExec
1267:                                            .getPostScript(), askNewExecution
1268:                                            .getRestitutionScriptFile());
1269:                                    postScriptItem.setEnabled(true);
1270:                                    setUpPostEngineItem.setEnabled(true);
1271:                                }
1272:                            } else if (oldPostScript != null) {
1273:                                pExec.deleteScriptFromDB(oldPostScript
1274:                                        .getName(), POST_SCRIPT);
1275:                                postScriptItem.setEnabled(false);
1276:                                setUpPostEngineItem.setEnabled(false);
1277:                            }
1278:                            // ATTACHEMENTS
1279:                            Vector oldFileAttachNamesVector = pExec
1280:                                    .getAttachFilesFromDB();
1281:                            // Liste des anciennes urls attach?es
1282:                            Vector oldUrlAttachVector = pExec
1283:                                    .getAttachUrlsFromDB();
1284:                            Collection attachValues = pExec.getAttachmentMap()
1285:                                    .values();
1286:                            for (Iterator iter = attachValues.iterator(); iter
1287:                                    .hasNext();) {
1288:                                Attachment attach = (Attachment) iter.next();
1289:
1290:                                if (attach instanceof  FileAttachment) {
1291:                                    if (!oldFileAttachNamesVector
1292:                                            .contains(attach.getName())) {
1293:                                        //pExec.addAttachFile2DB((FileAttachment)attach);
1294:                                        pExec
1295:                                                .addAttachFileInBddAndModel(attach);
1296:                                    }
1297:                                } else {
1298:                                    if (!oldUrlAttachVector.contains(attach
1299:                                            .getName())) {
1300:                                        //pExec.addAttachUrl2DB((UrlAttachment)attach);
1301:                                        pExec
1302:                                                .addAttachFileInBddAndModel(attach);
1303:                                    }
1304:                                }
1305:                                oldAttachMap.remove(attach.getName());
1306:                            }
1307:                            attachValues = oldAttachMap.values();
1308:                            for (Iterator iter = attachValues.iterator(); iter
1309:                                    .hasNext();) {
1310:                                Attachment attach = (Attachment) iter.next();
1311:                                pExec.deleteAttachFromExecInBddAndModel(attach);
1312:                                //pExec.deleteAttachFromExecInDB(attach.getIdBdd());
1313:                            }
1314:
1315:                            Api.commitTrans(transNumber);
1316:
1317:                            // IHM
1318:                            if (!initScriptItem.isEnabled()
1319:                                    && !postScriptItem.isEnabled()) {
1320:                                modifyScriptMenu.setEnabled(false);
1321:                            } else {
1322:                                modifyScriptMenu.setEnabled(true);
1323:                            }
1324:                            executionTable.getModel().setValueAt(
1325:                                    pExec.getName(), selectedIndex, 1);
1326:                            executionTable.getModel().setValueAt(
1327:                                    pExec.getEnvironment(), selectedIndex, 2);
1328:                            executionTable.getModel().setValueAt(
1329:                                    pExec.getDataSet(), selectedIndex, 3);
1330:                            executionTable.getModel().setValueAt(
1331:                                    pExec.getCreationDate(), selectedIndex, 4);
1332:                            executionTable.getModel().setValueAt(
1333:                                    pExec.getAttachmentMap().keySet(),
1334:                                    selectedIndex, 5);
1335:                            executionTable.getColumnModel().getColumn(0)
1336:                                    .setMaxWidth(18);
1337:                        } catch (Exception exception) {
1338:                            Api.forceRollBackTrans(transNumber);
1339:                            Tools.ihmExceptionView(exception.toString());
1340:                        }
1341:
1342:                    }
1343:                    commitPostScriptItem.setEnabled(false);
1344:                    commitInitScriptItem.setEnabled(false);
1345:                } // if selecetd
1346:            }
1347:
1348:            public void deleteExecutionPerformed(ActionEvent e) {
1349:                //int selectedRowIndex = executionTable.getSelectedRow();
1350:                int[] selectedRows = executionTable.getSelectedRows();
1351:                Object[] options = { Language.getInstance().getText("Oui"),
1352:                        Language.getInstance().getText("Non") };
1353:                int choice = JOptionPane
1354:                        .showOptionDialog(
1355:                                ExecutionView.this ,
1356:                                Language
1357:                                        .getInstance()
1358:                                        .getText(
1359:                                                "Etes_vous_sûr_de_vouloir_supprimer_toutes_les_exécutions_sélectionnées_?"),
1360:                                Language.getInstance().getText("Attention_!"),
1361:                                JOptionPane.YES_NO_OPTION,
1362:                                JOptionPane.QUESTION_MESSAGE, null, options,
1363:                                options[1]);
1364:                if (choice == JOptionPane.YES_OPTION) {
1365:                    //if (selectedRowIndex != -1) {
1366:                    for (int selectedRowIndex = selectedRows.length - 1; selectedRowIndex >= 0; selectedRowIndex--) {
1367:                        //Execution exec = DataModel.getObservedExecution();
1368:                        //Execution exec = DataModel.getCurrentCampaign().getExecution((String)sorter.getValueAt(selectedRowIndex, 1));
1369:                        Execution exec = DataModel.getCurrentCampaign()
1370:                                .getExecution(
1371:                                        (String) sorter.getValueAt(
1372:                                                selectedRows[selectedRowIndex],
1373:                                                1));
1374:                        if (exec != null) {
1375:                            try {
1376:                                // BdD
1377:                                exec.deleteInBddAndModel();
1378:
1379:                                // IHM
1380:                                DataModel
1381:                                        .getExecutionTableModel()
1382:                                        .removeData(
1383:                                                sorter
1384:                                                        .modelIndex(selectedRows[selectedRowIndex]));
1385:                                executionTable.getColumnModel().getColumn(0)
1386:                                        .setMaxWidth(18);
1387:                                DataModel.getExecutionResultTableModel()
1388:                                        .clearTable();
1389:
1390:                            } catch (Exception exception) {
1391:                                Tools.ihmExceptionView(exception.toString());
1392:                            }
1393:
1394:                        }
1395:                    }
1396:                }
1397:            }
1398:
1399:            public void deleteExecutionResultPerformed(ActionEvent e) {
1400:                //int selectedRowIndex = detailsExecutionTable.getSelectedRow();
1401:                int[] selectedRows = detailsExecutionTable.getSelectedRows();
1402:                Object[] options = { Language.getInstance().getText("Oui"),
1403:                        Language.getInstance().getText("Non") };
1404:                int choice = JOptionPane
1405:                        .showOptionDialog(
1406:                                ExecutionView.this ,
1407:                                Language
1408:                                        .getInstance()
1409:                                        .getText(
1410:                                                "Etes_vous_sûr_de_vouloir_supprimer_tous_les_résultats_d'exécution_sélectionnés_?"),
1411:                                Language.getInstance().getText("Attention_!"),
1412:                                JOptionPane.YES_NO_OPTION,
1413:                                JOptionPane.QUESTION_MESSAGE, null, options,
1414:                                options[1]);
1415:                if (choice == JOptionPane.YES_OPTION) {
1416:                    //if (selectedRowIndex != -1) {
1417:                    for (int selectedRowIndex = selectedRows.length - 1; selectedRowIndex >= 0; selectedRowIndex--) {
1418:                        //ExecutionResult execResult = DataModel.getObservedExecutionResult();
1419:                        //ExecutionResult execResult = DataModel.getObservedExecution().getExecutionResult((String)detailsSorter.getValueAt(selectedRowIndex, 0));
1420:                        ExecutionResult execResult = DataModel
1421:                                .getObservedExecution().getExecutionResult(
1422:                                        (String) detailsSorter.getValueAt(
1423:                                                selectedRows[selectedRowIndex],
1424:                                                0));
1425:                        if (execResult != null) {
1426:                            try {
1427:                                // BdD
1428:                                execResult.deleteFromDB();
1429:
1430:                                // IHM
1431:                                DataModel
1432:                                        .getExecutionResultTableModel()
1433:                                        .removeData(
1434:                                                detailsSorter
1435:                                                        .modelIndex(selectedRows[selectedRowIndex]));
1436:                                DataModel.getObservedExecution()
1437:                                        .removeExecutionResult(execResult);
1438:
1439:                            } catch (Exception exception) {
1440:                                Tools.ihmExceptionView(exception.toString());
1441:                            }
1442:                        }
1443:                    }
1444:                }
1445:            }
1446:
1447:            public void continueExecutionPerformed(ActionEvent e) {
1448:                int detailsSelectedRowIndex = detailsExecutionTable
1449:                        .getSelectedRow();
1450:                //boolean toBeContinued = true;
1451:                if (detailsSelectedRowIndex != -1) {
1452:                    // L'exécution affichée à l'écran
1453:                    // Execution courante
1454:                    Execution exec = DataModel.getObservedExecution();
1455:                    ExecutionResult finalExecResult = DataModel
1456:                            .getObservedExecutionResult();
1457:                    TestMethods.continueExecution(exec, finalExecResult, this ,
1458:                            false);
1459:
1460:                    /*
1461:                    finalExecResult.setExecutionDate(new Date(GregorianCalendar.getInstance().getTimeInMillis()));
1462:                    finalExecResult.setTester(DataModel.getCurrentUser().getLastName() + " " + DataModel.getCurrentUser().getFirstName());
1463:                    
1464:                    Vector pAllTestToExecute = new Vector();
1465:                    //Liste des tests groupés en sous-listes (manuels/automatiques)
1466:                    ArrayList splittedListOfTest = Tools.getListOfTestManualOrAutomatic(DataModel.getCurrentCampaign().getTestList(),   finalExecResult, pAllTestToExecute);
1467:                    Vector listExec = new Vector();
1468:                    // On parcourt la liste des sous-listes
1469:                    for (int h =0; h < splittedListOfTest.size(); h++) {
1470:                        if (((ArrayList)splittedListOfTest.get(h)).get(0) instanceof ManualTest) {
1471:                            listExec.add(new ManualExecution((ArrayList)splittedListOfTest.get(h), exec,  finalExecResult));
1472:                            
1473:                        } else {
1474:                            //Sous liste de tests automatiques
1475:                            ArrayList automaticTestList = (ArrayList)splittedListOfTest.get(h);
1476:                            listExec.add(new AutomaticExecution(automaticTestList, exec, finalExecResult));
1477:                        }
1478:                    }
1479:                    //new callExecThread(listExec, exec, splittedListOfTest, selectedRowIndex, attachToBeSuppress, false, finalExecResult, null, pAllTestToExecute.toArray()).start();
1480:                    new CallExecThread(listExec, exec, splittedListOfTest, false, finalExecResult, null, pAllTestToExecute.toArray(), (Component)this, false).start();
1481:                     */
1482:                }
1483:            }
1484:
1485:            public void attachExecutionPerformed(ActionEvent e) {
1486:                HashMap oldMap = new HashMap();
1487:                Set keysSet = DataModel.getObservedExecution()
1488:                        .getAttachmentMap().keySet();
1489:                for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
1490:                    Object elem = iter.next();
1491:                    oldMap.put(elem, DataModel.getObservedExecution()
1492:                            .getAttachmentMap().get(elem));
1493:                }
1494:                AttachmentViewWindow attachViewWindow = new AttachmentViewWindow(
1495:                        SalomeTMF.ptrSalomeTMF, EXECUTION, DataModel
1496:                                .getObservedExecution(), null, null, null);
1497:                if (!attachViewWindow.cancelPerformed) {
1498:                    int transNumber = -1;
1499:                    try {
1500:                        // BdD
1501:                        transNumber = Api
1502:                                .beginTransaction(Api.UPDATE_ATTACHMENT);
1503:                        Set keysSetNew = DataModel.getObservedExecution()
1504:                                .getAttachmentMap().keySet();
1505:                        for (Iterator iter = keysSetNew.iterator(); iter
1506:                                .hasNext();) {
1507:                            String elem = (String) iter.next();
1508:                            if (!oldMap.containsKey(elem)) {
1509:                                Attachment attach = DataModel
1510:                                        .getObservedExecution().getAttachment(
1511:                                                elem);
1512:                                DataModel.getObservedExecution()
1513:                                        .addAttachFileInBddAndModel(attach);
1514:                                /*if (attach instanceof FileAttachment) {
1515:                                	DataModel.getObservedExecution().addAttachFile2DB((FileAttachment)attach);
1516:                                } else {
1517:                                	DataModel.getObservedExecution().addAttachUrl2DB((UrlAttachment)attach);
1518:                                }*/
1519:                            }
1520:                            oldMap.remove(elem);
1521:                        }
1522:                        Set keyOfOldMap = oldMap.keySet();
1523:                        for (Iterator iterator = keyOfOldMap.iterator(); iterator
1524:                                .hasNext();) {
1525:                            String elem = (String) iterator.next();
1526:                            Attachment attach = (Attachment) oldMap.get(elem);
1527:                            DataModel.getObservedExecution()
1528:                                    .deleteAttachFromExecInBddAndModel(attach);
1529:                            //DataModel.getObservedExecution().deleteAttachFromExecInDB(attach.getIdBdd());
1530:                        }
1531:                        Api.commitTrans(transNumber);
1532:
1533:                        // IHM
1534:                        sorter.setValueAt(DataModel.getObservedExecution()
1535:                                .getAttachmentMap().keySet(), executionTable
1536:                                .getSelectedRow(), 5);
1537:
1538:                    } catch (Exception exception) {
1539:                        Api.forceRollBackTrans(transNumber);
1540:                        DataModel.getObservedExecution().setAttachmentMap(
1541:                                oldMap);
1542:                        Tools.ihmExceptionView(exception.toString());
1543:                    }
1544:                }
1545:            }
1546:
1547:            public void attachExecutionResultPerformed(ActionEvent e) {
1548:                HashMap oldMap = new HashMap();
1549:                Set keysSet = DataModel.getObservedExecutionResult()
1550:                        .getAttachmentMap().keySet();
1551:                for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
1552:                    Object elem = iter.next();
1553:                    oldMap.put(elem, DataModel.getObservedExecutionResult()
1554:                            .getAttachmentMap().get(elem));
1555:                }
1556:                AttachmentViewWindow attachViewWindow = new AttachmentViewWindow(
1557:                        SalomeTMF.ptrSalomeTMF, EXECUTION_RESULT, DataModel
1558:                                .getObservedExecutionResult(), null, null, null);
1559:                if (!attachViewWindow.cancelPerformed) {
1560:                    int transNumber = -1;
1561:                    try {
1562:                        // BdD
1563:                        Api
1564:                                .log("[ExecutionView:attachExecutionResultPerformed] : UPDATE_ATTACHMENT IN BDD");
1565:                        transNumber = Api
1566:                                .beginTransaction(Api.UPDATE_ATTACHMENT);
1567:                        Set keysSetNew = DataModel.getObservedExecutionResult()
1568:                                .getAttachmentMap().keySet();
1569:                        for (Iterator iter = keysSetNew.iterator(); iter
1570:                                .hasNext();) {
1571:                            String elem = (String) iter.next();
1572:                            if (!oldMap.containsKey(elem)) {
1573:                                Attachment attach = DataModel
1574:                                        .getObservedExecutionResult()
1575:                                        .getAttachment(elem);
1576:                                if (attach instanceof  FileAttachment) {
1577:                                    DataModel.getObservedExecutionResult()
1578:                                            .addAttachFile2DB(
1579:                                                    (FileAttachment) attach);
1580:                                } else {
1581:                                    DataModel.getObservedExecutionResult()
1582:                                            .addAttachUrl2DB(
1583:                                                    (UrlAttachment) attach);
1584:                                }
1585:                            }
1586:                            oldMap.remove(elem);
1587:                        }
1588:                        Set keyOfOldMap = oldMap.keySet();
1589:                        for (Iterator iterator = keyOfOldMap.iterator(); iterator
1590:                                .hasNext();) {
1591:                            String elem = (String) iterator.next();
1592:                            Attachment attach = (Attachment) oldMap.get(elem);
1593:                            DataModel.getObservedExecutionResult()
1594:                                    .deleteAttachFromExecResultInDB(
1595:                                            attach.getIdBdd());
1596:                        }
1597:                        Api.commitTrans(transNumber);
1598:                    } catch (Exception exception) {
1599:                        Api.forceRollBackTrans(transNumber);
1600:                        DataModel.getObservedExecutionResult()
1601:                                .setAttachmentMap(oldMap);
1602:                        Tools.ihmExceptionView(exception.toString());
1603:                    }
1604:                }
1605:            }
1606:
1607:            public void modifyinitScriptPerformed(ActionEvent e) {
1608:                modifyScript(PRE_SCRIPT);
1609:            }
1610:
1611:            public void modifypostScriptPerformed(ActionEvent e) {
1612:                modifyScript(POST_SCRIPT);
1613:            }
1614:
1615:            public void commitInitScriptPerformed(ActionEvent e) {
1616:                commitScript(PRE_SCRIPT);
1617:            }
1618:
1619:            public void commitPostScriptPerformed(ActionEvent e) {
1620:                commitScript(POST_SCRIPT);
1621:            }
1622:
1623:            private int findIndexOfExcution(Execution pExec) {
1624:                Api.log("[ExecutionView:findIndexOfExcution] : try to find "
1625:                        + pExec.getName() + " in executionTable");
1626:                int ret = -1;
1627:                boolean continu = true;
1628:                int size = executionTable.getModel().getRowCount();
1629:                int i = 0;
1630:                while (continu && i < size) {
1631:                    String name = (String) executionTable.getModel()
1632:                            .getValueAt(i, 1);
1633:                    Api.log("[ExecutionView:findIndexOfExcution] : compare"
1634:                            + pExec.getName() + " and " + name);
1635:
1636:                    if (name.equals(pExec.getName())) {
1637:                        ret = i;
1638:                        continu = false;
1639:                    } else {
1640:                        i++;
1641:                    }
1642:                }
1643:                return ret;
1644:
1645:            }
1646:
1647:            public void updateIHMTable(boolean newLaunch, Execution exec,
1648:                    ExecutionResult finalExecResult) {
1649:                if (newLaunch) {
1650:                    if (finalExecResult.getTime() == null) {
1651:                        finalExecResult.setTime(new Time(GregorianCalendar
1652:                                .getInstance().getTimeInMillis()));
1653:                    }
1654:                    int selectedRowIndex = findIndexOfExcution(exec);
1655:                    if (selectedRowIndex != -1) {
1656:                        if (exec.getName().equals(
1657:                                sorter.getValueAt(selectedRowIndex, 1))) {
1658:                            ArrayList resultList = new ArrayList();
1659:                            // la table des r?sultats d'ex?cutions
1660:                            resultList.add(finalExecResult.getName());
1661:                            SimpleDateFormat formater = new SimpleDateFormat(
1662:                                    "dd/MM/yyyy");
1663:                            resultList.add(formater.format(
1664:                                    finalExecResult.getExecutionDate())
1665:                                    .toString()
1666:                                    + "  "
1667:                                    + finalExecResult.getTime().toString());
1668:                            resultList.add(finalExecResult.getTester());
1669:                            resultList
1670:                                    .add(finalExecResult.getExecutionStatus());
1671:                            resultList.add(finalExecResult.getFormatedStat());
1672:                            DataModel.getExecutionResultTableModel().addRow(
1673:                                    resultList);
1674:                            // La table des ex?cutions
1675:                            sorter.setValueAt(finalExecResult
1676:                                    .getExecutionDate().toString(),
1677:                                    selectedRowIndex, 6);
1678:                        }
1679:                    }
1680:                } else {
1681:                    detailsSorter.setValueAt(finalExecResult.getTester(),
1682:                            detailsExecutionTable.getSelectedRow(), 2);
1683:                    detailsSorter.setValueAt(finalExecResult
1684:                            .getExecutionStatus(), detailsExecutionTable
1685:                            .getSelectedRow(), 3);
1686:                    detailsSorter.setValueAt(finalExecResult.getFormatedStat(),
1687:                            detailsExecutionTable.getSelectedRow(), 4);
1688:                }
1689:
1690:                int detailsTableIndex = detailsExecutionTable.getSelectedRow();
1691:                if (detailsTableIndex != -1
1692:                        && finalExecResult.getName().equals(
1693:                                detailsSorter.getValueAt(detailsTableIndex, 0))
1694:                        && finalExecResult.getExecutionStatus()
1695:                                .equals(FINISHED)) {
1696:                    continueExecution.setEnabled(false);
1697:                }
1698:            }
1699:
1700:        } // 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.