Source Code Cross Referenced for TestOrdering.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » ihm » main » 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.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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;
0025:
0026:        import java.awt.BorderLayout;
0027:        import java.awt.Color;
0028:        import java.awt.Container;
0029:        import java.awt.Dimension;
0030:        import java.awt.GraphicsConfiguration;
0031:        import java.awt.GraphicsDevice;
0032:        import java.awt.GraphicsEnvironment;
0033:        import java.awt.GridLayout;
0034:        import java.awt.Rectangle;
0035:        import java.awt.event.ActionEvent;
0036:        import java.awt.event.ActionListener;
0037:        import java.util.ArrayList;
0038:        import java.util.HashMap;
0039:        import java.util.HashSet;
0040:        import java.util.Iterator;
0041:
0042:        import javax.swing.BorderFactory;
0043:        import javax.swing.Box;
0044:        import javax.swing.BoxLayout;
0045:        import javax.swing.ButtonGroup;
0046:        import javax.swing.DefaultComboBoxModel;
0047:        import javax.swing.DefaultListModel;
0048:        import javax.swing.Icon;
0049:        import javax.swing.JButton;
0050:        import javax.swing.JComboBox;
0051:        import javax.swing.JDialog;
0052:        import javax.swing.JLabel;
0053:        import javax.swing.JList;
0054:        import javax.swing.JPanel;
0055:        import javax.swing.JRadioButton;
0056:        import javax.swing.JScrollPane;
0057:        import javax.swing.ListSelectionModel;
0058:        import javax.swing.event.ListSelectionEvent;
0059:        import javax.swing.event.ListSelectionListener;
0060:        import javax.swing.tree.DefaultMutableTreeNode;
0061:
0062:        import org.objectweb.salome_tmf.api.Util;
0063:        import org.objectweb.salome_tmf.data.Campaign;
0064:        import org.objectweb.salome_tmf.data.Family;
0065:        import org.objectweb.salome_tmf.data.SimpleData;
0066:        import org.objectweb.salome_tmf.data.Test;
0067:        import org.objectweb.salome_tmf.data.TestList;
0068:        import org.objectweb.salome_tmf.ihm.IHMConstants;
0069:        import org.objectweb.salome_tmf.ihm.languages.Language;
0070:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0071:        import org.objectweb.salome_tmf.ihm.models.DynamicTree;
0072:        import org.objectweb.salome_tmf.ihm.models.TestListFamilyCampaignTreeNode;
0073:        import org.objectweb.salome_tmf.ihm.models.TestTreeModel;
0074:        import org.objectweb.salome_tmf.ihm.tools.Tools;
0075:
0076:        /**
0077:         * Classe qui définit la fenêtre pour ordonner les suites de tests
0078:         */
0079:        public class TestOrdering extends JDialog implements  IHMConstants,
0080:                ActionListener, ListSelectionListener {
0081:
0082:            DefaultListModel listModel; //Ancien modele de données avant organisation
0083:            HashSet familyHashSet;
0084:            HashSet campaignHashSet;
0085:
0086:            DefaultComboBoxModel comboModel; //Modéle de données pour le choix
0087:            JLabel comboLabel;
0088:
0089:            JComboBox choiceComboBox; //Liste déroulante pour le choix des suites ou des tests.
0090:            JButton upButton;
0091:            JButton downButton;
0092:            JButton validate;
0093:            DefaultComboBoxModel testListComboModel;
0094:            JList list;
0095:
0096:            HashMap testListMap; // Key : famille, Value ArrayList avec des suites de tests de cette famille
0097:            HashMap testMap; // Key suite de tests, Value ArrayList avec les tests de cette suite.
0098:
0099:            TestTreeModel workingModel;
0100:
0101:            JRadioButton familyButton;
0102:            JRadioButton testListButton;
0103:            JRadioButton testButton;
0104:            JRadioButton campagneButton;
0105:
0106:            DefaultMutableTreeNode familySelected;
0107:
0108:            DefaultMutableTreeNode testListSelected;
0109:            JScrollPane usersListScrollPane;
0110:
0111:            //boolean useCampaign;
0112:            DynamicTree pDynamicTree;
0113:
0114:            boolean campaignOrderModified; // Pour indiquer si l'ordre des campagnes a été modifié
0115:            boolean familyOrderModified; //Indique si l'ordre des familles a été modifié
0116:
0117:            ArrayList familiesTestListOrderModified; //Liste des familles dont l'ordre des suites a été modifié 
0118:            ArrayList testListTestOrderModified; //Liste des suites dont l'ordre des tests a été modifié
0119:            ArrayList campaignFamilyOrderModified; // Liste des campagnes dont l'ordre des familles a été modifié
0120:            ArrayList campaignFamiliesTestListTestOrderModified; // Liste des campagnes dont l'ordre des tests a été modifié
0121:            ArrayList campaignFamiliesTestListOrderModified;
0122:
0123:            boolean campaignMode = false;
0124:
0125:            public TestOrdering(DynamicTree testTreeModel, boolean _withCampaign) {
0126:                super (SalomeTMFContext.getInstance().ptrFrame, true);
0127:                int t_x = 1024;
0128:                int t_y = 768;
0129:                try {
0130:                    GraphicsEnvironment ge = GraphicsEnvironment
0131:                            .getLocalGraphicsEnvironment();
0132:                    GraphicsDevice[] gs = ge.getScreenDevices();
0133:                    GraphicsDevice gd = gs[0];
0134:                    GraphicsConfiguration[] gc = gd.getConfigurations();
0135:                    Rectangle r = gc[0].getBounds();
0136:                    t_x = r.width;
0137:                    t_y = r.height;
0138:
0139:                } catch (Exception E) {
0140:                    t_x = 1024;
0141:                    t_y = 768;
0142:                }
0143:                int decal_x = t_x / 5;
0144:                int decal_y = t_x / 6;
0145:
0146:                campaignMode = _withCampaign;
0147:                pDynamicTree = testTreeModel;
0148:                campaignOrderModified = false;
0149:                familyOrderModified = false;
0150:                familiesTestListOrderModified = new ArrayList();
0151:                testListTestOrderModified = new ArrayList();
0152:                campaignFamilyOrderModified = new ArrayList();
0153:                campaignFamiliesTestListOrderModified = new ArrayList();
0154:                campaignFamiliesTestListTestOrderModified = new ArrayList();
0155:                familyHashSet = new HashSet();
0156:                campaignHashSet = new HashSet();
0157:
0158:                /** North Panel **/
0159:                familyButton = new JRadioButton(Language.getInstance().getText(
0160:                        "Familles"));
0161:                testListButton = new JRadioButton(Language.getInstance()
0162:                        .getText("Suites"));
0163:                testButton = new JRadioButton(Language.getInstance().getText(
0164:                        "Tests"));
0165:                campagneButton = new JRadioButton(Language.getInstance()
0166:                        .getText("Campagnes"));
0167:                campagneButton.addActionListener(this );
0168:                familyButton.addActionListener(this );
0169:                testListButton.addActionListener(this );
0170:                testButton.addActionListener(this );
0171:                /*Grouper les boutons radio*/
0172:                ButtonGroup choiceGroup = new ButtonGroup();
0173:                if (campaignMode) {
0174:                    choiceGroup.add(campagneButton);
0175:                }
0176:                choiceGroup.add(familyButton);
0177:                choiceGroup.add(testListButton);
0178:                choiceGroup.add(testButton);
0179:                /*Put the radio buttons in a column in a panel*/
0180:                JPanel radioPanel = new JPanel(new GridLayout(1, 0));
0181:                if (campaignMode) {
0182:                    radioPanel.add(campagneButton);
0183:                }
0184:                radioPanel.add(familyButton);
0185:                radioPanel.add(testListButton);
0186:                radioPanel.add(testButton);
0187:
0188:                /** Combo Panel **/
0189:                testListComboModel = new DefaultComboBoxModel();
0190:                comboModel = new DefaultComboBoxModel();
0191:                choiceComboBox = new JComboBox(comboModel);
0192:                choiceComboBox.setEnabled(false);
0193:                choiceComboBox.addActionListener(this );
0194:                comboLabel = new JLabel();
0195:
0196:                JPanel comboPanel = new JPanel();
0197:                comboPanel
0198:                        .setLayout(new BoxLayout(comboPanel, BoxLayout.X_AXIS));
0199:                comboPanel.add(comboLabel);
0200:                comboPanel.add(choiceComboBox);
0201:                JPanel northPanel = new JPanel();
0202:                northPanel
0203:                        .setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
0204:                northPanel.add(radioPanel);
0205:                northPanel.add(comboPanel);
0206:                northPanel.setBorder(BorderFactory
0207:                        .createLineBorder(Color.BLACK));
0208:
0209:                /** Center Panel **/
0210:                upButton = new JButton();
0211:                Icon icon = Tools.createAppletImageIcon(PATH_TO_ARROW_UP_ICON,
0212:                        "");
0213:                upButton.setIcon(icon);
0214:                upButton.setEnabled(false);
0215:                upButton.setToolTipText(Language.getInstance().getText(
0216:                        "Monter_d'un_cran"));
0217:                upButton.addActionListener(this );
0218:                downButton = new JButton();
0219:                icon = Tools.createAppletImageIcon(PATH_TO_ARROW_DOWN_ICON, "");
0220:                downButton.setIcon(icon);
0221:                downButton.setEnabled(false);
0222:                downButton.setToolTipText(Language.getInstance().getText(
0223:                        "Descendre_d'un_cran"));
0224:                downButton.addActionListener(this );
0225:
0226:                JPanel buttonSet = new JPanel();
0227:                buttonSet.setLayout(new BoxLayout(buttonSet, BoxLayout.Y_AXIS));
0228:                buttonSet.add(upButton);
0229:                buttonSet.add(Box.createRigidArea(new Dimension(1, 25)));
0230:                buttonSet.add(downButton);
0231:
0232:                listModel = new DefaultListModel();
0233:                list = new JList(listModel);
0234:                list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
0235:
0236:                list.setSelectedIndex(0);
0237:                list.addListSelectionListener(this );
0238:                list.setVisibleRowCount(listModel.getSize());
0239:
0240:                usersListScrollPane = new JScrollPane(list);
0241:
0242:                usersListScrollPane.setBorder(BorderFactory
0243:                        .createTitledBorder(""));
0244:                usersListScrollPane.setPreferredSize(new Dimension(t_x * 3 / 5,
0245:                        (t_y * 3 / 6) - 25));
0246:
0247:                JPanel centerPanel = new JPanel();
0248:                centerPanel.add(usersListScrollPane);
0249:                centerPanel.add(buttonSet);
0250:
0251:                /** SOUTH Panel **/
0252:                validate = new JButton(Language.getInstance().getText(
0253:                        "Terminer"));
0254:                validate.addActionListener(this );
0255:                JPanel southPanel = new JPanel();
0256:                southPanel.add(validate);
0257:
0258:                /** Main Panel **/
0259:                Container contentPaneFrame = this .getContentPane();
0260:                contentPaneFrame.setLayout(new BorderLayout());
0261:                contentPaneFrame.add(northPanel, BorderLayout.NORTH);
0262:                contentPaneFrame.add(centerPanel, BorderLayout.CENTER);
0263:                contentPaneFrame.add(southPanel, BorderLayout.SOUTH);
0264:
0265:                initData();
0266:                initToCurrentSelected();
0267:
0268:                setSize(new Dimension(t_x * 3 / 5, t_y * 4 / 6));
0269:                this .setTitle(Language.getInstance().getText("Ordonner"));
0270:
0271:                /*this.pack();
0272:                this.setLocationRelativeTo(this.getParent()); 
0273:                this.setVisible(true);
0274:                 */
0275:                centerScreen();
0276:            } // Fin du constructeur Ordering/1
0277:
0278:            void centerScreen() {
0279:                Dimension dim = getToolkit().getScreenSize();
0280:                this .pack();
0281:                Rectangle abounds = getBounds();
0282:                setLocation((dim.width - abounds.width) / 2,
0283:                        (dim.height - abounds.height) / 2);
0284:                this .setVisible(true);
0285:                requestFocus();
0286:            }
0287:
0288:            public void initData() {
0289:                //listModel = new DefaultListModel();
0290:                workingModel = pDynamicTree.getModel();
0291:                comboModel.removeAllElements();
0292:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) workingModel
0293:                        .getRoot();
0294:                if (campaignMode) {
0295:                    for (int i = 0; i < root.getChildCount(); i++) {
0296:                        TestListFamilyCampaignTreeNode tlfcampaign = new TestListFamilyCampaignTreeNode();
0297:                        tlfcampaign
0298:                                .setCampaignNode((DefaultMutableTreeNode) root
0299:                                        .getChildAt(i));
0300:                        campaignHashSet.add(tlfcampaign);
0301:                        for (int j = 0; j < ((DefaultMutableTreeNode) root
0302:                                .getChildAt(i)).getChildCount(); j++) {
0303:                            DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) root
0304:                                    .getChildAt(i)).getChildAt(j);
0305:                            TestListFamilyCampaignTreeNode tlfamily = new TestListFamilyCampaignTreeNode();
0306:                            tlfamily
0307:                                    .setCampaignNode((DefaultMutableTreeNode) root
0308:                                            .getChildAt(i));
0309:                            tlfamily.setFamilyNode(familyNode);
0310:                            familyHashSet.add(tlfamily);
0311:                            for (int k = 0; k < familyNode.getChildCount(); k++) {
0312:                                TestListFamilyCampaignTreeNode tlfList = new TestListFamilyCampaignTreeNode();
0313:                                tlfList
0314:                                        .setCampaignNode((DefaultMutableTreeNode) root
0315:                                                .getChildAt(i));
0316:                                tlfList.setFamilyNode(familyNode);
0317:                                tlfList
0318:                                        .setTestListNode((DefaultMutableTreeNode) familyNode
0319:                                                .getChildAt(k));
0320:                                testListComboModel.addElement(tlfList);
0321:                            }
0322:                        }
0323:                    }
0324:                } else {
0325:                    for (int i = 0; i < root.getChildCount(); i++) {
0326:                        for (int j = 0; j < ((DefaultMutableTreeNode) root
0327:                                .getChildAt(i)).getChildCount(); j++) {
0328:                            TestListFamilyCampaignTreeNode tlfFamily = new TestListFamilyCampaignTreeNode();
0329:                            tlfFamily
0330:                                    .setFamilyNode((DefaultMutableTreeNode) root
0331:                                            .getChildAt(i));
0332:                            familyHashSet.add(tlfFamily);
0333:                            TestListFamilyCampaignTreeNode tlfList = new TestListFamilyCampaignTreeNode();
0334:                            tlfList.setFamilyNode((DefaultMutableTreeNode) root
0335:                                    .getChildAt(i));
0336:                            tlfList
0337:                                    .setTestListNode((DefaultMutableTreeNode) ((DefaultMutableTreeNode) root
0338:                                            .getChildAt(i)).getChildAt(j));
0339:                            testListComboModel.addElement(tlfList);
0340:
0341:                        }
0342:                    }
0343:                }
0344:
0345:            }
0346:
0347:            void initToCurrentSelected() {
0348:                DefaultMutableTreeNode pNode = pDynamicTree.getSelectedNode();
0349:                SimpleData pData = null;
0350:                SimpleData parentData = null;
0351:                if (pNode == null) {
0352:                    return;
0353:                } else {
0354:                    if (pNode.getUserObject() instanceof  SimpleData)
0355:                        pData = (SimpleData) pNode.getUserObject();
0356:                }
0357:                DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) pNode
0358:                        .getParent();
0359:
0360:                if (parentNode != null) {
0361:                    if (parentNode.getUserObject() instanceof  SimpleData) {
0362:                        parentData = (SimpleData) parentNode.getUserObject();
0363:                    }
0364:                }
0365:
0366:                boolean trouve = false;
0367:                int size = 0;
0368:                boolean trouve2 = false;
0369:                int size2 = 0;
0370:                int i = 0;
0371:                if (pData instanceof  Campaign) {
0372:                    campagneButton.setSelected(true);
0373:                    campagnePerformed(null);
0374:                    size2 = listModel.getSize();
0375:                    i = 0;
0376:                    while (i < size2 && !trouve2) {
0377:                        DefaultMutableTreeNode pTempNode = (DefaultMutableTreeNode) listModel
0378:                                .getElementAt(i);
0379:                        Campaign pCamp = (Campaign) pTempNode.getUserObject();
0380:                        if (pCamp.getIdBdd() == pData.getIdBdd()) {
0381:                            trouve2 = true;
0382:                        } else {
0383:                            i++;
0384:                        }
0385:                    }
0386:                    if (trouve2) {
0387:                        list.setSelectedIndex(i);
0388:                    }
0389:                } else if (pData instanceof  Family) {
0390:                    familyButton.setSelected(true);
0391:                    familyPerformed(null);
0392:                    if (campaignMode) {
0393:                        size = comboModel.getSize();
0394:                        while (i < size && !trouve) {
0395:                            TestListFamilyCampaignTreeNode tlf = (TestListFamilyCampaignTreeNode) comboModel
0396:                                    .getElementAt(i);
0397:                            Campaign pCamp = (Campaign) tlf.getCampaignNode()
0398:                                    .getUserObject();
0399:                            if (pCamp.getIdBdd() == parentData.getIdBdd()) {
0400:                                trouve = true;
0401:                            } else {
0402:                                i++;
0403:                            }
0404:                        }
0405:                        if (trouve) {
0406:                            choiceComboBox.setSelectedIndex(i);
0407:                        }
0408:
0409:                    } else {
0410:                        // NOTHING
0411:                    }
0412:                    size2 = listModel.getSize();
0413:                    i = 0;
0414:                    while (i < size2 && !trouve2) {
0415:                        DefaultMutableTreeNode pTempNode = (DefaultMutableTreeNode) listModel
0416:                                .getElementAt(i);
0417:                        Family pFamily = (Family) pTempNode.getUserObject();
0418:                        if (pFamily.getIdBdd() == pData.getIdBdd()) {
0419:                            trouve2 = true;
0420:                        } else {
0421:                            i++;
0422:                        }
0423:                    }
0424:                    if (trouve2) {
0425:                        list.setSelectedIndex(i);
0426:                    }
0427:
0428:                } else if (pData instanceof  TestList) {
0429:                    testListButton.setSelected(true);
0430:                    testListPerformed(null);
0431:                    size = comboModel.getSize();
0432:                    while (i < size && !trouve) {
0433:                        TestListFamilyCampaignTreeNode tlf = (TestListFamilyCampaignTreeNode) comboModel
0434:                                .getElementAt(i);
0435:                        Family pFamily = (Family) tlf.getFamilyNode()
0436:                                .getUserObject();
0437:                        if (pFamily.getIdBdd() == parentData.getIdBdd()) {
0438:                            trouve = true;
0439:                        } else {
0440:                            i++;
0441:                        }
0442:                    }
0443:                    if (trouve) {
0444:                        choiceComboBox.setSelectedIndex(i);
0445:                    }
0446:                    size2 = listModel.getSize();
0447:                    i = 0;
0448:                    while (i < size2 && !trouve2) {
0449:                        DefaultMutableTreeNode pTempNode = (DefaultMutableTreeNode) listModel
0450:                                .getElementAt(i);
0451:                        TestList pTestList = (TestList) pTempNode
0452:                                .getUserObject();
0453:                        if (pTestList.getIdBdd() == pData.getIdBdd()) {
0454:                            trouve2 = true;
0455:                        } else {
0456:                            i++;
0457:                        }
0458:                    }
0459:                    if (trouve2) {
0460:                        list.setSelectedIndex(i);
0461:                    }
0462:                } else if (pData instanceof  Test) {
0463:                    testButton.setSelected(true);
0464:                    testPerformed(null);
0465:                    size = comboModel.getSize();
0466:                    while (i < size && !trouve) {
0467:                        TestListFamilyCampaignTreeNode tlf = (TestListFamilyCampaignTreeNode) comboModel
0468:                                .getElementAt(i);
0469:                        TestList pTestList = (TestList) tlf.getTestListNode()
0470:                                .getUserObject();
0471:                        if (pTestList.getIdBdd() == parentData.getIdBdd()) {
0472:                            trouve = true;
0473:                        } else {
0474:                            i++;
0475:                        }
0476:                    }
0477:                    if (trouve) {
0478:                        choiceComboBox.setSelectedIndex(i);
0479:                    }
0480:                    size2 = listModel.getSize();
0481:                    i = 0;
0482:                    while (i < size2 && !trouve2) {
0483:                        DefaultMutableTreeNode pTempNode = (DefaultMutableTreeNode) listModel
0484:                                .getElementAt(i);
0485:                        Test pTest = (Test) pTempNode.getUserObject();
0486:                        if (pTest.getIdBdd() == pData.getIdBdd()) {
0487:                            trouve2 = true;
0488:                        } else {
0489:                            i++;
0490:                        }
0491:                    }
0492:                    if (trouve2) {
0493:                        list.setSelectedIndex(i);
0494:                    }
0495:                }
0496:            }
0497:
0498:            private boolean containsValue(TestListFamilyCampaignTreeNode tlf) {
0499:                int size = comboModel.getSize();
0500:                for (int i = 0; i < size; i++) {
0501:                    if (((TestListFamilyCampaignTreeNode) comboModel
0502:                            .getElementAt(i)).getFamilyNode().equals(
0503:                            tlf.getFamilyNode())) {
0504:                        return true;
0505:                    }
0506:                }
0507:                return false;
0508:            }
0509:
0510:            /********************** ActionListener ******************************/
0511:
0512:            public void actionPerformed(ActionEvent e) {
0513:                if (e.getSource().equals(campagneButton)) {
0514:                    campagnePerformed(e);
0515:                } else if (e.getSource().equals(familyButton)) {
0516:                    familyPerformed(e);
0517:                } else if (e.getSource().equals(testListButton)) {
0518:                    testListPerformed(e);
0519:                } else if (e.getSource().equals(testButton)) {
0520:                    testPerformed(e);
0521:                } else if (e.getSource().equals(choiceComboBox)) {
0522:                    choiceComboPerformed(e);
0523:                } else if (e.getSource().equals(upButton)) {
0524:                    upPerformed(e);
0525:                } else if (e.getSource().equals(downButton)) {
0526:                    downPerformed(e);
0527:                } else if (e.getSource().equals(validate)) {
0528:                    validatePerformed(e);
0529:                }
0530:            }
0531:
0532:            void validatePerformed(ActionEvent e) {
0533:                TestOrdering.this .dispose();
0534:            }
0535:
0536:            void campagnePerformed(ActionEvent e) {
0537:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) workingModel
0538:                        .getRoot();
0539:                listModel.clear();
0540:                comboModel.removeAllElements();
0541:                choiceComboBox.setEnabled(false);
0542:                usersListScrollPane.setBorder(BorderFactory
0543:                        .createTitledBorder(Language.getInstance().getText(
0544:                                "Campagnes")));
0545:                for (int i = 0; i < root.getChildCount(); i++) {
0546:                    listModel.addElement(root.getChildAt(i));
0547:                }
0548:                comboLabel.setText("");
0549:            }
0550:
0551:            void familyPerformed(ActionEvent e) {
0552:                if (campaignMode) {
0553:                    choiceComboBox.setEnabled(true);
0554:                    comboModel.removeAllElements();
0555:                    for (Iterator iter = campaignHashSet.iterator(); iter
0556:                            .hasNext();) {
0557:                        comboModel.addElement(iter.next());
0558:                    }
0559:                    comboLabel.setText(Language.getInstance().getText(
0560:                            "Campagne")
0561:                            + " : ");
0562:                } else {
0563:                    DefaultMutableTreeNode root = (DefaultMutableTreeNode) workingModel
0564:                            .getRoot();
0565:                    listModel.clear();
0566:                    comboModel.removeAllElements();
0567:                    choiceComboBox.setEnabled(false);
0568:                    for (int i = 0; i < root.getChildCount(); i++) {
0569:                        listModel.addElement(root.getChildAt(i));
0570:                    }
0571:                    comboLabel.setText("");
0572:                }
0573:                usersListScrollPane.setBorder(BorderFactory
0574:                        .createTitledBorder(Language.getInstance().getText(
0575:                                "Familles")));
0576:            }
0577:
0578:            void testListPerformed(ActionEvent e) {
0579:                choiceComboBox.setEnabled(true);
0580:                listModel.clear();
0581:                comboModel.removeAllElements();
0582:                if (campaignMode) {
0583:                    comboLabel.setText(Language.getInstance().getText(
0584:                            "Campagne")
0585:                            + "/"
0586:                            + Language.getInstance().getText("Famille")
0587:                            + " : ");
0588:                } else {
0589:                    comboLabel.setText(Language.getInstance()
0590:                            .getText("Famille")
0591:                            + " : ");
0592:                }
0593:                usersListScrollPane.setBorder(BorderFactory
0594:                        .createTitledBorder(Language.getInstance().getText(
0595:                                "Suites")));
0596:                for (Iterator iter = familyHashSet.iterator(); iter.hasNext();) {
0597:                    TestListFamilyCampaignTreeNode tlf = (TestListFamilyCampaignTreeNode) iter
0598:                            .next();
0599:                    if (!containsValue(tlf)) {
0600:                        comboModel.addElement(tlf);
0601:                    }
0602:                }
0603:            }
0604:
0605:            void testPerformed(ActionEvent e) {
0606:                choiceComboBox.setEnabled(true);
0607:                listModel.clear();
0608:                comboModel.removeAllElements();
0609:                usersListScrollPane.setBorder(BorderFactory
0610:                        .createTitledBorder(Language.getInstance().getText(
0611:                                "Tests")));
0612:                if (campaignMode) {
0613:                    comboLabel.setText(Language.getInstance().getText(
0614:                            "Campagne")
0615:                            + "/"
0616:                            + Language.getInstance().getText("Famille")
0617:                            + "/"
0618:                            + Language.getInstance().getText("Suite")
0619:                            + " : ");
0620:                } else {
0621:                    comboLabel.setText(Language.getInstance()
0622:                            .getText("Famille")
0623:                            + "/"
0624:                            + Language.getInstance().getText("Suite")
0625:                            + " : ");
0626:                }
0627:                //DefaultMutableTreeNode root = (DefaultMutableTreeNode)workingModel.getRoot();
0628:                for (int i = 0; i < testListComboModel.getSize(); i++) {
0629:                    comboModel.addElement(testListComboModel.getElementAt(i));
0630:                }
0631:            }
0632:
0633:            void choiceComboPerformed(ActionEvent e) {
0634:                listModel.clear();
0635:                TestListFamilyCampaignTreeNode selectedNode = ((TestListFamilyCampaignTreeNode) choiceComboBox
0636:                        .getSelectedItem());
0637:                ;
0638:                if (selectedNode != null) {
0639:                    if (familyButton.isSelected() && campaignMode) {
0640:                        for (int i = 0; i < selectedNode.getCampaignNode()
0641:                                .getChildCount(); i++) {
0642:                            listModel.addElement(selectedNode.getCampaignNode()
0643:                                    .getChildAt(i));
0644:                        }
0645:                    } else if (testListButton.isSelected()) {
0646:                        for (int i = 0; i < selectedNode.getFamilyNode()
0647:                                .getChildCount(); i++) {
0648:                            listModel.addElement(selectedNode.getFamilyNode()
0649:                                    .getChildAt(i));
0650:                        }
0651:                    } else if (testButton.isSelected()) {
0652:                        for (int i = 0; i < selectedNode.getTestListNode()
0653:                                .getChildCount(); i++) {
0654:                            listModel.addElement(selectedNode.getTestListNode()
0655:                                    .getChildAt(i));
0656:                        }
0657:                    }
0658:                }
0659:            }
0660:
0661:            void upPerformed(ActionEvent e) {
0662:                int selectedIndex = list.getSelectedIndex();
0663:                if (selectedIndex != -1) {
0664:                    Object objToGoUp = listModel.getElementAt(selectedIndex);
0665:                    Object objToGoDown = listModel
0666:                            .getElementAt(selectedIndex - 1);
0667:                    listModel.setElementAt(objToGoUp, selectedIndex - 1);
0668:                    listModel.setElementAt(objToGoDown, selectedIndex);
0669:                    list.setSelectedIndex(selectedIndex - 1);
0670:                    DefaultMutableTreeNode nodeToGoUp = null;
0671:                    DefaultMutableTreeNode nodeToGoDown = null;
0672:                    if (campagneButton.isSelected()) {
0673:
0674:                        try {
0675:                            ((Campaign) ((DefaultMutableTreeNode) objToGoUp)
0676:                                    .getUserObject())
0677:                                    .updateOrderInDBAndModel(false);
0678:
0679:                            // IHM
0680:                            nodeToGoUp = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) workingModel
0681:                                    .getRoot()).getChildAt(selectedIndex);
0682:                            Campaign pCamp = (Campaign) nodeToGoUp
0683:                                    .getUserObject();
0684:
0685:                            workingModel.removeNodeFromParent(nodeToGoUp);
0686:                            workingModel.insertNodeInto(nodeToGoUp,
0687:                                    ((DefaultMutableTreeNode) workingModel
0688:                                            .getRoot()), selectedIndex - 1);
0689:                            DataModel.getCurrentProject()
0690:                                    .getCampaignListFromModel().remove(pCamp);
0691:                            DataModel.getCurrentProject()
0692:                                    .getCampaignListFromModel().add(
0693:                                            (selectedIndex - 1), pCamp);
0694:                            campaignOrderModified = true;
0695:
0696:                        } catch (Exception exception) {
0697:                            Tools.ihmExceptionView(exception);
0698:                        }
0699:                    } else if (familyButton.isSelected()) {
0700:                        if (campaignMode) {
0701:                            nodeToGoDown = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0702:                                    .getSelectedItem()).getCampaignNode()
0703:                                    .getChildAt(selectedIndex - 1);
0704:                            nodeToGoUp = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0705:                                    .getSelectedItem()).getCampaignNode()
0706:                                    .getChildAt(selectedIndex);
0707:                            ArrayList oldTestList = ((Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
0708:                                    .getSelectedItem()).getCampaignNode())
0709:                                    .getUserObject()).getTestListFromModel();
0710:                            ArrayList oldSuiteList = ((Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
0711:                                    .getSelectedItem()).getCampaignNode())
0712:                                    .getUserObject()).getSuitListFromModel();
0713:                            int firstTestIndex = oldTestList
0714:                                    .indexOf(((DefaultMutableTreeNode) ((DefaultMutableTreeNode) nodeToGoDown
0715:                                            .getFirstChild()).getFirstChild())
0716:                                            .getUserObject());
0717:                            int firstSuiteIndex = oldSuiteList
0718:                                    .indexOf(((DefaultMutableTreeNode) nodeToGoDown
0719:                                            .getFirstChild()).getUserObject());
0720:
0721:                            try {
0722:                                // BdD
0723:                                Campaign camp = (Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
0724:                                        .getSelectedItem()).getCampaignNode())
0725:                                        .getUserObject();
0726:                                Family pFamilyUp = (Family) nodeToGoUp
0727:                                        .getUserObject();
0728:                                //Family pFamilyDown = (Family)nodeToGoUp.getUserObject();
0729:
0730:                                camp.updateTestFamilyOrderInDB(pFamilyUp
0731:                                        .getIdBdd(), false);
0732:
0733:                                // IHM
0734:                                camp.reloadTestCampain(DataModel
0735:                                        .getCurrentProject()
0736:                                        .getAlltestFromModel());
0737:                                /*for (int j = 0; j < pFamilyUp.getSuiteListFromModel().size(); j++) {
0738:                                	TestList testList = (TestList)pFamilyUp.getSuiteListFromModel().get(j);
0739:                                	camp.getSuitListFromModel().remove(pFamilyUp.getSuiteListFromModel().get(j));
0740:                                	for (int k = 0; k < testList.getTestListFromModel().size(); k++) {
0741:                                		camp.getTestListFromModel().remove(testList.getTestListFromModel().get(k));
0742:                                		
0743:                                	}
0744:                                }
0745:                                int addIndex = firstTestIndex;
0746:                                for (int j = 0; j < pFamilyUp.getSuiteListFromModel().size(); j++) {
0747:                                	TestList testList = (TestList)pFamilyUp.getSuiteListFromModel().get(j);
0748:                                	camp.getSuitListFromModel().add((j+firstSuiteIndex), pFamilyUp.getSuiteListFromModel().get(j));
0749:                                	for (int k = 0; k < testList.getTestListFromModel().size(); k++) {
0750:                                		camp.getTestListFromModel().add((k+addIndex), testList.getTestListFromModel().get(k));
0751:                                		addIndex++;
0752:                                	}
0753:                                }*/
0754:
0755:                                workingModel.removeNodeFromParent(nodeToGoUp);
0756:                                workingModel
0757:                                        .insertNodeInto(
0758:                                                nodeToGoUp,
0759:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
0760:                                                        .getSelectedItem())
0761:                                                        .getCampaignNode(),
0762:                                                selectedIndex - 1);
0763:                                campaignFamilyOrderModified.add(camp);
0764:                                //camp.getFamilyListFromModel().remove(pFamilyUp);
0765:                                //camp.getFamilyListFromModel().add((selectedIndex-1),pFamilyUp);
0766:                            } catch (Exception exception) {
0767:                                Tools.ihmExceptionView(exception);
0768:                            }
0769:
0770:                        } else {
0771:
0772:                            try {
0773:                                //Decrementation du selectionné
0774:                                ((Family) ((DefaultMutableTreeNode) objToGoUp)
0775:                                        .getUserObject())
0776:                                        .updateOrderInBddAndModel(false);
0777:
0778:                                //IHM
0779:                                nodeToGoUp = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) workingModel
0780:                                        .getRoot()).getChildAt(selectedIndex);
0781:                                Family pFamilyUp = (Family) nodeToGoUp
0782:                                        .getUserObject();
0783:                                workingModel.removeNodeFromParent(nodeToGoUp);
0784:                                workingModel.insertNodeInto(nodeToGoUp,
0785:                                        ((DefaultMutableTreeNode) workingModel
0786:                                                .getRoot()), selectedIndex - 1);
0787:                                DataModel.getCurrentProject()
0788:                                        .getFamilyListFromModel().remove(
0789:                                                pFamilyUp);
0790:                                DataModel.getCurrentProject()
0791:                                        .getFamilyListFromModel().add(
0792:                                                (selectedIndex - 1), pFamilyUp);
0793:                                familyOrderModified = true;
0794:                            } catch (Exception exception) {
0795:                                Tools.ihmExceptionView(exception);
0796:                            }
0797:                        }
0798:                    } else if (testListButton.isSelected()) {
0799:                        nodeToGoUp = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0800:                                .getSelectedItem()).getFamilyNode().getChildAt(
0801:                                selectedIndex);
0802:                        nodeToGoDown = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0803:                                .getSelectedItem()).getFamilyNode().getChildAt(
0804:                                selectedIndex - 1);
0805:                        if (((TestListFamilyCampaignTreeNode) choiceComboBox
0806:                                .getSelectedItem()).getCampaignNode() == null) {
0807:
0808:                            try {
0809:                                ((TestList) nodeToGoUp.getUserObject())
0810:                                        .updateOrderInDBAndModel(false);
0811:
0812:                                //IHM
0813:                                workingModel.removeNodeFromParent(nodeToGoUp);
0814:                                Family pFamily = (Family) ((TestListFamilyCampaignTreeNode) choiceComboBox
0815:                                        .getSelectedItem()).getFamilyNode()
0816:                                        .getUserObject();
0817:                                workingModel
0818:                                        .insertNodeInto(
0819:                                                nodeToGoUp,
0820:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
0821:                                                        .getSelectedItem())
0822:                                                        .getFamilyNode(),
0823:                                                selectedIndex - 1);
0824:                                familiesTestListOrderModified.add(pFamily);
0825:                                pFamily.getSuiteListFromModel().remove(
0826:                                        nodeToGoUp.getUserObject());
0827:                                pFamily.getSuiteListFromModel().add(
0828:                                        (selectedIndex - 1),
0829:                                        nodeToGoUp.getUserObject());
0830:                            } catch (Exception exception) {
0831:                                Tools.ihmExceptionView(exception);
0832:                            }
0833:                        } else {
0834:                            ArrayList oldTestList = ((Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
0835:                                    .getSelectedItem()).getCampaignNode())
0836:                                    .getUserObject()).getTestListFromModel();
0837:                            // On récupère l'indice du premier test de la suite qui descend
0838:                            int firstIndex = oldTestList
0839:                                    .indexOf(((DefaultMutableTreeNode) nodeToGoDown
0840:                                            .getFirstChild()).getUserObject());
0841:                            int i = 0;
0842:                            if (firstIndex != -1) {
0843:
0844:                                try {
0845:                                    // BdD
0846:                                    Campaign camp = (Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
0847:                                            .getSelectedItem())
0848:                                            .getCampaignNode()).getUserObject();
0849:                                    camp.updateTestSuiteOrderInDB(
0850:                                            ((TestList) nodeToGoUp
0851:                                                    .getUserObject())
0852:                                                    .getIdBdd(), false);
0853:
0854:                                    // IHM
0855:                                    camp.reloadTestCampain(DataModel
0856:                                            .getCurrentProject()
0857:                                            .getAlltestFromModel());
0858:                                    /*for (i = 0; i < ((TestList)nodeToGoUp.getUserObject()).getTestListFromModel().size(); i++) {
0859:                                    	camp.getTestListFromModel().remove(((TestList)nodeToGoUp.getUserObject()).getTestListFromModel().get(i));
0860:                                    }
0861:                                    for (i = 0; i < ((TestList)nodeToGoUp.getUserObject()).getTestListFromModel().size(); i++) {
0862:                                    	camp.getTestListFromModel().add((i+firstIndex), ((TestList)nodeToGoUp.getUserObject()).getTestListFromModel().get(i));
0863:                                    }*/
0864:
0865:                                    workingModel
0866:                                            .removeNodeFromParent(nodeToGoUp);
0867:                                    workingModel
0868:                                            .insertNodeInto(
0869:                                                    nodeToGoUp,
0870:                                                    ((TestListFamilyCampaignTreeNode) choiceComboBox
0871:                                                            .getSelectedItem())
0872:                                                            .getFamilyNode(),
0873:                                                    selectedIndex - 1);
0874:                                    campaignFamiliesTestListOrderModified
0875:                                            .add(camp);
0876:                                    //camp.getSuitListFromModel().remove(nodeToGoUp.getUserObject());
0877:                                    //camp.getSuitListFromModel().add((selectedIndex-1), nodeToGoUp.getUserObject());
0878:
0879:                                } catch (Exception exception) {
0880:                                    Tools.ihmExceptionView(exception);
0881:                                }
0882:
0883:                            }
0884:                        }
0885:                    } else if (testButton.isSelected()) {
0886:                        nodeToGoUp = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0887:                                .getSelectedItem()).getTestListNode()
0888:                                .getChildAt(selectedIndex);
0889:                        nodeToGoDown = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0890:                                .getSelectedItem()).getTestListNode()
0891:                                .getChildAt(selectedIndex - 1);
0892:                        if (((TestListFamilyCampaignTreeNode) choiceComboBox
0893:                                .getSelectedItem()).getCampaignNode() == null) {
0894:                            try {
0895:                                TestList pSuite = (TestList) ((TestListFamilyCampaignTreeNode) choiceComboBox
0896:                                        .getSelectedItem()).getTestListNode()
0897:                                        .getUserObject();
0898:                                Test pTest = (Test) nodeToGoUp.getUserObject();
0899:                                //BDD
0900:                                pTest.updateOrderInDBAndModel(false);
0901:
0902:                                //IHM
0903:                                workingModel.removeNodeFromParent(nodeToGoUp);
0904:                                workingModel
0905:                                        .insertNodeInto(
0906:                                                nodeToGoUp,
0907:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
0908:                                                        .getSelectedItem())
0909:                                                        .getTestListNode(),
0910:                                                selectedIndex - 1);
0911:                                testListTestOrderModified
0912:                                        .add(((TestListFamilyCampaignTreeNode) choiceComboBox
0913:                                                .getSelectedItem())
0914:                                                .getTestListNode()
0915:                                                .getUserObject());
0916:                                pSuite.getTestListFromModel().remove(pTest);
0917:                                pSuite.getTestListFromModel().add(
0918:                                        (selectedIndex - 1), pTest);
0919:                            } catch (Exception exception) {
0920:                                Tools.ihmExceptionView(exception);
0921:                            }
0922:                        } else {
0923:
0924:                            try {
0925:                                // BdD
0926:                                Campaign camp = (Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
0927:                                        .getSelectedItem()).getCampaignNode())
0928:                                        .getUserObject();
0929:                                camp.updateTestOrderInDB(((Test) nodeToGoUp
0930:                                        .getUserObject()).getIdBdd(), false);
0931:
0932:                                // IHM
0933:                                workingModel.removeNodeFromParent(nodeToGoUp);
0934:                                workingModel
0935:                                        .insertNodeInto(
0936:                                                nodeToGoUp,
0937:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
0938:                                                        .getSelectedItem())
0939:                                                        .getTestListNode(),
0940:                                                selectedIndex - 1);
0941:                                campaignFamiliesTestListTestOrderModified
0942:                                        .add(camp);
0943:                                camp.getTestListFromModel().remove(
0944:                                        nodeToGoUp.getUserObject());
0945:                                camp.getTestListFromModel().add(
0946:                                        (selectedIndex - 1),
0947:                                        nodeToGoUp.getUserObject());
0948:
0949:                            } catch (Exception exception) {
0950:                                Tools.ihmExceptionView(exception);
0951:                            }
0952:                        }
0953:                    }
0954:                }
0955:            }
0956:
0957:            void downPerformed(ActionEvent e) {
0958:                int selectedIndex = list.getSelectedIndex();
0959:                if (selectedIndex != -1) {
0960:                    Object objToGoUp = listModel
0961:                            .getElementAt(selectedIndex + 1);
0962:                    Object objToGoDown = listModel.getElementAt(selectedIndex);
0963:                    listModel.setElementAt(objToGoUp, selectedIndex);
0964:                    listModel.setElementAt(objToGoDown, selectedIndex + 1);
0965:                    list.setSelectedIndex(selectedIndex + 1);
0966:                    DefaultMutableTreeNode nodeToGoUp = null;
0967:                    DefaultMutableTreeNode nodeToGoDown = null;
0968:                    if (campagneButton.isSelected()) {
0969:                        nodeToGoUp = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) workingModel
0970:                                .getRoot()).getChildAt(selectedIndex + 1);
0971:
0972:                        try {
0973:                            // BdD
0974:                            ((Campaign) ((DefaultMutableTreeNode) objToGoDown)
0975:                                    .getUserObject())
0976:                                    .updateOrderInDBAndModel(true);
0977:
0978:                            // IHM
0979:                            workingModel.removeNodeFromParent(nodeToGoUp);
0980:                            workingModel.insertNodeInto(nodeToGoUp,
0981:                                    ((DefaultMutableTreeNode) workingModel
0982:                                            .getRoot()), selectedIndex);
0983:                            DataModel.getCurrentProject()
0984:                                    .getCampaignListFromModel().remove(
0985:                                            nodeToGoUp.getUserObject());
0986:                            DataModel.getCurrentProject()
0987:                                    .getCampaignListFromModel().add(
0988:                                            (selectedIndex),
0989:                                            nodeToGoUp.getUserObject());
0990:                            campaignOrderModified = true;
0991:
0992:                        } catch (Exception exception) {
0993:                            Tools.ihmExceptionView(exception);
0994:                        }
0995:
0996:                    } else if (familyButton.isSelected()) {
0997:                        if (campaignMode) {
0998:                            nodeToGoDown = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
0999:                                    .getSelectedItem()).getCampaignNode()
1000:                                    .getChildAt(selectedIndex);
1001:                            nodeToGoUp = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
1002:                                    .getSelectedItem()).getCampaignNode()
1003:                                    .getChildAt(selectedIndex + 1);
1004:                            ArrayList oldTestList = ((Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
1005:                                    .getSelectedItem()).getCampaignNode())
1006:                                    .getUserObject()).getTestListFromModel();
1007:                            ArrayList oldSuiteList = ((Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
1008:                                    .getSelectedItem()).getCampaignNode())
1009:                                    .getUserObject()).getSuitListFromModel();
1010:                            int firstTestIndex = oldTestList
1011:                                    .indexOf(((DefaultMutableTreeNode) ((DefaultMutableTreeNode) nodeToGoDown
1012:                                            .getFirstChild()).getFirstChild())
1013:                                            .getUserObject());
1014:                            int firstSuiteIndex = oldSuiteList
1015:                                    .indexOf(((DefaultMutableTreeNode) nodeToGoDown
1016:                                            .getFirstChild()).getUserObject());
1017:
1018:                            try {
1019:                                // BdD                                           
1020:                                Campaign camp = (Campaign) ((TestListFamilyCampaignTreeNode) choiceComboBox
1021:                                        .getSelectedItem()).getCampaignNode()
1022:                                        .getUserObject();
1023:                                Family pFamilyDown = (Family) nodeToGoDown
1024:                                        .getUserObject();
1025:                                Family pFamilyUp = (Family) nodeToGoUp
1026:                                        .getUserObject();
1027:
1028:                                camp.updateTestFamilyOrderInDB(pFamilyDown
1029:                                        .getIdBdd(), true);
1030:
1031:                                // IHM
1032:                                //ArrayList testInModel = DataModel.getCurrentProject().getAlltestFromModel();
1033:                                camp.reloadTestCampain(DataModel
1034:                                        .getCurrentProject()
1035:                                        .getAlltestFromModel());
1036:                                /*Util.log("Nb de test dans la campagne : " + camp.getTestListFromModel().size());
1037:                                for (int k = 0; k < pFamilyUp.getSuiteListFromModel().size(); k++) {
1038:                                	TestList testList = (TestList) pFamilyUp.getSuiteListFromModel().get(k);
1039:                                	//camp.getSuitListFromModel().remove (pFamilyUp.getSuiteListFromModel().get(k));
1040:                                	camp.getSuitListFromModel().remove (testList);
1041:                                	for (int j = 0; j < testList.getTestListFromModel().size(); j++) {
1042:                                		Util.log("Suppréssion de " + testList.getTestListFromModel().get(j));
1043:                                		camp.getTestListFromModel().remove(testList.getTestListFromModel().get(j));
1044:                                		
1045:                                	}
1046:                                }
1047:                                Util.log("Nb de test dans la campagne2 : " + camp.getTestListFromModel().size());
1048:                                int addIndex = firstTestIndex;
1049:                                for (int k = 0; k < pFamilyUp.getSuiteListFromModel().size(); k++) {
1050:                                	TestList testList = (TestList)pFamilyUp.getSuiteListFromModel().get(k);
1051:                                	camp.getSuitListFromModel().add((k+firstSuiteIndex), pFamilyUp.getSuiteListFromModel().get(k));
1052:                                	Util.log("Nb de test dans la campagne3 : " + camp.getTestListFromModel().size());
1053:                                	for (int j = 0; j < testList.getTestListFromModel().size(); j++) {
1054:                                		Util.log("Ajout (index : " + (j+addIndex) + ") de " + testList.getTestListFromModel().get(j));
1055:                                		camp.getTestListFromModel().add((j+addIndex), testList.getTestListFromModel().get(j));
1056:                                		addIndex++;
1057:                                	}
1058:                                }
1059:                                 */
1060:                                workingModel.removeNodeFromParent(nodeToGoUp);
1061:                                workingModel
1062:                                        .insertNodeInto(
1063:                                                nodeToGoUp,
1064:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
1065:                                                        .getSelectedItem())
1066:                                                        .getCampaignNode(),
1067:                                                selectedIndex);
1068:                                campaignFamilyOrderModified.add(camp);
1069:                                //camp.getFamilyListFromModel().remove(pFamilyUp);
1070:                                //camp.getFamilyListFromModel().add((selectedIndex),pFamilyUp);
1071:
1072:                            } catch (Exception exception) {
1073:                                Tools.ihmExceptionView(exception);
1074:                            }
1075:
1076:                        } else {
1077:
1078:                            try {
1079:                                //IHM
1080:                                ((Family) ((DefaultMutableTreeNode) objToGoDown)
1081:                                        .getUserObject())
1082:                                        .updateOrderInBddAndModel(true);
1083:
1084:                                //BDD
1085:                                nodeToGoUp = (DefaultMutableTreeNode) ((DefaultMutableTreeNode) workingModel
1086:                                        .getRoot())
1087:                                        .getChildAt(selectedIndex + 1);
1088:                                workingModel.removeNodeFromParent(nodeToGoUp);
1089:                                workingModel.insertNodeInto(nodeToGoUp,
1090:                                        ((DefaultMutableTreeNode) workingModel
1091:                                                .getRoot()), selectedIndex);
1092:                                Family family = (Family) nodeToGoUp
1093:                                        .getUserObject();
1094:                                DataModel.getCurrentProject()
1095:                                        .getFamilyListFromModel()
1096:                                        .remove(family);
1097:                                DataModel.getCurrentProject()
1098:                                        .getFamilyListFromModel().add(
1099:                                                (selectedIndex), family);
1100:                                familyOrderModified = true;
1101:                            } catch (Exception exception) {
1102:                                Tools.ihmExceptionView(exception);
1103:                            }
1104:                        }
1105:                    } else if (testListButton.isSelected()) {
1106:                        nodeToGoUp = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
1107:                                .getSelectedItem()).getFamilyNode().getChildAt(
1108:                                selectedIndex + 1);
1109:                        nodeToGoDown = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
1110:                                .getSelectedItem()).getFamilyNode().getChildAt(
1111:                                selectedIndex);
1112:                        if (((TestListFamilyCampaignTreeNode) choiceComboBox
1113:                                .getSelectedItem()).getCampaignNode() == null) {
1114:
1115:                            try {
1116:                                //BDD
1117:                                Family pFamily = (Family) ((TestListFamilyCampaignTreeNode) choiceComboBox
1118:                                        .getSelectedItem()).getFamilyNode()
1119:                                        .getUserObject();
1120:                                ((TestList) nodeToGoDown.getUserObject())
1121:                                        .updateOrderInDBAndModel(true);
1122:
1123:                                //IHM
1124:                                workingModel.removeNodeFromParent(nodeToGoUp);
1125:                                workingModel
1126:                                        .insertNodeInto(
1127:                                                nodeToGoUp,
1128:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
1129:                                                        .getSelectedItem())
1130:                                                        .getFamilyNode(),
1131:                                                selectedIndex);
1132:                                familiesTestListOrderModified
1133:                                        .add(((TestListFamilyCampaignTreeNode) choiceComboBox
1134:                                                .getSelectedItem())
1135:                                                .getFamilyNode()
1136:                                                .getUserObject());
1137:                                pFamily.getSuiteListFromModel().remove(
1138:                                        nodeToGoUp.getUserObject());
1139:                                pFamily.getSuiteListFromModel().add(
1140:                                        (selectedIndex),
1141:                                        nodeToGoUp.getUserObject());
1142:                            } catch (Exception exception) {
1143:                                Tools.ihmExceptionView(exception);
1144:                            }
1145:                        } else {
1146:                            ArrayList oldTestList = ((Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
1147:                                    .getSelectedItem()).getCampaignNode())
1148:                                    .getUserObject()).getTestListFromModel();
1149:                            // On r?cup?re l'indice du premier test de la suite qui descend
1150:                            int firstIndex = oldTestList
1151:                                    .indexOf(((DefaultMutableTreeNode) nodeToGoDown
1152:                                            .getFirstChild()).getUserObject());
1153:                            int i = 0;
1154:                            if (firstIndex != -1) {
1155:
1156:                                try {
1157:                                    // BdD
1158:                                    Campaign camp = (Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
1159:                                            .getSelectedItem())
1160:                                            .getCampaignNode()).getUserObject();
1161:                                    TestList pSuiteUp = (TestList) nodeToGoUp
1162:                                            .getUserObject();
1163:                                    camp.updateTestSuiteOrderInDB(
1164:                                            ((TestList) nodeToGoDown
1165:                                                    .getUserObject())
1166:                                                    .getIdBdd(), true);
1167:
1168:                                    // IHM
1169:                                    camp.reloadTestCampain(DataModel
1170:                                            .getCurrentProject()
1171:                                            .getAlltestFromModel());
1172:                                    /*for (i = 0; i < pSuiteUp.getTestListFromModel().size(); i++) {
1173:                                    	camp.getTestListFromModel().remove(pSuiteUp.getTestListFromModel().get(i));
1174:                                    }
1175:                                    for (i = 0; i < pSuiteUp.getTestListFromModel().size(); i++) {
1176:                                    	camp.getTestListFromModel().add((i+firstIndex), pSuiteUp.getTestListFromModel().get(i));
1177:                                    }*/
1178:
1179:                                    workingModel
1180:                                            .removeNodeFromParent(nodeToGoUp);
1181:                                    workingModel
1182:                                            .insertNodeInto(
1183:                                                    nodeToGoUp,
1184:                                                    ((TestListFamilyCampaignTreeNode) choiceComboBox
1185:                                                            .getSelectedItem())
1186:                                                            .getFamilyNode(),
1187:                                                    selectedIndex);
1188:                                    campaignFamiliesTestListOrderModified
1189:                                            .add(camp);
1190:                                    //camp.getSuitListFromModel().remove(pSuiteUp);
1191:                                    //camp.getSuitListFromModel().add((selectedIndex), pSuiteUp);
1192:
1193:                                } catch (Exception exception) {
1194:                                    Tools.ihmExceptionView(exception);
1195:                                }
1196:                            }
1197:                        }
1198:                    } else if (testButton.isSelected()) {
1199:                        nodeToGoUp = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
1200:                                .getSelectedItem()).getTestListNode()
1201:                                .getChildAt(selectedIndex + 1);
1202:                        nodeToGoDown = (DefaultMutableTreeNode) ((TestListFamilyCampaignTreeNode) choiceComboBox
1203:                                .getSelectedItem()).getTestListNode()
1204:                                .getChildAt(selectedIndex);
1205:                        if (((TestListFamilyCampaignTreeNode) choiceComboBox
1206:                                .getSelectedItem()).getCampaignNode() == null) {
1207:                            try {
1208:                                //BDD
1209:                                Test pTestDown = (Test) nodeToGoDown
1210:                                        .getUserObject();
1211:                                Test pTestUp = (Test) nodeToGoUp
1212:                                        .getUserObject();
1213:                                TestList pSuite = (TestList) ((TestListFamilyCampaignTreeNode) choiceComboBox
1214:                                        .getSelectedItem()).getTestListNode()
1215:                                        .getUserObject();
1216:                                pTestDown.updateOrderInDBAndModel(true);
1217:
1218:                                //IHM
1219:                                workingModel.removeNodeFromParent(nodeToGoUp);
1220:                                workingModel
1221:                                        .insertNodeInto(
1222:                                                nodeToGoUp,
1223:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
1224:                                                        .getSelectedItem())
1225:                                                        .getTestListNode(),
1226:                                                selectedIndex);
1227:                                testListTestOrderModified.add(pSuite);
1228:                                pSuite.getTestListFromModel().remove(pTestUp);
1229:                                pSuite.getTestListFromModel().add(
1230:                                        (selectedIndex), pTestUp);
1231:
1232:                            } catch (Exception exception) {
1233:                                Tools.ihmExceptionView(exception);
1234:                            }
1235:
1236:                        } else {
1237:
1238:                            try {
1239:                                // BdD
1240:                                Campaign camp = (Campaign) (((TestListFamilyCampaignTreeNode) choiceComboBox
1241:                                        .getSelectedItem()).getCampaignNode())
1242:                                        .getUserObject();
1243:                                camp.updateTestOrderInDB(((Test) nodeToGoDown
1244:                                        .getUserObject()).getIdBdd(), true);
1245:
1246:                                // IHM
1247:                                workingModel.removeNodeFromParent(nodeToGoUp);
1248:                                workingModel
1249:                                        .insertNodeInto(
1250:                                                nodeToGoUp,
1251:                                                ((TestListFamilyCampaignTreeNode) choiceComboBox
1252:                                                        .getSelectedItem())
1253:                                                        .getTestListNode(),
1254:                                                selectedIndex);
1255:                                campaignFamiliesTestListTestOrderModified
1256:                                        .add(camp);
1257:                                camp.getTestListFromModel().remove(
1258:                                        nodeToGoUp.getUserObject());
1259:                                camp.getTestListFromModel().add(
1260:                                        (selectedIndex),
1261:                                        nodeToGoUp.getUserObject());
1262:
1263:                            } catch (Exception exception) {
1264:                                Tools.ihmExceptionView(exception);
1265:                            }
1266:                        }
1267:                    }
1268:                }
1269:            }
1270:
1271:            public void valueChanged(ListSelectionEvent e) {
1272:                if (e.getSource().equals(list)) {
1273:                    listChanged(e);
1274:                }
1275:            }
1276:
1277:            void listChanged(ListSelectionEvent e) {
1278:                int selectedIndex = list.getSelectedIndex();
1279:                if (selectedIndex != -1) {
1280:                    if (selectedIndex == 0) {
1281:                        upButton.setEnabled(false);
1282:                        if (selectedIndex == listModel.getSize() - 1) {
1283:                            downButton.setEnabled(false);
1284:                        } else {
1285:                            downButton.setEnabled(true);
1286:                        }
1287:                    } else if (selectedIndex == listModel.getSize() - 1) {
1288:                        upButton.setEnabled(true);
1289:                        downButton.setEnabled(false);
1290:                    } else if (selectedIndex == listModel.getSize()) {
1291:                        upButton.setEnabled(false);
1292:                        downButton.setEnabled(false);
1293:                    } else {
1294:                        upButton.setEnabled(true);
1295:                        downButton.setEnabled(true);
1296:                    }
1297:                } else {
1298:                    upButton.setEnabled(false);
1299:                    downButton.setEnabled(false);
1300:                }
1301:            }
1302:
1303:        } // Fin de la classe Ordering
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.