+++ /dev/null
-/*
- * Copyright
- * 2008 axYus - www.axyus.com
- * 2008 L.Meckert - laurent.meckert.com
- *
- * This file is part of XEMELIOS.
- *
- * XEMELIOS is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * XEMELIOS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with XEMELIOS; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package fr.gouv.finances.cp.xemelios.plugin.generatorPesPjs;
-
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-import java.util.zip.GZIPOutputStream;
-
-import javax.imageio.ImageIO;
-import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
-import javax.swing.filechooser.FileFilter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.commons.io.FilenameUtils;
-import org.apache.log4j.Logger;
-import org.netbeans.api.wizard.WizardDisplayer;
-import org.netbeans.spi.wizard.DeferredWizardResult;
-import org.netbeans.spi.wizard.ResultProgressHandle;
-import org.netbeans.spi.wizard.Summary;
-import org.netbeans.spi.wizard.Wizard;
-import org.netbeans.spi.wizard.WizardException;
-import org.netbeans.spi.wizard.WizardPage;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import fr.gouv.finances.cp.utils.PropertiesExpansion;
-import fr.gouv.finances.dgfip.utils.Base64;
-import fr.gouv.finances.dgfip.utils.xml.NamespaceContextImpl;
-import fr.gouv.finances.dgfip.xemelios.common.config.DocumentsModel;
-import fr.gouv.finances.dgfip.xemelios.common.config.Loader;
-import fr.gouv.finances.dgfip.xemelios.tools.MenuTitle;
-import fr.gouv.finances.dgfip.xemelios.tools.ToolServiceProviderFactory;
-import fr.gouv.finances.dgfip.xemelios.tools.XemeliosToolServiceProvider;
-
-/**
- *
- * @author jean-philippe.tessier
- */
-@MenuTitle(value = "Génération de fichier PES PJ")
-public class WizardPesPj extends AbstractDlgPesPj {
-
- private static final Logger logger = Logger.getLogger(WizardPesPj.class);
- private Wizard wizard = null;
- private boolean standaloneMode = false;
- private static final String NAMESPACE_PES_ALLER = "http://www.minefi.gouv.fr/cp/helios/pes_v2/Rev0/aller";
- private static final String NAMESPACE_ENCRYPTED_DATA = "http://www.w3.org/2001/04/xmlenc#";
- private static final String NAMESPACE_PES_FACTURE = "http://www.minefi.gouv.fr/cp/helios/pes_v2/facture";
- @Deprecated
- private DocumentsModel docModels;
- private DocumentBuilderFactory domFactory;
- private File fileToGenerate = null;
-
- public WizardPesPj() {
- super(null, true);
- }
-
- /**
- *
- * @param parent
- * @param modal
- */
- public WizardPesPj(java.awt.Frame parent, boolean modal) {
- super(parent, modal);
- // if(MainWindow.instance!=null){
- // docModels = MainWindow.instance.getDocModels();
- // }
- domFactory = DocumentBuilderFactory.newInstance();
- }
-
- public WizardPesPj(Properties props) {
- this(null, true);
- System.out.println("\n\n\n");
- PropertiesExpansion pp = new PropertiesExpansion();
- for (Enumeration<Object> en = props.keys(); en.hasMoreElements();) {
- String k = (String) en.nextElement();
- Object v = props.get(k);
- System.out.println(k + "=" + v);
- pp.put(k, v);
- }
- System.out.println("\n");
-
- for (Enumeration<Object> en = pp.keys(); en.hasMoreElements();) {
- String k = (String) en.nextElement();
- String v = pp.replace(k);
- System.out.println(k + "=" + v);
- System.setProperty(k, v);
- }
- standaloneMode = true;
- }
-
- public static void main(String[] args) {
- new WizardPesPj(null, true).run();
- }
-
- @Override
- public void run() {
- WizardPage[] pages = new WizardPage[] { new PanelPesPJAccueil(), new PanelPesPJPiecesJustificatives(), new PanelPesPJReferencesComptables() };
-
- MyProducer mp = new MyProducer();
-
- // Création du wizard
- wizard = WizardPage.createWizard("Génération d'un PES PJ", pages, mp);
-
- // Ajout de l'image du wizard
- BufferedImage img;
- try {
- InputStream is = this.getClass().getClassLoader().getResourceAsStream("fr/gouv/finances/cp/xemelios/plugin/generatorPesPjs/ImageWizard.png");
- img = ImageIO.read(is);
- is.close();
- UIManager.put("wizard.sidebar.image", img);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- // Ajout d'un oberver (Events)
- InstructionsPesPJ ip = new InstructionsPesPJ(wizard);
- wizard.addWizardObserver(ip);
-
- // Affichage du wizard
- WizardDisplayer.showWizard(wizard);
- }
-
- private void saveFluxPESPJ(Map wizardData) throws WizardException {
- // if(formIsValid()){
- try {
- startVentilateur();
- // setPropertiesGeneratorPESPJs();
- Document doc = createDOMdoc(wizardData);
-
- // Ecriture du DOM dans un fichier
- TransformerFactory tf = net.sf.saxon.TransformerFactoryImpl.newInstance();
-
- Transformer trans = tf.newTransformer();
- Properties props = new Properties();
- props.setProperty(OutputKeys.ENCODING, "ISO-8859-1");
- props.setProperty(OutputKeys.INDENT, "yes");
- props.setProperty(OutputKeys.METHOD, "xml");
- trans.setOutputProperties(props);
-
- File f = new File(fileToGenerate.getAbsolutePath());
- System.out.println("trying to create " + f.getAbsolutePath());
- FileOutputStream fos = new FileOutputStream(f);
-
- trans.transform(new DOMSource(doc), new StreamResult(fos));
- fos.flush();
- fos.close();
-
- stopVentilateur();
- ToolServiceProviderFactory toolFactory = ToolServiceProviderFactory.newInstance();
- XemeliosToolServiceProvider serviceProvider = toolFactory.getServiceProvider();
- if (serviceProvider.getAvailableDocumentsConfigurations().contains("pes-aller")) {
- // if (MainWindow.instance != null) {
- int response = JOptionPane.showConfirmDialog(parentWindow, "Le flux PES PJ à bien été généré.\n\nDésirez vous l'importer ?", "Importation du flux PES PJ généré", JOptionPane.YES_NO_OPTION);
- if (JOptionPane.YES_OPTION == response) {
- serviceProvider.importFile(fileToGenerate, "pes-aller");
- // importer(docModels.getDocumentById("PES_Aller"), new Pair((String) wizardData.get(Constants.PROPERTY_NAME_ID_COLL), (String)
- // wizardData.get(Constants.PROPERTY_NAME_LIBELLE)), new Pair((String) wizardData.get(Constants.PROPERTY_NAME_CODE_BUDG), (String)
- // wizardData.get(Constants.PROPERTY_NAME_LIBELLE)), new File(fileToGenerate.getAbsolutePath()));
- this.close();
- // this.setVisible(false);
- }
- }/*
- * else { JOptionPane.showMessageDialog(parentWindow, "Le flux PES PJ à bien été généré.", "Génération du flux PES PJ", JOptionPane.OK_OPTION); }
- */
-
- // resetDialog();
- } catch (Exception ex) {
- throw new WizardException(ex.getLocalizedMessage());
- } finally {
- stopVentilateur();
- }
- // }
- }
-
- // private void importer(DocumentModel dm, Pair coll, Pair budg, File f) {
- // try {
- // Class clazz = Class.forName(dm.getImportClass());
- // // Object obj = clazz.newInstance();
- // Constructor cc = clazz.getConstructor(XemeliosUser.class);
- // Object obj = cc.newInstance(MainWindow.instance.getConnectedUser());
- // if (!(obj instanceof DefaultImporter)) {
- // JOptionPane.showMessageDialog(MainWindow.instance,
- // "Cette classe n'est pas un importeur.\nLe fichier de configuration qui vous a été livré est certainement invalide.\nVeuillez contacter votre fournisseur.\n",
- // "Erreur", JOptionPane.ERROR_MESSAGE);
- // return;
- // }
- // EtatImporteur ei = (EtatImporteur) obj;
- // ei.setDocument(dm, coll, budg);
- // ArrayList<File> array = new ArrayList<File>();
- // array.add(f);
- // ImportContent fToImport = new ImportContent();
- // fToImport.setFilesToImport(array);
- //
- // MainWindow.instance.doImport(ei, fToImport, dm, true);
- //
- // } catch (Exception ex) {
- // ex.printStackTrace();
- // } finally {
- // }
- // }
-
- protected DocumentsModel getDocumentsInfosGenPesPjs(String repertoires) {
- DocumentsModel ret = null;
- try {
- ret = Loader.getDocumentsInfos(repertoires);
- } catch (Exception ex) {
- System.out.println(ex.getMessage());
- }
- return ret;
- }
-
- public void startVentilateur() {
- if (getGlassPane() != null) {
- getGlassPane().setVisible(true);
- } else {
- initGlassPane();
- getGlassPane().setVisible(true);
- }
- }
-
- public void stopVentilateur() {
- if (getGlassPane() != null) {
- getGlassPane().setVisible(false);
- } else {
- initGlassPane();
- getGlassPane().setVisible(false);
- }
- }
-
- private Document createDOMdoc(Map wizardData) {
- try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.newDocument();
-
- Element root = doc.createElementNS(NAMESPACE_PES_ALLER, "n:PES_Aller");
-
- root.setAttribute("xmlns:n", NAMESPACE_PES_ALLER);
- // root.setAttribute("xmlns:enc",NAMESPACE_ENCRYPTED_DATA);
-
- doc.appendChild(root);
-
- createEnveloppe(doc, wizardData);
- createEntetePES(doc, wizardData);
-
- TableModelPJ pjs = (TableModelPJ) wizardData.get(Constants.PROPERTY_NAME_TABLE_MODEL_PJ);
- if (pjs.getPjs() != null && pjs.getPjs().size() > 0) {
- createPES_PJ(doc, wizardData);
- }
-
- return doc;
-
- } catch (ParserConfigurationException ex) {
- // Logger.getLogger(DlgGenPesPjs.class.getName()).log(Level.FATAL, null, ex);
- ex.printStackTrace();
- }
- return null;
- }
-
- private void createEnveloppe(Document doc, Map wizardData) {
- Element enveloppe = doc.createElementNS("", "Enveloppe");
-
- Element parametre = doc.createElementNS("", "Parametres");
-
- Element version = doc.createElementNS("", "Version");
- version.setAttribute("V", "01");
-
- Element typeFic = doc.createElementNS("", "TypFic");
- typeFic.setAttribute("V", "PES_PJ");
-
- Element nomFic = doc.createElementNS("", "NomFic");
- nomFic.setAttribute("V", new File(fileToGenerate.getAbsolutePath()).getName());
-
- parametre.appendChild(version);
- parametre.appendChild(typeFic);
- parametre.appendChild(nomFic);
- enveloppe.appendChild(parametre);
-
- doc.getChildNodes().item(0).appendChild(enveloppe);
- }
-
- private void createEntetePES(Document doc, Map wizardData) {
- Element entetePES = doc.createElementNS("", "EnTetePES");
-
- Element dteStr = doc.createElementNS("", "DteStr");
- dteStr.setAttribute("V", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
-
- String idPost = (String) wizardData.get(Constants.PROPERTY_NAME_ID_POST);
- String idColl = (String) wizardData.get(Constants.PROPERTY_NAME_ID_COLL);
- String finess = (String) wizardData.get(Constants.PROPERTY_NAME_FINESS);
- String codColl = (String) wizardData.get(Constants.PROPERTY_NAME_CODE_COLL);
- String codBudg = (String) wizardData.get(Constants.PROPERTY_NAME_CODE_BUDG);
- String libCollBudg = (String) wizardData.get(Constants.PROPERTY_NAME_LIBELLE);
-
- Element idPoste = null;
- if (idPost.length() != 0) {
- idPoste = doc.createElementNS("", "IdPost");
- idPoste.setAttribute("V", idPost);
- }
-
- Element idCollec = null;
- if (idColl.length() != 0) {
- idCollec = doc.createElementNS("", "IdColl");
- idCollec.setAttribute("V", idColl);
- }
-
- Element finJur = null;
- if (finess.length() != 0) {
- finJur = doc.createElementNS("", "FinJur");
- finJur.setAttribute("V", finess);
- }
-
- Element codCollec = null;
- if (codColl.length() != 0) {
- codCollec = doc.createElementNS("", "CodCol");
- codCollec.setAttribute("V", codColl);
- }
-
- Element codBud = null;
- if (codBudg.length() != 0) {
- codBud = doc.createElementNS("", "CodBud");
- codBud.setAttribute("V", codBudg);
- }
-
- Element libelleColBud = null;
- if (libCollBudg.length() != 0) {
- libelleColBud = doc.createElementNS("", "LibelleColBud");
- libelleColBud.setAttribute("V", libCollBudg);
- }
-
- entetePES.appendChild(dteStr);
- if (idPoste != null) {
- entetePES.appendChild(idPoste);
- }
- if (idCollec != null) {
- entetePES.appendChild(idCollec);
- }
- if (finJur != null) {
- entetePES.appendChild(finJur);
- }
- if (codCollec != null) {
- entetePES.appendChild(codCollec);
- }
- if (codBud != null) {
- entetePES.appendChild(codBud);
- }
- if (libelleColBud != null) {
- entetePES.appendChild(libelleColBud);
- }
-
- doc.getChildNodes().item(0).appendChild(entetePES);
- }
-
- private void createPES_PJ(Document doc, Map wizardData) {
- try {
- Element PES_PJ = doc.createElementNS("", "PES_PJ");
-
- Element entetePES_PJ = doc.createElementNS("", "EnTetePES_PJ");
- Element idVer = doc.createElementNS("", "IdVer");
- idVer.setAttribute("V", "1");
- entetePES_PJ.appendChild(idVer);
-
- PES_PJ.appendChild(entetePES_PJ);
-
- createPJs(doc, PES_PJ, wizardData);
-
- doc.getChildNodes().item(0).appendChild(PES_PJ);
- } catch (IOException ex) {
- // Logger.getLogger(DlgGenPesPjs.class.getName()).log(Level.FATAL, null, ex);
- ex.printStackTrace();
- }
- }
-
- private void createPJs(Document doc, Element pes_pj, Map wizardData) throws IOException {
- Vector<Element> vpce = new Vector<Element>();
- Element contenu;
-
- TableModelPJ pjs = (TableModelPJ) wizardData.get(Constants.PROPERTY_NAME_TABLE_MODEL_PJ);
- for (PJ pj : pjs.getPjs()) {
- contenu = doc.createElementNS("", "Contenu");
- Element pce = doc.createElementNS("", "PJ");
-
- // Si ce n'est pas une facture, compression de la pj et encodage en base64 de son contenu
- if (!(pj.getTypePJ().contains("Facture"))) {
-
- Element fichier = doc.createElementNS("", "Fichier");
-
- fichier.setAttributeNS("", "MIMEType", FilenameUtils.getExtension(pj.getPjFile().getName()));
- // Creation d'un inputStream sur la PJ
- FileInputStream fis = new FileInputStream(pj.getPjFile());
-
- // Creation du gzip et d'un outputStream
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream gzo = new GZIPOutputStream(baos);
-
- // Lecture de la PJ et remplissage du gzip
- byte[] bTmp = new byte[2048];
- int read = 0;
- do {
- read = fis.read(bTmp);
- if (read > 0) {
- gzo.write(bTmp, 0, read);
- }
- } while (read > 0);
-
- fis.close();
- gzo.finish();
- gzo.flush();
- gzo.close();
-
- // System.out.println(Base64.encodeBytes(baos.toByteArray(),true));
- Text txt = doc.createTextNode(Base64.encodeBytes(baos.toByteArray(), true));
- fichier.appendChild(txt);
-
- baos.close();
-
- contenu.appendChild(fichier);
- pce.appendChild(contenu);
-
- } else {
- try {
- // Creation d'un InputStream pour lire la PJ
- FileInputStream fis = new FileInputStream(pj.getPjFile());
-
- // Parssage de la PJ
- // DOMParser domp = new DOMParser();
- // domp.parse(new InputSource(fis));
-
- DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
- Document document = domBuilder.parse(new InputSource(fis));
-
- // on vérifie que c'est bien un PES_Facture
- XPathFactory xpf = XPathFactory.newInstance();
- XPath xp = xpf.newXPath();
- NamespaceContextImpl ns = new NamespaceContextImpl();
- ns.addMapping("", NAMESPACE_PES_FACTURE);
- ns.addMapping("n", NAMESPACE_PES_FACTURE);
- xp.setNamespaceContext(ns);
- Element pesFacture = (Element) xp.evaluate("/n:PESFacture", document, XPathConstants.NODE);
- if (pesFacture == null) {
- throw new SAXException("ce n'est pas un PES Facture");
- }
- Node node = doc.adoptNode(pesFacture);
-
- // Ajout de la PJ
- contenu.appendChild(node);
- pce.appendChild(contenu);
-
- } catch (ParserConfigurationException pcEx) {
- // Logger.getLogger(DlgGenPesPjs.class.getName()).log(Level.SEVERE,"while instanciating new dom parser",pcEx);
- pcEx.printStackTrace();
- } catch (Exception ex) {
- // Logger.getLogger(DlgGenPesPjs.class.getName()).log(Level.FATAL, null, ex);
- // ex.printStackTrace();
- // ce n'est pas un fichier XML, on le met alors en binaire
- Element fichier = doc.createElementNS("", "Fichier");
- fichier.setAttributeNS("", "MIMEType", FilenameUtils.getExtension(pj.getPjFile().getName()));
- // Creation d'un inputStream sur la PJ
- FileInputStream fis = new FileInputStream(pj.getPjFile());
-
- // Creation du gzip et d'un outputStream
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream gzo = new GZIPOutputStream(baos);
-
- // Lecture de la PJ et remplissage du gzip
- byte[] bTmp = new byte[2048];
- int read = 0;
- do {
- read = fis.read(bTmp);
- if (read > 0) {
- gzo.write(bTmp, 0, read);
- }
- } while (read > 0);
-
- fis.close();
- gzo.finish();
- gzo.flush();
- gzo.close();
-
- // System.out.println(Base64.encodeBytes(baos.toByteArray(),true));
- Text txt = doc.createTextNode(Base64.encodeBytes(baos.toByteArray(), true));
- fichier.appendChild(txt);
-
- baos.close();
-
- contenu.appendChild(fichier);
- pce.appendChild(contenu);
- }
- }
-
- // Creation des éléments fils de la PES_PJ
- Element idUnique = doc.createElementNS("", "IdUnique");
- idUnique.setAttribute("V", pj.getIdentifiant());
-
- Element nomPJ = doc.createElementNS("", "NomPJ");
- nomPJ.setAttribute("V", pj.getPjFile().getName());
-
- Element typePJ = doc.createElementNS("", "TypePJ");
- typePJ.setAttribute("V", pj.getTypePJ().split(" - ")[0]);
-
- Element desc = doc.createElementNS("", "Description");
- desc.setAttribute("V", pj.getDescription());
-
- pce.appendChild(idUnique);
- pce.appendChild(nomPJ);
- pce.appendChild(typePJ);
- pce.appendChild(desc);
-
- createRefsComptas(doc, pj, pce, wizardData);
-
- vpce.add(pce);
- }
- for (Element e : vpce) {
- pes_pj.appendChild(e);
- }
- }
-
- private void createRefsComptas(Document doc, PJ pj, Element pce, Map wizardData) {
- for (RefCompta rc : pj.getVRefsComptas()) {
- Element refCompta = doc.createElementNS("", "RefCompta");
-
- Element domaine = doc.createElementNS("", "Domaine");
- domaine.setAttribute("V", rc.getDomaine().split(" - ")[0]);
-
- Element exer = doc.createElementNS("", "Exercice");
- exer.setAttribute("V", rc.getExercice().toString());
-
- Element typObj = doc.createElementNS("", "TypeObjet");
- typObj.setAttribute("V", rc.getTypePiece().key);
-
- Element id = doc.createElementNS("", "Identifiant");
- id.setAttribute("V", rc.getNumPiece().toString());
-
- Element complId;
- if (rc.getNumLignePiece().length() != 0) {
- complId = doc.createElementNS("", "ComplementIdentifiant");
- complId.setAttribute("V", rc.getNumLignePiece().toString());
- } else {
- complId = null;
- }
-
- Element codProd;
- if (rc.getCodeProduit().length() != 0) {
- codProd = doc.createElementNS("", "CodProd");
- codProd.setAttribute("V", rc.getCodeProduit());
- } else {
- codProd = null;
- }
-
- Element idTiers;
- if (rc.getIdTiers().length() != 0) {
- idTiers = doc.createElementNS("", "IdTiers");
- idTiers.setAttribute("V", rc.getIdTiers());
- } else {
- idTiers = null;
- }
-
- refCompta.appendChild(domaine);
- refCompta.appendChild(exer);
- refCompta.appendChild(typObj);
- refCompta.appendChild(id);
- if (complId != null) {
- refCompta.appendChild(complId);
- }
- if (codProd != null) {
- refCompta.appendChild(codProd);
- }
- if (idTiers != null) {
- refCompta.appendChild(idTiers);
- }
-
- pce.appendChild(refCompta);
- }
- }
-
- class MyProducer implements WizardPage.WizardResultProducer {
-
- @Override
- public Object finish(Map wizardData) throws WizardException {
- String[] items = new String[1];
- // items[0] = "Nombre de PJ générée(s) : "+((TableModelPJ) wizardData.get(Constants.PROPERTY_NAME_TABLE_MODEL_PJ)).getPjs().size();
- // items[1] = "Certificat utilisé: " + wizardData.get("jListCertificates");
- // items[2] = "Fichier signé: " + wizardData.get("TextFieldOutputFile");
-
- PropertiesExpansion props = ActionsPesPj.getInstance().getProperties();
-
- // Selection du fichier ou enregistrer le flux
- JFileChooser fc = null;
- if (props.getProperty(Constants.PROPERTY_NAME_PATH_FILE_TO_GENERATE) == null) {
- fc = new JFileChooser();
- } else {
- fc = new JFileChooser(new File(props.getProperty(Constants.PROPERTY_NAME_PATH_FILE_TO_GENERATE)).getParent());
- }
- fc.setApproveButtonText("Enregistrer");
- fc.setName("Enregistrer");
- fc.setDialogTitle("Enregistrer le PES PJ sous ...");
- fc.addChoosableFileFilter(new FileFilter() {
-
- @Override
- public boolean accept(File f) {
- return f.isDirectory() || f.getName().toUpperCase().endsWith("XML");
- }
-
- @Override
- public String getDescription() {
- return "Document XML";
- }
- });
-
- int reponse = fc.showOpenDialog(null);
- if (reponse == JFileChooser.APPROVE_OPTION) {
- String path = fc.getSelectedFile().getAbsolutePath().toUpperCase().contains(".XML") == true ? fc.getSelectedFile().getAbsolutePath() : fc.getSelectedFile().getAbsolutePath() + ".xml";
- fileToGenerate = new File(path);
- }
- // Création du flux
- saveFluxPESPJ(wizardData);
- props.setProperty(Constants.PROPERTY_NAME_PATH_FILE_TO_GENERATE, fileToGenerate.getAbsolutePath());
-
- return new MyDeferredWizardResult();
- }
-
- @Override
- public boolean cancel(Map settings) {
- boolean dialogShouldClose = JOptionPane.showConfirmDialog(null, "Désirez vous réellement annuler l'opération ?\nToutes les données seront perdues.") == JOptionPane.OK_OPTION;
- return dialogShouldClose;
- }
-
- class MyDeferredWizardResult extends DeferredWizardResult {
-
- public MyDeferredWizardResult() {
- super(true, true);
- }
-
- @Override
- public void start(java.util.Map wizardData, ResultProgressHandle progress) {
- try {
- String[] items = new String[8];
- items[0] = "Identifiant du poste : " + ((String) wizardData.get(Constants.PROPERTY_NAME_ID_POST));
- items[1] = "Identifiant de la collectivité : " + ((String) wizardData.get(Constants.PROPERTY_NAME_ID_COLL));
- items[2] = "Code budget : " + ((String) wizardData.get(Constants.PROPERTY_NAME_CODE_BUDG));
- items[3] = "Code de la collectivité : " + ((String) wizardData.get(Constants.PROPERTY_NAME_CODE_COLL));
- items[4] = "Finess juridique : " + ((String) wizardData.get(Constants.PROPERTY_NAME_FINESS));
- items[5] = "Libellé collectivité budget : " + ((String) wizardData.get(Constants.PROPERTY_NAME_LIBELLE));
- items[6] = "";
- items[7] = "Nombre de PJ générée(s) : " + ((TableModelPJ) wizardData.get(Constants.PROPERTY_NAME_TABLE_MODEL_PJ)).getPjs().size();
- // items[1] = "Certificat utilisé: " + Actions.getInstance().getAliasName();
- // items[2] = "Fichier signé: " + Actions.getInstance().getFileToGenerate().getAbsolutePath();
- // items[3] = "Résultat: " + Actions.getInstance().getSignStatusString();
-
- // progress.finished(Summary.create("Fichier PES PJ créé", null));
- progress.finished(Summary.create(items, "Génération réussie"));
- } catch (Exception e) {
- progress.failed("Echec de la génération du PES PJ", true);
- }
- }
- }
- }
-}