0001: /*
0002: * SalomeTMF is a Test Management Framework
0003: * Copyright (C) 2005 France Telecom R&D
0004: *
0005: * This library is free software; you can redistribute it and/or
0006: * modify it under the terms of the GNU Lesser General Public
0007: * License as published by the Free Software Foundation; either
0008: * version 2 of the License, or (at your option) any later version.
0009: *
0010: * This library is distributed in the hope that it will be useful,
0011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013: * Lesser General Public License for more details.
0014: *
0015: * You should have received a copy of the GNU Lesser General Public
0016: * License along with this library; if not, write to the Free Software
0017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018: *
0019: * @author Aurore PENAULT
0020: *
0021: * Contact: mikael.marche@rd.francetelecom.com
0022: */
0023:
0024: package salomeTMF_plug.docXML.common;
0025:
0026: import java.awt.BorderLayout;
0027: import java.awt.Container;
0028: import java.awt.Dimension;
0029: import java.awt.FlowLayout;
0030: import java.awt.Rectangle;
0031: import java.awt.event.ActionEvent;
0032: import java.awt.event.ActionListener;
0033: import java.io.File;
0034: import java.io.FileInputStream;
0035: import java.net.URL;
0036: import java.text.DateFormat;
0037: import java.util.ArrayList;
0038: import java.util.Date;
0039: import java.util.Locale;
0040: import java.util.Vector;
0041:
0042: import javax.swing.BorderFactory;
0043: import javax.swing.Box;
0044: import javax.swing.BoxLayout;
0045: import javax.swing.ButtonGroup;
0046: import javax.swing.JButton;
0047: import javax.swing.JCheckBox;
0048: import javax.swing.JComboBox;
0049: import javax.swing.JDialog;
0050: import javax.swing.JFileChooser;
0051: import javax.swing.JLabel;
0052: import javax.swing.JOptionPane;
0053: import javax.swing.JPanel;
0054: import javax.swing.JProgressBar;
0055: import javax.swing.JRadioButton;
0056: import javax.swing.JTabbedPane;
0057: import javax.swing.JTextField;
0058: import javax.swing.border.TitledBorder;
0059: import javax.swing.tree.DefaultMutableTreeNode;
0060:
0061: import org.dom4j.Document;
0062: import org.dom4j.DocumentFactory;
0063: import org.dom4j.Element;
0064: import org.java.plugin.Extension;
0065: import org.objectweb.salome_tmf.api.Api;
0066: import org.objectweb.salome_tmf.data.Campaign;
0067: import org.objectweb.salome_tmf.data.DataConstants;
0068: import org.objectweb.salome_tmf.data.Execution;
0069: import org.objectweb.salome_tmf.data.Family;
0070: import org.objectweb.salome_tmf.data.Test;
0071: import org.objectweb.salome_tmf.data.TestList;
0072: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
0073: import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
0074: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0075: import org.objectweb.salome_tmf.ihm.models.ScriptFileFilter;
0076: import org.objectweb.salome_tmf.ihm.tools.Tools;
0077: import org.objectweb.salome_tmf.plugins.IPlugObject;
0078: import org.objectweb.salome_tmf.plugins.JPFManager;
0079: import org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin;
0080:
0081: import salomeTMF_plug.docXML.data.GardePage;
0082: import salomeTMF_plug.docXML.export.Contexte;
0083: import salomeTMF_plug.docXML.export.XSLGenerator;
0084: import salomeTMF_plug.docXML.export.XmlGenerator;
0085: import salomeTMF_plug.docXML.export.Contexte.OutFormat;
0086: import salomeTMF_plug.docXML.languages.Language;
0087:
0088: /**
0089: * Classe créant l'IHM permettant à l'utilisateur de sélectionner les
0090: * différentes options pour la création de la documentation
0091: *
0092: * @author vapu8214
0093: */
0094: public class GenDocDialog extends JDialog implements DataConstants,
0095: ActionListener {
0096:
0097: private String tmpDir = System.getProperties().getProperty(
0098: "java.io.tmpdir");
0099:
0100: // Salome GUI
0101: static IPlugObject pIhm = null;
0102:
0103: JTabbedPane onglets;
0104:
0105: String reportFile;
0106:
0107: int sourceType;
0108:
0109: boolean annule = false;
0110:
0111: JRadioButton htmlRadio;
0112:
0113: JRadioButton docbookRadio;
0114:
0115: JRadioButton withoutFrameRadio;
0116:
0117: JRadioButton multiFrameRadio;
0118:
0119: JLabel htmlLabel;
0120:
0121: JTextField reportTextField;
0122:
0123: JButton htmlButton;
0124:
0125: JButton validationButton;
0126:
0127: JButton cancelButton;
0128:
0129: final String url_txt;
0130:
0131: String urlTranslate;
0132:
0133: JRadioButton formBox;
0134:
0135: JRadioButton gardeBox;
0136:
0137: JLabel gardeLabel;
0138:
0139: JTextField gardeTextField;
0140:
0141: JButton gardeButton;
0142:
0143: JButton formulaireButton;
0144:
0145: String gardeFile;
0146:
0147: JLabel enTeteLabel;
0148:
0149: JTextField enTeteTextField;
0150:
0151: JButton enTeteButton;
0152:
0153: String enTeteFile;
0154:
0155: JLabel piedLabel;
0156:
0157: JTextField piedTextField;
0158:
0159: JButton piedButton;
0160:
0161: String piedFile;
0162:
0163: ButtonGroup miseFormeGroup;
0164:
0165: /*
0166: * Barre de progression
0167: */
0168: JProgressBar progress;
0169:
0170: /*
0171: * Attributs pour l'inclusion des fichiers
0172: */
0173: JLabel inclusPhrase;
0174:
0175: JTextField inclusFormat;
0176:
0177: JCheckBox jpgBox;
0178:
0179: JCheckBox pngBox;
0180:
0181: JCheckBox gifBox;
0182:
0183: Element pageGardeElement;
0184:
0185: JButton testSelectionButton;
0186:
0187: private ArrayList<TestList> suiteList;
0188:
0189: private ArrayList<Family> familyList;
0190:
0191: private ArrayList<Test> testList;
0192:
0193: JButton campSelectionButton;
0194:
0195: JButton chapterSelectionButton;
0196:
0197: ArrayList<Campaign> campList;
0198:
0199: ArrayList<Execution> execList;
0200:
0201: DefaultMutableTreeNode chosenRoot;
0202:
0203: boolean initSelection = false;
0204: boolean initChapterSelection = false;
0205:
0206: boolean generation = false;
0207:
0208: URL genFic;
0209:
0210: URL urlBase;
0211:
0212: String logoFilePath;
0213:
0214: GardePage save;
0215:
0216: private String errorMessage = "";
0217: private Vector<JPanel> panelsPluginsForExport = new Vector<JPanel>();
0218: private JComboBox comboEncoding;
0219: private Vector<String> codingList;
0220:
0221: private ArrayList<String> chosenChaptersList;
0222:
0223: /**
0224: * Creates a new instance of GraphicDialog
0225: */
0226: public GenDocDialog(int type, IPlugObject vt) throws Exception {
0227: super (SalomeTMFContext.getInstance().getSalomeFrame(), true);
0228: pIhm = vt;
0229: urlBase = SalomeTMFContext.getInstance().getUrlBase();
0230:
0231: codingList = new Vector<String>();
0232: codingList.add("ISO-8859-15");
0233: codingList.add("ISO-8859-1");
0234: codingList.add("UTF-8");
0235: codingList.add("UTF-16");
0236: comboEncoding = new JComboBox(codingList);
0237: comboEncoding.setEditable(false);
0238:
0239: Vector<Extension> listExtXMLPlugin = vt
0240: .getXMLPrintersExtension();
0241: int size = listExtXMLPlugin.size();
0242: for (int i = 0; i < size; i++) {
0243: Extension pXMLExt = (Extension) listExtXMLPlugin
0244: .elementAt(i);
0245: JPFManager pJPFManager = vt.getPluginManager();
0246: try {
0247: XMLPrinterPlugin pXMLPrinterPlugin = (XMLPrinterPlugin) pJPFManager
0248: .activateExtension(pXMLExt);
0249: JPanel pPanel = pXMLPrinterPlugin
0250: .getExportOptionPanel();
0251: if (pPanel != null
0252: && !panelsPluginsForExport.contains(pPanel)) {
0253: panelsPluginsForExport.add(pPanel);
0254: }
0255: } catch (Exception e) {
0256:
0257: }
0258: }
0259:
0260: String _urlBase = urlBase.toString();
0261: url_txt = _urlBase.substring(0, _urlBase.lastIndexOf("/"));
0262: sourceType = type;
0263:
0264: htmlLabel = new JLabel();
0265: htmlLabel.setText(Language.getInstance().getText(
0266: "Fichier_de_sauvegarde_pour_la_documentation_:"));
0267: reportTextField = new JTextField(30);
0268: htmlButton = new JButton(Language.getInstance().getText(
0269: "Choisir..."));
0270: htmlButton.addActionListener(this );
0271:
0272: htmlRadio = new JRadioButton(Language.getInstance().getText(
0273: "HTML"), true);
0274: docbookRadio = new JRadioButton(Language.getInstance().getText(
0275: "DocBook"));
0276: withoutFrameRadio = new JRadioButton(Language.getInstance()
0277: .getText("Mode_simple"), true);
0278: multiFrameRadio = new JRadioButton(Language.getInstance()
0279: .getText("Mode_multi-frames"));
0280: htmlRadio.addActionListener(this );
0281: docbookRadio.addActionListener(this );
0282: ButtonGroup frameGroup = new ButtonGroup();
0283: frameGroup.add(withoutFrameRadio);
0284: frameGroup.add(multiFrameRadio);
0285: ButtonGroup langageGroup = new ButtonGroup();
0286: langageGroup.add(htmlRadio);
0287: langageGroup.add(docbookRadio);
0288:
0289: inclusPhrase = new JLabel(
0290: Language
0291: .getInstance()
0292: .getText(
0293: "Extensions_des_fichiers_à_inclure_[*.txt,_*.java,_...]_:"));
0294: inclusFormat = new JTextField(30);
0295: jpgBox = new JCheckBox(".jpeg");
0296: pngBox = new JCheckBox(".png");
0297: gifBox = new JCheckBox(".gif");
0298:
0299: validationButton = new JButton(Language.getInstance().getText(
0300: "Générer"));
0301: validationButton.addActionListener(this );
0302:
0303: cancelButton = new JButton(Language.getInstance().getText(
0304: "Annuler"));
0305: cancelButton.addActionListener(this );
0306:
0307: formulaireButton = new JButton(Language.getInstance().getText(
0308: "Formulaire"));
0309: formulaireButton.addActionListener(this );
0310:
0311: formBox = new JRadioButton(Language.getInstance().getText(
0312: "A_partir_d'un_"));
0313: formBox.addActionListener(this );
0314: formBox.setSelected(true);
0315:
0316: gardeBox = new JRadioButton(Language.getInstance().getText(
0317: "A_partir_de_fichiers_html_:_"));
0318: gardeBox.addActionListener(this );
0319:
0320: miseFormeGroup = new ButtonGroup();
0321: miseFormeGroup.add(formBox);
0322: miseFormeGroup.add(gardeBox);
0323:
0324: gardeLabel = new JLabel();
0325: gardeLabel.setText(Language.getInstance().getText(
0326: "Page_de_garde_:"));
0327: gardeTextField = new JTextField(30);
0328: gardeButton = new JButton(Language.getInstance().getText(
0329: "Choisir..."));
0330: gardeButton.addActionListener(this );
0331:
0332: enTeteLabel = new JLabel();
0333: enTeteLabel
0334: .setText(Language.getInstance().getText("En-tête_:"));
0335: enTeteTextField = new JTextField(30);
0336: enTeteButton = new JButton(Language.getInstance().getText(
0337: "Choisir..."));
0338: enTeteButton.addActionListener(this );
0339:
0340: piedLabel = new JLabel();
0341: piedLabel.setText(Language.getInstance().getText(
0342: "Pied_de_page_:"));
0343: piedTextField = new JTextField(30);
0344: piedButton = new JButton(Language.getInstance().getText(
0345: "Choisir..."));
0346: piedButton.addActionListener(this );
0347:
0348: JLabel encodingLabel = new JLabel(Language.getInstance()
0349: .getText("Encodage_:"));
0350:
0351: JPanel encodingPanel = new JPanel(new FlowLayout(
0352: FlowLayout.LEFT));
0353: encodingPanel.add(encodingLabel);
0354: encodingPanel.add(comboEncoding);
0355: encodingPanel.add(Box.createHorizontalGlue());
0356:
0357: JPanel htmlModePanel = new JPanel();
0358: htmlModePanel.setLayout(new BoxLayout(htmlModePanel,
0359: BoxLayout.Y_AXIS));
0360: htmlModePanel.add(withoutFrameRadio);
0361: htmlModePanel.add(multiFrameRadio);
0362: JPanel outputFormatFramePanel = new JPanel(new FlowLayout(
0363: FlowLayout.LEFT));
0364: outputFormatFramePanel.add(Box.createHorizontalStrut(15));
0365: outputFormatFramePanel.add(htmlModePanel);
0366:
0367: JPanel htmlPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
0368: htmlPanel.add(htmlRadio);
0369:
0370: JPanel docbookPanel = new JPanel(
0371: new FlowLayout(FlowLayout.LEFT));
0372: docbookPanel.add(docbookRadio);
0373:
0374: JPanel outputFormatPanel = new JPanel();
0375: outputFormatPanel.setLayout(new BoxLayout(outputFormatPanel,
0376: BoxLayout.Y_AXIS));
0377: outputFormatPanel.add(htmlPanel);
0378: outputFormatPanel.add(outputFormatFramePanel);
0379: outputFormatPanel.add(docbookPanel);
0380:
0381: JPanel outputPanel = new JPanel();
0382: outputPanel.setLayout(new BoxLayout(outputPanel,
0383: BoxLayout.Y_AXIS));
0384: TitledBorder outputTitle = BorderFactory
0385: .createTitledBorder(Language.getInstance().getText(
0386: "Sortie"));
0387: outputPanel.setBorder(outputTitle);
0388: outputPanel.add(outputFormatPanel);
0389: outputPanel.add(Box.createVerticalStrut(10));
0390: outputPanel.add(encodingPanel);
0391:
0392: JPanel panelChoisir = new JPanel(
0393: new FlowLayout(FlowLayout.LEFT));
0394: panelChoisir.add(htmlButton);
0395: JPanel panelHtmlTF = new JPanel(new FlowLayout(FlowLayout.LEFT));
0396: panelHtmlTF.add(reportTextField);
0397: JPanel panelHtmlLabel = new JPanel(new FlowLayout(
0398: FlowLayout.LEFT));
0399: panelHtmlLabel.add(htmlLabel);
0400:
0401: JPanel panelCenter = new JPanel();
0402: TitledBorder sauvTitle;
0403: sauvTitle = BorderFactory.createTitledBorder(Language
0404: .getInstance().getText("Sauvegarde"));
0405: panelCenter.setBorder(sauvTitle);
0406: panelCenter.setLayout(new BoxLayout(panelCenter,
0407: BoxLayout.Y_AXIS));
0408: panelCenter.add(panelHtmlLabel);
0409: panelCenter.add(panelHtmlTF);
0410: panelCenter.add(panelChoisir);
0411:
0412: JPanel buttons = new JPanel();
0413: buttons.add(validationButton);
0414: buttons.add(cancelButton);
0415:
0416: progress = new JProgressBar();
0417: JPanel progression = new JPanel(new FlowLayout(
0418: FlowLayout.CENTER));
0419: progression.add(progress);
0420:
0421: JPanel onglet1 = new JPanel();
0422: onglet1.setLayout(new BoxLayout(onglet1, BoxLayout.Y_AXIS));
0423: onglet1.add(outputPanel);
0424: onglet1.add(panelCenter);
0425: onglet1.add(Box.createRigidArea(new Dimension(1, 125)));
0426:
0427: JPanel commonPanel = new JPanel();
0428: commonPanel.setLayout(new BoxLayout(commonPanel,
0429: BoxLayout.Y_AXIS));
0430: commonPanel.add(buttons);
0431: commonPanel.add(Box.createRigidArea(new Dimension(1, 5)));
0432: commonPanel.add(progression);
0433:
0434: JPanel panelForm = new JPanel(new FlowLayout(FlowLayout.LEFT));
0435: panelForm.add(formBox);
0436: panelForm.add(formulaireButton);
0437:
0438: JPanel ligneFic = new JPanel(new FlowLayout(FlowLayout.LEFT));
0439: ligneFic.add(gardeBox);
0440:
0441: JPanel panelGardeLabel = new JPanel(new FlowLayout(
0442: FlowLayout.LEFT));
0443: panelGardeLabel.add(gardeLabel);
0444: JPanel panelGardeTF = new JPanel(
0445: new FlowLayout(FlowLayout.LEFT));
0446: panelGardeTF.add(gardeTextField);
0447: panelGardeLabel.add(gardeLabel);
0448: JPanel panelTeteLabel = new JPanel(new FlowLayout(
0449: FlowLayout.LEFT));
0450: panelTeteLabel.add(enTeteLabel);
0451: JPanel panelTeteTF = new JPanel(new FlowLayout(FlowLayout.LEFT));
0452: panelTeteTF.add(enTeteTextField);
0453: JPanel panelTeteButton = new JPanel(new FlowLayout(
0454: FlowLayout.LEFT));
0455: panelTeteButton.add(enTeteButton);
0456: JPanel panelPiedLabel = new JPanel(new FlowLayout(
0457: FlowLayout.LEFT));
0458: panelPiedLabel.add(piedLabel);
0459: JPanel panelPiedTF = new JPanel(new FlowLayout(FlowLayout.LEFT));
0460: panelPiedTF.add(piedTextField);
0461: JPanel panelPiedButton = new JPanel(new FlowLayout(
0462: FlowLayout.LEFT));
0463: panelPiedButton.add(piedButton);
0464: JPanel panelGardeChoisir = new JPanel(new FlowLayout(
0465: FlowLayout.LEFT));
0466: panelGardeChoisir.add(gardeButton);
0467: JPanel fichier = new JPanel();
0468: fichier.setLayout(new BoxLayout(fichier, BoxLayout.Y_AXIS));
0469: fichier.add(panelGardeLabel);
0470: fichier.add(panelGardeTF);
0471: fichier.add(panelGardeChoisir);
0472: fichier.add(Box.createRigidArea(new Dimension(1, 10)));
0473: fichier.add(panelTeteLabel);
0474: fichier.add(panelTeteTF);
0475: fichier.add(panelTeteButton);
0476: fichier.add(Box.createRigidArea(new Dimension(1, 10)));
0477: fichier.add(panelPiedLabel);
0478: fichier.add(panelPiedTF);
0479: fichier.add(panelPiedButton);
0480: gardeLabel.setEnabled(false);
0481: enTeteLabel.setEnabled(false);
0482: piedLabel.setEnabled(false);
0483: gardeTextField.setEnabled(false);
0484: enTeteTextField.setEnabled(false);
0485: enTeteButton.setEnabled(false);
0486: piedTextField.setEnabled(false);
0487: piedButton.setEnabled(false);
0488: gardeButton.setEnabled(false);
0489:
0490: JPanel onglet2 = new JPanel();
0491: onglet2.setLayout(new BoxLayout(onglet2, BoxLayout.Y_AXIS));
0492: onglet2.add(panelForm);
0493: onglet2.add(Box.createRigidArea(new Dimension(1, 10)));
0494: onglet2.add(ligneFic);
0495: onglet2.add(fichier);
0496:
0497: testSelectionButton = new JButton(Language.getInstance()
0498: .getText("Sélection_des_tests..."));
0499: testSelectionButton.addActionListener(this );
0500:
0501: JPanel selectTestCampPanel = new JPanel(new FlowLayout(
0502: FlowLayout.LEFT));
0503:
0504: campSelectionButton = new JButton(Language.getInstance()
0505: .getText("Sélection_des_campagnes..."));
0506: campSelectionButton.addActionListener(this );
0507:
0508: if (sourceType != CAMPAIGN) {
0509: selectTestCampPanel.add(testSelectionButton);
0510: } else {
0511: selectTestCampPanel.add(campSelectionButton);
0512: }
0513:
0514: chapterSelectionButton = new JButton(Language.getInstance()
0515: .getText("Sélection_des_chapitres..."));
0516: chapterSelectionButton.addActionListener(this );
0517: initChosenChaptersList();
0518:
0519: JPanel selectChapterPanel = new JPanel(new FlowLayout(
0520: FlowLayout.LEFT));
0521: selectChapterPanel.add(chapterSelectionButton);
0522:
0523: JPanel selectPanel = new JPanel();
0524: selectPanel.setLayout(new BoxLayout(selectPanel,
0525: BoxLayout.Y_AXIS));
0526: selectPanel.setBorder(BorderFactory.createTitledBorder(Language
0527: .getInstance().getText("Filtrage")));
0528: selectPanel.add(selectTestCampPanel);
0529: selectPanel.add(selectChapterPanel);
0530:
0531: JPanel inclusLabelPanel = new JPanel(new FlowLayout(
0532: FlowLayout.LEFT));
0533: inclusLabelPanel.add(inclusPhrase);
0534: JPanel inclusTFPanel = new JPanel(new FlowLayout(
0535: FlowLayout.LEFT));
0536: inclusTFPanel.add(inclusFormat);
0537: JPanel inclusionPanel = new JPanel();
0538: inclusionPanel.setLayout(new BoxLayout(inclusionPanel,
0539: BoxLayout.Y_AXIS));
0540: inclusionPanel.setBorder(BorderFactory
0541: .createTitledBorder(Language.getInstance().getText(
0542: "Fichiers_textes")));
0543: inclusionPanel.add(inclusLabelPanel);
0544: inclusionPanel.add(inclusTFPanel);
0545:
0546: JPanel imgJpgPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
0547: imgJpgPanel.add(jpgBox);
0548: JPanel imgGifPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
0549: imgGifPanel.add(gifBox);
0550: JPanel imgPngPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
0551: imgPngPanel.add(pngBox);
0552:
0553: JPanel imgPanel = new JPanel();
0554: imgPanel.setLayout(new BoxLayout(imgPanel, BoxLayout.Y_AXIS));
0555: imgPanel.setBorder(BorderFactory.createTitledBorder(Language
0556: .getInstance().getText("Fichiers_images")));
0557: imgPanel.add(imgJpgPanel);
0558: imgPanel.add(imgGifPanel);
0559: imgPanel.add(imgPngPanel);
0560:
0561: JPanel inclusTotalPanel = new JPanel();
0562: inclusTotalPanel.setLayout(new BoxLayout(inclusTotalPanel,
0563: BoxLayout.Y_AXIS));
0564: inclusTotalPanel.setBorder(BorderFactory
0565: .createTitledBorder(Language.getInstance().getText(
0566: "Inclusion_des_fichiers")));
0567: inclusTotalPanel.add(inclusionPanel);
0568: inclusTotalPanel.add(imgPanel);
0569:
0570: JPanel onglet3 = new JPanel();
0571: onglet3.setLayout(new BoxLayout(onglet3, BoxLayout.Y_AXIS));
0572: onglet3.add(selectPanel);
0573: onglet3.add(Box.createRigidArea(new Dimension(1, 10)));
0574: onglet3.add(inclusTotalPanel);
0575:
0576: onglets = new JTabbedPane();
0577: onglets.addTab(Language.getInstance().getText("Principal"),
0578: onglet1);
0579: onglets.addTab(Language.getInstance().getText("Mise_en_Forme"),
0580: onglet2);
0581: onglets.addTab(Language.getInstance().getText("Options"),
0582: onglet3);
0583:
0584: /**** Ajout des tabs des plugins ****/
0585: int size2 = panelsPluginsForExport.size();
0586: for (int i = 0; i < size2; i++) {
0587: JPanel pPanel = (JPanel) panelsPluginsForExport
0588: .elementAt(i);
0589: String name = pPanel.getName();
0590: onglets.addTab(name, pPanel);
0591: }
0592:
0593: Container contentPaneFrame = this .getContentPane();
0594: contentPaneFrame.add(onglets, BorderLayout.CENTER);
0595: contentPaneFrame.add(commonPanel, BorderLayout.SOUTH);
0596: setPreferredSize(new Dimension(450, 550));
0597: getRootPane().setDefaultButton(this .validationButton);
0598: this .setTitle(Language.getInstance().getText(
0599: "Génération_de_document"));
0600: //this.setLocation(400, 100);
0601: centerScreen();
0602: }
0603:
0604: void centerScreen() {
0605: Dimension dim = getToolkit().getScreenSize();
0606: this .pack();
0607: Rectangle abounds = getBounds();
0608: setLocation((dim.width - abounds.width) / 2,
0609: (dim.height - abounds.height) / 2);
0610: this .setVisible(true);
0611: requestFocus();
0612: }
0613:
0614: /***************************************************************************
0615: * Listener
0616: **************************************************************************/
0617:
0618: public void actionPerformed(ActionEvent evt) {
0619: if (evt.getSource().equals(htmlRadio)) {
0620: htmlRadioPerformed();
0621: } else if (evt.getSource().equals(docbookRadio)) {
0622: docbookRadioPerformed();
0623: } else if (evt.getSource().equals(htmlButton)) {
0624: try {
0625: htmlButtonPerformed();
0626: } catch (Exception ex) {
0627: Tools.ihmExceptionView(ex);
0628: }
0629: } else if (evt.getSource().equals(validationButton)) {
0630: validationButtonPerformed();
0631: } else if (evt.getSource().equals(cancelButton)) {
0632: try {
0633: cancelButtonPerformed();
0634: } catch (Exception ex) {
0635: Tools.ihmExceptionView(ex);
0636: }
0637: } else if (evt.getSource().equals(formulaireButton)) {
0638: try {
0639: formulaireButtonPerformed();
0640: } catch (Exception ex) {
0641: Tools.ihmExceptionView(ex);
0642: }
0643: } else if (evt.getSource().equals(formBox)) {
0644: try {
0645: formBoxPerformed();
0646: } catch (Exception ex) {
0647: Tools.ihmExceptionView(ex);
0648: }
0649: } else if (evt.getSource().equals(gardeBox)) {
0650: try {
0651: gardeBoxPerformed();
0652: } catch (Exception ex) {
0653: Tools.ihmExceptionView(ex);
0654: }
0655: } else if (evt.getSource().equals(gardeButton)) {
0656: try {
0657: gardeButtonPerformed();
0658: } catch (Exception ex) {
0659: Tools.ihmExceptionView(ex);
0660: }
0661: } else if (evt.getSource().equals(enTeteButton)) {
0662: try {
0663: enTeteButtonPerformed();
0664: } catch (Exception ex) {
0665: Tools.ihmExceptionView(ex);
0666: }
0667: } else if (evt.getSource().equals(piedButton)) {
0668: try {
0669: piedButtonPerformed();
0670: } catch (Exception ex) {
0671: Tools.ihmExceptionView(ex);
0672: }
0673: } else if (evt.getSource().equals(testSelectionButton)) {
0674: try {
0675: testSelectionButtonPerformed();
0676: } catch (Exception ex) {
0677: Tools.ihmExceptionView(ex);
0678: }
0679: } else if (evt.getSource().equals(campSelectionButton)) {
0680: try {
0681: campSelectionButtonPerformed();
0682: } catch (Exception ex) {
0683: Tools.ihmExceptionView(ex);
0684: }
0685: } else if (evt.getSource().equals(chapterSelectionButton)) {
0686: chapterSelectionButtonPerformed();
0687: }
0688:
0689: }
0690:
0691: void htmlRadioPerformed() {
0692: if (!withoutFrameRadio.isEnabled()) {
0693: withoutFrameRadio.setEnabled(true);
0694: multiFrameRadio.setEnabled(true);
0695: onglets.setEnabledAt(1, true);
0696: }
0697: }
0698:
0699: void docbookRadioPerformed() {
0700: withoutFrameRadio.setEnabled(false);
0701: multiFrameRadio.setEnabled(false);
0702: onglets.setEnabledAt(1, false);
0703: }
0704:
0705: void htmlButtonPerformed() throws Exception {
0706: JFileChooser fileChooser = new JFileChooser();
0707: if (htmlRadio.isSelected()) {
0708: fileChooser.addChoosableFileFilter(new ScriptFileFilter(
0709: Language.getInstance().getText(
0710: "Fichier_HTML_[*.html]"), ".html"));
0711: fileChooser.setSelectedFile(new File("index.html"));
0712: int returnVal = fileChooser.showDialog(GenDocDialog.this ,
0713: Language.getInstance().getText("Sélectionner"));
0714: if (returnVal == JFileChooser.APPROVE_OPTION) {
0715: reportFile = fileChooser.getSelectedFile()
0716: .getAbsolutePath();
0717: if (reportFile.indexOf(".") != -1) {
0718: if (!reportFile.substring(
0719: reportFile.lastIndexOf("."))
0720: .equals(".html")) {
0721: reportFile += ".html";
0722: }
0723: } else {
0724: reportFile += ".html";
0725: }
0726: }
0727: } else {
0728: fileChooser.addChoosableFileFilter(new ScriptFileFilter(
0729: Language.getInstance().getText(
0730: "Fichier_XML_[*.xml]"), ".xml"));
0731: fileChooser.setSelectedFile(new File("docbook.xml"));
0732: int returnVal = fileChooser.showDialog(GenDocDialog.this ,
0733: Language.getInstance().getText("Sélectionner"));
0734: if (returnVal == JFileChooser.APPROVE_OPTION) {
0735: reportFile = fileChooser.getSelectedFile()
0736: .getAbsolutePath();
0737: if (reportFile.indexOf(".") != -1) {
0738: if (!reportFile.substring(
0739: reportFile.lastIndexOf(".")).equals(".xml")
0740: && !reportFile.substring(
0741: reportFile.lastIndexOf("."))
0742: .equals(".docbook")) {
0743: reportFile += ".xml";
0744: }
0745: } else {
0746: reportFile += ".xml";
0747: }
0748: }
0749: }
0750: reportTextField.setText(reportFile);
0751: }
0752:
0753: void validationButtonPerformed() {
0754: Thread t = new Thread() {
0755: public void run() {
0756: // Instanciation et lancement du traitement
0757: try {
0758: genereDoc();
0759: } catch (Exception ex) {
0760: Tools.ihmExceptionView(ex);
0761: }
0762: }
0763: };
0764: t.start();
0765: }
0766:
0767: void cancelButtonPerformed() throws Exception {
0768: annule = true;
0769: GenDocDialog.this .dispose();
0770: }
0771:
0772: void formulaireButtonPerformed() throws Exception {
0773: new GardeDialog(GenDocDialog.this );
0774: }
0775:
0776: void formBoxPerformed() throws Exception {
0777: gardeLabel.setEnabled(false);
0778: enTeteLabel.setEnabled(false);
0779: piedLabel.setEnabled(false);
0780: gardeTextField.setEnabled(false);
0781: enTeteTextField.setEnabled(false);
0782: enTeteButton.setEnabled(false);
0783: piedTextField.setEnabled(false);
0784: piedButton.setEnabled(false);
0785: gardeButton.setEnabled(false);
0786: formulaireButton.setEnabled(true);
0787: }
0788:
0789: void gardeBoxPerformed() throws Exception {
0790: gardeLabel.setEnabled(true);
0791: enTeteLabel.setEnabled(true);
0792: piedLabel.setEnabled(true);
0793: gardeTextField.setEnabled(true);
0794: enTeteTextField.setEnabled(true);
0795: enTeteButton.setEnabled(true);
0796: piedTextField.setEnabled(true);
0797: piedButton.setEnabled(true);
0798: gardeButton.setEnabled(true);
0799: formulaireButton.setEnabled(false);
0800: }
0801:
0802: String selectHTMLPerformed() throws Exception {
0803: String fileHTML = null;
0804: JFileChooser fileChooser = new JFileChooser();
0805: fileChooser
0806: .addChoosableFileFilter(new ScriptFileFilter(
0807: Language.getInstance().getText(
0808: "Fichier_HTML_[*.html]"), ".html"));
0809: int returnVal = fileChooser.showDialog(GenDocDialog.this ,
0810: Language.getInstance().getText("Sélectionner"));
0811: if (returnVal == JFileChooser.APPROVE_OPTION) {
0812: fileHTML = fileChooser.getSelectedFile().getAbsolutePath();
0813: if (fileHTML.indexOf(".") != -1) {
0814: if (!fileHTML.substring(fileHTML.lastIndexOf("."))
0815: .equals(".html")) {
0816: fileHTML += ".html";
0817: }
0818: } else {
0819: fileHTML += ".html";
0820: }
0821: }
0822: return fileHTML;
0823: }
0824:
0825: void gardeButtonPerformed() throws Exception {
0826: String fileHTML = selectHTMLPerformed();
0827: if (fileHTML != null) {
0828: gardeFile = fileHTML;
0829: gardeTextField.setText(gardeFile);
0830: }
0831: }
0832:
0833: void enTeteButtonPerformed() throws Exception {
0834: String fileHTML = selectHTMLPerformed();
0835: if (fileHTML != null) {
0836: enTeteFile = fileHTML;
0837: enTeteTextField.setText(enTeteFile);
0838: }
0839: }
0840:
0841: void piedButtonPerformed() throws Exception {
0842: String fileHTML = selectHTMLPerformed();
0843: if (fileHTML != null) {
0844: piedFile = fileHTML;
0845: piedTextField.setText(piedFile);
0846: }
0847: }
0848:
0849: void testSelectionButtonPerformed() throws Exception {
0850: TestChooser testChooser = new TestChooser(SalomeTMFPanels
0851: .getTestDynamicTree().getRoot(), GenDocDialog.this ,
0852: initSelection, getChosenRoot(), TEST);
0853: if (!testChooser.isCancelled()) {
0854: setInitSelection(true);
0855: setFamilyList(testChooser.getTemporaryFamilyList());
0856: setSuiteList(testChooser.getTemporaryTestListList());
0857: setTestList(testChooser.getTemporaryTestList());
0858: setChosenRoot((DefaultMutableTreeNode) testChooser
0859: .getChosenTreeModel().getRoot());
0860: }
0861: }
0862:
0863: void campSelectionButtonPerformed() throws Exception {
0864: TestChooser testChooser = new TestChooser(SalomeTMFPanels
0865: .getCampaignDynamicTree().getRoot(), GenDocDialog.this ,
0866: initSelection, getChosenRoot(), CAMPAIGN);
0867: if (!testChooser.isCancelled()) {
0868: setInitSelection(true);
0869: setCampList(testChooser.getTemporaryCampList());
0870: setExecList(testChooser.getTemporaryExecList());
0871: setChosenRoot((DefaultMutableTreeNode) testChooser
0872: .getChosenTreeModel().getRoot());
0873: }
0874: }
0875:
0876: void chapterSelectionButtonPerformed() {
0877: initChosenChaptersList();
0878: new ChapterChooser(GenDocDialog.this , initChapterSelection,
0879: chosenChaptersList);
0880: }
0881:
0882: public void initChosenChaptersList() {
0883: ArrayList<String> extList = new ArrayList<String>();
0884: Vector<Extension> listExtXMLPlugin = pIhm
0885: .getXMLPrintersExtension();
0886: int size = listExtXMLPlugin.size();
0887: for (int i = 0; i < size; i++) {
0888: Extension pXMLExt = (Extension) listExtXMLPlugin
0889: .elementAt(i);
0890: JPFManager pJPFManager = pIhm.getPluginManager();
0891: try {
0892: XMLPrinterPlugin pXMLPrinterPlugin = (XMLPrinterPlugin) pJPFManager
0893: .activateExtension(pXMLExt);
0894: String title = pXMLPrinterPlugin
0895: .getChapterTitleInReport();
0896: if (title != null && !title.equals("")) {
0897: extList.add(title);
0898: }
0899: } catch (Exception e) {
0900:
0901: }
0902: }
0903: String projet = Language.getInstance().getText("Projet");
0904: String environnements = Language.getInstance().getText(
0905: "Environnements");
0906: String dossierTests = Language.getInstance().getText(
0907: "Dossier_de_tests");
0908: String campagnes = Language.getInstance().getText(
0909: "Campagnes_du_projet");
0910: String executions = Language.getInstance().getText(
0911: "Rapport_d_exécution");
0912: chosenChaptersList = new ArrayList<String>();
0913: chosenChaptersList.add(projet);
0914: chosenChaptersList.add(environnements);
0915: chosenChaptersList.addAll(extList);
0916: chosenChaptersList.add(dossierTests);
0917: if (sourceType == CAMPAIGN) {
0918: chosenChaptersList.add(campagnes);
0919: chosenChaptersList.add(executions);
0920: }
0921: }
0922:
0923: /***************************************************************************
0924: * Méthodes
0925: **************************************************************************/
0926:
0927: /**
0928: * Génération de la documentation Appel des méthodes de XmlGenerator
0929: */
0930: public void genereDoc() throws Exception {
0931: boolean ok = true;
0932: if (reportTextField.getText().equals("")) {
0933: JOptionPane
0934: .showMessageDialog(
0935: GenDocDialog.this ,
0936: Language
0937: .getInstance()
0938: .getText(
0939: "Vous_devez_entrez_un_nom_de_fichier_pour_le_document_généré"),
0940: Language.getInstance().getText("Erreur_!"),
0941: JOptionPane.ERROR_MESSAGE);
0942: ok = false;
0943: return;
0944: }
0945:
0946: String[] ficType = null;
0947: if (!inclusFormat.getText().equals("")) {
0948: ficType = inclusFormat.getText().split(",");
0949: }
0950:
0951: /** ************ TRANSFORMATION XML ******************* */
0952:
0953: progress.setIndeterminate(true);
0954:
0955: String saveFileName = reportTextField.getText().trim();
0956: String dirHtml = saveFileName.substring(0, saveFileName
0957: .lastIndexOf(File.separator));
0958: String xmlDirName = saveFileName.substring(0, saveFileName
0959: .lastIndexOf(File.separator));
0960: URL dtdStat = null;
0961: URL dtdDyna = null;
0962: URL css = null;
0963: URL cssPrint = null;
0964: URL translate = null;
0965: OutFormat outputFormat = OutFormat.HTML;
0966: if (docbookRadio.isSelected()) {
0967: outputFormat = OutFormat.DOCBOOK;
0968: }
0969: Contexte pContexte = new Contexte(dirHtml, ficType,
0970: (String) comboEncoding.getSelectedItem(), outputFormat);
0971: XmlGenerator pXmlGenerator;
0972: pXmlGenerator = new XmlGenerator(pIhm, pContexte);
0973:
0974: try {
0975: css = new URL(url_txt + "/plugins/docXML/xsl/salome.css");
0976: cssPrint = new URL(url_txt
0977: + "/plugins/docXML/xsl/salome_print.css");
0978: dtdStat = new URL(url_txt
0979: + "/plugins/docXML/xsl/SalomeStatique.dtd");
0980: dtdDyna = new URL(url_txt
0981: + "/plugins/docXML/xsl/SalomeDynamique.dtd");
0982: translate = new URL(url_txt
0983: + "/plugins/docXML/xsl/translate.xml");
0984: urlTranslate = translate.toString();
0985: try {
0986: if (sourceType != CAMPAIGN) {
0987: Tools.writeFile(dtdStat.openStream(), tmpDir
0988: + File.separator + "SalomeStatique.dtd");
0989: Tools.writeFile(dtdStat.openStream(), xmlDirName
0990: + File.separator + "SalomeStatique.dtd");
0991: } else {
0992: Tools.writeFile(dtdDyna.openStream(), tmpDir
0993: + File.separator + "SalomeDynamique.dtd");
0994: Tools.writeFile(dtdDyna.openStream(), xmlDirName
0995: + File.separator + "SalomeDynamique.dtd");
0996: }
0997: Tools.writeFile(css.openStream(), xmlDirName
0998: + File.separator + "salome.css");
0999: Tools.writeFile(cssPrint.openStream(), xmlDirName
1000: + File.separator + "salome_print.css");
1001:
1002: Tools.writeFile(translate.openStream(), tmpDir
1003: + File.separator + "translate.xml");
1004: Tools.writeFile(translate.openStream(), xmlDirName
1005: + File.separator + "translate.xml");
1006: //image mail
1007: URL emailURL = GenDocDialog.class
1008: .getResource("/salomeTMF_plug/docXML/resources/img/pied_mail.gif");
1009: Tools.writeFile(emailURL.openStream(), xmlDirName
1010: + File.separator + "pied_mail.gif");
1011:
1012: if (htmlRadio.isSelected()
1013: && multiFrameRadio.isSelected()) {
1014: URL icon = GenDocDialog.class
1015: .getResource("/salomeTMF_plug/docXML/resources/img/ftv2mnode.png");
1016: Tools.writeFile(icon.openStream(), xmlDirName
1017: + File.separator + "ftv2mnode.png");
1018: icon = GenDocDialog.class
1019: .getResource("/salomeTMF_plug/docXML/resources/img/ftv2pnode.png");
1020: Tools.writeFile(icon.openStream(), xmlDirName
1021: + File.separator + "ftv2pnode.png");
1022: icon = GenDocDialog.class
1023: .getResource("/salomeTMF_plug/docXML/resources/img/ftv2node.png");
1024: Tools.writeFile(icon.openStream(), xmlDirName
1025: + File.separator + "ftv2node.png");
1026: }
1027:
1028: //Logo
1029: if (logoFilePath != null) {
1030: String shortName = logoFilePath
1031: .toString()
1032: .substring(
1033: logoFilePath
1034: .toString()
1035: .lastIndexOf(File.separator));
1036: Tools.writeFile(new FileInputStream(new File(
1037: logoFilePath)), xmlDirName + File.separator
1038: + shortName);
1039: }
1040: } catch (Exception exception) {
1041: // Cas DEBUG
1042: if (sourceType != CAMPAIGN) {
1043: Tools
1044: .writeFile(
1045: GenDocDialog.class
1046: .getResourceAsStream("/salome/plugins/docXML/xsl/SalomeStatique.dtd"),
1047: tmpDir + File.separator
1048: + "SalomeStatique.dtd");
1049: Tools
1050: .writeFile(
1051: GenDocDialog.class
1052: .getResourceAsStream("/salome/plugins/docXML/xsl/SalomeStatique.dtd"),
1053: xmlDirName + File.separator
1054: + "SalomeStatique.dtd");
1055: } else {
1056: Tools
1057: .writeFile(
1058: GenDocDialog.class
1059: .getResourceAsStream("/salome/plugins/docXML/xsl/SalomeDynamique.dtd"),
1060: tmpDir + File.separator
1061: + "SalomeDynamique.dtd");
1062: Tools
1063: .writeFile(
1064: GenDocDialog.class
1065: .getResourceAsStream("/salome/plugins/docXML/xsl/SalomeDynamique.dtd"),
1066: xmlDirName + File.separator
1067: + "SalomeDynamique.dtd");
1068: }
1069: Tools
1070: .writeFile(
1071: GenDocDialog.class
1072: .getResourceAsStream("/salome/plugins/docXML/xsl/salome.css"),
1073: xmlDirName + File.separator
1074: + "salome.css");
1075: Tools
1076: .writeFile(
1077: GenDocDialog.class
1078: .getResourceAsStream("/salome/plugins/docXML/xsl/salome.css"),
1079: xmlDirName + File.separator
1080: + "salome_print.css");
1081: Tools
1082: .writeFile(
1083: GenDocDialog.class
1084: .getResourceAsStream("/salome/plugins/docXML/xsl/translate.xml"),
1085: tmpDir + File.separator
1086: + "translate.xml");
1087: Tools
1088: .writeFile(
1089: GenDocDialog.class
1090: .getResourceAsStream("/salome/plugins/docXML/xsl/translate.xml"),
1091: xmlDirName + File.separator
1092: + "translate.xml");
1093: }
1094:
1095: // Génération du fichier xml pour le dossier de tests
1096: if (!annule) {
1097: if (sourceType != CAMPAIGN) {
1098: Document doc = pXmlGenerator.toDocument(familyList,
1099: suiteList, testList);
1100: pXmlGenerator.documentToXML(doc, tmpDir
1101: + File.separator + "salome.xml");
1102: pXmlGenerator.documentToXML(doc, xmlDirName
1103: + File.separator + "salome.xml");
1104: } else {
1105: Document doc2 = pXmlGenerator.toDocumentDyna(
1106: campList, execList);
1107: pXmlGenerator.documentToXML(doc2, tmpDir
1108: + File.separator + "salomeDyna.xml");
1109: pXmlGenerator.documentToXML(doc2, xmlDirName
1110: + File.separator + "salomeDyna.xml");
1111: }
1112: }
1113:
1114: /* ************* TRANSFORMATION XSLT ******************* */
1115:
1116: // tableau pour la sélection des options
1117: boolean multiFrame = multiFrameRadio.isSelected();
1118: boolean htmlFormat = htmlRadio.isSelected();
1119: Vector<XMLPrinterPlugin> listXMLPlugins = pXmlGenerator
1120: .getListXMLPlugin();
1121: if (sourceType == CAMPAIGN && !annule) {
1122: genereDocCamp(listXMLPlugins, multiFrame, htmlFormat,
1123: dirHtml, xmlDirName, saveFileName);
1124: } else {
1125: genereDocTest(listXMLPlugins, multiFrame, htmlFormat,
1126: xmlDirName, saveFileName);
1127: }
1128:
1129: if (ok && !annule) {
1130: progress.setVisible(false);
1131: JOptionPane
1132: .showMessageDialog(
1133: GenDocDialog.this ,
1134: Language
1135: .getInstance()
1136: .getText(
1137: "La_génération_de_document_s'est_terminée_avec_succès."),
1138: Language.getInstance().getText(
1139: "Information..."),
1140: JOptionPane.INFORMATION_MESSAGE);
1141: GenDocDialog.this .dispose();
1142: }
1143:
1144: } catch (Exception e) {
1145: e.printStackTrace();
1146: Tools.ihmExceptionView(e);
1147: progress.setVisible(false);
1148: ok = false;
1149: GenDocDialog.this .dispose();
1150: return;
1151: }
1152: }
1153:
1154: /**
1155: * Génère le document des campagnes i.e. contenant les résultats d'exécution
1156: * @param pContexte
1157: * @param option
1158: * 0 : mode multi-frames, 1 : inclure les exécutions dans le
1159: * dossier des campagnes, 2 : inclure les exécutions dans le
1160: * dossier des campagnes
1161: * @param dirHtml
1162: * @param xmlDirName
1163: * @param saveFileName
1164: */
1165: void genereDocCamp(Vector<XMLPrinterPlugin> listXMLPlugins,
1166: boolean multiFrame, boolean htmlFormat, String dirHtml,
1167: String xmlDirName, String saveFileName) throws Exception {
1168: XSLGenerator pXSLGenerator = new XSLGenerator(listXMLPlugins,
1169: true, tmpDir + File.separator + "translate.xml");
1170:
1171: // Création du fichier xml pour les campagnes
1172: if (!annule) {
1173: /** ************ TRANSFORMATION XSLT ******************* */
1174: if (htmlFormat) {
1175: if (multiFrame) {
1176: // Mode = multi-frames => création de 3 fichiers html
1177: String tests = saveFileName.substring(0,
1178: saveFileName.lastIndexOf("."))
1179: + "_princ.html";
1180: pXSLGenerator
1181: .transform(
1182: multiFrame,
1183: htmlFormat,
1184: tmpDir + File.separator
1185: + "salomeDyna.xml",
1186: url_txt,
1187: "/plugins/docXML/xsl/frameDynaXmlToHtml.xsl",
1188: saveFileName, jpgBox.isSelected(),
1189: gifBox.isSelected(), pngBox
1190: .isSelected(), xmlDirName,
1191: chosenChaptersList);
1192: miseEnForme(tests, pXSLGenerator, false);
1193: } else {
1194: // création du fichier html pour les campages en mode simple
1195: // frame
1196: pXSLGenerator.transform(multiFrame, htmlFormat,
1197: tmpDir + File.separator + "salomeDyna.xml",
1198: url_txt,
1199: "/plugins/docXML/xsl/dynaXmlToHtml.xsl",
1200: saveFileName, jpgBox.isSelected(), gifBox
1201: .isSelected(), pngBox.isSelected(),
1202: xmlDirName, chosenChaptersList);
1203: miseEnForme(saveFileName, pXSLGenerator, false);
1204: }
1205: } else {
1206: //création d'un fichier au format docbook
1207: pXSLGenerator.transform(multiFrame, htmlFormat, tmpDir
1208: + File.separator + "salomeDyna.xml", url_txt,
1209: "/plugins/docXML/xsl/dynaXmlToDocBook.xsl",
1210: saveFileName, jpgBox.isSelected(), gifBox
1211: .isSelected(), pngBox.isSelected(),
1212: xmlDirName, chosenChaptersList);
1213: //miseEnForme(saveFileName, pXSLGenerator, false);
1214: }
1215: }
1216: }
1217:
1218: void genereDocTest(Vector<XMLPrinterPlugin> listXMLPlugins,
1219: boolean multiFrame, boolean htmlFormat, String xmlDirName,
1220: String saveFileName) throws Exception {
1221: XSLGenerator pXSLGenerator = new XSLGenerator(listXMLPlugins,
1222: false, tmpDir + File.separator + "translate.xml");
1223: if (htmlFormat) {
1224: if (multiFrame) {
1225: String tests = saveFileName.substring(0, saveFileName
1226: .lastIndexOf("."))
1227: + "_princ.html";
1228: pXSLGenerator
1229: .transform(
1230: multiFrame,
1231: htmlFormat,
1232: tmpDir + File.separator + "salome.xml",
1233: url_txt,
1234: "/plugins/docXML/xsl/frameStatiqueXmlToHtml.xsl",
1235: saveFileName, jpgBox.isSelected(),
1236: gifBox.isSelected(), pngBox
1237: .isSelected(), xmlDirName,
1238: chosenChaptersList);
1239:
1240: miseEnForme(tests, pXSLGenerator, true);
1241: } else { // mode simple frame
1242: pXSLGenerator.transform(multiFrame, htmlFormat, tmpDir
1243: + File.separator + "salome.xml", url_txt,
1244: "/plugins/docXML/xsl/statiqueXmlToHtml.xsl",
1245: saveFileName, jpgBox.isSelected(), gifBox
1246: .isSelected(), pngBox.isSelected(),
1247: xmlDirName, chosenChaptersList);
1248:
1249: miseEnForme(saveFileName, pXSLGenerator, true);
1250: }
1251: } else {
1252: //création d'un fichier au format docbook
1253: pXSLGenerator.transform(multiFrame, htmlFormat, tmpDir
1254: + File.separator + "salome.xml", url_txt,
1255: "/plugins/docXML/xsl/statiqueXmlToDocBook.xsl",
1256: saveFileName, jpgBox.isSelected(), gifBox
1257: .isSelected(), pngBox.isSelected(),
1258: xmlDirName, chosenChaptersList);
1259:
1260: //miseEnForme(saveFileName, pXSLGenerator, true);
1261: }
1262: }
1263:
1264: /**
1265: * Méthode qui appelle les méthodes de XmlGenerator qui permettent d'ajouter
1266: * les éléments de la mise en forme en fonction de ce qui a été rempli dans
1267: * l'onglet "mise en forme" de l'IHM
1268: *
1269: * @param path page html auquel on ajoute une mise en page
1270: * @param testPlan true if the generated document id the project test plan
1271: *
1272: */
1273: public void miseEnForme(String path, XSLGenerator pXSLGenerator,
1274: boolean testPlan) throws Exception {
1275: if (gardeBox.isSelected()) {
1276: // Insertion en-tête
1277: if (!enTeteTextField.getText().equals("")) {
1278: pXSLGenerator.addTitlePage(path, enTeteTextField
1279: .getText().trim(), true);
1280: }
1281: // Insertion page de garde
1282: if (!gardeTextField.getText().equals("")) {
1283: pXSLGenerator.addTitlePage(path, gardeTextField
1284: .getText().trim(), true);
1285: }
1286: // Insertion pied de page
1287: if (!piedTextField.getText().equals("")) {
1288: pXSLGenerator.addTitlePage(path, piedTextField
1289: .getText().trim(), false);
1290: }
1291: } else {
1292: // Insertion page de garde et/ou Pied de page avec formulaire de
1293: // création
1294: if (pageGardeElement == null)
1295: createTitlePage(testPlan);
1296: pXSLGenerator.addTitlePage(path, pageGardeElement, true);
1297: }
1298: }
1299:
1300: /**
1301: * Create the title page by default
1302: * @param testPlan true if the generated document is the project test plan
1303: */
1304: public void createTitlePage(boolean testPlan) throws Exception {
1305: String title = "";
1306: if (testPlan) {
1307: if (Api.getUsedLocale().equals("fr"))
1308: title = "Dossier de tests<br>"
1309: + DataModel.getCurrentProject()
1310: .getNameFromModel();
1311: else
1312: title = "Tests plan<br>"
1313: + DataModel.getCurrentProject()
1314: .getNameFromModel();
1315: } else {
1316: if (Api.getUsedLocale().equals("fr"))
1317: title = "Résultat des tests<br>"
1318: + DataModel.getCurrentProject()
1319: .getNameFromModel();
1320: else
1321: title = "Tests result<br>"
1322: + DataModel.getCurrentProject()
1323: .getNameFromModel();
1324: }
1325: createTitlePage(null, null, title, null, null, new Date(),
1326: DataModel.getCurrentUser().getFirstNameFromModel()
1327: + " "
1328: + DataModel.getCurrentUser()
1329: .getLastNameFromModel(), DataModel
1330: .getCurrentUser().getEmailFromModel());
1331: }
1332:
1333: /**
1334: * To create title page
1335: * @param urlLogo company logo url (can be null)
1336: * @param company company name (can be null)
1337: * @param title document's title (mandatory)
1338: * @param version document's version (can be null)
1339: * @param infos additional information (can be null)
1340: * @param date
1341: * @param author document's author (can be null)
1342: * @param email author's email (can be null)
1343: */
1344: public void createTitlePage(String logoFilePath, String company,
1345: String title, String version, String infos, Date date,
1346: String author, String email) throws Exception {
1347: DocumentFactory factory = new DocumentFactory();
1348: this .logoFilePath = logoFilePath;
1349: Element aTransmettre = factory.createElement("div");
1350: if (logoFilePath != null && !logoFilePath.equals("")
1351: || company != null && !company.equals("")) {
1352: Element tableLogoCompany = aTransmettre.addElement("table");
1353: Element tr1 = tableLogoCompany.addElement("tr");
1354: if (logoFilePath != null && !logoFilePath.equals("")) {
1355: Element td11 = tr1.addElement("td");
1356: Element img1 = td11.addElement("img");
1357: String shortName = logoFilePath.substring(logoFilePath
1358: .lastIndexOf(File.separator) + 1);
1359: img1.addAttribute("src", shortName);
1360: img1.addAttribute("border", "0");
1361: } else {
1362: logoFilePath = null;
1363: }
1364: if (company != null && !company.equals("")) {
1365: Element td12 = tr1.addElement("td");
1366: Element div = td12.addElement("div");
1367: String[] list = company.split("\n");
1368: Element h3Elem = div.addElement("h3");
1369: h3Elem.addText(list[0]);
1370: for (int i = 1; i < list.length; i++) {
1371: h3Elem.addElement("br");
1372: h3Elem.addText(list[i]);
1373: }
1374: }
1375: }
1376: Element divTitle = aTransmettre.addElement("div");
1377: divTitle.addAttribute("id", "title_titlepage");
1378: Element table3 = divTitle.addElement("table");
1379: table3.addAttribute("bgcolor", "#ff9933");
1380: table3.addAttribute("width", "90%");
1381: table3.addAttribute("border", "0");
1382: table3.addAttribute("cellpading", "0");
1383: table3.addAttribute("cellspacing", "3");
1384: table3.addAttribute("align", "center");
1385: Element t3tr1 = table3.addElement("tr");
1386: Element t3td11 = t3tr1.addElement("td");
1387: Element center = t3td11.addElement("center");
1388: Element font = center.addElement("font");
1389: font.addAttribute("color", "#ffffff");
1390: font.addAttribute("size", "8");
1391: if (title.indexOf("<br>") != -1) {
1392: String[] titles = title.split("<br>");
1393: font.addText(titles[0]);
1394: font.addElement("br");
1395: font.addText(titles[1]);
1396: } else
1397: font.setText(title);
1398: Element t3tr2 = table3.addElement("tr");
1399: Element t3td21 = t3tr2.addElement("td");
1400: if (version != null && !version.equals("")) {
1401: Element center2 = t3td21.addElement("center");
1402: Element font2 = center2.addElement("font");
1403: font2.addAttribute("color", "#ffffff");
1404: font2.addAttribute("size", "4");
1405: font2.setText("Version " + version);
1406: }
1407: if (infos != null && !infos.equals("")) {
1408: Element pInfo = aTransmettre.addElement("p");
1409: pInfo.addAttribute("align", "center");
1410: String[] list2 = infos.split("\n");
1411: for (int i = 0; i < list2.length; i++) {
1412: pInfo.addText(list2[i]);
1413: pInfo.addElement("br");
1414: }
1415: }
1416: Element divDateAuthor = aTransmettre.addElement("div");
1417: divDateAuthor.addAttribute("id", "date_author");
1418: Element tableDate = divDateAuthor.addElement("table");
1419: tableDate.addAttribute("width", "100%");
1420: Element tr5 = tableDate.addElement("tr");
1421: Element td51 = tr5.addElement("td");
1422: td51.addAttribute("height", "15%");
1423: td51.addAttribute("valign", "center");
1424: DateFormat df = DateFormat.getDateInstance(DateFormat.FULL,
1425: Locale.FRENCH);
1426: td51.setText(df.format(date));
1427: if (author != null && !author.equals("")) {
1428: Element td52 = tr5.addElement("td");
1429: td52.addAttribute("colspan", "2");
1430: td52.addAttribute("align", "right");
1431: td52.addAttribute("valign", "center");
1432: td52.addText(author);
1433: td52.addElement("br");
1434: if (email != null && !email.equals("")) {
1435: Element divMonitor = td52.addElement("div");
1436: divMonitor.addAttribute("id", "email_monitor");
1437: Element a = divMonitor.addElement("a");
1438: a.addAttribute("title", Language.getInstance().getText(
1439: "Contacter_l'auteur"));
1440: a.addAttribute("href", "mailto:" + email);
1441: Element img = a.addElement("img");
1442: img.addAttribute("alt", Language.getInstance().getText(
1443: "Contacter_l'auteur"));
1444: //URL mailURL = getClass().getResource("/salomeTMF_plug/docXML/resources/img/pied_mail.gif");
1445: //img.addAttribute("src", mailURL.toString());
1446: img.addAttribute("src", "pied_mail.gif");
1447: img.addAttribute("border", "0");
1448: img.addAttribute("width", "25");
1449: img.addAttribute("height", "42");
1450: Element divPrint = td52.addElement("div");
1451: divPrint.addAttribute("id", "email_print");
1452: divPrint.addElement("b").setText("Email : \u00A0");
1453: divPrint.addText(email);
1454: }
1455: }
1456: aTransmettre.addElement("hr");
1457: setElement(aTransmettre);
1458: }
1459:
1460: public void setElement(Element e) {
1461: pageGardeElement = e;
1462: }
1463:
1464: public Element getElement() {
1465: return pageGardeElement;
1466: }
1467:
1468: public void setSuiteList(ArrayList<TestList> li) {
1469: if (li != null)
1470: suiteList = li;
1471: }
1472:
1473: public void setFamilyList(ArrayList<Family> li) {
1474: if (li != null)
1475: familyList = li;
1476: }
1477:
1478: public void setTestList(ArrayList<Test> li) {
1479: if (li != null)
1480: testList = li;
1481: }
1482:
1483: public void setCampList(ArrayList<Campaign> camp) {
1484: if (camp != null)
1485: campList = camp;
1486: }
1487:
1488: public void setExecList(ArrayList<Execution> exec) {
1489: if (exec != null)
1490: execList = exec;
1491: }
1492:
1493: public void annule() throws Exception {
1494: annule = true;
1495: GenDocDialog.this .dispose();
1496: }
1497:
1498: /**
1499: * Getter for property chosenRoot.
1500: *
1501: * @return Value of property chosenRoot.
1502: */
1503: public javax.swing.tree.DefaultMutableTreeNode getChosenRoot() {
1504: return chosenRoot;
1505: }
1506:
1507: /**
1508: * Setter for property chosenRoot.
1509: *
1510: * @param chosenRoot
1511: * New value of property chosenRoot.
1512: */
1513: public void setChosenRoot(
1514: javax.swing.tree.DefaultMutableTreeNode chosenRoot) {
1515: this .chosenRoot = chosenRoot;
1516: }
1517:
1518: /**
1519: * Getter for property initSelection.
1520: *
1521: * @return Value of property initSelection.
1522: */
1523: public boolean isInitSelection() {
1524: return initSelection;
1525: }
1526:
1527: /**
1528: * Setter for property initSelection.
1529: *
1530: * @param initSelection
1531: * New value of property initSelection.
1532: */
1533: public void setInitSelection(boolean initSelection) {
1534: this .initSelection = initSelection;
1535: }
1536:
1537: /**
1538: * Getter for property save.
1539: *
1540: * @return Value of property save.
1541: */
1542: public salomeTMF_plug.docXML.data.GardePage getSave() {
1543: return save;
1544: }
1545:
1546: /**
1547: * Setter for property save.
1548: *
1549: * @param save
1550: * New value of property save.
1551: */
1552: public void setSave(salomeTMF_plug.docXML.data.GardePage save) {
1553: this .save = save;
1554: }
1555:
1556: /**
1557: * Getter for property url_txt.
1558: *
1559: * @return Value of property url_txt.
1560: */
1561: public java.lang.String getUrl_txt() {
1562: return url_txt;
1563: }
1564:
1565: /**
1566: * @return Returns the sourceType.
1567: */
1568: public int getSourceType() {
1569: return sourceType;
1570: }
1571:
1572: /**
1573: * @param sourceType
1574: * The sourceType to set.
1575: */
1576: public void setSourceType(int sourceType) {
1577: this .sourceType = sourceType;
1578: }
1579:
1580: /**
1581: * Méthode qui affiche les messages d'erreur
1582: * @return
1583: */
1584: public void showErrorMessage() {
1585: JOptionPane.showMessageDialog(GenDocDialog.this , errorMessage,
1586: Language.getInstance().getText("Erreur_!"),
1587: JOptionPane.ERROR_MESSAGE);
1588: GenDocDialog.this .dispose();
1589: }
1590:
1591: public boolean isInitChapterSelection() {
1592: return initChapterSelection;
1593: }
1594:
1595: public void setInitChapterSelection(boolean initChapterSelection) {
1596: this .initChapterSelection = initChapterSelection;
1597: }
1598:
1599: public ArrayList<String> getChosenChaptersList() {
1600: return chosenChaptersList;
1601: }
1602:
1603: public void setChosenChaptersList(
1604: ArrayList<String> chosenChaptersList) {
1605: this.chosenChaptersList = chosenChaptersList;
1606: }
1607: }
|