Source Code Cross Referenced for ActionDetailsView.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.Font;
032:        import java.awt.Frame;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.util.ArrayList;
036:        import java.util.Collection;
037:        import java.util.HashMap;
038:        import java.util.Iterator;
039:        import java.util.Set;
040:        import java.util.Vector;
041:
042:        import javax.swing.BorderFactory;
043:        import javax.swing.BoxLayout;
044:        import javax.swing.JButton;
045:        import javax.swing.JDialog;
046:        import javax.swing.JLabel;
047:        import javax.swing.JPanel;
048:        import javax.swing.JScrollPane;
049:        import javax.swing.JTable;
050:        import javax.swing.JTextPane;
051:        import javax.swing.ListSelectionModel;
052:        import javax.swing.event.ListSelectionEvent;
053:        import javax.swing.event.ListSelectionListener;
054:
055:        import org.objectweb.salome_tmf.api.Api;
056:        import org.objectweb.salome_tmf.data.Action;
057:        import org.objectweb.salome_tmf.data.Attachment;
058:        import org.objectweb.salome_tmf.data.ConnectionData;
059:        import org.objectweb.salome_tmf.data.DataConstants;
060:        import org.objectweb.salome_tmf.data.Execution;
061:        import org.objectweb.salome_tmf.data.ExecutionResult;
062:        import org.objectweb.salome_tmf.data.ExecutionTestResult;
063:        import org.objectweb.salome_tmf.data.FileAttachment;
064:        import org.objectweb.salome_tmf.data.ManualTest;
065:        import org.objectweb.salome_tmf.data.UrlAttachment;
066:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
067:        import org.objectweb.salome_tmf.ihm.languages.Language;
068:        import org.objectweb.salome_tmf.ihm.models.MyTableModel;
069:        import org.objectweb.salome_tmf.ihm.plugins.PluginsTools;
070:        import org.objectweb.salome_tmf.ihm.tools.Tools;
071:
072:        /**
073:         * Classe représentant la vue sur le détails des actions de tests
074:         * @author teaml039
075:         * @version : 0.1
076:         */
077:        public class ActionDetailsView extends JDialog implements  DataConstants {
078:
079:            /**
080:             * Modèle de données de la table des résultats d'action
081:             */
082:            MyTableModel actionsResultTableModel;
083:
084:            /**
085:             * Table des résultats d'action
086:             */
087:            JTable actionsResultTable;
088:
089:            /**
090:             * Description de l'action
091:             */
092:            JTextPane descriptionArea;
093:
094:            /**
095:             * Description du résultat attendu
096:             */
097:            JTextPane awaitedResultArea;
098:
099:            /**
100:             * Description du résultat effectif
101:             */
102:            JTextPane effectiveResultArea;
103:
104:            /**
105:             * Le panel des attachements
106:             */
107:            AttachmentView attachmentPanel;
108:
109:            /**
110:             * La table des anciens attachements
111:             */
112:            HashMap oldAttachMap;
113:
114:            /**
115:             * Le résultat de test courant
116:             */
117:            ExecutionTestResult effectivExecutionTestResult;
118:
119:            /**
120:             * Nom de l'exécution courante
121:             */
122:            String effectivExecutionName;
123:
124:            /**
125:             * Nom du résultat d'exécution courant
126:             */
127:            String effectivExecutionResultName;
128:
129:            ExecutionResult execRes;
130:
131:            /******************************************************************************/
132:            /** 							CONSTRUCTEUR								***/
133:            /******************************************************************************/
134:
135:            /**
136:             * Constructeur de la vue.
137:             */
138:            public ActionDetailsView(ManualTest observedTest,
139:                    Execution execution, ExecutionResult executionResult,
140:                    ExecutionTestResult executionTestResult) {
141:
142:                super (new Frame(), true);
143:
144:                execRes = executionResult;
145:
146:                // Initialisation des éléments de la fenêtre
147:                actionsResultTableModel = new MyTableModel();
148:                actionsResultTable = new JTable();
149:                effectiveResultArea = new JTextPane();
150:                awaitedResultArea = new JTextPane();
151:                descriptionArea = new JTextPane();
152:                JLabel testName = new JLabel(observedTest.getTestList()
153:                        .getFamily().getName()
154:                        + "/"
155:                        + observedTest.getTestList().getName()
156:                        + "/"
157:                        + observedTest.getName());
158:                testName.setFont(new Font(null, Font.BOLD, 18));
159:
160:                // Initialisation du modèle de données de la table
161:                actionsResultTableModel.addColumnNameAndColumn(Language
162:                        .getInstance().getText("Nom"));
163:                actionsResultTableModel.addColumnNameAndColumn(Language
164:                        .getInstance().getText("Description"));
165:                actionsResultTableModel.addColumnNameAndColumn(Language
166:                        .getInstance().getText("Résultat_attendu"));
167:                actionsResultTableModel.addColumnNameAndColumn(Language
168:                        .getInstance().getText("Résultat_effectif"));
169:                actionsResultTableModel.addColumnNameAndColumn(Language
170:                        .getInstance().getText("Statut"));
171:
172:                actionsResultTable.setModel(actionsResultTableModel);
173:
174:                actionsResultTable
175:                        .setPreferredScrollableViewportSize(new Dimension(700,
176:                                150));
177:                actionsResultTable
178:                        .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
179:
180:                // Mapping entre objets graphiques et constantes
181:                SalomeTMF.addToUIComponentsMap(
182:                        UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTIONS_TABLE,
183:                        actionsResultTable);
184:                // Activation des plugins associés
185:                PluginsTools
186:                        .activateAssociatedPlgs(UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTIONS_TABLE);
187:
188:                JScrollPane actionsResultTableScrollPane = new JScrollPane(
189:                        actionsResultTable);
190:
191:                // Action lorsqu'un élément est sélectionné dans la table
192:                ListSelectionModel rowSM = actionsResultTable
193:                        .getSelectionModel();
194:                rowSM.addListSelectionListener(new ListSelectionListener() {
195:                    public void valueChanged(ListSelectionEvent e) {
196:                        if (e.getValueIsAdjusting())
197:                            return;
198:
199:                        //Récupération de la l'index de la ligne sélectionnée
200:                        int selectedRowIndex = actionsResultTable
201:                                .getSelectedRow();
202:                        // Mise à jour des différentes descriptions
203:                        if (selectedRowIndex != -1) {
204:                            descriptionArea
205:                                    .setText((String) actionsResultTableModel
206:                                            .getValueAt(selectedRowIndex, 1));
207:                            descriptionArea.getCaret().setDot(0);
208:                            awaitedResultArea
209:                                    .setText((String) actionsResultTableModel
210:                                            .getValueAt(selectedRowIndex, 2));
211:                            awaitedResultArea.getCaret().setDot(0);
212:                            effectiveResultArea
213:                                    .setText((String) actionsResultTableModel
214:                                            .getValueAt(selectedRowIndex, 3));
215:                            effectiveResultArea.getCaret().setDot(0);
216:                        } else {
217:                            descriptionArea.setText("");
218:                            awaitedResultArea.setText("");
219:                            effectiveResultArea.setText("");
220:                        }
221:                    }
222:                });
223:
224:                descriptionArea.setEditable(false);
225:                descriptionArea.setPreferredSize(new Dimension(100, 100));
226:
227:                // Mapping entre objets graphiques et constantes
228:                SalomeTMF.addToUIComponentsMap(
229:                        UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_DESC,
230:                        descriptionArea);
231:                // Activation des plugins associés
232:                PluginsTools
233:                        .activateAssociatedPlgs(UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_DESC);
234:
235:                JScrollPane descriptionScrollPane = new JScrollPane(
236:                        descriptionArea);
237:                descriptionScrollPane.setBorder(BorderFactory
238:                        .createTitledBorder(BorderFactory
239:                                .createLineBorder(Color.BLACK), Language
240:                                .getInstance().getText("Description")));
241:                descriptionScrollPane.setPreferredSize(new Dimension(100, 100));
242:
243:                awaitedResultArea.setEditable(false);
244:                awaitedResultArea.setPreferredSize(new Dimension(100, 100));
245:
246:                // Mapping entre objets graphiques et constantes
247:                SalomeTMF
248:                        .addToUIComponentsMap(
249:                                UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_WAITED_RES,
250:                                awaitedResultArea);
251:                // Activation des plugins associés
252:                PluginsTools
253:                        .activateAssociatedPlgs(UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_WAITED_RES);
254:
255:                JScrollPane awaitedResultScrollPane = new JScrollPane(
256:                        awaitedResultArea);
257:                awaitedResultScrollPane.setBorder(BorderFactory
258:                        .createTitledBorder(BorderFactory
259:                                .createLineBorder(Color.BLACK), Language
260:                                .getInstance().getText("Résultat_attendu")));
261:                awaitedResultScrollPane
262:                        .setPreferredSize(new Dimension(100, 100));
263:
264:                effectiveResultArea.setEditable(false);
265:                effectiveResultArea.setPreferredSize(new Dimension(100, 100));
266:
267:                // Mapping entre objets graphiques et constantes
268:                SalomeTMF.addToUIComponentsMap(
269:                        UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_EFF_RES,
270:                        effectiveResultArea);
271:                // Activation des plugins associés
272:                PluginsTools
273:                        .activateAssociatedPlgs(UICompCst.TEST_EXECUTION_RESULT_DETAILS_ACTION_EFF_RES);
274:
275:                JScrollPane effectiveResultScrollPane = new JScrollPane(
276:                        effectiveResultArea);
277:                effectiveResultScrollPane.setBorder(BorderFactory
278:                        .createTitledBorder(BorderFactory
279:                                .createLineBorder(Color.BLACK), Language
280:                                .getInstance().getText("Résultat_effectif")));
281:                effectiveResultScrollPane.setPreferredSize(new Dimension(100,
282:                        100));
283:
284:                JButton quitButton = new JButton(Language.getInstance()
285:                        .getText("Terminer"));
286:                quitButton.addActionListener(new ActionListener() {
287:                    public void actionPerformed(ActionEvent e) {
288:                        HashMap oldAttachMap = (HashMap) effectivExecutionTestResult
289:                                .getAttachmentMap().clone();
290:                        if (ConnectionData.isConnected()) {
291:                            int transNumber = -1;
292:                            try {
293:                                transNumber = Api
294:                                        .beginTransaction(Api.INSERT_ATTACHMENT);
295:                                // ATTACHEMENTS
296:                                Vector oldFileAttachNamesVector = execRes
297:                                        .getExecTestResAttachFilesFromDB(effectivExecutionTestResult
298:                                                .getTest().getIdBDD());
299:                                // Liste des anciennes urls attachées
300:                                Vector oldUrlAttachVector = execRes
301:                                        .getExecTestResAttachUrlsFromDB(effectivExecutionTestResult
302:                                                .getTest().getIdBDD());
303:                                HashMap attachs = attachmentPanel
304:                                        .getAttachmentMap();
305:                                Collection attachValues = attachs.values();
306:
307:                                for (Iterator iter = oldFileAttachNamesVector
308:                                        .iterator(); iter.hasNext();) {
309:                                    String attach = (String) iter.next();
310:                                    if (!attachs.containsKey(attach)) {
311:
312:                                        Attachment attachment = effectivExecutionTestResult
313:                                                .getAttachment(attach);
314:                                        execRes
315:                                                .deleteAttachFromExecTestResultInDB(
316:                                                        effectivExecutionTestResult
317:                                                                .getTest()
318:                                                                .getIdBDD(),
319:                                                        attachment.getIdBdd());
320:                                        oldAttachMap.remove(attach);
321:                                    }
322:                                }
323:                                for (Iterator iter = oldUrlAttachVector
324:                                        .iterator(); iter.hasNext();) {
325:                                    String attach = (String) iter.next();
326:                                    if (!attachs.containsKey(attach)) {
327:
328:                                        Attachment attachment = effectivExecutionTestResult
329:                                                .getAttachment(attach);
330:                                        execRes
331:                                                .deleteAttachFromExecTestResultInDB(
332:                                                        effectivExecutionTestResult
333:                                                                .getTest()
334:                                                                .getIdBDD(),
335:                                                        attachment.getIdBdd());
336:                                        oldAttachMap.remove(attach);
337:                                    }
338:                                }
339:                                Api.commitTrans(transNumber);
340:
341:                                for (Iterator iter = attachValues.iterator(); iter
342:                                        .hasNext();) {
343:                                    Attachment attach = (Attachment) iter
344:                                            .next();
345:                                    if (attach instanceof  FileAttachment) {
346:                                        if (!oldFileAttachNamesVector
347:                                                .contains(attach.getName())) {
348:
349:                                            execRes
350:                                                    .addAttachFile2ExecTestResInDB(
351:                                                            effectivExecutionTestResult
352:                                                                    .getTest()
353:                                                                    .getIdBDD(),
354:                                                            (FileAttachment) attach);
355:                                        }
356:                                    } else {
357:                                        if (!oldUrlAttachVector.contains(attach
358:                                                .getName())) {
359:
360:                                            execRes
361:                                                    .addAttachUrl2ExecTestResInDB(
362:                                                            effectivExecutionTestResult
363:                                                                    .getTest()
364:                                                                    .getIdBDD(),
365:                                                            (UrlAttachment) attach);
366:                                        }
367:                                    }
368:                                    oldAttachMap.put(attach.getName(), attach);
369:                                }
370:
371:                            } catch (Exception exception) {
372:                                Api.forceRollBackTrans(transNumber);
373:                                Tools.ihmExceptionView(exception.toString());
374:                            }
375:                        }
376:
377:                        if (Api.getException() == null
378:                                || Api.getException().size() == 0) {
379:                            effectivExecutionTestResult
380:                                    .setAttachmentMap(oldAttachMap);
381:                        }
382:                        ActionDetailsView.this .dispose();
383:                    }
384:                });
385:
386:                initActionResultsData(observedTest, executionTestResult,
387:                        execution.getName(), executionResult.getName());
388:
389:                attachmentPanel = new AttachmentView(DataModel.getApplet(),
390:                        EXECUTION_RESULT_TEST, EXECUTION_RESULT_TEST,
391:                        executionTestResult, SMALL_SIZE_FOR_ATTACH, execution,
392:                        executionResult, observedTest);
393:                attachmentPanel.setBorder(BorderFactory.createTitledBorder(
394:                        BorderFactory.createLineBorder(Color.BLACK), Language
395:                                .getInstance().getText("Attachements")));
396:
397:                JPanel downPart = new JPanel(new FlowLayout());
398:                downPart.setLayout(new BoxLayout(downPart, BoxLayout.X_AXIS));
399:                downPart.add(awaitedResultScrollPane);
400:                downPart.add(effectiveResultScrollPane);
401:
402:                JPanel actionsDetailsPanel = new JPanel(new BorderLayout());
403:                actionsDetailsPanel.add(descriptionScrollPane,
404:                        BorderLayout.NORTH);
405:                actionsDetailsPanel.add(downPart, BorderLayout.SOUTH);
406:
407:                JPanel upPart = new JPanel(new BorderLayout());
408:                upPart.add(BorderLayout.NORTH, testName);
409:
410:                JPanel allView = new JPanel(new BorderLayout());
411:
412:                allView.add(upPart, BorderLayout.NORTH);
413:                allView.add(actionsResultTableScrollPane, BorderLayout.CENTER);
414:
415:                JPanel buttonPanel = new JPanel(new FlowLayout(
416:                        FlowLayout.CENTER));
417:                buttonPanel.add(quitButton);
418:
419:                JPanel panel = new JPanel();
420:                panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
421:
422:                panel.add(allView);
423:                panel.add(actionsDetailsPanel);
424:                panel.add(attachmentPanel);
425:                panel.add(buttonPanel);
426:
427:                Container contentPaneFrame = this .getContentPane();
428:                contentPaneFrame.add(panel);
429:                // Affichage
430:                this .setLocation(200, 50);
431:                this .setTitle(Language.getInstance().getText(
432:                        "Détails_d'exécutions"));
433:                this .pack();
434:                this .setVisible(true);
435:            } // Fin du constructeur ActionDeatilsView
436:
437:            /******************************************************************************/
438:            /** 							METHODES PUBLIQUES							***/
439:            /******************************************************************************/
440:
441:            /**
442:             * Méthode d'initialisation de la table des résultats d'actions
443:             */
444:            public void initActionResultsData(ManualTest test,
445:                    ExecutionTestResult execTestResult, String executionName,
446:                    String executionResultName) {
447:                // Conservation des anciennes valeurs
448:                oldAttachMap = new HashMap();
449:                Set keysSetOld = execTestResult.getAttachmentMap().keySet();
450:                for (Iterator iter = keysSetOld.iterator(); iter.hasNext();) {
451:                    Object elem = iter.next();
452:                    oldAttachMap.put(elem, execTestResult.getAttachmentMap()
453:                            .get(elem));
454:                }
455:
456:                effectivExecutionTestResult = execTestResult;
457:                effectivExecutionName = executionName;
458:                effectivExecutionResultName = executionResultName;
459:                ArrayList actionsList = test.getActionList();
460:                for (int i = 0; i < actionsList.size(); i++) {
461:                    ArrayList data = new ArrayList();
462:                    data.add(((Action) actionsList.get(i)).getName());
463:                    data.add(DataModel.getObservedExecutionResult()
464:                            .getDescriptionResult((Action) actionsList.get(i)));
465:                    data.add(DataModel.getObservedExecutionResult()
466:                            .getAwaitedResult(((Action) actionsList.get(i))));
467:                    data.add(DataModel.getObservedExecutionResult()
468:                            .getEffectivResult((Action) actionsList.get(i)));
469:                    data.add(Tools.getActionStatusIcon(DataModel
470:                            .getObservedExecutionResult().getActionStatus(
471:                                    (Action) actionsList.get(i))));
472:                    actionsResultTableModel.addRow(data);
473:                }
474:                if (actionsResultTableModel.getRowCount() > 0) {
475:                    actionsResultTable.getSelectionModel()
476:                            .setSelectionInterval(0, 0);
477:                }
478:            } // Fin de la méthode initActionResultsData/0
479:        } // Fin de la classe ActionDetailsView
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.