0001: /*
0002: * SalomeTMF is a Test Management Framework
0003: * Copyright (C) 2005 France Telecom R&D
0004: *
0005: * This library is free software; you can redistribute it and/or
0006: * modify it under the terms of the GNU Lesser General Public
0007: * License as published by the Free Software Foundation; either
0008: * version 2 of the License, or (at your option) any later version.
0009: *
0010: * This library is distributed in the hope that it will be useful,
0011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013: * Lesser General Public License for more details.
0014: *
0015: * You should have received a copy of the GNU Lesser General Public
0016: * License along with this library; if not, write to the Free Software
0017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018: *
0019: * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
0020: *
0021: * Contact: mikael.marche@rd.francetelecom.com
0022: */
0023:
0024: package org.objectweb.salome_tmf.ihm.datawrapper;
0025:
0026: import java.util.ArrayList;
0027: import java.util.Collection;
0028: import java.util.HashSet;
0029: import java.util.Hashtable;
0030: import java.util.Iterator;
0031: import java.util.Vector;
0032:
0033: import javax.swing.JApplet;
0034: import javax.swing.JOptionPane;
0035: import javax.swing.table.TableModel;
0036: import javax.swing.tree.DefaultMutableTreeNode;
0037:
0038: import org.objectweb.salome_tmf.api.Api;
0039: import org.objectweb.salome_tmf.api.ApiConstants;
0040: import org.objectweb.salome_tmf.data.Action;
0041: import org.objectweb.salome_tmf.data.Attachment;
0042: import org.objectweb.salome_tmf.data.AutomaticTest;
0043: import org.objectweb.salome_tmf.data.Campaign;
0044: import org.objectweb.salome_tmf.data.CampaignData;
0045: import org.objectweb.salome_tmf.data.ConnectionData;
0046: import org.objectweb.salome_tmf.data.DataConstants;
0047: import org.objectweb.salome_tmf.data.DataModelWrapper;
0048: import org.objectweb.salome_tmf.data.DataSet;
0049: import org.objectweb.salome_tmf.data.Element;
0050: import org.objectweb.salome_tmf.data.Environment;
0051: import org.objectweb.salome_tmf.data.Execution;
0052: import org.objectweb.salome_tmf.data.ExecutionResult;
0053: import org.objectweb.salome_tmf.data.ExecutionTestResult;
0054: import org.objectweb.salome_tmf.data.Family;
0055: import org.objectweb.salome_tmf.data.FileAttachment;
0056: import org.objectweb.salome_tmf.data.ManualTest;
0057: import org.objectweb.salome_tmf.data.Parameter;
0058: import org.objectweb.salome_tmf.data.Project;
0059: import org.objectweb.salome_tmf.data.ProjectData;
0060: import org.objectweb.salome_tmf.data.Test;
0061: import org.objectweb.salome_tmf.data.TestList;
0062: import org.objectweb.salome_tmf.data.TestPlanData;
0063: import org.objectweb.salome_tmf.data.User;
0064: import org.objectweb.salome_tmf.ihm.AskName;
0065: import org.objectweb.salome_tmf.ihm.AskNameAndDescription;
0066: import org.objectweb.salome_tmf.ihm.AskNewCampagne;
0067: import org.objectweb.salome_tmf.ihm.AskNewTest;
0068: import org.objectweb.salome_tmf.ihm.AskNewTestList;
0069: import org.objectweb.salome_tmf.ihm.AutomaticTestScriptView;
0070: import org.objectweb.salome_tmf.ihm.ExecutionView;
0071: import org.objectweb.salome_tmf.ihm.FillCampagne;
0072: import org.objectweb.salome_tmf.ihm.SalomeTMF;
0073: import org.objectweb.salome_tmf.ihm.languages.Language;
0074: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
0075: import org.objectweb.salome_tmf.ihm.models.ExecutionTableModel;
0076: import org.objectweb.salome_tmf.ihm.models.MyTableModel;
0077: import org.objectweb.salome_tmf.ihm.tools.Tools;
0078:
0079: /**
0080: * Classe regroupant l'ensemble des données sur les tests et les campagnes
0081: * @author teaml039
0082: * @version 0.1
0083: */
0084: public class DataModel implements ApiConstants, DataConstants,
0085: DataModelWrapper {
0086:
0087: private static JApplet applet;
0088:
0089: /* Les Models de tables de données */
0090: /**
0091: * Modèle de données des tables contenant l'ensemble de tous les paramètres
0092: */
0093: static private MyTableModel parameterTableModel;
0094: static private MyTableModel dataSetTableModel;
0095: static private MyTableModel environmentTableModel;
0096:
0097: /**
0098: * Modèle de données des tables contenant les paramètres d'un test
0099: */
0100: static private MyTableModel testParameterTableModel;
0101:
0102: /**
0103: * Modèles de données pour les paramètres d'un environnement
0104: */
0105: static private MyTableModel environmentParameterTableModel;
0106:
0107: /**
0108: * Modèle de données des tables contenant les actions d'un test
0109: */
0110: static private MyTableModel actionTableModel;
0111:
0112: /**
0113: * Modèle de données des tables contenant les exécutions d'une campagne
0114: */
0115: static private ExecutionTableModel executionTableModel;
0116:
0117: /**
0118: * Modèle de données des tables contenant les résultats des exécutions dans
0119: * la vue des exécutions
0120: */
0121: static private MyTableModel executionResultTableModel;
0122:
0123: /**
0124: * Modèle de données des tables contenant les attachements
0125: */
0126: static private MyTableModel attachmentTableModel;
0127:
0128: /* Les données courantes de l'IHM */
0129: static private Test currentTest;
0130: static private TestList currentTestList;
0131: static private Campaign currentCampaign;
0132: static private Family currentFamily;
0133:
0134: static private Environment currentEnvironment;
0135: static private Action currentAction;
0136: static Test testObservedInExecution;
0137: static Execution observedExecution;
0138: static ExecutionResult obervedExecutionResult;
0139: static ArrayList selectedExecution = new ArrayList();
0140: static private ExecutionTestResult currentExecutionTestResult;
0141:
0142: static private boolean badDirectoryView;
0143:
0144: static private String caretDescriptionValue;
0145: static private boolean campaignChange;
0146: static private boolean testChange;
0147: static private boolean testListChange;
0148: static private boolean familyChange;
0149:
0150: static private String oldCaretDescription;
0151: static private boolean beginDescriptionModification;
0152: static private HashSet testModifications;
0153: static private HashSet campaignModifications;
0154: static private HashSet dataModifications;
0155:
0156: Hashtable dynamicNodeMap = new Hashtable();
0157: Hashtable campaignNodeMap = new Hashtable();
0158:
0159: //static ProjectData pProjectData;
0160: static DataModel pDataModel = null;
0161:
0162: /**************************************************************************/
0163: /** METHODES PUBLIQUES ***/
0164: /**************************************************************************/
0165: /**
0166: * @return la campagne en cours de traitement
0167: */
0168: public static Campaign getCurrentCampaign() {
0169: return currentCampaign;
0170: } // Fin de la méthode getCurrentCampaign/0
0171:
0172: /**
0173: * @return le test en cours de traitement
0174: */
0175: public static Test getCurrentTest() {
0176: return currentTest;
0177: } // Fin de la méthode getCurrentTest/0
0178:
0179: /**
0180: * @return la suite de tests en cours de traitement
0181: */
0182: public static TestList getCurrentTestList() {
0183: return currentTestList;
0184: } // Fin de la méthode getCurrentTestList/0
0185:
0186: /**
0187: * @return la suite de tests en cours de traitement
0188: */
0189: public static Family getCurrentFamily() {
0190: return currentFamily;
0191: } // Fin de la méthode getCurrentFamily/0
0192:
0193: /**
0194: * @param campagne courante
0195: */
0196: public static void setCurrentCampaign(Campaign campaign) {
0197: currentCampaign = campaign;
0198: } // Fin de la méthode setCurrentcampaign/1
0199:
0200: /**
0201: * @param testList courantes
0202: */
0203: public static void setCurrentTestList(TestList testList) {
0204: currentTestList = testList;
0205: } // Fin de la méthode setCurrentTestList/1
0206:
0207: /**
0208: * @param test courant
0209: */
0210: public static void setCurrentTest(Test test) {
0211: currentTest = test;
0212: } // Fin de la méthode setCurrentTest/1
0213:
0214: /**
0215: * @return
0216: */
0217: public static Environment getCurrentEnvironment() {
0218: return currentEnvironment;
0219: }
0220:
0221: /**
0222: * @param environment
0223: */
0224: public static void setCurrentEnvironment(Environment environment) {
0225: currentEnvironment = environment;
0226: }
0227:
0228: /**
0229: * @return
0230: */
0231: public static Action getCurrentAction() {
0232: return currentAction;
0233: }
0234:
0235: /**
0236: * @param action
0237: */
0238: public static void setCurrentAction(Action action) {
0239: currentAction = action;
0240: }
0241:
0242: /**
0243: * @param Famille courante
0244: */
0245: public static void setCurrentFamily(Family family) {
0246: currentFamily = family;
0247: } // Fin de la méthode setCurrentFamily/1
0248:
0249: /**
0250: * @return
0251: */
0252: public static Test getTestObservedInExecution() {
0253: return testObservedInExecution;
0254: }
0255:
0256: /**
0257: * @param test
0258: */
0259: public static void setTestObservedInExecution(Test test) {
0260: testObservedInExecution = test;
0261: }
0262:
0263: /**
0264: * @return
0265: */
0266: public static ExecutionResult getObservedExecutionResult() {
0267: return obervedExecutionResult;
0268: }
0269:
0270: /**
0271: * @return
0272: */
0273: public static Execution getObservedExecution() {
0274: return observedExecution;
0275: }
0276:
0277: /**
0278: * @param result
0279: */
0280: public static void setObervedExecutionResult(ExecutionResult result) {
0281: obervedExecutionResult = result;
0282: }
0283:
0284: /**
0285: * @param execution
0286: */
0287: public static void setObservedExecution(Execution execution) {
0288: observedExecution = execution;
0289: }
0290:
0291: public static void addSelectedExecution(Execution exec) {
0292: selectedExecution.add(exec);
0293: }
0294:
0295: public static void removeSelectedExecution(Execution exec) {
0296: selectedExecution.remove(exec);
0297: }
0298:
0299: /**
0300: * @return
0301: */
0302: public static ArrayList getSelectedExecution() {
0303: return selectedExecution;
0304: }
0305:
0306: /**
0307: * @param list
0308: */
0309: public static void setSelectedExecution(ArrayList list) {
0310: selectedExecution = list;
0311: }
0312:
0313: /**
0314: * @return
0315: */
0316: public static ExecutionTestResult getCurrentExecutionTestResult() {
0317: return currentExecutionTestResult;
0318: }
0319:
0320: /**
0321: * @param result
0322: */
0323: public static void setCurrentExecutionTestResult(
0324: ExecutionTestResult result) {
0325: currentExecutionTestResult = result;
0326: }
0327:
0328: /**
0329: * @return le modèle de la table contenant tous les paramètres
0330: */
0331: public static MyTableModel getParameterTableModel() {
0332: return parameterTableModel;
0333: }
0334:
0335: /**
0336: * @param model le modèle de la
0337: */
0338: public static void setParameterTableModel(MyTableModel model) {
0339: parameterTableModel = model;
0340: }
0341:
0342: /**
0343: * @return
0344: */
0345: public static MyTableModel getDataSetTableModel() {
0346: return dataSetTableModel;
0347: }
0348:
0349: /**
0350: * @return
0351: */
0352: public static MyTableModel getEnvironmentTableModel() {
0353: return environmentTableModel;
0354: }
0355:
0356: /**
0357: * @param model
0358: */
0359: public static void setDataSetTableModel(MyTableModel model) {
0360: dataSetTableModel = model;
0361: }
0362:
0363: /**
0364: * @param model
0365: */
0366: public static void setEnvironmentTableModel(MyTableModel model) {
0367: environmentTableModel = model;
0368: }
0369:
0370: /**
0371: * @return
0372: */
0373: public static MyTableModel getTestParameterTableModel() {
0374: return testParameterTableModel;
0375: }
0376:
0377: /**
0378: * @param model
0379: */
0380: public static void setTestParameterTableModel(MyTableModel model) {
0381: testParameterTableModel = model;
0382: }
0383:
0384: /**
0385: * @return
0386: */
0387: public static MyTableModel getEnvironmentParameterTableModel() {
0388: return environmentParameterTableModel;
0389: }
0390:
0391: /**
0392: * @param model
0393: */
0394: public static void setEnvironmentParameterTableModel(
0395: MyTableModel model) {
0396: environmentParameterTableModel = model;
0397: }
0398:
0399: /**
0400: * @return
0401: */
0402: public static MyTableModel getActionTableModel() {
0403: return actionTableModel;
0404: }
0405:
0406: /**
0407: * @param model
0408: */
0409: public static void setActionTableModel(MyTableModel model) {
0410: actionTableModel = model;
0411: }
0412:
0413: /**
0414: * @return
0415: */
0416: public static ExecutionTableModel getExecutionTableModel() {
0417: return executionTableModel;
0418: }
0419:
0420: /**
0421: * @param model
0422: */
0423: public static void setExecutionTableModel(ExecutionTableModel model) {
0424: executionTableModel = model;
0425: }
0426:
0427: /**
0428: * @return
0429: */
0430: public static MyTableModel getExecutionResultTableModel() {
0431: return executionResultTableModel;
0432: }
0433:
0434: /**
0435: * @param model
0436: */
0437: public static void setExecutionResultTableModel(MyTableModel model) {
0438: executionResultTableModel = model;
0439: }
0440:
0441: /**
0442: * @return
0443: */
0444: public static MyTableModel getAttachmentTableModel() {
0445: return attachmentTableModel;
0446: }
0447:
0448: /**
0449: * @param model
0450: */
0451: public static void setAttachmentTableModel(MyTableModel model) {
0452: attachmentTableModel = model;
0453: }
0454:
0455: /**
0456: * @return
0457: */
0458: public static JApplet getApplet() {
0459: return applet;
0460: }
0461:
0462: /**
0463: * @param applet
0464: */
0465: public static void setApplet(JApplet pApplet) {
0466: applet = pApplet;
0467: }
0468:
0469: /**
0470: * @return
0471: */
0472: public static boolean isBadDirectoryView() {
0473: return badDirectoryView;
0474: }
0475:
0476: /**
0477: * @param b
0478: */
0479: public static void setBadDirectoryView(boolean b) {
0480: badDirectoryView = b;
0481: }
0482:
0483: /**
0484: * @return
0485: */
0486: public static String getCaretDescriptionValue() {
0487: return caretDescriptionValue;
0488: }
0489:
0490: /**
0491: * @param string
0492: */
0493: public static void setCaretDescriptionValue(String string) {
0494: caretDescriptionValue = string;
0495: }
0496:
0497: /**
0498: * @return
0499: */
0500: public static boolean isCampaignChange() {
0501: return campaignChange;
0502: }
0503:
0504: /**
0505: * @param b
0506: */
0507: public static void setCampaignChange(boolean b) {
0508: campaignChange = b;
0509: }
0510:
0511: /**
0512: * @return
0513: */
0514: public static boolean isTestChange() {
0515: return testChange;
0516: }
0517:
0518: /**
0519: * @param b
0520: */
0521: public static void setTestChange(boolean b) {
0522: testChange = b;
0523: }
0524:
0525: /**
0526: * @return
0527: */
0528: public static boolean isTestListChange() {
0529: return testListChange;
0530: }
0531:
0532: /**
0533: * @param b
0534: */
0535: public static void setTestListChange(boolean b) {
0536: testListChange = b;
0537: }
0538:
0539: /**
0540: * @return
0541: */
0542: public static String getOldCaretDescription() {
0543: return oldCaretDescription;
0544: }
0545:
0546: /**
0547: * @param string
0548: */
0549: public static void setOldCaretDescription(String string) {
0550: oldCaretDescription = string;
0551: }
0552:
0553: /**
0554: * @return
0555: */
0556: public static boolean isBeginDescriptionModification() {
0557: return beginDescriptionModification;
0558: }
0559:
0560: /**
0561: * @param b
0562: */
0563: public static void setBeginDescriptionModification(boolean b) {
0564: beginDescriptionModification = b;
0565: }
0566:
0567: /**
0568: * @return
0569: */
0570: public static boolean isFamilyChange() {
0571: return familyChange;
0572: }
0573:
0574: /**
0575: * @param b
0576: */
0577: public static void setFamilyChange(boolean b) {
0578: familyChange = b;
0579: }
0580:
0581: public static void addTestModification(Object obj) {
0582: testModifications.add(obj);
0583: }
0584:
0585: public static void removeTestModification(Object obj) {
0586: testModifications.remove(obj);
0587: }
0588:
0589: public static HashSet getTestModification() {
0590: return testModifications;
0591: }
0592:
0593: public static boolean containsTestModification(Object obj) {
0594: return testModifications.contains(obj);
0595: }
0596:
0597: public static boolean containsTestModification(int i) {
0598: for (Iterator iter = testModifications.iterator(); iter
0599: .hasNext();) {
0600: Integer elem = (Integer) iter.next();
0601: if (elem.intValue() == i)
0602: return true;
0603: }
0604: return false;
0605: }
0606:
0607: public static void addCampaignModification(Object obj) {
0608: campaignModifications.add(obj);
0609: }
0610:
0611: public static void removeCampaignModification(Object obj) {
0612: campaignModifications.remove(obj);
0613: }
0614:
0615: public static HashSet getCampaignModification() {
0616: return campaignModifications;
0617: }
0618:
0619: public static boolean containsCampaignModification(Object obj) {
0620: return campaignModifications.contains(obj);
0621: }
0622:
0623: public static boolean containsCampaignModification(int i) {
0624: for (Iterator iter = campaignModifications.iterator(); iter
0625: .hasNext();) {
0626: Integer elem = (Integer) iter.next();
0627: if (elem.intValue() == i)
0628: return true;
0629: }
0630: return false;
0631: }
0632:
0633: public static void addDataModification(Object obj) {
0634: dataModifications.add(obj);
0635: }
0636:
0637: public static void removeDataModification(Object obj) {
0638: dataModifications.remove(obj);
0639: }
0640:
0641: public static HashSet getDataModification() {
0642: return dataModifications;
0643: }
0644:
0645: public static boolean containsDataModification(Object obj) {
0646: return dataModifications.contains(obj);
0647: }
0648:
0649: public static boolean containsDataModification(int i) {
0650: for (Iterator iter = dataModifications.iterator(); iter
0651: .hasNext();) {
0652: Integer elem = (Integer) iter.next();
0653: if (elem.intValue() == i)
0654: return true;
0655: }
0656: return false;
0657: }
0658:
0659: //**** DataModelWrapper Implementation *******//
0660: public static DataModel getInstance() {
0661: if (pDataModel == null) {
0662: pDataModel = new DataModel();
0663: }
0664: return pDataModel;
0665:
0666: }
0667:
0668: public void addParameterToModel(ArrayList data) {
0669: parameterTableModel.addRow(data);
0670: }
0671:
0672: public void clearParameterToModel() {
0673: parameterTableModel.clearTable();
0674: }
0675:
0676: public void addEnvToModel(ArrayList data) {
0677: environmentTableModel.addRow(data);
0678: }
0679:
0680: public void clearEnvModel() {
0681: environmentTableModel.clearTable();
0682: }
0683:
0684: public void addFamilyToModel(Family pFamily) {
0685: DefaultMutableTreeNode familyNode;
0686: familyNode = SalomeTMF.getTestDynamicTree().addObject(null,
0687: pFamily, true);
0688: dynamicNodeMap.put(pFamily, familyNode);
0689: }
0690:
0691: public void updateFamilyToModel(Family pFamily) {
0692: SalomeTMF.getTestDynamicTree().findRemoveFamilyNode(
0693: pFamily.getName(), true);
0694: dynamicNodeMap.remove(pFamily);
0695: addFamilyToModel(pFamily);
0696: }
0697:
0698: public void clearFamilyToModel(Family pFamily) {
0699: SalomeTMF.getTestDynamicTree().findRemoveFamilyNode(
0700: pFamily.getName(), false);
0701: }
0702:
0703: public void refreshFamilyToModel(Family pFamily) {
0704: if (pFamily.equals(currentFamily)) {
0705: initFamily(pFamily);
0706: }
0707: }
0708:
0709: public void addTestListToModel(Family pFamily, TestList pList) {
0710: DefaultMutableTreeNode testListNode;
0711: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) dynamicNodeMap
0712: .get(pFamily);
0713: testListNode = SalomeTMF.getTestDynamicTree().addObject(
0714: familyNode, pList, false);
0715: dynamicNodeMap.put(pList, testListNode);
0716: }
0717:
0718: public void updateTestListToModel(TestList pList) {
0719: SalomeTMF.getTestDynamicTree().findRemoveTestListNode(
0720: pList.getName(), pList.getFamily().getName(), true);
0721: dynamicNodeMap.remove(pList);
0722: addTestListToModel(pList.getFamily(), pList);
0723: }
0724:
0725: public void clearTestListToModel(TestList pList) {
0726: SalomeTMF.getTestDynamicTree().findRemoveTestListNode(
0727: pList.getName(), pList.getFamily().getName(), false);
0728:
0729: }
0730:
0731: public void refreshTestListToModel(TestList pList) {
0732: if (pList.equals(currentTestList)) {
0733: initTestList(pList);
0734: }
0735: }
0736:
0737: public void addTestToModel(TestList pList, Test pTest) {
0738: DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) dynamicNodeMap
0739: .get(pList);
0740: DefaultMutableTreeNode testNode = SalomeTMF
0741: .getTestDynamicTree().addObject(testListNode, pTest,
0742: false);
0743: dynamicNodeMap.put(pTest, testNode);
0744: }
0745:
0746: public void updateTestToModel(TestList pList, Test pTest) {
0747: SalomeTMF.getTestDynamicTree().findRemoveTestNode(
0748: pTest.getName(), pList.getName(),
0749: pList.getFamily().getName(), true);
0750: dynamicNodeMap.remove(pTest);
0751: addTestToModel(pList, pTest);
0752: }
0753:
0754: public void refreshTestToModel(Test pTest) {
0755: if (pTest.equals(currentTest)) {
0756: //le test traité est affiché à l'écran, il faut modifier l'affichage avec les nouvelles valeurs
0757: initTest(pTest);
0758: if (pTest instanceof ManualTest) {
0759: initActionTable((ManualTest) pTest);
0760: }
0761: }
0762: }
0763:
0764: public void clearTestToModel(Test pTest) {
0765: SalomeTMF.getTestDynamicTree().findRemoveTestNode(
0766: pTest.getName(), pTest.getTestList().getName(),
0767: pTest.getTestList().getFamily().getName(), true);
0768: }
0769:
0770: public void addCampaignToModel(Campaign campaign) {
0771: DefaultMutableTreeNode campaignNode;
0772: campaignNode = SalomeTMF.getCampaignDynamicTree().addObject(
0773: null, campaign, true);
0774: campaignNodeMap.put(campaign, campaignNode);
0775: }
0776:
0777: public void upadateCampaignToModel(Campaign campaign) {
0778: DefaultMutableTreeNode campaignNode = SalomeTMF
0779: .getCampaignDynamicTree().findRemoveCampaignNode(
0780: campaign.getName(), false);
0781: campaignNodeMap.remove(campaign);
0782: campaignNodeMap.put(campaign, campaignNode);
0783: }
0784:
0785: public void refreshCampaignToModel(Campaign campaign) {
0786: if (campaign.equals(getCurrentCampaign())) {
0787: initCampaign(campaign);
0788: }
0789: }
0790:
0791: public void addCampaignFamilyToModel(Campaign campaign,
0792: Family pFamily) {
0793: DefaultMutableTreeNode campaignNode = (DefaultMutableTreeNode) campaignNodeMap
0794: .get(campaign);
0795: DefaultMutableTreeNode familyNode = SalomeTMF
0796: .getCampaignDynamicTree().addObject(campaignNode,
0797: pFamily, false);
0798: campaignNodeMap.put(pFamily, familyNode);
0799: }
0800:
0801: public void upadateCampaignFamilyToModel(Campaign campaign,
0802: Family pFamily) {
0803: DefaultMutableTreeNode familyNode = SalomeTMF
0804: .getCampaignDynamicTree()
0805: .findRemoveFamilyNodeInCampagneTree(pFamily.getName(),
0806: campaign.getName(), false);
0807: campaignNodeMap.remove(pFamily);
0808: campaignNodeMap.put(pFamily, familyNode);
0809: }
0810:
0811: public void addCampaignTestListToModel(Family pFamily,
0812: TestList pList) {
0813: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) campaignNodeMap
0814: .get(pFamily);
0815: DefaultMutableTreeNode testListNode = SalomeTMF
0816: .getCampaignDynamicTree().addObject(familyNode, pList,
0817: false);
0818: campaignNodeMap.put(pList, testListNode);
0819: }
0820:
0821: public void upadateCampaignTestListToModel(Campaign campaign,
0822: Family pFamily, TestList pList) {
0823: DefaultMutableTreeNode testListNode = SalomeTMF
0824: .getCampaignDynamicTree()
0825: .findRemoveTestListNodeInCampagneTree(pList.getName(),
0826: pFamily.getName(), campaign.getName(), false);
0827: campaignNodeMap.remove(pList);
0828: campaignNodeMap.put(pList, testListNode);
0829: }
0830:
0831: public void addCampaignTestToModel(TestList pList, Test pTest) {
0832: DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) campaignNodeMap
0833: .get(pList);
0834: SalomeTMF.getCampaignDynamicTree().addObject(testListNode,
0835: pTest, false);
0836: campaignNodeMap.put(pTest, testListNode);
0837: }
0838:
0839: public void upadateCampaignTestToModel(TestList pList, Test pTest) {
0840:
0841: }
0842:
0843: ///////////////////////////////////////////////////////////////////////////
0844:
0845: public static void clearData() {
0846: dataClear();
0847: tableClear();
0848: }
0849:
0850: public static void initData() {
0851: dataClear();
0852: initTableModel();
0853: }
0854:
0855: private static void dataClear() {
0856: currentTest = null;
0857: currentTestList = null;
0858: currentCampaign = null;
0859: currentFamily = null;
0860: currentEnvironment = null;
0861: currentAction = null;
0862: currentExecutionTestResult = null;
0863:
0864: campaignChange = false;
0865: testChange = false;
0866: testListChange = false;
0867: beginDescriptionModification = false;
0868: badDirectoryView = true;
0869:
0870: selectedExecution.clear();
0871: testModifications = new HashSet();
0872: campaignModifications = new HashSet();
0873: dataModifications = new HashSet();
0874: }
0875:
0876: private static void tableClear() {
0877: parameterTableModel.clearTable();
0878: dataSetTableModel.clearTable();
0879: environmentTableModel.clearTable();
0880: testParameterTableModel.clearTable();
0881: environmentParameterTableModel.clearTable();
0882: actionTableModel.clearTable();
0883: executionTableModel.clearTable();
0884: executionResultTableModel.clearTable();
0885: attachmentTableModel.clearTable();
0886: }
0887:
0888: public static void initTableModel() {
0889: if (parameterTableModel == null) {
0890: parameterTableModel = new MyTableModel();
0891: parameterTableModel.addColumnNameAndColumn(Language
0892: .getInstance().getText("Nom"));
0893: parameterTableModel.addColumnNameAndColumn(Language
0894: .getInstance().getText("Description"));
0895: }
0896: // parameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0897: // parameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0898:
0899: if (testParameterTableModel == null) {
0900: testParameterTableModel = new MyTableModel();
0901: testParameterTableModel.addColumnNameAndColumn(Language
0902: .getInstance().getText("Nom"));
0903: testParameterTableModel.addColumnNameAndColumn(Language
0904: .getInstance().getText("Description"));
0905: }
0906: // testParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0907: // testParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0908:
0909: if (environmentParameterTableModel == null) {
0910: environmentParameterTableModel = new MyTableModel();
0911: environmentParameterTableModel
0912: .addColumnNameAndColumn(Language.getInstance()
0913: .getText("Nom"));
0914: environmentParameterTableModel
0915: .addColumnNameAndColumn(Language.getInstance()
0916: .getText("Valeur"));
0917: environmentParameterTableModel
0918: .addColumnNameAndColumn(Language.getInstance()
0919: .getText("Description"));
0920: }
0921: // environmentParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0922: // environmentParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Valeur"));
0923: // environmentParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0924:
0925: if (actionTableModel == null) {
0926: actionTableModel = new MyTableModel();
0927: actionTableModel.addColumnNameAndColumn(Language
0928: .getInstance().getText("Nom"));
0929: actionTableModel.addColumnNameAndColumn(Language
0930: .getInstance().getText("Description"));
0931: actionTableModel.addColumnNameAndColumn(Language
0932: .getInstance().getText("Résultat_attendu"));
0933: actionTableModel.addColumnNameAndColumn(Language
0934: .getInstance().getText("Attachements"));
0935: }
0936: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0937: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0938: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Résultat_attendu"));
0939: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Attachements"));
0940:
0941: if (executionTableModel == null) {
0942: executionTableModel = new ExecutionTableModel();
0943: executionTableModel.addColumnNameAndColumn("");
0944: executionTableModel.addColumnNameAndColumn(Language
0945: .getInstance().getText("Nom"));
0946: executionTableModel.addColumnNameAndColumn(Language
0947: .getInstance().getText("Environnement"));
0948: executionTableModel.addColumnNameAndColumn(Language
0949: .getInstance().getText("Jeu_de_données"));
0950: executionTableModel.addColumnNameAndColumn(Language
0951: .getInstance().getText("Date_de_création"));
0952: executionTableModel.addColumnNameAndColumn(Language
0953: .getInstance().getText("Attachements"));
0954: executionTableModel.addColumnNameAndColumn(Language
0955: .getInstance().getText("Dernière_Exécution"));
0956: }
0957: // executionTableModel.addColumnNameAndColumn("");
0958: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0959: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Environnement"));
0960: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Jeu_de_données"));
0961: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Date_de_création"));
0962: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Attachements"));
0963: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Dernière_Exécution"));
0964:
0965: if (executionResultTableModel == null) {
0966: executionResultTableModel = new MyTableModel();
0967: executionResultTableModel.addColumnNameAndColumn(Language
0968: .getInstance().getText("Nom"));
0969: executionResultTableModel.addColumnNameAndColumn(Language
0970: .getInstance().getText("Date"));
0971: executionResultTableModel.addColumnNameAndColumn(Language
0972: .getInstance().getText("Testeur"));
0973: executionResultTableModel.addColumnNameAndColumn(Language
0974: .getInstance().getText("Résultat"));
0975: executionResultTableModel.addColumnNameAndColumn(Language
0976: .getInstance().getText("Statistiques"));
0977: }
0978: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0979: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Date"));
0980: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Testeur"));
0981: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Résultat"));
0982: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Statistiques"));
0983:
0984: if (attachmentTableModel == null) {
0985: attachmentTableModel = new MyTableModel();
0986: attachmentTableModel.addColumnNameAndColumn(Language
0987: .getInstance().getText("Nom"));
0988: attachmentTableModel.addColumnNameAndColumn(Language
0989: .getInstance().getText("Taille"));
0990: attachmentTableModel.addColumnNameAndColumn(Language
0991: .getInstance().getText("Date_de_création"));
0992: }
0993: // attachmentTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0994: // attachmentTableModel.addColumnNameAndColumn(Language.getInstance().getText("Taille"));
0995: // attachmentTableModel.addColumnNameAndColumn(Language.getInstance().getText("Date_de_création"));
0996: }
0997:
0998: /********************************************* Init Data ************************************************************/
0999:
1000: //public static void initDataTests(String p, String userLogin, JApplet applet) {
1001: public static void loadFromBase(String p, String userLogin,
1002: JApplet applet) {
1003: setApplet(applet);
1004: //initData();
1005: ProjectData.setDataModelWrapper(getInstance());
1006: try {
1007: if (ProjectData.dataConnected()) {
1008: clearData();
1009: SalomeTMF.getTestDynamicTree().clear();
1010: SalomeTMF.getCampaignDynamicTree().clear();
1011: ProjectData.loadData(p, userLogin, applet
1012: .getDocumentBase());
1013: }
1014: } catch (Exception e) {
1015: Tools.ihmExceptionView(e.toString());
1016: JOptionPane
1017: .showMessageDialog(
1018: applet,
1019: Language
1020: .getInstance()
1021: .getText(
1022: "Impossible_de_se_connecter_à_la_base_:_on_travaille_en_local_!"),
1023: Language.getInstance().getText("Erreur_!"),
1024: JOptionPane.ERROR_MESSAGE);
1025: }
1026: }
1027:
1028: //public static void refreshFromBase() {
1029: public static void reloadFromBase() {
1030: if (ConnectionData.isConnected()) {
1031: int transNumber = -1;
1032: ;
1033: try {
1034: // DATA and IHM
1035: clearData();
1036:
1037: SalomeTMF.clearTrees();
1038: transNumber = Api.beginTransaction(Api.LOADING);
1039: ProjectData.reloadData(false);
1040:
1041: SalomeTMF.getTestMultiUserChangeListenerPanel().reset();
1042: Api.commitTrans(transNumber);
1043: } catch (Exception exception) {
1044: Api.forceRollBackTrans(transNumber);
1045: Tools.ihmExceptionView(exception.toString());
1046: }
1047: } else {
1048: JOptionPane
1049: .showMessageDialog(
1050: applet,
1051: Language
1052: .getInstance()
1053: .getText(
1054: "Impossible_!\n_Vous_n'êtes_pas_connecté_à_la_base."),
1055: Language.getInstance().getText("Erreur_!"),
1056: JOptionPane.ERROR_MESSAGE);
1057: }
1058:
1059: }
1060:
1061: /**
1062: * Méthode qui réinitialise la table des actions pour les tests manuels
1063: */
1064: public static void initActionTable(ManualTest test) {
1065: if (test != null) {
1066: ArrayList actionList = test.getActionList();
1067: if ((actionList != null) && (actionList.size() > 0)) {
1068: actionTableModel.clearTable();
1069: for (int i = 0; i < actionList.size(); i++) {
1070: ArrayList actionParameters = new ArrayList();
1071: actionParameters.add(((Action) actionList.get(i))
1072: .getName());
1073: actionParameters.add(((Action) actionList.get(i))
1074: .getDescription());
1075: actionParameters.add(((Action) actionList.get(i))
1076: .getAwaitedResult());
1077: actionParameters.add(((Action) actionList.get(i))
1078: .getAttachmentMap().keySet());
1079: actionTableModel.addRow(actionParameters);
1080: }
1081: } else {
1082: actionTableModel.clearTable();
1083: }
1084: }
1085: } // Fin de la méthode initActionTable/0
1086:
1087: /**
1088: * M?thode qui initialise les d?tails d'un test pass? en param?tre, ses attachements et ses
1089: * param?tres.
1090: * @param test un test
1091: */
1092: public static void initTest(Test test) {
1093: if (test != null && test instanceof ManualTest) {
1094: SalomeTMF.getManualTestDateLabel().setText(
1095: Language.getInstance().getText(
1096: "Date_de_création_:_")
1097: + test.getCreationDate().toString());
1098: SalomeTMF.getManualTestConceptorLabel().setText(
1099: Language.getInstance().getText("Concepteur_:_")
1100: + test.getConceptor());
1101: SalomeTMF.getManualTestNameLabel().setText(
1102: Language.getInstance().getText("Nom_du_test_:_")
1103: + test.getName());
1104: SalomeTMF.getManualDetailsDescription().setText(
1105: test.getDescription());
1106: } else if (test != null && test instanceof AutomaticTest) {
1107: SalomeTMF.getAutomaticTestDateLabel().setText(
1108: Language.getInstance().getText(
1109: "Date_de_création_:_")
1110: + test.getCreationDate().toString());
1111: SalomeTMF.getAutomaticTestConceptorLabel().setText(
1112: Language.getInstance().getText("Concepteur_:_")
1113: + test.getConceptor());
1114: SalomeTMF.getAutomaticTestNameLabel().setText(
1115: Language.getInstance().getText("Nom_du_test_:_")
1116: + test.getName());
1117: SalomeTMF.getAutomaticDetailsDescription().setText(
1118: test.getDescription());
1119: }
1120: testParameterTableModel.clearTable();
1121: for (int i = 0; i < test.getParameterList().size(); i++) {
1122: testParameterTableModel.addValueAt(((Parameter) test
1123: .getParameterList().get(i)).getName(), i, 0);
1124: testParameterTableModel.addValueAt(((Parameter) test
1125: .getParameterList().get(i)).getDescription(), i, 1);
1126: }
1127: initAttachmentTable(test.getAttachmentMap().values());
1128: } // Fin de la méthode initDetails/1
1129:
1130: /**
1131: * M?thode qui initialise les d?tails de la campagne pass?e en param?tre ainsi que ses ex?cutions
1132: * @param campagne une campagne
1133: */
1134: public static void initCampaign(Campaign campaign) {
1135: SalomeTMF.getCampaignConceptorLabel().setText(
1136: Language.getInstance().getText("Concepteur_:_")
1137: + campaign.getConceptor());
1138: SalomeTMF.getCampaignDateLabel().setText(
1139: Language.getInstance().getText("Date_de_création_:_")
1140: + campaign.getDate().toString());
1141: SalomeTMF.getCampagneDetailsDescription().setText(
1142: campaign.getDescription());
1143: SalomeTMF.getCampaignNameLabel().setText(
1144: Language.getInstance().getText("Nom_de_la_campagne_:_")
1145: + campaign.getName());
1146:
1147: dataSetTableModel.clearTable();
1148: for (int i = 0; i < campaign.getDataSetList().size(); i++) {
1149: dataSetTableModel.addValueAt(((DataSet) campaign
1150: .getDataSetList().get(i)).getName(), i, 0);
1151: dataSetTableModel.addValueAt(((DataSet) campaign
1152: .getDataSetList().get(i)).getDescription(), i, 1);
1153: }
1154: ArrayList executionList = campaign.getExecutionList();
1155: executionTableModel.clearTable();
1156: if ((executionList != null) && (executionList.size() > 0)) {
1157: for (int i = 0; i < executionList.size(); i++) {
1158: ArrayList executionParameters = new ArrayList();
1159: executionParameters.add(new Boolean(false));
1160: executionParameters.add(((Execution) executionList
1161: .get(i)).getName());
1162: executionParameters.add(((Execution) executionList
1163: .get(i)).getEnvironment());
1164: executionParameters.add(((Execution) executionList
1165: .get(i)).getDataSet());
1166: executionParameters.add(((Execution) executionList
1167: .get(i)).getCreationDate());
1168: executionParameters.add(((Execution) executionList
1169: .get(i)).getAttachmentMap().keySet());
1170: if (((Execution) executionList.get(i)).getLastDate() != null) {
1171: executionParameters.add(((Execution) executionList
1172: .get(i)).getLastDate().toString());
1173: } else {
1174: executionParameters.add("");
1175: }
1176:
1177: executionTableModel.addRow(executionParameters);
1178: ExecutionView.getTable().getColumnModel().getColumn(0)
1179: .setMaxWidth(18);
1180: }
1181: }
1182: executionResultTableModel.clearTable();
1183: initAttachmentTable(campaign.getAttachmentMap().values());
1184:
1185: } // Fin de la méthode initDetails/1
1186:
1187: /**
1188: * R?initialise la description des familles en fonction de la famille
1189: * pass?e en param?tre
1190: * @param family une famille
1191: */
1192: public static void initFamily(Family family) {
1193: SalomeTMF.getFamilyDescription().setText(
1194: family.getDescription());
1195: } // Fin de la m?thode initDescription/1
1196:
1197: /**
1198: * R?initialise la description des suites en fonction de la suite pass?e en
1199: * param?tre
1200: * @param list une suite de tests
1201: */
1202: public static void initTestList(TestList list) {
1203: SalomeTMF.getTestListDescription().setText(
1204: list.getDescription());
1205: initAttachmentTable(list.getAttachmentMap().values());
1206: } // Fin de la m?thode initTestList/1
1207:
1208: public static void initAttachmentTable(Collection col) {
1209: attachmentTableModel.clearTable();
1210: int rowIndex = 0;
1211: for (Iterator iter = col.iterator(); iter.hasNext();) {
1212: Attachment attach = (Attachment) iter.next();
1213: attachmentTableModel.addValueAt(attach.getName(), rowIndex,
1214: 0);
1215: if (attach instanceof FileAttachment) {
1216: attachmentTableModel.addValueAt(
1217: ((FileAttachment) attach).getSize().toString(),
1218: rowIndex, 1);
1219: attachmentTableModel.addValueAt(
1220: ((FileAttachment) attach).getDate().toString(),
1221: rowIndex, 2);
1222: } else {
1223: attachmentTableModel.addValueAt("", rowIndex, 1);
1224: attachmentTableModel.addValueAt("", rowIndex, 2);
1225: }
1226: rowIndex++;
1227: }
1228: }
1229:
1230: //********************************** Refresh ***********************************************************//
1231:
1232: //********************************** Delete in tree ****************************************************//
1233:
1234: /**
1235: * Méthode de suppression de tests, suites de tests, familles ou campagnes.
1236: * @return vrai si la suppression s'est correctement deroulee, faux sinon.
1237: */
1238: public static boolean deleteInTestTree() {
1239: DefaultMutableTreeNode selectedNode = SalomeTMF
1240: .getTestDynamicTree().getSelectedNode();
1241:
1242: boolean result = true;
1243:
1244: Object[] options = { Language.getInstance().getText("Oui"),
1245: Language.getInstance().getText("Non") };
1246: int choice = -1;
1247: int actionCase = -1;
1248: String message = "";
1249: ArrayList campaignList = new ArrayList();
1250:
1251: if ((selectedNode.getUserObject() instanceof Test)) {
1252: campaignList = CampaignData
1253: .getCampaignOfTest((Test) selectedNode
1254: .getUserObject());
1255: if (campaignList.size() > 0) {
1256: message = Language.getInstance().getText("Le_test_<_")
1257: + ((Test) selectedNode.getUserObject())
1258: .getName()
1259: + Language
1260: .getInstance()
1261: .getText(
1262: "_>_est_utilisé_dans_les_campagnes_:\n");
1263: for (int i = 0; i < campaignList.size(); i++) {
1264: message = message
1265: + "* "
1266: + ((Campaign) campaignList.get(i))
1267: .getName() + "\n";
1268: }
1269: message = message
1270: + Language
1271: .getInstance()
1272: .getText(
1273: "Le_test_sera_purgé_des_résultats_d'exécution_de_ces_campagnes_\n");
1274: }
1275:
1276: choice = JOptionPane
1277: .showOptionDialog(
1278: applet,
1279: message
1280: + Language
1281: .getInstance()
1282: .getText(
1283: "Etes_vous_sûr_de_vouloir_supprimer_le_test_<_")
1284: + ((Test) selectedNode
1285: .getUserObject()).getName()
1286: + " > ?", Language.getInstance()
1287: .getText("Attention_!"),
1288: JOptionPane.YES_NO_OPTION,
1289: JOptionPane.WARNING_MESSAGE, null, options,
1290: options[1]);
1291: actionCase = SalomeTMF.TEST;
1292: } else if (selectedNode.getUserObject() instanceof TestList) {
1293: campaignList = CampaignData
1294: .getCampaignOfTestList((TestList) selectedNode
1295: .getUserObject());
1296: if (campaignList.size() > 0) {
1297: message = Language.getInstance().getText(
1298: "La_suite_de_tests_<_")
1299: + ((TestList) selectedNode.getUserObject())
1300: .getName()
1301: + Language
1302: .getInstance()
1303: .getText(
1304: "_>_est_utilisée_dans_les_campagnes_:\n");
1305: for (int i = 0; i < campaignList.size(); i++) {
1306: message = message
1307: + "* "
1308: + ((Campaign) campaignList.get(i))
1309: .getName() + "\n";
1310: }
1311: message = message
1312: + Language
1313: .getInstance()
1314: .getText(
1315: "Les_tests_de_la_suite_seront_purgés_des_résultats_d'exécution_de_ces_campagnes_\n");
1316: }
1317: choice = JOptionPane
1318: .showOptionDialog(
1319: applet,
1320: message
1321: + Language
1322: .getInstance()
1323: .getText(
1324: "Etes_vous_sûr_de_vouloir_supprimer_la_suite_<_")
1325: + ((TestList) selectedNode
1326: .getUserObject()).getName()
1327: + " > ?", Language.getInstance()
1328: .getText("Attention_!"),
1329: JOptionPane.YES_NO_OPTION,
1330: JOptionPane.WARNING_MESSAGE, null, options,
1331: options[1]);
1332: actionCase = TESTLIST;
1333: } else if (selectedNode.getUserObject() instanceof Family) {
1334: campaignList = CampaignData
1335: .getCampaignOfFamily((Family) selectedNode
1336: .getUserObject());
1337: if (campaignList.size() > 0) {
1338: message = Language.getInstance().getText(
1339: "La_famille_<_")
1340: + ((Family) selectedNode.getUserObject())
1341: .getName()
1342: + Language
1343: .getInstance()
1344: .getText(
1345: "_>_est_utilisée_dans_les_campagnes_:\n");
1346: for (int i = 0; i < campaignList.size(); i++) {
1347: /*if (((Campaign)campaignList.get(i)).getTestListList().size() == 1) {
1348: toBeDelete = "* " + ((Campaign)campaignList.get(i)).getName() + "\n";
1349: }*/
1350: message = message
1351: + "* "
1352: + ((Campaign) campaignList.get(i))
1353: .getName() + "\n";
1354: }
1355: //message = message + "Parmi celles-ci seront supprim?es :\n" + toBeDelete + "car elles ne contiennent que ce test.\n\n";
1356: message = message
1357: + Language
1358: .getInstance()
1359: .getText(
1360: "Les_tests_de_la_famille_seront_purgés_des_résultats_d'exécution_de_ces_campagnes_\n");
1361: }
1362: choice = JOptionPane
1363: .showOptionDialog(
1364: applet,
1365: message
1366: + Language
1367: .getInstance()
1368: .getText(
1369: "Etes_vous_sûr_de_vouloir_supprimer_la_famille_<_")
1370: + ((Family) selectedNode
1371: .getUserObject()).getName()
1372: + " > ?", Language.getInstance()
1373: .getText("Attention_!"),
1374: JOptionPane.YES_NO_OPTION,
1375: JOptionPane.WARNING_MESSAGE, null, options,
1376: options[1]);
1377: actionCase = SalomeTMF.FAMILY;
1378: }
1379:
1380: if (choice == JOptionPane.YES_OPTION) {
1381: // LE CAS DES TESTS
1382: if (actionCase == SalomeTMF.TEST) {
1383:
1384: boolean testDeleted = false;
1385:
1386: try {
1387: //BDD & DATA
1388: TestPlanData
1389: .deleteTestInBDDandModel(((Test) selectedNode
1390: .getUserObject()));
1391: testDeleted = true;
1392:
1393: //IHM
1394: for (int j = 0; j < campaignList.size(); j++) {
1395: // Suppression en cascade dans l'arbre des campagnes
1396: DefaultMutableTreeNode testNodeInCampaignTree = SalomeTMF
1397: .getCampaignDynamicTree()
1398: .findRemoveTestNodeInCampagneTree(
1399: ((Test) selectedNode
1400: .getUserObject())
1401: .getName(),
1402: ((Test) selectedNode
1403: .getUserObject())
1404: .getTestList()
1405: .getName(),
1406: ((Test) selectedNode
1407: .getUserObject())
1408: .getTestList()
1409: .getFamily().getName(),
1410: ((Campaign) campaignList.get(j))
1411: .getName(), false);
1412: DefaultMutableTreeNode testListParent = (DefaultMutableTreeNode) testNodeInCampaignTree
1413: .getParent();
1414: SalomeTMF.getCampaignDynamicTree().removeNode(
1415: testNodeInCampaignTree);
1416: if (testListParent.getChildCount() == 0) {
1417: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListParent
1418: .getParent();
1419: SalomeTMF.getCampaignDynamicTree()
1420: .removeNode(testListParent);
1421: if (familyParent.getChildCount() == 0) {
1422: SalomeTMF.getCampaignDynamicTree()
1423: .removeNode(familyParent);
1424: }
1425: }
1426: // on nettoie la table des résultats des exécutions si la campagne
1427: //traitée est selectionnée dans l'arbre des campagnes
1428: if ((SalomeTMF.getCampaignDynamicTree()
1429: .getSelectedNode()) != null
1430: && (SalomeTMF.getCampaignDynamicTree()
1431: .getSelectedNode())
1432: .getUserObject() instanceof Campaign
1433: && ((Campaign) (SalomeTMF
1434: .getCampaignDynamicTree()
1435: .getSelectedNode())
1436: .getUserObject())
1437: .equals((campaignList.get(j)))) {
1438: executionResultTableModel.clearTable();
1439: //TestData.getExecutionTableModel().clearTable();
1440: }
1441:
1442: }
1443:
1444: } catch (Exception exception) {
1445: if (testDeleted) {
1446: // Erreur au niveau de L'IHM -> faire un reload
1447: reloadFromBase();
1448: result = true;
1449: } else {
1450: // Erreur au niveau BDD
1451: result = false;
1452: Tools.ihmExceptionView(exception.toString());
1453: }
1454:
1455: }
1456: //LE CAS DES FAMILLES
1457: } else if (actionCase == SalomeTMF.FAMILY) {
1458: boolean familyDeleted = false;
1459: try {
1460: // BDD & DATA
1461: TestPlanData
1462: .deleteFamilyInBDDandModel((Family) selectedNode
1463: .getUserObject());
1464: familyDeleted = true;
1465:
1466: // IHM
1467: for (int j = 0; j < campaignList.size(); j++) {
1468: // Nettoyage de l'arbre des campagnes
1469: DefaultMutableTreeNode familyNodeInCampaignTree = SalomeTMF
1470: .getCampaignDynamicTree()
1471: .findRemoveFamilyNodeInCampagneTree(
1472: ((Family) selectedNode
1473: .getUserObject())
1474: .getName(),
1475: ((Campaign) campaignList.get(j))
1476: .getName(), false);
1477: SalomeTMF.getCampaignDynamicTree().removeNode(
1478: familyNodeInCampaignTree);
1479: // on nettoie la table des résultats des exécutions si la campagne
1480: //traitée est sélectionnée dans l'abre des campagnes
1481: if ((SalomeTMF.getCampaignDynamicTree()
1482: .getSelectedNode()) != null
1483: && (SalomeTMF.getCampaignDynamicTree()
1484: .getSelectedNode())
1485: .getUserObject() instanceof Campaign
1486: && ((Campaign) (SalomeTMF
1487: .getCampaignDynamicTree()
1488: .getSelectedNode())
1489: .getUserObject())
1490: .equals((campaignList.get(j)))) {
1491: getExecutionResultTableModel().clearTable();
1492: //TestData.getExecutionTableModel().clearTable();
1493: }
1494: }
1495:
1496: } catch (Exception exception) {
1497: if (familyDeleted) {
1498: //Erreur au niveau de L'IHM -> faire un reload
1499: reloadFromBase();
1500: result = true;
1501: } else {
1502: result = false;
1503: Tools.ihmExceptionView(exception.toString());
1504: }
1505: }
1506: } else {
1507: boolean deleteSuite = false;
1508: try {
1509: // DB
1510: TestPlanData
1511: .deleteTestListInBDDandModel((TestList) selectedNode
1512: .getUserObject());
1513: deleteSuite = true;
1514:
1515: // IHM
1516: for (int j = 0; j < campaignList.size(); j++) {
1517:
1518: // Nettoyage de l'arbre des campagnes
1519: DefaultMutableTreeNode testListNodeInCampaignTree = SalomeTMF
1520: .getCampaignDynamicTree()
1521: .findRemoveTestListNodeInCampagneTree(
1522: ((TestList) selectedNode
1523: .getUserObject())
1524: .getName(),
1525: ((TestList) selectedNode
1526: .getUserObject())
1527: .getFamily().getName(),
1528: ((Campaign) campaignList.get(j))
1529: .getName(), false);
1530: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListNodeInCampaignTree
1531: .getParent();
1532: SalomeTMF.getCampaignDynamicTree().removeNode(
1533: testListNodeInCampaignTree);
1534: if (familyParent.getChildCount() == 0) {
1535: SalomeTMF.getCampaignDynamicTree()
1536: .removeNode(familyParent);
1537: }
1538: // on nettoie la table des r?sultats des executions si la campagne
1539: //traitee est selectionnee dans l'abre des campagnes
1540: if ((SalomeTMF.getCampaignDynamicTree()
1541: .getSelectedNode()) != null
1542: && (SalomeTMF.getCampaignDynamicTree()
1543: .getSelectedNode())
1544: .getUserObject() instanceof Campaign
1545: && ((Campaign) (SalomeTMF
1546: .getCampaignDynamicTree()
1547: .getSelectedNode())
1548: .getUserObject())
1549: .equals((campaignList.get(j)))) {
1550: executionResultTableModel.clearTable();
1551: //TestData.getExecutionTableModel().clearTable();
1552: }
1553:
1554: }
1555:
1556: } catch (Exception exception) {
1557: if (deleteSuite) {
1558: //Erreur au niveau de L'IHM -> faire un reload
1559: reloadFromBase();
1560: result = true;
1561: } else {
1562: result = false;
1563: Tools.ihmExceptionView(exception.toString());
1564: }
1565: }
1566: }
1567:
1568: SalomeTMF.getWorkSpaceTest().removeAll();
1569: SalomeTMF.getTestDynamicTree().removeCurrentNode();
1570: SalomeTMF.getDelTestOrTestList().setEnabled(false);
1571: SalomeTMF.getTests().validate();
1572: SalomeTMF.getTests().repaint();
1573:
1574: }
1575:
1576: return result;
1577: } // Fin de la methode deleteReally/0
1578:
1579: /**
1580: * Methode de suppression de tests, suites de tests, familles ou campagnes
1581: * de l'arbre des campagnes.
1582: * @return vrai si la suppression s'est correctement deroulee, faux sinon.
1583: */
1584: public static boolean deleteInCampaignTree() {
1585: DefaultMutableTreeNode selectedNode;
1586: boolean result = true;
1587: boolean isCampEmpty = false;
1588: boolean deleted = false;
1589:
1590: selectedNode = SalomeTMF.getCampaignDynamicTree()
1591: .getSelectedNode();
1592:
1593: Object[] options = { Language.getInstance().getText("Oui"),
1594: Language.getInstance().getText("Non") };
1595: int choice = -1;
1596: int actionCase = -1;
1597: if ((selectedNode.getUserObject() instanceof Test)) {
1598: choice = JOptionPane
1599: .showOptionDialog(
1600: applet,
1601: Language
1602: .getInstance()
1603: .getText(
1604: "Etes_vous_sûr_de_vouloir_supprimer_le_test_<")
1605: + ((Test) selectedNode
1606: .getUserObject()).getName()
1607: + Language.getInstance().getText(
1608: ">_de_cette_campagne_?"),
1609: Language.getInstance().getText(
1610: "Attention_!"),
1611: JOptionPane.YES_NO_OPTION,
1612: JOptionPane.QUESTION_MESSAGE, null,
1613: options, options[1]);
1614: actionCase = SalomeTMF.TEST;
1615: } else if (selectedNode.getUserObject() instanceof TestList) {
1616: choice = JOptionPane
1617: .showOptionDialog(
1618: applet,
1619: Language
1620: .getInstance()
1621: .getText(
1622: "Etes_vous_sûr_de_vouloir_supprimer_la_suite_<")
1623: + ((TestList) selectedNode
1624: .getUserObject()).getName()
1625: + Language.getInstance().getText(
1626: ">_de_cette_campagne_?"),
1627: Language.getInstance().getText(
1628: "Attention_!"),
1629: JOptionPane.YES_NO_OPTION,
1630: JOptionPane.QUESTION_MESSAGE, null,
1631: options, options[1]);
1632: actionCase = TESTLIST;
1633: } else if (selectedNode.getUserObject() instanceof Family) {
1634: choice = JOptionPane
1635: .showOptionDialog(
1636: applet,
1637: Language
1638: .getInstance()
1639: .getText(
1640: "Etes_vous_sûr_de_vouloir_supprimer_la_famille_<")
1641: + ((Family) selectedNode
1642: .getUserObject()).getName()
1643: + Language.getInstance().getText(
1644: ">_de_cette_campagne_?"),
1645: Language.getInstance().getText(
1646: "Attention_!"),
1647: JOptionPane.YES_NO_OPTION,
1648: JOptionPane.QUESTION_MESSAGE, null,
1649: options, options[1]);
1650: actionCase = SalomeTMF.FAMILY;
1651: } else if (selectedNode.getUserObject() instanceof Campaign) {
1652: choice = JOptionPane
1653: .showOptionDialog(
1654: applet,
1655: Language
1656: .getInstance()
1657: .getText(
1658: "Etes_vous_sûr_de_vouloir_supprimer_la_campagne_<")
1659: + ((Campaign) selectedNode
1660: .getUserObject()).getName()
1661: + "> ?", Language.getInstance()
1662: .getText("Attention_!"),
1663: JOptionPane.YES_NO_OPTION,
1664: JOptionPane.QUESTION_MESSAGE, null,
1665: options, options[1]);
1666: actionCase = CAMPAIGN;
1667: }
1668:
1669: if (choice == JOptionPane.YES_OPTION) {
1670: if (actionCase == CAMPAIGN) {
1671: try {
1672: // BdD
1673: CampaignData
1674: .deleteCampaignFromBDDandModel((Campaign) selectedNode
1675: .getUserObject());
1676: deleted = true;
1677:
1678: //Model
1679: SalomeTMF.getWorkSpaceCampagne().removeAll();
1680: SalomeTMF.getAddTestInCampagne().setEnabled(false);
1681: SalomeTMF.getOrderCampagne().setEnabled(false);
1682: SalomeTMF.getDelCampagne().setEnabled(false);
1683: SalomeTMF.getCampagne().validate();
1684: SalomeTMF.getCampagne().repaint();
1685: SalomeTMF.getCampaignDynamicTree()
1686: .removeCurrentNode();
1687:
1688: } catch (Exception exception) {
1689: if (deleted) {
1690: //Erreur au niveau de L'IHM -> faire un reload
1691: reloadFromBase();
1692: result = true;
1693: } else {
1694: Tools.ihmExceptionView(exception.toString());
1695: result = false;
1696: }
1697: }
1698: } else {
1699: if (actionCase == SalomeTMF.TEST) {
1700: try {
1701: // BDD and Model
1702: isCampEmpty = CampaignData
1703: .deleteTestFromCampaignInBDDandModel(
1704: (Test) selectedNode
1705: .getUserObject(),
1706: currentCampaign);
1707: deleted = true;
1708:
1709: // IHM
1710: DefaultMutableTreeNode testListParent = (DefaultMutableTreeNode) selectedNode
1711: .getParent();
1712: SalomeTMF.getCampaignDynamicTree().removeNode(
1713: selectedNode);
1714: if (testListParent.getChildCount() == 0) {
1715: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListParent
1716: .getParent();
1717: SalomeTMF.getCampaignDynamicTree()
1718: .removeNode(testListParent);
1719: if (familyParent.getChildCount() == 0) {
1720: SalomeTMF.getCampaignDynamicTree()
1721: .removeNode(familyParent);
1722: }
1723: }
1724: } catch (Exception exception) {
1725: if (deleted) {
1726: //Erreur au niveau de L'IHM -> faire un reload
1727: reloadFromBase();
1728: result = true;
1729: } else {
1730: Tools
1731: .ihmExceptionView(exception
1732: .toString());
1733: result = false;
1734: }
1735: }
1736:
1737: } else if (actionCase == SalomeTMF.FAMILY) {
1738: try {
1739: // BdD
1740: isCampEmpty = CampaignData
1741: .deleteFamilyFromCampaignInBDDandModel(
1742: (Family) selectedNode
1743: .getUserObject(),
1744: currentCampaign);
1745: deleted = true;
1746:
1747: // IHM
1748: SalomeTMF.getCampaignDynamicTree()
1749: .removeCurrentNode();
1750: } catch (Exception exception) {
1751: if (deleted) {
1752: //Erreur au niveau de L'IHM -> faire un reload
1753: reloadFromBase();
1754: result = true;
1755: } else {
1756: Tools
1757: .ihmExceptionView(exception
1758: .toString());
1759: result = false;
1760: }
1761: }
1762: } else {
1763: try {
1764: // BDD and Model
1765: isCampEmpty = CampaignData
1766: .deleteTestListFromCampaignInBDDandModel(
1767: (TestList) selectedNode
1768: .getUserObject(),
1769: currentCampaign);
1770: deleted = true;
1771:
1772: //IHM
1773: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) selectedNode
1774: .getParent();
1775: SalomeTMF.getCampaignDynamicTree().removeNode(
1776: selectedNode);
1777: if (familyParent.getChildCount() == 0) {
1778: SalomeTMF.getCampaignDynamicTree()
1779: .removeNode(familyParent);
1780: }
1781: } catch (Exception exception) {
1782: if (deleted) {
1783: //Erreur au niveau de L'IHM -> faire un reload
1784: reloadFromBase();
1785: result = true;
1786: } else {
1787: Tools
1788: .ihmExceptionView(exception
1789: .toString());
1790: result = false;
1791: }
1792: }
1793: }
1794:
1795: // Si la campagne est vide, suppression de ses résultats d'exécution
1796: if (isCampEmpty) {
1797: JOptionPane
1798: .showMessageDialog(
1799: applet,
1800: Language
1801: .getInstance()
1802: .getText(
1803: "Les_résultats_d'exécution_de_cette_campagne_ont_été_supprimés_car_elle_ne_contient_plus_de_tests."),
1804: Language.getInstance().getText(
1805: "Information_!"),
1806: JOptionPane.INFORMATION_MESSAGE);
1807: }
1808: SalomeTMF.getWorkSpaceTest().removeAll();
1809: SalomeTMF.getDelTestOrTestList().setEnabled(false);
1810: SalomeTMF.getTests().validate();
1811: SalomeTMF.getTests().repaint();
1812: }
1813: //return true;
1814: }
1815: //return false;
1816: return result;
1817: } // Fin de la methode deleteAction/0
1818:
1819: //**************************************** Ajout *********************************************//
1820: /**
1821: * Methode qui permet d'ajouter une nouvelle campagne de tests
1822: */
1823: public static void addNewCampagne() {
1824: AskNewCampagne askNewCampagne = new AskNewCampagne(applet,
1825: Language.getInstance().getText(
1826: "Nouvelle_campagne_de_tests"));
1827: if (askNewCampagne.getCampagne() == null)
1828: return;
1829: if (CampaignData.containsCampaign(askNewCampagne.getCampagne()
1830: .getName())
1831: || ConnectionData
1832: .isInBase(askNewCampagne.getCampagne())) {
1833: JOptionPane.showMessageDialog(applet,
1834: "Le nom de la campagne existe déjà !", Language
1835: .getInstance().getText("Erreur_!"),
1836: JOptionPane.ERROR_MESSAGE);
1837: } else {
1838:
1839: try {
1840: Campaign camp = askNewCampagne.getCampagne();
1841: // BdD
1842: if (CampaignData.addCampaignInBDDandModel(camp)) {
1843: Tools.RefreshView(camp.getName(), "Campaign");
1844: }
1845: // IHM
1846: SalomeTMF.getCampaignDynamicTree().addObject(null,
1847: camp, true);
1848: } catch (Exception exception) {
1849: Tools.ihmExceptionView(exception.toString());
1850: }
1851: }
1852: } // Fin de la m?thode addNewCampagne/0
1853:
1854: /**
1855: * Méthode qui permet d'ajouter une nouvelle suite de tests
1856: */
1857: public static void addNewTestList() {
1858: // Fen?tre pour construire la nouvelle suite
1859: AskNewTestList testListDialog = new AskNewTestList(Language
1860: .getInstance().getText("Nouvelle_suite"), Language
1861: .getInstance().getText("Nom_de_la_suite_:"));
1862: // La nouvelle suite en cours de cr?ation
1863: TestList newTestList = testListDialog.getTestList();
1864: // Le noeud sélectionné
1865: DefaultMutableTreeNode node = SalomeTMF.getTestDynamicTree()
1866: .getSelectedNode();
1867: // l'utilisateur n'a pas annulé
1868: if (newTestList == null) {
1869: return;
1870: }
1871: DefaultMutableTreeNode familyNode = null;
1872: Family pFamily = null;
1873:
1874: if (node != null) {
1875: if (node.getUserObject() instanceof Family) {
1876: pFamily = (Family) node.getUserObject();
1877: } else if (node.getUserObject() instanceof TestList) {
1878: pFamily = (((TestList) node.getUserObject())
1879: .getFamily());
1880: } else if (node.getUserObject() instanceof Test) {
1881: pFamily = (((Test) node.getUserObject()).getTestList()
1882: .getFamily());
1883: }
1884: }
1885: if (pFamily == null) {
1886: //Ajout de la famille par defaut
1887: //pFamily = TestPlanData.getDefaultFamily();
1888: pFamily = TestPlanData
1889: .getFamily(TestPlanData.DEFAULT_FAMILY_NAME);
1890: if (pFamily == null) {
1891: pFamily = new Family();
1892: pFamily
1893: .setDescription(TestPlanData.DEFAULT_FAMILY_DESC);
1894: pFamily.setName(TestPlanData.DEFAULT_FAMILY_NAME);
1895: //if (!TestPlanData.containsFamily(pFamily.getName())){
1896: try {
1897: // BDD & MODEL
1898: TestPlanData.addFamilyInBddAndModel(pFamily);
1899:
1900: //IHM
1901: familyNode = SalomeTMF.getTestDynamicTree()
1902: .addObject(null, pFamily, true);
1903: } catch (Exception exception) {
1904: Tools.ihmExceptionView(exception.toString());
1905: return;
1906: }
1907: }
1908: }
1909: newTestList.setFamily(pFamily);
1910: try {
1911: if (TestPlanData.containsTestList(pFamily, newTestList
1912: .getName())
1913: || ConnectionData.isInBase(newTestList)) {
1914: JOptionPane
1915: .showMessageDialog(
1916: applet,
1917: Language
1918: .getInstance()
1919: .getText(
1920: "Le_nom_de_la_suite_existe_déjà_dans_cette_famille_!"),
1921: Language.getInstance().getText(
1922: "Erreur_!"),
1923: JOptionPane.ERROR_MESSAGE);
1924: return;
1925: }
1926:
1927: //BDD & MODEL
1928: TestPlanData.addTestListInFamilyInModelAndBDD(newTestList,
1929: pFamily);
1930:
1931: //IHM
1932: if (familyNode == null) {
1933: DefaultMutableTreeNode fNode = SalomeTMF
1934: .getTestDynamicTree().findRemoveFamilyNode(
1935: newTestList.getFamily().getName(),
1936: false);
1937: if (fNode == null) {
1938: familyNode = SalomeTMF.getTestDynamicTree()
1939: .addObject(null, newTestList.getFamily(),
1940: true);
1941: } else {
1942: familyNode = fNode;
1943: }
1944: }
1945: SalomeTMF.getTestDynamicTree().addObject(familyNode,
1946: newTestList, true);
1947: } catch (Exception e) {
1948: Tools.ihmExceptionView(e.toString());
1949: }
1950: } // Fin de la m?thode addNewTestList/0
1951:
1952: public static void addNewFamily() {
1953: AskNameAndDescription askNewFamily = new AskNameAndDescription(
1954: FAMILY, Language.getInstance().getText(
1955: "Nouvelle_famille"), Language.getInstance()
1956: .getText("Nouvelle_famille_:"),
1957: SalomeTMF.ptrFrame);
1958: Family newFamily = askNewFamily.getFamily();
1959: if (newFamily != null) {
1960: if (TestPlanData.containsFamily(newFamily.getName())
1961: || ConnectionData.isInBase(newFamily)) {
1962: JOptionPane.showMessageDialog(applet, Language
1963: .getInstance().getText(
1964: "Cette_famille_existe_déjà_!"),
1965: Language.getInstance().getText("Erreur_!"),
1966: JOptionPane.ERROR_MESSAGE);
1967: } else {
1968: try {
1969: //BDD & MODEL
1970: TestPlanData.addFamilyInBddAndModel(newFamily);
1971: //IHM
1972: SalomeTMF.getTestDynamicTree().addObject(null,
1973: newFamily, true);
1974: } catch (Exception exception) {
1975: Tools.ihmExceptionView(exception.toString());
1976: }
1977:
1978: }
1979: }
1980: } // Fin de la méthode addNewTestList/0
1981:
1982: /**
1983: * M?thode qui permet d'ajouter un nouveau test.
1984: */
1985: public static void addNewTest() {
1986: //String type ="";
1987: AskNewTest askNewTest = new AskNewTest(applet, Language
1988: .getInstance().getText("Nouveau_Test"));
1989: DefaultMutableTreeNode node = SalomeTMF.getTestDynamicTree()
1990: .getSelectedNode();
1991: Test pTest = askNewTest.getTest();
1992: if (pTest == null)
1993: return;
1994:
1995: TestList pTestList;
1996: Family pFamily;
1997: //DefaultMutableTreeNode testListNode;
1998: //DefaultMutableTreeNode familyNode ;
1999:
2000: DefaultMutableTreeNode pNode = null;
2001: if (node == null
2002: || node == SalomeTMF.getTestDynamicTree().getRoot()) {
2003: // Rien n'est seléctionné
2004: //Ajout de la famille par defaut
2005: //pFamily = TestPlanData.getDefaultFamily();
2006: pFamily = TestPlanData
2007: .getFamily(TestPlanData.DEFAULT_FAMILY_NAME);
2008: if (pFamily == null) {
2009: pFamily = new Family();
2010: pFamily
2011: .setDescription(TestPlanData.DEFAULT_FAMILY_DESC);
2012: pFamily.setName(TestPlanData.DEFAULT_FAMILY_NAME);
2013: //if (!TestPlanData.containsFamily(pFamily.getName())){
2014: try {
2015: // BDD & MODEL
2016: TestPlanData.addFamilyInBddAndModel(pFamily);
2017: //IHM
2018: pNode = SalomeTMF.getTestDynamicTree().addObject(
2019: null, pFamily, true);
2020: } catch (Exception exception) {
2021: Tools.ihmExceptionView(exception.toString());
2022: return;
2023: }
2024: } else {
2025: pNode = SalomeTMF.getTestDynamicTree()
2026: .findRemoveFamilyNode(pFamily.getName(), false);
2027: }
2028: pTestList = pFamily
2029: .getTestList(TestPlanData.DEFAULT_TESTLIST_NAME);
2030: if (pTestList == null) {
2031: //Ajout de la suite par defaut
2032: pTestList = new TestList();
2033: pTestList.setName(TestPlanData.DEFAULT_TESTLIST_NAME);
2034: try {
2035: //BDD & MODEL
2036: TestPlanData.addTestListInFamilyInModelAndBDD(
2037: pTestList, pFamily);
2038: //IHM
2039: pNode = SalomeTMF.getTestDynamicTree().addObject(
2040: pNode, pTestList, true);
2041: } catch (Exception exception) {
2042: Tools.ihmExceptionView(exception.toString());
2043: return;
2044: }
2045: } else {
2046: pNode = SalomeTMF.getTestDynamicTree()
2047: .findRemoveTestListNode(
2048: TestPlanData.DEFAULT_TESTLIST_NAME,
2049: pTestList.getFamily().getName(), false);
2050: }
2051: } else if (node.getUserObject() instanceof Family) {
2052: pFamily = (Family) node.getUserObject();
2053: pTestList = pFamily
2054: .getTestList(TestPlanData.DEFAULT_TESTLIST_NAME);
2055: pNode = node;
2056: if (pTestList == null) {
2057: //Ajout de la suite par defaut
2058: pTestList = new TestList();
2059: pTestList.setName(TestPlanData.DEFAULT_TESTLIST_NAME);
2060: try {
2061: //BDD & MODEL
2062: TestPlanData.addTestListInFamilyInModelAndBDD(
2063: pTestList, pFamily);
2064: //IHM
2065: pNode = SalomeTMF.getTestDynamicTree().addObject(
2066: pNode, pTestList, true);
2067: } catch (Exception exception) {
2068: Tools.ihmExceptionView(exception.toString());
2069: return;
2070: }
2071: } else {
2072: pNode = SalomeTMF.getTestDynamicTree()
2073: .findRemoveTestListNode(DEFAULT_TESTLIST_NAME,
2074: pFamily.getName(), false);
2075: }
2076: } else if (node.getUserObject() instanceof TestList) {
2077: pTestList = (TestList) node.getUserObject();
2078: pFamily = pTestList.getFamily();
2079: pNode = node;
2080: } else if (node.getUserObject() instanceof Test) {
2081: pTestList = ((Test) node.getUserObject()).getTestList();
2082: pFamily = pTestList.getFamily();
2083: pNode = (DefaultMutableTreeNode) node.getParent();
2084: } else {
2085: //???????????????????
2086: return;
2087: }
2088:
2089: try {
2090: if ((pTestList.getTest(pTest.getName()) != null)
2091: || ConnectionData.isInBase(pTest, pTestList)) {
2092: JOptionPane
2093: .showMessageDialog(
2094: applet,
2095: Language
2096: .getInstance()
2097: .getText(
2098: "Ce_nom_de_test_existe_déjà_pour_cette_suite_!"),
2099: Language.getInstance().getText(
2100: "Erreur_!"),
2101: JOptionPane.ERROR_MESSAGE);
2102: return;
2103: }
2104:
2105: //BDD & MODELL
2106: if (TestPlanData.addTestInListInBddAndModel(pTest,
2107: pTestList)) {
2108: Tools.RefreshView(pTest.getName(), Language
2109: .getInstance().getText("Test"));
2110: }
2111: // IHM
2112: SalomeTMF.getTestDynamicTree()
2113: .addObject(pNode, pTest, true);
2114: } catch (Exception e) {
2115: Tools.ihmExceptionView(e.toString());
2116: }
2117: // ???????????????
2118: String login = pTest.getConceptor();
2119: pTest.setConceptor(ConnectionData.getAdminVTSelect()
2120: .getUserName(login)
2121: + " "
2122: + ConnectionData.getAdminVTSelect().getUserFirstName(
2123: login));
2124: } // Fin de la m?thode addNewTest/0
2125:
2126: public static void importTestsToCampaign() {
2127: DynamicTree campaignDynamicTree = SalomeTMF
2128: .getCampaignDynamicTree();
2129: DynamicTree testDynamicTree = SalomeTMF.getTestDynamicTree();
2130: DefaultMutableTreeNode selectedCampagneNode = campaignDynamicTree
2131: .getSelectedNode();
2132: ArrayList oldTestList = new ArrayList();
2133: for (int k = 0; k < currentCampaign.getTestList().size(); k++) {
2134: oldTestList.add(currentCampaign.getTestList().get(k));
2135: }
2136:
2137: ArrayList testsToBeKeeped = null;
2138:
2139: if (selectedCampagneNode == null) {
2140: return;
2141: }
2142: //if (selectedCampagneNode != null) {
2143: if (!currentCampaign.containsExecutionResult()) {
2144:
2145: new FillCampagne(selectedCampagneNode, campaignDynamicTree
2146: .getModel(), testDynamicTree.getRoot());
2147: boolean newDataSetCreated = false;
2148: ArrayList datasetsCreated;
2149:
2150: int transNumber = -1;
2151: try {
2152: // BDD & MODEL
2153:
2154: transNumber = Api
2155: .beginTransaction(Api.INSERT_TEST_INTO_CAMPAIGN);
2156: //On vide la campagne
2157: for (int j = 0; j < oldTestList.size(); j++) {
2158: currentCampaign.deleteTestFromCampInDB(
2159: ((Test) oldTestList.get(j)).getIdBDD(),
2160: true);
2161: }
2162: //Puis on lui ajoute les tests
2163: testsToBeKeeped = currentCampaign.getTestList();
2164: ArrayList dataSets = currentCampaign.getDataSetList();
2165:
2166: if (testsToBeKeeped != null) {
2167: int size = testsToBeKeeped.size();
2168: for (int j = 0; j < size; j++) {
2169: Test pTest = (Test) testsToBeKeeped.get(j);
2170: datasetsCreated = CampaignData
2171: .addTestInCampaignInBddAndModel(pTest,
2172: currentCampaign);
2173: if (datasetsCreated.size() > 0) {
2174: newDataSetCreated = true;
2175: for (int k = 0; k < currentCampaign
2176: .getExecutionList().size(); k++) {
2177: executionTableModel.setValueAt(
2178: ((DataSet) datasetsCreated
2179: .get(k)).getName(), k,
2180: 3);
2181: }
2182: }
2183: }
2184: }
2185:
2186: Api.commitTrans(transNumber);
2187:
2188: //IHM
2189: campaignDynamicTree.repaint();
2190: if (newDataSetCreated) {
2191: for (int i = 0; i < dataSets.size(); i++) {
2192: DataSet newDataSet = (DataSet) dataSets.get(i);
2193: ArrayList dataView = new ArrayList();
2194: dataView.add(newDataSet.getName());
2195: dataView.add(newDataSet.getDescription());
2196: dataSetTableModel.addRow(dataView);
2197: }
2198: }
2199:
2200: } catch (Exception exception) {
2201: Api.forceRollBackTrans(transNumber);
2202: currentCampaign.setTestList(oldTestList);
2203: Tools.ihmExceptionView(exception.toString());
2204: }
2205:
2206: } else {
2207: JOptionPane
2208: .showMessageDialog(
2209: applet,
2210: Language
2211: .getInstance()
2212: .getText(
2213: "Cette_campagne_contient_déjà_des_résultat_d'exécution.\nIl_n'est_plus_possible_de_la_modifier."),
2214: Language.getInstance().getText("Erreur_!"),
2215: JOptionPane.ERROR_MESSAGE);
2216: }
2217: //}
2218: }
2219:
2220: /********************************* RENAME *************************************************/
2221:
2222: /**
2223: * Méthode permettant de renommer une campagne
2224: *
2225: */
2226: public static void renameCampaign() {
2227: DefaultMutableTreeNode selectedNode = SalomeTMF
2228: .getCampaignDynamicTree().getSelectedNode();
2229: if (selectedNode != null
2230: && selectedNode.getUserObject() instanceof Campaign) {
2231: AskName askName = new AskName(Language.getInstance()
2232: .getText("Nouveau_nom_:"), Language.getInstance()
2233: .getText("Renommer"), Language.getInstance()
2234: .getText("nom"), ((Campaign) selectedNode
2235: .getUserObject()).getName(), SalomeTMF.ptrFrame);
2236: if (askName.getResult() != null) {
2237: if (!CampaignData.containsCampaign(askName.getResult())
2238: && !ConnectionData.isCampaignInBase(askName
2239: .getResult())) {
2240: try {
2241: // BdD
2242: ((Campaign) selectedNode.getUserObject())
2243: .updateInDB(askName.getResult(),
2244: currentCampaign
2245: .getDescription());
2246:
2247: // IHM
2248: selectedNode.setUserObject(selectedNode
2249: .getUserObject());
2250: SalomeTMF.getCampaignNameLabel().setText(
2251: Language.getInstance().getText(
2252: "Nom_de_la_campagne_:_")
2253: + askName.getResult());
2254: SalomeTMF.getCampaignDynamicTree().repaint();
2255:
2256: } catch (Exception exception) {
2257: Tools.ihmExceptionView(exception.toString());
2258: }
2259:
2260: } else if (CampaignData
2261: .getCampaign(askName.getResult()) == null
2262: || !CampaignData.getCampaign(
2263: askName.getResult()).equals(
2264: selectedNode.getUserObject())) {
2265: JOptionPane
2266: .showMessageDialog(
2267: applet,
2268: Language
2269: .getInstance()
2270: .getText(
2271: "Le_nom_de_la_campagne_existe_déjà_!"),
2272: Language.getInstance().getText(
2273: "Erreur_!"),
2274: JOptionPane.ERROR_MESSAGE);
2275: }
2276: }
2277: }
2278: }
2279:
2280: /**
2281: * Méthode permettant le renommage des tests, familles, suites de tests.
2282: *
2283: */
2284: public static void renameTest() {
2285: DefaultMutableTreeNode selectedNode = SalomeTMF
2286: .getTestDynamicTree().getSelectedNode();
2287: if (selectedNode != null
2288: && selectedNode.getUserObject() instanceof Element) {
2289: //String oldName = ((Element)selectedNode.getUserObject()).getName();
2290: AskName askName = new AskName(Language.getInstance()
2291: .getText("Nouveau_nom_:"), Language.getInstance()
2292: .getText("Renommer"), Language.getInstance()
2293: .getText("nom"), ((Element) selectedNode
2294: .getUserObject()).getName(), SalomeTMF.ptrFrame);
2295: if (askName.getResult() != null) {
2296: if (selectedNode.getUserObject() instanceof Test) {
2297: if (!TestPlanData
2298: .containsTest(
2299: ((TestList) ((DefaultMutableTreeNode) selectedNode
2300: .getParent())
2301: .getUserObject()), askName
2302: .getResult())
2303: && !ConnectionData
2304: .isTestInBase(
2305: askName.getResult(),
2306: ((TestList) ((DefaultMutableTreeNode) selectedNode
2307: .getParent())
2308: .getUserObject())
2309: .getName(),
2310: ((TestList) ((DefaultMutableTreeNode) selectedNode
2311: .getParent())
2312: .getUserObject())
2313: .getFamily()
2314: .getName())) {
2315:
2316: try {
2317: ((Test) selectedNode.getUserObject())
2318: .updateInBddAndModel(askName
2319: .getResult(),
2320: ((Test) selectedNode
2321: .getUserObject())
2322: .getDescription());
2323:
2324: SalomeTMF.getManualTestNameLabel().setText(
2325: Language.getInstance().getText(
2326: "Nom_du_test_:_")
2327: + ((Test) selectedNode
2328: .getUserObject())
2329: .getName());
2330: selectedNode.setUserObject(selectedNode
2331: .getUserObject());
2332: SalomeTMF.getTestDynamicTree().repaint();
2333: } catch (Exception exception) {
2334: Tools
2335: .ihmExceptionView(exception
2336: .toString());
2337: }
2338: } else if (TestPlanData
2339: .getTest(
2340: ((TestList) ((DefaultMutableTreeNode) selectedNode
2341: .getParent())
2342: .getUserObject())
2343: .getFamily().getName(),
2344: ((TestList) ((DefaultMutableTreeNode) selectedNode
2345: .getParent())
2346: .getUserObject()).getName(),
2347: askName.getResult()) == null
2348: || !TestPlanData
2349: .getTest(
2350: ((TestList) ((DefaultMutableTreeNode) selectedNode
2351: .getParent())
2352: .getUserObject())
2353: .getFamily()
2354: .getName(),
2355: ((TestList) ((DefaultMutableTreeNode) selectedNode
2356: .getParent())
2357: .getUserObject())
2358: .getName(),
2359: askName.getResult())
2360: .equals(
2361: selectedNode
2362: .getUserObject())) {
2363: JOptionPane
2364: .showMessageDialog(
2365: applet,
2366: Language
2367: .getInstance()
2368: .getText(
2369: "Ce_nom_de_test_existe_déjà_dans_cette_suite_!"),
2370: Language.getInstance().getText(
2371: "Erreur_!"),
2372: JOptionPane.ERROR_MESSAGE);
2373: }
2374: } else if (selectedNode.getUserObject() instanceof TestList) {
2375: if (!TestPlanData.containsTestList(
2376: ((TestList) selectedNode.getUserObject())
2377: .getFamily(), askName.getResult())
2378: && !ConnectionData.isTestListInBase(askName
2379: .getResult(),
2380: ((TestList) selectedNode
2381: .getUserObject())
2382: .getFamily().getName())) {
2383:
2384: try {
2385: ((TestList) selectedNode.getUserObject())
2386: .updateInBddAndModel(askName
2387: .getResult(),
2388: ((TestList) selectedNode
2389: .getUserObject())
2390: .getDescription());
2391:
2392: selectedNode.setUserObject(selectedNode
2393: .getUserObject());
2394: SalomeTMF.getTestDynamicTree().repaint();
2395: } catch (Exception exception) {
2396: Tools
2397: .ihmExceptionView(exception
2398: .toString());
2399: }
2400: } else if (TestPlanData.getTestList(
2401: ((TestList) selectedNode.getUserObject())
2402: .getFamily().getName(), askName
2403: .getResult()) == null
2404: || !TestPlanData.getTestList(
2405: ((TestList) selectedNode
2406: .getUserObject())
2407: .getFamily().getName(),
2408: askName.getResult()).equals(
2409: selectedNode.getUserObject())) {
2410: JOptionPane
2411: .showMessageDialog(
2412: applet,
2413: Language
2414: .getInstance()
2415: .getText(
2416: "Le_nom_de_la_suite_existe_déjà_dans_cette_famille_!"),
2417: Language.getInstance().getText(
2418: "Erreur_!"),
2419: JOptionPane.ERROR_MESSAGE);
2420: }
2421: } else if (selectedNode.getUserObject() instanceof Family) {
2422: if (!TestPlanData.containsFamily(askName
2423: .getResult())
2424: && !ConnectionData.isFamilyInBase(askName
2425: .getResult())) {
2426:
2427: try {
2428: ((Family) selectedNode.getUserObject())
2429: .updateInBddAndModel(askName
2430: .getResult(),
2431: ((Family) selectedNode
2432: .getUserObject())
2433: .getDescription());
2434:
2435: selectedNode.setUserObject(selectedNode
2436: .getUserObject());
2437: SalomeTMF.getTestDynamicTree().repaint();
2438: } catch (Exception exception) {
2439: Tools
2440: .ihmExceptionView(exception
2441: .toString());
2442: }
2443: } else if (TestPlanData.getFamily(askName
2444: .getResult()) == null
2445: || !TestPlanData.getFamily(
2446: askName.getResult()).equals(
2447: selectedNode.getUserObject())) {
2448: JOptionPane.showMessageDialog(applet, Language
2449: .getInstance().getText(
2450: "Cette_famille_existe_déjà_!"),
2451: Language.getInstance().getText(
2452: "Erreur_!"),
2453: JOptionPane.ERROR_MESSAGE);
2454:
2455: }
2456: }
2457: }
2458: }
2459:
2460: } // Fin de la méthode renameTest/0
2461:
2462: ////////////////////////////////////// Divers ///////////////////////////////////////////////
2463:
2464: public static void initTestScript(AutomaticTest test) {
2465: //System.out.println("Init Test Script");
2466: AutomaticTestScriptView.setTest(test);
2467:
2468: }
2469:
2470: /**
2471: * Methode d'affichage des exceptions levees par l'API
2472: * @param exceptionList un vecteur d'exceptions
2473: */
2474: public static void apiExceptionView(Vector exceptionList) {
2475: String message = "";
2476: for (int i = 0; i < exceptionList.size(); i++) {
2477: message = message + exceptionList.get(i) + "\n";
2478: }
2479: JOptionPane.showMessageDialog(applet, Language.getInstance()
2480: .getText("Liste_des_exceptions_levées_par_l'API_:")
2481: + message, Language.getInstance().getText(
2482: "Information_!"), JOptionPane.INFORMATION_MESSAGE);
2483: Api.purgeException();
2484: }
2485:
2486: ////////////// Pas utilisé ????? ////////////////////////////
2487: /*
2488: public static void refreshEnvironmentAndParameter() {
2489: if (ConnectionData.isConnected()) {
2490: try {
2491: // DATA
2492: pProjectData.reloadEnvironmentAndParameterData();
2493:
2494: // IHM
2495: getDataModification().clear();
2496: SalomeTMF.getDataMultiUserChangeListenerPanel().reset();
2497: } catch (Exception exception) {
2498: Tools.ihmExceptionView(exception.toString());
2499: }
2500:
2501: } else {
2502: JOptionPane.showMessageDialog(applet,
2503: Language.getInstance().getText("Impossible_!\n_Vous_n'êtes_pas_connecté_à_la_base."),
2504: Language.getInstance().getText("Erreur_!"),
2505: JOptionPane.ERROR_MESSAGE);
2506: }
2507: } // Fin de la m?thode refreshEnvironmentAndParameter/0
2508: */
2509:
2510: } // Fin de la classe TestData
|