01: /*
02: * SalomeTMF is a Test Management Framework
03: * Copyright (C) 2005 France Telecom R&D
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * @author Mikael MARCHE, Fayçal SOUGRATI, Vincent PAUTRET
20: *
21: * Contact: mikael.marche@rd.francetelecom.com
22: */
23:
24: package org.objectweb.salome_tmf.ihm.models;
25:
26: import java.awt.event.MouseAdapter;
27: import java.awt.event.MouseEvent;
28: import java.util.HashMap;
29:
30: import org.objectweb.salome_tmf.api.Api;
31: import org.objectweb.salome_tmf.api.ApiConstants;
32: import org.objectweb.salome_tmf.api.Util;
33: import org.objectweb.salome_tmf.data.AutomaticTest;
34: import org.objectweb.salome_tmf.data.DataConstants;
35: import org.objectweb.salome_tmf.ihm.main.AttachmentViewWindow;
36: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
37: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
38: import org.objectweb.salome_tmf.ihm.tools.Tools;
39:
40: /**
41: * @author teaml039
42: */
43: public class AutomaticTestResultMouseListener extends MouseAdapter
44: implements DataConstants {
45:
46: /**
47: * Appel?e si on appuie sur un bouton de la souris
48: * @param e un ?v?nement venant de la souris
49: */
50: public void mousePressed(MouseEvent e) {
51: if (e.getClickCount() > 1) {
52: if (DataModel.getTestObservedInExecution() instanceof AutomaticTest) {
53: //HashMap oldAttachMap = (HashMap)DataModel.getCurrentExecutionTestResult().getAttachmentMapFromModel().clone();
54: HashMap oldAttachMap = DataModel
55: .getCurrentExecutionTestResult()
56: .getCopyOfAttachmentMapFromModel();
57: //AttachmentViewWindow attachWindow = new AttachmentViewWindow(SalomeTMF.ptrSalomeTMF, EXECUTION_RESULT_TEST, DataModel.getCurrentExecutionTestResult(), DataModel.getObservedExecution(), DataModel.getObservedExecutionResult(), DataModel.getTestObservedInExecution());
58: AttachmentViewWindow attachWindow = new AttachmentViewWindow(
59: SalomeTMFContext.getInstance().getBaseIHM(),
60: EXECUTION_RESULT_TEST, DataModel
61: .getCurrentExecutionTestResult());
62: int transNumber = -1;
63: if (!attachWindow.cancelPerformed) {
64: try {
65: Util
66: .log("[AutomaticTestResultMouseListener] Api.INSERT_ATTACHMENT");
67: transNumber = Api.beginTransaction(100,
68: ApiConstants.INSERT_ATTACHMENT);
69:
70: DataModel.getCurrentExecutionTestResult()
71: .updateAttachement(oldAttachMap);
72:
73: Api.commitTrans(transNumber);
74: } catch (Exception exception) {
75: Api.forceRollBackTrans(transNumber);
76: DataModel.getCurrentExecutionTestResult()
77: .setAttachmentMapInModel(oldAttachMap);
78: Tools.ihmExceptionView(exception);
79: }
80: }
81: }
82: }
83: } // Fin de la m?thode mousePressed/1
84: } // Fin de la classe AutomaticTestResultMouseListener
|