Source Code Cross Referenced for ExecChooser.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » cronExec » 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 » salomeTMF_plug.cronExec 
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 Aurore PENAULT
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package salomeTMF_plug.cronExec;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Container;
028:        import java.awt.Dimension;
029:        import java.awt.FlowLayout;
030:        import java.awt.GridLayout;
031:        import java.awt.event.ActionEvent;
032:        import java.awt.event.ActionListener;
033:        import java.util.ArrayList;
034:        import java.util.Date;
035:        import java.util.Iterator;
036:        import java.util.Timer;
037:
038:        import javax.swing.BorderFactory;
039:        import javax.swing.Box;
040:        import javax.swing.BoxLayout;
041:        import javax.swing.JButton;
042:        import javax.swing.JCheckBox;
043:        import javax.swing.JDialog;
044:        import javax.swing.JLabel;
045:        import javax.swing.JOptionPane;
046:        import javax.swing.JPanel;
047:        import javax.swing.JScrollPane;
048:        import javax.swing.JTextField;
049:        import javax.swing.JTree;
050:        import javax.swing.event.TreeSelectionEvent;
051:        import javax.swing.event.TreeSelectionListener;
052:        import javax.swing.tree.DefaultMutableTreeNode;
053:        import javax.swing.tree.DefaultTreeModel;
054:        import javax.swing.tree.TreePath;
055:
056:        import org.objectweb.salome_tmf.api.Api;
057:        import org.objectweb.salome_tmf.api.data.ExecutionWrapper;
058:        import org.objectweb.salome_tmf.data.Campaign;
059:        import org.objectweb.salome_tmf.data.DataConstants;
060:        import org.objectweb.salome_tmf.data.Execution;
061:        import org.objectweb.salome_tmf.data.Family;
062:        import org.objectweb.salome_tmf.data.Test;
063:        import org.objectweb.salome_tmf.data.TestList;
064:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
065:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
066:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
067:        import org.objectweb.salome_tmf.ihm.models.TestTreeModel;
068:        import org.objectweb.salome_tmf.ihm.models.TreeRenderer;
069:
070:        import salomeTMF_plug.cronExec.languages.Language;
071:
072:        import com.toedter.calendar.JDateChooser;
073:
074:        /**
075:         * Classe qui construit la fenêtre permettant de choisir les tests à insérer 
076:         * dans la documentation
077:         * @author vapu8214
078:         */
079:        public class ExecChooser extends JDialog implements  DataConstants {
080:            /**
081:             * Modèle de l'arbre des tests
082:             */
083:            protected TestTreeModel campTreeModel;
084:
085:            /**
086:             * Modèle de l'arbre des tests sélectionnés
087:             */
088:            protected TestTreeModel chosenTreeModel;
089:
090:            /**
091:             * l'arbre des tests choisis
092:             */
093:            JTree chosenTree;
094:
095:            /**
096:             * l'arbre des tests
097:             */
098:            JTree testTree;
099:
100:            /**
101:             * Noeud sélectionné dans l'arbre des tests choisis
102:             */
103:            DefaultMutableTreeNode chosenSelectedNode;
104:
105:            /**
106:             * Noeud sélectionné dans l'arbre des tests
107:             */
108:            DefaultMutableTreeNode testSelectedNode;
109:
110:            /**
111:             * Racine de l'arbre temporaire des tests choisis
112:             */
113:            DefaultMutableTreeNode temporaryChosenRootNode;
114:
115:            /**
116:             * Racine de l'arbre final des tests choisis
117:             */
118:            DefaultMutableTreeNode realChosenRoot;
119:
120:            /**
121:             * Liste des campagnes sélectionnées
122:             */
123:            ArrayList temporaryCampList;
124:
125:            /**
126:             * Liste des exécutions sélectionnées
127:             */
128:            ArrayList temporaryExecList;
129:
130:            /**
131:             * Liste des tests sélectionnés
132:             */
133:            ArrayList temporaryTestList;
134:
135:            /**
136:             * Liste des suites sélectionnées
137:             */
138:            ArrayList temporaryTestListList;
139:
140:            /**
141:             * Liste des familles sélectionnées
142:             */
143:            ArrayList temporaryFamilyList;
144:
145:            ArrayList testSelectedNodes;
146:
147:            ArrayList chosenSelectedNodes;
148:
149:            JDateChooser date;
150:            JTextField hour;
151:            JTextField minutes;
152:            JTextField occurences;
153:            JTextField interval;
154:            JCheckBox stopOnError;
155:
156:            CronExecPlugin cronPlg;
157:
158:            Timer pTimer;
159:
160:            /**
161:             * Constructeur de la fenêtre pour l'ajout de tests à la documentation.
162:             * @param chosenRoot le noeud racine de la liste des tests sélectionnés
163:             * @param model le modèle de données des tests
164:             * @param testRoot la racine de l'arbre des tests 
165:             */
166:            public ExecChooser(CronExecPlugin cron_plg, Timer timer) {
167:
168:                super (SalomeTMFContext.getInstance().getSalomeFrame(), true);
169:                cronPlg = cron_plg;
170:                pTimer = timer;
171:
172:                DefaultMutableTreeNode chosenRoot = new DefaultMutableTreeNode(
173:                        Language.getInstance().getText("Sélection"));
174:
175:                temporaryCampList = new ArrayList();
176:
177:                chosenSelectedNodes = new ArrayList();
178:                testSelectedNodes = new ArrayList();
179:
180:                realChosenRoot = new DefaultMutableTreeNode(Language
181:                        .getInstance().getText("Sélection"));
182:
183:                TreeRenderer chosenRenderer = new TreeRenderer();
184:                TreeRenderer testRenderer = new TreeRenderer();
185:
186:                temporaryChosenRootNode = new DefaultMutableTreeNode(chosenRoot
187:                        .getUserObject());
188:
189:                chosenSelectedNode = temporaryChosenRootNode;
190:
191:                chosenTree = new JTree();
192:                chosenTreeModel = new TestTreeModel(temporaryChosenRootNode,
193:                        chosenTree, null);
194:                chosenTree.setModel(chosenTreeModel);
195:
196:                initTemporaryTree(chosenRoot);
197:
198:                DefaultMutableTreeNode testRoot = SalomeTMFPanels
199:                        .getCampaignDynamicTree().getRoot();
200:                DefaultMutableTreeNode testRootClone = (DefaultMutableTreeNode) testRoot
201:                        .clone();
202:                for (int j = 0; j < testRoot.getChildCount(); j++) {
203:                    DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) testRoot
204:                            .getChildAt(j);
205:                    Campaign campaign = (Campaign) childNode.getUserObject();
206:                    addObject(testRootClone, campaign, true);
207:                }
208:                testTree = new JTree();
209:                campTreeModel = new TestTreeModel(testRootClone, testTree, null);
210:                testTree.setModel(campTreeModel);
211:
212:                testTree.setCellRenderer(testRenderer);
213:                testTree.addTreeSelectionListener(new TreeSelectionListener() {
214:                    public void valueChanged(TreeSelectionEvent e) {
215:                        testSelectedNodes.clear();
216:                        TreePath[] pathTab = testTree.getSelectionPaths();
217:                        if (pathTab != null) {
218:                            for (int i = 0; i < pathTab.length; i++) {
219:                                testSelectedNodes.add(pathTab[i]
220:                                        .getLastPathComponent());
221:                            }
222:                        }
223:                    }
224:                });
225:
226:                chosenTree.setCellRenderer(chosenRenderer);
227:                chosenTree
228:                        .addTreeSelectionListener(new TreeSelectionListener() {
229:                            public void valueChanged(TreeSelectionEvent e) {
230:                                chosenSelectedNodes.clear();
231:                                TreePath[] pathTab = chosenTree
232:                                        .getSelectionPaths();
233:                                if (pathTab != null) {
234:                                    for (int i = 0; i < pathTab.length; i++) {
235:                                        chosenSelectedNodes.add(pathTab[i]
236:                                                .getLastPathComponent());
237:                                    }
238:                                }
239:                            }
240:                        });
241:
242:                // Exécutions de chaque campagne
243:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) campTreeModel
244:                        .getRoot();
245:                for (int j = 0; j < root.getChildCount(); j++) {
246:                    DefaultMutableTreeNode campNode = (DefaultMutableTreeNode) root
247:                            .getChildAt(j);
248:                    if (campNode.getUserObject() instanceof  Campaign) {
249:                        campNode.removeAllChildren();
250:                        Campaign camp = (Campaign) campNode.getUserObject();
251:                        ArrayList execList = camp.getExecutionListFromModel();
252:                        if (!execList.isEmpty()) {
253:                            Iterator it = execList.iterator();
254:                            while (it.hasNext()) {
255:                                Execution exec = (Execution) it.next();
256:                                addObject(campNode, exec, true);
257:                            }
258:                        }
259:                    }
260:                }
261:
262:                JButton addButton = new JButton("<");
263:                addButton.setToolTipText(Language.getInstance().getText(
264:                        "Retirer_de_la_sélection"));
265:                addButton.addActionListener(new ActionListener() {
266:                    public void actionPerformed(ActionEvent e) {
267:                        int i = chosenSelectedNodes.size() - 1;
268:                        while (i >= 0) {
269:                            DefaultMutableTreeNode node = (DefaultMutableTreeNode) chosenSelectedNodes
270:                                    .get(i);
271:                            ((DefaultTreeModel) chosenTree.getModel())
272:                                    .removeNodeFromParent(node);
273:                            removeFromModel(node);
274:                            i = chosenSelectedNodes.size() - 1;
275:                        }
276:                    }
277:                });
278:
279:                JButton removeButton = new JButton(">");
280:                removeButton.setToolTipText(Language.getInstance().getText(
281:                        "Ajouter_à_la_sélection"));
282:                removeButton.addActionListener(new ActionListener() {
283:                    public void actionPerformed(ActionEvent e) {
284:                        for (int i = 0; i < testSelectedNodes.size(); i++) {
285:                            Object nodeValue = ((DefaultMutableTreeNode) testSelectedNodes
286:                                    .get(i)).getUserObject();
287:                            testSelectedNode = ((DefaultMutableTreeNode) testSelectedNodes
288:                                    .get(i));
289:
290:                            if (nodeValue instanceof  Campaign) {
291:                                addNodeToNode(testSelectedNode,
292:                                        temporaryChosenRootNode);
293:                            } else if (nodeValue instanceof  Execution) {
294:                                DefaultMutableTreeNode campNode = findCampaignNodeInChosenTree(((Execution) nodeValue)
295:                                        .getCampagneFromModel()
296:                                        .getNameFromModel());
297:                                if (campNode != null) {
298:                                    addNodeToNode(testSelectedNode, campNode);
299:                                } else {
300:                                    DefaultMutableTreeNode newCampNode = addObject(
301:                                            temporaryChosenRootNode,
302:                                            ((Execution) nodeValue)
303:                                                    .getCampagneFromModel(),
304:                                            true);
305:                                    addNodeToNode(testSelectedNode, newCampNode);
306:                                }
307:                            }
308:                        }
309:                    }
310:                });
311:
312:                JPanel buttonSet = new JPanel();
313:                buttonSet.setLayout(new BoxLayout(buttonSet, BoxLayout.Y_AXIS));
314:                buttonSet.add(removeButton);
315:                buttonSet.add(Box.createRigidArea(new Dimension(1, 25)));
316:                buttonSet.add(addButton);
317:
318:                JScrollPane chosenScrollPane = new JScrollPane(chosenTree);
319:                chosenScrollPane.setBorder(BorderFactory
320:                        .createTitledBorder(Language.getInstance().getText(
321:                                "Sélection")));
322:                chosenScrollPane.setPreferredSize(new Dimension(300, 450));
323:
324:                JScrollPane testScrollPane = new JScrollPane(testTree);
325:                testScrollPane.setBorder(BorderFactory
326:                        .createTitledBorder(Language.getInstance().getText(
327:                                "Exécutions")));
328:                testScrollPane.setPreferredSize(new Dimension(300, 450));
329:
330:                JLabel dateLabel = new JLabel(Language.getInstance().getText(
331:                        "Date_du_lancement_:"));
332:                JPanel dateLabelPanel = new JPanel(new FlowLayout(
333:                        FlowLayout.LEFT));
334:                dateLabelPanel.add(dateLabel);
335:                date = new JDateChooser("d MMMMM yyyy", false);
336:                JPanel datePanel = new JPanel();
337:                datePanel.setLayout(new BoxLayout(datePanel, BoxLayout.Y_AXIS));
338:                datePanel.setBorder(BorderFactory.createTitledBorder(""));
339:                datePanel.add(dateLabelPanel);
340:                datePanel.add(Box.createRigidArea(new Dimension(1, 10)));
341:                datePanel.add(date);
342:
343:                JLabel hourLabel = new JLabel(Language.getInstance().getText(
344:                        "Heure_de_lancement_:"));
345:                JPanel hourLabelPanel = new JPanel(new FlowLayout(
346:                        FlowLayout.LEFT));
347:                hourLabelPanel.add(hourLabel);
348:                hour = new JTextField(2);
349:                JLabel separator = new JLabel(":");
350:                minutes = new JTextField(2);
351:                JPanel hourFieldPanel = new JPanel();
352:                hourFieldPanel.add(hour);
353:                hourFieldPanel.add(separator);
354:                hourFieldPanel.add(minutes);
355:                JPanel hourPanel = new JPanel();
356:                hourPanel.setLayout(new BoxLayout(hourPanel, BoxLayout.Y_AXIS));
357:                hourPanel.setBorder(BorderFactory.createTitledBorder(""));
358:                hourPanel.add(hourLabelPanel);
359:                hourPanel.add(Box.createRigidArea(new Dimension(1, 10)));
360:                hourPanel.add(hourFieldPanel);
361:
362:                JLabel occurencesLabel = new JLabel(Language.getInstance()
363:                        .getText("Occurences_:"));
364:                JPanel occurencesLabelPanel = new JPanel(new FlowLayout(
365:                        FlowLayout.LEFT));
366:                occurencesLabelPanel.add(occurencesLabel);
367:                occurences = new JTextField(4);
368:                occurences.setText("1");
369:                JPanel occurencesPanel = new JPanel();
370:                occurencesPanel.setLayout(new BoxLayout(occurencesPanel,
371:                        BoxLayout.Y_AXIS));
372:                occurencesPanel.setBorder(BorderFactory.createTitledBorder(""));
373:                occurencesPanel.add(occurencesLabelPanel);
374:                occurencesPanel.add(Box.createRigidArea(new Dimension(1, 10)));
375:                occurencesPanel.add(occurences);
376:
377:                JLabel intervalLabel = new JLabel("Interval :");
378:                JPanel intervalLabelPanel = new JPanel(new FlowLayout(
379:                        FlowLayout.LEFT));
380:                intervalLabelPanel.add(intervalLabel);
381:                interval = new JTextField(4);
382:                interval.setText("0");
383:                JLabel min = new JLabel("min");
384:                JPanel intervalFieldPanel = new JPanel();
385:                intervalFieldPanel.add(interval);
386:                intervalFieldPanel.add(min);
387:                JPanel intervalPanel = new JPanel();
388:                intervalPanel.setLayout(new BoxLayout(intervalPanel,
389:                        BoxLayout.Y_AXIS));
390:                intervalPanel.setBorder(BorderFactory.createTitledBorder(""));
391:                intervalPanel.add(intervalLabelPanel);
392:                intervalPanel.add(Box.createRigidArea(new Dimension(1, 10)));
393:                intervalPanel.add(intervalFieldPanel);
394:
395:                JLabel stopOnErrorLabel = new JLabel(Language.getInstance()
396:                        .getText("Options_d'exécution_:"));
397:                JPanel stopOnErrorPanel = new JPanel(new FlowLayout(
398:                        FlowLayout.CENTER));
399:                stopOnErrorPanel.add(stopOnErrorLabel);
400:                stopOnError = new JCheckBox();
401:                stopOnError.setSelected(true);
402:                JLabel stopLabel = new JLabel(Language.getInstance().getText(
403:                        "Arrêter_si_erreur"));
404:                JPanel checkPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
405:                checkPanel.add(stopOnError);
406:                checkPanel.add(stopLabel);
407:                JPanel optionsPanel = new JPanel();
408:                optionsPanel.setLayout(new BoxLayout(optionsPanel,
409:                        BoxLayout.Y_AXIS));
410:                optionsPanel.setBorder(BorderFactory.createTitledBorder(""));
411:                optionsPanel.add(stopOnErrorLabel);
412:                optionsPanel.add(Box.createRigidArea(new Dimension(1, 10)));
413:                optionsPanel.add(checkPanel);
414:
415:                JPanel infoPanel = new JPanel();
416:                infoPanel.setLayout(new GridLayout(1, 5));
417:                infoPanel.add(datePanel);
418:                infoPanel.add(hourPanel);
419:                infoPanel.add(occurencesPanel);
420:                infoPanel.add(intervalPanel);
421:                infoPanel.add(optionsPanel);
422:
423:                JPanel windowPanel = new JPanel();
424:                windowPanel.setLayout(new BoxLayout(windowPanel,
425:                        BoxLayout.X_AXIS));
426:                windowPanel.add(testScrollPane);
427:                windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
428:                windowPanel.add(buttonSet);
429:                windowPanel.add(Box.createRigidArea(new Dimension(20, 50)));
430:                windowPanel.add(chosenScrollPane);
431:
432:                JButton validate = new JButton(Language.getInstance().getText(
433:                        "Valider"));
434:                validate.setToolTipText(Language.getInstance().getText(
435:                        "Valider"));
436:                validate.addActionListener(new ActionListener() {
437:                    public void actionPerformed(ActionEvent e) {
438:                        init();
439:                        String hourText = hour.getText();
440:                        String minText = minutes.getText();
441:                        String occText = occurences.getText();
442:                        String intText = interval.getText();
443:
444:                        if ((hourText == null)
445:                                || (hourText.equalsIgnoreCase(""))
446:                                || (minText == null)
447:                                || (minText.equalsIgnoreCase(""))
448:                                || (occText == null)
449:                                || (occText.equalsIgnoreCase(""))
450:                                || (intText == null)
451:                                || (intText.equalsIgnoreCase(""))) {
452:                            JOptionPane
453:                                    .showMessageDialog(
454:                                            ExecChooser.this ,
455:                                            Language
456:                                                    .getInstance()
457:                                                    .getText(
458:                                                            "Vous_devez_saisir_l'heure,_le_nombre_d'occurence_et_l'intervalle_entre_les_exécutions!"),
459:                                            Language.getInstance().getText(
460:                                                    "Erreur_!"),
461:                                            JOptionPane.ERROR_MESSAGE);
462:                        } else {
463:                            try {
464:                                int hourValue = Integer.parseInt(hourText);
465:                                int minutesValue = Integer.parseInt(minText);
466:                                int occurencesValue = Integer.parseInt(occText);
467:                                int intervalValue = Integer.parseInt(intText);
468:
469:                                if ((hourValue < 0) || (hourValue > 23)
470:                                        || (minutesValue < 0)
471:                                        || (minutesValue > 59)) {
472:                                    JOptionPane
473:                                            .showMessageDialog(
474:                                                    ExecChooser.this ,
475:                                                    Language
476:                                                            .getInstance()
477:                                                            .getText(
478:                                                                    "Format_de_l'heure_incorrect!"),
479:                                                    Language
480:                                                            .getInstance()
481:                                                            .getText("Erreur_!"),
482:                                                    JOptionPane.ERROR_MESSAGE);
483:                                } else {
484:                                    if (temporaryExecList.size() == 0) {
485:                                        JOptionPane
486:                                                .showMessageDialog(
487:                                                        ExecChooser.this ,
488:                                                        Language
489:                                                                .getInstance()
490:                                                                .getText(
491:                                                                        "Vous_devez_seléctionner_au_moins_une_exécution!"),
492:                                                        Language
493:                                                                .getInstance()
494:                                                                .getText(
495:                                                                        "Erreur_!"),
496:                                                        JOptionPane.ERROR_MESSAGE);
497:                                    } else {
498:                                        Date firstTime = date.getDate();
499:                                        firstTime.setHours(hourValue);
500:                                        firstTime.setMinutes(minutesValue);
501:                                        firstTime.setSeconds(0);
502:
503:                                        if (firstTime.before(new Date())) {
504:                                            JOptionPane
505:                                                    .showMessageDialog(
506:                                                            ExecChooser.this ,
507:                                                            Language
508:                                                                    .getInstance()
509:                                                                    .getText(
510:                                                                            "La_date_programmée_est_déjà_passée!"),
511:                                                            Language
512:                                                                    .getInstance()
513:                                                                    .getText(
514:                                                                            "Erreur_!"),
515:                                                            JOptionPane.ERROR_MESSAGE);
516:                                        } else {
517:
518:                                            if (occurencesValue <= 0) {
519:                                                JOptionPane
520:                                                        .showMessageDialog(
521:                                                                ExecChooser.this ,
522:                                                                Language
523:                                                                        .getInstance()
524:                                                                        .getText(
525:                                                                                "Le_nombre_d'occurences_doit_être_supérieur_ou_égal_à_1_!"),
526:                                                                Language
527:                                                                        .getInstance()
528:                                                                        .getText(
529:                                                                                "Erreur_!"),
530:                                                                JOptionPane.ERROR_MESSAGE);
531:                                            } else if (occurencesValue == 1) {
532:                                                ExecTask execTask = new ExecTask(
533:                                                        temporaryExecList,
534:                                                        pTimer,
535:                                                        occurencesValue,
536:                                                        stopOnError
537:                                                                .isSelected());
538:                                                pTimer.schedule(execTask,
539:                                                        firstTime);
540:                                                cronPlg.setAlreadyCron(true);
541:                                                cronPlg
542:                                                        .getCronButton()
543:                                                        .setIcon(
544:                                                                new javax.swing.ImageIcon(
545:                                                                        getClass()
546:                                                                                .getResource(
547:                                                                                        "/salomeTMF_plug/cronExec/resources/cron_on.gif")));
548:                                                if (!Api.isNET_CHANGE_TRACK()) {
549:                                                    Api
550:                                                            .runListenerThread(DataModel
551:                                                                    .getCurrentProject()
552:                                                                    .getNameFromModel());
553:                                                }
554:                                                ExecChooser.this .dispose();
555:                                            } else {
556:                                                if (intervalValue <= 0) {
557:                                                    JOptionPane
558:                                                            .showMessageDialog(
559:                                                                    ExecChooser.this ,
560:                                                                    Language
561:                                                                            .getInstance()
562:                                                                            .getText(
563:                                                                                    "L'intervalle_entre_les_exécutions_doit_être_supérieur_ou_égal_à_1_!"),
564:                                                                    Language
565:                                                                            .getInstance()
566:                                                                            .getText(
567:                                                                                    "Erreur_!"),
568:                                                                    JOptionPane.ERROR_MESSAGE);
569:                                                } else {
570:                                                    long period = intervalValue * 60000;
571:
572:                                                    ExecTask execTask = new ExecTask(
573:                                                            temporaryExecList,
574:                                                            pTimer,
575:                                                            occurencesValue,
576:                                                            stopOnError
577:                                                                    .isSelected());
578:                                                    pTimer.schedule(execTask,
579:                                                            firstTime, period);
580:                                                    cronPlg
581:                                                            .setAlreadyCron(true);
582:                                                    cronPlg
583:                                                            .getCronButton()
584:                                                            .setIcon(
585:                                                                    new javax.swing.ImageIcon(
586:                                                                            getClass()
587:                                                                                    .getResource(
588:                                                                                            "/salomeTMF_plug/cronExec/resources/cron_on.gif")));
589:                                                    if (!Api
590:                                                            .isNET_CHANGE_TRACK()) {
591:                                                        Api
592:                                                                .runListenerThread(DataModel
593:                                                                        .getCurrentProject()
594:                                                                        .getNameFromModel());
595:                                                    }
596:                                                    ExecChooser.this .dispose();
597:                                                }
598:                                            }
599:                                        }
600:                                    }
601:                                }
602:
603:                            } catch (NumberFormatException nfe) {
604:                                JOptionPane
605:                                        .showMessageDialog(
606:                                                ExecChooser.this ,
607:                                                Language
608:                                                        .getInstance()
609:                                                        .getText(
610:                                                                "Problèmes_dans_le_format_des_entrées_saisies!"),
611:                                                Language.getInstance().getText(
612:                                                        "Erreur_!"),
613:                                                JOptionPane.ERROR_MESSAGE);
614:                            }
615:                        }
616:                    }
617:                });
618:
619:                JButton cancel = new JButton("Annuler");
620:                cancel
621:                        .setToolTipText(Language.getInstance().getText(
622:                                "Annuler"));
623:                cancel.addActionListener(new ActionListener() {
624:                    public void actionPerformed(ActionEvent e) {
625:                        cronPlg.setAlreadyCron(false);
626:                        cronPlg
627:                                .getCronButton()
628:                                .setIcon(
629:                                        new javax.swing.ImageIcon(
630:                                                getClass()
631:                                                        .getResource(
632:                                                                "/salomeTMF_plug/cronExec/resources/cron_off.gif")));
633:                        ExecChooser.this .dispose();
634:                    }
635:                });
636:
637:                JPanel secondButtonSet = new JPanel();
638:                secondButtonSet.add(validate);
639:                secondButtonSet.add(cancel);
640:
641:                JPanel center = new JPanel();
642:                center.add(windowPanel);
643:
644:                JPanel page = new JPanel();
645:                page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
646:                page.add(infoPanel);
647:                page.add(center);
648:                page.add(secondButtonSet);
649:
650:                Container contentPaneFrame = this .getContentPane();
651:                contentPaneFrame.add(page, BorderLayout.CENTER);
652:                this 
653:                        .setTitle(Language.getInstance().getText(
654:                                "Cron_exécutions"));
655:                //this.setLocation(300, 200);
656:                this .setLocationRelativeTo(this .getParent());
657:                this .pack();
658:                this .setVisible(true);
659:
660:            } // Fin du constructeur ExecChooser
661:
662:            /**
663:             * Méthode Récursive qui ajoute un noeud à un autre noeud. Tous les fils du 
664:             * noeud à ajouter sont aussi ajouter récursivement. 
665:             * @param nodeToBeAdded le noeud à ajouter
666:             * @param nodeToReceive le noeud qui reçoit
667:             */
668:            private void addNodeToNode(DefaultMutableTreeNode nodeToBeAdded,
669:                    DefaultMutableTreeNode nodeToReceive) {
670:                DefaultMutableTreeNode newNode = null;
671:                for (int j = 0; j < nodeToReceive.getChildCount(); j++) {
672:                    if (((DefaultMutableTreeNode) nodeToReceive.getChildAt(j))
673:                            .getUserObject().equals(
674:                                    nodeToBeAdded.getUserObject())) {
675:                        newNode = (DefaultMutableTreeNode) nodeToReceive
676:                                .getChildAt(j);
677:                    }
678:                }
679:                if (newNode == null) {
680:                    newNode = new DefaultMutableTreeNode(nodeToBeAdded
681:                            .getUserObject());
682:                    chosenTreeModel.insertNodeInto(newNode, nodeToReceive,
683:                            nodeToReceive.getChildCount());
684:                    chosenTree.scrollPathToVisible(new TreePath(newNode
685:                            .getPath()));
686:                    if (nodeToBeAdded.getUserObject() instanceof  Family) {
687:                        temporaryFamilyList.add(nodeToBeAdded.getUserObject());
688:                    } else if (nodeToBeAdded.getUserObject() instanceof  TestList) {
689:                        temporaryTestListList
690:                                .add(nodeToBeAdded.getUserObject());
691:                    } else if (nodeToBeAdded.getUserObject() instanceof  Test) {
692:                        temporaryTestList.add(nodeToBeAdded.getUserObject());
693:                    }
694:                }
695:                for (int i = 0; i < nodeToBeAdded.getChildCount(); i++) {
696:                    addNodeToNode((DefaultMutableTreeNode) nodeToBeAdded
697:                            .getChildAt(i), newNode);
698:                }
699:            } // Fin de la méthode addNodeToNode/2
700:
701:            /**
702:             * Méthode qui retourne le noeud correspondant à une campagne si le nom passé
703:             * en paramètre est le nom d'une campagne présente dans l'arbre des sélections
704:             * @param campName un nom
705:             * @return lengthnoeud correspondant à une campagne si lengthnom passé 
706:             * en paramètre est lengthnom d'une campagne présente dans l'arbre des sélections,
707:             * <code>null</code> sinon.
708:             */
709:            public DefaultMutableTreeNode findCampaignNodeInChosenTree(
710:                    String campName) {
711:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
712:                        .getRoot();
713:                for (int j = 0; j < root.getChildCount(); j++) {
714:                    DefaultMutableTreeNode campNode = (DefaultMutableTreeNode) root
715:                            .getChildAt(j);
716:                    if (campNode.getUserObject() instanceof  Campaign
717:                            && ((Campaign) campNode.getUserObject())
718:                                    .getNameFromModel().equals(campName)) {
719:                        return campNode;
720:                    }
721:                }
722:                return null;
723:            } // Fin de la méthode findCampaignNode/1 
724:
725:            /**
726:             * Méthode qui retourne le noeud correspondant à une famille si le nom passé
727:             * en paramètre est le nom d'une famille présente dans l'arbre des sélections 
728:             * @param familyName un nom
729:             * @return le noeud correspondant à une famille si le nom passé
730:             * en paramètre est le nom d'une famille présente dans l'arbre des sélections,
731:             * <code>null</code> sinon.
732:             */
733:            public DefaultMutableTreeNode findFamilyNodeInChosenTree(
734:                    String familyName) {
735:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
736:                        .getRoot();
737:                for (int j = 0; j < root.getChildCount(); j++) {
738:                    DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
739:                            .getChildAt(j);
740:                    if (familyNode.getUserObject() instanceof  Family
741:                            && ((Family) familyNode.getUserObject())
742:                                    .getNameFromModel().equals(familyName)) {
743:                        return familyNode;
744:                    }
745:                }
746:                return null;
747:            } // Fin de la méthode findFamilyNode/1
748:
749:            /**
750:             * Méthode qui retourne le noeud correspondant à une suite si le nom passé
751:             * en paramètre est le nom d'une suite présente dans l'arbre des sélections 
752:             * @param testListName un nom
753:             * @return le noeud correspondant à une famille si le nom passé
754:             * en paramètre est le nom d'une famille présente dans l'arbre des sélections,
755:             * <code>null</code> sinon. 
756:             */
757:            public DefaultMutableTreeNode findTestListNodeInChosenTree(
758:                    String testListName, String familyName) {
759:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
760:                        .getRoot();
761:                for (int j = 0; j < root.getChildCount(); j++) {
762:                    DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) root
763:                            .getChildAt(j);
764:                    if (familyNode.getUserObject() instanceof  Family
765:                            && ((Family) familyNode.getUserObject())
766:                                    .getNameFromModel().equals(familyName)) {
767:                        for (int k = 0; k < familyNode.getChildCount(); k++) {
768:                            DefaultMutableTreeNode testListNode = (DefaultMutableTreeNode) familyNode
769:                                    .getChildAt(k);
770:                            if (testListNode.getUserObject() instanceof  TestList
771:                                    && ((TestList) testListNode.getUserObject())
772:                                            .getNameFromModel().equals(
773:                                                    testListName)) {
774:                                return testListNode;
775:                            }
776:                        }
777:                    }
778:                }
779:                return null;
780:            } // Fin de la méthode findFamilyNode/1
781:
782:            /**
783:             * Méthode d'ajout d'un noeud dans l'arbre sous le parent.
784:             * @param parent le parent 
785:             * @param child le noeud à ajouter
786:             * @param shouldBeVisible visible ou non
787:             * @return le nouveau noeud de l'arbre
788:             */
789:            public DefaultMutableTreeNode addObject(
790:                    DefaultMutableTreeNode parent, Object child,
791:                    boolean shouldBeVisible) {
792:
793:                DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(
794:                        child);
795:                if (parent == null) {
796:                    parent = temporaryChosenRootNode;
797:                }
798:
799:                // Insertion du noeud
800:                chosenTreeModel.insertNodeInto(childNode, parent, parent
801:                        .getChildCount());
802:
803:                // on s'assure que le noeud est visible
804:                if (shouldBeVisible) {
805:                    chosenTree.scrollPathToVisible(new TreePath(childNode
806:                            .getPath()));
807:                }
808:                return childNode;
809:            } // Fin de la classe addObject/3
810:
811:            /**
812:             * Supprime du modèle les éléments retirés de la sélection.
813:             * @param node le noeud à partir duquel on retire les éléments
814:             */
815:            private void removeFromModel(DefaultMutableTreeNode node) {
816:                for (int i = 0; i < node.getChildCount(); i++) {
817:                    removeFromModel((DefaultMutableTreeNode) node.getChildAt(i));
818:                }
819:                if (node.getUserObject() instanceof  Family) {
820:                    temporaryFamilyList.remove(node.getUserObject());
821:                } else if (node.getUserObject() instanceof  TestList) {
822:                    temporaryTestListList.remove(node.getUserObject());
823:                } else if (node.getUserObject() instanceof  Test) {
824:                    temporaryTestList.remove(node.getUserObject());
825:                }
826:            } // Fin de la méthode removeFromModel/1
827:
828:            /**
829:             * Méthode qui initialise l'arbre temporaire à partir de la racine passé
830:             * en paramètre. 
831:             * @param root la racine du nouvel arbre temporaire
832:             */
833:            public void initTemporaryTree(DefaultMutableTreeNode root) {
834:                for (int i = 0; i < root.getChildCount(); i++) {
835:                    addNodeToNode((DefaultMutableTreeNode) root.getChildAt(i),
836:                            temporaryChosenRootNode);
837:                }
838:            } // Fin de la méthode initTemporaryTree/1
839:
840:            public void init() {
841:
842:                temporaryCampList = new ArrayList();
843:                temporaryExecList = new ArrayList();
844:                DefaultMutableTreeNode root = (DefaultMutableTreeNode) chosenTreeModel
845:                        .getRoot();
846:                for (int j = 0; j < root.getChildCount(); j++) {
847:                    DefaultMutableTreeNode campNode = (DefaultMutableTreeNode) root
848:                            .getChildAt(j);
849:
850:                    temporaryCampList.add((Campaign) campNode.getUserObject());
851:                    for (int k = 0; k < campNode.getChildCount(); k++) {
852:                        DefaultMutableTreeNode execNode = (DefaultMutableTreeNode) campNode
853:                                .getChildAt(k);
854:                        if (execNode.getUserObject() instanceof  Execution) {
855:                            Execution exec = (Execution) execNode
856:                                    .getUserObject();
857:                            ExecutionWrapper execWrap = new ExecutionWrapper();
858:                            execWrap.setName(exec.getNameFromModel());
859:                            execWrap.setLastDate(exec.getLastDateFromModel());
860:                            execWrap.setCreationDate(exec
861:                                    .getCreationDateFromModel());
862:                            execWrap.setIdBDD(exec.getIdBdd());
863:                            execWrap.setDescription(exec
864:                                    .getDescriptionFromModel());
865:                            execWrap.setCampId(exec.getCampagneFromModel()
866:                                    .getIdBdd());
867:                            temporaryExecList.add(execWrap);
868:                        }
869:                    }
870:
871:                }
872:            }
873:
874:        } // Fin de la classe ExecChooser
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.