Source Code Cross Referenced for ExportDialog.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » docXML » common » 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.docXML.common 
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.docXML.common;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Container;
028:        import java.awt.Cursor;
029:        import java.awt.Dimension;
030:        import java.awt.FlowLayout;
031:        import java.awt.Font;
032:        import java.awt.Rectangle;
033:        import java.awt.event.ActionEvent;
034:        import java.awt.event.ActionListener;
035:        import java.awt.event.WindowAdapter;
036:        import java.awt.event.WindowEvent;
037:        import java.io.File;
038:        import java.net.URL;
039:        import java.util.ArrayList;
040:        import java.util.Vector;
041:
042:        import javax.swing.BorderFactory;
043:        import javax.swing.Box;
044:        import javax.swing.BoxLayout;
045:        import javax.swing.JButton;
046:        import javax.swing.JCheckBox;
047:        import javax.swing.JComboBox;
048:        import javax.swing.JDialog;
049:        import javax.swing.JFileChooser;
050:        import javax.swing.JLabel;
051:        import javax.swing.JOptionPane;
052:        import javax.swing.JPanel;
053:        import javax.swing.JProgressBar;
054:        import javax.swing.JTabbedPane;
055:        import javax.swing.JTextField;
056:        import javax.swing.tree.DefaultMutableTreeNode;
057:
058:        import org.dom4j.Document;
059:        import org.java.plugin.Extension;
060:        import org.objectweb.salome_tmf.data.DataConstants;
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.models.ScriptFileFilter;
067:        import org.objectweb.salome_tmf.ihm.tools.Tools;
068:        import org.objectweb.salome_tmf.plugins.IPlugObject;
069:        import org.objectweb.salome_tmf.plugins.JPFManager;
070:        import org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin;
071:
072:        import salomeTMF_plug.docXML.export.Contexte;
073:        import salomeTMF_plug.docXML.export.XmlGenerator;
074:        import salomeTMF_plug.docXML.export.Contexte.OutFormat;
075:        import salomeTMF_plug.docXML.languages.Language;
076:
077:        /**
078:         *
079:         * @author  vapu8214
080:         */
081:        public class ExportDialog extends JDialog implements  ActionListener,
082:                DataConstants {
083:
084:            // Salome GUI
085:            protected IPlugObject pIhm = null;
086:            URL urlBase;
087:            String url_txt;
088:            private String fs = System.getProperties().getProperty(
089:                    "file.separator");
090:
091:            String xmlFile;
092:            JLabel sauvLabel;
093:            JTextField sauvTF;
094:            JButton sauvButton;
095:
096:            JCheckBox importTestBox;
097:            JButton testSelection;
098:            JLabel tousTests;
099:            boolean selectionDesTests = false;
100:
101:            JButton valider;
102:            JButton annuler;
103:            boolean annule = false;
104:            JProgressBar progress;
105:
106:            private boolean initSelection = false;
107:            private ArrayList<TestList> suiteSelectionList;
108:            private ArrayList<Family> familySelectionList;
109:            private ArrayList<Test> testSelectionList;
110:            private DefaultMutableTreeNode chosenRoot;
111:
112:            private Vector<JPanel> panelsPluginsForExport = new Vector<JPanel>();
113:            private Thread exportProcess;
114:
115:            private JComboBox comboEncoding;
116:            private Vector<String> codingList;
117:
118:            /** Creates a new instance of ExportDialog */
119:            public ExportDialog(IPlugObject vt) throws Exception {
120:                super (SalomeTMFContext.getInstance().getSalomeFrame(), true);
121:                pIhm = vt;
122:
123:                urlBase = SalomeTMFContext.getInstance().getUrlBase();
124:                String _urlBase = urlBase.toString();
125:                url_txt = _urlBase.substring(0, _urlBase.lastIndexOf("/"));
126:
127:                createComponents();
128:            }
129:
130:            public void createComponents() {
131:                codingList = new Vector<String>();
132:                codingList.add("ISO-8859-15");
133:                codingList.add("ISO-8859-1");
134:                codingList.add("UTF-8");
135:                codingList.add("UTF-16");
136:
137:                comboEncoding = new JComboBox(codingList);
138:                comboEncoding.setEditable(false);
139:
140:                Vector<Extension> listExtXMLPlugin = pIhm
141:                        .getXMLPrintersExtension();
142:                int size = listExtXMLPlugin.size();
143:                for (int i = 0; i < size; i++) {
144:                    Extension pXMLExt = (Extension) listExtXMLPlugin
145:                            .elementAt(i);
146:                    JPFManager pJPFManager = pIhm.getPluginManager();
147:                    try {
148:                        XMLPrinterPlugin pXMLPrinterPlugin = (XMLPrinterPlugin) pJPFManager
149:                                .activateExtension(pXMLExt);
150:                        JPanel pPanel = pXMLPrinterPlugin
151:                                .getExportOptionPanel();
152:                        if (pPanel != null
153:                                && !panelsPluginsForExport.contains(pPanel)) {
154:                            panelsPluginsForExport.add(pPanel);
155:                        }
156:                    } catch (Exception e) {
157:
158:                    }
159:                }
160:
161:                //DataModel.reloadFromBase(false);
162:
163:                sauvLabel = new JLabel(Language.getInstance().getText(
164:                        "Fichier_de_sauvegarde_:"));
165:                sauvTF = new JTextField(30);
166:                sauvButton = new JButton(Language.getInstance().getText(
167:                        "Choisir..."));
168:                sauvButton.addActionListener(this );
169:
170:                importTestBox = new JCheckBox(Language.getInstance().getText(
171:                        "Exporter_uniquement_les_tests"));
172:                importTestBox.addActionListener(this );
173:                importTestBox.setSelected(true);
174:                testSelection = new JButton(Language.getInstance().getText(
175:                        "Sélection_des_tests..."));
176:                testSelection.addActionListener(this );
177:
178:                tousTests = new JLabel(Language.getInstance().getText(
179:                        "(Par_défaut,_tous_les_tests_sont_exportés)"));
180:                tousTests.setFont(new Font(null, Font.ITALIC, 12));
181:
182:                valider = new JButton(Language.getInstance().getText("OK"));
183:                valider.addActionListener(this );
184:
185:                annuler = new JButton(Language.getInstance().getText("Annuler"));
186:                annuler.addActionListener(this );
187:
188:                JPanel importTestPanel = new JPanel();
189:                importTestPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
190:                importTestPanel.add(importTestBox);
191:
192:                JPanel selectTestPanel = new JPanel();
193:                selectTestPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
194:                selectTestPanel.add(testSelection);
195:                selectTestPanel.add(tousTests);
196:
197:                JPanel selectPanel = new JPanel();
198:                selectPanel.setLayout(new BoxLayout(selectPanel,
199:                        BoxLayout.Y_AXIS));
200:                selectPanel.setBorder(BorderFactory.createTitledBorder(""));
201:                selectPanel.add(importTestPanel);
202:                selectPanel.add(selectTestPanel);
203:
204:                JPanel sauvLabelPanel = new JPanel(new FlowLayout(
205:                        FlowLayout.LEFT));
206:                sauvLabelPanel.add(sauvLabel);
207:                JPanel sauvTFPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
208:                sauvTFPanel.add(sauvTF);
209:                JPanel sauvButtonPanel = new JPanel(new FlowLayout(
210:                        FlowLayout.LEFT));
211:                sauvButtonPanel.add(sauvButton);
212:
213:                JLabel encodingLabel = new JLabel(Language.getInstance()
214:                        .getText("Encodage_:"));
215:
216:                JPanel encodingPanel = new JPanel(new FlowLayout(
217:                        FlowLayout.LEFT));
218:                encodingPanel.add(encodingLabel);
219:                encodingPanel.add(comboEncoding);
220:
221:                JPanel sauvPanel = new JPanel();
222:                sauvPanel.setLayout(new BoxLayout(sauvPanel, BoxLayout.Y_AXIS));
223:                sauvPanel.setBorder(BorderFactory.createTitledBorder(""));
224:                sauvPanel.add(sauvLabelPanel);
225:                sauvPanel.add(sauvTFPanel);
226:                sauvPanel.add(sauvButtonPanel);
227:                sauvPanel.add(Box.createVerticalStrut(5));
228:                sauvPanel.add(encodingPanel);
229:
230:                JPanel buttons = new JPanel();
231:                buttons.add(valider);
232:                buttons.add(annuler);
233:
234:                progress = new JProgressBar();
235:                JPanel progression = new JPanel(new FlowLayout(
236:                        FlowLayout.CENTER));
237:                progression.add(progress);
238:
239:                JPanel commonPanel = new JPanel();
240:                commonPanel.setLayout(new BoxLayout(commonPanel,
241:                        BoxLayout.Y_AXIS));
242:                commonPanel.add(buttons);
243:                commonPanel.add(Box.createRigidArea(new Dimension(1, 5)));
244:                commonPanel.add(progression);
245:
246:                JPanel page = new JPanel();
247:                page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
248:                page.add(Box.createVerticalStrut(10));
249:                page.add(sauvPanel);
250:                page.add(Box.createVerticalStrut(10));
251:                page.add(selectPanel);
252:
253:                JTabbedPane onglets = new JTabbedPane();
254:                onglets.addTab(Language.getInstance().getText("Principal"),
255:                        page);
256:                /**** Ajout des tabs des plugins ****/
257:                for (JPanel pPanel : panelsPluginsForExport) {
258:                    String name = pPanel.getName();
259:                    onglets.addTab(name, pPanel);
260:                }
261:
262:                Container contentPaneFrame = this .getContentPane();
263:                contentPaneFrame.add(onglets, BorderLayout.CENTER);
264:                contentPaneFrame.add(commonPanel, BorderLayout.SOUTH);
265:
266:                setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
267:                addWindowListener(new WindowAdapter() {
268:                    public void windowClosing(WindowEvent we) {
269:                        if (exportProcess != null && exportProcess.isAlive()) {
270:                            return;
271:                        } else {
272:                            dispose();
273:                        }
274:                    }
275:                });
276:
277:                setTitle(Language.getInstance().getText("Export_au_format_XML"));
278:                //setLocation(400,100);
279:                centerScreen();
280:            }
281:
282:            void centerScreen() {
283:                Dimension dim = getToolkit().getScreenSize();
284:                this .pack();
285:                Rectangle abounds = getBounds();
286:                setLocation((dim.width - abounds.width) / 2,
287:                        (dim.height - abounds.height) / 2);
288:                this .setVisible(true);
289:                requestFocus();
290:            }
291:
292:            /*****************************************************************************************************
293:             * Action Listener
294:             ****************************************************************************************************/
295:
296:            public void actionPerformed(ActionEvent evt) {
297:                if (exportProcess != null && exportProcess.isAlive()) {
298:                    return;
299:                }
300:                if (evt.getSource().equals(valider)) {
301:                    try {
302:                        validerPerformed();
303:                    } catch (Exception ex) {
304:                        Tools.ihmExceptionView(ex);
305:                    }
306:                } else if (evt.getSource().equals(annuler)) {
307:                    try {
308:                        annulerPerformed();
309:                    } catch (Exception ex) {
310:                        Tools.ihmExceptionView(ex);
311:                    }
312:                } else if (evt.getSource().equals(testSelection)) {
313:                    try {
314:                        testSelectionPerformed();
315:                    } catch (Exception ex) {
316:                        Tools.ihmExceptionView(ex);
317:                    }
318:                } else if (evt.getSource().equals(importTestBox)) {
319:                    try {
320:                        importTestBoxPerformed();
321:                    } catch (Exception ex) {
322:                        Tools.ihmExceptionView(ex);
323:                    }
324:                } else if (evt.getSource().equals(sauvButton)) {
325:                    try {
326:                        sauvButtonPerformed();
327:                    } catch (Exception ex) {
328:                        Tools.ihmExceptionView(ex);
329:                    }
330:                }
331:            }
332:
333:            void validerPerformed() throws Exception {
334:                //exporter();
335:                if (exportProcess == null || !exportProcess.isAlive()) {
336:                    exportProcess = new Thread(new ExportProcess());
337:                    exportProcess.start();
338:                }
339:            }
340:
341:            void annulerPerformed() throws Exception {
342:                dispose();
343:            }
344:
345:            void testSelectionPerformed() throws Exception {
346:                TestChooser testChooser = new TestChooser(SalomeTMFPanels
347:                        .getTestDynamicTree().getRoot(), ExportDialog.this ,
348:                        initSelection, getChosenRoot(), TEST);
349:                if (!testChooser.isCancelled()) {
350:                    setInitSelection(true);
351:                    setFamilySelectionList(testChooser.getTemporaryFamilyList());
352:                    setSuiteSelectionList(testChooser
353:                            .getTemporaryTestListList());
354:                    setTestSelectionList(testChooser.getTemporaryTestList());
355:                    setChosenRoot((DefaultMutableTreeNode) testChooser
356:                            .getChosenTreeModel().getRoot());
357:                }
358:            }
359:
360:            void importTestBoxPerformed() throws Exception {
361:                if (!importTestBox.isSelected()) {
362:                    testSelection.setEnabled(false);
363:                } else {
364:                    testSelection.setEnabled(true);
365:                }
366:            }
367:
368:            void sauvButtonPerformed() throws Exception {
369:                JFileChooser fileChooser = new JFileChooser();
370:                fileChooser.addChoosableFileFilter(new ScriptFileFilter(
371:                        Language.getInstance().getText("Fichier_XML_[*.xml]"),
372:                        ".xml"));
373:                int returnVal = fileChooser.showDialog(ExportDialog.this ,
374:                        Language.getInstance().getText("Sélectionner"));
375:                if (returnVal == JFileChooser.APPROVE_OPTION) {
376:                    xmlFile = fileChooser.getSelectedFile().getAbsolutePath();
377:                    if (xmlFile.indexOf(".") != -1) {
378:                        if (!xmlFile.substring(xmlFile.lastIndexOf("."))
379:                                .equals(".xml")) {
380:                            xmlFile += ".xml";
381:                        }
382:                    } else {
383:                        xmlFile += ".xml";
384:                    }
385:                    sauvTF.setText(xmlFile);
386:                }
387:            }
388:
389:            /*****************************************************************************************************
390:             * Méthodes
391:             ****************************************************************************************************/
392:
393:            class ExportProcess implements  Runnable {
394:                public void run() {
395:                    boolean ok = true;
396:                    if (sauvTF.getText().equals("")) {
397:                        JOptionPane.showMessageDialog(ExportDialog.this ,
398:                                Language.getInstance().getText(
399:                                        "Vous_devez_entrez_un_nom_de_fichier"),
400:                                Language.getInstance().getText("Erreur_!"),
401:                                JOptionPane.ERROR_MESSAGE);
402:                        ok = false;
403:                    } else {
404:                        try {
405:                            String saveFileName = sauvTF.getText().trim();
406:                            String xmlDirName = "";
407:                            if (saveFileName.lastIndexOf(fs) != -1) {
408:                                xmlDirName = saveFileName.substring(0,
409:                                        saveFileName.lastIndexOf(fs));
410:                            } else {
411:                                File saveFile = new File(saveFileName);
412:                                xmlDirName = saveFile.getParent();
413:                            }
414:
415:                            Document doc;
416:                            Contexte pContexte = new Contexte(xmlDirName, null,
417:                                    (String) comboEncoding.getSelectedItem(),
418:                                    OutFormat.XML);
419:                            XmlGenerator generator = new XmlGenerator(pIhm,
420:                                    pContexte);
421:                            generator.addDocType = false;
422:                            setCursor(Cursor
423:                                    .getPredefinedCursor(Cursor.WAIT_CURSOR));
424:                            progress.setIndeterminate(true);
425:                            if (!isInitSelection()) {
426:                                doc = generator.toDocumentDyna(null, null);
427:                            } else {
428:                                doc = generator.toDocument(
429:                                        getFamilySelectionList(),
430:                                        getSuiteSelectionList(),
431:                                        getTestSelectionList());
432:                            }
433:                            generator.documentToXML(doc, saveFileName);
434:
435:                            progress.setVisible(false);
436:                            setCursor(Cursor
437:                                    .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
438:                            if (ok && !annule) {
439:                                JOptionPane
440:                                        .showMessageDialog(
441:                                                ExportDialog.this ,
442:                                                Language
443:                                                        .getInstance()
444:                                                        .getText(
445:                                                                "L'export_au_format_xml_s'est_terminé_avec_succès"),
446:                                                Language.getInstance().getText(
447:                                                        "Information..."),
448:                                                JOptionPane.INFORMATION_MESSAGE);
449:                            }
450:                            ExportDialog.this .dispose();
451:                        } catch (Exception e) {
452:                            progress.setVisible(false);
453:                            setCursor(Cursor
454:                                    .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
455:                            Tools.ihmExceptionView(e);
456:                            ok = false;
457:                            ExportDialog.this .dispose();
458:                        }
459:                    }
460:
461:                }
462:            }
463:
464:            /*****************************************************************************************************
465:             * Selecteur
466:             ****************************************************************************************************/
467:
468:            /**
469:             * @return Returns the chosenRoot.
470:             */
471:            public DefaultMutableTreeNode getChosenRoot() {
472:                return chosenRoot;
473:            }
474:
475:            /**
476:             * @param chosenRoot The chosenRoot to set.
477:             */
478:            public void setChosenRoot(DefaultMutableTreeNode chosenRoot) {
479:                this .chosenRoot = chosenRoot;
480:            }
481:
482:            /**
483:             * @return Returns the familySelectionList.
484:             */
485:            public ArrayList<Family> getFamilySelectionList() {
486:                return familySelectionList;
487:            }
488:
489:            /**
490:             * @param familySelectionList The familySelectionList to set.
491:             */
492:            public void setFamilySelectionList(
493:                    ArrayList<Family> familySelectionList) {
494:                if (familySelectionList != null)
495:                    this .familySelectionList = familySelectionList;
496:            }
497:
498:            /**
499:             * @return Returns the suiteSelectionList.
500:             */
501:            public ArrayList<TestList> getSuiteSelectionList() {
502:                return suiteSelectionList;
503:            }
504:
505:            /**
506:             * @param suiteSelectionList The suiteSelectionList to set.
507:             */
508:            public void setSuiteSelectionList(
509:                    ArrayList<TestList> suiteSelectionList) {
510:                if (suiteSelectionList != null)
511:                    this .suiteSelectionList = suiteSelectionList;
512:            }
513:
514:            /**
515:             * @return Returns the testSelectionList.
516:             */
517:            public ArrayList<Test> getTestSelectionList() {
518:                return testSelectionList;
519:            }
520:
521:            /**
522:             * @param testSelectionList The testSelectionList to set.
523:             */
524:            public void setTestSelectionList(ArrayList<Test> testSelectionList) {
525:                if (testSelectionList != null)
526:                    this .testSelectionList = testSelectionList;
527:            }
528:
529:            /**
530:             * @return Returns the initSelection.
531:             */
532:            public boolean isInitSelection() {
533:                return initSelection;
534:            }
535:
536:            /**
537:             * @param initSelection The initSelection to set.
538:             */
539:            public void setInitSelection(boolean initSelection) {
540:                this.initSelection = initSelection;
541:            }
542:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.