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.GridLayout;
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.util.ArrayList;
036: import java.util.GregorianCalendar;
037: import java.util.HashMap;
038:
039: import javax.swing.BorderFactory;
040: import javax.swing.Box;
041: import javax.swing.BoxLayout;
042: import javax.swing.ImageIcon;
043: import javax.swing.JButton;
044: import javax.swing.JDialog;
045: import javax.swing.JLabel;
046: import javax.swing.JPanel;
047: import javax.swing.JScrollPane;
048: import javax.swing.JTable;
049: import javax.swing.JTextPane;
050: import javax.swing.ListSelectionModel;
051: import javax.swing.event.CaretEvent;
052: import javax.swing.event.CaretListener;
053: import javax.swing.event.ListSelectionEvent;
054: import javax.swing.event.ListSelectionListener;
055:
056: import org.objectweb.salome_tmf.api.ApiConstants;
057: import org.objectweb.salome_tmf.data.Action;
058: import org.objectweb.salome_tmf.data.DataConstants;
059: import org.objectweb.salome_tmf.data.Execution;
060: import org.objectweb.salome_tmf.data.ExecutionResult;
061: import org.objectweb.salome_tmf.data.ManualTest;
062: import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
063: import org.objectweb.salome_tmf.ihm.languages.Language;
064: import org.objectweb.salome_tmf.ihm.models.MyTableModel;
065: import org.objectweb.salome_tmf.ihm.plugins.PluginsTools;
066: import org.objectweb.salome_tmf.ihm.tools.Tools;
067:
068: /**
069: * Classe qui cr?e la fen?tre tracant l'?x?cution d'un test
070: * @author teaml039
071: * @version : 0.1
072: */
073: public class ManualExecution extends JDialog implements ApiConstants,
074: DataConstants, IHMConstants, Runnable {
075:
076: /**
077: * Bouton pour indiquer que l'action a r?ussi
078: */
079: JButton statusOkButton;
080:
081: /**
082: * Bouton pour indiquer que l'action a ?chou?
083: */
084: JButton statusFailedButton;
085:
086: /**
087: * Bouton pour indiquer que l'on ne conna?t pas le r?sultat de l'action
088: */
089: JButton statusUnknowButton;
090:
091: /**
092: * Bouton pour revenir au test pr?c?dent
093: */
094: JButton prevTestButton;
095:
096: /**
097: * Bouton pour passer au test suivant
098: */
099: JButton nextTestButton;
100:
101: /**
102: * Bouton pour interrompre l'ex?cution
103: */
104: JButton stopButton;
105:
106: /**
107: * Bouton pour sortir de la fen?tre
108: */
109: JButton endButton;
110:
111: /**
112: * Mod?le de donn?es pour la table des actions
113: */
114: MyTableModel actionsTableModel;
115:
116: /**
117: * Table des actions
118: */
119: JTable actionsTable;
120:
121: /**
122: * Description de l'action courante
123: */
124: JTextPane actionDescription;
125:
126: /**
127: * R?sultat attendu de l'action courante
128: */
129: JTextPane awaitedResult;
130:
131: /**
132: * R?sultat effectif de l'action courante
133: */
134: JTextPane effectiveResult;
135:
136: /**
137: * Liste des tests ? ex?cuter
138: */
139: ArrayList testsToBeExecuted;
140:
141: /**
142: * Nom du test courant
143: */
144: JLabel testName;
145:
146: /**
147: * Description du test courant
148: */
149: JTextPane testDescription;
150:
151: /**
152: * Conteneur pour l'affichage
153: */
154: Container contentPaneFrame;
155:
156: /**
157: * Le test en cours d'ex?cution
158: */
159: ManualTest testInExecution;
160:
161: /**
162: * Indice du test en cours d'ex?cution
163: */
164: int indexOfTextInExecution;
165:
166: /**
167: * R?sultat de l'?x?cution
168: */
169: ExecutionResult execResult;
170:
171: /**
172: * Nom du r?sultat d'ex?cution courant
173: */
174: String currentExecutionResultName;
175:
176: /**
177: * Indexe de bloquage dans la table des actions (pour emp?cher la s?lection)
178: */
179: int blockIndex;
180:
181: /**
182: * Mod?le de s?lection pour la table des actions
183: */
184: ListSelectionModel rowSM;
185:
186: /**
187: * Execution courante
188: */
189: Execution currentExecution;
190:
191: HashMap oldMap;
192:
193: Thread t;
194:
195: //ExecutionView execView;
196:
197: //JButton addBugButton;
198:
199: boolean finished = false;
200: boolean stop_exec = false;
201:
202: /******************************************************************************/
203: /** CONSTRUCTEUR ***/
204: /******************************************************************************/
205: //ExecutionResult finalExecResult;
206: /**
207: * Constructeur de la fen?tre
208: * @param testList liste de tests ? ex?cuter
209: */
210: public ManualExecution(ArrayList testList, Execution execution,
211: ExecutionResult executionResult) {
212:
213: super (SalomeTMF.ptrFrame, true);
214: //this.finalExecResult = finalExecResult;
215:
216: finished = false;
217: blockIndex = 0;
218:
219: oldMap = new HashMap();
220:
221: statusOkButton = new JButton(Language.getInstance().getText(
222: "Succès"));
223:
224: statusFailedButton = new JButton(Language.getInstance()
225: .getText("Echec"));
226:
227: statusUnknowButton = new JButton(Language.getInstance()
228: .getText("Inconclusif"));
229:
230: prevTestButton = new JButton(Language.getInstance().getText(
231: "Test_précédent"));
232:
233: nextTestButton = new JButton(Language.getInstance().getText(
234: "Test_suivant"));
235:
236: stopButton = new JButton(Language.getInstance().getText("Stop"));
237:
238: endButton = new JButton(Language.getInstance().getText(
239: "Terminer"));
240:
241: actionsTableModel = new MyTableModel();
242:
243: actionsTable = new JTable();
244:
245: actionDescription = new JTextPane();
246:
247: awaitedResult = new JTextPane();
248:
249: effectiveResult = new JTextPane();
250:
251: testsToBeExecuted = new ArrayList();
252:
253: testName = new JLabel();
254:
255: testDescription = new JTextPane();
256:
257: // Mapping entre objets graphiques et constantes
258: SalomeTMF.addToUIComponentsMap(
259: UICompCst.MANUAL_EXECUTION_TEST_DESCRIPTION_TEXTPANE,
260: testDescription);
261: SalomeTMF.addToUIComponentsMap(
262: UICompCst.MANUAL_EXECUTION_ACTION_DESCRIPTION_TEXTPANE,
263: actionDescription);
264: SalomeTMF
265: .addToUIComponentsMap(
266: UICompCst.MANUAL_EXECUTION_ACTION_WAITED_RESULT_TEXTPANE,
267: awaitedResult);
268: SalomeTMF
269: .addToUIComponentsMap(
270: UICompCst.MANUAL_EXECUTION_ACTION_EFFECTIVE_RESULT_TEXTPANE,
271: effectiveResult);
272: // Activation des plugins associ?s
273: PluginsTools
274: .activateAssociatedPlgs(UICompCst.MANUAL_EXECUTION_TEST_DESCRIPTION_TEXTPANE);
275: PluginsTools
276: .activateAssociatedPlgs(UICompCst.MANUAL_EXECUTION_ACTION_DESCRIPTION_TEXTPANE);
277: PluginsTools
278: .activateAssociatedPlgs(UICompCst.MANUAL_EXECUTION_ACTION_WAITED_RESULT_TEXTPANE);
279: PluginsTools
280: .activateAssociatedPlgs(UICompCst.MANUAL_EXECUTION_ACTION_EFFECTIVE_RESULT_TEXTPANE);
281:
282: contentPaneFrame = this .getContentPane();
283:
284: //execView = executionView;
285:
286: statusOkButton.setToolTipText(Language.getInstance().getText(
287: "L'action_a_réussie"));
288: statusOkButton.setIcon(Tools.createAppletImageIcon(
289: PATH_TO_SUCCESS_ICON, ""));
290: statusOkButton.addActionListener(new ActionListener() {
291: public void actionPerformed(ActionEvent e) {
292: int selectedRowIndex = actionsTable.getSelectedRow();
293: if (selectedRowIndex != -1) {
294: actionsTableModel.setValueAt(Tools
295: .createAppletImageIcon(
296: PATH_TO_SUCCESS_ICON, ""),
297: selectedRowIndex, actionsTableModel
298: .getColumnCount() - 1);
299: execResult.addStatusForAction(testInExecution
300: .getAction((String) actionsTableModel
301: .getValueAt(selectedRowIndex, 0)),
302: SUCCESS);
303:
304: if (selectedRowIndex < (actionsTableModel
305: .getRowCount() - 1)) {
306:
307: blockIndexCalculation(selectedRowIndex);
308: ListSelectionModel lsm = actionsTable
309: .getSelectionModel();
310: lsm.setSelectionInterval(selectedRowIndex + 1,
311: selectedRowIndex + 1);
312: } else {
313:
314: blockIndexCalculation(0);
315: changeTest();
316: }
317: }
318: }
319: });
320:
321: statusFailedButton.setToolTipText(Language.getInstance()
322: .getText("L'action_a_échouée"));
323: statusFailedButton.setIcon(Tools.createAppletImageIcon(
324: PATH_TO_FAIL_ICON, ""));
325: statusFailedButton.addActionListener(new ActionListener() {
326: public void actionPerformed(ActionEvent e) {
327: int selectedRowIndex = actionsTable.getSelectedRow();
328: if (selectedRowIndex != -1) {
329:
330: execResult.addStatusForAction(testInExecution
331: .getAction((String) actionsTableModel
332: .getValueAt(selectedRowIndex, 0)),
333: FAIL);
334: actionsTableModel.setValueAt(Tools
335: .createAppletImageIcon(PATH_TO_FAIL_ICON,
336: ""), selectedRowIndex,
337: actionsTableModel.getColumnCount() - 1);
338: if (selectedRowIndex < (actionsTableModel
339: .getRowCount() - 1)) {
340: //blockIndex = selectedRowIndex + 1;
341: blockIndexCalculation(selectedRowIndex);
342: } else {
343: //blockIndex = 0;
344: blockIndexCalculation(0);
345: }
346: }
347: }
348: });
349:
350: statusUnknowButton.setToolTipText(Language.getInstance()
351: .getText("Pas_de_résultat_pour_cette_action"));
352: statusUnknowButton.setIcon(Tools.createAppletImageIcon(
353: PATH_TO_UNKNOW_ICON, ""));
354: statusUnknowButton.addActionListener(new ActionListener() {
355: public void actionPerformed(ActionEvent e) {
356: int selectedRowIndex = actionsTable.getSelectedRow();
357: if (selectedRowIndex != -1) {
358:
359: execResult.addStatusForAction(testInExecution
360: .getAction((String) actionsTableModel
361: .getValueAt(selectedRowIndex, 0)),
362: UNKNOWN);
363: actionsTableModel.setValueAt(Tools
364: .createAppletImageIcon(PATH_TO_UNKNOW_ICON,
365: ""), selectedRowIndex,
366: actionsTableModel.getColumnCount() - 1);
367: if (selectedRowIndex < (actionsTableModel
368: .getRowCount() - 1)) {
369: //blockIndex = selectedRowIndex + 1;
370: blockIndexCalculation(selectedRowIndex);
371: } else {
372: //blockIndex = 0;
373: blockIndexCalculation(0);
374: }
375: }
376: }
377: });
378:
379: prevTestButton.setToolTipText(Language.getInstance().getText(
380: "Revenir_au_test_précédent"));
381: prevTestButton.setEnabled(false);
382: prevTestButton.setIcon(Tools.createAppletImageIcon(
383: PATH_TO_ARROW_BACK_ICON, ""));
384: prevTestButton.addActionListener(new ActionListener() {
385: public void actionPerformed(ActionEvent e) {
386: changeTestBack();
387: blockIndexCalculation(0);
388: }
389: });
390:
391: nextTestButton.setToolTipText(Language.getInstance().getText(
392: "Passer_au_test_suivant"));
393: nextTestButton.setIcon(Tools.createAppletImageIcon(
394: PATH_TO_ARROW_ICON, ""));
395: nextTestButton.addActionListener(new ActionListener() {
396: public void actionPerformed(ActionEvent e) {
397: changeTest();
398: blockIndexCalculation(0);
399: }
400: });
401: if (testList.size() < 2) {
402: nextTestButton.setEnabled(false);
403: }
404:
405: stopButton.setToolTipText(Language.getInstance().getText(
406: "Interrompre_l'exécution"));
407: stopButton.setIcon(Tools.createAppletImageIcon(
408: PATH_TO_STOP_ICON, ""));
409: stopButton.addActionListener(new ActionListener() {
410: public void actionPerformed(ActionEvent e) {
411: testStatusCalculation();
412: stop_exec = true;
413: execResult.setExecutionStatus(INTERRUPT);
414: //execView.libere();
415: finished = true;
416: ManualExecution.this .dispose();
417: }
418: });
419:
420: endButton.setToolTipText(Language.getInstance().getText(
421: "Sortir_de_l'exécution"));
422: endButton.setIcon(Tools.createAppletImageIcon(
423: PATH_TO_MOVE_ICON, ""));
424: endButton.addActionListener(new ActionListener() {
425: public void actionPerformed(ActionEvent e) {
426: testStatusCalculation();
427:
428: finished = true;
429: ManualExecution.this .dispose();
430: }
431: });
432:
433: JButton attachButton = new JButton(Language.getInstance()
434: .getText("Attachements"));
435: attachButton.addActionListener(new ActionListener() {
436: public void actionPerformed(ActionEvent e) {
437: new AttachmentViewWindow(SalomeTMF.ptrSalomeTMF,
438: EXECUTION_RESULT_TEST, DataModel
439: .getCurrentExecutionTestResult(), null,
440: null, null);
441:
442: }
443: });
444:
445: // Details sur le test
446: testDescription.setEditable(false);
447: JScrollPane testDescriptionScrollPane = new JScrollPane(
448: testDescription);
449: testDescriptionScrollPane.setPreferredSize(new Dimension(150,
450: 150));
451: testDescriptionScrollPane.setBorder(BorderFactory
452: .createTitledBorder(BorderFactory
453: .createLineBorder(Color.BLACK), Language
454: .getInstance().getText("Description_du_test")));
455:
456: // Table d'actions
457:
458: actionsTableModel.addColumnNameAndColumn(Language.getInstance()
459: .getText("Action"));
460: actionsTableModel.addColumnNameAndColumn(Language.getInstance()
461: .getText("Attachement"));
462: actionsTableModel.addColumnNameAndColumn(Language.getInstance()
463: .getText("Date"));
464: actionsTableModel.addColumnNameAndColumn(Language.getInstance()
465: .getText("Statut"));
466:
467: /*TableSorter sorter = new TableSorter(actionsTableModel);
468: actionsTable.setModel(sorter);
469: sorter.setTableHeader(actionsTable.getTableHeader()); */
470: actionsTable.setModel(actionsTableModel);
471:
472: actionsTable.setPreferredScrollableViewportSize(new Dimension(
473: 700, 200));
474: actionsTable
475: .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
476:
477: rowSM = actionsTable.getSelectionModel();
478: rowSM.addListSelectionListener(new ListSelectionListener() {
479: public void valueChanged(ListSelectionEvent e) {
480: if (e.getValueIsAdjusting())
481: return;
482:
483: int selectedRowIndex = actionsTable.getSelectedRow();
484: if (selectedRowIndex != -1
485: && actionsTableModel.getRowCount() > 0) {
486: if (blockIndex != -1
487: && selectedRowIndex > blockIndex) {
488: selectedRowIndex = blockIndex;
489: rowSM.setSelectionInterval(selectedRowIndex,
490: selectedRowIndex);
491: }
492: ArrayList dataList = actionsTableModel
493: .getData(selectedRowIndex);
494: Action action = testInExecution
495: .getAction((String) dataList.get(0));
496: actionDescription.setText(Tools
497: .getInstantiedDescription(action
498: .getDescription(), currentExecution
499: .getDataSet()));
500: actionDescription.getCaret().setDot(0);
501: awaitedResult.setText(Tools
502: .getInstantiedDescription(action
503: .getAwaitedResult(),
504: currentExecution.getDataSet()));
505: awaitedResult.getCaret().setDot(0);
506: effectiveResult.setText(execResult
507: .getEffectivResult(action));
508: effectiveResult.getCaret().setDot(0);
509: }
510: }
511: });
512:
513: // Mapping entre objets graphiques et constantes
514: SalomeTMF.addToUIComponentsMap(
515: UICompCst.MANUAL_EXECUTION_ACTIONS_TABLE, actionsTable);
516: // Activation des plugins associés
517: PluginsTools
518: .activateAssociatedPlgs(UICompCst.MANUAL_EXECUTION_ACTIONS_TABLE);
519:
520: JScrollPane actionsTableScrollPane = new JScrollPane(
521: actionsTable);
522:
523: // Details sur les actions
524: actionDescription.setEditable(false);
525: JScrollPane actionDescriptionScrollPane = new JScrollPane(
526: actionDescription);
527: actionDescriptionScrollPane.setBorder(BorderFactory
528: .createTitledBorder(BorderFactory
529: .createLineBorder(Color.BLACK), Language
530: .getInstance().getText(
531: "Description_de_l'action")));
532: actionDescriptionScrollPane.setPreferredSize(new Dimension(400,
533: 180));
534:
535: awaitedResult.setEditable(false);
536: JScrollPane awaitedResultScrollPane = new JScrollPane(
537: awaitedResult);
538: awaitedResultScrollPane.setBorder(BorderFactory
539: .createTitledBorder(BorderFactory
540: .createLineBorder(Color.BLACK), Language
541: .getInstance().getText("Résultat_attendu")));
542: awaitedResultScrollPane
543: .setPreferredSize(new Dimension(200, 180));
544:
545: effectiveResult.addCaretListener(new EffectivResultListener());
546: JScrollPane effectiveResultScrollPane = new JScrollPane(
547: effectiveResult);
548: effectiveResultScrollPane.setBorder(BorderFactory
549: .createTitledBorder(BorderFactory
550: .createLineBorder(Color.BLACK), Language
551: .getInstance().getText("Résultat_effectif")));
552: effectiveResultScrollPane.setPreferredSize(new Dimension(200,
553: 180));
554:
555: // Construction de la fen?tre
556: //JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
557: JPanel buttonsPanel = new JPanel(new GridLayout(1, 10));
558: buttonsPanel.add(statusOkButton);
559: buttonsPanel.add(statusFailedButton);
560: buttonsPanel.add(statusUnknowButton);
561: buttonsPanel.add(Box.createRigidArea(new Dimension(50, 1)));
562: buttonsPanel.add(prevTestButton);
563: buttonsPanel.add(nextTestButton);
564: buttonsPanel.add(stopButton);
565: buttonsPanel.add(endButton);
566: buttonsPanel.add(Box.createRigidArea(new Dimension(50, 1)));
567: buttonsPanel.add(attachButton);
568: //buttonsPanel.add(addBugButton);
569:
570: // Mapping entre objets graphiques et constantes
571: SalomeTMF.addToUIComponentsMap(
572: UICompCst.MANUAL_EXECUTION_BUTTONS_PANEL, buttonsPanel);
573: // Activation des plugins associ?es
574: PluginsTools
575: .activateAssociatedPlgs(UICompCst.MANUAL_EXECUTION_BUTTONS_PANEL);
576:
577: JPanel testDetailsPanel = new JPanel();
578: testDetailsPanel.setLayout(new BoxLayout(testDetailsPanel,
579: BoxLayout.Y_AXIS));
580: testDetailsPanel.add(testName);
581: testDetailsPanel.add(Box.createRigidArea(new Dimension(1, 10)));
582: testDetailsPanel.add(testDescriptionScrollPane);
583:
584: JPanel actionsResults = new JPanel();
585: actionsResults.setLayout(new BoxLayout(actionsResults,
586: BoxLayout.X_AXIS));
587: actionsResults.add(awaitedResultScrollPane);
588: actionsResults.add(effectiveResultScrollPane);
589:
590: JPanel actionsDetailsPanel = new JPanel(new BorderLayout());
591: actionsDetailsPanel.add(actionDescriptionScrollPane,
592: BorderLayout.NORTH);
593: actionsDetailsPanel.add(actionsResults, BorderLayout.SOUTH);
594:
595: contentPaneFrame.add(actionsTableScrollPane,
596: BorderLayout.CENTER);
597: contentPaneFrame.add(actionsDetailsPanel, BorderLayout.SOUTH);
598: contentPaneFrame.add(buttonsPanel, BorderLayout.NORTH);
599: contentPaneFrame.add(testDetailsPanel, BorderLayout.EAST);
600:
601: initData(testList, execution, executionResult);
602:
603: if (actionsTableModel.getRowCount() > 0) {
604: rowSM.setSelectionInterval(0, 0);
605: }
606:
607: this .addWindowListener(new WindowListener() {
608: public void windowClosing(WindowEvent e) {
609:
610: testStatusCalculation();
611: //execView.libere();
612: //execResult.setExecutionStatus(INTERRUPT);
613: stop_exec = true;
614: finished = true;
615: }
616:
617: public void windowDeiconified(WindowEvent e) {
618: }
619:
620: public void windowOpened(WindowEvent e) {
621: }
622:
623: public void windowActivated(WindowEvent e) {
624: }
625:
626: public void windowDeactivated(WindowEvent e) {
627: }
628:
629: public void windowClosed(WindowEvent e) {
630: }
631:
632: public void windowIconified(WindowEvent e) {
633: }
634: });
635:
636: this .setLocation(0, 80);
637: this .setTitle(Language.getInstance().getText(
638: "Execution_d'un_test_manuel_(exéc._en_cours_:_")
639: + execution.getName() + ")");
640: this .pack();
641:
642: } // Fin du constructeur ManualExecution/0
643:
644: /**
645: * M?thode qui initialise l'ex?cution avec la liste des tests pass?e en
646: * param?tre
647: * @param list une liste de tests
648: */
649: public void initData(ArrayList list, Execution execution,
650: ExecutionResult executionResult) {
651:
652: execResult = executionResult;
653:
654: currentExecution = execution;
655:
656: if (list != null && list.size() > 0) {
657: testsToBeExecuted = list;
658: indexOfTextInExecution = 0;
659: blockIndex = 0;
660: testInExecution = (ManualTest) testsToBeExecuted.get(0);
661: DataModel.setCurrentExecutionTestResult(execResult
662: .getExecutionTestResult(testInExecution));
663: testName.setText(Language.getInstance().getText(
664: "Nom_du_test_:_")
665: + testInExecution.getName());
666: testDescription.setText(testInExecution.getDescription());
667: for (int i = 0; i < testInExecution.getActionList().size(); i++) {
668: Action action = (Action) testInExecution
669: .getActionList().get(i);
670: ArrayList actionData = new ArrayList();
671: actionData.add(action.getName());
672: actionData.add(action.getAttachmentMap().keySet());
673: actionData.add(GregorianCalendar.getInstance()
674: .getTime().toString());
675: actionData.add(Tools.getActionStatusIcon(execResult
676: .getActionStatus(action)));
677: if (execResult.getActionStatus(action) != null
678: && !execResult.getActionStatus(action).equals(
679: "")) {
680: blockIndex = blockIndex + 1;
681: }
682: actionsTableModel.addRow(actionData);
683: }
684: for (int i = 0; i < list.size(); i++) {
685: ManualTest test = (ManualTest) list.get(i);
686: for (int j = 0; j < test.getActionList().size(); j++) {
687: Action action = (Action) test.getActionList()
688: .get(j);
689: execResult.addDescriptionResult(action, Tools
690: .getInstantiedDescription(action
691: .getDescription(), currentExecution
692: .getDataSet()));
693: execResult.addAwaitedResult(action, Tools
694: .getInstantiedDescription(action
695: .getAwaitedResult(),
696: currentExecution.getDataSet()));
697: }
698: }
699: }
700: } // Fin de la m?thode initData/1
701:
702: /**
703: * M?thode qui permet de passer au test suivant.
704: */
705: public void changeTest() {
706: if (testsToBeExecuted.size() > 1) {
707: prevTestButton.setEnabled(true);
708: }
709: if ((indexOfTextInExecution + 1) == (testsToBeExecuted.size() - 1)) {
710:
711: nextTestButton.setEnabled(false);
712: }
713: testStatusCalculation();
714: if ((indexOfTextInExecution + 1) < testsToBeExecuted.size()) {
715:
716: indexOfTextInExecution++;
717: testInExecution = (ManualTest) testsToBeExecuted
718: .get(indexOfTextInExecution);
719: DataModel.setCurrentExecutionTestResult(execResult
720: .getExecutionTestResult(testInExecution));
721: testName.setText(Language.getInstance().getText(
722: "Nom_du_test_:_")
723: + testInExecution.getName());
724: testDescription.setText(testInExecution.getDescription());
725: actionsTableModel.clearTable();
726: for (int i = 0; i < testInExecution.getActionList().size(); i++) {
727: Action action = (Action) testInExecution
728: .getActionList().get(i);
729: ArrayList actionData = new ArrayList();
730: actionData.add(action.getName());
731: actionData.add(action.getAttachmentMap().keySet());
732: actionData.add(GregorianCalendar.getInstance()
733: .getTime().toString());
734: //putIconStatusInTable(actionData, action.getStatus(currentExecutionResultName), i);
735: putIconStatusInTable(actionData, execResult
736: .getActionStatus(action), i);
737: actionsTableModel.addRow(actionData);
738: }
739: ListSelectionModel lsm = actionsTable.getSelectionModel();
740: lsm.setSelectionInterval(0, 0);
741:
742: } else if ((indexOfTextInExecution + 1) == testsToBeExecuted
743: .size()) {
744:
745: }
746:
747: } // Fin de la m?thode changeTest/0
748:
749: /**
750: * M?thode qui permet de passer au test pr?c?dant.
751: */
752: public void changeTestBack() {
753: if (testsToBeExecuted.size() > 1) {
754: nextTestButton.setEnabled(true);
755: }
756: if ((indexOfTextInExecution - 1) == 0) {
757: prevTestButton.setEnabled(false);
758: }
759: testStatusCalculation();
760: if ((indexOfTextInExecution - 1) > -1) {
761: indexOfTextInExecution--;
762: testInExecution = (ManualTest) testsToBeExecuted
763: .get(indexOfTextInExecution);
764: DataModel.setCurrentExecutionTestResult(execResult
765: .getExecutionTestResult(testInExecution));
766: testName.setText(Language.getInstance().getText(
767: "Nom_du_test_:_")
768: + testInExecution.getName());
769: testDescription.setText(testInExecution.getDescription());
770: actionsTableModel.clearTable();
771: for (int i = 0; i < testInExecution.getActionList().size(); i++) {
772: Action action = (Action) testInExecution
773: .getActionList().get(i);
774: ArrayList actionData = new ArrayList();
775: actionData.add(action.getName());
776: actionData.add(action.getAttachmentMap().keySet());
777: actionData.add(GregorianCalendar.getInstance()
778: .getTime().toString());
779: //putIconStatusInTable(actionData, action.getStatus(currentExecutionResultName), i);
780: putIconStatusInTable(actionData, execResult
781: .getActionStatus(action), i);
782: actionsTableModel.addRow(actionData);
783: }
784: ListSelectionModel lsm = actionsTable.getSelectionModel();
785: lsm.setSelectionInterval(0, 0);
786:
787: }
788:
789: } // Fin de la m?thode changeTestBack/0
790:
791: /**
792: * M?thode qui retourne le r?sultat de l'ex?cution
793: * @return le r?sultat de l'ex?cution
794: */
795: public ExecutionResult getExecutionResult() {
796: return execResult;
797: } // Fin de la m?thode getExecutionResult/0
798:
799: /**
800: *
801: * @param data
802: * @param type
803: * @param index
804: */
805: public void putIconStatusInTable(ArrayList data, String type,
806: int index) {
807: ImageIcon icon = getActionStatusIcon(type, index);
808: if (icon != null) {
809: data.add(icon);
810: } else {
811: data.add("");
812: }
813: } // Fin de la m?thode putIconStatusInTable/2
814:
815: /**
816: * Retourne l'icone associ?e au type pass? au param?tre. On retourne <code>null</code>
817: * si le type n'est pas SUCCESS, FAIL ou UNKNOW.
818: * @param type
819: * @param index
820: * @return
821: */
822: public ImageIcon getActionStatusIcon(String type, int index) {
823: if (type.equals(SUCCESS)) {
824: } else if (type.equals(FAIL)) {
825: blockIndex = index;
826: } else if (type.equals(UNKNOWN)) {
827: blockIndex = index;
828: }
829: return Tools.getActionStatusIcon(type);
830: } // Fin de la m?thode getActionStatusIcon/1
831:
832: /**
833: *
834: *
835: */
836: public void testStatusCalculation() {
837: int successAction = 0;
838: ArrayList actionList = testInExecution.getActionList();
839: for (int i = 0; i < actionList.size(); i++) {
840: if (execResult
841: .getActionStatus(((Action) actionList.get(i)))
842: .equals(FAIL)) {
843: execResult.addTestResultStatus(testInExecution, FAIL);
844: return;
845: } else if (execResult.getActionStatus(
846: ((Action) actionList.get(i))).equals(UNKNOWN)) {
847: execResult
848: .addTestResultStatus(testInExecution, UNKNOWN);
849: return;
850: } else if (execResult.getActionStatus(
851: ((Action) actionList.get(i))).equals(SUCCESS)) {
852: successAction++;
853: }
854:
855: }
856: if (successAction == actionList.size()) {
857: execResult.addTestResultStatus(testInExecution, SUCCESS);
858: return;
859: }
860: execResult.addTestResultStatus(testInExecution, "");
861: } // Fin de la m?thode testStatusCalculation/0
862:
863: /**
864: * Calcule l'index de bloquage de la s?lection.
865: */
866: private void blockIndexCalculation(int selectedRowIndex) {
867: ArrayList actionList = testInExecution.getActionList();
868: blockIndex = selectedRowIndex + 1;
869:
870: while (blockIndex < actionList.size()
871: && !execResult.getActionStatus(
872: ((Action) actionList.get(blockIndex))).equals(
873: "")) {
874: blockIndex++;
875: }
876: } // Fin de la m?thode blockIndexCalculation/0
877:
878: /**
879: * Retourne la liste des attachements ? supprimer
880: * @return
881: */
882: public HashMap getOldAttachMap() {
883: return oldMap;
884: } // Fin de la m?thode getOldAttachMap/0
885:
886: /**
887: *
888: * @author teaml039
889: */
890: public class EffectivResultListener implements CaretListener {
891:
892: /* (non-Javadoc)
893: * @see javax.swing.event.CaretListener#caretUpdate(javax.swing.event.CaretEvent)
894: */
895: public void caretUpdate(CaretEvent e) {
896: int selectedRowIndex = actionsTable.getSelectedRow();
897: if (selectedRowIndex != -1) {
898: execResult.addEffectivResult(testInExecution
899: .getAction((String) actionsTableModel
900: .getValueAt(selectedRowIndex, 0)),
901: ((JTextPane) e.getSource()).getText());
902: }
903: }
904: } // Fin de la classe EffectivResultListener
905:
906: public void lauchManualExecution() {
907: t = new Thread(this );
908: stop_exec = false;
909: t.start();
910: }
911:
912: public void run() {
913: this .setVisible(true);
914: }
915:
916: public boolean isStoped() {
917: return stop_exec;
918: }
919:
920: public boolean isFinished() {
921: return finished;
922: }
923:
924: public void setFinished(boolean b) {
925: finished = b;
926: }
927: } // Fin de la classe ManualExecution
|