Source Code Cross Referenced for AskNewExecution.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) 


001:        /*
002:         * SalomeTMF is a Test Management Framework
003:         * Copyright (C) 2005 France Telecom R&D
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *
019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.ihm;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Color;
028:        import java.awt.Container;
029:        import java.awt.Dimension;
030:        import java.awt.FlowLayout;
031:        import java.awt.event.ActionEvent;
032:        import java.awt.event.ActionListener;
033:        import java.awt.event.WindowEvent;
034:        import java.awt.event.WindowListener;
035:        import java.io.File;
036:        import java.sql.Date;
037:        import java.util.ArrayList;
038:        import java.util.Collection;
039:        import java.util.Enumeration;
040:        import java.util.GregorianCalendar;
041:        import java.util.HashSet;
042:        import java.util.Iterator;
043:        import java.util.Set;
044:        import java.util.StringTokenizer;
045:
046:        import javax.swing.BorderFactory;
047:        import javax.swing.Box;
048:        import javax.swing.BoxLayout;
049:        import javax.swing.DefaultComboBoxModel;
050:        import javax.swing.JButton;
051:        import javax.swing.JComboBox;
052:        import javax.swing.JDialog;
053:        import javax.swing.JFileChooser;
054:        import javax.swing.JLabel;
055:        import javax.swing.JOptionPane;
056:        import javax.swing.JPanel;
057:        import javax.swing.JTextField;
058:
059:        import org.java.plugin.Extension;
060:        import org.objectweb.salome_tmf.api.Api;
061:        import org.objectweb.salome_tmf.api.ApiConstants;
062:        import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
063:        import org.objectweb.salome_tmf.data.Attachment;
064:        import org.objectweb.salome_tmf.data.Campaign;
065:        import org.objectweb.salome_tmf.data.ConnectionData;
066:        import org.objectweb.salome_tmf.data.DataConstants;
067:        import org.objectweb.salome_tmf.data.DataSet;
068:        import org.objectweb.salome_tmf.data.Environment;
069:        import org.objectweb.salome_tmf.data.Execution;
070:        import org.objectweb.salome_tmf.data.Parameter;
071:        import org.objectweb.salome_tmf.data.ProjectData;
072:        import org.objectweb.salome_tmf.data.Script;
073:        import org.objectweb.salome_tmf.data.Test;
074:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
075:        import org.objectweb.salome_tmf.ihm.datawrapper.TestMethods;
076:        import org.objectweb.salome_tmf.ihm.languages.Language;
077:        import org.objectweb.salome_tmf.ihm.models.ScriptFileFilter;
078:        import org.objectweb.salome_tmf.ihm.tools.Tools;
079:
080:        /**
081:         * Classe qui définit la fenêtre permettant de créer une nouvelle exécution
082:         * @author teaml039
083:         * @version : 0.1
084:         */
085:        public class AskNewExecution extends JDialog implements  ApiConstants,
086:                DataConstants, ActionListener {
087:
088:            /**
089:             * Label pour récupérer le nom de l'exécution
090:             */
091:            JLabel executionName;
092:
093:            /**
094:             * Champ pour récupérer le nom de l'exécution
095:             */
096:            JTextField executionNameTextField;
097:
098:            /**
099:             * Label de la date de création
100:             */
101:            JLabel creationDate;
102:
103:            /**
104:             * Modèle de données pour la liste déroulante des jeux de données
105:             */
106:            private DefaultComboBoxModel comboModelForDataSet;
107:
108:            /**
109:             * Liste déroulante des jeux de données
110:             */
111:            JComboBox dataSetComboBox;
112:
113:            /**
114:             * Bouton pour entrer un nouveau jeu de données
115:             */
116:            JButton newDataSetButton;
117:
118:            /**
119:             * Label du script d'initialisation
120:             */
121:            JLabel initScriptLabel;
122:
123:            /**
124:             * Label du script de restitution
125:             */
126:            JLabel restitutionScriptLabel;
127:
128:            /**
129:             * Bouton pour ajouter un script d'initialisation
130:             */
131:            JButton addInitScriptButton;
132:
133:            /**
134:             * Bouton pour supprimer un script d'initialisation
135:             */
136:            JButton removeInitScriptButton;
137:
138:            /**
139:             * Bouton pour ajouter un script de restitution
140:             */
141:            JButton addRestitutionScriptButton;
142:
143:            /**
144:             * Bouton pour supprimer un script de restitution
145:             */
146:            JButton removeRestitutionScriptButton;
147:
148:            /**
149:             * Modèle de données de la liste déroulante des environnements
150:             */
151:            private DefaultComboBoxModel comboModelForEnvironment;
152:
153:            /**
154:             * Liste déroulante des environnements
155:             */
156:            JComboBox environmentComboBox;
157:
158:            /**
159:             * Bouton pour entrer un nouvel environnement
160:             */
161:            JButton newEnvironmentButton;
162:
163:            JButton validationButton;
164:            JButton cancelButton;
165:
166:            /**
167:             * Date de création
168:             */
169:            Date time;
170:
171:            /**
172:             * Nouvelle exécution
173:             */
174:            Execution execution;
175:
176:            AttachmentView attachmentPanel;
177:
178:            Script initScript;
179:
180:            Script restitutionScript;
181:
182:            File initScriptFile;
183:
184:            File restitutionScriptFile;
185:
186:            String message;
187:
188:            static ScriptFileFilter[] tabPlugScriptFileFilter = null;
189:            static JFileChooser fileChooser = new JFileChooser();
190:            /**************************************************************************/
191:            /**							CONSTRUCTEURS								***/
192:            /**************************************************************************/
193:            boolean initNewFile = false;
194:            boolean restitutionNewFile = false;
195:
196:            /**
197:             * Constructeur de la fenêtre
198:             */
199:            public AskNewExecution(Execution exec) {
200:
201:                super (SalomeTMF.ptrFrame, true);
202:                executionName = new JLabel(Language.getInstance().getText(
203:                        "Nom_de_l'exécution_:_"));
204:                executionNameTextField = new JTextField(20);
205:                creationDate = new JLabel();
206:                comboModelForDataSet = new DefaultComboBoxModel();
207:                dataSetComboBox = new JComboBox(comboModelForDataSet);
208:                newDataSetButton = new JButton(Language.getInstance().getText(
209:                        "Nouveau"));
210:                initScriptLabel = new JLabel(Language.getInstance().getText(
211:                        "Script_d'initialisation_:_"));
212:                restitutionScriptLabel = new JLabel(Language.getInstance()
213:                        .getText("Script_de_restitution_:_"));
214:                addInitScriptButton = new JButton(Language.getInstance()
215:                        .getText("Ajouter"));
216:                removeInitScriptButton = new JButton(Language.getInstance()
217:                        .getText("Supprimer"));
218:                addRestitutionScriptButton = new JButton(Language.getInstance()
219:                        .getText("Ajouter"));
220:                removeRestitutionScriptButton = new JButton(Language
221:                        .getInstance().getText("Supprimer"));
222:                comboModelForEnvironment = new DefaultComboBoxModel();
223:                newEnvironmentButton = new JButton(Language.getInstance()
224:                        .getText("Nouveau"));
225:                environmentComboBox = new JComboBox(comboModelForEnvironment);
226:                JPanel namePanel = new JPanel();
227:                namePanel.add(executionName);
228:                namePanel.add(executionNameTextField);
229:
230:                if (exec != null) {
231:                    time = exec.getCreationDate();
232:                } else {
233:                    time = new Date(GregorianCalendar.getInstance()
234:                            .getTimeInMillis());
235:                    creationDate.setText(Language.getInstance().getText(
236:                            "Date_de_création_:_")
237:                            + time);
238:                }
239:                // Jeu de données
240:
241:                JPanel comboDataSetPanel = new JPanel(new FlowLayout(
242:                        FlowLayout.LEFT));
243:                comboDataSetPanel.add(dataSetComboBox);
244:
245:                JPanel newDataSetButtonPanel = new JPanel(new FlowLayout(
246:                        FlowLayout.LEFT));
247:                newDataSetButtonPanel.add(newDataSetButton);
248:
249:                JPanel dataSetPanel = new JPanel();
250:                dataSetPanel.setLayout(new BoxLayout(dataSetPanel,
251:                        BoxLayout.Y_AXIS));
252:                dataSetPanel.add(comboDataSetPanel);
253:                dataSetPanel.add(Box.createRigidArea(new Dimension(1, 5)));
254:                dataSetPanel.add(newDataSetButtonPanel);
255:                dataSetPanel.setBorder(BorderFactory.createTitledBorder(
256:                        BorderFactory.createLineBorder(Color.BLACK), Language
257:                                .getInstance().getText("Jeu_de_données")));
258:
259:                // Scripts
260:                addInitScriptButton.addActionListener(this );
261:                addRestitutionScriptButton.addActionListener(this );
262:                removeInitScriptButton.addActionListener(this );
263:                removeRestitutionScriptButton.addActionListener(this );
264:
265:                JPanel initLabelPanel = new JPanel(new FlowLayout(
266:                        FlowLayout.LEFT));
267:                initLabelPanel.add(initScriptLabel);
268:
269:                JPanel initButtonPanel = new JPanel(new FlowLayout(
270:                        FlowLayout.LEFT));
271:                initButtonPanel.add(addInitScriptButton);
272:                initButtonPanel.add(removeInitScriptButton);
273:
274:                JPanel restLabelPanel = new JPanel(new FlowLayout(
275:                        FlowLayout.LEFT));
276:                restLabelPanel.add(restitutionScriptLabel);
277:
278:                JPanel restButtonPanel = new JPanel(new FlowLayout(
279:                        FlowLayout.LEFT));
280:                restButtonPanel.add(addRestitutionScriptButton);
281:                restButtonPanel.add(removeRestitutionScriptButton);
282:
283:                JPanel allScriptPanel = new JPanel();
284:                allScriptPanel.setLayout(new BoxLayout(allScriptPanel,
285:                        BoxLayout.Y_AXIS));
286:                allScriptPanel.setBorder(BorderFactory.createTitledBorder(
287:                        BorderFactory.createLineBorder(Color.BLACK), Language
288:                                .getInstance().getText("Scripts")));
289:                allScriptPanel.add(initLabelPanel);
290:                allScriptPanel.add(initButtonPanel);
291:                allScriptPanel.add(Box.createRigidArea(new Dimension(1, 10)));
292:                allScriptPanel.add(restLabelPanel);
293:                allScriptPanel.add(restButtonPanel);
294:
295:                newEnvironmentButton.setToolTipText(Language.getInstance()
296:                        .getText("Nouvel_environnement"));
297:                newEnvironmentButton.addActionListener(this );
298:
299:                newDataSetButton.setToolTipText(Language.getInstance().getText(
300:                        "Nouveau_jeu_de_données"));
301:                newDataSetButton.addActionListener(this );
302:                // Context
303:                JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
304:                comboPanel.add(environmentComboBox);
305:
306:                JPanel contextButtonPanel = new JPanel(new FlowLayout(
307:                        FlowLayout.LEFT));
308:                contextButtonPanel.add(newEnvironmentButton);
309:
310:                JPanel contextPanel = new JPanel();
311:                contextPanel.setLayout(new BoxLayout(contextPanel,
312:                        BoxLayout.Y_AXIS));
313:                contextPanel.add(comboPanel);
314:                contextPanel.add(Box.createRigidArea(new Dimension(1, 5)));
315:                contextPanel.add(contextButtonPanel);
316:                contextPanel.setBorder(BorderFactory.createTitledBorder(
317:                        BorderFactory.createLineBorder(Color.BLACK), Language
318:                                .getInstance().getText("Environnement")));
319:
320:                // validation
321:                validationButton = new JButton(Language.getInstance().getText(
322:                        "Valider"));
323:                validationButton.addActionListener(this );
324:
325:                cancelButton = new JButton(Language.getInstance().getText(
326:                        "Annuler"));
327:                cancelButton.addActionListener(this );
328:
329:                JPanel validationPanel = new JPanel(new FlowLayout(
330:                        FlowLayout.CENTER));
331:                validationPanel.add(validationButton);
332:                validationPanel.add(cancelButton);
333:
334:                attachmentPanel = new AttachmentView(DataModel.getApplet(),
335:                        EXECUTION, EXECUTION, exec, SMALL_SIZE_FOR_ATTACH,
336:                        null, null, null);
337:                attachmentPanel.setBorder(BorderFactory.createTitledBorder(
338:                        BorderFactory.createLineBorder(Color.BLACK), Language
339:                                .getInstance().getText("Attachements")));
340:
341:                JPanel allPanel = new JPanel();
342:                allPanel.setLayout(new BoxLayout(allPanel, BoxLayout.Y_AXIS));
343:                allPanel.add(namePanel);
344:                allPanel.add(creationDate);
345:                allPanel.add(dataSetPanel);
346:                allPanel.add(contextPanel);
347:                allPanel.add(allScriptPanel);
348:                allPanel.add(attachmentPanel);
349:                allPanel.add(validationPanel);
350:
351:                Container contentPaneFrame = this .getContentPane();
352:                contentPaneFrame.add(allPanel, BorderLayout.CENTER);
353:
354:                initData(exec);
355:                giveAccessToIhmExecutionView();
356:                this .addWindowListener(new WindowListener() {
357:                    public void windowClosing(WindowEvent e) {
358:                        execution = null;
359:                        DataModel.initAttachmentTable(DataModel
360:                                .getCurrentCampaign().getAttachmentMap()
361:                                .values());
362:                    }
363:
364:                    public void windowDeiconified(WindowEvent e) {
365:                    }
366:
367:                    public void windowOpened(WindowEvent e) {
368:                    }
369:
370:                    public void windowActivated(WindowEvent e) {
371:                    }
372:
373:                    public void windowDeactivated(WindowEvent e) {
374:                    }
375:
376:                    public void windowClosed(WindowEvent e) {
377:                    }
378:
379:                    public void windowIconified(WindowEvent e) {
380:                    }
381:                });
382:
383:                if (tabPlugScriptFileFilter == null) {
384:                    initTabPlugScriptFileFilter();
385:                }
386:
387:                this .setLocation(300, 20);
388:                if (exec != null) {
389:                    this .setTitle(Language.getInstance().getText(
390:                            "Modifier_l'exécution"));
391:                } else {
392:                    this .setTitle(Language.getInstance().getText(
393:                            "Nouvelle_exécution"));
394:                }
395:                this .pack();
396:                this .setVisible(true);
397:
398:            } // Fin du constructeur AskNewExecution/0
399:
400:            /******************************************************************************/
401:            /** 							ACCESSEURS ET MUTATEURS						***/
402:            /******************************************************************************/
403:
404:            /**
405:             * Retourne l'exécution créée
406:             * @return l'exécution créée
407:             */
408:            public Execution getExecution() {
409:                return execution;
410:            } // Fin de la méthode getExecution/0
411:
412:            private void initTabPlugScriptFileFilter() {
413:                if (SalomeTMF.associatedScriptEngine.size() == 0) {
414:                    removeInitScriptButton.setEnabled(false);
415:                    addInitScriptButton.setEnabled(false);
416:                    addRestitutionScriptButton.setEnabled(false);
417:                    removeRestitutionScriptButton.setEnabled(false);
418:                    fileChooser = null;
419:                    return;
420:                }
421:
422:                tabPlugScriptFileFilter = new ScriptFileFilter[SalomeTMF.associatedScriptEngine
423:                        .size()];
424:                Enumeration e = SalomeTMF.associatedScriptEngine.keys();
425:                int i = 0;
426:                while (e.hasMoreElements()) {
427:                    Extension ScriptExt = (Extension) e.nextElement();
428:                    String extID = ScriptExt.getId();
429:                    String extList = (String) SalomeTMF.associatedScriptEngine
430:                            .get(ScriptExt);
431:                    StringTokenizer st = new StringTokenizer(extList, ",");
432:                    String[] tabExt = new String[st.countTokens()];
433:                    System.out.println("Add extension " + extID
434:                            + ", with filter :" + extList);
435:                    int j = 0;
436:                    while (st.hasMoreTokens()) {
437:                        tabExt[j] = st.nextToken();
438:                        j++;
439:                    }
440:                    tabPlugScriptFileFilter[i] = new ScriptFileFilter(extID,
441:                            tabExt);
442:                    i++;
443:                }
444:                int tabFilterSize = tabPlugScriptFileFilter.length;
445:                for (i = 0; i < tabFilterSize; i++) {
446:                    fileChooser
447:                            .addChoosableFileFilter(tabPlugScriptFileFilter[i]);
448:                }
449:                fileChooser.setAcceptAllFileFilterUsed(false);
450:            }
451:
452:            /**
453:             *
454:             *
455:             */
456:            public void initData(Execution exec) {
457:                DataModel.getAttachmentTableModel().clearTable();
458:                comboModelForDataSet.addElement(ProjectData.getEmptyDataSet());
459:                for (int i = 0; i < DataModel.getCurrentCampaign()
460:                        .getDataSetList().size(); i++) {
461:                    comboModelForDataSet.addElement(DataModel
462:                            .getCurrentCampaign().getDataSetList().get(i));
463:                }
464:                //comboModelForEnvironment.addElement(TestData.getEmptyEnvironment());
465:                for (int j = 0; j < ProjectData.getCurrentProject()
466:                        .getEnvironmentList().size(); j++) {
467:                    comboModelForEnvironment.addElement(ProjectData
468:                            .getCurrentProject().getEnvironmentList().get(j));
469:                }
470:                if (exec != null) {
471:                    execution = exec;
472:
473:                    executionNameTextField.setText(exec.getName());
474:
475:                    if (exec.getDataSet() != null) {
476:                        comboModelForDataSet.setSelectedItem(exec.getDataSet());
477:                    }
478:
479:                    comboModelForEnvironment.setSelectedItem(exec
480:                            .getEnvironment());
481:
482:                    if (exec.getExecutionResultList().size() != 0) {
483:                        dataSetComboBox.setEnabled(false);
484:                        newDataSetButton.setEnabled(false);
485:                        environmentComboBox.setEnabled(false);
486:                        newEnvironmentButton.setEnabled(false);
487:                        addInitScriptButton.setEnabled(false);
488:                        removeInitScriptButton.setEnabled(false);
489:                        addRestitutionScriptButton.setEnabled(false);
490:                        removeRestitutionScriptButton.setEnabled(false);
491:                    }
492:
493:                    if (exec.getInitScript() != null) {
494:                        initScriptLabel.setText(Language.getInstance().getText(
495:                                "Script_d'initialisation_:_")
496:                                + exec.getInitScript().getName());
497:                        initScript = exec.getInitScript();
498:
499:                    }
500:
501:                    if (exec.getPostScript() != null) {
502:                        restitutionScriptLabel.setText(Language.getInstance()
503:                                .getText("Script_de_restitution_:_")
504:                                + exec.getPostScript().getName());
505:                        restitutionScript = exec.getPostScript();
506:                    }
507:
508:                    Collection col = exec.getAttachmentMap().values();
509:                    DataModel.initAttachmentTable(col);
510:
511:                } else {
512:                    execution = new Execution();
513:                    int i = DataModel.getExecutionTableModel().getRowCount();
514:                    Campaign camp = DataModel.getCurrentCampaign();
515:                    while (camp.getExecutionList().contains(
516:                            camp.getExecution("Exec" + i))) {
517:                        i++;
518:                    }
519:                    executionNameTextField.setText("Exec" + i);
520:                }
521:            } // Fin de la méthode initData/0
522:
523:            private String parameterConflict(DataSet dataSet, Environment env) {
524:                String result = "";
525:                if (dataSet != null && env != null) {
526:                    Set keysSet = dataSet.getParametersHashMap().keySet();
527:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
528:                        String paramName = (String) iter.next();
529:                        Parameter param = ProjectData.getCurrentProject()
530:                                .getParameter(paramName);
531:                        if (env.containsParameter(param)) {
532:                            result = result + " " + param.getName() + "\n";
533:                        }
534:                    }
535:                }
536:                return result;
537:            }
538:
539:            /**
540:             * @return
541:             */
542:            public File getInitScriptFile() {
543:                return initScriptFile;
544:            }
545:
546:            /**
547:             * @return
548:             */
549:            public File getRestitutionScriptFile() {
550:                return restitutionScriptFile;
551:            }
552:
553:            private DataSet createDataSetFromCampaign(HashSet setOfParam,
554:                    Environment env, ArrayList notValuedParamList) {
555:                DataSet dataSet = new DataSet();
556:
557:                for (Iterator iter = setOfParam.iterator(); iter.hasNext();) {
558:                    Parameter param = (Parameter) iter.next();
559:                    if (env.getParameter(param.getName()) != null) {
560:                        dataSet.addParameter(param.getName(), env
561:                                .getParameterValue(param));
562:                    } else {
563:                        dataSet.addParameter(param.getName(), "");
564:                        notValuedParamList.add(param);
565:                        message = message + "* " + param.getName() + "\n";
566:                    }
567:                }
568:                int i = 0;
569:                String name = "dataSet_" + i;
570:                while (DataModel.getCurrentCampaign().getDataSet(name) != null
571:                        || ConnectionData.isInBaseDataSet(name, DataModel
572:                                .getCurrentCampaign().getName())) {
573:                    i++;
574:                    name = "dataSet_" + i;
575:                }
576:                dataSet.setName(name);
577:                dataSet.setDescription(Language.getInstance().getText(
578:                        "Jeu_de_données_généré_automatiquement."));
579:                DataModel.getCurrentCampaign().addDataSet(dataSet);
580:                ArrayList dataView = new ArrayList();
581:                dataView.add(dataSet.getName());
582:                dataView.add(dataSet.getDescription());
583:                DataModel.getDataSetTableModel().addRow(dataView);
584:                int transNumber = -1;
585:                try {
586:                    // BdD
587:                    transNumber = Api.beginTransaction(Api.INSERT_DATA_SET);
588:                    //dataSet.add2DB( DataModel.getCurrentCampaign());
589:                    dataSet.addToBddAndModel(DataModel.getCurrentCampaign());
590:                    Set keysSet = dataSet.getParametersHashMap().keySet();
591:                    for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
592:                        String paramName = (String) iter.next();
593:                        String value = dataSet.getValue(paramName);
594:                        if (value == null)
595:                            value = "";
596:                        //dataSet.addParamValue2DB(value, ProjectData.getCurrentProject().getParameter(paramName));
597:                        dataSet.addParamValueToBddAndModel(value, ProjectData
598:                                .getCurrentProject().getParameter(paramName));
599:                    }
600:                    Api.commitTrans(transNumber);
601:
602:                    return dataSet;
603:                } catch (Exception exception) {
604:                    Api.forceRollBackTrans(transNumber);
605:                    Tools.ihmExceptionView(exception.toString());
606:                }
607:
608:                return null;
609:            }
610:
611:            private void createAndQuit() {
612:                if (environmentComboBox.getSelectedItem() != null) {
613:                    String conflicts = parameterConflict(
614:                            (DataSet) dataSetComboBox.getSelectedItem(),
615:                            (Environment) environmentComboBox.getSelectedItem());
616:                    if (conflicts.length() > 0) {
617:
618:                        JOptionPane
619:                                .showMessageDialog(
620:                                        AskNewExecution.this ,
621:                                        Language
622:                                                .getInstance()
623:                                                .getText(
624:                                                        "Lors_de_l'exécution,_les_valeurs_des_paramètres_:\n")
625:                                                + conflicts
626:                                                + Language
627:                                                        .getInstance()
628:                                                        .getText(
629:                                                                "_seront_celles_du_jeu_de_données."),
630:                                        Language.getInstance().getText(
631:                                                "Attention_!"),
632:                                        JOptionPane.WARNING_MESSAGE);
633:                    }
634:
635:                    execution.setName(executionNameTextField.getText().trim());
636:                    execution.setCampagne(DataModel.getCurrentCampaign());
637:                    execution.setCreationDate(time);
638:
639:                    HashSet setOfParam = new HashSet();
640:                    // Récupération de tous les paramètres de la campagne
641:                    for (int i = 0; i < DataModel.getCurrentCampaign()
642:                            .getTestList().size(); i++) {
643:                        Test test = (Test) DataModel.getCurrentCampaign()
644:                                .getTestList().get(i);
645:                        for (int j = 0; j < test.getParameterList().size(); j++) {
646:                            setOfParam.add(test.getParameterList().get(j));
647:                        }
648:                    }
649:                    ArrayList notValuedParamList = new ArrayList();
650:                    message = "";
651:                    if (((DataSet) dataSetComboBox.getSelectedItem()).getName()
652:                            .equals(ProjectData.EMPTY_NAME)) {
653:                        //if (((DataSet)dataSetComboBox.getSelectedItem()).getName().equals(Language.getInstance().getText("Aucun"))) {
654:                        //if (((Environment)environmentComboBox.getSelectedItem()).getParametersHashTable().size() > 0) {
655:                        if (!setOfParam.isEmpty()) {
656:                            execution.setDataSet(createDataSetFromCampaign(
657:                                    setOfParam,
658:                                    (Environment) environmentComboBox
659:                                            .getSelectedItem(),
660:                                    notValuedParamList));
661:                        } else {
662:                            execution.setDataSet((DataSet) dataSetComboBox
663:                                    .getSelectedItem());
664:                        }
665:                    } else {
666:                        message = TestMethods.notValuedParamListCreation(
667:                                setOfParam, (Environment) environmentComboBox
668:                                        .getSelectedItem(),
669:                                (DataSet) dataSetComboBox.getSelectedItem(),
670:                                notValuedParamList);
671:                        execution.setDataSet((DataSet) dataSetComboBox
672:                                .getSelectedItem());
673:                    }
674:                    if (notValuedParamList.size() > 0) {
675:                        JOptionPane
676:                                .showMessageDialog(
677:                                        AskNewExecution.this ,
678:                                        Language
679:                                                .getInstance()
680:                                                .getText(
681:                                                        "Attention_!\nLes_paramètres_suivants_:\n")
682:                                                + message
683:                                                + Language
684:                                                        .getInstance()
685:                                                        .getText(
686:                                                                "ne_sont_pas_valués."),
687:                                        Language.getInstance().getText(
688:                                                "Attention_!"),
689:                                        JOptionPane.INFORMATION_MESSAGE);
690:                    }
691:
692:                    execution.setEnvironment((Environment) environmentComboBox
693:                            .getSelectedItem());
694:                    execution.setInitScript(initScript);
695:                    execution.setPostScript(restitutionScript);
696:                    execution.getAttachmentMap().clear();
697:                    Collection values = attachmentPanel.getAttachmentMap()
698:                            .values();
699:                    for (Iterator iter = values.iterator(); iter.hasNext();) {
700:                        execution.addAttachment((Attachment) iter.next());
701:                    }
702:                    DataModel.initAttachmentTable(DataModel
703:                            .getCurrentCampaign().getAttachmentMap().values());
704:                    AskNewExecution.this .dispose();
705:                } else {
706:                    JOptionPane
707:                            .showMessageDialog(
708:                                    AskNewExecution.this ,
709:                                    Language
710:                                            .getInstance()
711:                                            .getText(
712:                                                    "Une_exécution_doit_obligatoirement_avoir_un_environnement_!"),
713:                                    Language.getInstance().getText("Erreur_!"),
714:                                    JOptionPane.ERROR_MESSAGE);
715:                }
716:            }
717:
718:            public void giveAccessToIhmExecutionView() {
719:                if (!AdminProject.canDeleteCamp()) {
720:                    removeRestitutionScriptButton.setEnabled(false);
721:                    removeInitScriptButton.setEnabled(false);
722:                }
723:                if (!AdminProject.canCreateCamp()) {
724:                    addInitScriptButton.setEnabled(false);
725:                    addRestitutionScriptButton.setEnabled(false);
726:                }
727:                if (!AdminProject.canUpdateCamp()) {
728:
729:                }
730:
731:            }
732:
733:            public void actionPerformed(ActionEvent e) {
734:                Object source = e.getSource();
735:                if (source.equals(addInitScriptButton)) {
736:                    addInitScriptPerformed(e);
737:                } else if (source.equals(addRestitutionScriptButton)) {
738:                    addRestitutionScriptPerformed(e);
739:                } else if (source.equals(removeInitScriptButton)) {
740:                    removeInitScriptPerformed(e);
741:                } else if (source.equals(removeRestitutionScriptButton)) {
742:                    removeRestitutionScriptPerformed(e);
743:                } else if (source.equals(newEnvironmentButton)) {
744:                    newEnvironmentPerformed(e);
745:                } else if (source.equals(newDataSetButton)) {
746:                    newDataSetPerformed(e);
747:                } else if (source.equals(validationButton)) {
748:                    validationPerformed(e);
749:                } else if (source.equals(cancelButton)) {
750:                    cancelPerformed(e);
751:                }
752:            }
753:
754:            public void addInitScriptPerformed(ActionEvent e) {
755:                if (fileChooser == null) {
756:                    removeInitScriptButton.setEnabled(false);
757:                    addInitScriptButton.setEnabled(false);
758:                    return;
759:                }
760:                fileChooser.setApproveButtonText(Language.getInstance()
761:                        .getText("Valider"));
762:                int returnVal = fileChooser
763:                        .showOpenDialog(AskNewExecution.this );
764:                if (returnVal == JFileChooser.APPROVE_OPTION) {
765:                    ScriptFileFilter filter = (ScriptFileFilter) fileChooser
766:                            .getFileFilter();
767:                    String scriptPlugIns = filter.getDescription();
768:                    initScriptFile = fileChooser.getSelectedFile();
769:                    try {
770:                        if (!initScriptFile.exists()) {
771:                            initScriptFile.createNewFile();
772:                            initNewFile = true;
773:                        }
774:                    } catch (Exception ex) {
775:                        return;
776:                    }
777:                    initScript = new Script();
778:                    initScript.setName(initScriptFile.getName());
779:                    initScript.setLocalisation((initScriptFile
780:                            .getAbsolutePath()));
781:                    initScript.setScriptExtension(scriptPlugIns);
782:                    initScript.setPlugArg("");
783:                    initScript.setType(PRE_SCRIPT);
784:                    initScriptLabel.setText(Language.getInstance().getText(
785:                            "Script_d'initialisation_:_")
786:                            + initScriptFile.getName());
787:                }
788:            }
789:
790:            public void addRestitutionScriptPerformed(ActionEvent e) {
791:                if (fileChooser == null) {
792:                    addRestitutionScriptButton.setEnabled(false);
793:                    removeRestitutionScriptButton.setEnabled(false);
794:                    return;
795:                }
796:                fileChooser.setApproveButtonText(Language.getInstance()
797:                        .getText("Valider"));
798:                int returnVal = fileChooser
799:                        .showOpenDialog(AskNewExecution.this );
800:                if (returnVal == JFileChooser.APPROVE_OPTION) {
801:                    ScriptFileFilter filter = (ScriptFileFilter) fileChooser
802:                            .getFileFilter();
803:                    String scriptPlugIns = filter.getDescription();
804:                    restitutionScriptFile = fileChooser.getSelectedFile();
805:                    try {
806:                        if (!restitutionScriptFile.exists()) {
807:                            restitutionScriptFile.createNewFile();
808:                            restitutionNewFile = true;
809:                        }
810:                    } catch (Exception ex) {
811:                        return;
812:                    }
813:                    restitutionScript = new Script();
814:                    restitutionScript.setName(restitutionScriptFile.getName());
815:                    restitutionScript.setLocalisation(restitutionScriptFile
816:                            .getAbsolutePath());
817:                    restitutionScript.setScriptExtension(scriptPlugIns);
818:                    restitutionScript.setPlugArg("");
819:                    restitutionScript.setType(POST_SCRIPT);
820:                    restitutionScriptLabel.setText(Language.getInstance()
821:                            .getText("Script_de_restitution_:_")
822:                            + restitutionScriptFile.getName());
823:                }
824:            }
825:
826:            public void removeInitScriptPerformed(ActionEvent e) {
827:                initScriptLabel.setText(Language.getInstance().getText(
828:                        "Script_d'initialisation_:_"));
829:                initScript = null;
830:            }
831:
832:            public void removeRestitutionScriptPerformed(ActionEvent e) {
833:                restitutionScriptLabel.setText(Language.getInstance().getText(
834:                        "Script_de_restitution_:_"));
835:                restitutionScript = null;
836:            }
837:
838:            public void newEnvironmentPerformed(ActionEvent e) {
839:                AskNewEnvironment askNewEnvironment = new AskNewEnvironment();
840:                if (askNewEnvironment.getEnvironment() != null) {
841:                    int transNumber = -1;
842:                    try {
843:                        Environment env = askNewEnvironment.getEnvironment();
844:
845:                        // BdD
846:                        transNumber = Api
847:                                .beginTransaction(Api.INSERT_ENVIRONMENT);
848:                        //env.add2DB();
849:                        ProjectData.getCurrentProject()
850:                                .addEnvironmentInBddAndModel(env);
851:                        Set keysSet = askNewEnvironment.getEnvironment()
852:                                .getParametersHashTable().keySet();
853:                        for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
854:                            Parameter param = (Parameter) iter.next();
855:                            //env.addParamValue2DB(param);
856:                            env.addParamValueInBddAndModel(param, env
857:                                    .getParameterValue(param));
858:                        }
859:                        if (askNewEnvironment.getScriptFile() != null) {
860:                            //env.addScript2DB(env.getInitScript(),askNewEnvironment.getScriptFile());
861:                            env.addScript2BddAndModel(env.getInitScript(),
862:                                    askNewEnvironment.getScriptFile());
863:                        }
864:                        Api.commitTrans(transNumber);
865:
866:                        // IHM
867:                        comboModelForEnvironment.addElement(askNewEnvironment
868:                                .getEnvironment());
869:                        ArrayList data = new ArrayList();
870:                        data.add(askNewEnvironment.getEnvironment().getName());
871:                        String initScriptName = "";
872:                        if (askNewEnvironment.getEnvironment().getInitScript() != null) {
873:                            initScriptName = askNewEnvironment.getEnvironment()
874:                                    .getInitScript().getName();
875:                        }
876:                        data.add(initScriptName);
877:                        data.add(askNewEnvironment.getEnvironment()
878:                                .getParametersHashTable());
879:                        data.add(askNewEnvironment.getEnvironment()
880:                                .getDescription());
881:                        DataModel.getEnvironmentTableModel().addRow(data);
882:                        //ProjectData.getCurrentProject().addEnvironment(askNewEnvironment.getEnvironment());
883:                        environmentComboBox.setSelectedItem(askNewEnvironment
884:                                .getEnvironment());
885:
886:                    } catch (Exception exception) {
887:                        Api.forceRollBackTrans(transNumber);
888:                        Tools.ihmExceptionView(exception.toString());
889:                    }
890:                }
891:            }
892:
893:            public void newDataSetPerformed(ActionEvent e) {
894:                AskNewDataSet askNewDataSet = new AskNewDataSet();
895:                if (askNewDataSet.getDataSet() != null) {
896:                    int transNumber = -1;
897:                    try {
898:                        DataSet dataSet = askNewDataSet.getDataSet();
899:                        // BdD
900:                        transNumber = Api
901:                                .beginTransaction(Api.INSERT_ENVIRONMENT);
902:                        //dataSet.add2DB(DataModel.getCurrentCampaign());
903:                        dataSet
904:                                .addToBddAndModel(DataModel
905:                                        .getCurrentCampaign());
906:                        Set keysSet = askNewDataSet.getDataSet()
907:                                .getParametersHashMap().keySet();
908:                        for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
909:                            String paramName = (String) iter.next();
910:                            String value = askNewDataSet.getDataSet().getValue(
911:                                    paramName);
912:                            if (value == null)
913:                                value = "";
914:                            //dataSet.addParamValue2DB(value, ProjectData.getCurrentProject().getParameter(paramName));
915:                            dataSet.addParamValueToBddAndModel(value,
916:                                    ProjectData.getCurrentProject()
917:                                            .getParameter(paramName));
918:                        }
919:                        Api.commitTrans(transNumber);
920:
921:                        // IHM
922:                        ArrayList data = new ArrayList();
923:                        data.add(dataSet.getName());
924:                        data.add(dataSet.getDescription());
925:                        DataModel.getDataSetTableModel().addRow(data);
926:                        //DataModel.getCurrentCampaign().addDataSet(dataSet);
927:                        comboModelForDataSet.addElement(dataSet);
928:                        dataSetComboBox.setSelectedItem(dataSet);
929:                    } catch (Exception exception) {
930:                        Api.forceRollBackTrans(transNumber);
931:                        Tools.ihmExceptionView(exception.toString());
932:                    }
933:                }
934:            }
935:
936:            public void validationPerformed(ActionEvent e) {
937:                if (executionNameTextField.getText() != null
938:                        && !executionNameTextField.getText().trim().equals("")) {
939:                    if (!DataModel.getCurrentCampaign().containsExecution(
940:                            executionNameTextField.getText().trim())
941:                            && !ConnectionData.isInBaseExec(
942:                                    executionNameTextField.getText().trim(),
943:                                    DataModel.getCurrentCampaign().getName())) {
944:                        createAndQuit();
945:                    } else if (DataModel.getCurrentCampaign().getExecution(
946:                            executionNameTextField.getText().trim()) != null
947:                            && DataModel.getCurrentCampaign().getExecution(
948:                                    executionNameTextField.getText().trim())
949:                                    .equals(execution)) {
950:                        createAndQuit();
951:                    } else {
952:                        JOptionPane
953:                                .showMessageDialog(
954:                                        AskNewExecution.this ,
955:                                        Language
956:                                                .getInstance()
957:                                                .getText(
958:                                                        "Ce_nom_d'exécution_existe_déjà_pour_cette_campagne_!"),
959:                                        Language.getInstance().getText(
960:                                                "Erreur_!"),
961:                                        JOptionPane.ERROR_MESSAGE);
962:                    }
963:                } else {
964:                    JOptionPane
965:                            .showMessageDialog(
966:                                    AskNewExecution.this ,
967:                                    Language
968:                                            .getInstance()
969:                                            .getText(
970:                                                    "Il_faut_obligatoirement_donner_un_nom_à_l'exécution_!"),
971:                                    Language.getInstance().getText(
972:                                            "Attention_!"),
973:                                    JOptionPane.WARNING_MESSAGE);
974:                }
975:            }
976:
977:            public void cancelPerformed(ActionEvent e) {
978:                DataModel.initAttachmentTable(DataModel.getCurrentCampaign()
979:                        .getAttachmentMap().values());
980:                execution = null;
981:                if (initNewFile)
982:                    initScriptFile.delete();
983:
984:                if (restitutionNewFile)
985:                    restitutionScriptFile.delete();
986:
987:                AskNewExecution.this .dispose();
988:            }
989:
990:        } // Fin de la classe AskNewExecution
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.