1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
9 |
* language governing permissions and limitations under the License.
|
9 |
* language governing permissions and limitations under the License.
|
10 |
*
|
10 |
*
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.preferences;
|
14 |
package org.openconcerto.erp.preferences;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
16 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
17 |
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
|
17 |
import org.openconcerto.erp.core.customerrelationship.customer.report.FicheClientXmlSheet;
|
18 |
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
|
18 |
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
|
19 |
import org.openconcerto.erp.core.finance.accounting.report.BalanceSheet;
|
19 |
import org.openconcerto.erp.core.finance.accounting.report.BalanceSheet;
|
20 |
import org.openconcerto.erp.core.finance.accounting.report.GrandLivreSheetXML;
|
20 |
import org.openconcerto.erp.core.finance.accounting.report.GrandLivreSheetXML;
|
21 |
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheetXML;
|
21 |
import org.openconcerto.erp.core.finance.accounting.report.JournauxSheetXML;
|
22 |
import org.openconcerto.erp.core.humanresources.payroll.report.EtatChargesPayeSheet;
|
22 |
import org.openconcerto.erp.core.humanresources.payroll.report.EtatChargesPayeSheet;
|
23 |
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
|
23 |
import org.openconcerto.erp.core.humanresources.payroll.report.FichePayeSheetXML;
|
24 |
import org.openconcerto.erp.core.humanresources.payroll.report.LivrePayeSheet;
|
24 |
import org.openconcerto.erp.core.humanresources.payroll.report.LivrePayeSheet;
|
25 |
import org.openconcerto.erp.core.sales.invoice.report.ListeVenteXmlSheet;
|
25 |
import org.openconcerto.erp.core.sales.invoice.report.ListeVenteXmlSheet;
|
26 |
import org.openconcerto.erp.core.sales.invoice.report.VenteComptoirSheet;
|
26 |
import org.openconcerto.erp.core.sales.invoice.report.VenteComptoirSheet;
|
27 |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
|
27 |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureXmlSheet;
|
28 |
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
|
28 |
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet;
|
29 |
import org.openconcerto.erp.core.sales.quote.report.DevisXmlSheet;
|
29 |
import org.openconcerto.erp.core.sales.quote.report.DevisXmlSheet;
|
30 |
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
|
30 |
import org.openconcerto.erp.core.sales.shipment.report.BonLivraisonXmlSheet;
|
31 |
import org.openconcerto.erp.core.supplychain.order.element.DemandePrixSheetXML;
|
31 |
import org.openconcerto.erp.core.supplychain.order.element.DemandePrixSheetXML;
|
32 |
import org.openconcerto.erp.generationDoc.AbstractLocalTemplateProvider;
|
32 |
import org.openconcerto.erp.generationDoc.AbstractLocalTemplateProvider;
|
33 |
import org.openconcerto.erp.generationDoc.DefaultCloudTemplateProvider;
|
33 |
import org.openconcerto.erp.generationDoc.DefaultCloudTemplateProvider;
|
34 |
import org.openconcerto.erp.generationDoc.DefaultLocalTemplateProvider;
|
34 |
import org.openconcerto.erp.generationDoc.DefaultLocalTemplateProvider;
|
35 |
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
|
35 |
import org.openconcerto.erp.generationDoc.DocumentLocalStorageManager;
|
36 |
import org.openconcerto.erp.generationDoc.SheetXml;
|
36 |
import org.openconcerto.erp.generationDoc.SheetXml;
|
37 |
import org.openconcerto.erp.generationDoc.TemplateManager;
|
37 |
import org.openconcerto.erp.generationDoc.TemplateManager;
|
38 |
import org.openconcerto.erp.generationDoc.gestcomm.AvoirClientXmlSheet;
|
38 |
import org.openconcerto.erp.generationDoc.gestcomm.AvoirClientXmlSheet;
|
39 |
import org.openconcerto.erp.generationDoc.gestcomm.AvoirFournisseurXmlSheet;
|
39 |
import org.openconcerto.erp.generationDoc.gestcomm.AvoirFournisseurXmlSheet;
|
40 |
import org.openconcerto.erp.generationDoc.gestcomm.BonReceptionXmlSheet;
|
40 |
import org.openconcerto.erp.generationDoc.gestcomm.BonReceptionXmlSheet;
|
41 |
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
|
41 |
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
|
42 |
import org.openconcerto.erp.generationDoc.gestcomm.CourrierClientSheet;
|
42 |
import org.openconcerto.erp.generationDoc.gestcomm.CourrierClientSheet;
|
43 |
import org.openconcerto.erp.generationDoc.gestcomm.EtatVentesXmlSheet;
|
43 |
import org.openconcerto.erp.generationDoc.gestcomm.EtatVentesXmlSheet;
|
44 |
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet;
|
44 |
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet;
|
45 |
import org.openconcerto.erp.generationDoc.gestcomm.FicheArticleXmlSheet;
|
45 |
import org.openconcerto.erp.generationDoc.gestcomm.FicheArticleXmlSheet;
|
46 |
import org.openconcerto.erp.generationDoc.gestcomm.FicheRelanceSheet;
|
46 |
import org.openconcerto.erp.generationDoc.gestcomm.FicheRelanceSheet;
|
47 |
import org.openconcerto.erp.generationDoc.gestcomm.PointageXmlSheet;
|
47 |
import org.openconcerto.erp.generationDoc.gestcomm.PointageXmlSheet;
|
48 |
import org.openconcerto.erp.generationDoc.gestcomm.RelanceSheet;
|
48 |
import org.openconcerto.erp.generationDoc.gestcomm.RelanceSheet;
|
49 |
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeEmisSheet;
|
49 |
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeEmisSheet;
|
50 |
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeSheet;
|
50 |
import org.openconcerto.erp.generationDoc.gestcomm.ReleveChequeSheet;
|
51 |
import org.openconcerto.sql.Configuration;
|
51 |
import org.openconcerto.sql.Configuration;
|
52 |
import org.openconcerto.sql.model.SQLRow;
|
52 |
import org.openconcerto.sql.model.SQLRow;
|
53 |
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
|
53 |
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
|
54 |
import org.openconcerto.ui.preferences.TemplateProps;
|
54 |
import org.openconcerto.ui.preferences.TemplateProps;
|
55 |
import org.openconcerto.utils.StreamUtils;
|
55 |
import org.openconcerto.utils.StreamUtils;
|
- |
|
56 |
import org.openconcerto.utils.prog.VMLauncher;
|
56 |
|
57 |
|
57 |
import java.io.File;
|
58 |
import java.io.File;
|
58 |
import java.io.IOException;
|
59 |
import java.io.IOException;
|
59 |
import java.io.InputStream;
|
60 |
import java.io.InputStream;
|
60 |
|
61 |
|
61 |
import javax.swing.JOptionPane;
|
62 |
import javax.swing.JOptionPane;
|
62 |
|
63 |
|
63 |
public class TemplateNXProps extends TemplateProps {
|
64 |
public class TemplateNXProps extends TemplateProps {
|
64 |
|
65 |
|
65 |
private static final String societeBaseName = ((ComptaPropsConfiguration) Configuration.getInstance()).getSocieteBaseName();
|
66 |
private static final String societeBaseName = ((ComptaPropsConfiguration) Configuration.getInstance()).getSocieteBaseName();
|
66 |
|
67 |
|
67 |
@Override
|
68 |
@Override
|
68 |
protected String getPropsFileName() {
|
69 |
protected String getPropsFileName() {
|
69 |
final File f = Configuration.getInstance().getConfDir();
|
70 |
final File f = Configuration.getInstance().getConfDir();
|
70 |
final File f2 = new File(f, "Configuration" + File.separator + "Template.properties");
|
71 |
final File f2 = new File(f, "Configuration" + File.separator + "Template.properties");
|
71 |
|
72 |
|
72 |
if (!f2.exists()) {
|
73 |
if (!f2.exists()) {
|
73 |
final InputStream fConf = ComptaBasePropsConfiguration.getStreamStatic("/Configuration/Template.properties");
|
74 |
final InputStream fConf = ComptaBasePropsConfiguration.getStreamStatic("/Configuration/Template.properties");
|
74 |
if (fConf != null) {
|
75 |
if (fConf != null) {
|
75 |
try {
|
76 |
try {
|
76 |
StreamUtils.copy(fConf, f2);
|
77 |
StreamUtils.copy(fConf, f2);
|
77 |
fConf.close();
|
78 |
fConf.close();
|
78 |
} catch (IOException e) {
|
79 |
} catch (IOException e) {
|
79 |
JOptionPane.showMessageDialog(null,
|
80 |
JOptionPane.showMessageDialog(null,
|
80 |
"Impossible de copier le fichier de configuration de l'emplacement des modéles\ndepuis le serveur, veuillez définir l'emplacement des modéles manuellement.");
|
81 |
"Impossible de copier le fichier de configuration de l'emplacement des modéles\ndepuis le serveur, veuillez définir l'emplacement des modéles manuellement.");
|
81 |
e.printStackTrace();
|
82 |
e.printStackTrace();
|
82 |
}
|
83 |
}
|
83 |
}
|
84 |
}
|
84 |
}
|
85 |
}
|
85 |
|
86 |
|
86 |
if (f2.exists()) {
|
87 |
if (f2.exists()) {
|
87 |
return f2.getAbsolutePath();
|
88 |
return f2.getAbsolutePath();
|
88 |
} else {
|
89 |
} else {
|
89 |
try {
|
90 |
try {
|
90 |
f2.getParentFile().mkdirs();
|
91 |
f2.getParentFile().mkdirs();
|
91 |
f2.createNewFile();
|
92 |
f2.createNewFile();
|
92 |
} catch (IOException e) {
|
93 |
} catch (IOException e) {
|
93 |
System.err.println(f2);
|
94 |
System.err.println(f2);
|
94 |
e.printStackTrace();
|
95 |
e.printStackTrace();
|
95 |
}
|
96 |
}
|
96 |
return f2.getAbsolutePath();
|
97 |
return f2.getAbsolutePath();
|
97 |
}
|
98 |
}
|
98 |
}
|
99 |
}
|
99 |
|
100 |
|
100 |
@Override
|
101 |
@Override
|
101 |
public String getPropertySuffix() {
|
102 |
public String getPropertySuffix() {
|
102 |
return societeBaseName;
|
103 |
return societeBaseName;
|
103 |
}
|
104 |
}
|
104 |
|
105 |
|
105 |
@Override
|
106 |
@Override
|
106 |
public String getDefaultStringValue() {
|
107 |
public String getDefaultStringValue() {
|
107 |
|
108 |
|
108 |
final Configuration conf = ComptaPropsConfiguration.getInstance();
|
109 |
final Configuration conf = ComptaPropsConfiguration.getInstance();
|
109 |
final SQLRow rowSociete = ((ComptaPropsConfiguration) conf).getRowSociete();
|
110 |
final SQLRow rowSociete = ((ComptaPropsConfiguration) conf).getRowSociete();
|
110 |
return conf.getWD().getAbsolutePath() + File.separator + rowSociete.getString("NOM") + "-" + rowSociete.getID();
|
111 |
return conf.getWD().getAbsolutePath() + File.separator + rowSociete.getString("NOM") + "-" + rowSociete.getID();
|
111 |
}
|
112 |
}
|
112 |
|
113 |
|
113 |
public void initDocumentLocalStorage() {
|
114 |
public void initDocumentLocalStorage() {
|
114 |
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
|
115 |
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
|
115 |
String propertyDefaultDirectory = getProperty(SheetXml.DEFAULT_PROPERTY_NAME + "OO");
|
116 |
String propertyDefaultDirectory = getProperty(SheetXml.DEFAULT_PROPERTY_NAME + "OO");
|
116 |
if (propertyDefaultDirectory == null) {
|
117 |
if (propertyDefaultDirectory == null) {
|
117 |
System.out.println("Warning: no default directory stored for document output");
|
118 |
System.out.println("Warning: no default directory stored for document output");
|
118 |
propertyDefaultDirectory = getDefaultStringValue();
|
119 |
propertyDefaultDirectory = getDefaultStringValue();
|
119 |
}
|
120 |
}
|
120 |
storage.setDocumentDefaultDirectory(new File(propertyDefaultDirectory));
|
121 |
storage.setDocumentDefaultDirectory(new File(propertyDefaultDirectory));
|
121 |
String propertyDefaultPDFDirectory = getProperty(SheetXml.DEFAULT_PROPERTY_NAME + "PDF");
|
122 |
String propertyDefaultPDFDirectory = getProperty(SheetXml.DEFAULT_PROPERTY_NAME + "PDF");
|
122 |
if (propertyDefaultPDFDirectory == null) {
|
123 |
if (propertyDefaultPDFDirectory == null) {
|
123 |
System.out.println("Warning: no default directory stored for PFD output");
|
124 |
System.out.println("Warning: no default directory stored for PFD output");
|
124 |
propertyDefaultPDFDirectory = propertyDefaultDirectory;
|
125 |
propertyDefaultPDFDirectory = propertyDefaultDirectory;
|
125 |
}
|
126 |
}
|
126 |
|
127 |
|
127 |
final String propertyAtt = getProperty(AttachmentSQLElement.DIRECTORY_PREFS);
|
128 |
final String propertyAtt = getProperty(AttachmentSQLElement.DIRECTORY_PREFS);
|
128 |
if (propertyAtt != null && propertyAtt.trim().length() > 0) {
|
129 |
if (propertyAtt != null && propertyAtt.trim().length() > 0) {
|
129 |
storage.addDocumentDirectory(AttachmentSQLElement.DIRECTORY_PREFS, new File(propertyAtt));
|
130 |
storage.addDocumentDirectory(AttachmentSQLElement.DIRECTORY_PREFS, new File(propertyAtt));
|
130 |
}
|
131 |
}
|
131 |
|
132 |
|
132 |
storage.setPDFDefaultDirectory(new File(propertyDefaultPDFDirectory));
|
133 |
storage.setPDFDefaultDirectory(new File(propertyDefaultPDFDirectory));
|
133 |
|
134 |
|
134 |
register(DemandePrixSheetXML.TEMPLATE_ID, DemandePrixSheetXML.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("DEMANDE_PRIX"));
|
135 |
register(DemandePrixSheetXML.TEMPLATE_ID, DemandePrixSheetXML.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("DEMANDE_PRIX"));
|
135 |
register(DevisXmlSheet.TEMPLATE_ID, DevisXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("DEVIS"));
|
136 |
register(DevisXmlSheet.TEMPLATE_ID, DevisXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("DEVIS"));
|
136 |
register(VenteFactureXmlSheet.TEMPLATE_ID, VenteFactureXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_FACTURE"));
|
137 |
register(VenteFactureXmlSheet.TEMPLATE_ID, VenteFactureXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_FACTURE"));
|
- |
|
138 |
register(VenteFactureXmlSheet.TEMPLATE_ID + VenteFactureXmlSheet.TEMPLATE_SITUATION_SUFFIX, VenteFactureXmlSheet.TEMPLATE_PROPERTY_NAME,
|
- |
|
139 |
AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_FACTURE") + " " + VenteFactureXmlSheet.TEMPLATE_SITUATION_SUFFIX);
|
137 |
register(CommandeClientXmlSheet.TEMPLATE_ID, CommandeClientXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE_CLIENT"));
|
140 |
register(CommandeClientXmlSheet.TEMPLATE_ID, CommandeClientXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE_CLIENT"));
|
138 |
register(BonLivraisonXmlSheet.TEMPLATE_ID, BonLivraisonXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("BON_DE_LIVRAISON"));
|
141 |
register(BonLivraisonXmlSheet.TEMPLATE_ID, BonLivraisonXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("BON_DE_LIVRAISON"));
|
139 |
register(AvoirClientXmlSheet.TEMPLATE_ID, AvoirClientXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("AVOIR_CLIENT"));
|
142 |
register(AvoirClientXmlSheet.TEMPLATE_ID, AvoirClientXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("AVOIR_CLIENT"));
|
140 |
register(AvoirFournisseurXmlSheet.TEMPLATE_ID, AvoirFournisseurXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("AVOIR_FOURNISSEUR"));
|
143 |
register(AvoirFournisseurXmlSheet.TEMPLATE_ID, AvoirFournisseurXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("AVOIR_FOURNISSEUR"));
|
141 |
register(BonReceptionXmlSheet.TEMPLATE_ID, BonReceptionXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("BON_RECEPTION"));
|
144 |
register(BonReceptionXmlSheet.TEMPLATE_ID, BonReceptionXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("BON_RECEPTION"));
|
142 |
register(FactureFournisseurXmlSheet.TEMPLATE_ID, FactureFournisseurXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("FACTURE_FOURNISSEUR"));
|
145 |
register(FactureFournisseurXmlSheet.TEMPLATE_ID, FactureFournisseurXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("FACTURE_FOURNISSEUR"));
|
143 |
register(CommandeXmlSheet.TEMPLATE_ID, CommandeXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE"));
|
146 |
register(CommandeXmlSheet.TEMPLATE_ID, CommandeXmlSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE"));
|
144 |
register(FicheArticleXmlSheet.TEMPLATE_ID, FicheArticleXmlSheet.TEMPLATE_PROPERTY_NAME, "Fiche article");
|
147 |
register(FicheArticleXmlSheet.TEMPLATE_ID, FicheArticleXmlSheet.TEMPLATE_PROPERTY_NAME, "Fiche article");
|
145 |
register(EtatVentesXmlSheet.TEMPLATE_ID, EtatVentesXmlSheet.TEMPLATE_PROPERTY_NAME, null);
|
148 |
register(EtatVentesXmlSheet.TEMPLATE_ID, EtatVentesXmlSheet.TEMPLATE_PROPERTY_NAME, null);
|
146 |
register(FicheClientXmlSheet.TEMPLATE_ID, FicheClientXmlSheet.TEMPLATE_PROPERTY_NAME, "Fiche client");
|
149 |
register(FicheClientXmlSheet.TEMPLATE_ID, FicheClientXmlSheet.TEMPLATE_PROPERTY_NAME, "Fiche client");
|
147 |
register(FicheRelanceSheet.TEMPLATE_ID, FicheRelanceSheet.TEMPLATE_PROPERTY_NAME, null);
|
150 |
register(FicheRelanceSheet.TEMPLATE_ID, FicheRelanceSheet.TEMPLATE_PROPERTY_NAME, null);
|
148 |
register(ReleveChequeSheet.TEMPLATE_ID, ReleveChequeSheet.TEMPLATE_PROPERTY_NAME, null);
|
151 |
register(ReleveChequeSheet.TEMPLATE_ID, ReleveChequeSheet.TEMPLATE_PROPERTY_NAME, null);
|
149 |
register(ListeVenteXmlSheet.TEMPLATE_ID, ListeVenteXmlSheet.TEMPLATE_PROPERTY_NAME, null);
|
152 |
register(ListeVenteXmlSheet.TEMPLATE_ID, ListeVenteXmlSheet.TEMPLATE_PROPERTY_NAME, null);
|
150 |
register(BalanceSheet.TEMPLATE_ID, BalanceSheet.TEMPLATE_PROPERTY_NAME, BalanceSheet.TEMPLATE_ID);
|
153 |
register(BalanceSheet.TEMPLATE_ID, BalanceSheet.TEMPLATE_PROPERTY_NAME, BalanceSheet.TEMPLATE_ID);
|
151 |
register(GrandLivreSheetXML.TEMPLATE_ID, GrandLivreSheetXML.TEMPLATE_PROPERTY_NAME, GrandLivreSheetXML.TEMPLATE_ID);
|
154 |
register(GrandLivreSheetXML.TEMPLATE_ID, GrandLivreSheetXML.TEMPLATE_PROPERTY_NAME, GrandLivreSheetXML.TEMPLATE_ID);
|
152 |
register(JournauxSheetXML.TEMPLATE_ID, JournauxSheetXML.TEMPLATE_PROPERTY_NAME, JournauxSheetXML.TEMPLATE_ID);
|
155 |
register(JournauxSheetXML.TEMPLATE_ID, JournauxSheetXML.TEMPLATE_PROPERTY_NAME, JournauxSheetXML.TEMPLATE_ID);
|
153 |
register(EtatChargesPayeSheet.TEMPLATE_ID, EtatChargesPayeSheet.TEMPLATE_PROPERTY_NAME, "Etat des charges");
|
156 |
register(EtatChargesPayeSheet.TEMPLATE_ID, EtatChargesPayeSheet.TEMPLATE_PROPERTY_NAME, "Etat des charges");
|
154 |
register(FichePayeSheetXML.TEMPLATE_ID, FichePayeSheetXML.TEMPLATE_PROPERTY_NAME, "Fiche paye");
|
157 |
register(FichePayeSheetXML.TEMPLATE_ID, FichePayeSheetXML.TEMPLATE_PROPERTY_NAME, "Fiche paye");
|
155 |
register(LivrePayeSheet.TEMPLATE_ID, LivrePayeSheet.TEMPLATE_PROPERTY_NAME, "Livre paye");
|
158 |
register(LivrePayeSheet.TEMPLATE_ID, LivrePayeSheet.TEMPLATE_PROPERTY_NAME, "Livre paye");
|
156 |
register(CourrierClientSheet.TEMPLATE_ID, CourrierClientSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE"));
|
159 |
register(CourrierClientSheet.TEMPLATE_ID, CourrierClientSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("COMMANDE"));
|
157 |
register(PointageXmlSheet.TEMPLATE_ID, PointageXmlSheet.TEMPLATE_PROPERTY_NAME, null);
|
160 |
register(PointageXmlSheet.TEMPLATE_ID, PointageXmlSheet.TEMPLATE_PROPERTY_NAME, null);
|
158 |
register(RelanceSheet.TEMPLATE_ID, RelanceSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("RELANCE"));
|
161 |
register(RelanceSheet.TEMPLATE_ID, RelanceSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("RELANCE"));
|
159 |
register(VenteComptoirSheet.TEMPLATE_ID, VenteComptoirSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_COMPTOIR"));
|
162 |
register(VenteComptoirSheet.TEMPLATE_ID, VenteComptoirSheet.TEMPLATE_PROPERTY_NAME, AbstractGenerationDocumentPreferencePanel.getLabelFromTable("SAISIE_VENTE_COMPTOIR"));
|
160 |
register(ReleveChequeEmisSheet.TEMPLATE_ID, ReleveChequeEmisSheet.TEMPLATE_PROPERTY_NAME, null);
|
163 |
register(ReleveChequeEmisSheet.TEMPLATE_ID, ReleveChequeEmisSheet.TEMPLATE_PROPERTY_NAME, null);
|
161 |
storage.dump();
|
164 |
storage.dump();
|
162 |
|
165 |
|
163 |
}
|
166 |
}
|
164 |
|
167 |
|
165 |
public void preventecRegister(String path, String templateId, String defaultSubFolder) {
|
168 |
public void preventecRegister(String path, String templateId, String defaultSubFolder) {
|
166 |
if (templateId == null) {
|
169 |
if (templateId == null) {
|
167 |
throw new IllegalArgumentException("null template id");
|
170 |
throw new IllegalArgumentException("null template id");
|
168 |
}
|
171 |
}
|
169 |
|
172 |
|
170 |
if (TemplateManager.getInstance().isKnwonTemplate(templateId)) {
|
173 |
if (TemplateManager.getInstance().isKnwonTemplate(templateId)) {
|
171 |
System.err.println("Warning: registering known template id : " + templateId);
|
174 |
System.err.println("Warning: registering known template id : " + templateId);
|
172 |
}
|
175 |
}
|
173 |
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
|
176 |
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
|
174 |
if (defaultSubFolder != null) {
|
177 |
if (defaultSubFolder != null) {
|
175 |
storage.addDocumentDirectory(templateId, new File(path, defaultSubFolder));
|
178 |
storage.addDocumentDirectory(templateId, new File(path, defaultSubFolder));
|
176 |
storage.addPDFDirectory(templateId, new File(path, defaultSubFolder));
|
179 |
storage.addPDFDirectory(templateId, new File(path, defaultSubFolder));
|
177 |
} else {
|
180 |
} else {
|
178 |
storage.addDocumentDirectory(templateId, new File(path));
|
181 |
storage.addDocumentDirectory(templateId, new File(path));
|
179 |
storage.addPDFDirectory(templateId, new File(path));
|
182 |
storage.addPDFDirectory(templateId, new File(path));
|
180 |
}
|
183 |
}
|
181 |
}
|
184 |
}
|
182 |
|
185 |
|
183 |
public void register(String templateId, String propertyBaseName, String defaultSubFolder) {
|
186 |
public void register(String templateId, String propertyBaseName, String defaultSubFolder) {
|
184 |
if (templateId == null) {
|
187 |
if (templateId == null) {
|
185 |
throw new IllegalArgumentException("null template id");
|
188 |
throw new IllegalArgumentException("null template id");
|
186 |
}
|
189 |
}
|
187 |
if (propertyBaseName == null) {
|
190 |
if (propertyBaseName == null) {
|
188 |
throw new IllegalArgumentException("null propertyBaseName");
|
191 |
throw new IllegalArgumentException("null propertyBaseName");
|
189 |
}
|
192 |
}
|
190 |
if (TemplateManager.getInstance().isKnwonTemplate(templateId)) {
|
193 |
if (TemplateManager.getInstance().isKnwonTemplate(templateId)) {
|
191 |
System.err.println("Warning: registering known template id : " + templateId + " with property base name: " + propertyBaseName);
|
194 |
System.err.println("Warning: registering known template id : " + templateId + " with property base name: " + propertyBaseName);
|
192 |
}
|
195 |
}
|
193 |
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
|
196 |
final DocumentLocalStorageManager storage = DocumentLocalStorageManager.getInstance();
|
194 |
|
197 |
|
195 |
final String propertyOO = getProperty(propertyBaseName + "OO");
|
198 |
final String propertyOO = getProperty(propertyBaseName + "OO");
|
196 |
if (propertyOO != null) {
|
199 |
if (propertyOO != null) {
|
197 |
storage.addDocumentDirectory(templateId, new File(propertyOO));
|
200 |
storage.addDocumentDirectory(templateId, new File(propertyOO));
|
198 |
} else {
|
201 |
} else {
|
199 |
if (defaultSubFolder != null && defaultSubFolder.trim().length() > 0) {
|
202 |
if (defaultSubFolder != null && defaultSubFolder.trim().length() > 0) {
|
200 |
storage.addDocumentDirectory(templateId, new File(storage.getDocumentOutputDirectory("default"), defaultSubFolder));
|
203 |
storage.addDocumentDirectory(templateId, new File(storage.getDocumentOutputDirectory("default"), defaultSubFolder));
|
201 |
}
|
204 |
}
|
202 |
}
|
205 |
}
|
203 |
final String propertyPDF = getProperty(propertyBaseName + "PDF");
|
206 |
final String propertyPDF = getProperty(propertyBaseName + "PDF");
|
204 |
if (propertyPDF != null) {
|
207 |
if (propertyPDF != null) {
|
205 |
storage.addPDFDirectory(templateId, new File(propertyPDF));
|
208 |
storage.addPDFDirectory(templateId, new File(propertyPDF));
|
206 |
} else {
|
209 |
} else {
|
207 |
if (defaultSubFolder != null && defaultSubFolder.trim().length() > 0) {
|
210 |
if (defaultSubFolder != null && defaultSubFolder.trim().length() > 0) {
|
208 |
storage.addDocumentDirectory(templateId, new File(storage.getPDFOutputDirectory("default"), defaultSubFolder));
|
211 |
storage.addDocumentDirectory(templateId, new File(storage.getPDFOutputDirectory("default"), defaultSubFolder));
|
209 |
}
|
212 |
}
|
210 |
}
|
213 |
}
|
211 |
}
|
214 |
}
|
212 |
|
215 |
|
213 |
synchronized public static TemplateProps getInstance() {
|
216 |
synchronized public static TemplateProps getInstance() {
|
214 |
if (instance == null) {
|
217 |
if (instance == null) {
|
215 |
instance = new TemplateNXProps();
|
218 |
instance = new TemplateNXProps();
|
216 |
((TemplateNXProps) instance).initDocumentLocalStorage();
|
219 |
((TemplateNXProps) instance).initDocumentLocalStorage();
|
217 |
((TemplateNXProps) instance).initDefaulTemplateProvider();
|
220 |
((TemplateNXProps) instance).initDefaulTemplateProvider();
|
218 |
}
|
221 |
}
|
219 |
return instance;
|
222 |
return instance;
|
220 |
}
|
223 |
}
|
221 |
|
224 |
|
222 |
private void initDefaulTemplateProvider() {
|
225 |
private void initDefaulTemplateProvider() {
|
223 |
final String property = getProperty("LocationTemplate");
|
226 |
final String property = getProperty("LocationTemplate");
|
224 |
final AbstractLocalTemplateProvider provider;
|
227 |
final AbstractLocalTemplateProvider provider;
|
225 |
|
228 |
|
226 |
final ComptaPropsConfiguration configuration = (ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance();
|
229 |
final ComptaPropsConfiguration configuration = (ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance();
|
227 |
if (!configuration.isOnCloud()) {
|
230 |
if (!configuration.isOnCloud()) {
|
228 |
provider = new DefaultLocalTemplateProvider();
|
231 |
provider = new DefaultLocalTemplateProvider();
|
229 |
if (property != null) {
|
232 |
if (property != null) {
|
230 |
File storage = new File(property);
|
233 |
File storage = new File(property);
|
231 |
((DefaultLocalTemplateProvider) provider).setBaseDirectory(storage);
|
234 |
((DefaultLocalTemplateProvider) provider).setBaseDirectory(storage);
|
- |
|
235 |
} else if (VMLauncher.getJPackageAppDir() != null) {
|
- |
|
236 |
((DefaultLocalTemplateProvider) provider).setBaseDirectory(new File(VMLauncher.getJPackageAppDir(), "Configuration/Template/Default"));
|
232 |
}
|
237 |
}
|
233 |
} else {
|
238 |
} else {
|
234 |
provider = new DefaultCloudTemplateProvider(configuration.getSocieteID());
|
239 |
provider = new DefaultCloudTemplateProvider(configuration.getSocieteID());
|
235 |
}
|
240 |
}
|
236 |
|
241 |
|
237 |
TemplateManager.getInstance().setDefaultProvider(provider);
|
242 |
TemplateManager.getInstance().setDefaultProvider(provider);
|
238 |
TemplateManager.getInstance().dump();
|
243 |
TemplateManager.getInstance().dump();
|
239 |
}
|
244 |
}
|
240 |
}
|
245 |
}
|