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.main.datawrapper;
0025:
0026: import java.awt.Cursor;
0027: import java.util.ArrayList;
0028: import java.util.Collection;
0029: import java.util.Enumeration;
0030: import java.util.HashSet;
0031: import java.util.Hashtable;
0032: import java.util.Iterator;
0033: import java.util.Vector;
0034:
0035: import javax.swing.JOptionPane;
0036: import javax.swing.JTabbedPane;
0037: import javax.swing.tree.DefaultMutableTreeNode;
0038: import javax.swing.tree.TreePath;
0039:
0040: import org.objectweb.salome_tmf.api.Api;
0041: import org.objectweb.salome_tmf.api.ApiConstants;
0042: import org.objectweb.salome_tmf.api.Util;
0043: import org.objectweb.salome_tmf.api.data.AutomaticTestWrapper;
0044: import org.objectweb.salome_tmf.api.data.CampaignWrapper;
0045: import org.objectweb.salome_tmf.api.data.DataUpToDateException;
0046: import org.objectweb.salome_tmf.api.data.EnvironmentWrapper;
0047: import org.objectweb.salome_tmf.api.data.FamilyWrapper;
0048: import org.objectweb.salome_tmf.api.data.ManualTestWrapper;
0049: import org.objectweb.salome_tmf.api.data.ParameterWrapper;
0050: import org.objectweb.salome_tmf.api.data.SuiteWrapper;
0051: import org.objectweb.salome_tmf.api.data.TestWrapper;
0052: import org.objectweb.salome_tmf.data.Action;
0053: import org.objectweb.salome_tmf.data.Attachment;
0054: import org.objectweb.salome_tmf.data.AutomaticTest;
0055: import org.objectweb.salome_tmf.data.Campaign;
0056: import org.objectweb.salome_tmf.data.DataConstants;
0057: import org.objectweb.salome_tmf.data.DataLoader;
0058: import org.objectweb.salome_tmf.data.DataSet;
0059: import org.objectweb.salome_tmf.data.Environment;
0060: import org.objectweb.salome_tmf.data.Execution;
0061: import org.objectweb.salome_tmf.data.ExecutionResult;
0062: import org.objectweb.salome_tmf.data.ExecutionTestResult;
0063: import org.objectweb.salome_tmf.data.Family;
0064: import org.objectweb.salome_tmf.data.FileAttachment;
0065: import org.objectweb.salome_tmf.data.IDataModelWrapper;
0066: import org.objectweb.salome_tmf.data.ManualTest;
0067: import org.objectweb.salome_tmf.data.Parameter;
0068: import org.objectweb.salome_tmf.data.Project;
0069: import org.objectweb.salome_tmf.data.SimpleData;
0070: import org.objectweb.salome_tmf.data.Test;
0071: import org.objectweb.salome_tmf.data.TestList;
0072: import org.objectweb.salome_tmf.data.User;
0073: import org.objectweb.salome_tmf.ihm.admin.AskName;
0074: import org.objectweb.salome_tmf.ihm.common.AskNameAndDescription;
0075: import org.objectweb.salome_tmf.ihm.languages.Language;
0076: import org.objectweb.salome_tmf.ihm.main.AskNewCampagne;
0077: import org.objectweb.salome_tmf.ihm.main.AskNewTest;
0078: import org.objectweb.salome_tmf.ihm.main.AskNewTestList;
0079: import org.objectweb.salome_tmf.ihm.main.AutomaticTestScriptView;
0080: import org.objectweb.salome_tmf.ihm.main.BaseIHM;
0081: import org.objectweb.salome_tmf.ihm.main.ExecutionView;
0082: import org.objectweb.salome_tmf.ihm.main.FillCampagne;
0083: import org.objectweb.salome_tmf.ihm.main.IAssignedCampAction;
0084: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
0085: import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
0086: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
0087: import org.objectweb.salome_tmf.ihm.models.ExecutionTableModel;
0088: import org.objectweb.salome_tmf.ihm.models.MyTableModel;
0089: import org.objectweb.salome_tmf.ihm.tools.Tools;
0090: import org.objectweb.salome_tmf.plugins.UICompCst;
0091:
0092: public class DataModel implements ApiConstants, DataConstants,
0093: IDataModelWrapper {
0094:
0095: private static BaseIHM applet;
0096:
0097: /* Les Models de tables de données */
0098: /**
0099: * Modèle de données des tables contenant l'ensemble de tous les paramètres
0100: */
0101: static private MyTableModel parameterTableModel;
0102: static private MyTableModel dataSetTableModel;
0103: static private MyTableModel environmentTableModel;
0104:
0105: /**
0106: * Modèle de données des tables contenant les paramètres d'un test
0107: */
0108: static private MyTableModel testParameterTableModel;
0109:
0110: /**
0111: * Modèles de données pour les paramètres d'un environnement
0112: */
0113: static private MyTableModel environmentParameterTableModel;
0114:
0115: /**
0116: * Modèle de données des tables contenant les actions d'un test
0117: */
0118: static private MyTableModel actionTableModel;
0119:
0120: /**
0121: * Modèle de données des tables contenant les exécutions d'une campagne
0122: */
0123: static private ExecutionTableModel executionTableModel;
0124:
0125: /**
0126: * Modèle de données des tables contenant les résultats des exécutions dans
0127: * la vue des exécutions
0128: */
0129: static private MyTableModel executionResultTableModel;
0130:
0131: /**
0132: * Modèle de données des tables contenant les attachements
0133: */
0134: static private MyTableModel attachmentTableModel;
0135:
0136: /**
0137: * Modèle de données des tables contenant les attachements
0138: */
0139: static private MyTableModel defectTableModel;
0140:
0141: /* Les données courantes de l'IHM */
0142: static Test currentTest;
0143: static TestList currentTestList;
0144: static Campaign currentCampaign;
0145: static Family currentFamily;
0146: static Project currentProject;
0147: static User currentUser;
0148:
0149: static Environment currentEnvironment;
0150: static Action currentAction;
0151: static Test testObservedInExecution;
0152: static Execution observedExecution;
0153: static ExecutionResult obervedExecutionResult;
0154: static ArrayList selectedExecution = new ArrayList();
0155: static private ExecutionTestResult currentExecutionTestResult;
0156:
0157: static private boolean badDirectoryView;
0158:
0159: static private String caretDescriptionValue;
0160: static private boolean campaignChange;
0161: static private boolean testChange;
0162: static private boolean testListChange;
0163: static private boolean familyChange;
0164:
0165: static private String oldCaretDescription;
0166: static private boolean beginDescriptionModification;
0167: static private HashSet testModifications;
0168: static private HashSet campaignModifications;
0169: static private HashSet dataModifications;
0170:
0171: static private IAssignedCampAction pIAssignedCampAction;
0172:
0173: Hashtable dynamicNodeMap = new Hashtable();
0174: Hashtable campaignNodeMap = new Hashtable();
0175:
0176: //static DataLoader pProjectData;
0177: static DataModel pDataModel = null;
0178:
0179: /**************************************************************************/
0180: /** METHODES PUBLIQUES ***/
0181: /**************************************************************************/
0182: public static User getCurrentUser() {
0183: return currentUser;
0184: }
0185:
0186: public static Project getCurrentProject() {
0187: return currentProject;
0188: }
0189:
0190: /**
0191: * @return la campagne en cours de traitement
0192: */
0193: public static Campaign getCurrentCampaign() {
0194: return currentCampaign;
0195: } // Fin de la méthode getCurrentCampaign/0
0196:
0197: /**
0198: * @return le test en cours de traitement
0199: */
0200: public static Test getCurrentTest() {
0201: return currentTest;
0202: } // Fin de la méthode getCurrentTest/0
0203:
0204: /**
0205: * @return la suite de tests en cours de traitement
0206: */
0207: public static TestList getCurrentTestList() {
0208: return currentTestList;
0209: } // Fin de la méthode getCurrentTestList/0
0210:
0211: /**
0212: * @return la suite de tests en cours de traitement
0213: */
0214: public static Family getCurrentFamily() {
0215: return currentFamily;
0216: } // Fin de la méthode getCurrentFamily/0
0217:
0218: /**
0219: * @param campagne courante
0220: */
0221: public static void setCurrentCampaign(Campaign campaign) {
0222: currentCampaign = campaign;
0223: } // Fin de la méthode setCurrentcampaign/1
0224:
0225: /**
0226: * @param testList courantes
0227: */
0228: public static void setCurrentTestList(TestList testList) {
0229: currentTestList = testList;
0230: } // Fin de la méthode setCurrentTestList/1
0231:
0232: /**
0233: * @param test courant
0234: */
0235: public static void setCurrentTest(Test test) {
0236: currentTest = test;
0237: } // Fin de la méthode setCurrentTest/1
0238:
0239: /**
0240: * @return
0241: */
0242: public static Environment getCurrentEnvironment() {
0243: return currentEnvironment;
0244: }
0245:
0246: /**
0247: * @param environment
0248: */
0249: public static void setCurrentEnvironment(Environment environment) {
0250: currentEnvironment = environment;
0251: }
0252:
0253: /**
0254: * @return
0255: */
0256: public static Action getCurrentAction() {
0257: return currentAction;
0258: }
0259:
0260: /**
0261: * @param action
0262: */
0263: public static void setCurrentAction(Action action) {
0264: currentAction = action;
0265: }
0266:
0267: /**
0268: * @param Famille courante
0269: */
0270: public static void setCurrentFamily(Family family) {
0271: currentFamily = family;
0272: } // Fin de la méthode setCurrentFamily/1
0273:
0274: /**
0275: * @return
0276: */
0277: public static Test getTestObservedInExecution() {
0278: return testObservedInExecution;
0279: }
0280:
0281: /**
0282: * @param test
0283: */
0284: public static void setTestObservedInExecution(Test test) {
0285: testObservedInExecution = test;
0286: }
0287:
0288: /**
0289: * @return
0290: */
0291: public static ExecutionResult getObservedExecutionResult() {
0292: return obervedExecutionResult;
0293: }
0294:
0295: /**
0296: * @return
0297: */
0298: public static Execution getObservedExecution() {
0299: return observedExecution;
0300: }
0301:
0302: /**
0303: * @param result
0304: */
0305: public static void setObervedExecutionResult(ExecutionResult result) {
0306: obervedExecutionResult = result;
0307: }
0308:
0309: /**
0310: * @param execution
0311: */
0312: public static void setObservedExecution(Execution execution) {
0313: observedExecution = execution;
0314: }
0315:
0316: public static void addSelectedExecution(Execution exec) {
0317: selectedExecution.add(exec);
0318: }
0319:
0320: public static void removeSelectedExecution(Execution exec) {
0321: selectedExecution.remove(exec);
0322: }
0323:
0324: /**
0325: * @return
0326: */
0327: public static ArrayList getSelectedExecution() {
0328: return selectedExecution;
0329: }
0330:
0331: /**
0332: * @param list
0333: */
0334: public static void setSelectedExecution(ArrayList list) {
0335: selectedExecution = list;
0336: }
0337:
0338: /**
0339: * @return
0340: */
0341: public static ExecutionTestResult getCurrentExecutionTestResult() {
0342: return currentExecutionTestResult;
0343: }
0344:
0345: /**
0346: * @param result
0347: */
0348: public static void setCurrentExecutionTestResult(
0349: ExecutionTestResult result) {
0350: currentExecutionTestResult = result;
0351: }
0352:
0353: /**
0354: * @return le modèle de la table contenant tous les paramètres
0355: */
0356: public static MyTableModel getParameterTableModel() {
0357: return parameterTableModel;
0358: }
0359:
0360: /**
0361: * @param model le modèle de la
0362: */
0363: public static void setParameterTableModel(MyTableModel model) {
0364: parameterTableModel = model;
0365: }
0366:
0367: /**
0368: * @return
0369: */
0370: public static MyTableModel getDataSetTableModel() {
0371: return dataSetTableModel;
0372: }
0373:
0374: /**
0375: * @return
0376: */
0377: public static MyTableModel getEnvironmentTableModel() {
0378: return environmentTableModel;
0379: }
0380:
0381: /**
0382: * @param model
0383: */
0384: public static void setDataSetTableModel(MyTableModel model) {
0385: dataSetTableModel = model;
0386: }
0387:
0388: /**
0389: * @param model
0390: */
0391: public static void setEnvironmentTableModel(MyTableModel model) {
0392: environmentTableModel = model;
0393: }
0394:
0395: /**
0396: * @return
0397: */
0398: public static MyTableModel getTestParameterTableModel() {
0399: return testParameterTableModel;
0400: }
0401:
0402: /**
0403: * @param model
0404: */
0405: public static void setTestParameterTableModel(MyTableModel model) {
0406: testParameterTableModel = model;
0407: }
0408:
0409: /**
0410: * @return
0411: */
0412: public static MyTableModel getEnvironmentParameterTableModel() {
0413: return environmentParameterTableModel;
0414: }
0415:
0416: /**
0417: * @param model
0418: */
0419: public static void setEnvironmentParameterTableModel(
0420: MyTableModel model) {
0421: environmentParameterTableModel = model;
0422: }
0423:
0424: /**
0425: * @return
0426: */
0427: public static MyTableModel getActionTableModel() {
0428: return actionTableModel;
0429: }
0430:
0431: /**
0432: * @param model
0433: */
0434: public static void setActionTableModel(MyTableModel model) {
0435: actionTableModel = model;
0436: }
0437:
0438: /**
0439: * @return
0440: */
0441: public static ExecutionTableModel getExecutionTableModel() {
0442: return executionTableModel;
0443: }
0444:
0445: /**
0446: * @param model
0447: */
0448: public static void setExecutionTableModel(ExecutionTableModel model) {
0449: executionTableModel = model;
0450: }
0451:
0452: /**
0453: * @return
0454: */
0455: public static MyTableModel getExecutionResultTableModel() {
0456: return executionResultTableModel;
0457: }
0458:
0459: /**
0460: * @param model
0461: */
0462: public static void setExecutionResultTableModel(MyTableModel model) {
0463: executionResultTableModel = model;
0464: }
0465:
0466: /**
0467: * @return
0468: */
0469: public static MyTableModel getAttachmentTableModel() {
0470: return attachmentTableModel;
0471: }
0472:
0473: /**
0474: * @param model
0475: */
0476: public static void setAttachmentTableModel(MyTableModel model) {
0477: attachmentTableModel = model;
0478: }
0479:
0480: public static MyTableModel getDefectTableModel() {
0481: return defectTableModel;
0482: }
0483:
0484: /**
0485: * @param model
0486: */
0487: public static void setDefectTableModel(MyTableModel model) {
0488: defectTableModel = model;
0489: }
0490:
0491: /**
0492: * @return
0493: */
0494: public static BaseIHM getApplet() {
0495: return applet;
0496: }
0497:
0498: /**
0499: * @param applet
0500: */
0501: public static void setApplet(BaseIHM pApplet) {
0502: applet = pApplet;
0503: }
0504:
0505: /**
0506: * @return
0507: */
0508: public static boolean isBadDirectoryView() {
0509: return badDirectoryView;
0510: }
0511:
0512: /**
0513: * @param b
0514: */
0515: public static void setBadDirectoryView(boolean b) {
0516: badDirectoryView = b;
0517: }
0518:
0519: /**
0520: * @return
0521: */
0522: public static String getCaretDescriptionValue() {
0523: return caretDescriptionValue;
0524: }
0525:
0526: /**
0527: * @param string
0528: */
0529: public static void setCaretDescriptionValue(String string) {
0530: caretDescriptionValue = string;
0531: }
0532:
0533: /**
0534: * @return
0535: */
0536: /* public static boolean isCampaignChange() {
0537: return campaignChange;
0538: }
0539:
0540:
0541: public static void setCampaignChange(boolean b) {
0542: campaignChange = b;
0543: }*/
0544:
0545: /*
0546: public static boolean isTestChange() {
0547: return testChange;
0548: }
0549: */
0550:
0551: /*
0552: public static void setTestChange(boolean b) {
0553: testChange = b;
0554: }*/
0555:
0556: /*
0557: public static boolean isTestListChange() {
0558: return testListChange;
0559: }
0560:
0561:
0562: public static void setTestListChange(boolean b) {
0563: testListChange = b;
0564: }*/
0565:
0566: /**
0567: * @return
0568: */
0569: /*public static String getOldCaretDescription() {
0570: return oldCaretDescription;
0571: }
0572:
0573:
0574: public static void setOldCaretDescription(String string) {
0575: oldCaretDescription = string;
0576: }*/
0577:
0578: /**
0579: * @return
0580: */
0581: /*public static boolean isBeginDescriptionModification() {
0582: return beginDescriptionModification;
0583: }
0584:
0585:
0586: public static void setBeginDescriptionModification(boolean b) {
0587: beginDescriptionModification = b;
0588: } */
0589:
0590: /**
0591: * @return
0592: */
0593: public static boolean isFamilyChange() {
0594: return familyChange;
0595: }
0596:
0597: /**
0598: * @param b
0599: */
0600: /*public static void setFamilyChange(boolean b) {
0601: familyChange = b;
0602: }*/
0603:
0604: public static void setAssignedCampAction(
0605: IAssignedCampAction _pIAssignedCampAction) {
0606: pIAssignedCampAction = _pIAssignedCampAction;
0607: }
0608:
0609: public static IAssignedCampAction getAssignedCampAction() {
0610: return pIAssignedCampAction;
0611: }
0612:
0613: /*****************************************************************************************/
0614:
0615: public static void addTestModification(Object obj) {
0616: testModifications.add(obj);
0617: }
0618:
0619: public static void removeTestModification(Object obj) {
0620: testModifications.remove(obj);
0621: }
0622:
0623: public static HashSet getTestModification() {
0624: return testModifications;
0625: }
0626:
0627: public static boolean containsTestModification(Object obj) {
0628: return testModifications.contains(obj);
0629: }
0630:
0631: public static boolean containsTestModification(int i) {
0632: for (Iterator iter = testModifications.iterator(); iter
0633: .hasNext();) {
0634: Integer elem = (Integer) iter.next();
0635: if (elem.intValue() == i)
0636: return true;
0637: }
0638: return false;
0639: }
0640:
0641: public static void addCampaignModification(Object obj) {
0642: campaignModifications.add(obj);
0643: }
0644:
0645: public static void removeCampaignModification(Object obj) {
0646: campaignModifications.remove(obj);
0647: }
0648:
0649: public static HashSet getCampaignModification() {
0650: return campaignModifications;
0651: }
0652:
0653: public static boolean containsCampaignModification(Object obj) {
0654: return campaignModifications.contains(obj);
0655: }
0656:
0657: public static boolean containsCampaignModification(int i) {
0658: for (Iterator iter = campaignModifications.iterator(); iter
0659: .hasNext();) {
0660: Integer elem = (Integer) iter.next();
0661: if (elem.intValue() == i)
0662: return true;
0663: }
0664: return false;
0665: }
0666:
0667: public static void addDataModification(Object obj) {
0668: dataModifications.add(obj);
0669: }
0670:
0671: public static void removeDataModification(Object obj) {
0672: dataModifications.remove(obj);
0673: }
0674:
0675: public static HashSet getDataModification() {
0676: return dataModifications;
0677: }
0678:
0679: public static boolean containsDataModification(Object obj) {
0680: return dataModifications.contains(obj);
0681: }
0682:
0683: public static boolean containsDataModification(int i) {
0684: for (Iterator iter = dataModifications.iterator(); iter
0685: .hasNext();) {
0686: Integer elem = (Integer) iter.next();
0687: if (elem.intValue() == i)
0688: return true;
0689: }
0690: return false;
0691: }
0692:
0693: //**** DataModelWrapper Implementation *******//
0694: public static DataModel getInstance() {
0695: if (pDataModel == null) {
0696: pDataModel = new DataModel();
0697: }
0698: return pDataModel;
0699:
0700: }
0701:
0702: public void addParameterToModel(ArrayList data) {
0703: parameterTableModel.addRow(data);
0704: }
0705:
0706: public void clearParameterToModel() {
0707: parameterTableModel.clearTable();
0708: }
0709:
0710: public void addEnvToModel(ArrayList data) {
0711: environmentTableModel.addRow(data);
0712: }
0713:
0714: public void clearEnvModel() {
0715: environmentTableModel.clearTable();
0716: }
0717:
0718: public void addFamilyToModel(Family pFamily) {
0719: DefaultMutableTreeNode familyNode;
0720: familyNode = SalomeTMFPanels.getTestDynamicTree().addObject(
0721: null, pFamily, true);
0722: dynamicNodeMap.put(pFamily, familyNode);
0723: }
0724:
0725: public void updateFamilyToModel(Family pFamily) {
0726: SalomeTMFPanels.getTestDynamicTree().findRemoveFamilyNode(
0727: pFamily.getNameFromModel(), true);
0728: dynamicNodeMap.remove(pFamily);
0729: addFamilyToModel(pFamily);
0730: }
0731:
0732: public void clearFamilyToModel(Family pFamily) {
0733: SalomeTMFPanels.getTestDynamicTree().findRemoveFamilyNode(
0734: pFamily.getNameFromModel(), false);
0735: }
0736:
0737: public void refreshFamilyToModel(Family pFamily) {
0738: if (pFamily.equals(currentFamily)) {
0739: initFamily(pFamily);
0740: }
0741: }
0742:
0743: public void addTestListToModel(Family pFamily, TestList pList) {
0744: DefaultMutableTreeNode testListNode;
0745: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) dynamicNodeMap
0746: .get(pFamily);
0747: testListNode = SalomeTMFPanels.getTestDynamicTree().addObject(
0748: familyNode, pList, false);
0749: dynamicNodeMap.put(pList, testListNode);
0750: }
0751:
0752: public void updateTestListToModel(TestList pList) {
0753: SalomeTMFPanels.getTestDynamicTree().findRemoveTestListNode(
0754: pList.getNameFromModel(),
0755: pList.getFamilyFromModel().getNameFromModel(), true);
0756: dynamicNodeMap.remove(pList);
0757: addTestListToModel(pList.getFamilyFromModel(), pList);
0758: }
0759:
0760: public void clearTestListToModel(TestList pList) {
0761: SalomeTMFPanels.getTestDynamicTree().findRemoveTestListNode(
0762: pList.getNameFromModel(),
0763: pList.getFamilyFromModel().getNameFromModel(), false);
0764:
0765: }
0766:
0767: public void refreshTestListToModel(TestList pList) {
0768: if (pList.equals(currentTestList)) {
0769: initTestList(pList);
0770: }
0771: }
0772:
0773: public void addTestToModel(TestList pList, Test pTest) {
0774: DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) dynamicNodeMap
0775: .get(pList);
0776: DefaultMutableTreeNode testNode = SalomeTMFPanels
0777: .getTestDynamicTree().addObject(testListNode, pTest,
0778: false);
0779: dynamicNodeMap.put(pTest, testNode);
0780: }
0781:
0782: public void updateTestToModel(TestList pList, Test pTest) {
0783: SalomeTMFPanels.getTestDynamicTree().findRemoveTestNode(
0784: pTest.getNameFromModel(), pList.getNameFromModel(),
0785: pList.getFamilyFromModel().getNameFromModel(), true);
0786: dynamicNodeMap.remove(pTest);
0787: addTestToModel(pList, pTest);
0788: }
0789:
0790: public void refreshTestToModel(Test pTest) {
0791: if (pTest.equals(currentTest)) {
0792: //le test traité est affiché à l'écran, il faut modifier l'affichage avec les nouvelles valeurs
0793: initTest(pTest);
0794: if (pTest instanceof ManualTest) {
0795: initActionTable((ManualTest) pTest);
0796: }
0797: }
0798: }
0799:
0800: public void clearTestToModel(Test pTest) {
0801: SalomeTMFPanels.getTestDynamicTree().findRemoveTestNode(
0802: pTest.getNameFromModel(),
0803: pTest.getTestListFromModel().getNameFromModel(),
0804: pTest.getTestListFromModel().getFamilyFromModel()
0805: .getNameFromModel(), true);
0806: }
0807:
0808: public void addCampaignToModel(Campaign campaign) {
0809: DefaultMutableTreeNode campaignNode;
0810: campaignNode = SalomeTMFPanels.getCampaignDynamicTree()
0811: .addObject(null, campaign, true);
0812: campaignNodeMap.put(campaign, campaignNode);
0813: }
0814:
0815: public void upadateCampaignToModel(Campaign campaign) {
0816: DefaultMutableTreeNode campaignNode = SalomeTMFPanels
0817: .getCampaignDynamicTree().findRemoveCampaignNode(
0818: campaign.getNameFromModel(), false);
0819: campaignNodeMap.remove(campaign);
0820: campaignNodeMap.put(campaign, campaignNode);
0821: }
0822:
0823: public void refreshCampaignToModel(Campaign campaign) {
0824: if (campaign.equals(getCurrentCampaign())) {
0825: initCampaign(campaign);
0826: }
0827: }
0828:
0829: public void addCampaignFamilyToModel(Campaign campaign,
0830: Family pFamily) {
0831: DefaultMutableTreeNode campaignNode = (DefaultMutableTreeNode) campaignNodeMap
0832: .get(campaign);
0833: DefaultMutableTreeNode familyNode = SalomeTMFPanels
0834: .getCampaignDynamicTree().addObject(campaignNode,
0835: pFamily, false);
0836: campaignNodeMap.put(pFamily, familyNode);
0837: }
0838:
0839: public void upadateCampaignFamilyToModel(Campaign campaign,
0840: Family pFamily) {
0841: DefaultMutableTreeNode familyNode = SalomeTMFPanels
0842: .getCampaignDynamicTree()
0843: .findRemoveFamilyNodeInCampagneTree(
0844: pFamily.getNameFromModel(),
0845: campaign.getNameFromModel(), false);
0846: campaignNodeMap.remove(pFamily);
0847: campaignNodeMap.put(pFamily, familyNode);
0848: }
0849:
0850: public void addCampaignTestListToModel(Family pFamily,
0851: TestList pList) {
0852: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) campaignNodeMap
0853: .get(pFamily);
0854: DefaultMutableTreeNode testListNode = SalomeTMFPanels
0855: .getCampaignDynamicTree().addObject(familyNode, pList,
0856: false);
0857: campaignNodeMap.put(pList, testListNode);
0858: }
0859:
0860: public void upadateCampaignTestListToModel(Campaign campaign,
0861: Family pFamily, TestList pList) {
0862: DefaultMutableTreeNode testListNode = SalomeTMFPanels
0863: .getCampaignDynamicTree()
0864: .findRemoveTestListNodeInCampagneTree(
0865: pList.getNameFromModel(),
0866: pFamily.getNameFromModel(),
0867: campaign.getNameFromModel(), false);
0868: campaignNodeMap.remove(pList);
0869: campaignNodeMap.put(pList, testListNode);
0870: }
0871:
0872: public void addCampaignTestToModel(TestList pList, Test pTest) {
0873: DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) campaignNodeMap
0874: .get(pList);
0875: SalomeTMFPanels.getCampaignDynamicTree().addObject(
0876: testListNode, pTest, false);
0877: campaignNodeMap.put(pTest, testListNode);
0878: }
0879:
0880: public void upadateCampaignTestToModel(TestList pList, Test pTest) {
0881:
0882: }
0883:
0884: ///////////////////////////////////////////////////////////////////////////
0885:
0886: public static void clearData() {
0887: dataClear();
0888: tableClear();
0889: }
0890:
0891: public static void initData() {
0892: dataClear();
0893: initTableModel();
0894: }
0895:
0896: private static void dataClear() {
0897: currentTest = null;
0898: currentTestList = null;
0899: currentCampaign = null;
0900: currentFamily = null;
0901: currentEnvironment = null;
0902: currentAction = null;
0903: currentExecutionTestResult = null;
0904:
0905: campaignChange = false;
0906: testChange = false;
0907: testListChange = false;
0908: beginDescriptionModification = false;
0909: badDirectoryView = true;
0910:
0911: selectedExecution.clear();
0912: testModifications = new HashSet();
0913: campaignModifications = new HashSet();
0914: dataModifications = new HashSet();
0915: }
0916:
0917: private static void tableClear() {
0918: parameterTableModel.clearTable();
0919: dataSetTableModel.clearTable();
0920: environmentTableModel.clearTable();
0921: testParameterTableModel.clearTable();
0922: environmentParameterTableModel.clearTable();
0923: actionTableModel.clearTable();
0924: executionTableModel.clearTable();
0925: executionResultTableModel.clearTable();
0926: attachmentTableModel.clearTable();
0927: defectTableModel.clearTable();
0928: }
0929:
0930: public static void initTableModel() {
0931: if (parameterTableModel == null) {
0932: parameterTableModel = new MyTableModel();
0933: parameterTableModel.addColumnNameAndColumn(Language
0934: .getInstance().getText("Nom"));
0935: parameterTableModel.addColumnNameAndColumn(Language
0936: .getInstance().getText("Description"));
0937: }
0938: // parameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0939: // parameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0940:
0941: if (testParameterTableModel == null) {
0942: testParameterTableModel = new MyTableModel();
0943: testParameterTableModel.addColumnNameAndColumn(Language
0944: .getInstance().getText("Nom"));
0945: testParameterTableModel.addColumnNameAndColumn(Language
0946: .getInstance().getText("Description"));
0947: }
0948: // testParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0949: // testParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0950:
0951: if (environmentParameterTableModel == null) {
0952: environmentParameterTableModel = new MyTableModel();
0953: environmentParameterTableModel
0954: .addColumnNameAndColumn(Language.getInstance()
0955: .getText("Nom"));
0956: environmentParameterTableModel
0957: .addColumnNameAndColumn(Language.getInstance()
0958: .getText("Valeur"));
0959: environmentParameterTableModel
0960: .addColumnNameAndColumn(Language.getInstance()
0961: .getText("Description"));
0962: }
0963: // environmentParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0964: // environmentParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Valeur"));
0965: // environmentParameterTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0966:
0967: if (actionTableModel == null) {
0968: actionTableModel = new MyTableModel();
0969: actionTableModel.addColumnNameAndColumn(Language
0970: .getInstance().getText("Nom"));
0971: actionTableModel.addColumnNameAndColumn(Language
0972: .getInstance().getText("Description"));
0973: actionTableModel.addColumnNameAndColumn(Language
0974: .getInstance().getText("Résultat_attendu"));
0975: actionTableModel.addColumnNameAndColumn(Language
0976: .getInstance().getText("Attachements"));
0977: }
0978: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
0979: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Description"));
0980: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Résultat_attendu"));
0981: // actionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Attachements"));
0982:
0983: if (executionTableModel == null) {
0984: executionTableModel = new ExecutionTableModel();
0985: executionTableModel.addColumnNameAndColumn("");
0986: executionTableModel.addColumnNameAndColumn(Language
0987: .getInstance().getText("Nom"));
0988: executionTableModel.addColumnNameAndColumn(Language
0989: .getInstance().getText("Environnement"));
0990: executionTableModel.addColumnNameAndColumn(Language
0991: .getInstance().getText("Jeu_de_données"));
0992: executionTableModel.addColumnNameAndColumn(Language
0993: .getInstance().getText("Date_de_création"));
0994: executionTableModel.addColumnNameAndColumn(Language
0995: .getInstance().getText("Attachements"));
0996: executionTableModel.addColumnNameAndColumn(Language
0997: .getInstance().getText("Dernière_Exécution"));
0998: }
0999: // executionTableModel.addColumnNameAndColumn("");
1000: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
1001: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Environnement"));
1002: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Jeu_de_données"));
1003: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Date_de_création"));
1004: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Attachements"));
1005: // executionTableModel.addColumnNameAndColumn(Language.getInstance().getText("Dernière_Exécution"));
1006:
1007: if (executionResultTableModel == null) {
1008: executionResultTableModel = new MyTableModel();
1009: executionResultTableModel.addColumnNameAndColumn(Language
1010: .getInstance().getText("Nom"));
1011: executionResultTableModel.addColumnNameAndColumn(Language
1012: .getInstance().getText("Date"));
1013: executionResultTableModel.addColumnNameAndColumn(Language
1014: .getInstance().getText("Testeur"));
1015: executionResultTableModel.addColumnNameAndColumn(Language
1016: .getInstance().getText("Résultat"));
1017: executionResultTableModel.addColumnNameAndColumn(Language
1018: .getInstance().getText("Statistiques"));
1019: }
1020: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
1021: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Date"));
1022: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Testeur"));
1023: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Résultat"));
1024: // executionResultTableModel.addColumnNameAndColumn(Language.getInstance().getText("Statistiques"));
1025:
1026: if (attachmentTableModel == null) {
1027: attachmentTableModel = new MyTableModel();
1028: attachmentTableModel.addColumnNameAndColumn(Language
1029: .getInstance().getText("Nom"));
1030: attachmentTableModel.addColumnNameAndColumn(Language
1031: .getInstance().getText("Taille"));
1032: attachmentTableModel.addColumnNameAndColumn(Language
1033: .getInstance().getText("Date_de_création"));
1034: }
1035: // attachmentTableModel.addColumnNameAndColumn(Language.getInstance().getText("Nom"));
1036: // attachmentTableModel.addColumnNameAndColumn(Language.getInstance().getText("Taille"));
1037: // attachmentTableModel.addColumnNameAndColumn(Language.getInstance().getText("Date_de_création"));
1038: if (defectTableModel == null) {
1039: defectTableModel = new MyTableModel();
1040: defectTableModel.addColumnNameAndColumn(Language
1041: .getInstance().getText("Exécution"));
1042: defectTableModel.addColumnNameAndColumn(Language
1043: .getInstance().getText("Test"));
1044: defectTableModel.addColumnNameAndColumn("Bug Tracker");
1045: defectTableModel.addColumnNameAndColumn(Language
1046: .getInstance().getText("Anomalies"));
1047: }
1048: }
1049:
1050: /********************************************* Init Data ************************************************************/
1051:
1052: //public static void initDataTests(String p, String userLogin, JApplet applet) {
1053: public static void loadFromBase(String p, String userLogin,
1054: BaseIHM applet) {
1055: setApplet(applet);
1056: //initData();
1057: if (applet.isGraphique()) {
1058: DataLoader.setDataModelWrapper(getInstance());
1059: }
1060: try {
1061: if (DataLoader.dataConnected()) {
1062: if (applet.isGraphique()) {
1063: clearData();
1064: SalomeTMFPanels.getTestDynamicTree().clear();
1065: SalomeTMFPanels.getCampaignDynamicTree().clear();
1066: }
1067: DataLoader.loadData(p, userLogin, SalomeTMFContext
1068: .getInstance().getUrlBase(), true);
1069: currentProject = DataLoader.getCurrentProject();
1070: currentUser = DataLoader.getCurrentUser();
1071: }
1072: } catch (Exception e) {
1073: if (applet.isGraphique()) {
1074: Tools.ihmExceptionView(e);
1075: SalomeTMFContext
1076: .getInstance()
1077: .showMessage(
1078: Language
1079: .getInstance()
1080: .getText(
1081: "Impossible_de_se_connecter_à_la_base_:_on_travaille_en_local_!"),
1082: Language.getInstance().getText(
1083: "Erreur_!"),
1084: JOptionPane.ERROR_MESSAGE);
1085: } else {
1086: e.printStackTrace();
1087: }
1088: }
1089: }
1090:
1091: //public static void refreshFromBase() {
1092: public static void reloadFromBase(boolean dynamicLoad) {
1093: if (Api.isConnected()) {
1094: int transNumber = -1;
1095: try {
1096: transNumber = Api.beginTransaction(111,
1097: ApiConstants.LOADING);
1098: // DATA and IHM
1099: if (applet.isGraphique()) {
1100: clearData();
1101: SalomeTMFPanels.clearTrees();
1102: }
1103: //transNumber = Api.beginTransaction(ApiConstants.LOADING);
1104: DataLoader.reloadData(dynamicLoad);
1105:
1106: //SalomeTMFPanels.getTestMultiUserChangeListenerPanel().reset();
1107: currentProject = DataLoader.getCurrentProject();
1108: currentUser = DataLoader.getCurrentUser();
1109: afterRefresh();
1110: System.gc();
1111: Api.commitTrans(transNumber);
1112: } catch (Exception exception) {
1113: Api.forceRollBackTrans(transNumber);
1114: if (applet.isGraphique()) {
1115: Tools.ihmExceptionView(exception);
1116: } else {
1117: exception.printStackTrace();
1118: }
1119: }
1120: } else {
1121: SalomeTMFContext
1122: .getInstance()
1123: .showMessage(
1124: Language
1125: .getInstance()
1126: .getText(
1127: "Impossible_!\n_Vous_n'êtes_pas_connecté_à_la_base."),
1128: Language.getInstance().getText("Erreur_!"),
1129: JOptionPane.ERROR_MESSAGE);
1130: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
1131: Language.getInstance().getText("Impossible_!\n_Vous_n'êtes_pas_connecté_à_la_base."),
1132: Language.getInstance().getText("Erreur_!"),
1133: JOptionPane.ERROR_MESSAGE);*/
1134: }
1135:
1136: }
1137:
1138: /**
1139: * Méthode qui réinitialise la table des actions pour les tests manuels
1140: */
1141: public static void initActionTable(ManualTest test) {
1142: if (test != null) {
1143: ArrayList actionList = test.getActionListFromModel(false);
1144: if ((actionList != null) && (actionList.size() > 0)) {
1145: actionTableModel.clearTable();
1146: for (int i = 0; i < actionList.size(); i++) {
1147: ArrayList actionParameters = new ArrayList();
1148: actionParameters.add(((Action) actionList.get(i))
1149: .getNameFromModel());
1150: actionParameters.add(((Action) actionList.get(i))
1151: .getDescriptionFromModel());
1152: actionParameters.add(((Action) actionList.get(i))
1153: .getAwaitedResultFromModel());
1154: actionParameters.add(((Action) actionList.get(i))
1155: .getAttachmentMapFromModel().keySet());
1156: actionTableModel.addRow(actionParameters);
1157: }
1158: } else {
1159: actionTableModel.clearTable();
1160: }
1161: }
1162: //.
1163: //setColumnSize(actionTableModel.get);
1164: //setColumnSize(actionParameters.get);
1165: } // Fin de la méthode initActionTable/0
1166:
1167: /**
1168: * M?thode qui initialise les d?tails d'un test pass? en param?tre, ses attachements et ses
1169: * param?tres.
1170: * @param test un test
1171: */
1172: public static void initTest(Test test) {
1173: if (test != null && test instanceof ManualTest) {
1174: /*
1175: SalomeTMFPanels.getManualTestDateLabel().setText(Language.getInstance().getText("Date_de_création_:_") + test.getCreationDateFromModel().toString());
1176: SalomeTMFPanels.getManualTestConceptorLabel().setText(Language.getInstance().getText("Concepteur_:_") + test.getConceptorFromModel());
1177: SalomeTMFPanels.getManualTestNameLabel().setText(Language.getInstance().getText("Nom_du_test_:_") + test.getNameFromModel());
1178: */
1179: SalomeTMFPanels.setTestPanelTestInfo(
1180: DataConstants.MANUAL_TEST, test.getNameFromModel(),
1181: test.getConceptorFromModel(), test
1182: .getCreationDateFromModel().toString());
1183: SalomeTMFPanels.setTestPanelDescription(
1184: DataConstants.MANUAL_TEST, test
1185: .getDescriptionFromModel());
1186: boolean executed = false;
1187: ArrayList campaignList = currentProject
1188: .getCampaignOfTest(test);
1189: if (campaignList != null && campaignList.size() > 0) {
1190: int i = 0;
1191: int size = campaignList.size();
1192: SalomeTMFPanels.getManualTestButtonCampaignDetails()
1193: .setEnabled(true);
1194: while (i < size && !executed) {
1195: Campaign pCampaign = (Campaign) campaignList.get(i);
1196: if (pCampaign.containsExecutionResultInModel()) {
1197: executed = true;
1198: }
1199: i++;
1200: }
1201: } else {
1202: SalomeTMFPanels.getManualTestButtonCampaignDetails()
1203: .setEnabled(false);
1204: }
1205: //SalomeTMFPanels.getManualTestExecutedLabel().setText(Language.getInstance().getText("Exécute") +" : " + executed);
1206: SalomeTMFPanels.setTestPanelTestExecutedInfo(
1207: DataConstants.MANUAL_TEST, "" + executed);
1208: DataModel.initActionTable((ManualTest) test);
1209:
1210: } else if (test != null && test instanceof AutomaticTest) {
1211: /*
1212: * SalomeTMFPanels.getAutomaticTestDateLabel().setText(Language.getInstance().getText("Date_de_création_:_") + test.getCreationDateFromModel().toString());
1213: SalomeTMFPanels.getAutomaticTestConceptorLabel().setText(Language.getInstance().getText("Concepteur_:_") + test.getConceptorFromModel());
1214: SalomeTMFPanels.getAutomaticTestNameLabel().setText(Language.getInstance().getText("Nom_du_test_:_") + test.getNameFromModel());
1215: */
1216: SalomeTMFPanels.setTestPanelTestInfo(
1217: DataConstants.AUTOMATIC_TEST, test
1218: .getNameFromModel(), test
1219: .getConceptorFromModel(), test
1220: .getCreationDateFromModel().toString());
1221: SalomeTMFPanels.setTestPanelDescription(
1222: DataConstants.AUTOMATIC_TEST, test
1223: .getDescriptionFromModel());
1224: boolean executed = false;
1225: ArrayList campaignList = currentProject
1226: .getCampaignOfTest(test);
1227: if (campaignList != null && campaignList.size() > 0) {
1228: int i = 0;
1229: int size = campaignList.size();
1230: SalomeTMFPanels.getAutomaticButtonCampaignDetails()
1231: .setEnabled(true);
1232: while (i < size && !executed) {
1233: Campaign pCampaign = (Campaign) campaignList.get(i);
1234: if (pCampaign.containsExecutionResultInModel()) {
1235: executed = true;
1236: }
1237: i++;
1238: }
1239: } else {
1240: SalomeTMFPanels.getAutomaticButtonCampaignDetails()
1241: .setEnabled(false);
1242: }
1243: //SalomeTMFPanels.getAutomaticTestExecutedLabel().setText(Language.getInstance().getText("Exécute") +" : " + executed);
1244: SalomeTMFPanels.setTestPanelTestExecutedInfo(
1245: DataConstants.AUTOMATIC_TEST, "" + executed);
1246: DataModel.initTestScript((AutomaticTest) test);
1247: }
1248: testParameterTableModel.clearTable();
1249: for (int i = 0; i < test.getParameterListFromModel().size(); i++) {
1250: testParameterTableModel.addValueAt(((Parameter) test
1251: .getParameterListFromModel().get(i))
1252: .getNameFromModel(), i, 0);
1253: testParameterTableModel.addValueAt(((Parameter) test
1254: .getParameterListFromModel().get(i))
1255: .getDescriptionFromModel(), i, 1);
1256: }
1257: initAttachmentTable(test.getAttachmentMapFromModel().values());
1258: } // Fin de la méthode initDetails/1
1259:
1260: /**
1261: * M?thode qui initialise les d?tails de la campagne pass?e en param?tre ainsi que ses ex?cutions
1262: * @param campagne une campagne
1263: */
1264: public static void initCampaign(Campaign campaign) {
1265: /*
1266: * SalomeTMFPanels.getCampaignConceptorLabel().setText(Language.getInstance().getText("Concepteur_:_") + campaign.getConceptorFroModel());
1267: SalomeTMFPanels.getCampaignDateLabel().setText(Language.getInstance().getText("Date_de_création_:_") + campaign.getDateFromModel().toString());
1268: SalomeTMFPanels.getCampaignNameLabel().setText(Language.getInstance().getText("Nom_de_la_campagne_:_") + campaign.getNameFromModel());
1269: */
1270: SalomeTMFPanels.setCampPanelInfo(campaign.getNameFromModel(),
1271: campaign.getConceptorFroModel(), campaign
1272: .getDateFromModel().toString());
1273: SalomeTMFPanels.setCampPanelDescription(DataConstants.CAMPAIGN,
1274: campaign.getDescriptionFromModel());
1275:
1276: dataSetTableModel.clearTable();
1277: for (int i = 0; i < campaign.getDataSetListFromModel().size(); i++) {
1278: dataSetTableModel.addValueAt(((DataSet) campaign
1279: .getDataSetListFromModel().get(i))
1280: .getNameFromModel(), i, 0);
1281: dataSetTableModel.addValueAt(((DataSet) campaign
1282: .getDataSetListFromModel().get(i))
1283: .getDescriptionFromModel(), i, 1);
1284: }
1285: ArrayList executionList = campaign.getExecutionListFromModel();
1286: executionTableModel.clearTable();
1287: if ((executionList != null) && (executionList.size() > 0)) {
1288: for (int i = 0; i < executionList.size(); i++) {
1289: ArrayList executionParameters = new ArrayList();
1290: executionParameters.add(new Boolean(false));
1291: executionParameters.add(((Execution) executionList
1292: .get(i)).getNameFromModel());
1293: executionParameters.add(((Execution) executionList
1294: .get(i)).getEnvironmentFromModel());
1295: executionParameters.add(((Execution) executionList
1296: .get(i)).getDataSetFromModel());
1297: executionParameters.add(((Execution) executionList
1298: .get(i)).getCreationDateFromModel());
1299: executionParameters.add(((Execution) executionList
1300: .get(i)).getAttachmentMapFromModel().keySet());
1301: if (((Execution) executionList.get(i))
1302: .getLastDateFromModel() != null) {
1303: executionParameters.add(((Execution) executionList
1304: .get(i)).getLastDateFromModel().toString());
1305: } else {
1306: executionParameters.add("");
1307: }
1308:
1309: executionTableModel.addRow(executionParameters);
1310: ExecutionView.getTable().getColumnModel().getColumn(0)
1311: .setMaxWidth(18);
1312: }
1313: }
1314: executionResultTableModel.clearTable();
1315: initAttachmentTable(campaign.getAttachmentMapFromModel()
1316: .values());
1317:
1318: } // Fin de la méthode initDetails/1
1319:
1320: /**
1321: * R?initialise la description des familles en fonction de la famille
1322: * pass?e en param?tre
1323: * @param family une famille
1324: */
1325: public static void initFamily(Family family) {
1326: SalomeTMFPanels.setTestPanelDescription(DataConstants.FAMILY,
1327: family.getDescriptionFromModel());
1328: initAttachmentTable(family.getAttachmentMapFromModel().values());
1329: } // Fin de la m?thode initDescription/1
1330:
1331: /**
1332: * R?initialise la description des suites en fonction de la suite pass?e en
1333: * param?tre
1334: * @param list une suite de tests
1335: */
1336: public static void initTestList(TestList list) {
1337: SalomeTMFPanels.setTestPanelDescription(DataConstants.TESTLIST,
1338: list.getDescriptionFromModel());
1339: initAttachmentTable(list.getAttachmentMapFromModel().values());
1340: } // Fin de la m?thode initTestList/1
1341:
1342: public static void initAttachmentTable(Collection col) {
1343: attachmentTableModel.clearTable();
1344: int rowIndex = 0;
1345: for (Iterator iter = col.iterator(); iter.hasNext();) {
1346: Attachment attach = (Attachment) iter.next();
1347: attachmentTableModel.addValueAt(attach.getNameFromModel(),
1348: rowIndex, 0);
1349: if (attach instanceof FileAttachment) {
1350: attachmentTableModel.addValueAt(
1351: ((FileAttachment) attach).getSize().toString(),
1352: rowIndex, 1);
1353: attachmentTableModel.addValueAt(
1354: ((FileAttachment) attach).getDate().toString(),
1355: rowIndex, 2);
1356: } else {
1357: attachmentTableModel.addValueAt("", rowIndex, 1);
1358: attachmentTableModel.addValueAt("", rowIndex, 2);
1359: }
1360: rowIndex++;
1361: }
1362: }
1363:
1364: //********************************** Refresh ***********************************************************//
1365: public static void reloadData() {
1366: DefaultMutableTreeNode selectedNode = SalomeTMFPanels
1367: .getTestDynamicTree().getSelectedNode();
1368: if (selectedNode != null) {
1369: if (selectedNode.getUserObject() instanceof SimpleData) {
1370: try {
1371: reloadData((SimpleData) selectedNode
1372: .getUserObject());
1373: } catch (Exception e) {
1374: // TODO: handle exception
1375: e.printStackTrace();
1376: }
1377: }
1378: }
1379: }
1380:
1381: public static void reloadData(SimpleData data) throws Exception {
1382: int transNumber = -1;
1383: try {
1384: //transNumber = Api.beginTransaction(111, ApiConstants.LOADING);
1385: currentProject.setLoad(true);
1386:
1387: if (data instanceof Family) {
1388: reloadParameters();
1389: reloadFamily((Family) data, true);
1390: } else if (data instanceof TestList) {
1391: reloadParameters();
1392: reloadSuite((TestList) data, true);
1393: } else if (data instanceof Test) {
1394: reloadParameters();
1395: reloadTest((Test) data, true);
1396: } else if (data instanceof Campaign) {
1397: reloadCampaign((Campaign) data);
1398: }
1399:
1400: currentProject.setLoad(false);
1401: //Api.commitTrans(transNumber);
1402:
1403: } catch (Exception e) {
1404: currentProject.setLoad(false);
1405: e.printStackTrace();
1406: //Api.forceRollBackTrans(transNumber);
1407: }
1408: }
1409:
1410: public static void reloadDataPlan() throws Exception {
1411: int transNumber = -1;
1412: try {
1413: //transNumber = Api.beginTransaction(111, ApiConstants.LOADING);
1414: currentProject.setLoad(true);
1415:
1416: reloadParameters();
1417: reloadEnvironnements();
1418: reloadParameters();
1419: reloadEnvironnements();
1420:
1421: currentProject.setLoad(false);
1422: //Api.commitTrans(transNumber);
1423:
1424: } catch (Exception e) {
1425: currentProject.setLoad(false);
1426: e.printStackTrace();
1427: //Api.forceRollBackTrans(transNumber);
1428: throw e;
1429: }
1430: }
1431:
1432: public static void reloadTestPlan() throws Exception {
1433: int transNumber = -1;
1434: try {
1435: //transNumber = Api.beginTransaction(111, ApiConstants.LOADING);
1436: currentProject.setLoad(true);
1437: reloadParameters();
1438:
1439: ArrayList familleInModel = currentProject
1440: .getFamilyListFromModel();
1441: Vector familleInDB = currentProject
1442: .getProjectFamiliesWrapperFromDB();
1443: int sizeModel = familleInModel.size();
1444: int sizeDB = familleInDB.size();
1445: Vector famille2Delete = new Vector();
1446: Vector famille2Add = new Vector();
1447:
1448: for (int i = 0; i < sizeModel; i++) {
1449: Family pFamily = (Family) familleInModel.get(i);
1450: boolean trouve = false;
1451: int j = 0;
1452: while (j < sizeDB && !trouve) {
1453: FamilyWrapper familleDB = (FamilyWrapper) familleInDB
1454: .get(j);
1455: if (pFamily.getIdBdd() == familleDB.getIdBDD()) {
1456: trouve = true;
1457: }
1458: j++;
1459: }
1460: if (!trouve) {
1461: famille2Delete.add(pFamily);
1462: } else {
1463: reloadFamily(pFamily, false);
1464: }
1465: }
1466:
1467: /*Ajout des nouveaux*/
1468: for (int i = 0; i < sizeDB; i++) {
1469: FamilyWrapper familyDB = (FamilyWrapper) familleInDB
1470: .get(i);
1471: Family pFamilyDB = new Family(familyDB);
1472: boolean trouve = false;
1473: int j = 0;
1474: while (j < sizeModel && !trouve) {
1475: Family pFamily = (Family) familleInModel.get(j);
1476: if (familyDB.getIdBDD() == pFamily.getIdBdd()) {
1477: trouve = true;
1478: }
1479: j++;
1480: }
1481: if (!trouve) {
1482: famille2Add.add(pFamilyDB);
1483: }
1484: }
1485:
1486: //DynamicTree testTree = SalomeTMFPanels.getTestDynamicTree();
1487: DefaultMutableTreeNode pParentNode = SalomeTMFPanels
1488: .getTestDynamicTree().getRoot();
1489:
1490: boolean refresh = false;
1491: int size2 = famille2Delete.size();
1492: for (int i = 0; i < size2; i++) {
1493: Family pFamily = (Family) famille2Delete.get(i);
1494: ArrayList campaignList = currentProject
1495: .getCampaignOfFamily(pFamily);
1496: if (campaignList.size() > 0) {
1497: refresh = true;
1498: }
1499: currentProject.deleteFamilyInModel(pFamily);
1500: //IHM
1501: //DefaultMutableTreeNode pSuiteNode = SalomeTMFPanels.getTestDynamicTree().findRemoveTestListNode(pSuite.getNameFromModel(),pFamily.getNameFromModel(), false);
1502: //SalomeTMFPanels.getTestDynamicTree().removeNode(pSuiteNode);
1503:
1504: }
1505:
1506: size2 = famille2Add.size();
1507: for (int i = 0; i < size2; i++) {
1508: Family pFamily = (Family) famille2Add.get(i);
1509: currentProject.addFamilyInModel(pFamily);
1510: SalomeTMFPanels.getTestDynamicTree().addObject(
1511: pParentNode, pFamily, true);
1512: reloadFamily(pFamily, false);
1513: }
1514:
1515: currentProject.triFamilleInModel();
1516: sizeModel = familleInModel.size();
1517: Vector listeNode = new Vector();
1518: for (int i = 0; i < sizeModel; i++) {
1519: Family pFamily = (Family) familleInModel.get(i);
1520: DefaultMutableTreeNode pFamilyNode = SalomeTMFPanels
1521: .getTestDynamicTree().findRemoveFamilyNode(
1522: pFamily.getNameFromModel(), false);
1523: //DefaultMutableTreeNode pSuiteNode = reloadSuite(pSuite, false);
1524: listeNode.add(pFamilyNode);
1525: }
1526: //IHM
1527: SalomeTMFPanels.getTestDynamicTree().removeChildFromNode(
1528: pParentNode);
1529: sizeModel = listeNode.size();
1530: for (int i = 0; i < sizeModel; i++) {
1531: DefaultMutableTreeNode pFamilyNode = (DefaultMutableTreeNode) listeNode
1532: .get(i);
1533: SalomeTMFPanels.getTestDynamicTree().addNode(
1534: pParentNode, pFamilyNode, true);
1535: }
1536:
1537: if (refresh) {
1538: SalomeTMFContext.getInstance().showMessage(
1539: Language.getInstance().getText("Update_data"),
1540: Language.getInstance().getText("Erreur_!"),
1541: JOptionPane.ERROR_MESSAGE);
1542: }
1543:
1544: if (pParentNode != null) {
1545: SalomeTMFPanels.getTestDynamicTree()
1546: .scrollPathToVisible(pParentNode);
1547: }
1548: SalomeTMFPanels.getTestDynamicTree().repaint();
1549: SalomeTMFPanels.setTestPanelWorkSpace(-1);
1550: SalomeTMFPanels.reValidateTestPanel();
1551: currentProject.setLoad(false);
1552: //Api.commitTrans(transNumber);
1553:
1554: } catch (Exception e) {
1555: currentProject.setLoad(false);
1556: e.printStackTrace();
1557: //Api.forceRollBackTrans(transNumber);
1558: throw e;
1559: }
1560:
1561: }
1562:
1563: public static void reloadCampainPlan() throws Exception {
1564: int transNumber = -1;
1565: try {
1566: //transNumber = Api.beginTransaction(111, ApiConstants.LOADING);
1567: currentProject.setLoad(true);
1568: reloadParameters();
1569: reloadEnvironnements();
1570:
1571: ArrayList campagneInModel = currentProject
1572: .getCampaignListFromModel();
1573: Vector campagneInDB = currentProject
1574: .getCampaignsWrapperListFromDB();
1575: int sizeModel = campagneInModel.size();
1576: int sizeDB = campagneInDB.size();
1577: Vector campagne2Delete = new Vector();
1578: Vector campagne2Add = new Vector();
1579:
1580: for (int i = 0; i < sizeModel; i++) {
1581: Campaign pCamp = (Campaign) campagneInModel.get(i);
1582: boolean trouve = false;
1583: int j = 0;
1584: while (j < sizeDB && !trouve) {
1585: CampaignWrapper campagneDB = (CampaignWrapper) campagneInDB
1586: .get(j);
1587: if (pCamp.getIdBdd() == campagneDB.getIdBDD()) {
1588: trouve = true;
1589: }
1590: j++;
1591: }
1592: if (!trouve) {
1593: campagne2Delete.add(pCamp);
1594: } else {
1595: reloadCamp(pCamp, false);
1596: }
1597: }
1598:
1599: /*Ajout des nouveaux*/
1600: for (int i = 0; i < sizeDB; i++) {
1601: CampaignWrapper campagneDB = (CampaignWrapper) campagneInDB
1602: .get(i);
1603: Campaign pCampDB = new Campaign(campagneDB);
1604: boolean trouve = false;
1605: int j = 0;
1606: while (j < sizeModel && !trouve) {
1607: Campaign pCamp = (Campaign) campagneInModel.get(j);
1608: if (campagneDB.getIdBDD() == pCamp.getIdBdd()) {
1609: trouve = true;
1610: }
1611: j++;
1612: }
1613: if (!trouve) {
1614: campagne2Add.add(pCampDB);
1615: }
1616: }
1617:
1618: //DynamicTree testTree = SalomeTMFPanels.getTestDynamicTree();
1619: DefaultMutableTreeNode pParentNode = SalomeTMFPanels
1620: .getCampaignDynamicTree().getRoot();
1621:
1622: boolean refresh = false;
1623: int size2 = campagne2Delete.size();
1624: for (int i = 0; i < size2; i++) {
1625: Campaign pCamp = (Campaign) campagne2Delete.get(i);
1626: currentProject.deleteCampaignInModel(pCamp);
1627: }
1628:
1629: size2 = campagne2Add.size();
1630: for (int i = 0; i < size2; i++) {
1631: Campaign pCamp = (Campaign) campagne2Add.get(i);
1632: currentProject.addCampaignInModel(pCamp);
1633: SalomeTMFPanels.getCampaignDynamicTree().addObject(
1634: pParentNode, pCamp, true);
1635: reloadCamp(pCamp, false);
1636: }
1637:
1638: currentProject.triCampagneInModel();
1639:
1640: sizeModel = campagneInModel.size();
1641: Vector listeNode = new Vector();
1642: for (int i = 0; i < sizeModel; i++) {
1643: Campaign pCamp = (Campaign) campagneInModel.get(i);
1644: DefaultMutableTreeNode pCampNode = SalomeTMFPanels
1645: .getCampaignDynamicTree()
1646: .findRemoveCampaignNode(
1647: pCamp.getNameFromModel(), false);
1648: //DefaultMutableTreeNode pSuiteNode = reloadSuite(pSuite, false);
1649: listeNode.add(pCampNode);
1650: }
1651: //IHM
1652: SalomeTMFPanels.getCampaignDynamicTree()
1653: .removeChildFromNode(pParentNode);
1654: sizeModel = listeNode.size();
1655: for (int i = 0; i < sizeModel; i++) {
1656: DefaultMutableTreeNode pCampNode = (DefaultMutableTreeNode) listeNode
1657: .get(i);
1658: SalomeTMFPanels.getCampaignDynamicTree().addNode(
1659: pParentNode, pCampNode, true);
1660: }
1661:
1662: if (refresh) {
1663: SalomeTMFContext.getInstance().showMessage(
1664: Language.getInstance().getText("Update_data"),
1665: Language.getInstance().getText("Erreur_!"),
1666: JOptionPane.ERROR_MESSAGE);
1667: }
1668:
1669: if (pParentNode != null) {
1670: SalomeTMFPanels.getCampaignDynamicTree()
1671: .scrollPathToVisible(pParentNode);
1672: }
1673: SalomeTMFPanels.getCampaignDynamicTree().repaint();
1674: SalomeTMFPanels.setCampPanelWorkSpace(-1);
1675: SalomeTMFPanels.reValidateCampainPanel();
1676: currentProject.setLoad(false);
1677: //Api.commitTrans(transNumber);
1678:
1679: } catch (Exception e) {
1680: //currentProject.setLoad(false);
1681: e.printStackTrace();
1682: Api.forceRollBackTrans(transNumber);
1683: throw e;
1684: }
1685:
1686: }
1687:
1688: static DefaultMutableTreeNode reloadFamily(Family pFamily,
1689: boolean ihm) throws Exception {
1690: ArrayList suiteInModel = pFamily.getSuiteListFromModel();
1691: Vector suiteInDB = pFamily.getSuitesWrapperFromDB();
1692: int sizeModel = suiteInModel.size();
1693: int sizeDB = suiteInDB.size();
1694: Vector suite2Delete = new Vector();
1695: Vector suite2Add = new Vector();
1696:
1697: pFamily.reloadBaseFromDB();
1698: pFamily.reloadAttachmentDataFromDB(true);
1699:
1700: for (int i = 0; i < sizeModel; i++) {
1701: TestList pSuite = (TestList) suiteInModel.get(i);
1702: boolean trouve = false;
1703: int j = 0;
1704: while (j < sizeDB && !trouve) {
1705: SuiteWrapper suiteDB = (SuiteWrapper) suiteInDB.get(j);
1706: if (pSuite.getIdBdd() == suiteDB.getIdBDD()) {
1707: trouve = true;
1708: }
1709: j++;
1710: }
1711: if (!trouve) {
1712: suite2Delete.add(pSuite);
1713: } else {
1714: reloadSuite(pSuite, false);
1715: }
1716: }
1717:
1718: /*Ajout des nouveaux*/
1719: for (int i = 0; i < sizeDB; i++) {
1720: SuiteWrapper suiteDB = (SuiteWrapper) suiteInDB.get(i);
1721: TestList pSuiteDB = new TestList(suiteDB);
1722: boolean trouve = false;
1723: int j = 0;
1724: while (j < sizeModel && !trouve) {
1725: TestList pSuite = (TestList) suiteInModel.get(j);
1726: if (suiteDB.getIdBDD() == pSuite.getIdBdd()) {
1727: trouve = true;
1728: }
1729: j++;
1730: }
1731: if (!trouve) {
1732: suite2Add.add(pSuiteDB);
1733: }
1734: }
1735:
1736: //DynamicTree testTree = SalomeTMFPanels.getTestDynamicTree();
1737: DefaultMutableTreeNode pFamilyNode = SalomeTMFPanels
1738: .getTestDynamicTree().findRemoveFamilyNode(
1739: pFamily.getNameFromModel(), false);
1740:
1741: boolean refresh = false;
1742: int size2 = suite2Delete.size();
1743: for (int i = 0; i < size2; i++) {
1744: TestList pSuite = (TestList) suite2Delete.get(i);
1745: ArrayList campaignList = currentProject
1746: .getCampaignOfTestList(pSuite);
1747: if (campaignList.size() > 0) {
1748: refresh = true;
1749: }
1750: currentProject.deleteTestListInModel(pSuite);
1751: //IHM
1752: //DefaultMutableTreeNode pSuiteNode = SalomeTMFPanels.getTestDynamicTree().findRemoveTestListNode(pSuite.getNameFromModel(),pFamily.getNameFromModel(), false);
1753: //SalomeTMFPanels.getTestDynamicTree().removeNode(pSuiteNode);
1754:
1755: }
1756:
1757: size2 = suite2Add.size();
1758: for (int i = 0; i < size2; i++) {
1759: TestList pSuite = (TestList) suite2Add.get(i);
1760: currentProject.addTestListInFamilyInModel(pSuite, pFamily);
1761:
1762: SalomeTMFPanels.getTestDynamicTree().addObject(pFamilyNode,
1763: pSuite, true);
1764: reloadSuite(pSuite, false);
1765: }
1766:
1767: pFamily.triTestListInModel();
1768: sizeModel = suiteInModel.size();
1769: Vector listeNode = new Vector();
1770: for (int i = 0; i < sizeModel; i++) {
1771: TestList pSuite = (TestList) suiteInModel.get(i);
1772: DefaultMutableTreeNode pSuiteNode = SalomeTMFPanels
1773: .getTestDynamicTree().findRemoveTestListNode(
1774: pSuite.getNameFromModel(),
1775: pFamily.getNameFromModel(), false);
1776: //DefaultMutableTreeNode pSuiteNode = reloadSuite(pSuite, false);
1777: listeNode.add(pSuiteNode);
1778: }
1779: //IHM
1780: SalomeTMFPanels.getTestDynamicTree().removeChildFromNode(
1781: pFamilyNode);
1782: sizeModel = listeNode.size();
1783: for (int i = 0; i < sizeModel; i++) {
1784: DefaultMutableTreeNode pSuiteNode = (DefaultMutableTreeNode) listeNode
1785: .get(i);
1786: SalomeTMFPanels.getTestDynamicTree().addNode(pFamilyNode,
1787: pSuiteNode, true);
1788: //SalomeTMFPanels.getTestDynamicTree().addObject(pFamilyNode, pSuite, true);
1789: }
1790:
1791: if (refresh && ihm) {
1792: SalomeTMFContext.getInstance().showMessage(
1793: Language.getInstance().getText("Update_data"),
1794: Language.getInstance().getText("Erreur_!"),
1795: JOptionPane.ERROR_MESSAGE);
1796: }
1797:
1798: if (ihm) {
1799: SalomeTMFPanels.getTestDynamicTree().repaint();
1800: DataModel.setCurrentFamily(pFamily);
1801: DataModel.initFamily(pFamily);
1802: SalomeTMFPanels.setTestPanelWorkSpace(DataConstants.FAMILY);
1803: SalomeTMFPanels.reValidateTestPanel();
1804: }
1805: return pFamilyNode;
1806:
1807: }
1808:
1809: static DefaultMutableTreeNode reloadSuite(TestList pSuite,
1810: boolean message) throws Exception {
1811: ArrayList testInModel = pSuite.getTestListFromModel();
1812: Vector testInDB = pSuite.getTestsWrapperFromDB();
1813: int sizeModel = testInModel.size();
1814: int sizeDB = testInDB.size();
1815: Vector test2Delete = new Vector();
1816: Vector test2Add = new Vector();
1817:
1818: pSuite.reloadBaseFromDB();
1819: pSuite.reloadAttachmentDataFromDB(true);
1820:
1821: for (int i = 0; i < sizeModel; i++) {
1822: Test pTest = (Test) testInModel.get(i);
1823: boolean trouve = false;
1824: int j = 0;
1825: while (j < sizeDB && !trouve) {
1826: TestWrapper testDB = (TestWrapper) testInDB.get(j);
1827: if (pTest.getIdBdd() == testDB.getIdBDD()) {
1828: trouve = true;
1829: }
1830: j++;
1831: }
1832: if (!trouve) {
1833: test2Delete.add(pTest);
1834: } else {
1835: pTest.reloadFromDB(true, currentProject
1836: .getParameterSetFromModel(), false);
1837: if (pTest instanceof ManualTest) {
1838: ((ManualTest) pTest).reloadActionFromDB(
1839: currentProject.getParameterSetFromModel(),
1840: true);
1841: }
1842: }
1843: }
1844: /*Ajout des nouveaux*/
1845: for (int i = 0; i < sizeDB; i++) {
1846: TestWrapper testDB = (TestWrapper) testInDB.get(i);
1847: Test test;
1848: if (testDB.getType().equals(ApiConstants.MANUAL)) {
1849: test = new ManualTest(new ManualTestWrapper(testDB));
1850: } else {
1851: test = new AutomaticTest(new AutomaticTestWrapper(
1852: testDB));
1853: }
1854:
1855: boolean trouve = false;
1856: int j = 0;
1857: while (j < sizeModel && !trouve) {
1858: Test pTest = (Test) testInModel.get(j);
1859: if (testDB.getIdBDD() == pTest.getIdBdd()) {
1860: trouve = true;
1861: }
1862: j++;
1863: }
1864: if (!trouve) {
1865: test.reloadFromDB(false, currentProject
1866: .getParameterSetFromModel(), false);
1867: test2Add.add(test);
1868: }
1869: }
1870:
1871: DefaultMutableTreeNode pSuiteNode = SalomeTMFPanels
1872: .getTestDynamicTree().findRemoveTestListNode(
1873: pSuite.getNameFromModel(),
1874: pSuite.getFamilyFromModel().getNameFromModel(),
1875: false);
1876:
1877: int size2 = test2Add.size();
1878: for (int i = 0; i < size2; i++) {
1879: Test pTest = (Test) test2Add.get(i);
1880: currentProject.addTestInListInModel(pTest, pSuite);
1881: //IHM
1882: //SalomeTMFPanels.getTestDynamicTree().addObject(pSuiteNode, pTest,true);
1883: }
1884:
1885: boolean refresh = false;
1886: size2 = test2Delete.size();
1887: for (int i = 0; i < size2; i++) {
1888: Test pTest = (Test) test2Delete.get(i);
1889: ArrayList campaignList = currentProject
1890: .getCampaignOfTest(pTest);
1891: if (campaignList.size() > 0) {
1892: refresh = true;
1893: }
1894: currentProject.deleteTestInModel(pTest);
1895: //IHM
1896: //DefaultMutableTreeNode pTestNode = SalomeTMFPanels.getTestDynamicTree().findRemoveTestNode(pTest.getNameFromModel(),pSuite.getNameFromModel(),pSuite.getFamilyFromModel().getNameFromModel(), false);
1897: //SalomeTMFPanels.getTestDynamicTree().removeNode(pTestNode);
1898: }
1899:
1900: // IHM
1901: //pSuiteNode.removeAllChildren();
1902: if (pSuiteNode != null) {
1903: SalomeTMFPanels.getTestDynamicTree().removeChildFromNode(
1904: pSuiteNode);
1905:
1906: pSuite.triTestInModel();
1907: sizeModel = testInModel.size();
1908: for (int i = 0; i < sizeModel; i++) {
1909: Test pTest = (Test) testInModel.get(i);
1910: SalomeTMFPanels.getTestDynamicTree().addObject(
1911: pSuiteNode, pTest, true);
1912: }
1913: }
1914: /*if (pSuiteNode.getChildCount() == 0){
1915: pSuiteNode.removeFromParent();
1916: }*/
1917:
1918: if (refresh && message) {
1919: SalomeTMFContext.getInstance().showMessage(
1920: Language.getInstance().getText("Update_data"),
1921: Language.getInstance().getText("Erreur_!"),
1922: JOptionPane.ERROR_MESSAGE);
1923: }
1924:
1925: //SalomeTMFPanels.setTestPanelWorkSpace(-1); //remove all
1926: if (message) {
1927: //SalomeTMFPanels.setTestPanelWorkSpace(-1); //remove all
1928: SalomeTMFPanels.getTestDynamicTree().repaint();
1929:
1930: if (pSuiteNode != null) {
1931: SalomeTMFPanels.getTestDynamicTree()
1932: .scrollPathToVisible(pSuiteNode);
1933: }
1934: DataModel.setCurrentTestList(pSuite);
1935: DataModel.initTestList(pSuite);
1936: SalomeTMFPanels
1937: .setTestPanelWorkSpace(DataConstants.TESTLIST);
1938: SalomeTMFPanels.reValidateTestPanel();
1939: }
1940: return pSuiteNode;
1941: }
1942:
1943: static void reloadTest(Test pTest, boolean ihm) throws Exception {
1944: //int transNumber = -1;
1945: try {
1946: //transNumber = Api.beginTransaction(111, ApiConstants.LOADING);
1947: //currentProject.setLoad(true);
1948:
1949: pTest.reloadFromDB(true, currentProject
1950: .getParameterSetFromModel(), false);
1951: if (pTest instanceof ManualTest) {
1952: ((ManualTest) pTest).reloadActionFromDB(currentProject
1953: .getParameterSetFromModel(), true);
1954: }
1955: if (ihm) {
1956: DefaultMutableTreeNode pTestNode = SalomeTMFPanels
1957: .getTestDynamicTree().findRemoveTestNode(
1958: pTest.getNameFromModel(),
1959: pTest.getTestListFromModel()
1960: .getNameFromModel(),
1961: pTest.getTestListFromModel()
1962: .getFamilyFromModel()
1963: .getNameFromModel(), false);
1964: //SalomeTMFPanels.setTestPanelWorkSpace(-1); //remove all
1965: if (pTestNode != null) {
1966: SalomeTMFPanels.getTestDynamicTree()
1967: .scrollPathToVisible(pTestNode);
1968: }
1969: DataModel.setCurrentTest(pTest);
1970: DataModel.initTest(pTest);
1971: if (pTest instanceof ManualTest) {
1972: SalomeTMFPanels
1973: .setTestPanelWorkSpace(DataConstants.MANUAL_TEST);
1974: } else {
1975: SalomeTMFPanels
1976: .setTestPanelWorkSpace(DataConstants.AUTOMATIC_TEST);
1977: }
1978: SalomeTMFPanels.reValidateTestPanel();
1979: }
1980: //currentProject.setLoad(false);
1981:
1982: //Api.commitTrans(transNumber);
1983: } catch (Exception e) {
1984: //Api.forceRollBackTrans(transNumber);
1985: //currentProject.setLoad(false);
1986: SalomeTMFContext.getInstance().showMessage(
1987: Language.getInstance().getText("Update_data"),
1988: Language.getInstance().getText("Erreur_!"),
1989: JOptionPane.ERROR_MESSAGE);
1990: }
1991: }
1992:
1993: public static void reloadEnvironnements() throws Exception {
1994: ArrayList envInModel = currentProject
1995: .getEnvironmentListFromModel();
1996: Vector environmentOfProject = currentProject
1997: .getEnvironmentWrapperFromDB();
1998: int sizeModel = envInModel.size();
1999: int sizeDB = environmentOfProject.size();
2000: Vector env2Delete = new Vector();
2001: Vector env2Add = new Vector();
2002:
2003: for (int i = 0; i < sizeModel; i++) {
2004: Environment pEnv = (Environment) envInModel.get(i);
2005: boolean trouve = false;
2006: int j = 0;
2007: while (j < sizeDB && !trouve) {
2008: EnvironmentWrapper envDB = (EnvironmentWrapper) environmentOfProject
2009: .get(j);
2010: if (pEnv.getIdBdd() == envDB.getIdBDD()) {
2011: trouve = true;
2012: }
2013: j++;
2014: }
2015: if (!trouve) {
2016: env2Delete.add(pEnv);
2017: } else {
2018: pEnv.reloadFromDB(true, currentProject
2019: .getParameterSetFromModel());
2020: }
2021: }
2022:
2023: // Ajout des nouveaux
2024: for (int i = 0; i < sizeDB; i++) {
2025: EnvironmentWrapper envDB = (EnvironmentWrapper) environmentOfProject
2026: .get(i);
2027: Environment env = new Environment(envDB);
2028: boolean trouve = false;
2029: int j = 0;
2030: while (j < sizeModel && !trouve) {
2031: Environment pEnv = (Environment) envInModel.get(j);
2032: if (envDB.getIdBDD() == pEnv.getIdBdd()) {
2033: trouve = true;
2034: }
2035: j++;
2036: }
2037: if (!trouve) {
2038: env.reloadFromDB(false, currentProject
2039: .getParameterSetFromModel());
2040: env2Add.add(env);
2041: }
2042: }
2043:
2044: int size2 = env2Add.size();
2045: for (int i = 0; i < size2; i++) {
2046: Environment pEnv = (Environment) env2Add.get(i);
2047: currentProject.addEnvironmentInModel(pEnv);
2048: }
2049:
2050: boolean refresh = false;
2051: size2 = env2Delete.size();
2052: for (int i = 0; i < size2; i++) {
2053: Environment pEnv = (Environment) env2Delete.get(i);
2054: ArrayList concernedExecutions = currentProject
2055: .getExecutionOfEnvironmentInModel(pEnv
2056: .getNameFromModel());
2057: if (concernedExecutions.size() > 0) {
2058: refresh = true;
2059: }
2060: currentProject.deleteEnvironmentInModel(pEnv);
2061: }
2062: if (refresh) {
2063: SalomeTMFContext.getInstance().showMessage(
2064: Language.getInstance().getText("Update_data"),
2065: Language.getInstance().getText("Erreur_!"),
2066: JOptionPane.ERROR_MESSAGE);
2067: }
2068:
2069: //IHM
2070: envInModel = currentProject.getEnvironmentListFromModel();
2071: sizeModel = envInModel.size();
2072: environmentTableModel.clearTable();
2073: for (int i = 0; i < sizeModel; i++) {
2074: ArrayList data = new ArrayList();
2075: Environment pEnv = (Environment) envInModel.get(i);
2076: data.add(pEnv.getNameFromModel());
2077: String initScriptName = "";
2078: if (pEnv.getInitScriptFromModel() != null) {
2079: initScriptName = pEnv.getInitScriptFromModel()
2080: .getNameFromModel();
2081: }
2082: data.add(initScriptName);
2083: data.add(pEnv.getParametersHashTableFromModel());
2084: data.add(pEnv.getDescriptionFromModel());
2085: environmentTableModel.addRow(data);
2086: }
2087:
2088: }
2089:
2090: public static void reloadProjectAttachement() throws Exception {
2091: currentProject.reloadAttachmentDataFromDB(true);
2092: }
2093:
2094: public static void reloadParameters() throws Exception {
2095: Hashtable projectParamModel = currentProject
2096: .getParameterSetFromModel();
2097: Vector projectParamDB = currentProject
2098: .getParametersWrapperFromDB();
2099: Vector param2Delete = new Vector();
2100: Vector param2Add = new Vector();
2101: int size = projectParamDB.size();
2102:
2103: Enumeration enumParam = projectParamModel.elements();
2104: while (enumParam.hasMoreElements()) {
2105: Parameter pParam = (Parameter) enumParam.nextElement();
2106: boolean trouve = false;
2107: int i = 0;
2108: while (i < size && !trouve) {
2109: ParameterWrapper paramBdd = (ParameterWrapper) projectParamDB
2110: .get(i);
2111: if (paramBdd.getIdBDD() == pParam.getIdBdd()) {
2112: trouve = true;
2113: }
2114: i++;
2115: }
2116: if (!trouve) {
2117: param2Delete.add(pParam);
2118: }
2119: }
2120:
2121: //Ajout des nouveaux
2122: for (int i = 0; i < size; i++) {
2123: ParameterWrapper paramBdd = (ParameterWrapper) projectParamDB
2124: .get(i);
2125: Parameter param = new Parameter(paramBdd);
2126: enumParam = projectParamModel.elements();
2127: boolean trouve = false;
2128: while (enumParam.hasMoreElements() && !trouve) {
2129: Parameter pParam = (Parameter) enumParam.nextElement();
2130: if (paramBdd.getIdBDD() == pParam.getIdBdd()) {
2131: trouve = true;
2132: }
2133: }
2134: if (!trouve) {
2135: param2Add.add(param);
2136: }
2137: }
2138: int size2 = param2Add.size();
2139: for (int i = 0; i < size2; i++) {
2140: Parameter pParam = (Parameter) param2Add.get(i);
2141: currentProject.addParameterToModel(pParam);
2142: }
2143:
2144: //Suppression des parametres
2145: size2 = param2Delete.size();
2146: boolean refresh = false;
2147: for (int i = 0; i < size2; i++) {
2148: Parameter pParam = (Parameter) param2Delete.get(i);
2149: //Si il sont utilisé --> forcer le refresh
2150: ArrayList testsOfParam = DataModel.getCurrentProject()
2151: .getTestOfParameterFromModel(
2152: pParam.getNameFromModel());
2153: ArrayList envOfParam = DataModel.getCurrentProject()
2154: .getEnvironmentOfParameterFromModel(
2155: pParam.getNameFromModel());
2156: if (testsOfParam.size() > 0 || envOfParam.size() > 0) {
2157: refresh = true;
2158: } else {
2159: currentProject.delParamInModel(pParam);
2160: }
2161: }
2162: if (refresh) {
2163: SalomeTMFContext.getInstance().showMessage(
2164: Language.getInstance().getText("Update_data"),
2165: Language.getInstance().getText("Erreur_!"),
2166: JOptionPane.ERROR_MESSAGE);
2167: }
2168:
2169: //IHM
2170: getParameterTableModel().clearTable();
2171: projectParamModel = currentProject.getParameterSetFromModel();
2172: enumParam = projectParamModel.elements();
2173: while (enumParam.hasMoreElements()) {
2174: Parameter pParam = (Parameter) enumParam.nextElement();
2175: ArrayList dataList = new ArrayList();
2176: dataList.add(pParam.getNameFromModel());
2177: dataList.add(pParam.getDescriptionFromModel());
2178: DataModel.getParameterTableModel().addRow(dataList);
2179: }
2180: }
2181:
2182: public static void reloadCampaign(Campaign pCamp) {
2183: Campaign pCampSav = currentCampaign;
2184: currentCampaign = pCamp;
2185: reloadCampaign(false);
2186: currentCampaign = pCampSav;
2187: if (pIAssignedCampAction != null) {
2188: pIAssignedCampAction.updateData(pCamp);
2189: }
2190:
2191: }
2192:
2193: public static void synchronizeCampaign(Campaign pCamp) {
2194: if (pCamp == null) {
2195: return;
2196: }
2197:
2198: if (currentCampaign.containsExecutionResultInModel()) {
2199: if (!Api.isLockExecutedTest()) {
2200: Object[] options = {
2201: Language.getInstance().getText("Oui"),
2202: Language.getInstance().getText("Non") };
2203: int choice = SalomeTMFContext
2204: .getInstance()
2205: .askQuestion(
2206: Language
2207: .getInstance()
2208: .getText(
2209: "Cette_campagne_contient_des_resultat_dexecution_plus_possible_de_les_modifier")
2210: + "\n"
2211: + Language.getInstance()
2212: .getText("continuer"),
2213: Language.getInstance().getText(
2214: "Attention_!"),
2215: JOptionPane.WARNING_MESSAGE, options);
2216: if (choice == JOptionPane.NO_OPTION) {
2217: return;
2218: }
2219: } else {
2220: JOptionPane
2221: .showMessageDialog(
2222: SalomeTMFContext.getInstance()
2223: .getSalomeFrame(),
2224: Language
2225: .getInstance()
2226: .getText(
2227: "Cette_campagne_contient_déjà_des_résultat_d'exécution.\nIl_n'est_plus_possible_de_la_modifier."),
2228: Language.getInstance().getText(
2229: "Erreur_!"),
2230: JOptionPane.ERROR_MESSAGE);
2231: return;
2232: }
2233: }
2234:
2235: try {
2236: DefaultMutableTreeNode pNode = SalomeTMFPanels
2237: .getCampaignDynamicTree().getSelectedNode();
2238: SimpleData pData = null;
2239: if (pNode == null) {
2240: return;
2241: } else {
2242: if (pNode.getParent() == null) {
2243: /*DefaultMutableTreeNode pRoot = SalomeTMFPanels.getCampaignDynamicTree().getRoot();
2244: int nbChild = pRoot.getChildCount();
2245: for (int i = 0; i < nbChild ; i++ ){
2246: pData = ((SimpleData) ((DefaultMutableTreeNode)pRoot.getChildAt(i)).getUserObject());
2247: synchronizeCampaign((Campaign)pData);
2248: }*/
2249: return;
2250: } else {
2251: pData = (SimpleData) pNode.getUserObject();
2252: }
2253:
2254: }
2255:
2256: boolean refresh = pCamp.synchronizeWithTestPlanFromModel(
2257: pData, currentUser.getIdBdd());
2258: if (refresh) {
2259: reloadCamp(pCamp, true);
2260: }
2261: } catch (Exception e) {
2262: Tools.ihmExceptionView(e);
2263: }
2264:
2265: }
2266:
2267: public static void reloadCampaign(boolean all) {
2268: if (all && currentCampaign == null) {
2269: return;
2270: }
2271: try {
2272: reloadParameters();
2273: reloadEnvironnements();
2274: } catch (Exception e) {
2275: e.printStackTrace();
2276: }
2277: ArrayList testInModel = currentProject.getAlltestFromModel();
2278: ArrayList envInModel = currentProject
2279: .getEnvironmentListFromModel();
2280: Hashtable paramInModel = currentProject
2281: .getParameterSetFromModel();
2282: DynamicTree campaignDynamicTree = SalomeTMFPanels
2283: .getCampaignDynamicTree();
2284: ArrayList campList = null;
2285: if (all) {
2286: campList = currentProject.getCampaignListFromModel();
2287: } else {
2288: campList = new ArrayList();
2289: campList.add(currentCampaign);
2290: }
2291: DefaultMutableTreeNode pCampNode = null;
2292: int transNumber = -1;
2293: try {
2294: transNumber = Api.beginTransaction(111,
2295: ApiConstants.LOADING);
2296: currentProject.setLoad(true);
2297:
2298: int size = campList.size();
2299: for (int i = 0; i < size; i++) {
2300: Campaign pCamp = (Campaign) campList.get(i);
2301:
2302: //BDD
2303: boolean reload = pCamp.reloadCampain(testInModel,
2304: envInModel, paramInModel);
2305: pCamp.reloadAttachmentDataFromDB(true);
2306: if (reload) {
2307: SalomeTMFContext.getInstance().showMessage(
2308: Language.getInstance().getText(
2309: "Update_data"),
2310: Language.getInstance().getText("Erreur_!"),
2311: JOptionPane.ERROR_MESSAGE);
2312: i = size;
2313: }
2314:
2315: //IHM
2316: pCampNode = campaignDynamicTree.findRemoveCampaignNode(
2317: pCamp.getNameFromModel(), false);
2318:
2319: campaignDynamicTree.removeChildFromNode(pCampNode);
2320: ArrayList newTestList = pCamp.getTestListFromModel();
2321: Family pCurrentFamily = null;
2322: TestList pCurrentTestList = null;
2323: DefaultMutableTreeNode pFamilyNode = null;
2324: DefaultMutableTreeNode pSuiteNode = null;
2325: //DefaultMutableTreeNode pTestNode = null;
2326: int size2 = newTestList.size();
2327: for (int j = 0; j < size2; j++) {
2328: Test pTest = (Test) newTestList.get(j);
2329: TestList pTestList = pTest.getTestListFromModel();
2330: Family pFamily = pTestList.getFamilyFromModel();
2331: if (!pFamily.equals(pCurrentFamily)) {
2332: pFamilyNode = campaignDynamicTree
2333: .findRemoveFamilyNodeInCampagneTree(
2334: pFamily.getNameFromModel(),
2335: pCamp.getNameFromModel(), false);
2336: if (pFamilyNode == null) {
2337: pFamilyNode = campaignDynamicTree
2338: .addObject(pCampNode, pFamily, true);
2339: }
2340: pCurrentFamily = pFamily;
2341: }
2342: if (!pTestList.equals(pCurrentTestList)) {
2343: pSuiteNode = campaignDynamicTree
2344: .findRemoveTestListNodeInCampagneTree(
2345: pTestList.getNameFromModel(),
2346: pFamily.getNameFromModel(),
2347: pCamp.getNameFromModel(), false);
2348: if (pSuiteNode == null) {
2349: pSuiteNode = campaignDynamicTree.addObject(
2350: pFamilyNode, pTestList, true);
2351: }
2352: pCurrentTestList = pTestList;
2353: }
2354: SalomeTMFPanels.getCampaignDynamicTree().addObject(
2355: pSuiteNode, pTest, true);
2356:
2357: }
2358:
2359: }
2360:
2361: currentProject.setLoad(false);
2362:
2363: Api.commitTrans(transNumber);
2364: } catch (Exception exception) {
2365: Api.forceRollBackTrans(transNumber);
2366: currentProject.setLoad(false);
2367: exception.printStackTrace();
2368: Tools.ihmExceptionView(exception);
2369: SalomeTMFContext.getInstance().showMessage(
2370: Language.getInstance().getText("Update_data"),
2371: Language.getInstance().getText("Erreur_!"),
2372: JOptionPane.ERROR_MESSAGE);
2373: return;
2374: }
2375: if (pCampNode != null) {
2376: campaignDynamicTree.scrollPathToVisible(pCampNode);
2377: DataModel.setCurrentCampaign((Campaign) pCampNode
2378: .getUserObject());
2379: DataModel
2380: .initCampaign((Campaign) pCampNode.getUserObject());
2381: SalomeTMFPanels
2382: .setCampPanelWorkSpace(DataConstants.CAMPAIGN);
2383: SalomeTMFPanels.reValidateCampainPanel();
2384: }
2385: campaignDynamicTree.repaint();
2386: }
2387:
2388: static DefaultMutableTreeNode reloadCamp(Campaign pCamp, boolean ihm)
2389: throws Exception {
2390: DefaultMutableTreeNode pCampNode = null;
2391: ArrayList testInModel = currentProject.getAlltestFromModel();
2392: ArrayList envInModel = currentProject
2393: .getEnvironmentListFromModel();
2394: Hashtable paramInModel = currentProject
2395: .getParameterSetFromModel();
2396: DynamicTree campaignDynamicTree = SalomeTMFPanels
2397: .getCampaignDynamicTree();
2398: // BDD
2399: boolean reload = pCamp.reloadCampain(testInModel, envInModel,
2400: paramInModel);
2401: pCamp.reloadAttachmentDataFromDB(true);
2402: if (reload && ihm) {
2403: SalomeTMFContext.getInstance().showMessage(
2404: Language.getInstance().getText("Update_data"),
2405: Language.getInstance().getText("Erreur_!"),
2406: JOptionPane.ERROR_MESSAGE);
2407: }
2408:
2409: //IHM
2410: pCampNode = campaignDynamicTree.findRemoveCampaignNode(pCamp
2411: .getNameFromModel(), false);
2412:
2413: campaignDynamicTree.removeChildFromNode(pCampNode);
2414: ArrayList newTestList = pCamp.getTestListFromModel();
2415: Family pCurrentFamily = null;
2416: TestList pCurrentTestList = null;
2417: DefaultMutableTreeNode pFamilyNode = null;
2418: DefaultMutableTreeNode pSuiteNode = null;
2419: //DefaultMutableTreeNode pTestNode = null;
2420: int size2 = newTestList.size();
2421: for (int j = 0; j < size2; j++) {
2422: Test pTest = (Test) newTestList.get(j);
2423: TestList pTestList = pTest.getTestListFromModel();
2424: Family pFamily = pTestList.getFamilyFromModel();
2425: if (!pFamily.equals(pCurrentFamily)) {
2426: pFamilyNode = campaignDynamicTree
2427: .findRemoveFamilyNodeInCampagneTree(pFamily
2428: .getNameFromModel(), pCamp
2429: .getNameFromModel(), false);
2430: if (pFamilyNode == null) {
2431: pFamilyNode = campaignDynamicTree.addObject(
2432: pCampNode, pFamily, true);
2433: }
2434: pCurrentFamily = pFamily;
2435: }
2436: if (!pTestList.equals(pCurrentTestList)) {
2437: pSuiteNode = campaignDynamicTree
2438: .findRemoveTestListNodeInCampagneTree(pTestList
2439: .getNameFromModel(), pFamily
2440: .getNameFromModel(), pCamp
2441: .getNameFromModel(), false);
2442: if (pSuiteNode == null) {
2443: pSuiteNode = campaignDynamicTree.addObject(
2444: pFamilyNode, pTestList, true);
2445: }
2446: pCurrentTestList = pTestList;
2447: }
2448: SalomeTMFPanels.getCampaignDynamicTree().addObject(
2449: pSuiteNode, pTest, true);
2450: }
2451: return pCampNode;
2452: }
2453:
2454: //********************************** Delete in tree ****************************************************//
2455:
2456: /**
2457: * Méthode de suppression de tests, suites de tests, familles ou campagnes.
2458: * @return vrai si la suppression s'est correctement deroulee, faux sinon.
2459: */
2460: public static boolean deleteInTestTree() {
2461: DefaultMutableTreeNode selectedNode = SalomeTMFPanels
2462: .getTestDynamicTree().getSelectedNode();
2463:
2464: boolean result = true;
2465: if (selectedNode == null) {
2466: return result;
2467: }
2468:
2469: Object[] options = { Language.getInstance().getText("Oui"),
2470: Language.getInstance().getText("Non") };
2471: int choice = -1;
2472: int actionCase = -1;
2473: String message = "";
2474: ArrayList campaignList = new ArrayList();
2475: Vector reqManagers = SalomeTMFContext.getInstance()
2476: .getReqManagers();
2477:
2478: if ((selectedNode.getUserObject() instanceof Test)) {
2479: campaignList = currentProject
2480: .getCampaignOfTest((Test) selectedNode
2481: .getUserObject());
2482: if (campaignList.size() > 0) {
2483: message = Language.getInstance().getText("Le_test_<_")
2484: + ((Test) selectedNode.getUserObject())
2485: .getNameFromModel()
2486: + Language
2487: .getInstance()
2488: .getText(
2489: "_>_est_utilisé_dans_les_campagnes_:\n");
2490: for (int i = 0; i < campaignList.size(); i++) {
2491: message = message
2492: + "* "
2493: + ((Campaign) campaignList.get(i))
2494: .getNameFromModel() + "\n";
2495: }
2496: message = message
2497: + Language
2498: .getInstance()
2499: .getText(
2500: "Le_test_sera_purgé_des_résultats_d'exécution_de_ces_campagnes_\n");
2501: }
2502: choice = SalomeTMFContext
2503: .getInstance()
2504: .askQuestion(
2505: message
2506: + Language
2507: .getInstance()
2508: .getText(
2509: "Etes_vous_sûr_de_vouloir_supprimer_le_test_<_")
2510: + ((Test) selectedNode
2511: .getUserObject())
2512: .getNameFromModel()
2513: + " > ?",
2514: Language.getInstance().getText(
2515: "Attention_!"),
2516: JOptionPane.WARNING_MESSAGE, options);
2517:
2518: /*choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2519: message + Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_le_test_<_") + ((Test)selectedNode.getUserObject()).getNameFromModel() + " > ?",
2520: Language.getInstance().getText("Attention_!"),
2521: JOptionPane.YES_NO_OPTION,
2522: JOptionPane.WARNING_MESSAGE,
2523: null,
2524: options,
2525: options[1]);
2526: */
2527: actionCase = TEST;
2528: } else if (selectedNode.getUserObject() instanceof TestList) {
2529: campaignList = currentProject
2530: .getCampaignOfTestList((TestList) selectedNode
2531: .getUserObject());
2532: if (campaignList.size() > 0) {
2533: message = Language.getInstance().getText(
2534: "La_suite_de_tests_<_")
2535: + ((TestList) selectedNode.getUserObject())
2536: .getNameFromModel()
2537: + Language
2538: .getInstance()
2539: .getText(
2540: "_>_est_utilisée_dans_les_campagnes_:\n");
2541: for (int i = 0; i < campaignList.size(); i++) {
2542: message = message
2543: + "* "
2544: + ((Campaign) campaignList.get(i))
2545: .getNameFromModel() + "\n";
2546: }
2547: message = message
2548: + Language
2549: .getInstance()
2550: .getText(
2551: "Les_tests_de_la_suite_seront_purgés_des_résultats_d'exécution_de_ces_campagnes_\n");
2552: }
2553: choice = SalomeTMFContext
2554: .getInstance()
2555: .askQuestion(
2556: message
2557: + Language
2558: .getInstance()
2559: .getText(
2560: "Etes_vous_sûr_de_vouloir_supprimer_la_suite_<_")
2561: + ((TestList) selectedNode
2562: .getUserObject())
2563: .getNameFromModel()
2564: + " > ?",
2565: Language.getInstance().getText(
2566: "Attention_!"),
2567: JOptionPane.WARNING_MESSAGE, options);
2568:
2569: /*choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2570: message + Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_la_suite_<_") + ((TestList)selectedNode.getUserObject()).getNameFromModel() +" > ?",
2571: Language.getInstance().getText("Attention_!"),
2572: JOptionPane.YES_NO_OPTION,
2573: JOptionPane.WARNING_MESSAGE,
2574: null,
2575: options,
2576: options[1]);
2577: */
2578: actionCase = TESTLIST;
2579: } else if (selectedNode.getUserObject() instanceof Family) {
2580: campaignList = currentProject
2581: .getCampaignOfFamily((Family) selectedNode
2582: .getUserObject());
2583: if (campaignList.size() > 0) {
2584: message = Language.getInstance().getText(
2585: "La_famille_<_")
2586: + ((Family) selectedNode.getUserObject())
2587: .getNameFromModel()
2588: + Language
2589: .getInstance()
2590: .getText(
2591: "_>_est_utilisée_dans_les_campagnes_:\n");
2592: for (int i = 0; i < campaignList.size(); i++) {
2593: /*if (((Campaign)campaignList.get(i)).getTestListList().size() == 1) {
2594: toBeDelete = "* " + ((Campaign)campaignList.get(i)).getName() + "\n";
2595: }*/
2596: message = message
2597: + "* "
2598: + ((Campaign) campaignList.get(i))
2599: .getNameFromModel() + "\n";
2600: }
2601: //message = message + "Parmi celles-ci seront supprim?es :\n" + toBeDelete + "car elles ne contiennent que ce test.\n\n";
2602: message = message
2603: + Language
2604: .getInstance()
2605: .getText(
2606: "Les_tests_de_la_famille_seront_purgés_des_résultats_d'exécution_de_ces_campagnes_\n");
2607: }
2608: choice = SalomeTMFContext
2609: .getInstance()
2610: .askQuestion(
2611: message
2612: + Language
2613: .getInstance()
2614: .getText(
2615: "Etes_vous_sûr_de_vouloir_supprimer_la_famille_<_")
2616: + ((Family) selectedNode
2617: .getUserObject())
2618: .getNameFromModel()
2619: + " > ?",
2620: Language.getInstance().getText(
2621: "Attention_!"),
2622: JOptionPane.WARNING_MESSAGE, options);
2623:
2624: /*
2625: choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2626: message + Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_la_famille_<_") + ((Family)selectedNode.getUserObject()).getNameFromModel() + " > ?",
2627: Language.getInstance().getText("Attention_!"),
2628: JOptionPane.YES_NO_OPTION,
2629: JOptionPane.WARNING_MESSAGE,
2630: null,
2631: options,
2632: options[1]);
2633: */
2634: actionCase = FAMILY;
2635: }
2636:
2637: if (choice == JOptionPane.YES_OPTION) {
2638: // LE CAS DES TESTS
2639: SalomeTMFPanels.getTestDynamicTree().getTree().setCursor(
2640: new Cursor(Cursor.WAIT_CURSOR));
2641:
2642: boolean deleted = false;
2643: if (actionCase == TEST) {
2644: try {
2645: // Delete req links
2646: /*if (reqManagers!=null && reqManagers.size() != 0) {
2647: for (int i=0; i<reqManagers.size(); i++) {
2648: ReqManager req = (ReqManager)reqManagers.elementAt(i);
2649: req.deleteReqLinkWithTest(((Test)selectedNode.getUserObject()).getIdBdd());
2650: }
2651: }*/
2652:
2653: //BDD & DATA
2654: currentProject
2655: .deleteTestInDBandModel(((Test) selectedNode
2656: .getUserObject()));
2657: deleted = true;
2658:
2659: //IHM
2660: for (int j = 0; j < campaignList.size(); j++) {
2661: // Suppression en cascade dans l'arbre des campagnes
2662: DefaultMutableTreeNode testNodeInCampaignTree = SalomeTMFPanels
2663: .getCampaignDynamicTree()
2664: .findRemoveTestNodeInCampagneTree(
2665: ((Test) selectedNode
2666: .getUserObject())
2667: .getNameFromModel(),
2668: ((Test) selectedNode
2669: .getUserObject())
2670: .getTestListFromModel()
2671: .getNameFromModel(),
2672: ((Test) selectedNode
2673: .getUserObject())
2674: .getTestListFromModel()
2675: .getFamilyFromModel()
2676: .getNameFromModel(),
2677: ((Campaign) campaignList.get(j))
2678: .getNameFromModel(),
2679: false);
2680: DefaultMutableTreeNode testListParent = (DefaultMutableTreeNode) testNodeInCampaignTree
2681: .getParent();
2682: SalomeTMFPanels.getCampaignDynamicTree()
2683: .removeNode(testNodeInCampaignTree);
2684: if (testListParent.getChildCount() == 0) {
2685: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListParent
2686: .getParent();
2687: SalomeTMFPanels.getCampaignDynamicTree()
2688: .removeNode(testListParent);
2689: if (familyParent.getChildCount() == 0) {
2690: SalomeTMFPanels
2691: .getCampaignDynamicTree()
2692: .removeNode(familyParent);
2693: }
2694: }
2695: // on nettoie la table des résultats des exécutions si la campagne
2696: //traitée est selectionnée dans l'arbre des campagnes
2697: if ((SalomeTMFPanels.getCampaignDynamicTree()
2698: .getSelectedNode()) != null
2699: && (SalomeTMFPanels
2700: .getCampaignDynamicTree()
2701: .getSelectedNode())
2702: .getUserObject() instanceof Campaign
2703: && ((Campaign) (SalomeTMFPanels
2704: .getCampaignDynamicTree()
2705: .getSelectedNode())
2706: .getUserObject())
2707: .equals((campaignList.get(j)))) {
2708: executionResultTableModel.clearTable();
2709: //TestData.getExecutionTableModel().clearTable();
2710: }
2711:
2712: }
2713:
2714: } catch (Exception exception) {
2715: exception.printStackTrace();
2716: if (deleted) {
2717: // Erreur au niveau de L'IHM -> faire un reload
2718: reloadFromBase(true);
2719: result = true;
2720: } else {
2721: // Erreur au niveau BDD
2722: result = false;
2723: Tools.ihmExceptionView(exception);
2724: }
2725: }
2726: //LE CAS DES FAMILLES
2727: } else if (actionCase == FAMILY) {
2728: try {
2729: // // Delete req links
2730: /*Family family = (Family)selectedNode.getUserObject();
2731: ArrayList testLists = family.getSuiteListFromModel();
2732: for (int j=0; j<testLists.size(); j++) {
2733: TestList testList = (TestList)testLists.get(j);
2734: ArrayList tests = testList.getTestListFromModel();
2735: for (int k=0; k<tests.size(); k++) {
2736: Test test = (Test)tests.get(k);
2737: if (reqManagers!=null && reqManagers.size() != 0) {
2738: for (int i=0; i<reqManagers.size(); i++) {
2739: ReqManager req = (ReqManager)reqManagers.elementAt(i);
2740: req.deleteReqLinkWithTest(test.getIdBdd());
2741: }
2742: }
2743: }
2744: }*/
2745:
2746: // BDD & DATA
2747: currentProject
2748: .deleteFamilyInDBAndModel((Family) selectedNode
2749: .getUserObject());
2750: deleted = true;
2751:
2752: // IHM
2753: for (int j = 0; j < campaignList.size(); j++) {
2754: // Nettoyage de l'arbre des campagnes
2755: DefaultMutableTreeNode familyNodeInCampaignTree = SalomeTMFPanels
2756: .getCampaignDynamicTree()
2757: .findRemoveFamilyNodeInCampagneTree(
2758: ((Family) selectedNode
2759: .getUserObject())
2760: .getNameFromModel(),
2761: ((Campaign) campaignList.get(j))
2762: .getNameFromModel(),
2763: false);
2764: SalomeTMFPanels.getCampaignDynamicTree()
2765: .removeNode(familyNodeInCampaignTree);
2766: // on nettoie la table des résultats des exécutions si la campagne
2767: //traitée est sélectionnée dans l'abre des campagnes
2768: if ((SalomeTMFPanels.getCampaignDynamicTree()
2769: .getSelectedNode()) != null
2770: && (SalomeTMFPanels
2771: .getCampaignDynamicTree()
2772: .getSelectedNode())
2773: .getUserObject() instanceof Campaign
2774: && ((Campaign) (SalomeTMFPanels
2775: .getCampaignDynamicTree()
2776: .getSelectedNode())
2777: .getUserObject())
2778: .equals((campaignList.get(j)))) {
2779: getExecutionResultTableModel().clearTable();
2780: //TestData.getExecutionTableModel().clearTable();
2781: }
2782: }
2783:
2784: } catch (Exception exception) {
2785: if (deleted) {
2786: //Erreur au niveau de L'IHM -> faire un reload
2787: reloadFromBase(true);
2788: result = true;
2789: } else {
2790: result = false;
2791: Tools.ihmExceptionView(exception);
2792: }
2793: }
2794: } else {
2795: try {
2796: // Delete req links
2797: /*TestList testList = (TestList)selectedNode.getUserObject();
2798: ArrayList tests = testList.getTestListFromModel();
2799: for (int k=0; k<tests.size(); k++) {
2800: Test test = (Test)tests.get(k);
2801: if (reqManagers!=null && reqManagers.size() != 0) {
2802: for (int i=0; i<reqManagers.size(); i++) {
2803: ReqManager req = (ReqManager)reqManagers.elementAt(i);
2804: req.deleteReqLinkWithTest(test.getIdBdd());
2805: }
2806: }
2807: }*/
2808:
2809: // DB
2810: currentProject
2811: .deleteTestListInDBandModel((TestList) selectedNode
2812: .getUserObject());
2813: deleted = true;
2814:
2815: // IHM
2816: for (int j = 0; j < campaignList.size(); j++) {
2817:
2818: // Nettoyage de l'arbre des campagnes
2819: DefaultMutableTreeNode testListNodeInCampaignTree = SalomeTMFPanels
2820: .getCampaignDynamicTree()
2821: .findRemoveTestListNodeInCampagneTree(
2822: ((TestList) selectedNode
2823: .getUserObject())
2824: .getNameFromModel(),
2825: ((TestList) selectedNode
2826: .getUserObject())
2827: .getFamilyFromModel()
2828: .getNameFromModel(),
2829: ((Campaign) campaignList.get(j))
2830: .getNameFromModel(),
2831: false);
2832: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListNodeInCampaignTree
2833: .getParent();
2834: SalomeTMFPanels.getCampaignDynamicTree()
2835: .removeNode(testListNodeInCampaignTree);
2836: if (familyParent.getChildCount() == 0) {
2837: SalomeTMFPanels.getCampaignDynamicTree()
2838: .removeNode(familyParent);
2839: }
2840: // on nettoie la table des r?sultats des executions si la campagne
2841: //traitee est selectionnee dans l'abre des campagnes
2842: if ((SalomeTMFPanels.getCampaignDynamicTree()
2843: .getSelectedNode()) != null
2844: && (SalomeTMFPanels
2845: .getCampaignDynamicTree()
2846: .getSelectedNode())
2847: .getUserObject() instanceof Campaign
2848: && ((Campaign) (SalomeTMFPanels
2849: .getCampaignDynamicTree()
2850: .getSelectedNode())
2851: .getUserObject())
2852: .equals((campaignList.get(j)))) {
2853: executionResultTableModel.clearTable();
2854: //TestData.getExecutionTableModel().clearTable();
2855: }
2856:
2857: }
2858:
2859: } catch (Exception exception) {
2860: if (deleted) {
2861: //Erreur au niveau de L'IHM -> faire un reload
2862: reloadFromBase(true);
2863: result = true;
2864: } else {
2865: result = false;
2866: Tools.ihmExceptionView(exception);
2867: }
2868: }
2869: }
2870: if (deleted) {
2871: SalomeTMFPanels.setTestPanelWorkSpace(-1); //remove all
2872: SalomeTMFPanels.getTestDynamicTree()
2873: .removeCurrentNode();
2874: SalomeTMFPanels.getDelTestOrTestList()
2875: .setEnabled(false);
2876: SalomeTMFPanels.reValidateTestPanel();
2877: }
2878: SalomeTMFPanels.getTestDynamicTree().getTree().setCursor(
2879: new Cursor(Cursor.DEFAULT_CURSOR));
2880: }
2881:
2882: return result;
2883: } // Fin de la methode deleteReally/0
2884:
2885: /**
2886: * Methode de suppression de tests, suites de tests, familles ou campagnes
2887: * de l'arbre des campagnes.
2888: * @return vrai si la suppression s'est correctement deroulee, faux sinon.
2889: */
2890: public static boolean deleteInCampaignTree() {
2891: DefaultMutableTreeNode selectedNode;
2892: boolean result = true;
2893: boolean isCampEmpty = false;
2894: boolean deleted = false;
2895:
2896: selectedNode = SalomeTMFPanels.getCampaignDynamicTree()
2897: .getSelectedNode();
2898: if (selectedNode == null) {
2899: return true;
2900: }
2901: Object[] options = { Language.getInstance().getText("Oui"),
2902: Language.getInstance().getText("Non") };
2903: int choice = -1;
2904: int actionCase = -1;
2905: if ((selectedNode.getUserObject() instanceof Test)) {
2906: choice = SalomeTMFContext
2907: .getInstance()
2908: .askQuestion(
2909: Language
2910: .getInstance()
2911: .getText(
2912: "Etes_vous_sûr_de_vouloir_supprimer_le_test_<")
2913: + ((Test) selectedNode
2914: .getUserObject())
2915: .getNameFromModel()
2916: + Language.getInstance().getText(
2917: ">_de_cette_campagne_?"),
2918: Language.getInstance().getText(
2919: "Attention_!"),
2920: JOptionPane.QUESTION_MESSAGE, options);
2921:
2922: /*choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2923: Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_le_test_<") + ((Test)selectedNode.getUserObject()).getNameFromModel() + Language.getInstance().getText(">_de_cette_campagne_?"),
2924: Language.getInstance().getText("Attention_!"),
2925: JOptionPane.YES_NO_OPTION,
2926: JOptionPane.QUESTION_MESSAGE,
2927: null,
2928: options,
2929: options[1]);*/
2930: actionCase = TEST;
2931: } else if (selectedNode.getUserObject() instanceof TestList) {
2932: choice = SalomeTMFContext
2933: .getInstance()
2934: .askQuestion(
2935: Language
2936: .getInstance()
2937: .getText(
2938: "Etes_vous_sûr_de_vouloir_supprimer_la_suite_<")
2939: + ((TestList) selectedNode
2940: .getUserObject())
2941: .getNameFromModel()
2942: + Language.getInstance().getText(
2943: ">_de_cette_campagne_?"),
2944: Language.getInstance().getText(
2945: "Attention_!"),
2946: JOptionPane.QUESTION_MESSAGE, options);
2947: /*choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2948: Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_la_suite_<") + ((TestList)selectedNode.getUserObject()).getNameFromModel()+ Language.getInstance().getText(">_de_cette_campagne_?"),
2949: Language.getInstance().getText("Attention_!"),
2950: JOptionPane.YES_NO_OPTION,
2951: JOptionPane.QUESTION_MESSAGE,
2952: null,
2953: options,
2954: options[1]);*/
2955: actionCase = TESTLIST;
2956: } else if (selectedNode.getUserObject() instanceof Family) {
2957: choice = SalomeTMFContext
2958: .getInstance()
2959: .askQuestion(
2960: Language
2961: .getInstance()
2962: .getText(
2963: "Etes_vous_sûr_de_vouloir_supprimer_la_famille_<")
2964: + ((Family) selectedNode
2965: .getUserObject())
2966: .getNameFromModel()
2967: + Language.getInstance().getText(
2968: ">_de_cette_campagne_?"),
2969: Language.getInstance().getText(
2970: "Attention_!"),
2971: JOptionPane.QUESTION_MESSAGE, options);
2972:
2973: /*choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2974: Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_la_famille_<") + ((Family)selectedNode.getUserObject()).getNameFromModel()+ Language.getInstance().getText(">_de_cette_campagne_?"),
2975: Language.getInstance().getText("Attention_!"),
2976: JOptionPane.YES_NO_OPTION,
2977: JOptionPane.QUESTION_MESSAGE,
2978: null,
2979: options,
2980: options[1]);
2981: */
2982: actionCase = FAMILY;
2983: } else if (selectedNode.getUserObject() instanceof Campaign) {
2984: choice = SalomeTMFContext
2985: .getInstance()
2986: .askQuestion(
2987: Language
2988: .getInstance()
2989: .getText(
2990: "Etes_vous_sûr_de_vouloir_supprimer_la_campagne_<")
2991: + ((Campaign) selectedNode
2992: .getUserObject())
2993: .getNameFromModel() + "> ?",
2994: Language.getInstance().getText(
2995: "Attention_!"),
2996: JOptionPane.QUESTION_MESSAGE, options);
2997:
2998: /*choice = JOptionPane.showOptionDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
2999: Language.getInstance().getText("Etes_vous_sûr_de_vouloir_supprimer_la_campagne_<") + ((Campaign)selectedNode.getUserObject()).getNameFromModel() + "> ?",
3000: Language.getInstance().getText("Attention_!"),
3001: JOptionPane.YES_NO_OPTION,
3002: JOptionPane.QUESTION_MESSAGE,
3003: null,
3004: options,
3005: options[1]);*/
3006: actionCase = CAMPAIGN;
3007: }
3008:
3009: if (choice == JOptionPane.YES_OPTION) {
3010: if (actionCase == CAMPAIGN) {
3011: try {
3012: // BdD
3013: currentProject
3014: .deleteCampaignInDBAndModel((Campaign) selectedNode
3015: .getUserObject());
3016: deleted = true;
3017:
3018: //Model
3019: setCurrentCampaign(null);
3020: SalomeTMFPanels.setCampPanelWorkSpace(-1);
3021: SalomeTMFPanels.getAddTestInCampagne().setEnabled(
3022: false);
3023: SalomeTMFPanels.getOrderCampagne()
3024: .setEnabled(false);
3025: SalomeTMFPanels.getDelCampagne().setEnabled(false);
3026: SalomeTMFPanels.reValidateCampainPanel();
3027: SalomeTMFPanels.getCampaignDynamicTree()
3028: .removeCurrentNode();
3029:
3030: } catch (Exception exception) {
3031: if (deleted) {
3032: //Erreur au niveau de L'IHM -> faire un reload
3033: reloadFromBase(true);
3034: result = true;
3035: } else {
3036: Tools.ihmExceptionView(exception);
3037: result = false;
3038: }
3039: }
3040: } else {
3041: if (actionCase == TEST) {
3042: try {
3043: // BDD and Model
3044: isCampEmpty = currentProject
3045: .deleteTestFromCampaignInDBAndModel(
3046: (Test) selectedNode
3047: .getUserObject(),
3048: currentCampaign);
3049: deleted = true;
3050:
3051: // IHM
3052: DefaultMutableTreeNode testListParent = (DefaultMutableTreeNode) selectedNode
3053: .getParent();
3054: SalomeTMFPanels.getCampaignDynamicTree()
3055: .removeNode(selectedNode);
3056: if (testListParent.getChildCount() == 0) {
3057: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) testListParent
3058: .getParent();
3059: SalomeTMFPanels.getCampaignDynamicTree()
3060: .removeNode(testListParent);
3061: if (familyParent.getChildCount() == 0) {
3062: SalomeTMFPanels
3063: .getCampaignDynamicTree()
3064: .removeNode(familyParent);
3065: }
3066: }
3067: } catch (Exception exception) {
3068: if (deleted) {
3069: //Erreur au niveau de L'IHM -> faire un reload
3070: reloadFromBase(true);
3071: result = true;
3072: } else {
3073: Tools.ihmExceptionView(exception);
3074: result = false;
3075: }
3076: }
3077:
3078: } else if (actionCase == FAMILY) {
3079: try {
3080: // BdD
3081: isCampEmpty = currentProject
3082: .deleteFamilyFromCampaignInDBAndModel(
3083: (Family) selectedNode
3084: .getUserObject(),
3085: currentCampaign);
3086: deleted = true;
3087:
3088: // IHM
3089: SalomeTMFPanels.getCampaignDynamicTree()
3090: .removeCurrentNode();
3091: } catch (Exception exception) {
3092: if (deleted) {
3093: //Erreur au niveau de L'IHM -> faire un reload
3094: reloadFromBase(true);
3095: result = true;
3096: } else {
3097: Tools.ihmExceptionView(exception);
3098: result = false;
3099: }
3100: }
3101: } else {
3102: try {
3103: // BDD and Model
3104: isCampEmpty = currentProject
3105: .deleteTestListFromCampaignInDBAndModel(
3106: (TestList) selectedNode
3107: .getUserObject(),
3108: currentCampaign);
3109: deleted = true;
3110:
3111: //IHM
3112: DefaultMutableTreeNode familyParent = (DefaultMutableTreeNode) selectedNode
3113: .getParent();
3114: SalomeTMFPanels.getCampaignDynamicTree()
3115: .removeNode(selectedNode);
3116: if (familyParent.getChildCount() == 0) {
3117: SalomeTMFPanels.getCampaignDynamicTree()
3118: .removeNode(familyParent);
3119: }
3120: } catch (Exception exception) {
3121: if (deleted) {
3122: //Erreur au niveau de L'IHM -> faire un reload
3123: reloadFromBase(true);
3124: result = true;
3125: } else {
3126: Tools.ihmExceptionView(exception);
3127: result = false;
3128: }
3129: }
3130: }
3131:
3132: // Si la campagne est vide, suppression de ses résultats d'exécution
3133: if (isCampEmpty) {
3134: SalomeTMFContext
3135: .getInstance()
3136: .showMessage(
3137: Language
3138: .getInstance()
3139: .getText(
3140: "Les_résultats_d'exécution_de_cette_campagne_ont_été_supprimés_car_elle_ne_contient_plus_de_tests."),
3141: Language.getInstance().getText(
3142: "Information_!"),
3143: JOptionPane.INFORMATION_MESSAGE);
3144: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
3145: Language.getInstance().getText("Les_résultats_d'exécution_de_cette_campagne_ont_été_supprimés_car_elle_ne_contient_plus_de_tests."),
3146: Language.getInstance().getText("Information_!"),
3147: JOptionPane.INFORMATION_MESSAGE);*/
3148: }
3149: SalomeTMFPanels.setTestPanelWorkSpace(-1); //remove all
3150: SalomeTMFPanels.getDelTestOrTestList()
3151: .setEnabled(false);
3152: SalomeTMFPanels.reValidateTestPanel();
3153: }
3154: //return true;
3155: }
3156: //return false;
3157: return result;
3158: } // Fin de la methode deleteAction/0
3159:
3160: //**************************************** Ajout *********************************************//
3161: public static void makeCopie(SimpleData toCopie, SimpleData from)
3162: throws Exception {
3163: if (toCopie == null) {
3164: return;
3165: }
3166:
3167: if (toCopie instanceof ManualTest) {
3168: ManualTest pTest;
3169: if (from instanceof Family) {
3170: Family pFamily = (Family) from;
3171: TestList pTestList = DataModel.getDefaultTestList(
3172: pFamily, true);
3173: DefaultMutableTreeNode pNode = SalomeTMFPanels
3174: .getTestDynamicTree().findRemoveTestListNode(
3175: ApiConstants.DEFAULT_TESTLIST_NAME,
3176: pTestList.getFamilyFromModel()
3177: .getNameFromModel(), false);
3178:
3179: pTest = ManualTest.copieIn((ManualTest) toCopie,
3180: pTestList);
3181:
3182: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3183: pTest, true);
3184: } else if (from instanceof TestList) {
3185: TestList pTestList = (TestList) from;
3186: DefaultMutableTreeNode pNode = SalomeTMFPanels
3187: .getTestDynamicTree().findRemoveTestListNode(
3188: pTestList.getNameFromModel(),
3189: pTestList.getFamilyFromModel()
3190: .getNameFromModel(), false);
3191:
3192: pTest = ManualTest.copieIn((ManualTest) toCopie,
3193: pTestList);
3194:
3195: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3196: pTest, true);
3197: } else if (from instanceof Test) {
3198:
3199: TestList pTestList = ((Test) from)
3200: .getTestListFromModel();
3201: if (pTestList != null) {
3202: DefaultMutableTreeNode pNode = SalomeTMFPanels
3203: .getTestDynamicTree()
3204: .findRemoveTestListNode(
3205: pTestList.getNameFromModel(),
3206: pTestList.getFamilyFromModel()
3207: .getNameFromModel(), false);
3208:
3209: pTest = ManualTest.copieIn((ManualTest) toCopie,
3210: pTestList);
3211:
3212: SalomeTMFPanels.getTestDynamicTree().addObject(
3213: pNode, pTest, true);
3214: }
3215: } else {
3216: Family pFamily = DataModel.getDefaultFamily(true);
3217: DefaultMutableTreeNode pNode = SalomeTMFPanels
3218: .getTestDynamicTree().findRemoveFamilyNode(
3219: pFamily.getNameFromModel(), false);
3220:
3221: TestList pTestList = DataModel.getDefaultTestList(
3222: pFamily, true);
3223: pNode = SalomeTMFPanels.getTestDynamicTree()
3224: .findRemoveTestListNode(
3225: ApiConstants.DEFAULT_TESTLIST_NAME,
3226: pTestList.getFamilyFromModel()
3227: .getNameFromModel(), false);
3228:
3229: pTest = ManualTest.copieIn((ManualTest) toCopie,
3230: pTestList);
3231:
3232: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3233: pTest, true);
3234:
3235: }
3236: } else if (toCopie instanceof AutomaticTest) {
3237: AutomaticTest pTest;
3238: if (from instanceof Family) {
3239: Family pFamily = (Family) from;
3240: TestList pTestList = DataModel.getDefaultTestList(
3241: pFamily, true);
3242: DefaultMutableTreeNode pNode = SalomeTMFPanels
3243: .getTestDynamicTree().findRemoveTestListNode(
3244: ApiConstants.DEFAULT_TESTLIST_NAME,
3245: pTestList.getFamilyFromModel()
3246: .getNameFromModel(), false);
3247:
3248: pTest = AutomaticTest.copieIn((AutomaticTest) toCopie,
3249: pTestList);
3250:
3251: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3252: pTest, true);
3253: } else if (from instanceof TestList) {
3254: TestList pTestList = (TestList) from;
3255: DefaultMutableTreeNode pNode = SalomeTMFPanels
3256: .getTestDynamicTree().findRemoveTestListNode(
3257: pTestList.getNameFromModel(),
3258: pTestList.getFamilyFromModel()
3259: .getNameFromModel(), false);
3260:
3261: pTest = AutomaticTest.copieIn((AutomaticTest) toCopie,
3262: pTestList);
3263:
3264: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3265: pTest, true);
3266: } else if (from instanceof Test) {
3267:
3268: TestList pTestList = ((Test) from)
3269: .getTestListFromModel();
3270: if (pTestList != null) {
3271: DefaultMutableTreeNode pNode = SalomeTMFPanels
3272: .getTestDynamicTree()
3273: .findRemoveTestListNode(
3274: pTestList.getNameFromModel(),
3275: pTestList.getFamilyFromModel()
3276: .getNameFromModel(), false);
3277:
3278: pTest = AutomaticTest.copieIn(
3279: (AutomaticTest) toCopie, pTestList);
3280:
3281: SalomeTMFPanels.getTestDynamicTree().addObject(
3282: pNode, pTest, true);
3283: }
3284: } else {
3285: Family pFamily = DataModel.getDefaultFamily(true);
3286: DefaultMutableTreeNode pNode = SalomeTMFPanels
3287: .getTestDynamicTree().findRemoveFamilyNode(
3288: pFamily.getNameFromModel(), false);
3289:
3290: TestList pTestList = DataModel.getDefaultTestList(
3291: pFamily, true);
3292: pNode = SalomeTMFPanels.getTestDynamicTree()
3293: .findRemoveTestListNode(
3294: ApiConstants.DEFAULT_TESTLIST_NAME,
3295: pTestList.getFamilyFromModel()
3296: .getNameFromModel(), false);
3297:
3298: pTest = AutomaticTest.copieIn((AutomaticTest) toCopie,
3299: pTestList);
3300:
3301: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3302: pTest, true);
3303:
3304: }
3305: } else if (toCopie instanceof TestList) {
3306: if (from instanceof Family) {
3307: Family pFamily = (Family) from;
3308: DefaultMutableTreeNode pNode = SalomeTMFPanels
3309: .getTestDynamicTree().findRemoveFamilyNode(
3310: pFamily.getNameFromModel(), false);
3311:
3312: TestList pTestList = TestList.copieIn(
3313: (TestList) toCopie, pFamily);
3314:
3315: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(
3316: pNode, pTestList, true);
3317: // Ajout des test ?? dans l'arbre ???
3318: ArrayList listOfTest = pTestList.getTestListFromModel();
3319: int size = listOfTest.size();
3320: for (int i = 0; i < size; i++) {
3321: Test pTest = (Test) listOfTest.get(i);
3322: SalomeTMFPanels.getTestDynamicTree().addObject(
3323: pNode, pTest, true);
3324: }
3325: } else if (from instanceof TestList) {
3326: TestList pTestList = (TestList) from;
3327: Family pFamily = pTestList.getFamilyFromModel();
3328:
3329: DefaultMutableTreeNode pNode = SalomeTMFPanels
3330: .getTestDynamicTree().findRemoveFamilyNode(
3331: pFamily.getNameFromModel(), false);
3332:
3333: pTestList = TestList.copieIn((TestList) toCopie,
3334: pFamily);
3335:
3336: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(
3337: pNode, pTestList, true);
3338: // Ajout des test ?? dans l'arbre ???
3339: ArrayList listOfTest = pTestList.getTestListFromModel();
3340: int size = listOfTest.size();
3341: for (int i = 0; i < size; i++) {
3342: Test pTest = (Test) listOfTest.get(i);
3343: SalomeTMFPanels.getTestDynamicTree().addObject(
3344: pNode, pTest, true);
3345: }
3346:
3347: } else if (from instanceof Test) {
3348: TestList pTestList = ((Test) from)
3349: .getTestListFromModel();
3350: Family pFamily = pTestList.getFamilyFromModel();
3351:
3352: DefaultMutableTreeNode pNode = SalomeTMFPanels
3353: .getTestDynamicTree().findRemoveFamilyNode(
3354: pFamily.getNameFromModel(), false);
3355:
3356: pTestList = TestList.copieIn((TestList) toCopie,
3357: pFamily);
3358:
3359: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(
3360: pNode, pTestList, true);
3361: // Ajout des test ?? dans l'arbre ???
3362: ArrayList listOfTest = pTestList.getTestListFromModel();
3363: int size = listOfTest.size();
3364: for (int i = 0; i < size; i++) {
3365: Test pTest = (Test) listOfTest.get(i);
3366: SalomeTMFPanels.getTestDynamicTree().addObject(
3367: pNode, pTest, true);
3368: }
3369: } else {
3370: Family pFamily = DataModel.getDefaultFamily(true);
3371: DefaultMutableTreeNode pNode = SalomeTMFPanels
3372: .getTestDynamicTree().findRemoveFamilyNode(
3373: pFamily.getNameFromModel(), false);
3374:
3375: TestList pTestList = TestList.copieIn(
3376: (TestList) toCopie, pFamily);
3377:
3378: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(
3379: pNode, pTestList, true);
3380: // Ajout des test ?? dans l'arbre ???
3381: ArrayList listOfTest = pTestList.getTestListFromModel();
3382: int size = listOfTest.size();
3383: for (int i = 0; i < size; i++) {
3384: Test pTest = (Test) listOfTest.get(i);
3385: SalomeTMFPanels.getTestDynamicTree().addObject(
3386: pNode, pTest, true);
3387: }
3388: }
3389: } else if (toCopie instanceof Family) {
3390: Family newFamily = Family.copieIn((Family) toCopie);
3391: //IHM
3392: DefaultMutableTreeNode pNode = SalomeTMFPanels
3393: .getTestDynamicTree().addObject(null, newFamily,
3394: true);
3395: ArrayList listOfTestList = newFamily
3396: .getSuiteListFromModel();
3397: int size = listOfTestList.size();
3398: for (int i = 0; i < size; i++) {
3399: TestList pTestList = (TestList) listOfTestList.get(i);
3400: DefaultMutableTreeNode pNode2 = SalomeTMFPanels
3401: .getTestDynamicTree().addObject(pNode,
3402: pTestList, true);
3403: // Ajout des test ?? dans l'arbre ???
3404: ArrayList listOfTest = pTestList.getTestListFromModel();
3405: int size2 = listOfTest.size();
3406: for (int j = 0; j < size2; j++) {
3407: Test pTest = (Test) listOfTest.get(j);
3408: SalomeTMFPanels.getTestDynamicTree().addObject(
3409: pNode2, pTest, true);
3410: }
3411: }
3412: } else if (toCopie instanceof Campaign) {
3413: Campaign pCamp = Campaign.copieIn((Campaign) toCopie,
3414: currentUser);
3415: DataModel.getCurrentProject().addCampaignInModel(pCamp);
3416: DefaultMutableTreeNode pCampNode = SalomeTMFPanels
3417: .getCampaignDynamicTree().addObject(null, pCamp,
3418: true);
3419: //ajouter les tests
3420: ArrayList testList = pCamp.getTestListFromModel();
3421: Family pCurrentFamily = null;
3422: TestList pCurrentTestList = null;
3423: DefaultMutableTreeNode pFamilyNode = null;
3424: DefaultMutableTreeNode pSuiteNode = null;
3425: for (int i = 0; i < testList.size(); i++) {
3426: Test pTest = (Test) testList.get(i);
3427: TestList pTestList = pTest.getTestListFromModel();
3428: Family pFamily = pTestList.getFamilyFromModel();
3429: if (!pFamily.equals(pCurrentFamily)) {
3430: pFamilyNode = SalomeTMFPanels
3431: .getCampaignDynamicTree().addObject(
3432: pCampNode, pFamily, true);
3433: pCurrentFamily = pFamily;
3434: }
3435: if (!pTestList.equals(pCurrentTestList)) {
3436: pSuiteNode = SalomeTMFPanels
3437: .getCampaignDynamicTree().addObject(
3438: pFamilyNode, pTestList, true);
3439: pCurrentTestList = pTestList;
3440: }
3441: SalomeTMFPanels.getCampaignDynamicTree().addObject(
3442: pSuiteNode, pTest, true);
3443: }
3444: SalomeTMFPanels.getCampaignDynamicTree().repaint();
3445: SalomeTMFPanels.getCampaignDynamicTree()
3446: .scrollPathToVisible(pCampNode);
3447: }
3448: }
3449:
3450: public static TestList getDefaultTestList(Family pFamily,
3451: boolean toAdd) throws Exception {
3452: Project currentProject = DataModel.getCurrentProject();
3453: TestList pTestList = pFamily
3454: .getTestListInModel(ApiConstants.DEFAULT_TESTLIST_NAME);
3455: DefaultMutableTreeNode pNode = SalomeTMFPanels
3456: .getTestDynamicTree().findRemoveFamilyNode(
3457: pFamily.getNameFromModel(), false);
3458: if (pTestList == null) {
3459:
3460: if (TestList.isInBase(pFamily,
3461: ApiConstants.DEFAULT_TESTLIST_NAME)) {
3462: // Add only in Model
3463: Vector suiteVector = pFamily.getSuitesWrapperFromDB();
3464: int i = 0;
3465: boolean found = false;
3466: while ((i < suiteVector.size()) && (!found)) {
3467: SuiteWrapper suiteBdd = (SuiteWrapper) suiteVector
3468: .get(i);
3469: if (suiteBdd.getName().equals(
3470: ApiConstants.DEFAULT_TESTLIST_NAME)) {
3471: found = true;
3472: pTestList = new TestList(pFamily, suiteBdd);
3473: currentProject.addTestListInFamilyInModel(
3474: pTestList, pFamily);
3475: }
3476: i++;
3477: }
3478: } else {
3479: if (toAdd) {
3480: // Add in BDD & MODEL
3481: pTestList = new TestList(
3482: ApiConstants.DEFAULT_TESTLIST_NAME,
3483: ApiConstants.DEFAULT_TESTLIST_DESC);
3484: currentProject.addTestListInFamilyInDBAndModel(
3485: pTestList, pFamily);
3486: }
3487: }
3488: if (toAdd) {
3489: //IHM
3490: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3491: pTestList, true);
3492: }
3493:
3494: }
3495:
3496: return pTestList;
3497: }
3498:
3499: public static Family getDefaultFamily(boolean toAdd)
3500: throws Exception {
3501: Project currentProject = DataModel.getCurrentProject();
3502: Family pFamily = currentProject
3503: .getFamilyFromModel(ApiConstants.DEFAULT_FAMILY_NAME);
3504: if (pFamily == null) {
3505:
3506: if (Family.isInBase(currentProject,
3507: ApiConstants.DEFAULT_FAMILY_NAME)) {
3508: // Add only in Model
3509: Vector familyVector = currentProject
3510: .getProjectFamiliesWrapperFromDB();
3511: int i = 0;
3512: boolean found = false;
3513: while ((i < familyVector.size()) && (!found)) {
3514: FamilyWrapper familyBdd = (FamilyWrapper) familyVector
3515: .get(i);
3516: if (familyBdd.getName().equals(
3517: ApiConstants.DEFAULT_FAMILY_NAME)) {
3518: found = true;
3519: pFamily = new Family(currentProject, familyBdd);
3520: currentProject.addFamilyInModel(pFamily);
3521: }
3522: i++;
3523: }
3524: } else {
3525: // Add in BDD & MODEL
3526: if (toAdd) {
3527: pFamily = new Family(
3528: ApiConstants.DEFAULT_FAMILY_NAME,
3529: ApiConstants.DEFAULT_FAMILY_DESC);
3530: currentProject.addFamilyInDBAndModel(pFamily);
3531: }
3532: }
3533:
3534: if (toAdd) {
3535: SalomeTMFPanels.getTestDynamicTree().addObject(null,
3536: pFamily, true);
3537: }
3538:
3539: }
3540: return pFamily;
3541: }
3542:
3543: /**
3544: * Methode qui permet d'ajouter une nouvelle campagne de tests
3545: */
3546: public static void addNewCampagne() {
3547: AskNewCampagne askNewCampagne = new AskNewCampagne(
3548: SalomeTMFContext.getInstance().getSalomeFrame(),
3549: Language.getInstance().getText(
3550: "Nouvelle_campagne_de_tests"));
3551: if (askNewCampagne.getCampagne() == null)
3552: return;
3553: if (currentProject.containsCampaignInModel(askNewCampagne
3554: .getCampagne().getNameFromModel())
3555: || Campaign.isInBase(currentProject, askNewCampagne
3556: .getCampagne())) {
3557: SalomeTMFContext.getInstance().showMessage(
3558: "Le nom de la campagne existe déjà !",
3559: Language.getInstance().getText("Erreur_!"),
3560: JOptionPane.ERROR_MESSAGE);
3561:
3562: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
3563: "Le nom de la campagne existe déjà !",
3564: Language.getInstance().getText("Erreur_!"),
3565: JOptionPane.ERROR_MESSAGE);*/
3566: } else {
3567:
3568: try {
3569: Campaign camp = askNewCampagne.getCampagne();
3570: // BdD
3571: currentProject.addCampaignInDBandModel(camp);
3572:
3573: // IHM
3574: SalomeTMFPanels.getCampaignDynamicTree().addObject(
3575: null, camp, true);
3576: } catch (Exception exception) {
3577: Tools.ihmExceptionView(exception);
3578: }
3579: }
3580: } // Fin de la m?thode addNewCampagne/0
3581:
3582: /**
3583: * Méthode qui permet d'ajouter une nouvelle suite de tests
3584: */
3585: public static void addNewTestList() {
3586: // Fen?tre pour construire la nouvelle suite
3587: AskNewTestList testListDialog = new AskNewTestList(Language
3588: .getInstance().getText("Nouvelle_suite"), Language
3589: .getInstance().getText("Nom_de_la_suite_:"));
3590: // La nouvelle suite en cours de cr?ation
3591: TestList newTestList = testListDialog.getTestList();
3592: // Le noeud sélectionné
3593: DefaultMutableTreeNode node = SalomeTMFPanels
3594: .getTestDynamicTree().getSelectedNode();
3595: // l'utilisateur n'a pas annulé
3596: if (newTestList == null) {
3597: return;
3598: }
3599: DefaultMutableTreeNode familyNode = null;
3600: Family pFamily = null;
3601:
3602: if (node != null) {
3603: if (node.getUserObject() instanceof Family) {
3604: pFamily = (Family) node.getUserObject();
3605: } else if (node.getUserObject() instanceof TestList) {
3606: pFamily = (((TestList) node.getUserObject())
3607: .getFamilyFromModel());
3608: } else if (node.getUserObject() instanceof Test) {
3609: pFamily = (((Test) node.getUserObject())
3610: .getTestListFromModel().getFamilyFromModel());
3611: }
3612: }
3613: if (pFamily == null) {
3614: //Ajout de la famille par defaut
3615: try {
3616: pFamily = getDefaultFamily(true);
3617: } catch (Exception exception) {
3618: Tools.ihmExceptionView(exception);
3619: return;
3620: }
3621: /*
3622: pFamily = currentProject.getFamilyFromModel(ApiConstants.DEFAULT_FAMILY_NAME);
3623: if (pFamily == null){
3624:
3625: //if (!TestPlanData.containsFamily(pFamily.getName())){
3626: try {
3627:
3628: if (Family.isInBase(currentProject,ApiConstants.DEFAULT_FAMILY_NAME)) {
3629: // Add only in Model
3630: Vector familyVector = currentProject.getProjectFamiliesWrapperFromDB();
3631: int i = 0;
3632: boolean found = false;
3633: while ((i<familyVector.size())&&(!found)) {
3634: FamilyWrapper familyBdd = (FamilyWrapper) familyVector.get(i);
3635: if (familyBdd.getName().equals(ApiConstants.DEFAULT_FAMILY_NAME)) {
3636: found = true;
3637: pFamily = new Family(currentProject, familyBdd);
3638: currentProject.addFamilyInModel(pFamily);
3639: }
3640: i++;
3641: }
3642: } else {
3643: // Add in BDD & MODEL
3644: pFamily = new Family(ApiConstants.DEFAULT_FAMILY_NAME, ApiConstants.DEFAULT_FAMILY_DESC);
3645: currentProject.addFamilyInDBAndModel(pFamily);
3646: }
3647:
3648: //IHM
3649: familyNode = SalomeTMFPanels.getTestDynamicTree().addObject(null, pFamily, true);
3650: } catch (Exception exception) {
3651: Tools.ihmExceptionView(exception);
3652: return;
3653: }
3654: }*/
3655: }
3656:
3657: //newTestList.setFamily(pFamily);
3658: try {
3659: if (currentProject.containsTestListInModel(pFamily,
3660: newTestList.getNameFromModel())
3661: || TestList.isInBase(pFamily, newTestList)) {
3662: SalomeTMFContext
3663: .getInstance()
3664: .showMessage(
3665: Language
3666: .getInstance()
3667: .getText(
3668: "Le_nom_de_la_suite_existe_déjà_dans_cette_famille_!"),
3669: Language.getInstance().getText(
3670: "Erreur_!"),
3671: JOptionPane.ERROR_MESSAGE);
3672: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
3673: Language.getInstance().getText("Le_nom_de_la_suite_existe_déjà_dans_cette_famille_!"),
3674: Language.getInstance().getText("Erreur_!"),
3675: JOptionPane.ERROR_MESSAGE);*/
3676: return;
3677: }
3678:
3679: //BDD & MODEL
3680: currentProject.addTestListInFamilyInDBAndModel(newTestList,
3681: pFamily);
3682:
3683: //IHM
3684: if (familyNode == null) {
3685: DefaultMutableTreeNode fNode = SalomeTMFPanels
3686: .getTestDynamicTree().findRemoveFamilyNode(
3687: newTestList.getFamilyFromModel()
3688: .getNameFromModel(), false);
3689: if (fNode == null) {
3690: familyNode = SalomeTMFPanels.getTestDynamicTree()
3691: .addObject(null,
3692: newTestList.getFamilyFromModel(),
3693: true);
3694: } else {
3695: familyNode = fNode;
3696: }
3697: }
3698: SalomeTMFPanels.getTestDynamicTree().addObject(familyNode,
3699: newTestList, true);
3700: } catch (Exception e) {
3701: Tools.ihmExceptionView(e);
3702: }
3703: } // Fin de la m?thode addNewTestList/0
3704:
3705: public static void addNewFamily() {
3706: AskNameAndDescription askNewFamily = new AskNameAndDescription(
3707: FAMILY, Language.getInstance().getText(
3708: "Nouvelle_famille"), Language.getInstance()
3709: .getText("Nouvelle_famille_:"),
3710: SalomeTMFContext.getInstance().getSalomeFrame(), null);
3711: Family newFamily = askNewFamily.getFamily();
3712: if (newFamily != null) {
3713: if (currentProject.containsFamilyInModel(newFamily
3714: .getNameFromModel())
3715: || Family.isInBase(currentProject, newFamily)) {
3716: SalomeTMFContext.getInstance().showMessage(
3717: Language.getInstance().getText(
3718: "Cette_famille_existe_déjà_!"),
3719: Language.getInstance().getText("Erreur_!"),
3720: JOptionPane.ERROR_MESSAGE);
3721:
3722: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
3723: Language.getInstance().getText("Cette_famille_existe_déjà_!"),
3724: Language.getInstance().getText("Erreur_!"),
3725: JOptionPane.ERROR_MESSAGE);*/
3726: } else {
3727: try {
3728: //BDD & MODEL
3729: currentProject.addFamilyInDBAndModel(newFamily);
3730: //IHM
3731: SalomeTMFPanels.getTestDynamicTree().addObject(
3732: null, newFamily, true);
3733: } catch (DataUpToDateException e1) {
3734: SalomeTMFContext.getInstance().showMessage(
3735: Language.getInstance().getText(
3736: "Update_data"),
3737: Language.getInstance().getText("Erreur_!"),
3738: JOptionPane.ERROR_MESSAGE);
3739: } catch (Exception exception) {
3740: Tools.ihmExceptionView(exception);
3741: }
3742:
3743: }
3744: }
3745: } // Fin de la méthode addNewTestList/0
3746:
3747: /**
3748: * M?thode qui permet d'ajouter un nouveau test.
3749: */
3750: public static void addNewTest() {
3751: //String type ="";
3752: AskNewTest askNewTest = new AskNewTest(SalomeTMFContext
3753: .getInstance().getSalomeFrame(), Language.getInstance()
3754: .getText("Nouveau_Test"));
3755: DefaultMutableTreeNode node = SalomeTMFPanels
3756: .getTestDynamicTree().getSelectedNode();
3757: Test pTest = askNewTest.getTest();
3758: if (pTest == null)
3759: return;
3760:
3761: TestList pTestList;
3762: Family pFamily;
3763: //DefaultMutableTreeNode testListNode;
3764: //DefaultMutableTreeNode familyNode ;
3765:
3766: DefaultMutableTreeNode pNode = null;
3767: if (node == null
3768: || node == SalomeTMFPanels.getTestDynamicTree()
3769: .getRoot()) {
3770: // Rien n'est seléctionné
3771: //Ajout de la famille par defaut
3772: //pFamily = TestPlanData.getDefaultFamily();
3773:
3774: try {
3775: pFamily = getDefaultFamily(true);
3776: pNode = SalomeTMFPanels.getTestDynamicTree()
3777: .findRemoveFamilyNode(
3778: pFamily.getNameFromModel(), false);
3779: } catch (Exception exception) {
3780: Tools.ihmExceptionView(exception);
3781: return;
3782: }
3783:
3784: /*pFamily = currentProject.getFamilyFromModel(ApiConstants.DEFAULT_FAMILY_NAME);
3785: if (pFamily == null){
3786: //pFamily = new Family(ApiConstants.DEFAULT_FAMILY_NAME, ApiConstants.DEFAULT_FAMILY_DESC);
3787: try {
3788: if (Family.isInBase(currentProject,ApiConstants.DEFAULT_FAMILY_NAME)) {
3789: // Add only in Model
3790: Vector familyVector = currentProject.getProjectFamiliesWrapperFromDB();
3791: int i = 0;
3792: boolean found = false;
3793: while ((i<familyVector.size())&&(!found)) {
3794: FamilyWrapper familyBdd = (FamilyWrapper) familyVector.get(i);
3795: if (familyBdd.getName().equals(ApiConstants.DEFAULT_FAMILY_NAME)) {
3796: found = true;
3797: pFamily = new Family(currentProject, familyBdd);
3798: currentProject.addFamilyInModel(pFamily);
3799: }
3800: i++;
3801: }q
3802: } else {
3803: // Add in BDD & MODEL
3804: pFamily = new Family(ApiConstants.DEFAULT_FAMILY_NAME, ApiConstants.DEFAULT_FAMILY_DESC);
3805: currentProject.addFamilyInDBAndModel(pFamily);
3806: }
3807:
3808: //IHM
3809: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(null, pFamily, true);
3810: } catch (Exception exception) {
3811: Tools.ihmExceptionView(exception);
3812: return;
3813: }
3814: } else {
3815: pNode = SalomeTMFPanels.getTestDynamicTree().findRemoveFamilyNode(pFamily.getNameFromModel(), false);
3816: }*/
3817:
3818: try {
3819: pTestList = getDefaultTestList(pFamily, true);
3820: pNode = SalomeTMFPanels.getTestDynamicTree()
3821: .findRemoveTestListNode(
3822: ApiConstants.DEFAULT_TESTLIST_NAME,
3823: pFamily.getNameFromModel(), false);
3824: } catch (Exception exception) {
3825: Tools.ihmExceptionView(exception);
3826: return;
3827: }
3828:
3829: /*pTestList = pFamily.getTestListInModel(ApiConstants.DEFAULT_TESTLIST_NAME);
3830: if (pTestList == null) {
3831: //Ajout de la suite par defaut
3832: //pTestList = new TestList(ApiConstants.DEFAULT_TESTLIST_NAME, ApiConstants.DEFAULT_TESTLIST_DESC);
3833:
3834:
3835: try {
3836:
3837: if (TestList.isInBase(pFamily,ApiConstants.DEFAULT_TESTLIST_NAME)) {
3838: // Add only in Model
3839: Vector suiteVector = pFamily.getSuitesWrapperFromDB();
3840: int i = 0;
3841: boolean found = false;
3842: while ((i<suiteVector.size())&&(!found)) {
3843: SuiteWrapper suiteBdd = (SuiteWrapper) suiteVector.get(i);
3844: if (suiteBdd.getName().equals(ApiConstants.DEFAULT_TESTLIST_NAME)) {
3845: found = true;
3846: pTestList = new TestList(pFamily, suiteBdd);
3847: currentProject.addTestListInFamilyInModel(pTestList,pFamily);
3848: }
3849: i++;
3850: }
3851: } else {
3852: // Add in BDD & MODEL
3853: pTestList = new TestList(ApiConstants.DEFAULT_TESTLIST_NAME, ApiConstants.DEFAULT_TESTLIST_DESC);
3854: currentProject.addTestListInFamilyInDBAndModel(pTestList, pFamily);
3855: }
3856:
3857: //IHM
3858: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(pNode, pTestList, true);
3859: } catch (Exception exception) {
3860: Tools.ihmExceptionView(exception);
3861: return;
3862: }
3863: } else {
3864: pNode = SalomeTMFPanels.getTestDynamicTree().findRemoveTestListNode(ApiConstants.DEFAULT_TESTLIST_NAME, pTestList.getFamilyFromModel().getNameFromModel(), false);
3865: }*/
3866: } else if (node.getUserObject() instanceof Family) {
3867: pFamily = (Family) node.getUserObject();
3868: try {
3869: pTestList = getDefaultTestList(pFamily, true);
3870: pNode = SalomeTMFPanels.getTestDynamicTree()
3871: .findRemoveTestListNode(
3872: ApiConstants.DEFAULT_TESTLIST_NAME,
3873: pFamily.getNameFromModel(), false);
3874: } catch (Exception exception) {
3875: Tools.ihmExceptionView(exception);
3876: return;
3877: }
3878:
3879: /*pTestList = pFamily.getTestListInModel(ApiConstants.DEFAULT_TESTLIST_NAME);
3880: pNode = node;
3881: if (pTestList == null) {
3882: //Ajout de la suite par defaut
3883: //pTestList = new TestList(ApiConstants.DEFAULT_TESTLIST_NAME, ApiConstants.DEFAULT_TESTLIST_DESC);
3884: try {
3885:
3886: if (TestList.isInBase(pFamily,ApiConstants.DEFAULT_TESTLIST_NAME)) {
3887: // Add only in Model
3888: Vector suiteVector = pFamily.getSuitesWrapperFromDB();
3889: int i = 0;
3890: boolean found = false;
3891: while ((i<suiteVector.size())&&(!found)) {
3892: SuiteWrapper suiteBdd = (SuiteWrapper) suiteVector.get(i);
3893: if (suiteBdd.getName().equals(ApiConstants.DEFAULT_TESTLIST_NAME)) {
3894: found = true;
3895: pTestList = new TestList(pFamily, suiteBdd);
3896: currentProject.addTestListInFamilyInModel(pTestList,pFamily);
3897: }
3898: i++;
3899: }
3900: } else {
3901: // Add in BDD & MODEL
3902: pTestList = new TestList(ApiConstants.DEFAULT_TESTLIST_NAME, ApiConstants.DEFAULT_TESTLIST_DESC);
3903: currentProject.addTestListInFamilyInDBAndModel(pTestList, pFamily);
3904: }
3905:
3906: //IHM
3907: pNode = SalomeTMFPanels.getTestDynamicTree().addObject(pNode, pTestList, true);
3908: } catch (Exception exception) {
3909: Tools.ihmExceptionView(exception);
3910: return;
3911: }
3912: } else {
3913: pNode = SalomeTMFPanels.getTestDynamicTree().findRemoveTestListNode(DEFAULT_TESTLIST_NAME, pFamily.getNameFromModel(), false);
3914: }*/
3915: } else if (node.getUserObject() instanceof TestList) {
3916: pTestList = (TestList) node.getUserObject();
3917: pFamily = pTestList.getFamilyFromModel();
3918: pNode = node;
3919: } else if (node.getUserObject() instanceof Test) {
3920: pTestList = ((Test) node.getUserObject())
3921: .getTestListFromModel();
3922: pFamily = pTestList.getFamilyFromModel();
3923: pNode = (DefaultMutableTreeNode) node.getParent();
3924: } else {
3925: //???????????????????
3926: return;
3927: }
3928:
3929: try {
3930: if ((pTestList.getTestFromModel(pTest.getNameFromModel()) != null)
3931: || Test.isInBase(pTestList, pTest)) {
3932: SalomeTMFContext
3933: .getInstance()
3934: .showMessage(
3935: Language
3936: .getInstance()
3937: .getText(
3938: "Ce_nom_de_test_existe_déjà_pour_cette_suite_!"),
3939: Language.getInstance().getText(
3940: "Erreur_!"),
3941: JOptionPane.ERROR_MESSAGE);
3942: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
3943: Language.getInstance().getText("Ce_nom_de_test_existe_déjà_pour_cette_suite_!"),
3944: Language.getInstance().getText("Erreur_!"),
3945: JOptionPane.ERROR_MESSAGE);*/
3946: return;
3947: }
3948:
3949: //BDD & MODELL
3950: currentProject.addTestInListInDBAndModel(pTest, pTestList);
3951: // IHM
3952: SalomeTMFPanels.getTestDynamicTree().addObject(pNode,
3953: pTest, true);
3954: } catch (Exception e) {
3955: Tools.ihmExceptionView(e);
3956: }
3957: // ???????????????
3958: pTest.setConceptorInModel(currentUser.getFirstNameFromModel()
3959: + " " + currentUser.getLastNameFromModel());
3960:
3961: } // Fin de la m?thode addNewTest/0
3962:
3963: public static void importTestsToCampaign() {
3964: if (currentCampaign == null) {
3965: return;
3966: }
3967: try {
3968: if (!currentCampaign.isValideModel()) {
3969: SalomeTMFContext.getInstance().showMessage(
3970: Language.getInstance().getText("Update_data"),
3971: Language.getInstance().getText("Erreur_!"),
3972: JOptionPane.ERROR_MESSAGE);
3973: return;
3974: }
3975: } catch (Exception e) {
3976: Tools.ihmExceptionView(e);
3977: SalomeTMFContext.getInstance().showMessage(
3978: Language.getInstance().getText("Update_data"),
3979: Language.getInstance().getText("Erreur_!"),
3980: JOptionPane.ERROR_MESSAGE);
3981: return;
3982: }
3983:
3984: DynamicTree campaignDynamicTree = SalomeTMFPanels
3985: .getCampaignDynamicTree();
3986: DynamicTree testDynamicTree = SalomeTMFPanels
3987: .getTestDynamicTree();
3988: DefaultMutableTreeNode selectedCampagneNode = campaignDynamicTree
3989: .getSelectedNode();
3990: ArrayList oldTestList = new ArrayList();
3991: Hashtable oldAssignedUser = new Hashtable();
3992: for (int k = 0; k < currentCampaign.getTestListFromModel()
3993: .size(); k++) {
3994: Test pTest = (Test) currentCampaign.getTestListFromModel()
3995: .get(k);
3996: int idUserAssigned = currentCampaign
3997: .getAssignedUserID(pTest);
3998: if (idUserAssigned == -1) {
3999: idUserAssigned = currentUser.getIdBdd();
4000: }
4001: oldAssignedUser.put(new Integer(pTest.getIdBdd()),
4002: new Integer(idUserAssigned));
4003: oldTestList.add(pTest);
4004: }
4005:
4006: ArrayList testsToBeKeeped = null;
4007:
4008: if (selectedCampagneNode == null) {
4009: return;
4010: }
4011: boolean doAnUpdate = false;
4012: if (currentCampaign.containsExecutionResultInModel()) {
4013: if (!Api.isLockExecutedTest()) {
4014: Object[] options = {
4015: Language.getInstance().getText("Oui"),
4016: Language.getInstance().getText("Non") };
4017: int choice = SalomeTMFContext
4018: .getInstance()
4019: .askQuestion(
4020: Language
4021: .getInstance()
4022: .getText(
4023: "Cette_campagne_contient_des_resultat_dexecution_plus_possible_de_les_modifier")
4024: + "\n"
4025: + Language.getInstance()
4026: .getText("continuer"),
4027: Language.getInstance().getText(
4028: "Attention_!"),
4029: JOptionPane.WARNING_MESSAGE, options);
4030: if (choice == JOptionPane.NO_OPTION) {
4031: return;
4032: }
4033: doAnUpdate = true;
4034: } else {
4035: JOptionPane
4036: .showMessageDialog(
4037: SalomeTMFContext.getInstance()
4038: .getSalomeFrame(),
4039: Language
4040: .getInstance()
4041: .getText(
4042: "Cette_campagne_contient_déjà_des_résultat_d'exécution.\nIl_n'est_plus_possible_de_la_modifier."),
4043: Language.getInstance().getText(
4044: "Erreur_!"),
4045: JOptionPane.ERROR_MESSAGE);
4046: return;
4047: }
4048: }
4049:
4050: FillCampagne pFillCampagne = new FillCampagne(
4051: selectedCampagneNode, campaignDynamicTree.getModel(),
4052: testDynamicTree.getRoot());
4053: if (!pFillCampagne.okSelected()) {
4054: return;
4055: }
4056: boolean newDataSetCreated = false;
4057: ArrayList datasetsCreated;
4058:
4059: int transNumber = -1;
4060: try {
4061: // BDD & MODEL
4062:
4063: transNumber = Api.beginTransaction(110,
4064: ApiConstants.INSERT_TEST_INTO_CAMPAIGN);
4065: //On vide la campagne
4066: for (int j = 0; j < oldTestList.size(); j++) {
4067: currentCampaign.deleteTestFromCampInDB(
4068: ((Test) oldTestList.get(j)).getIdBdd(), false);
4069: }
4070: currentCampaign.clearAssignedUserForTest();
4071:
4072: //Puis on lui ajoute les tests
4073: testsToBeKeeped = currentCampaign.getTestListFromModel();
4074: ArrayList dataSets = currentCampaign
4075: .getDataSetListFromModel();
4076:
4077: if (testsToBeKeeped != null) {
4078: int size = testsToBeKeeped.size();
4079: for (int j = 0; j < size; j++) {
4080: Test pTest = (Test) testsToBeKeeped.get(j);
4081: Util.log("[DataModel->importTestsToCampaign] test "
4082: + pTest);
4083: int id = currentUser.getIdBdd();
4084: Integer userID = (Integer) oldAssignedUser
4085: .get(new Integer(pTest.getIdBdd()));
4086: if (userID != null) {
4087: id = userID.intValue();
4088: }
4089: datasetsCreated = currentProject
4090: .addTestInCampaignInDBAndModel(pTest,
4091: currentCampaign, id);
4092:
4093: if (datasetsCreated.size() > 0) {
4094: newDataSetCreated = true;
4095: for (int k = 0; k < currentCampaign
4096: .getExecutionListFromModel().size(); k++) {
4097: executionTableModel.setValueAt(
4098: ((DataSet) datasetsCreated.get(k))
4099: .getNameFromModel(), k, 3);
4100: }
4101: }
4102: }
4103: }
4104: /* IHM */
4105: campaignDynamicTree.repaint();
4106: if (newDataSetCreated) {
4107: for (int i = 0; i < dataSets.size(); i++) {
4108: DataSet newDataSet = (DataSet) dataSets.get(i);
4109: ArrayList dataView = new ArrayList();
4110: dataView.add(newDataSet.getNameFromModel());
4111: dataView.add(newDataSet.getDescriptionFromModel());
4112: dataSetTableModel.addRow(dataView);
4113: }
4114: }
4115: if (pIAssignedCampAction != null) {
4116: pIAssignedCampAction.updateData(currentCampaign);
4117: }
4118:
4119: Api.commitTrans(transNumber);
4120: } catch (Exception exception) {
4121: Api.forceRollBackTrans(transNumber);
4122: currentCampaign.setTestListInModel(oldTestList);
4123: Tools.ihmExceptionView(exception);
4124: }
4125: if (doAnUpdate) {
4126: //DataModel.reloadCamp()
4127: }
4128:
4129: }
4130:
4131: /********************************* RENAME *************************************************/
4132:
4133: /**
4134: * Méthode permettant de renommer une campagne
4135: *
4136: */
4137: public static void renameCampaign() {
4138: DefaultMutableTreeNode selectedNode = SalomeTMFPanels
4139: .getCampaignDynamicTree().getSelectedNode();
4140: if (selectedNode != null
4141: && selectedNode.getUserObject() instanceof Campaign) {
4142: AskName askName = new AskName(Language.getInstance()
4143: .getText("Nouveau_nom_:"), Language.getInstance()
4144: .getText("Renommer"), Language.getInstance()
4145: .getText("nom"), ((Campaign) selectedNode
4146: .getUserObject()).getNameFromModel(),
4147: SalomeTMFContext.getInstance().getSalomeFrame());
4148: if (askName.getResult() != null) {
4149: if (!currentProject.containsCampaignInModel(askName
4150: .getResult())
4151: && !Campaign.isInBase(currentProject, askName
4152: .getResult())) {
4153: try {
4154: // BdD
4155: ((Campaign) selectedNode.getUserObject())
4156: .updateInDBAndModel(
4157: askName.getResult(),
4158: currentCampaign
4159: .getDescriptionFromModel());
4160:
4161: // IHM
4162: selectedNode.setUserObject(selectedNode
4163: .getUserObject());
4164: //SalomeTMFPanels.getCampaignNameLabel().setText(Language.getInstance().getText("Nom_de_la_campagne_:_") + askName.getResult());
4165: SalomeTMFPanels.setCampPanelInfo(askName
4166: .getResult(), null, null);
4167: SalomeTMFPanels.getCampaignDynamicTree()
4168: .refreshNode(selectedNode);
4169: //SalomeTMFPanels.getCampaignDynamicTree().repaint();
4170:
4171: } catch (Exception exception) {
4172: Tools.ihmExceptionView(exception);
4173: }
4174:
4175: } else if (currentProject.getCampaignFromModel(askName
4176: .getResult()) == null
4177: || !currentProject.getCampaignFromModel(
4178: askName.getResult()).equals(
4179: selectedNode.getUserObject())) {
4180: SalomeTMFContext
4181: .getInstance()
4182: .showMessage(
4183: Language
4184: .getInstance()
4185: .getText(
4186: "Le_nom_de_la_campagne_existe_déjà_!"),
4187: Language.getInstance().getText(
4188: "Erreur_!"),
4189: JOptionPane.ERROR_MESSAGE);
4190:
4191: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
4192: Language.getInstance().getText("Le_nom_de_la_campagne_existe_déjà_!"),
4193: Language.getInstance().getText("Erreur_!"),
4194: JOptionPane.ERROR_MESSAGE);*/
4195: }
4196: }
4197: }
4198: }
4199:
4200: /**
4201: * Méthode permettant le renommage des tests, familles, suites de tests.
4202: *
4203: */
4204: public static void renameTest() {
4205: DefaultMutableTreeNode selectedNode = SalomeTMFPanels
4206: .getTestDynamicTree().getSelectedNode();
4207: if (selectedNode != null
4208: && selectedNode.getUserObject() instanceof SimpleData) {
4209: //String oldName = ((Element)selectedNode.getUserObject()).getName();
4210: AskName askName = new AskName(Language.getInstance()
4211: .getText("Nouveau_nom_:"), Language.getInstance()
4212: .getText("Renommer"), Language.getInstance()
4213: .getText("nom"), ((SimpleData) selectedNode
4214: .getUserObject()).getNameFromModel(),
4215: SalomeTMFContext.getInstance().getSalomeFrame());
4216: if (askName.getResult() != null) {
4217: if (selectedNode.getUserObject() instanceof Test) {
4218: if (!currentProject
4219: .containsTestInModel(
4220: ((TestList) ((DefaultMutableTreeNode) selectedNode
4221: .getParent())
4222: .getUserObject()), askName
4223: .getResult())
4224: && !Test
4225: .isInBase(
4226: ((TestList) ((DefaultMutableTreeNode) selectedNode
4227: .getParent())
4228: .getUserObject()),
4229: askName.getResult())) {
4230:
4231: try {
4232: ((Test) selectedNode.getUserObject())
4233: .updateInDBAndModel(
4234: askName.getResult(),
4235: ((Test) selectedNode
4236: .getUserObject())
4237: .getDescriptionFromModel());
4238: //SalomeTMFPanels.getManualTestNameLabel().setText(Language.getInstance().getText("Nom_du_test_:_") + ((Test)selectedNode.getUserObject()).getNameFromModel());
4239: SalomeTMFPanels.setTestPanelTestInfo(
4240: DataConstants.MANUAL_TEST,
4241: ((Test) selectedNode
4242: .getUserObject())
4243: .getNameFromModel(), null,
4244: null);
4245: selectedNode.setUserObject(selectedNode
4246: .getUserObject());
4247: SalomeTMFPanels.getTestDynamicTree()
4248: .refreshNode(selectedNode);
4249: //SalomeTMFPanels.getTestDynamicTree().repaint();
4250: } catch (Exception exception) {
4251: Tools.ihmExceptionView(exception);
4252: }
4253: } else if (currentProject
4254: .getTestFromModel(
4255: ((TestList) ((DefaultMutableTreeNode) selectedNode
4256: .getParent())
4257: .getUserObject())
4258: .getFamilyFromModel()
4259: .getNameFromModel(),
4260: ((TestList) ((DefaultMutableTreeNode) selectedNode
4261: .getParent())
4262: .getUserObject())
4263: .getNameFromModel(),
4264: askName.getResult()) == null
4265: || !currentProject
4266: .getTestFromModel(
4267: ((TestList) ((DefaultMutableTreeNode) selectedNode
4268: .getParent())
4269: .getUserObject())
4270: .getFamilyFromModel()
4271: .getNameFromModel(),
4272: ((TestList) ((DefaultMutableTreeNode) selectedNode
4273: .getParent())
4274: .getUserObject())
4275: .getNameFromModel(),
4276: askName.getResult())
4277: .equals(
4278: selectedNode
4279: .getUserObject())) {
4280: SalomeTMFContext
4281: .getInstance()
4282: .showMessage(
4283: Language
4284: .getInstance()
4285: .getText(
4286: "Ce_nom_de_test_existe_déjà_dans_cette_suite_!"),
4287: Language.getInstance().getText(
4288: "Erreur_!"),
4289: JOptionPane.ERROR_MESSAGE);
4290:
4291: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
4292: Language.getInstance().getText("Ce_nom_de_test_existe_déjà_dans_cette_suite_!"),
4293: Language.getInstance().getText("Erreur_!"),
4294: JOptionPane.ERROR_MESSAGE);*/
4295: }
4296: } else if (selectedNode.getUserObject() instanceof TestList) {
4297: if (!currentProject.containsTestListInModel(
4298: ((TestList) selectedNode.getUserObject())
4299: .getFamilyFromModel(), askName
4300: .getResult())
4301: && !TestList.isInBase(
4302: ((TestList) selectedNode
4303: .getUserObject())
4304: .getFamilyFromModel(),
4305: askName.getResult())) {
4306:
4307: try {
4308: ((TestList) selectedNode.getUserObject())
4309: .updateInDBAndModel(
4310: askName.getResult(),
4311: ((TestList) selectedNode
4312: .getUserObject())
4313: .getDescriptionFromModel());
4314:
4315: selectedNode.setUserObject(selectedNode
4316: .getUserObject());
4317: SalomeTMFPanels.getTestDynamicTree()
4318: .refreshNode(selectedNode);
4319: //SalomeTMFPanels.getTestDynamicTree().repaint();
4320: } catch (Exception exception) {
4321: Tools.ihmExceptionView(exception);
4322: }
4323: } else if (currentProject.getTestListFromModel(
4324: ((TestList) selectedNode.getUserObject())
4325: .getFamilyFromModel()
4326: .getNameFromModel(), askName
4327: .getResult()) == null
4328: || !currentProject.getTestListFromModel(
4329: ((TestList) selectedNode
4330: .getUserObject())
4331: .getFamilyFromModel()
4332: .getNameFromModel(),
4333: askName.getResult()).equals(
4334: selectedNode.getUserObject())) {
4335: SalomeTMFContext
4336: .getInstance()
4337: .showMessage(
4338: Language
4339: .getInstance()
4340: .getText(
4341: "Le_nom_de_la_suite_existe_déjà_dans_cette_famille_!"),
4342: Language.getInstance().getText(
4343: "Erreur_!"),
4344: JOptionPane.ERROR_MESSAGE);
4345:
4346: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
4347: Language.getInstance().getText("Le_nom_de_la_suite_existe_déjà_dans_cette_famille_!"),
4348: Language.getInstance().getText("Erreur_!"),
4349: JOptionPane.ERROR_MESSAGE);*/
4350: }
4351: } else if (selectedNode.getUserObject() instanceof Family) {
4352: if (!currentProject.containsFamilyInModel(askName
4353: .getResult())
4354: && !Family.isInBase(currentProject, askName
4355: .getResult())) {
4356:
4357: try {
4358: ((Family) selectedNode.getUserObject())
4359: .updateInDBAndModel(
4360: askName.getResult(),
4361: ((Family) selectedNode
4362: .getUserObject())
4363: .getDescriptionFromModel());
4364:
4365: selectedNode.setUserObject(selectedNode
4366: .getUserObject());
4367: SalomeTMFPanels.getTestDynamicTree()
4368: .refreshNode(selectedNode);
4369: //SalomeTMFPanels.getTestDynamicTree().repaint();
4370: } catch (Exception exception) {
4371: Tools.ihmExceptionView(exception);
4372: }
4373: } else if (currentProject
4374: .getFamilyFromModel(askName.getResult()) == null
4375: || !currentProject.getFamilyFromModel(
4376: askName.getResult()).equals(
4377: selectedNode.getUserObject())) {
4378: SalomeTMFContext.getInstance().showMessage(
4379: Language.getInstance().getText(
4380: "Cette_famille_existe_déjà_!"),
4381: Language.getInstance().getText(
4382: "Erreur_!"),
4383: JOptionPane.ERROR_MESSAGE);
4384:
4385: /*JOptionPane.showMessageDialog(SalomeTMFContext.getInstance().getSalomeFrame(),
4386: Language.getInstance().getText("Cette_famille_existe_déjà_!"),
4387: Language.getInstance().getText("Erreur_!"),
4388: JOptionPane.ERROR_MESSAGE);*/
4389:
4390: }
4391: }
4392: }
4393: }
4394:
4395: } // Fin de la méthode renameTest/0
4396:
4397: ////////////////////////////////////// Divers ///////////////////////////////////////////////
4398:
4399: public static void initTestScript(AutomaticTest test) {
4400: //System.out.println("Init Test Script");
4401: AutomaticTestScriptView.setTest(test);
4402:
4403: }
4404:
4405: static void afterRefresh() {
4406: SalomeTMFPanels.getAddTestInCampagne().setEnabled(false);
4407: SalomeTMFPanels.getDelCampagne().setEnabled(false);
4408: SalomeTMFPanels.getRenameCampaignButton().setEnabled(false);
4409: SalomeTMFPanels.getRenameTestButton().setEnabled(false);
4410: SalomeTMFPanels.getDelTestOrTestList().setEnabled(false);
4411: SalomeTMFPanels.resetTreeSelection();
4412: }
4413:
4414: static public boolean isTestExecuted(Test pTest) {
4415: boolean executed = false;
4416: if (pTest == null) {
4417: return executed;
4418: }
4419: ArrayList campaignList = currentProject
4420: .getCampaignOfTest(pTest);
4421: if (campaignList != null && campaignList.size() > 0) {
4422: int i = 0;
4423: int size = campaignList.size();
4424: while (i < size && !executed) {
4425: Campaign pCampaign = (Campaign) campaignList.get(i);
4426: if (pCampaign.containsExecutionResultInModel()) {
4427: executed = true;
4428: }
4429: i++;
4430: }
4431: }
4432: return executed;
4433: }
4434:
4435: /************************ HyperLink *****************/
4436: static public void view(SimpleData data) {
4437: if (data == null) {
4438: return;
4439: }
4440: if (data instanceof Test) {
4441: Test pTest = (Test) data;
4442: DynamicTree pDynamicTree = SalomeTMFPanels
4443: .getTestDynamicTree();
4444: DefaultMutableTreeNode node = pDynamicTree
4445: .findRemoveTestNode(pTest.getNameFromModel(), pTest
4446: .getTestListFromModel().getNameFromModel(),
4447: pTest.getTestListFromModel()
4448: .getFamilyFromModel()
4449: .getNameFromModel(), false);
4450: if (node != null) {
4451: //pReqTree.refreshNode(node);
4452: JTabbedPane tabs = (JTabbedPane) SalomeTMFContext
4453: .getInstance().getUIComponent(
4454: UICompCst.MAIN_TABBED_PANE);
4455: tabs.setSelectedIndex(0);
4456: pDynamicTree.getTree().setSelectionPath(
4457: new TreePath(node.getPath()));
4458:
4459: }
4460: } else if (data instanceof TestList) {
4461: TestList pTestList = (TestList) data;
4462: DynamicTree pDynamicTree = SalomeTMFPanels
4463: .getTestDynamicTree();
4464: DefaultMutableTreeNode node = pDynamicTree
4465: .findRemoveTestListNode(pTestList
4466: .getNameFromModel(), pTestList
4467: .getFamilyFromModel().getNameFromModel(),
4468: false);
4469: if (node != null) {
4470: //pReqTree.refreshNode(node);
4471: JTabbedPane tabs = (JTabbedPane) SalomeTMFContext
4472: .getInstance().getUIComponent(
4473: UICompCst.MAIN_TABBED_PANE);
4474: tabs.setSelectedIndex(0);
4475: pDynamicTree.getTree().setSelectionPath(
4476: new TreePath(node.getPath()));
4477:
4478: }
4479: } else if (data instanceof Family) {
4480: Family pFamily = (Family) data;
4481: DynamicTree pDynamicTree = SalomeTMFPanels
4482: .getTestDynamicTree();
4483: DefaultMutableTreeNode node = pDynamicTree
4484: .findRemoveFamilyNode(pFamily.getNameFromModel(),
4485: false);
4486: if (node != null) {
4487: //pReqTree.refreshNode(node);
4488: JTabbedPane tabs = (JTabbedPane) SalomeTMFContext
4489: .getInstance().getUIComponent(
4490: UICompCst.MAIN_TABBED_PANE);
4491: tabs.setSelectedIndex(0);
4492: pDynamicTree.getTree().setSelectionPath(
4493: new TreePath(node.getPath()));
4494:
4495: }
4496: } else if (data instanceof Campaign) {
4497: Campaign pCamp = (Campaign) data;
4498: DynamicTree pDynamicTree = SalomeTMFPanels
4499: .getCampaignDynamicTree();
4500: DefaultMutableTreeNode node = pDynamicTree
4501: .findRemoveCampaignNode(pCamp.getNameFromModel(),
4502: false);
4503: if (node != null) {
4504: //pReqTree.refreshNode(node);
4505: JTabbedPane tabs = (JTabbedPane) SalomeTMFContext
4506: .getInstance().getUIComponent(
4507: UICompCst.MAIN_TABBED_PANE);
4508: tabs.setSelectedIndex(1);
4509: pDynamicTree.getTree().setSelectionPath(
4510: new TreePath(node.getPath()));
4511: }
4512: }
4513: }
4514:
4515: static public void assignCampaignTo(SimpleData data, User user) {
4516: if (data == null || user == null || currentCampaign == null) {
4517: return;
4518: }
4519: try {
4520: if (data instanceof Test) {
4521: Test pTest = (Test) data;
4522: currentCampaign.updateTestAssignationInDBAndModel(pTest
4523: .getIdBdd(), user.getIdBdd());
4524: } else if (data instanceof TestList) {
4525: TestList pTestList = (TestList) data;
4526: currentCampaign.updateSuiteAssignationInDBAndModel(
4527: pTestList.getIdBdd(), user.getIdBdd());
4528: } else if (data instanceof Family) {
4529: Family pFamily = (Family) data;
4530: currentCampaign.updateFamilyAssignationInDBAndModel(
4531: pFamily.getIdBdd(), user.getIdBdd());
4532: } else if (data instanceof Campaign) {
4533: Campaign pCamp = (Campaign) data;
4534: pCamp.updateCampaignAssignationInDBAndModel(user
4535: .getIdBdd());
4536: }
4537: } catch (Exception e) {
4538: e.printStackTrace();
4539: }
4540: }
4541:
4542: // //////////// Pas utilisé ????? ////////////////////////////
4543: /*
4544: public static void refreshEnvironmentAndParameter() {
4545: if (ConnectionData.isConnected()) {
4546: try {
4547: // DATA
4548: pDataLoader.reloadEnvironmentAndParameterData();
4549:
4550: // IHM
4551: getDataModification().clear();
4552: SalomeTMFPanels.getDataMultiUserChangeListenerPanel().reset();
4553: } catch (Exception exception) {
4554: Tools.ihmExceptionView(exception.toString());
4555: }
4556:
4557: } else {
4558: JOptionPane.showMessageDialog(applet,
4559: Language.getInstance().getText("Impossible_!\n_Vous_n'êtes_pas_connecté_à_la_base."),
4560: Language.getInstance().getText("Erreur_!"),
4561: JOptionPane.ERROR_MESSAGE);
4562: }
4563: } // Fin de la m?thode refreshEnvironmentAndParameter/0
4564: */
4565:
4566: } // Fin de la classe TestData
|