001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Aurore PENAULT
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package salomeTMF_plug.gen_doc_xml;
025:
026: import java.awt.BorderLayout;
027: import java.awt.Container;
028: import java.awt.Dimension;
029: import java.awt.event.ActionEvent;
030: import java.awt.event.ActionListener;
031: import java.util.ArrayList;
032: import java.util.Iterator;
033: import java.util.List;
034:
035: import javax.swing.BorderFactory;
036: import javax.swing.Box;
037: import javax.swing.BoxLayout;
038: import javax.swing.JButton;
039: import javax.swing.JDialog;
040: import javax.swing.JOptionPane;
041: import javax.swing.JPanel;
042: import javax.swing.JScrollPane;
043: import javax.swing.JTree;
044: import javax.swing.event.TreeSelectionEvent;
045: import javax.swing.event.TreeSelectionListener;
046: import javax.swing.tree.DefaultMutableTreeNode;
047: import javax.swing.tree.DefaultTreeModel;
048: import javax.swing.tree.TreePath;
049:
050: import org.dom4j.Document;
051: import org.dom4j.Element;
052: import org.objectweb.salome_tmf.api.data.AutomaticTestWrapper;
053: import org.objectweb.salome_tmf.api.data.FamilyWrapper;
054: import org.objectweb.salome_tmf.api.data.ManualTestWrapper;
055: import org.objectweb.salome_tmf.api.data.SuiteWrapper;
056: import org.objectweb.salome_tmf.data.AutomaticTest;
057: import org.objectweb.salome_tmf.data.Campaign;
058: import org.objectweb.salome_tmf.data.DataConstants;
059: import org.objectweb.salome_tmf.data.Execution;
060: import org.objectweb.salome_tmf.data.Family;
061: import org.objectweb.salome_tmf.data.ManualTest;
062: import org.objectweb.salome_tmf.data.Test;
063: import org.objectweb.salome_tmf.data.TestList;
064: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
065: import org.objectweb.salome_tmf.ihm.models.TestTreeModel;
066: import org.objectweb.salome_tmf.ihm.models.TreeRenderer;
067:
068: import salomeTMF_plug.gen_doc_xml.languages.Language;
069:
070: public class ImportTestChooser extends JDialog implements DataConstants {
071:
072: /**
073: * Modèle de l'arbre des tests
074: */
075: protected TestTreeModel testTreeModel;
076:
077: /**
078: * Modèle de l'arbre des tests sélectionnés
079: */
080: protected TestTreeModel chosenTreeModel;
081:
082: /**
083: * l'arbre des tests choisis
084: */
085: JTree chosenTree;
086:
087: /**
088: * l'arbre des tests
089: */
090: JTree testTree;
091:
092: /**
093: * Noeud sélectionné dans l'arbre des tests choisis
094: */
095: DefaultMutableTreeNode chosenSelectedNode;
096:
097: /**
098: * Noeud sélectionné dans l'arbre des tests
099: */
100: DefaultMutableTreeNode testSelectedNode;
101:
102: /**
103: * Racine de l'arbre temporaire des tests choisis
104: */
105: DefaultMutableTreeNode temporaryChosenRootNode;
106:
107: /**
108: * Racine de l'arbre final des tests choisis
109: */
110: DefaultMutableTreeNode realChosenRoot;
111:
112: /**
113: * Liste des tests sélectionnés
114: */
115: ArrayList temporaryTestList;
116:
117: /**
118: * Liste des suites sélectionnées
119: */
120: ArrayList temporaryTestListList;
121:
122: /**
123: * Liste des familles sélectionnées
124: */
125: ArrayList temporaryFamilyList;
126:
127: ArrayList testSelectedNodes;
128:
129: ArrayList chosenSelectedNodes;
130:
131: ImportDialog idialog;
132:
133: CreateProjectDialog cdialog;
134:
135: public ImportTestChooser(JDialog i, Document doc,
136: boolean initSelection) {
137: super (i, true);
138:
139: if (i instanceof ImportDialog) {
140: idialog = (ImportDialog) i;
141: } else {
142: cdialog = (CreateProjectDialog) i;
143: }
144: temporaryTestList = new ArrayList();
145: temporaryTestListList = new ArrayList();
146: temporaryFamilyList = new ArrayList();
147:
148: chosenSelectedNodes = new ArrayList();
149: testSelectedNodes = new ArrayList();
150:
151: DynamicTree testDynamicTree = createTestDynamicTree(doc);
152:
153: realChosenRoot = testDynamicTree.getRoot();
154:
155: TreeRenderer chosenRenderer = new TreeRenderer();
156: TreeRenderer testRenderer = new TreeRenderer();
157:
158: if (initSelection) {
159: if (idialog != null) {
160: temporaryChosenRootNode = new DefaultMutableTreeNode(
161: idialog.getChosenRoot().getUserObject());
162: } else {
163: temporaryChosenRootNode = new DefaultMutableTreeNode(
164: cdialog.getChosenRoot().getUserObject());
165: }
166: } else {
167: temporaryChosenRootNode = new DefaultMutableTreeNode(
168: testDynamicTree.getRoot().getUserObject());
169: }
170:
171: chosenSelectedNode = temporaryChosenRootNode;
172:
173: chosenTree = new JTree();
174: chosenTreeModel = new TestTreeModel(temporaryChosenRootNode,
175: chosenTree, null);
176: chosenTree.setModel(chosenTreeModel);
177:
178: if (initSelection) {
179: if (idialog != null) {
180: initTemporaryTree(idialog.getChosenRoot());
181: } else {
182: initTemporaryTree(cdialog.getChosenRoot());
183: }
184: } else {
185: initTemporaryTree(testDynamicTree.getRoot());
186: }
187:
188: chosenTree.setCellRenderer(chosenRenderer);
189: chosenTree
190: .addTreeSelectionListener(new TreeSelectionListener() {
191: public void valueChanged(TreeSelectionEvent e) {
192: chosenSelectedNodes.clear();
193: TreePath[] pathTab = chosenTree
194: .getSelectionPaths();
195: if (pathTab != null) {
196: for (int i = 0; i < pathTab.length; i++) {
197: chosenSelectedNodes.add(pathTab[i]
198: .getLastPathComponent());
199: }
200: }
201: }
202: });
203: testTree = new JTree(testTreeModel);
204: testTreeModel = new TestTreeModel(testDynamicTree.getRoot(),
205: testTree, null);
206: testTree.setModel(testTreeModel);
207:
208: testTree.setCellRenderer(testRenderer);
209: testTree.addTreeSelectionListener(new TreeSelectionListener() {
210: public void valueChanged(TreeSelectionEvent e) {
211: testSelectedNodes.clear();
212: TreePath[] pathTab = testTree.getSelectionPaths();
213: if (pathTab != null) {
214: for (int i = 0; i < pathTab.length; i++) {
215: testSelectedNodes.add(pathTab[i]
216: .getLastPathComponent());
217: }
218: }
219: }
220: });
221:
222: JButton addButton = new JButton(">");
223: addButton.setToolTipText(Language.getInstance().getText(
224: "Ajouter_à_la_sélection"));
225: addButton.addActionListener(new ActionListener() {
226: public void actionPerformed(ActionEvent e) {
227: for (int i = 0; i < testSelectedNodes.size(); i++) {
228: Object nodeValue = ((DefaultMutableTreeNode) testSelectedNodes
229: .get(i)).getUserObject();
230: testSelectedNode = ((DefaultMutableTreeNode) testSelectedNodes
231: .get(i));
232: if (nodeValue instanceof Family) {
233: addNodeToNode(testSelectedNode,
234: temporaryChosenRootNode);
235: } else if (nodeValue instanceof TestList) {
236: DefaultMutableTreeNode familyNode = findFamilyNodeInChosenTree(((TestList) nodeValue)
237: .getFamilyFromModel()
238: .getNameFromModel());
239: if (familyNode != null) {
240: addNodeToNode(testSelectedNode, familyNode);
241: } else {
242: DefaultMutableTreeNode newFamilyNode = addObject(
243: temporaryChosenRootNode,
244: ((TestList) nodeValue)
245: .getFamilyFromModel(), true);
246: addNodeToNode(testSelectedNode,
247: newFamilyNode);
248: }
249: } else if (nodeValue instanceof Test) {
250: DefaultMutableTreeNode testListNode = findTestListNodeInChosenTree(
251: ((Test) nodeValue)
252: .getTestListFromModel()
253: .getNameFromModel(),
254: ((Test) nodeValue)
255: .getTestListFromModel()
256: .getFamilyFromModel()
257: .getNameFromModel());
258: if (testListNode != null) {
259: addNodeToNode(testSelectedNode,
260: testListNode);
261: } else {
262: DefaultMutableTreeNode familyNode = findFamilyNodeInChosenTree(((Test) nodeValue)
263: .getTestListFromModel()
264: .getFamilyFromModel()
265: .getNameFromModel());
266: if (familyNode != null) {
267: DefaultMutableTreeNode newListNode = addObject(
268: familyNode,
269: ((Test) nodeValue)
270: .getTestListFromModel(),
271: true);
272: addNodeToNode(testSelectedNode,
273: newListNode);
274: } else {
275: DefaultMutableTreeNode newFamilyNode = addObject(
276: temporaryChosenRootNode,
277: ((Test) nodeValue)
278: .getTestListFromModel()
279: .getFamilyFromModel(),
280: true);
281: DefaultMutableTreeNode newList = addObject(
282: newFamilyNode,
283: ((Test) nodeValue)
284: .getTestListFromModel(),
285: true);
286: addNodeToNode(testSelectedNode, newList);
287: }
288: }
289: }
290: }
291: }
292: });
293:
294: JButton removeButton = new JButton("<");
295: removeButton.setToolTipText(Language.getInstance().getText(
296: "Retirer_de_la_sélection"));
297: removeButton.addActionListener(new ActionListener() {
298: public void actionPerformed(ActionEvent e) {
299: int i = chosenSelectedNodes.size() - 1;
300: boolean continu = true;
301: while (i >= 0 && continu) {
302: Object nodeValue = ((DefaultMutableTreeNode) chosenSelectedNodes
303: .get(i)).getUserObject();
304: DefaultMutableTreeNode node = (DefaultMutableTreeNode) chosenSelectedNodes
305: .get(i);
306: if (nodeValue instanceof Campaign
307: || nodeValue instanceof Execution
308: || nodeValue instanceof Family
309: || nodeValue instanceof TestList
310: || nodeValue instanceof Test) {
311: ((DefaultTreeModel) chosenTree.getModel())
312: .removeNodeFromParent(node);
313: removeFromModel(node);
314: i = chosenSelectedNodes.size() - 1;
315: } else {
316: continu = false;
317: }
318: }
319: }
320: });
321:
322: JPanel buttonSet = new JPanel();
323: buttonSet.setLayout(new BoxLayout(buttonSet, BoxLayout.Y_AXIS));
324: buttonSet.add(addButton);
325: buttonSet.add(Box.createRigidArea(new Dimension(1, 25)));
326: buttonSet.add(removeButton);
327:
328: JScrollPane chosenScrollPane = new JScrollPane(chosenTree);
329: chosenScrollPane.setBorder(BorderFactory
330: .createTitledBorder(Language.getInstance().getText(
331: "Sélection")));
332: chosenScrollPane.setPreferredSize(new Dimension(300, 450));
333:
334: JScrollPane testScrollPane = new JScrollPane(testTree);
335: testScrollPane.setBorder(BorderFactory
336: .createTitledBorder(Language.getInstance().getText(
337: "Tests")));
338: testScrollPane.setPreferredSize(new Dimension(300, 450));
339:
340: JPanel windowPanel = new JPanel();
341: windowPanel.setLayout(new BoxLayout(windowPanel,
342: BoxLayout.X_AXIS));
343: windowPanel.add(testScrollPane);
344: windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
345: windowPanel.add(buttonSet);
346: windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
347: windowPanel.add(chosenScrollPane);
348:
349: JButton validate = new JButton(Language.getInstance().getText(
350: "Valider"));
351: validate.setToolTipText(Language.getInstance().getText(
352: "Valider"));
353: validate.addActionListener(new ActionListener() {
354: public void actionPerformed(ActionEvent e) {
355: updateList();
356: if (temporaryTestList.size() == 0) {
357: JOptionPane
358: .showMessageDialog(
359: ImportTestChooser.this ,
360: Language
361: .getInstance()
362: .getText(
363: "Vous_devez_sélectionner_au_moins_un_test_à_importer"),
364: Language.getInstance().getText(
365: "Erreur_!"),
366: JOptionPane.ERROR_MESSAGE);
367: } else {
368: if (idialog != null) {
369: ImportTestChooser.this .idialog
370: .setInitSelection(true);
371: if (temporaryFamilyList != null) {
372: idialog
373: .setFamilySelectionList(temporaryFamilyList);
374: }
375: if (temporaryTestListList != null) {
376: idialog
377: .setSuiteSelectionList(temporaryTestListList);
378: }
379: if (temporaryTestList != null) {
380: idialog
381: .setTestSelectionList(temporaryTestList);
382: }
383: idialog
384: .setChosenRoot((DefaultMutableTreeNode) chosenTreeModel
385: .getRoot());
386: idialog.setSelectionDesTests(true);
387: } else {
388: ImportTestChooser.this .cdialog
389: .setInitSelection(true);
390: if (temporaryFamilyList != null) {
391: cdialog
392: .setFamilySelectionList(temporaryFamilyList);
393: }
394: if (temporaryTestListList != null) {
395: cdialog
396: .setSuiteSelectionList(temporaryTestListList);
397: }
398: if (temporaryTestList != null) {
399: cdialog
400: .setTestSelectionList(temporaryTestList);
401: }
402: cdialog
403: .setChosenRoot((DefaultMutableTreeNode) chosenTreeModel
404: .getRoot());
405: cdialog.setSelectionDesTests(true);
406: }
407: ImportTestChooser.this .dispose();
408: }
409: }
410: });
411:
412: JButton cancel = new JButton(Language.getInstance().getText(
413: "Annuler"));
414: cancel
415: .setToolTipText(Language.getInstance().getText(
416: "Annuler"));
417: cancel.addActionListener(new ActionListener() {
418: public void actionPerformed(ActionEvent e) {
419: ImportTestChooser.this .dispose();
420: }
421: });
422:
423: JPanel secondButtonSet = new JPanel();
424: secondButtonSet.add(validate);
425: secondButtonSet.add(cancel);
426:
427: JPanel center = new JPanel();
428: center.add(windowPanel);
429:
430: JPanel page = new JPanel();
431: page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
432: page.add(center);
433: page.add(secondButtonSet);
434:
435: Container contentPaneFrame = this .getContentPane();
436: contentPaneFrame.add(page, BorderLayout.CENTER);
437: this .setTitle(Language.getInstance().getText(
438: "Ajouter_des_tests_à_la_sélection"));
439: this .setLocation(300, 200);
440: this .pack();
441: this .setVisible(true);
442: }
443:
444: /**
445: * @param doc
446: * @return
447: */
448: private DynamicTree createTestDynamicTree(Document doc) {
449: DynamicTree testDynamicTree = new DynamicTree(Language
450: .getInstance().getText("Plan_de_tests"), FAMILY);
451: DefaultMutableTreeNode rootNode = testDynamicTree.getRoot();
452: List familyList = doc.selectNodes("//Famille");
453: Iterator itFamille = familyList.iterator();
454: while (itFamille.hasNext()) {
455: Element familyElem = (Element) itFamille.next();
456: String familyName = familyElem.elementText("Nom");
457: FamilyWrapper f = new FamilyWrapper();
458: f.setName(familyName);
459: Family family = new Family(f);
460: DefaultMutableTreeNode familyNode = testDynamicTree
461: .addObject(rootNode, family, false);
462: temporaryFamilyList.add(family);
463: List suiteList = familyElem.selectNodes(".//SuiteTest");
464: Iterator itSuite = suiteList.iterator();
465: while (itSuite.hasNext()) {
466: Element suiteElem = (Element) itSuite.next();
467: String suiteName = suiteElem.elementText("Nom");
468: SuiteWrapper s = new SuiteWrapper();
469: s.setName(suiteName);
470: TestList sList = new TestList(s);
471: DefaultMutableTreeNode suiteNode = testDynamicTree
472: .addObject(familyNode, sList, false);
473: temporaryTestListList.add(sList);
474: family.addTestListInModel(sList);
475: //sList.setFamily(family);
476: List testList = suiteElem.selectNodes(".//Test");
477: Iterator itTest = testList.iterator();
478: while (itTest.hasNext()) {
479: Element testElem = (Element) itTest.next();
480: String testName = testElem.elementText("Nom");
481: DefaultMutableTreeNode testNode;
482: if (testElem.element("TestAuto") == null) {
483: ManualTestWrapper t = new ManualTestWrapper();
484: t.setName(testName);
485: ManualTest mTest = new ManualTest(t);
486: testNode = testDynamicTree.addObject(suiteNode,
487: mTest, false);
488: temporaryTestList.add(mTest);
489: sList.addTestInModel(mTest);
490: //mTest.setTestList(sList);
491: } else {
492: AutomaticTestWrapper a = new AutomaticTestWrapper();
493: a.setName(testName);
494: AutomaticTest aTest = new AutomaticTest(a);
495: testNode = testDynamicTree.addObject(suiteNode,
496: aTest);
497: temporaryTestList.add(aTest);
498: sList.addTestInModel(aTest);
499: //aTest.setTestList(sList);
500: }
501: }
502: }
503: }
504: return testDynamicTree;
505: }
506:
507: /**
508: * Méthode qui initialise l'arbre temporaire à partir de la racine passé
509: * en paramètre.
510: * @param root la racine du nouvel arbre temporaire
511: */
512: public void initTemporaryTree(DefaultMutableTreeNode root) {
513: for (int i = 0; i < root.getChildCount(); i++) {
514: addNodeToNode((DefaultMutableTreeNode) root.getChildAt(i),
515: temporaryChosenRootNode);
516: }
517: } // Fin de la méthode initTemporaryTree/1
518:
519: /**
520: * Méthode Récursive qui ajoute un noeud à un autre noeud. Tous les fils du
521: * noeud à ajouter sont aussi ajouter récursivement.
522: * @param nodeToBeAdded le noeud à ajouter
523: * @param nodeToReceive le noeud qui reçoit
524: */
525: private void addNodeToNode(DefaultMutableTreeNode nodeToBeAdded,
526: DefaultMutableTreeNode nodeToReceive) {
527: DefaultMutableTreeNode newNode = null;
528: for (int j = 0; j < nodeToReceive.getChildCount(); j++) {
529: if (((DefaultMutableTreeNode) nodeToReceive.getChildAt(j))
530: .getUserObject().equals(
531: nodeToBeAdded.getUserObject())) {
532: newNode = (DefaultMutableTreeNode) nodeToReceive
533: .getChildAt(j);
534: }
535: }
536: if (newNode == null) {
537: newNode = new DefaultMutableTreeNode(nodeToBeAdded
538: .getUserObject());
539: chosenTreeModel.insertNodeInto(newNode, nodeToReceive,
540: nodeToReceive.getChildCount());
541: chosenTree.scrollPathToVisible(new TreePath(newNode
542: .getPath()));
543: if (nodeToBeAdded.getUserObject() instanceof Family) {
544: temporaryFamilyList.add(nodeToBeAdded.getUserObject());
545: } else if (nodeToBeAdded.getUserObject() instanceof TestList) {
546: temporaryTestListList
547: .add(nodeToBeAdded.getUserObject());
548: } else if (nodeToBeAdded.getUserObject() instanceof Test) {
549: temporaryTestList.add(nodeToBeAdded.getUserObject());
550: }
551: }
552: for (int i = 0; i < nodeToBeAdded.getChildCount(); i++) {
553: addNodeToNode((DefaultMutableTreeNode) nodeToBeAdded
554: .getChildAt(i), newNode);
555: }
556: } // Fin de la méthode addNodeToNode/2
557:
558: /**
559: * Méthode qui retourne le noeud correspondant à une famille si le nom passé
560: * en paramètre est le nom d'une famille présente dans l'arbre des sélections
561: * @param familyName un nom
562: * @return le noeud correspondant à une famille si le nom passé
563: * en paramètre est le nom d'une famille présente dans l'arbre des sélections,
564: * <code>null</code> sinon.
565: */
566: public DefaultMutableTreeNode findFamilyNodeInChosenTree(
567: String familyName) {
568: DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
569: .getRoot();
570: for (int j = 0; j < root.getChildCount(); j++) {
571: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
572: .getChildAt(j);
573: if (familyNode.getUserObject() instanceof Family
574: && ((Family) familyNode.getUserObject())
575: .getNameFromModel().equals(familyName)) {
576: return familyNode;
577: }
578: }
579: return null;
580: } // Fin de la méthode findFamilyNode/1
581:
582: /**
583: * Méthode qui retourne le noeud correspondant à une suite si le nom passé
584: * en paramètre est le nom d'une suite présente dans l'arbre des sélections
585: * @param testListName un nom
586: * @return le noeud correspondant à une famille si le nom passé
587: * en paramètre est le nom d'une famille présente dans l'arbre des sélections,
588: * <code>null</code> sinon.
589: */
590: public DefaultMutableTreeNode findTestListNodeInChosenTree(
591: String testListName, String familyName) {
592: DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
593: .getRoot();
594: for (int j = 0; j < root.getChildCount(); j++) {
595: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
596: .getChildAt(j);
597: if (familyNode.getUserObject() instanceof Family
598: && ((Family) familyNode.getUserObject())
599: .getNameFromModel().equals(familyName)) {
600: for (int k = 0; k < familyNode.getChildCount(); k++) {
601: DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) familyNode
602: .getChildAt(k);
603: if (testListNode.getUserObject() instanceof TestList
604: && ((TestList) testListNode.getUserObject())
605: .getNameFromModel().equals(
606: testListName)) {
607: return testListNode;
608: }
609: }
610: }
611: }
612: return null;
613: } // Fin de la méthode findFamilyNode/1
614:
615: /**
616: * Méthode d'ajout d'un noeud dans l'arbre sous le parent.
617: * @param parent le parent
618: * @param child le noeud à ajouter
619: * @param shouldBeVisible visible ou non
620: * @return le nouveau noeud de l'arbre
621: */
622: public DefaultMutableTreeNode addObject(
623: DefaultMutableTreeNode parent, Object child,
624: boolean shouldBeVisible) {
625:
626: DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(
627: child);
628: if (parent == null) {
629: parent = temporaryChosenRootNode;
630: }
631: // Insertion du noeud
632: chosenTreeModel.insertNodeInto(childNode, parent, parent
633: .getChildCount());
634:
635: // on s'assure que le noeud est visible
636: if (shouldBeVisible) {
637: chosenTree.scrollPathToVisible(new TreePath(childNode
638: .getPath()));
639: }
640: return childNode;
641: } // Fin de la classe addObject/3
642:
643: /**
644: * Supprime du modèle les éléments retirés de la sélection.
645: * @param node le noeud à partir duquel on retire les éléments
646: */
647: private void removeFromModel(DefaultMutableTreeNode node) {
648: for (int i = 0; i < node.getChildCount(); i++) {
649: removeFromModel((DefaultMutableTreeNode) node.getChildAt(i));
650: }
651: if (node.getUserObject() instanceof Family) {
652: temporaryFamilyList.remove(node.getUserObject());
653: } else if (node.getUserObject() instanceof TestList) {
654: temporaryTestListList.remove(node.getUserObject());
655: } else if (node.getUserObject() instanceof Test) {
656: temporaryTestList.remove(node.getUserObject());
657: }
658: } // Fin de la méthode removeFromModel/1
659:
660: public void updateList() {
661: temporaryTestList = new ArrayList();
662: temporaryTestListList = new ArrayList();
663: temporaryFamilyList = new ArrayList();
664: DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
665: .getRoot();
666: for (int j = 0; j < root.getChildCount(); j++) {
667: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
668: .getChildAt(j);
669: if (familyNode.getUserObject() instanceof Family) {
670: temporaryFamilyList.add(familyNode.getUserObject());
671: for (int k = 0; k < familyNode.getChildCount(); k++) {
672: DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) familyNode
673: .getChildAt(k);
674: if (testListNode.getUserObject() instanceof TestList) {
675: temporaryTestListList.add(testListNode
676: .getUserObject());
677: for (int l = 0; l < testListNode
678: .getChildCount(); l++) {
679: DefaultMutableTreeNode testNode = (DefaultMutableTreeNode) testListNode
680: .getChildAt(l);
681: if (testNode.getUserObject() instanceof Test) {
682: temporaryTestList.add(testNode
683: .getUserObject());
684: }
685: }
686: }
687: }
688: }
689: }
690: }
691: }
|