public static final String IHM_REF_COMPTA_LIBELLE_NUM_LIGNE_PIECE_DEPENSE = "\"<html>Numéro de Mandat (<font color='red'>*</font>)</html>\"";
public static final String IHM_REF_COMPTA_LIBELLE_NUM_LIGNE_PIECE_RECETTE = "\"<html>Numéro de Titre (<font color='red'>*</font>)</html>\"";
+
+ public static final String PROPERTIES_FILE_NAME = "generateur-pes-pj.properties";
+ public static final String PROPERTIES_LAST_DIRECTORY_PJ = "last.directory.pj";
+ public static final String PROPERTIES_LAST_DIRECTORY_SAVE = "last.directory.save";
}
codeBudget.setV(codeBudg);
entete.setCodBud(codeBudget);
- BaseNum20 finessJuridique = new BaseNum20();
- finessJuridique.setV(finess);
- entete.setFinJur(finessJuridique);
-
+ if(!finess.isEmpty()){
+ BaseNum20 finessJuridique = new BaseNum20();
+ finessJuridique.setV(finess);
+ entete.setFinJur(finessJuridique);
+ }
+
BaseTexte38 libelleCollectiviteBudget = new BaseTexte38();
libelleCollectiviteBudget.setV(libelleColBudg);
entete.setLibelleColBud(libelleCollectiviteBudget);
import com.axyus.generator.pespj.steps.PjStep;
import com.axyus.generator.pespj.steps.ReferenceComptableStep;
import com.axyus.generator.pespj.utils.ConfigHandler;
+import com.axyus.generator.pespj.utils.Constants;
import com.axyus.swing.components.wizard.WizardProcess;
import com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl;
import fr.gouv.minefi.cp.helios.pes_v2.rev0.aller.PESAller;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
/**
int stepIndex = 0;
+ private static Properties properties;
+ private static File propertiesFile = new File(System.getProperty("user.home"), Constants.PROPERTIES_FILE_NAME);
+
private PESAller pesAller;
private ConfigHandler configHandler;
public GeneratorPesPjWizardProcess(WizardLauncher.RunContextAdapter runContextAdapter) throws UnExpectedException {
this.runContextAdapter = runContextAdapter;
this.pesAller = new PESAller();
-
- try {
+
+ try {
+ if(!propertiesFile.exists()){
+ propertiesFile.createNewFile();
+ }
InputStream input = this.getClass().getResourceAsStream("/com/axyus/generator/pespj/datas.xml");
try{
DocumentBuilder documentBuilder = new DocumentBuilderFactoryImpl().newDocumentBuilder();
configHandler = new ConfigHandler(documentBuilder.parse(input));
+ properties = new Properties();
+ properties.load(new FileInputStream(propertiesFile));
}finally{
input.close();
}
this.pjStep = new PjStep();
this.referenceComptableStep = new ReferenceComptableStep();
this.generationResultStep = new GenerationResultStep(runContextAdapter.isPesFileImportSupported());
+ this.generationResultStep.setPreviousEnable(false);
if (runContextAdapter.isPesFileImportSupported()) {
this.importXemeliosConfirmationStep = new ImportXemeliosResultStep();
public boolean isInXemelios() {
return inXemelios;
- }
+ }
+
+ public void storeInPropertiesFile() throws Exception {
+ properties.store(new FileOutputStream(propertiesFile), null);
+ }
+
+ public Properties getProperties(){
+ return properties;
+ }
}
@Override
public void validate() throws StepValidationException {
XemeliosToolServiceProvider serviceProvider = ToolServiceProviderFactory.newInstance().getServiceProvider();
- List<String> availableDocumentsList = serviceProvider.getImportableDocumentsConfigurations();
-
+ List<String> availableDocumentsList = serviceProvider.getImportableDocumentsConfigurations();
+
if (availableDocumentsList.contains(DOC_ID)) {
try {
getWizardProcess().setImportXemeliosException(null);
import com.axyus.generator.pespj.GeneratorPesPjWizardProcess;
import com.axyus.generator.pespj.ui.ReferenceComptableUI;
import com.axyus.generator.pespj.ui.renderer.TableModelReferenceComptable;
+import com.axyus.generator.pespj.utils.Constants;
import com.axyus.generator.pespj.utils.DateUtils;
import com.axyus.generator.pespj.utils.GeneratePesUtils;
import com.axyus.swing.components.wizard.WizardProcess;
-import fr.gouv.minefi.cp.helios.pes_v2.facture.r0.aller.TPESFacture;
import fr.gouv.minefi.cp.helios.pes_v2.facture.r0.aller.TPESFactureOld;
import fr.gouv.minefi.cp.helios.pes_v2.rev0.aller.PESAller;
+import javax.swing.JOptionPane;
import org.apache.commons.io.FilenameUtils;
/**
* @author SME
*/
public class ReferenceComptableStep extends WizardProcess.Step<GeneratorPesPjWizardProcess> {
- private static Log logger = LogFactory.getLog(ReferenceComptableStep.class);
+ private static final String ENCODING = "ISO-8859-1";
+ private static Log logger = LogFactory.getLog(ReferenceComptableStep.class);
private ReferenceComptableUI referenceComptablePanelUI;
private File pesPjFile;
}
}
- JFileChooser chooseFileDialog = new JFileChooser(System.getProperty("user.home"));
+ String directoryPath = getWizardProcess().getProperties().getProperty(Constants.PROPERTIES_LAST_DIRECTORY_SAVE);
+ if(directoryPath == null){
+ directoryPath = System.getProperty("user.home");
+ }
+ JFileChooser chooseFileDialog = new JFileChooser(new File(directoryPath));
FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("xml files (*.xml)", "xml");
chooseFileDialog.setFileFilter(xmlfilter);
chooseFileDialog.setDialogTitle("Enregistrer sous ...");
- int response = chooseFileDialog.showDialog(getWizardProcess().getWizardDialog(), "Enregistrer");
-
- if (response == JFileChooser.APPROVE_OPTION) {
- this.referenceComptablePanelUI.setBusy(true);
- try{
- pesPjFile = chooseFileDialog.getSelectedFile();
+
+ int responseConfirm = JOptionPane.showConfirmDialog(getWizardProcess().getWizardDialog(),
+ "Vous êtes sur le point de générer le PES PJ, vous ne pourrez pas revenir en arrière.\n Etes-vous sûr de vouloir continuer ?",
+ "Confirmer la génération",
+ JOptionPane.YES_NO_OPTION);
+
+ if (responseConfirm == JOptionPane.YES_OPTION) {
+ int responseChooseFile = chooseFileDialog.showDialog(getWizardProcess().getWizardDialog(), "Enregistrer");
+ if(responseChooseFile == JFileChooser.APPROVE_OPTION) {
+ this.referenceComptablePanelUI.setBusy(true);
+ try{
+ pesPjFile = chooseFileDialog.getSelectedFile();
+ getWizardProcess().getProperties().setProperty(Constants.PROPERTIES_LAST_DIRECTORY_SAVE, pesPjFile.getParent());
- if(!FilenameUtils.isExtension(pesPjFile.getName(), "xml")){
- pesPjFile = new File(pesPjFile.getAbsolutePath()+".xml");
- if(!pesPjFile.exists()){
- pesPjFile.createNewFile();
+ if(!FilenameUtils.isExtension(pesPjFile.getName(), "xml")){
+ pesPjFile = new File(pesPjFile.getAbsolutePath()+".xml");
+ if(!pesPjFile.exists()){
+ pesPjFile.createNewFile();
+ }
}
- }
- PESAller pesAller = getWizardProcess().getPesAller();
- if(factureObj != null){
- pesAller.setPESFacture(factureObj);
- }
- pesAller.setPESPJ(GeneratePesUtils.generatePesPj(pesAller, getWizardProcess().getPjStep().getPjs()));
-
- FileOutputStream fos = new FileOutputStream(pesPjFile);
- // Génration du flux XML
- try {
- JAXBContext context = JAXBContext.newInstance(PESAller.class);
- pesPjFile = chooseFileDialog.getSelectedFile();
-
- Marshaller m = context.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- logger.debug("Début de la génération : " + DateUtils.xmlFormatWithHours(new Date()));
- m.marshal(pesAller, fos);
- logger.debug("Fin de la génération : " + DateUtils.xmlFormatWithHours(new Date()));
- fos.flush();
+ PESAller pesAller = getWizardProcess().getPesAller();
+ if(factureObj != null){
+ pesAller.setPESFacture(factureObj);
+ }
+ pesAller.setPESPJ(GeneratePesUtils.generatePesPj(pesAller, getWizardProcess().getPjStep().getPjs()));
+
+ FileOutputStream fos = new FileOutputStream(pesPjFile);
+ // Génration du flux XML
+ try {
+ JAXBContext context = JAXBContext.newInstance(PESAller.class);
+ pesPjFile = chooseFileDialog.getSelectedFile();
+
+ Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.setProperty(Marshaller.JAXB_ENCODING, ENCODING);
+
+ logger.debug("Début de la génération : " + DateUtils.xmlFormatWithHours(new Date()));
+ m.marshal(pesAller, fos);
+ logger.debug("Fin de la génération : " + DateUtils.xmlFormatWithHours(new Date()));
+ fos.flush();
+ getWizardProcess().storeInPropertiesFile();
+ } finally {
+ fos.close();
+ }
+ } catch (Exception e) {
+ throw new StepValidationException("Probleme de génération du flux xml."+e.getLocalizedMessage());
} finally {
- fos.close();
+ this.referenceComptablePanelUI.setBusy(false);
}
- } catch (Exception e) {
- throw new StepValidationException("Probleme de génération du flux xml."+e.getLocalizedMessage());
- } finally {
- this.referenceComptablePanelUI.setBusy(false);
+ } else {
+ throw new StepValidationException("");
}
} else {
throw new StepValidationException("");
private GeneratorPesPjWizardProcess wizardProcess;
public GenerationResultUI() {
- initComponents();
+ initComponents();
+
importXemeliosCheckBx.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
}
@Override
- public String getName() {
+ public String getName() {
return "Résultat de la vérification";
}
* @param wizardProcess the wizardProcess to set
*/
public void setWizardProcess(GeneratorPesPjWizardProcess wizardProcess) {
- this.wizardProcess = wizardProcess;
+ this.wizardProcess = wizardProcess;
}
}
import com.axyus.swing.components.AbstractWizardPanel;
import com.axyus.generator.pespj.ui.renderer.PairComboBoxRenderer;
import com.axyus.generator.pespj.ui.renderer.TableModelPJ;
+import com.axyus.generator.pespj.utils.Constants;
import com.axyus.generator.pespj.utils.PJfile;
import fr.gouv.minefi.cp.helios.pes_v2.rev0.aller.PESAller;
import fr.gouv.minefi.cp.helios.pes_v2.rev0.aller.TPESPJs;
import java.io.File;
import java.util.Date;
import javax.swing.DefaultComboBoxModel;
+import javax.swing.JDialog;
import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTable;
private void browse_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browse_buttonActionPerformed
setBusy(true);
- JFileChooser chooseFileDialog = new JFileChooser(System.getProperty("user.home"));
+
+ String directoryPath = ((GeneratorPesPjWizardProcess) getWizardDialog().getWizardProcess()).getProperties().getProperty(Constants.PROPERTIES_LAST_DIRECTORY_PJ);
+ if(directoryPath == null){
+ directoryPath = System.getProperty("user.home");
+ }
+ JFileChooser chooseFileDialog = new JFileChooser(directoryPath);
chooseFileDialog.setDialogTitle("Sélectionez une PJ");
int response = chooseFileDialog.showDialog(this, "Sélectionner");
setBusy(false);
if(response == JFileChooser.APPROVE_OPTION){
File selectedFile = chooseFileDialog.getSelectedFile();
+ ((GeneratorPesPjWizardProcess) getWizardDialog().getWizardProcess()).getProperties().setProperty(Constants.PROPERTIES_LAST_DIRECTORY_PJ, selectedFile.getParent());
if (selectedFile != null) {
pieceJustificative.setText(selectedFile.getAbsolutePath());
if(!GeneratorUtils.isFacture(((Pair) typePj.getSelectedItem()).key)){
description.setText(selectedFile.getName());
}
}
+ try {
+ ((GeneratorPesPjWizardProcess) getWizardDialog().getWizardProcess()).storeInPropertiesFile();
+ } catch (Exception e) {
+ logger.error(e);
+ }
inModeSaisie(true);
}
if(canGenerateIdUnique()){
tableModel.add(new PJfile(pieceJustificative.getText(),GeneratePesUtils.generatePj(pieceJustificative.getText(),
((Pair) typePj.getSelectedItem()).key, nomPj.getText(),
idUnique.getText(), description.getText())));
+ JOptionPane.showMessageDialog(getWizardDialog(), "La PJ a été ajoutée avec succès.\nLe formulaire de saisie a été réinitialisé.");
} finally {
setBusy(false);
resetChamps();
}
private void updateButtonSate() {
- previousButton.setEnabled(getWizardProcess().hasPreviousStep());
+ previousButton.setEnabled(getWizardProcess().hasPreviousStep() && getWizardProcess().getCurrentStep().isPreviousEnable());
nextButton.setEnabled(getWizardProcess().hasNextStep());
cancelButton.setText(getWizardProcess().hasNextStep() ? "Annuler" : "Fermer");
}
private WizardProcessType wizardProcess;
private SwingWorker worker;
+ private boolean previousEnable = true;
public void setWizardProcess(WizardProcessType wizardProcess) {
this.wizardProcess = wizardProcess;
return wizardProcess;
}
+ public boolean isPreviousEnable() {
+ return previousEnable;
+ }
+
+ public void setPreviousEnable(boolean previousEnable) {
+ this.previousEnable = previousEnable;
+ }
+
public abstract String getTile();
public void beforeDisplay() {