Source Code Cross Referenced for ExportDialog.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » gen_doc_xml » 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.gen_doc_xml 
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.gen_doc_xml;
025:
026:        import java.awt.BorderLayout;
027:        import java.awt.Container;
028:        import java.awt.FlowLayout;
029:        import java.awt.Font;
030:        import java.awt.event.ActionEvent;
031:        import java.awt.event.ActionListener;
032:        import java.net.URL;
033:        import java.util.ArrayList;
034:
035:        import javax.swing.BorderFactory;
036:        import javax.swing.Box;
037:        import javax.swing.BoxLayout;
038:        import javax.swing.JButton;
039:        import javax.swing.JCheckBox;
040:        import javax.swing.JDialog;
041:        import javax.swing.JFileChooser;
042:        import javax.swing.JLabel;
043:        import javax.swing.JOptionPane;
044:        import javax.swing.JPanel;
045:        import javax.swing.JTextField;
046:        import javax.swing.tree.DefaultMutableTreeNode;
047:
048:        import org.dom4j.Document;
049:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
050:        import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
051:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
052:        import org.objectweb.salome_tmf.ihm.models.ScriptFileFilter;
053:        import org.objectweb.salome_tmf.ihm.tools.Tools;
054:        import org.objectweb.salome_tmf.plugins.IPlugObject;
055:
056:        import salomeTMF_plug.gen_doc_xml.languages.Language;
057:
058:        /**
059:         *
060:         * @author  vapu8214
061:         */
062:        public class ExportDialog extends JDialog {
063:
064:            // Salome GUI
065:            IPlugObject pIhm = null;
066:            URL urlBase;
067:            String url_txt;
068:            private String fs = System.getProperties().getProperty(
069:                    "file.separator");
070:
071:            String xmlFile;
072:            JLabel sauvLabel;
073:            JTextField sauvTF;
074:            JButton sauvButton;
075:
076:            JCheckBox importTestBox;
077:            JLabel importTestLabel;
078:            JButton testSelection;
079:            JLabel tousTests;
080:            boolean selectionDesTests = false;
081:
082:            JButton valider;
083:            JButton annuler;
084:            boolean annule = false;
085:
086:            boolean initSelection = false;
087:            ArrayList suiteSelectionList;
088:            ArrayList familySelectionList;
089:            ArrayList testSelectionList;
090:            DefaultMutableTreeNode chosenRoot;
091:
092:            /** Creates a new instance of ExportDialog */
093:            public ExportDialog(IPlugObject vt) {
094:                super (SalomeTMFContext.getInstance().getSalomeFrame(), true);
095:                pIhm = vt;
096:                urlBase = SalomeTMFContext.getInstance().getUrlBase();
097:                String _urlBase = urlBase.toString();
098:                url_txt = _urlBase.substring(0, _urlBase.lastIndexOf("/"));
099:
100:                DataModel.reloadFromBase(false);
101:
102:                sauvLabel = new JLabel(Language.getInstance().getText(
103:                        "Fichier_de_sauvegarde_:"));
104:                sauvTF = new JTextField(30);
105:                sauvButton = new JButton(Language.getInstance().getText(
106:                        "Choisir..."));
107:                sauvButton.addActionListener(new ActionListener() {
108:                    public void actionPerformed(ActionEvent e) {
109:                        JFileChooser fileChooser = new JFileChooser();
110:                        fileChooser
111:                                .addChoosableFileFilter(new ScriptFileFilter(
112:                                        Language.getInstance().getText(
113:                                                "Fichier_XML_[*.xml]"), ".xml"));
114:                        int returnVal = fileChooser.showDialog(
115:                                ExportDialog.this , Language.getInstance()
116:                                        .getText("Sélectionner"));
117:                        if (returnVal == JFileChooser.APPROVE_OPTION) {
118:                            xmlFile = fileChooser.getSelectedFile()
119:                                    .getAbsolutePath();
120:                            if (xmlFile.indexOf(".") != -1) {
121:                                if (!xmlFile
122:                                        .substring(xmlFile.lastIndexOf("."))
123:                                        .equals(".xml")) {
124:                                    xmlFile += ".xml";
125:                                }
126:                            } else {
127:                                xmlFile += ".xml";
128:                            }
129:                            sauvTF.setText(xmlFile);
130:                        }
131:                    }
132:                });
133:
134:                importTestBox = new JCheckBox();
135:                importTestBox.addActionListener(new ActionListener() {
136:                    public void actionPerformed(ActionEvent e) {
137:                        if (!importTestBox.isSelected()) {
138:                            testSelection.setEnabled(false);
139:                        } else {
140:                            testSelection.setEnabled(true);
141:                        }
142:                    }
143:                });
144:                importTestBox.setSelected(true);
145:                importTestLabel = new JLabel(Language.getInstance().getText(
146:                        "Exporter_uniquement_les_tests"));
147:                testSelection = new JButton(Language.getInstance().getText(
148:                        "Sélection_des_tests..."));
149:                testSelection.addActionListener(new ActionListener() {
150:                    public void actionPerformed(ActionEvent e) {
151:                        if (initSelection) {
152:                            new TestChooser(SalomeTMFPanels
153:                                    .getTestDynamicTree().getRoot(),
154:                                    ExportDialog.this , initSelection);
155:                        } else {
156:                            new TestChooser(SalomeTMFPanels
157:                                    .getTestDynamicTree().getRoot(),
158:                                    ExportDialog.this , initSelection);
159:                        }
160:                    }
161:                });
162:                tousTests = new JLabel(Language.getInstance().getText(
163:                        "(Par_défaut,_tous_les_tests_sont_exportés)"));
164:                tousTests.setFont(new Font(null, Font.ITALIC, 12));
165:
166:                valider = new JButton(Language.getInstance().getText("OK"));
167:                valider.addActionListener(new ActionListener() {
168:                    public void actionPerformed(ActionEvent e) {
169:                        exporter();
170:                    }
171:                });
172:
173:                annuler = new JButton(Language.getInstance().getText("Annuler"));
174:                annuler.addActionListener(new ActionListener() {
175:                    public void actionPerformed(ActionEvent e) {
176:                        ExportDialog.this .dispose();
177:                    }
178:                });
179:
180:                JPanel importTestPanel = new JPanel();
181:                importTestPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
182:                importTestPanel.add(importTestBox);
183:                importTestPanel.add(importTestLabel);
184:
185:                JPanel selectTestPanel = new JPanel();
186:                selectTestPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
187:                selectTestPanel.add(testSelection);
188:                selectTestPanel.add(tousTests);
189:
190:                JPanel selectPanel = new JPanel();
191:                selectPanel.setLayout(new BoxLayout(selectPanel,
192:                        BoxLayout.Y_AXIS));
193:                selectPanel.setBorder(BorderFactory.createTitledBorder(""));
194:                selectPanel.add(importTestPanel);
195:                selectPanel.add(selectTestPanel);
196:
197:                JPanel sauvLabelPanel = new JPanel(new FlowLayout(
198:                        FlowLayout.LEFT));
199:                sauvLabelPanel.add(sauvLabel);
200:                JPanel sauvTFPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
201:                sauvTFPanel.add(sauvTF);
202:                JPanel sauvButtonPanel = new JPanel(new FlowLayout(
203:                        FlowLayout.LEFT));
204:                sauvButtonPanel.add(sauvButton);
205:
206:                JPanel sauvPanel = new JPanel();
207:                sauvPanel.setLayout(new BoxLayout(sauvPanel, BoxLayout.Y_AXIS));
208:                sauvPanel.setBorder(BorderFactory.createTitledBorder(""));
209:                sauvPanel.add(sauvLabelPanel);
210:                sauvPanel.add(sauvTFPanel);
211:                sauvPanel.add(sauvButtonPanel);
212:
213:                JPanel buttons = new JPanel();
214:                buttons.add(valider);
215:                buttons.add(annuler);
216:
217:                JPanel page = new JPanel();
218:                page.setLayout(new BoxLayout(page, BoxLayout.Y_AXIS));
219:                page.add(Box.createVerticalStrut(10));
220:                page.add(sauvPanel);
221:                page.add(Box.createVerticalStrut(10));
222:                page.add(selectPanel);
223:                page.add(Box.createVerticalStrut(10));
224:                page.add(buttons);
225:
226:                Container contentPaneFrame = this .getContentPane();
227:                contentPaneFrame.add(page, BorderLayout.CENTER);
228:
229:                setLocation(400, 100);
230:                setTitle(Language.getInstance().getText("Export_au_format_XML"));
231:                pack();
232:                setVisible(true);
233:
234:            }
235:
236:            public void exporter() {
237:                boolean ok = true;
238:                if (sauvTF.getText().equals("")) {
239:                    JOptionPane.showMessageDialog(ExportDialog.this , Language
240:                            .getInstance().getText(
241:                                    "Vous_devez_entrez_un_nom_de_fichier"),
242:                            Language.getInstance().getText("Erreur_!"),
243:                            JOptionPane.ERROR_MESSAGE);
244:                    ok = false;
245:                } else {
246:                    String saveFileName = sauvTF.getText().trim();
247:                    String xmlDirName = saveFileName.substring(0, saveFileName
248:                            .lastIndexOf(fs));
249:                    /*URL dtdDyna = null;
250:                    try {
251:                        dtdDyna = new URL(url_txt + "/plugins/gen_doc_xml/xsl/SalomeDynamique.dtd");
252:                        // Cas serveur
253:                        try {
254:                            Tools.writeFile(dtdDyna.openStream(), xmlDirName + "SalomeDynamique.dtd");
255:                        }catch (Exception exception){
256:                            // Cas DEBUG
257:                            Tools.writeFile(ExportDialog.class.getResourceAsStream("/salome/plugins/gen_doc_xml/xsl/SalomeDynamique.dtd"), xmlDirName + "SalomeDynamique.dtd");
258:                        }
259:                    }catch (Exception e){
260:                        e.printStackTrace();
261:                        Tools.ihmExceptionView(Language.getInstance().getText("Erreur_de_chargement_des_fichiers_nécessaires_à_la_transformation")+e.toString());
262:                        ok=false;
263:                        ExportDialog.this.dispose();
264:                    }*/
265:                    Document doc;
266:                    XmlGenerator generator = new XmlGenerator(pIhm);
267:                    generator.addDocType = false;
268:                    if (!isInitSelection()) {
269:                        doc = generator.toDocumentDyna(xmlDirName, null, null,
270:                                null);
271:                    } else {
272:                        doc = generator.toDocument(xmlDirName,
273:                                getFamilySelectionList(),
274:                                getSuiteSelectionList(),
275:                                getTestSelectionList(), null);
276:                    }
277:                    try {
278:                        generator.documentToXML(doc, saveFileName);
279:                    } catch (Exception e) {
280:                        //e.printStackTrace();
281:                        Tools.ihmExceptionView(e);
282:                        //Tools.ihmExceptionView(Language.getInstance().getText("Erreur_lors_de_la_création_du_fichier_xml")+e.toString());
283:                        ok = false;
284:                        ExportDialog.this .dispose();
285:                    }
286:                }
287:                if (ok && !annule) {
288:                    JOptionPane
289:                            .showMessageDialog(
290:                                    ExportDialog.this ,
291:                                    Language
292:                                            .getInstance()
293:                                            .getText(
294:                                                    "L'export_au_format_xml_s'est_terminé_avec_succès"),
295:                                    Language.getInstance().getText(
296:                                            "Information..."),
297:                                    JOptionPane.INFORMATION_MESSAGE);
298:                    ExportDialog.this .dispose();
299:                }
300:            }
301:
302:            /**
303:             * @return Returns the chosenRoot.
304:             */
305:            public DefaultMutableTreeNode getChosenRoot() {
306:                return chosenRoot;
307:            }
308:
309:            /**
310:             * @param chosenRoot The chosenRoot to set.
311:             */
312:            public void setChosenRoot(DefaultMutableTreeNode chosenRoot) {
313:                this .chosenRoot = chosenRoot;
314:            }
315:
316:            /**
317:             * @return Returns the familySelectionList.
318:             */
319:            public ArrayList getFamilySelectionList() {
320:                return familySelectionList;
321:            }
322:
323:            /**
324:             * @param familySelectionList The familySelectionList to set.
325:             */
326:            public void setFamilySelectionList(ArrayList familySelectionList) {
327:                this .familySelectionList = familySelectionList;
328:            }
329:
330:            /**
331:             * @return Returns the suiteSelectionList.
332:             */
333:            public ArrayList getSuiteSelectionList() {
334:                return suiteSelectionList;
335:            }
336:
337:            /**
338:             * @param suiteSelectionList The suiteSelectionList to set.
339:             */
340:            public void setSuiteSelectionList(ArrayList suiteSelectionList) {
341:                this .suiteSelectionList = suiteSelectionList;
342:            }
343:
344:            /**
345:             * @return Returns the testSelectionList.
346:             */
347:            public ArrayList getTestSelectionList() {
348:                return testSelectionList;
349:            }
350:
351:            /**
352:             * @param testSelectionList The testSelectionList to set.
353:             */
354:            public void setTestSelectionList(ArrayList testSelectionList) {
355:                this .testSelectionList = testSelectionList;
356:            }
357:
358:            /**
359:             * @return Returns the initSelection.
360:             */
361:            public boolean isInitSelection() {
362:                return initSelection;
363:            }
364:
365:            /**
366:             * @param initSelection The initSelection to set.
367:             */
368:            public void setInitSelection(boolean initSelection) {
369:                this.initSelection = initSelection;
370:            }
371:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.