001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2007 EDF / 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 Jérémie DEFAYE
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package salomeTMF_plug.pluginxlsxml.Export;
025:
026: import org.dom4j.Document;
027: import org.objectweb.salome_tmf.plugins.IPlugObject;
028: import salomeTMF_plug.docXML.export.Contexte;
029: import salomeTMF_plug.docXML.export.XmlGenerator;
030: import salomeTMF_plug.docXML.export.Contexte.OutFormat;
031:
032: /**
033: * Class which call DocXml plugin to import or Export Data
034: *
035: * @author adm_dfej
036: */
037:
038: public class CallPackageDocXML {
039:
040: /**
041: * Class that call package DocXML to parse XML file
042: */
043: public enum OutFormat {
044: XML, HTML, DOCBOOK, EXCEL
045: };
046:
047: private OutFormat outputFormat;
048:
049: boolean initSelection = false;
050:
051: /**
052: * Get the File Separator (different between Unix and Windows)
053: */
054: private String fs = System.getProperties().getProperty(
055: "file.separator");
056:
057: /**
058: * Creates a new instance of CallPackageDocXML
059: *
060: * @param pIhm
061: * Interface Homme Machine
062: * @param saveFileName2
063: * Name of the XML file
064: */
065: public CallPackageDocXML(IPlugObject pIhm, String saveFileName2) {
066:
067: final String xlsDirName = saveFileName2.substring(0,
068: saveFileName2.lastIndexOf(fs));
069: Document doc;
070: // final Contexte pContexte = new Contexte(xlsDirName, null, "ISO-8859-1", outputFormat.EXCEL);
071: final Contexte pContexte = new Contexte(xlsDirName, null,
072: "ISO-8859-1", null);
073:
074: XmlGenerator generator;
075: generator = new XmlGenerator(pIhm, pContexte);
076: generator.addDocType = false;
077: try {
078: if (!isInitSelection()) {
079: doc = generator.toDocumentDyna(null, null);
080: } else {
081: doc = generator.toDocument(null, null, null);
082: }
083: generator.documentToXML(doc, saveFileName2);
084:
085: } catch (final Exception ex) {
086: ex.printStackTrace();
087: }
088:
089: }
090:
091: /**
092: * Return initSelection
093: *
094: * @return initSelection
095: */
096: public boolean isInitSelection() {
097: return initSelection;
098: }
099:
100: /**
101: * Set initSelection
102: *
103: * @param initSelection
104: * The initSelection to set.
105: */
106: public void setInitSelection(boolean initSelection) {
107: this.initSelection = initSelection;
108: }
109: }
|