Source Code Cross Referenced for ParameterView.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.Dimension;
028:        import java.awt.GridLayout;
029:        import java.awt.event.ActionEvent;
030:        import java.awt.event.ActionListener;
031:        import java.util.ArrayList;
032:
033:        import javax.swing.BorderFactory;
034:        import javax.swing.JButton;
035:        import javax.swing.JOptionPane;
036:        import javax.swing.JPanel;
037:        import javax.swing.JScrollPane;
038:        import javax.swing.JTable;
039:        import javax.swing.ListSelectionModel;
040:        import javax.swing.event.ListSelectionEvent;
041:        import javax.swing.event.ListSelectionListener;
042:        import javax.swing.tree.DefaultMutableTreeNode;
043:
044:        import org.objectweb.salome_tmf.api.Api;
045:        import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
046:        import org.objectweb.salome_tmf.data.Action;
047:        import org.objectweb.salome_tmf.data.Campaign;
048:        import org.objectweb.salome_tmf.data.CampaignData;
049:        import org.objectweb.salome_tmf.data.ConnectionData;
050:        import org.objectweb.salome_tmf.data.DataConstants;
051:        import org.objectweb.salome_tmf.data.DataSet;
052:        import org.objectweb.salome_tmf.data.Environment;
053:        import org.objectweb.salome_tmf.data.Execution;
054:        import org.objectweb.salome_tmf.data.Family;
055:        import org.objectweb.salome_tmf.data.ManualTest;
056:        import org.objectweb.salome_tmf.data.Parameter;
057:        import org.objectweb.salome_tmf.data.ProjectData;
058:        import org.objectweb.salome_tmf.data.Test;
059:        import org.objectweb.salome_tmf.data.TestList;
060:        import org.objectweb.salome_tmf.data.TestPlanData;
061:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
062:        import org.objectweb.salome_tmf.ihm.languages.Language;
063:        import org.objectweb.salome_tmf.ihm.models.TableSorter;
064:        import org.objectweb.salome_tmf.ihm.plugins.PluginsTools;
065:        import org.objectweb.salome_tmf.ihm.tools.Tools;
066:
067:        /**
068:         * @author teaml039
069:         * @version : 0.1
070:         */
071:        public class ParameterView extends JPanel implements  DataConstants,
072:                ActionListener, ListSelectionListener {
073:
074:            JPanel paramsPanel;
075:
076:            JButton modifyParameterButton;
077:
078:            JButton deleteParameterButton;
079:
080:            JButton addParameter;
081:
082:            JButton useParameterButton;
083:            //	MyTableModel manualParameterTableModel = new MyTableModel();
084:
085:            JTable parametersTable;
086:
087:            boolean usingFonctionEnable;
088:
089:            TableSorter sorter;
090:
091:            /******************************************************************************/
092:            /** 							CONSTRUCTEUR								***/
093:            /******************************************************************************/
094:
095:            /**
096:             *
097:             * type is use for plugin UI = AUTOMATIC_TEST or MANUAL_TEST or PARAMETER or -1 for Dynamic
098:             */
099:
100:            public ParameterView(boolean use, int type) {
101:                paramsPanel = new JPanel();
102:
103:                modifyParameterButton = new JButton(Language.getInstance()
104:                        .getText("Modifier"));
105:                deleteParameterButton = new JButton(Language.getInstance()
106:                        .getText("Supprimer"));
107:                parametersTable = new JTable();
108:
109:                addParameter = new JButton(Language.getInstance().getText(
110:                        "Nouveau"));
111:                addParameter.setToolTipText(Language.getInstance().getText(
112:                        "Ajouter_un_nouveau_paramètre"));
113:                addParameter.addActionListener(this );
114:
115:                useParameterButton = new JButton(Language.getInstance()
116:                        .getText("Utiliser"));
117:                useParameterButton.setToolTipText(Language.getInstance()
118:                        .getText("Utiliser_des_paramètres_existants"));
119:                useParameterButton.addActionListener(this );
120:
121:                modifyParameterButton.setEnabled(false);
122:                modifyParameterButton.setToolTipText(Language.getInstance()
123:                        .getText("Modifier_un_paramètre"));
124:                modifyParameterButton.addActionListener(this );
125:
126:                deleteParameterButton.setToolTipText(Language.getInstance()
127:                        .getText("Supprimer_un_paramètre"));
128:                deleteParameterButton.setEnabled(false);
129:                deleteParameterButton.addActionListener(this );
130:
131:                JPanel buttonsPanel = new JPanel(new GridLayout(1, 3));
132:                buttonsPanel.add(addParameter);
133:
134:                if (use) {
135:                    buttonsPanel.add(useParameterButton);
136:                }
137:
138:                buttonsPanel.add(modifyParameterButton);
139:                buttonsPanel.add(deleteParameterButton);
140:                buttonsPanel.setBorder(BorderFactory.createRaisedBevelBorder());
141:
142:                ListSelectionModel rowSM = parametersTable.getSelectionModel();
143:                rowSM.addListSelectionListener(this );
144:
145:                //sorter = new TableSorter();
146:                if (use) {
147:                    sorter = new TableSorter(DataModel
148:                            .getTestParameterTableModel());
149:                    //parametersTable.setModel(DataModel.getTestParameterTableModel());
150:                } else {
151:                    sorter = new TableSorter(DataModel.getParameterTableModel());
152:                    //parametersTable.setModel(DataModel.getParameterTableModel());
153:                }
154:                parametersTable.setModel(sorter);
155:                sorter.setTableHeader(parametersTable.getTableHeader());
156:
157:                parametersTable
158:                        .setPreferredScrollableViewportSize(new Dimension(600,
159:                                200));
160:                parametersTable
161:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
162:
163:                JScrollPane tablePane = new JScrollPane(parametersTable);
164:                tablePane.setBorder(BorderFactory.createRaisedBevelBorder());
165:
166:                initData(use);
167:
168:                paramsPanel.setLayout(new BorderLayout());
169:                paramsPanel.add(buttonsPanel, BorderLayout.NORTH);
170:                paramsPanel.add(tablePane, BorderLayout.CENTER);
171:
172:                this .setLayout(new BorderLayout());
173:                this .add(paramsPanel);
174:
175:                mapUIComponents(paramsPanel, parametersTable, buttonsPanel,
176:                        type);
177:
178:            } // Fin du constructeur ManualParameterView/0
179:
180:            void mapUIComponents(JPanel paramsPanel, JTable parametersTable,
181:                    JPanel buttonsPanel, int type) {
182:                switch (type) {
183:                case MANUAL_TEST: {
184:                    SalomeTMF.addToUIComponentsMap(
185:                            UICompCst.MANUAL_TEST_PARAMS_PANEL, paramsPanel);
186:                    UICompCst.staticUIComps
187:                            .add(UICompCst.MANUAL_TEST_PARAMS_PANEL);
188:
189:                    SalomeTMF
190:                            .addToUIComponentsMap(
191:                                    UICompCst.MANUAL_TEST_PARAMS_TABLE,
192:                                    parametersTable);
193:                    UICompCst.staticUIComps
194:                            .add(UICompCst.MANUAL_TEST_PARAMS_TABLE);
195:
196:                    SalomeTMF.addToUIComponentsMap(
197:                            UICompCst.MANUAL_TEST_PARAMS_BUTTONS_PANEL,
198:                            buttonsPanel);
199:                    UICompCst.staticUIComps
200:                            .add(UICompCst.MANUAL_TEST_PARAMS_BUTTONS_PANEL);
201:                    break;
202:                }
203:                case AUTOMATIC_TEST: {
204:                    SalomeTMF.addToUIComponentsMap(
205:                            UICompCst.AUTOMATED_TEST_PARAMS_PANEL, paramsPanel);
206:                    UICompCst.staticUIComps
207:                            .add(UICompCst.AUTOMATED_TEST_PARAMS_PANEL);
208:
209:                    SalomeTMF.addToUIComponentsMap(
210:                            UICompCst.AUTOMATED_TEST_PARAMS_TABLE,
211:                            parametersTable);
212:                    UICompCst.staticUIComps
213:                            .add(UICompCst.AUTOMATED_TEST_PARAMS_TABLE);
214:
215:                    SalomeTMF.addToUIComponentsMap(
216:                            UICompCst.AUTOMATED_TEST_PARAMS_BUTTONS_PANEL,
217:                            buttonsPanel);
218:                    UICompCst.staticUIComps
219:                            .add(UICompCst.AUTOMATED_TEST_PARAMS_BUTTONS_PANEL);
220:                    break;
221:                }
222:                case PARAMETER: {
223:                    SalomeTMF.addToUIComponentsMap(UICompCst.DATA_PARAMS_PANEL,
224:                            paramsPanel);
225:                    UICompCst.staticUIComps.add(UICompCst.DATA_PARAMS_PANEL);
226:
227:                    SalomeTMF.addToUIComponentsMap(UICompCst.DATA_PARAMS_TABLE,
228:                            parametersTable);
229:                    UICompCst.staticUIComps.add(UICompCst.DATA_PARAMS_TABLE);
230:
231:                    SalomeTMF.addToUIComponentsMap(
232:                            UICompCst.DATA_PARAMS_BUTTONS_PANEL, buttonsPanel);
233:                    UICompCst.staticUIComps
234:                            .add(UICompCst.DATA_PARAMS_BUTTONS_PANEL);
235:                    break;
236:                }
237:
238:                default: {
239:                    SalomeTMF.addToUIComponentsMap(UICompCst.PARAMS_PANEL,
240:                            paramsPanel);
241:                    PluginsTools.activateAssociatedPlgs(UICompCst.PARAMS_PANEL);
242:
243:                    SalomeTMF.addToUIComponentsMap(UICompCst.PARAMS_TABLE,
244:                            parametersTable);
245:                    PluginsTools.activateAssociatedPlgs(UICompCst.PARAMS_TABLE);
246:
247:                    SalomeTMF.addToUIComponentsMap(
248:                            UICompCst.PARAMS_BUTTONS_PANEL, buttonsPanel);
249:                    PluginsTools
250:                            .activateAssociatedPlgs(UICompCst.PARAMS_BUTTONS_PANEL);
251:                }
252:                }
253:            }
254:
255:            /**
256:             *
257:             * @param use
258:             */
259:            private void initData(boolean use) {
260:                usingFonctionEnable = use;
261:            }
262:
263:            /**
264:             *
265:             * @param use
266:             */
267:            public static void addNewParameter(boolean use) {
268:                AskNewParameter askNewParameter = new AskNewParameter(null);
269:                Parameter param = askNewParameter.getParameter();
270:                if (param != null && param.getName() != null
271:                        && param.getName() != "") {
272:                    if (!ProjectData.getCurrentProject().containsParameter(
273:                            param.getName().trim())) {
274:
275:                        try {
276:                            //param.add2DB();
277:                            ProjectData.getCurrentProject()
278:                                    .addParameterToBddAndModel(param);
279:                            ArrayList dataList = new ArrayList();
280:                            dataList.add(param.getName());
281:                            dataList.add(param.getDescription());
282:                            //ProjectData.getCurrentProject().addParameter(param);
283:                            DataModel.getParameterTableModel().addRow(dataList);
284:                            if (use) {
285:                                if (ConnectionData.isConnected()) {
286:                                    try {
287:                                        DataModel
288:                                                .getCurrentTest()
289:                                                .setUseParamInBddAndModel(param);
290:                                    } catch (Exception exception) {
291:                                        Tools.ihmExceptionView(exception
292:                                                .toString());
293:                                    }
294:                                }
295:                                if (Api.getException() == null
296:                                        || Api.getException().size() == 0) {
297:                                    DataModel.getTestParameterTableModel()
298:                                            .addRow(dataList);
299:                                    //DataModel.getCurrentTest().addParameter(param);
300:                                }
301:                            }
302:
303:                        } catch (Exception exception) {
304:                            Tools.ihmExceptionView(exception.toString());
305:                        }
306:
307:                    } else {
308:                        JOptionPane.showMessageDialog(null, Language
309:                                .getInstance().getText(
310:                                        "Ce_nom_de_paramètre_existe_déjà_!"),
311:                                Language.getInstance().getText("Erreur_!"),
312:                                JOptionPane.ERROR_MESSAGE);
313:                    }
314:                }
315:            }
316:
317:            /**
318:             *
319:             *
320:             */
321:            public static void usingParameter() {
322:                UsingDefinedParameterView usingDefinedParameterView = new UsingDefinedParameterView(
323:                        false, false);
324:                if (usingDefinedParameterView.getParameterList() != null) {
325:                    for (int i = 0; i < usingDefinedParameterView
326:                            .getParameterList().size(); i++) {
327:                        Parameter param = (Parameter) usingDefinedParameterView
328:                                .getParameterList().get(i);
329:                        if (!DataModel.getCurrentTest().hasParameterName(
330:                                param.getName())) {
331:
332:                            try {
333:                                DataModel.getCurrentTest()
334:                                        .setUseParamInBddAndModel(param);
335:                                ArrayList dataList = new ArrayList();
336:                                dataList.add(param.getName());
337:                                dataList.add(param.getDescription());
338:                                DataModel.getTestParameterTableModel().addRow(
339:                                        dataList);
340:                                //DataModel.getCurrentTest().addParameter(param);
341:                            } catch (Exception exception) {
342:                                Tools.ihmExceptionView(exception.toString());
343:                            }
344:
345:                        } else {
346:                            JOptionPane.showMessageDialog(null, Language
347:                                    .getInstance().getText("Le_paramètre_")
348:                                    + param.getName()
349:                                    + Language.getInstance().getText(
350:                                            "_existe_déjà_pour_ce_test_!"),
351:                                    Language.getInstance().getText("Erreur_!"),
352:                                    JOptionPane.ERROR_MESSAGE);
353:                        }
354:                    }
355:                }
356:            }
357:
358:            /**
359:             *
360:             * @param currentTest
361:             * @param paramName
362:             */
363:            /*private static void cleanActionOfParameter(Test currentTest, String paramName) {
364:                if (currentTest instanceof ManualTest) {
365:                    for (int i = 0; i < ((ManualTest)currentTest).getActionList().size(); i++) {
366:                        
367:                        //Action action = (Action)((ManualTest)DataModel.getCurrentTest()).getActionList().get(i);
368:                    	Action action = (Action)((ManualTest)currentTest).getActionList().get(i);
369:                        
370:                        try {
371:                        	String newDesc = Tools.clearStringOfParameter(action.getDescription(), paramName);
372:                            String newResult = Tools.clearStringOfParameter(action.getAwaitedResult(), paramName);
373:                            
374:                        	// DB
375:                        	action.updateInDB(action.getName(), newDesc, newResult, action.getOrderIndex());
376:                            
377:                            // Data
378:                        	
379:                            action.getParameterHashSet().remove(DataModel.getCurrentProject().getParameter(paramName));
380:                            
381:                            if (DataModel.getCurrentTest() != null) {
382:            	                if (DataModel.getCurrentTest().equals(currentTest)) {
383:            	                    int row = DataModel.getActionTableModel().findRow(action.getName());
384:            	                    DataModel.getActionTableModel().setValueAt(newDesc, row, 1);
385:            	                    DataModel.getActionTableModel().setValueAt(newResult, row, 2);
386:            	                }
387:                            }
388:                        } catch (Exception exception) {
389:                            Tools.ihmExceptionView(exception.toString());
390:                        }
391:                    }
392:                }
393:            } // Fin de la m?thode cleanActionOfParameter/2
394:             */
395:
396:            private static void upadateActionOfParameterView(Test currentTest,
397:                    String paramName) {
398:                if (currentTest instanceof  ManualTest) {
399:                    for (int i = 0; i < ((ManualTest) currentTest)
400:                            .getActionList().size(); i++) {
401:                        Action action = (Action) ((ManualTest) currentTest)
402:                                .getActionList().get(i);
403:                        try {
404:                            if (DataModel.getCurrentTest() != null
405:                                    && DataModel.getCurrentTest().equals(
406:                                            currentTest)) {
407:                                int row = DataModel.getActionTableModel()
408:                                        .findRow(action.getName());
409:                                DataModel.getActionTableModel().setValueAt(
410:                                        action.getDescription(), row, 1);
411:                                DataModel.getActionTableModel().setValueAt(
412:                                        action.getAwaitedResult(), row, 2);
413:                            }
414:                        } catch (Exception exception) {
415:                            Tools.ihmExceptionView(exception.toString());
416:                        }
417:                    }
418:                }
419:            } // Fin de la m?thode cleanActionOfParameter/2
420:
421:            /**
422:             *
423:             *
424:             */
425:            public void giveAccessToIhmParameterView() {
426:                if (usingFonctionEnable) {
427:                    if (!AdminProject.canDeleteTest()) {
428:                        deleteParameterButton.setEnabled(false);
429:
430:                    }
431:                    if (!AdminProject.canCreateTest()) {
432:                        addParameter.setEnabled(false);
433:                        useParameterButton.setEnabled(false);
434:
435:                    }
436:                    if (!AdminProject.canUpdateTest()) {
437:                        modifyParameterButton.setEnabled(false);
438:
439:                    }
440:
441:                } else {
442:                    if (!AdminProject.canDeleteCamp()) {
443:                        deleteParameterButton.setEnabled(false);
444:                    }
445:                    if (!AdminProject.canCreateCamp()
446:                            && !AdminProject.canExecutCamp()) {
447:                        addParameter.setEnabled(false);
448:                        useParameterButton.setEnabled(false);
449:                    }
450:                    if (!AdminProject.canUpdateCamp()
451:                            && !AdminProject.canExecutCamp()) {
452:                        modifyParameterButton.setEnabled(false);
453:                    }
454:                }
455:
456:            }
457:
458:            /***************** Event Managment ************************/
459:            public void actionPerformed(ActionEvent e) {
460:                if (e.getSource().equals(addParameter)) {
461:                    addParameterPerformed();
462:                } else if (e.getSource().equals(useParameterButton)) {
463:                    useParameterButtonPerformed();
464:                } else if (e.getSource().equals(modifyParameterButton)) {
465:                    modifyParameterButtonPerformed();
466:                } else if (e.getSource().equals(deleteParameterButton)) {
467:                    deleteParameterButtonPerformed();
468:                }
469:            }
470:
471:            public void valueChanged(ListSelectionEvent e) {
472:                if (e.getSource().equals(parametersTable.getSelectionModel())) {
473:                    parametersTablevalueChanged(e);
474:                }
475:            }
476:
477:            public void addParameterPerformed() {
478:                String message = CampaignData
479:                        .getCampaignWithExecResultWhereTestIsUse(DataModel
480:                                .getCurrentTest());
481:                if (!message.equals("") && usingFonctionEnable) {
482:                    JOptionPane
483:                            .showMessageDialog(
484:                                    ParameterView.this ,
485:                                    Language
486:                                            .getInstance()
487:                                            .getText(
488:                                                    "Ce_test_est_utilisé_dans_les_campagnes_:_\n")
489:                                            + message
490:                                            + Language
491:                                                    .getInstance()
492:                                                    .getText(
493:                                                            "qui_possèdent_des_résultats_d'exécutions.\nAfin_de_conserver_l'intégrité_des_résultats,_vous_ne_pouvez_pas_ajouter_un_nouveau_paramètre."),
494:                                    Language.getInstance().getText("Erreur_!"),
495:                                    JOptionPane.ERROR_MESSAGE);
496:                } else {
497:                    addNewParameter(usingFonctionEnable);
498:                }
499:            }
500:
501:            public void useParameterButtonPerformed() {
502:                String message = CampaignData
503:                        .getCampaignWithExecResultWhereTestIsUse(DataModel
504:                                .getCurrentTest());
505:                if (!message.equals("") && usingFonctionEnable) {
506:                    JOptionPane
507:                            .showMessageDialog(
508:                                    ParameterView.this ,
509:                                    Language
510:                                            .getInstance()
511:                                            .getText(
512:                                                    "Ce_test_est_utilisé_dans_les_campagnes_:_\n")
513:                                            + message
514:                                            + Language
515:                                                    .getInstance()
516:                                                    .getText(
517:                                                            "qui_possèdent_des_résultats_d'exécutions.\nAfin_de_conserver_l'intégrité_des_résultats,_vous_ne_pouvez_pas_ajouter_un_paramètre_déjà_défini."),
518:                                    Language.getInstance().getText("Erreur_!"),
519:                                    JOptionPane.ERROR_MESSAGE);
520:                } else {
521:
522:                    usingParameter();
523:                }
524:            }
525:
526:            public void modifyParameterButtonPerformed() {
527:                int selectedRowIndex = parametersTable.getSelectedRow();
528:                if (selectedRowIndex != -1) {
529:                    String message = CampaignData
530:                            .getCampaignWithExecResultWhereTestIsUse(DataModel
531:                                    .getCurrentTest());
532:                    if (!message.equals("") && usingFonctionEnable) {
533:                        JOptionPane
534:                                .showMessageDialog(
535:                                        ParameterView.this ,
536:                                        Language
537:                                                .getInstance()
538:                                                .getText(
539:                                                        "Ce_test_est_utilisé_dans_les_campagnes_:_\n")
540:                                                + message
541:                                                + Language
542:                                                        .getInstance()
543:                                                        .getText(
544:                                                                "qui_possèdent_des_résultats_d'exécutions.\nAfin_de_conserver_l'intégrité_des_résultats,_vous_ne_pouvez_pas_modifier_ce_paramètre."),
545:                                        Language.getInstance().getText(
546:                                                "Erreur_!"),
547:                                        JOptionPane.ERROR_MESSAGE);
548:                    } else {
549:
550:                        ArrayList paramList;
551:                        if (usingFonctionEnable) {
552:                            //paramList = DataModel.getTestParameterTableModel().getData(selectedRowIndex);
553:                            paramList = DataModel
554:                                    .getTestParameterTableModel()
555:                                    .getData(
556:                                            sorter.modelIndex(selectedRowIndex));
557:
558:                        } else {
559:                            //paramList = DataModel.getParameterTableModel().getData(selectedRowIndex);
560:                            paramList = DataModel
561:                                    .getParameterTableModel()
562:                                    .getData(
563:                                            sorter.modelIndex(selectedRowIndex));
564:                        }
565:                        AskNameAndDescription askNewParameter = null;
566:                        if (paramList != null
567:                                && paramList.size() == parametersTable
568:                                        .getColumnCount()) {
569:                            askNewParameter = new AskNameAndDescription(
570:                                    PARAMETER, Language.getInstance().getText(
571:                                            "Modifier_un_paramètre"), Language
572:                                            .getInstance().getText(
573:                                                    "Nom_du_paramètre_:_"),
574:                                    ProjectData.getCurrentProject()
575:                                            .getParameter(
576:                                                    (String) paramList.get(0)),
577:                                    SalomeTMF.ptrFrame);
578:                        }
579:                        if (askNewParameter != null) {
580:                            Parameter param = askNewParameter.getNewParameter();
581:                            if (param != null) {
582:
583:                                try {
584:                                    // BdD
585:                                    param.updateDescriptionInBddAndModel(param
586:                                            .getDescription());
587:
588:                                    // IHM
589:                                    ArrayList dataList = new ArrayList();
590:                                    dataList.add(param.getName());
591:                                    dataList.add(param.getDescription());
592:                                    if (usingFonctionEnable) {
593:                                        DataModel
594:                                                .getTestParameterTableModel()
595:                                                .modifyData(
596:                                                        dataList,
597:                                                        sorter
598:                                                                .modelIndex(selectedRowIndex));
599:                                        Parameter oldParam = ((ManualTest) DataModel
600:                                                .getCurrentTest())
601:                                                .getParameter((String) paramList
602:                                                        .get(0));
603:                                        oldParam.setName(param.getName());
604:                                        oldParam.setDescription(param
605:                                                .getDescription());
606:                                    } else {
607:                                        DataModel
608:                                                .getParameterTableModel()
609:                                                .modifyData(
610:                                                        dataList,
611:                                                        sorter
612:                                                                .modelIndex(selectedRowIndex));
613:                                    }
614:                                } catch (Exception exception) {
615:                                    Tools
616:                                            .ihmExceptionView(exception
617:                                                    .toString());
618:                                }
619:                            }
620:                        }
621:                    }
622:                }
623:            }
624:
625:            public void deleteParameterButtonPerformed() {
626:                int selectedRowIndex = parametersTable.getSelectedRow();
627:                String paramName;
628:                if (usingFonctionEnable) {
629:                    String message = CampaignData
630:                            .getCampaignWithExecResultWhereTestIsUse(DataModel
631:                                    .getCurrentTest());
632:                    if (!message.equals("") && usingFonctionEnable) {
633:                        JOptionPane
634:                                .showMessageDialog(
635:                                        ParameterView.this ,
636:                                        Language
637:                                                .getInstance()
638:                                                .getText(
639:                                                        "Ce_test_est_utilisé_dans_les_campagnes_:_\n")
640:                                                + message
641:                                                + Language
642:                                                        .getInstance()
643:                                                        .getText(
644:                                                                "qui_possèdent_des_résultats_d'exécutions.\nAfin_de_conserver_l'intégrité_des_résultats,_vous_ne_pouvez_pas_supprimer_ce_paramètre."),
645:                                        Language.getInstance().getText(
646:                                                "Erreur_!"),
647:                                        JOptionPane.ERROR_MESSAGE);
648:                    } else {
649:
650:                        Object[] options = {
651:                                Language.getInstance().getText("Oui"),
652:                                Language.getInstance().getText("Non") };
653:                        int choice = -1;
654:                        choice = JOptionPane
655:                                .showOptionDialog(
656:                                        ParameterView.this ,
657:                                        //"Etes vous s?r de vouloir supprimer le param?tre <" +(String)DataModel.getTestParameterTableModel().getValueAt(selectedRowIndex, 0) + "> du test <" + DataModel.getCurrentTest() + "> ?",
658:                                        Language
659:                                                .getInstance()
660:                                                .getText(
661:                                                        "Etes_vous_sûr_de_vouloir_supprimer_le_paramètre_<")
662:                                                + (String) sorter.getValueAt(
663:                                                        selectedRowIndex, 0)
664:                                                + Language.getInstance()
665:                                                        .getText(">_du_test_<")
666:                                                + DataModel.getCurrentTest()
667:                                                + "> ?", Language.getInstance()
668:                                                .getText("Attention_!"),
669:                                        JOptionPane.YES_NO_OPTION,
670:                                        JOptionPane.QUESTION_MESSAGE, null,
671:                                        options, options[1]);
672:                        if (choice == JOptionPane.YES_OPTION) {
673:                            //paramName = (String)DataModel.getTestParameterTableModel().getValueAt(selectedRowIndex, 0);
674:                            paramName = (String) sorter.getValueAt(
675:                                    selectedRowIndex, 0);
676:
677:                            try {
678:                                Test test = DataModel.getCurrentTest();
679:                                Parameter param = test.getParameter(paramName);
680:
681:                                // BdD & Model
682:                                //test.deleteUseParamFromDB(param);
683:                                test.deleteUseParamInBddAndModel(param);
684:                                // DataModel.getCurrentTest().deleteParameter(paramName);
685:                                // IHM
686:                                DataModel
687:                                        .getTestParameterTableModel()
688:                                        .removeData(
689:                                                sorter
690:                                                        .modelIndex(selectedRowIndex));
691:                                if (DataModel.getTestParameterTableModel()
692:                                        .getRowCount() == 0) {
693:                                    deleteParameterButton.setEnabled(false);
694:                                }
695:                                upadateActionOfParameterView(test, paramName);
696:
697:                            } catch (Exception exception) {
698:                                Tools.ihmExceptionView(exception.toString());
699:                            }
700:                        }
701:                    }
702:                } else {
703:                    //paramName = (String)DataModel.getParameterTableModel().getValueAt(selectedRowIndex, 0);
704:                    paramName = (String) sorter.getValueAt(selectedRowIndex, 0);
705:                    ArrayList testsOfParam = TestPlanData
706:                            .getTestOfParameter(paramName);
707:                    ArrayList envOfParam = ProjectData
708:                            .getEnvironmentOfParameter(paramName);
709:                    if (testsOfParam.size() > 0 || envOfParam.size() > 0) {
710:                        Object[] options = {
711:                                Language.getInstance().getText("Oui"),
712:                                Language.getInstance().getText("Non") };
713:                        int choice = -1;
714:                        //int actionCase = -1;
715:                        String message = Language.getInstance().getText(
716:                                "Le_paramètre_<")
717:                                + paramName
718:                                + Language.getInstance().getText(
719:                                        ">_est_utilisé_dans_les_tests_:\n");
720:                        String campaignMessage = "";
721:                        ArrayList concernedCampaign = new ArrayList();
722:                        String testsMessage = "";
723:                        String envMessage = "";
724:                        //String toBeDelete = "";
725:                        for (int i = 0; i < testsOfParam.size(); i++) {
726:                            testsMessage = testsMessage
727:                                    + "* "
728:                                    + ((Test) testsOfParam.get(i))
729:                                            .getTestList().getFamily()
730:                                            .getName()
731:                                    + "/"
732:                                    + ((Test) testsOfParam.get(i))
733:                                            .getTestList().getName() + "/"
734:                                    + ((Test) testsOfParam.get(i)).getName()
735:                                    + "\n";
736:                            ArrayList campaignOfTest = CampaignData
737:                                    .getCampaignOfTest((Test) testsOfParam
738:                                            .get(i));
739:                            if (campaignOfTest.size() > 0) {
740:                                for (int j = 0; j < campaignOfTest.size(); j++) {
741:                                    if (!concernedCampaign
742:                                            .contains(campaignOfTest.get(j))) {
743:                                        campaignMessage = campaignMessage
744:                                                + "* "
745:                                                + ((Campaign) campaignOfTest
746:                                                        .get(j)).getName()
747:                                                + "\n";
748:                                        concernedCampaign.add(campaignOfTest
749:                                                .get(j));
750:                                    }
751:                                }
752:                            }
753:                        }
754:                        for (int k = 0; k < envOfParam.size(); k++) {
755:                            if (((Environment) envOfParam.get(k))
756:                                    .containsParameter(paramName)) {
757:                                envMessage = envMessage
758:                                        + "* "
759:                                        + ((Environment) envOfParam.get(k))
760:                                                .getName() + "\n";
761:                            }
762:                        }
763:
764:                        message = message
765:                                + testsMessage
766:                                + Language.getInstance().getText(
767:                                        "dans_les_campagnes_:_\n")
768:                                + campaignMessage
769:                                + Language.getInstance().getText(
770:                                        "dans_les_environnements_:\n")
771:                                + envMessage;
772:                        message = message
773:                                + Language
774:                                        .getInstance()
775:                                        .getText(
776:                                                "Le_paramètre_sera_supprimé_des_tests_et_des_environnements_et_des_jeux_de_données_concernés.\nLes_résultats_d'exécutions_des_campagnes_seront_perdus.\n");
777:                        choice = JOptionPane
778:                                .showOptionDialog(
779:                                        ParameterView.this ,
780:                                        message
781:                                                + Language
782:                                                        .getInstance()
783:                                                        .getText(
784:                                                                "Etes_vous_sûr_de_vouloir_supprimer_le_paramètre_<_")
785:                                                + paramName + " > ?", Language
786:                                                .getInstance().getText(
787:                                                        "Attention_!"),
788:                                        JOptionPane.YES_NO_OPTION,
789:                                        JOptionPane.WARNING_MESSAGE, null,
790:                                        options, options[1]);
791:                        if (choice == JOptionPane.YES_OPTION) {
792:
793:                            try {
794:                                // BdD and Model
795:                                Parameter pParam = ProjectData
796:                                        .getCurrentProject().getParameter(
797:                                                paramName);
798:                                ProjectData.delParamInBddAndModel(pParam);
799:
800:                                // IHM
801:                                //Suppression du param?tre des tests et action de tests (si manuel)
802:                                for (int j = 0; j < testsOfParam.size(); j++) {
803:                                    Test pTest = (Test) testsOfParam.get(j);
804:                                    // Si le test courant est trait?, on nettoie la table des param?tres
805:                                    if (DataModel.getCurrentTest() != null
806:                                            && DataModel.getCurrentTest()
807:                                                    .equals(pTest)) {
808:                                        int rowIndex = DataModel
809:                                                .getTestParameterTableModel()
810:                                                .findRow(paramName);
811:                                        if (rowIndex != -1) {
812:                                            DataModel
813:                                                    .getTestParameterTableModel()
814:                                                    .removeData(
815:                                                            sorter
816:                                                                    .modelIndex(rowIndex));
817:                                        }
818:                                    }
819:
820:                                    upadateActionOfParameterView(pTest,
821:                                            paramName);
822:                                    //Suppression en cascade dans l'arbre des campagnes
823:                                    for (int k = 0; k < concernedCampaign
824:                                            .size(); k++) {
825:                                        Campaign campaign = (Campaign) concernedCampaign
826:                                                .get(k);
827:
828:                                        DefaultMutableTreeNode testNodeInCampaignTree = SalomeTMF
829:                                                .getCampaignDynamicTree()
830:                                                .findRemoveTestNodeInCampagneTree(
831:                                                        pTest.getName(),
832:                                                        pTest.getTestList()
833:                                                                .getName(),
834:                                                        pTest.getTestList()
835:                                                                .getFamily()
836:                                                                .getName(),
837:                                                        campaign.getName(),
838:                                                        false);
839:                                        DefaultMutableTreeNode testListParent = (DefaultMutableTreeNode) testNodeInCampaignTree
840:                                                .getParent();
841:                                        SalomeTMF.getCampaignDynamicTree()
842:                                                .removeNode(
843:                                                        testNodeInCampaignTree);
844:                                        if (testListParent.getChildCount() == 0) {
845:                                            DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListParent
846:                                                    .getParent();
847:                                            SalomeTMF.getCampaignDynamicTree()
848:                                                    .removeNode(testListParent);
849:                                            //DataModel.deleteTestListFromCampaign((TestList)testListParent.getUserObject(),campaign);
850:                                            if (familyParent.getChildCount() == 0) {
851:                                                SalomeTMF
852:                                                        .getCampaignDynamicTree()
853:                                                        .removeNode(
854:                                                                familyParent);
855:                                                //DataModel.deleteFamilyFromCampaign((Family)familyParent.getUserObject(), campaign);
856:                                            }
857:                                        }
858:                                        //Si la campagne traitée est la campagne courant, nettoyage de la table des r?sultats d'ex?cutions
859:                                        if (DataModel.getCurrentCampaign() != null
860:                                                && DataModel
861:                                                        .getCurrentCampaign()
862:                                                        .equals(campaign)) {
863:                                            DataModel
864:                                                    .getExecutionResultTableModel()
865:                                                    .clearTable();
866:                                        }
867:                                    }
868:                                }
869:                                //DataModel.getParameterTableModel().removeData(selectedRowIndex);
870:                                DataModel.getParameterTableModel().removeData(
871:                                        sorter.modelIndex(selectedRowIndex));
872:
873:                            } catch (Exception exception) {
874:                                Tools.ihmExceptionView(exception.toString());
875:                            }
876:                        }
877:
878:                    } else {
879:                        Object[] options = {
880:                                Language.getInstance().getText("Oui"),
881:                                Language.getInstance().getText("Non") };
882:                        int choice = -1;
883:                        choice = JOptionPane
884:                                .showOptionDialog(
885:                                        ParameterView.this ,
886:                                        //"Etes vous s?r de vouloir supprimer le param?tre <" +(String)DataModel.getParameterTableModel().getValueAt(selectedRowIndex, 0) + "> du projet ?",
887:                                        Language
888:                                                .getInstance()
889:                                                .getText(
890:                                                        "Etes_vous_sûr_de_vouloir_supprimer_le_paramètre_<")
891:                                                + (String) sorter.getValueAt(
892:                                                        selectedRowIndex, 0)
893:                                                + Language
894:                                                        .getInstance()
895:                                                        .getText(
896:                                                                ">_du_projet_?"),
897:                                        Language.getInstance().getText(
898:                                                "Attention_!"),
899:                                        JOptionPane.YES_NO_OPTION,
900:                                        JOptionPane.QUESTION_MESSAGE, null,
901:                                        options, options[1]);
902:                        if (choice == JOptionPane.YES_OPTION) {
903:
904:                            try {
905:                                // BdD
906:                                Parameter pParam = ProjectData
907:                                        .getCurrentProject().getParameter(
908:                                                paramName);
909:                                ProjectData.delParamInBddAndModel(pParam);
910:                                //DataModel.getCurrentProject().getParameter(paramName).deleteFromDB();
911:
912:                                // IHM
913:                                DataModel.getParameterTableModel().removeData(
914:                                        sorter.modelIndex(selectedRowIndex));
915:                                //DataModel.getCurrentProject().removeParameter(paramName);
916:
917:                            } catch (Exception exception) {
918:                                Tools.ihmExceptionView(exception.toString());
919:                            }
920:                        }
921:                    }
922:                }
923:            }
924:
925:            public void parametersTablevalueChanged(ListSelectionEvent e) {
926:
927:                if (e.getValueIsAdjusting())
928:                    return;
929:
930:                int nbOfSelectedRows = parametersTable.getSelectedRowCount();
931:                int selectedRow = parametersTable.getSelectedRow();
932:                if (selectedRow != -1) {
933:                    if (nbOfSelectedRows != 1) {
934:                        if (usingFonctionEnable) {
935:                            if (AdminProject.canDeleteTest())
936:                                deleteParameterButton.setEnabled(true);
937:                        } else {
938:                            if (AdminProject.canDeleteCamp())
939:                                deleteParameterButton.setEnabled(true);
940:                        }
941:                        modifyParameterButton.setEnabled(false);
942:
943:                    } else {
944:                        if (usingFonctionEnable) {
945:                            if (AdminProject.canUpdateTest())
946:                                modifyParameterButton.setEnabled(true);
947:                            if (AdminProject.canDeleteTest())
948:                                deleteParameterButton.setEnabled(true);
949:                        } else {
950:                            if (AdminProject.canUpdateCamp()
951:                                    || AdminProject.canExecutCamp())
952:                                modifyParameterButton.setEnabled(true);
953:                            if (AdminProject.canDeleteCamp())
954:                                deleteParameterButton.setEnabled(true);
955:                        }
956:                    }
957:                } else {
958:                    deleteParameterButton.setEnabled(false);
959:                    modifyParameterButton.setEnabled(false);
960:                }
961:
962:            }
963:
964:        } // Fin de la classe ManualParameterView
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.