Source Code Cross Referenced for FillCampagne.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » org.objectweb.salome_tmf.ihm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SalomeTMF is a Test Management Framework
003:         * Copyright (C) 2005 France Telecom R&D
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *
019:         * @author Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.ihm;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Container;
028:        import java.awt.Dimension;
029:        import java.awt.Toolkit;
030:        import java.awt.event.ActionEvent;
031:        import java.awt.event.ActionListener;
032:        import java.util.ArrayList;
033:
034:        import javax.swing.BorderFactory;
035:        import javax.swing.Box;
036:        import javax.swing.BoxLayout;
037:        import javax.swing.JButton;
038:        import javax.swing.JDialog;
039:        import javax.swing.JPanel;
040:        import javax.swing.JScrollPane;
041:        import javax.swing.JTree;
042:        import javax.swing.event.TreeSelectionEvent;
043:        import javax.swing.event.TreeSelectionListener;
044:        import javax.swing.tree.DefaultMutableTreeNode;
045:        import javax.swing.tree.DefaultTreeModel;
046:        import javax.swing.tree.MutableTreeNode;
047:        import javax.swing.tree.TreePath;
048:
049:        import org.objectweb.salome_tmf.data.Family;
050:        import org.objectweb.salome_tmf.data.Test;
051:        import org.objectweb.salome_tmf.data.TestList;
052:        import org.objectweb.salome_tmf.ihm.datawrapper.DataModel;
053:        import org.objectweb.salome_tmf.ihm.languages.Language;
054:        import org.objectweb.salome_tmf.ihm.models.TestTreeModel;
055:        import org.objectweb.salome_tmf.ihm.models.TreeRenderer;
056:
057:        /**
058:         * Classe qui construit la fen?tre permettant de choisir les tests ? ins?rer
059:         * dans une campagne
060:         */
061:        public class FillCampagne extends JDialog {
062:            /**
063:             * Mod?le de l'arbre des tests
064:             */
065:            protected TestTreeModel testTreeModel;
066:
067:            /**
068:             * Mod?le de l'arbre des campagnes
069:             */
070:            protected TestTreeModel campagneTreeModel;
071:
072:            /**
073:             * l'arbre des campagnes
074:             */
075:            JTree campagneTree;
076:
077:            /**
078:             * l'arbre des tests
079:             */
080:            JTree testTree;
081:
082:            /**
083:             * Noeud s?lectionn? dans l'arbre des campagnes
084:             */
085:            DefaultMutableTreeNode campagneSelectedNode;
086:
087:            /**
088:             * Noeud s?lectionn? dans l'arbre des tests
089:             */
090:            DefaultMutableTreeNode testSelectedNode;
091:
092:            /**
093:             * Racine de l'arbre temporaire des campagnes
094:             */
095:            DefaultMutableTreeNode temporaryCampagneRootNode;
096:
097:            /**
098:             * Racine de l'arbre final des campagnes
099:             */
100:            DefaultMutableTreeNode realCampagneRoot;
101:
102:            /**
103:             * Toolkit
104:             */
105:            private Toolkit toolkit = Toolkit.getDefaultToolkit();
106:
107:            /**
108:             * Liste des tests s?lectionn?s
109:             */
110:            ArrayList temporaryTestList;
111:
112:            /**
113:             * Liste des suites s?lectionn?es
114:             */
115:            //ArrayList temporaryTestListList;
116:            /**
117:             * Liste des familles s?lectionn?es
118:             */
119:            //ArrayList temporaryFamilyList;
120:            /**
121:             * Mod?le de l'arbre qui sera finalement conserv?
122:             */
123:            TestTreeModel realModel;
124:
125:            ArrayList testSelectedNodes;
126:
127:            ArrayList campaignSelectedNodes;
128:
129:            /******************************************************************************/
130:            /** 							CONSTRUCTEURS								***/
131:            /******************************************************************************/
132:
133:            /**
134:             * Constructeur de la fen?tre pour l'ajout de tests ? une campagne.
135:             * @param campagneRoot le noeud racine de la campagne
136:             * @param model le mod?le de donn?es des tests
137:             * @param testRoot la racine de l'arbre des tests
138:             */
139:            public FillCampagne(DefaultMutableTreeNode campagneRoot,
140:                    TestTreeModel model, DefaultMutableTreeNode testRoot) {
141:
142:                super (SalomeTMF.ptrFrame, true);
143:
144:                temporaryTestList = new ArrayList();
145:                //temporaryTestListList = new ArrayList();
146:                //temporaryFamilyList = new ArrayList();
147:
148:                campaignSelectedNodes = new ArrayList();
149:                testSelectedNodes = new ArrayList();
150:
151:                realCampagneRoot = campagneRoot;
152:                realModel = model;
153:
154:                TreeRenderer campagneRenderer = new TreeRenderer();
155:                TreeRenderer testRenderer = new TreeRenderer();
156:
157:                temporaryCampagneRootNode = new DefaultMutableTreeNode(
158:                        campagneRoot.getUserObject());
159:
160:                campagneSelectedNode = temporaryCampagneRootNode;
161:
162:                campagneTreeModel = new TestTreeModel(temporaryCampagneRootNode);
163:                campagneTree = new JTree(campagneTreeModel);
164:
165:                initTemporaryTree(campagneRoot);
166:
167:                campagneTree.setCellRenderer(campagneRenderer);
168:                campagneTree
169:                        .addTreeSelectionListener(new TreeSelectionListener() {
170:                            public void valueChanged(TreeSelectionEvent e) {
171:                                campaignSelectedNodes.clear();
172:                                TreePath[] pathTab = campagneTree
173:                                        .getSelectionPaths();
174:                                if (pathTab != null) {
175:                                    for (int i = 0; i < pathTab.length; i++) {
176:                                        campaignSelectedNodes.add(pathTab[i]
177:                                                .getLastPathComponent());
178:                                    }
179:                                }
180:                            }
181:                        });
182:
183:                testTreeModel = new TestTreeModel(testRoot);
184:                testTree = new JTree(testTreeModel);
185:                testTree.setCellRenderer(testRenderer);
186:                testTree.addTreeSelectionListener(new TreeSelectionListener() {
187:                    public void valueChanged(TreeSelectionEvent e) {
188:                        testSelectedNodes.clear();
189:                        TreePath[] pathTab = testTree.getSelectionPaths();
190:                        if (pathTab != null) {
191:                            for (int i = 0; i < pathTab.length; i++) {
192:                                testSelectedNodes.add(pathTab[i]
193:                                        .getLastPathComponent());
194:                            }
195:                        }
196:                    }
197:                });
198:
199:                JButton removeButton = new JButton("<");
200:                removeButton.setToolTipText(Language.getInstance().getText(
201:                        "Retirer_de_la_campagne"));
202:                removeButton.addActionListener(new ActionListener() {
203:                    public void actionPerformed(ActionEvent e) {
204:                        int i = campaignSelectedNodes.size() - 1;
205:                        while (i >= 0) {
206:                            DefaultMutableTreeNode node = (DefaultMutableTreeNode) campaignSelectedNodes
207:                                    .get(i);
208:                            ((DefaultTreeModel) campagneTree.getModel())
209:                                    .removeNodeFromParent(node);
210:                            removeFromModel(node);
211:                            i = campaignSelectedNodes.size() - 1;
212:                        }
213:                    }
214:                });
215:
216:                JButton addButton = new JButton(">");
217:                addButton.setToolTipText(Language.getInstance().getText(
218:                        "Ajouter_à_la_campagne"));
219:                addButton.addActionListener(new ActionListener() {
220:                    public void actionPerformed(ActionEvent e) {
221:                        for (int i = 0; i < testSelectedNodes.size(); i++) {
222:                            Object nodeValue = ((DefaultMutableTreeNode) testSelectedNodes
223:                                    .get(i)).getUserObject();
224:                            testSelectedNode = ((DefaultMutableTreeNode) testSelectedNodes
225:                                    .get(i));
226:                            if (nodeValue instanceof  Family) {
227:                                addNodeToNode(testSelectedNode,
228:                                        temporaryCampagneRootNode);
229:
230:                            } else if (nodeValue instanceof  TestList) {
231:                                DefaultMutableTreeNode familyNode = findFamilyNodeInCampagneTree(((TestList) nodeValue)
232:                                        .getFamily().getName());
233:                                if (familyNode != null) {
234:                                    addNodeToNode(testSelectedNode, familyNode);
235:                                } else {
236:                                    DefaultMutableTreeNode newFamilyNode = addObject(
237:                                            temporaryCampagneRootNode,
238:                                            ((TestList) nodeValue).getFamily(),
239:                                            true);
240:                                    addNodeToNode(testSelectedNode,
241:                                            newFamilyNode);
242:                                }
243:                            } else if (nodeValue instanceof  Test) {
244:                                DefaultMutableTreeNode testListNode = findTestListNodeInCampagneTree(
245:                                        ((Test) nodeValue).getTestList()
246:                                                .getName(), ((Test) nodeValue)
247:                                                .getTestList().getFamily()
248:                                                .getName());
249:                                if (testListNode != null) {
250:                                    addNodeToNode(testSelectedNode,
251:                                            testListNode);
252:                                } else {
253:                                    DefaultMutableTreeNode familyNode = findFamilyNodeInCampagneTree(((Test) nodeValue)
254:                                            .getTestList().getFamily()
255:                                            .getName());
256:                                    if (familyNode != null) {
257:                                        DefaultMutableTreeNode newListNode = addObject(
258:                                                familyNode, ((Test) nodeValue)
259:                                                        .getTestList(), true);
260:                                        addNodeToNode(testSelectedNode,
261:                                                newListNode);
262:                                    } else {
263:                                        DefaultMutableTreeNode newFamilyNode = addObject(
264:                                                temporaryCampagneRootNode,
265:                                                ((Test) nodeValue)
266:                                                        .getTestList()
267:                                                        .getFamily(), true);
268:                                        DefaultMutableTreeNode newList = addObject(
269:                                                newFamilyNode,
270:                                                ((Test) nodeValue)
271:                                                        .getTestList(), true);
272:                                        addNodeToNode(testSelectedNode, newList);
273:                                    }
274:                                }
275:                            }
276:                        }
277:                    }
278:                });
279:
280:                JPanel buttonSet = new JPanel();
281:                buttonSet.setLayout(new BoxLayout(buttonSet, BoxLayout.Y_AXIS));
282:                buttonSet.add(addButton);
283:                buttonSet.add(Box.createRigidArea(new Dimension(1, 25)));
284:                buttonSet.add(removeButton);
285:
286:                JScrollPane campagneScrollPane = new JScrollPane(campagneTree);
287:                campagneScrollPane.setBorder(BorderFactory
288:                        .createTitledBorder(Language.getInstance().getText(
289:                                "Campagne")));
290:                campagneScrollPane.setPreferredSize(new Dimension(300, 450));
291:
292:                JScrollPane testScrollPane = new JScrollPane(testTree);
293:                testScrollPane.setBorder(BorderFactory
294:                        .createTitledBorder(Language.getInstance().getText(
295:                                "Tests")));
296:                testScrollPane.setPreferredSize(new Dimension(300, 450));
297:
298:                JPanel windowPanel = new JPanel();
299:                windowPanel.setLayout(new BoxLayout(windowPanel,
300:                        BoxLayout.X_AXIS));
301:                windowPanel.add(testScrollPane);
302:                windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
303:                windowPanel.add(buttonSet);
304:                windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
305:                windowPanel.add(campagneScrollPane);
306:
307:                JButton validate = new JButton(Language.getInstance().getText(
308:                        "Valider"));
309:                validate.setToolTipText(Language.getInstance().getText(
310:                        "Valider"));
311:                validate.addActionListener(new ActionListener() {
312:                    public void actionPerformed(ActionEvent e) {
313:                        int nbChildren = temporaryCampagneRootNode
314:                                .getChildCount();
315:                        for (int k = realCampagneRoot.getChildCount() - 1; k >= 0; k--) {
316:                            realModel
317:                                    .removeNodeFromParent((DefaultMutableTreeNode) realCampagneRoot
318:                                            .getChildAt(k));
319:                        }
320:                        for (int i = 0; i < nbChildren; i++) {
321:                            //realCampagneRoot.add((DefaultMutableTreeNode)temporaryCampagneRootNode.getChildAt(0));
322:                            realModel
323:                                    .insertNodeInto(
324:                                            (DefaultMutableTreeNode) temporaryCampagneRootNode
325:                                                    .getChildAt(0),
326:                                            realCampagneRoot, realCampagneRoot
327:                                                    .getChildCount());
328:                            //realModel.insertNodeInto((DefaultMutableTreeNode)temporaryCampagneRootNode.getChildAt(0), realCampagneRoot, realCampagneRoot.getChildCount());
329:                        }
330:
331:                        cleanTree(realModel, realCampagneRoot);
332:                        //DataModel.getCurrentCampaign().setFamilyList(temporaryFamilyList);
333:                        //DataModel.getCurrentCampaign().setTestListList(temporaryTestListList);
334:                        System.out.println("fill campagne "
335:                                + DataModel.getCurrentCampaign().getName());
336:                        DataModel.getCurrentCampaign().fillCamp(
337:                                temporaryTestList);
338:
339:                        FillCampagne.this .dispose();
340:                    }
341:                });
342:
343:                JButton cancel = new JButton(Language.getInstance().getText(
344:                        "Annuler"));
345:                cancel
346:                        .setToolTipText(Language.getInstance().getText(
347:                                "Annuler"));
348:                cancel.addActionListener(new ActionListener() {
349:                    public void actionPerformed(ActionEvent e) {
350:                        FillCampagne.this .dispose();
351:                    }
352:                });
353:
354:                JPanel secondButtonSet = new JPanel();
355:                secondButtonSet.add(validate);
356:                secondButtonSet.add(cancel);
357:
358:                JPanel center = new JPanel();
359:                center.add(windowPanel);
360:
361:                JPanel page = new JPanel();
362:                page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
363:                page.add(center);
364:                page.add(secondButtonSet);
365:
366:                Container contentPaneFrame = this .getContentPane();
367:                contentPaneFrame.add(page, BorderLayout.CENTER);
368:                this .setTitle(Language.getInstance().getText(
369:                        "AJouter_des_tests_à_une_campagne"));
370:                this .setLocation(300, 200);
371:                this .pack();
372:                this .setVisible(true);
373:
374:            } // Fin du constructeur FillCampagne/2
375:
376:            /**
377:             * M?thode R?cursive qui ajoute un noeud ? un autre noeud. Tous les fils du
378:             * noeud ? ajouter sont aussi ajouter r?cursivement.
379:             * @param nodeToBeAdded le noeud ? ajouter
380:             * @param nodeToReceive le noeud qui re?oit
381:             */
382:            private void addNodeToNode(DefaultMutableTreeNode nodeToBeAdded,
383:                    DefaultMutableTreeNode nodeToReceive) {
384:                DefaultMutableTreeNode newNode = null;
385:                for (int j = 0; j < nodeToReceive.getChildCount(); j++) {
386:                    if (((DefaultMutableTreeNode) nodeToReceive.getChildAt(j))
387:                            .getUserObject().equals(
388:                                    nodeToBeAdded.getUserObject())) {
389:                        newNode = (DefaultMutableTreeNode) nodeToReceive
390:                                .getChildAt(j);
391:                    }
392:                }
393:                if (newNode == null) {
394:                    newNode = new DefaultMutableTreeNode(nodeToBeAdded
395:                            .getUserObject());
396:                    campagneTreeModel.insertNodeInto(newNode, nodeToReceive,
397:                            nodeToReceive.getChildCount());
398:                    campagneTree.scrollPathToVisible(new TreePath(newNode
399:                            .getPath()));
400:                    /*if (nodeToBeAdded.getUserObject() instanceof Family) {
401:                        temporaryFamilyList.add(nodeToBeAdded.getUserObject());
402:                    } else if (nodeToBeAdded.getUserObject() instanceof TestList) {
403:                        temporaryTestListList.add(nodeToBeAdded.getUserObject());
404:                    } else */if (nodeToBeAdded.getUserObject() instanceof  Test) {
405:                        temporaryTestList.add(nodeToBeAdded.getUserObject());
406:                    }
407:                }
408:                for (int i = 0; i < nodeToBeAdded.getChildCount(); i++) {
409:                    addNodeToNode((DefaultMutableTreeNode) nodeToBeAdded
410:                            .getChildAt(i), newNode);
411:                }
412:            } // Fin de la m?thode addNodeToNode/2
413:
414:            /**
415:             * M?thode qui retourne le noeud correspondant ? une famille si le nom pass?
416:             * en param?tre est le nom d'une famille pr?sente dans l'arbre des campagnes
417:             * @param familyName un nom
418:             * @return le noeud correspondant ? une famille si le nom pass?
419:             * en param?tre est le nom d'une famille pr?sente dans l'arbre des campagnes,
420:             * <code>null</code> sinon.
421:             */
422:            public DefaultMutableTreeNode findFamilyNodeInCampagneTree(
423:                    String familyName) {
424:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) campagneTreeModel
425:                        .getRoot();
426:                for (int j = 0; j < root.getChildCount(); j++) {
427:                    DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
428:                            .getChildAt(j);
429:                    if (familyNode.getUserObject() instanceof  Family
430:                            && ((Family) familyNode.getUserObject()).getName()
431:                                    .equals(familyName)) {
432:                        return familyNode;
433:                    }
434:                }
435:                return null;
436:            } // Fin de la m?thode findFamilyNode/1
437:
438:            /**
439:             * M?thode qui retourne le noeud correspondant ? une suite si le nom pass?
440:             * en param?tre est le nom d'une suite pr?sente dans l'arbre des campagnes
441:             * @param testListName un nom
442:             * @return le noeud correspondant ? une famille si le nom pass?
443:             * en param?tre est le nom d'une famille pr?sente dans l'arbre des campagnes,
444:             * <code>null</code> sinon.
445:             */
446:            public DefaultMutableTreeNode findTestListNodeInCampagneTree(
447:                    String testListName, String familyName) {
448:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) campagneTreeModel
449:                        .getRoot();
450:                for (int j = 0; j < root.getChildCount(); j++) {
451:                    DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
452:                            .getChildAt(j);
453:                    if (familyNode.getUserObject() instanceof  Family
454:                            && ((Family) familyNode.getUserObject()).getName()
455:                                    .equals(familyName)) {
456:                        for (int k = 0; k < familyNode.getChildCount(); k++) {
457:                            DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) familyNode
458:                                    .getChildAt(k);
459:                            if (testListNode.getUserObject() instanceof  TestList
460:                                    && ((TestList) testListNode.getUserObject())
461:                                            .getName().equals(testListName)) {
462:                                return testListNode;
463:                            }
464:                        }
465:                    }
466:                }
467:                return null;
468:            } // Fin de la m?thode findFamilyNode/1
469:
470:            /**
471:             * M?thode d'ajout d'un noeud dans l'arbre sous le parent.
472:             * @param parent le parent
473:             * @param child le noeud ? ajouter
474:             * @param shouldBeVisible visible ou non
475:             * @return le nouveau noeud de l'arbre
476:             */
477:            public DefaultMutableTreeNode addObject(
478:                    DefaultMutableTreeNode parent, Object child,
479:                    boolean shouldBeVisible) {
480:
481:                DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(
482:                        child);
483:                if (parent == null) {
484:                    parent = temporaryCampagneRootNode;
485:                }
486:
487:                // Insertion du noeud
488:                campagneTreeModel.insertNodeInto(childNode, parent, parent
489:                        .getChildCount());
490:
491:                // on s'assure que le noeud est visible
492:                if (shouldBeVisible) {
493:                    campagneTree.scrollPathToVisible(new TreePath(childNode
494:                            .getPath()));
495:                }
496:                return childNode;
497:            } // Fin de la classe addObject/3
498:
499:            /**
500:             * Suppression du noeud courant.
501:             */
502:            public void removeCurrentNode() {
503:                TreePath currentSelection = campagneTree.getSelectionPath();
504:                if (currentSelection != null) {
505:                    DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) (currentSelection
506:                            .getLastPathComponent());
507:                    MutableTreeNode parent = (MutableTreeNode) (currentNode
508:                            .getParent());
509:                    if (parent != null) {
510:                        campagneTreeModel.removeNodeFromParent(currentNode);
511:                        removeFromModel(currentNode);
512:                        return;
513:                    }
514:                }
515:                // Si aucune s?lection ou si la racine est s?lectionn?e
516:                toolkit.beep();
517:            } // Fin de la classe removeCurrentNode/0
518:
519:            /**
520:             * Supprime du mod?le les ?l?ments retir?s de la campagne.
521:             * @param node le noeud ? partir duquel on retire les ?l?ments
522:             */
523:            private void removeFromModel(DefaultMutableTreeNode node) {
524:                for (int i = 0; i < node.getChildCount(); i++) {
525:                    removeFromModel((DefaultMutableTreeNode) node.getChildAt(i));
526:                }
527:                /*if (node.getUserObject() instanceof Family) {
528:                    temporaryFamilyList.remove(node.getUserObject());
529:                } else if (node.getUserObject() instanceof TestList) {
530:                    temporaryTestListList.remove(node.getUserObject());
531:                } else */if (node.getUserObject() instanceof  Test) {
532:                    temporaryTestList.remove(node.getUserObject());
533:                }
534:            } // Fin de la m?thode removeFromModel/1
535:
536:            /**
537:             * M?thode qui initialise l'arbre temporaire ? partir de la racine pass?
538:             * en param?tre.
539:             * @param root la racine du nouvel arbre temporaire
540:             */
541:            public void initTemporaryTree(DefaultMutableTreeNode root) {
542:                for (int i = 0; i < root.getChildCount(); i++) {
543:                    addNodeToNode((DefaultMutableTreeNode) root.getChildAt(i),
544:                            temporaryCampagneRootNode);
545:                }
546:            } // Fin de la m?thode initTemporaryTree/1
547:
548:            public void cleanTree(TestTreeModel model,
549:                    DefaultMutableTreeNode root) {
550:
551:                /*for (int i = root.getChildCount()-1; i >=0 ; i--) {
552:                    DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode)root.getChildAt(i);
553:                    for (int j = familyNode.getChildCount()-1; j >= 0 ; j--) {
554:                        if (familyNode.getChildAt(j).getChildCount() == 0) {
555:                            temporaryTestListList.remove(((DefaultMutableTreeNode)familyNode.getChildAt(j)).getUserObject());
556:                            ((Family)familyNode.getUserObject()).getTestListList().remove(((DefaultMutableTreeNode)familyNode.getChildAt(j)).getUserObject());
557:                            model.removeNodeFromParent((DefaultMutableTreeNode)familyNode.getChildAt(j));
558:                            
559:                        }
560:                    }
561:                    if (familyNode.getChildCount() == 0) {
562:                        temporaryFamilyList.remove((familyNode).getUserObject());
563:                        model.removeNodeFromParent(familyNode);
564:                        
565:                    }
566:                }*/
567:            }
568:        } // Fin de la classe FillCampagne
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.