1 |
package org.openconcerto.modules.badge;
|
1 |
package org.openconcerto.modules.badge;
|
2 |
|
2 |
|
3 |
import java.awt.Component;
|
3 |
import java.awt.Component;
|
4 |
import java.io.File;
|
4 |
import java.io.File;
|
5 |
import java.io.IOException;
|
5 |
import java.io.IOException;
|
6 |
import java.sql.SQLException;
|
6 |
import java.sql.SQLException;
|
7 |
import java.text.DateFormat;
|
7 |
import java.text.DateFormat;
|
8 |
import java.text.Normalizer;
|
8 |
import java.text.Normalizer;
|
9 |
import java.text.Normalizer.Form;
|
9 |
import java.text.Normalizer.Form;
|
10 |
import java.text.SimpleDateFormat;
|
10 |
import java.text.SimpleDateFormat;
|
11 |
import java.util.ArrayList;
|
11 |
import java.util.ArrayList;
|
12 |
import java.util.Arrays;
|
12 |
import java.util.Arrays;
|
13 |
import java.util.Calendar;
|
13 |
import java.util.Calendar;
|
14 |
import java.util.Date;
|
14 |
import java.util.Date;
|
15 |
import java.util.HashMap;
|
15 |
import java.util.HashMap;
|
16 |
import java.util.HashSet;
|
16 |
import java.util.HashSet;
|
17 |
import java.util.List;
|
17 |
import java.util.List;
|
18 |
import java.util.Map;
|
18 |
import java.util.Map;
|
19 |
import java.util.Set;
|
19 |
import java.util.Set;
|
20 |
import java.util.regex.Matcher;
|
20 |
import java.util.regex.Matcher;
|
21 |
import java.util.regex.Pattern;
|
21 |
import java.util.regex.Pattern;
|
22 |
|
22 |
|
23 |
import javax.swing.Action;
|
23 |
import javax.swing.Action;
|
24 |
import javax.swing.Icon;
|
24 |
import javax.swing.Icon;
|
25 |
import javax.swing.JFrame;
|
25 |
import javax.swing.JFrame;
|
26 |
import javax.swing.JTable;
|
26 |
import javax.swing.JTable;
|
27 |
import javax.swing.table.DefaultTableCellRenderer;
|
27 |
import javax.swing.table.DefaultTableCellRenderer;
|
28 |
|
28 |
|
29 |
import org.openconcerto.erp.action.CreateFrameAbstractAction;
|
29 |
import org.openconcerto.erp.action.CreateFrameAbstractAction;
|
30 |
import org.openconcerto.erp.action.PreferencesAction;
|
- |
|
31 |
import org.openconcerto.erp.config.Gestion;
|
- |
|
32 |
import org.openconcerto.erp.config.MainFrame;
|
30 |
import org.openconcerto.erp.config.MainFrame;
|
33 |
import org.openconcerto.erp.core.common.element.AdresseSQLElement;
|
31 |
import org.openconcerto.erp.core.common.element.AdresseSQLElement;
|
34 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
32 |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
|
35 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
33 |
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
|
36 |
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
|
34 |
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactSQLElement;
|
37 |
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
|
35 |
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
|
38 |
import org.openconcerto.erp.modules.AbstractModule;
|
36 |
import org.openconcerto.erp.modules.AbstractModule;
|
39 |
import org.openconcerto.erp.modules.ComponentsContext;
|
37 |
import org.openconcerto.erp.modules.ComponentsContext;
|
40 |
import org.openconcerto.erp.modules.DBContext;
|
38 |
import org.openconcerto.erp.modules.DBContext;
|
41 |
import org.openconcerto.erp.modules.MenuContext;
|
39 |
import org.openconcerto.erp.modules.MenuContext;
|
42 |
import org.openconcerto.erp.modules.ModuleFactory;
|
40 |
import org.openconcerto.erp.modules.ModuleFactory;
|
43 |
import org.openconcerto.erp.modules.ModuleManager;
|
- |
|
44 |
import org.openconcerto.erp.modules.ModulePackager;
|
- |
|
45 |
import org.openconcerto.erp.modules.ModulePreferencePanel;
|
41 |
import org.openconcerto.erp.modules.ModulePreferencePanel;
|
46 |
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
|
42 |
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
|
47 |
import org.openconcerto.erp.modules.ModuleVersion;
|
43 |
import org.openconcerto.erp.modules.ModuleVersion;
|
48 |
import org.openconcerto.erp.modules.RuntimeModuleFactory;
|
- |
|
49 |
import org.openconcerto.sql.Configuration;
|
44 |
import org.openconcerto.sql.Configuration;
|
50 |
import org.openconcerto.sql.element.SQLComponent;
|
45 |
import org.openconcerto.sql.element.SQLComponent;
|
51 |
import org.openconcerto.sql.element.SQLElement;
|
46 |
import org.openconcerto.sql.element.SQLElement;
|
52 |
import org.openconcerto.sql.element.SQLElementDirectory;
|
47 |
import org.openconcerto.sql.element.SQLElementDirectory;
|
53 |
import org.openconcerto.sql.element.UISQLComponent;
|
48 |
import org.openconcerto.sql.element.UISQLComponent;
|
- |
|
49 |
import org.openconcerto.sql.model.DBRoot;
|
54 |
import org.openconcerto.sql.model.SQLName;
|
50 |
import org.openconcerto.sql.model.SQLName;
|
55 |
import org.openconcerto.sql.model.SQLRow;
|
51 |
import org.openconcerto.sql.model.SQLRow;
|
56 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
52 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
57 |
import org.openconcerto.sql.model.SQLRowValues;
|
53 |
import org.openconcerto.sql.model.SQLRowValues;
|
58 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
54 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
59 |
import org.openconcerto.sql.model.SQLSyntax;
|
55 |
import org.openconcerto.sql.model.SQLSyntax;
|
60 |
import org.openconcerto.sql.model.SQLTable;
|
56 |
import org.openconcerto.sql.model.SQLTable;
|
61 |
import org.openconcerto.sql.model.Where;
|
57 |
import org.openconcerto.sql.model.Where;
|
62 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
58 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
63 |
import org.openconcerto.sql.view.FileDropHandler;
|
59 |
import org.openconcerto.sql.view.FileDropHandler;
|
64 |
import org.openconcerto.sql.view.IListFrame;
|
60 |
import org.openconcerto.sql.view.IListFrame;
|
65 |
import org.openconcerto.sql.view.IListPanel;
|
61 |
import org.openconcerto.sql.view.IListPanel;
|
66 |
import org.openconcerto.sql.view.list.IListe;
|
62 |
import org.openconcerto.sql.view.list.IListe;
|
67 |
import org.openconcerto.sql.view.list.RowAction;
|
63 |
import org.openconcerto.sql.view.list.RowAction;
|
68 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
64 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
69 |
import org.openconcerto.ui.PanelFrame;
|
65 |
import org.openconcerto.ui.PanelFrame;
|
70 |
import org.openconcerto.ui.group.Group;
|
66 |
import org.openconcerto.ui.group.Group;
|
71 |
import org.openconcerto.ui.group.LayoutHints;
|
67 |
import org.openconcerto.ui.group.LayoutHints;
|
72 |
import org.openconcerto.utils.FileUtils;
|
- |
|
73 |
import org.openconcerto.utils.ListMap;
|
68 |
import org.openconcerto.utils.ListMap;
|
74 |
import org.openconcerto.utils.PrefType;
|
69 |
import org.openconcerto.utils.PrefType;
|
75 |
import org.openconcerto.utils.StringUtils;
|
70 |
import org.openconcerto.utils.StringUtils;
|
76 |
import org.openconcerto.utils.cc.IClosure;
|
71 |
import org.openconcerto.utils.cc.IClosure;
|
77 |
|
72 |
|
78 |
public final class Module extends AbstractModule {
|
73 |
public final class Module extends AbstractModule {
|
79 |
|
74 |
|
80 |
private static final String CLIENT_ADH_FIELDNAME = "ID_ADHERENT";
|
75 |
private static final String CLIENT_ADH_FIELDNAME = "ID_ADHERENT";
|
81 |
private static final Pattern FIRST_NAME_PATTERN = Pattern.compile("([^0-9]*)([0-9]*).*");
|
76 |
private static final Pattern FIRST_NAME_PATTERN = Pattern.compile("([^0-9]*)([0-9]*).*");
|
82 |
public static final boolean HAS_CODE_IN_FIRST_NAME = Boolean.getBoolean("adherent.hasCodeInFirstName");
|
77 |
public static final boolean HAS_CODE_IN_FIRST_NAME = Boolean.getBoolean("adherent.hasCodeInFirstName");
|
83 |
|
78 |
|
84 |
public Module(ModuleFactory f) throws IOException {
|
79 |
public Module(ModuleFactory f) throws IOException {
|
85 |
super(f);
|
80 |
super(f);
|
86 |
|
81 |
|
87 |
}
|
82 |
}
|
88 |
|
83 |
|
89 |
@Override
|
84 |
@Override
|
90 |
protected void install(final DBContext ctxt) throws SQLException, IOException {
|
85 |
protected void install(final DBContext ctxt) throws SQLException, IOException {
|
91 |
super.install(ctxt);
|
86 |
super.install(ctxt);
|
92 |
final AdresseSQLElement addrElem = ctxt.getElementDirectory().getElement(AdresseSQLElement.class);
|
87 |
final AdresseSQLElement addrElem = ctxt.getElementDirectory().getElement(AdresseSQLElement.class);
|
93 |
|
88 |
|
94 |
final ModuleVersion dbVersion = ctxt.getLastInstalledVersion() == null ? ModuleVersion.MIN : ctxt.getLastInstalledVersion();
|
89 |
final ModuleVersion dbVersion = ctxt.getLastInstalledVersion() == null ? ModuleVersion.MIN : ctxt.getLastInstalledVersion();
|
95 |
if (dbVersion.getMerged() > this.getFactory().getVersion().getMerged())
|
90 |
if (dbVersion.getMerged() > this.getFactory().getVersion().getMerged())
|
96 |
throw new IllegalStateException("Cannot downgrade from " + dbVersion + " to " + this.getFactory());
|
91 |
throw new IllegalStateException("Cannot downgrade from " + dbVersion + " to " + this.getFactory());
|
97 |
if (dbVersion.getMerged() < ModuleVersion.getMerged(1, 0)) {
|
92 |
if (dbVersion.getMerged() < ModuleVersion.getMerged(1, 0)) {
|
98 |
// ENTREE
|
93 |
// ENTREE
|
99 |
final SQLCreateTable createTableEntree = ctxt.getCreateTable("ENTREE");
|
94 |
final SQLCreateTable createTableEntree = ctxt.getCreateTable("ENTREE");
|
100 |
createTableEntree.addDateAndTimeColumn("DATE");
|
95 |
createTableEntree.addDateAndTimeColumn("DATE");
|
101 |
createTableEntree.addVarCharColumn("NUMERO_CARTE", 256);
|
96 |
createTableEntree.addVarCharColumn("NUMERO_CARTE", 256);
|
102 |
createTableEntree.addVarCharColumn("ADHERENT", 512);
|
97 |
createTableEntree.addVarCharColumn("ADHERENT", 512);
|
103 |
createTableEntree.addVarCharColumn("MOTIF", 2048);
|
98 |
createTableEntree.addVarCharColumn("MOTIF", 2048);
|
104 |
createTableEntree.addColumn("ACCEPTE", "boolean");
|
99 |
createTableEntree.addColumn("ACCEPTE", "boolean");
|
105 |
|
100 |
|
106 |
// PLAGE
|
101 |
// PLAGE
|
107 |
final SQLCreateTable createTablePlage = ctxt.getCreateTable("PLAGE_HORAIRE");
|
102 |
final SQLCreateTable createTablePlage = ctxt.getCreateTable("PLAGE_HORAIRE");
|
108 |
createTablePlage.addVarCharColumn("NOM", 256);
|
103 |
createTablePlage.addVarCharColumn("NOM", 256);
|
109 |
createTablePlage.addColumn("DEBUT_1_LUNDI", "time");
|
104 |
createTablePlage.addColumn("DEBUT_1_LUNDI", "time");
|
110 |
createTablePlage.addColumn("DEBUT_1_MARDI", "time");
|
105 |
createTablePlage.addColumn("DEBUT_1_MARDI", "time");
|
111 |
createTablePlage.addColumn("DEBUT_1_MERCREDI", "time");
|
106 |
createTablePlage.addColumn("DEBUT_1_MERCREDI", "time");
|
112 |
createTablePlage.addColumn("DEBUT_1_JEUDI", "time");
|
107 |
createTablePlage.addColumn("DEBUT_1_JEUDI", "time");
|
113 |
createTablePlage.addColumn("DEBUT_1_VENDREDI", "time");
|
108 |
createTablePlage.addColumn("DEBUT_1_VENDREDI", "time");
|
114 |
createTablePlage.addColumn("DEBUT_1_SAMEDI", "time");
|
109 |
createTablePlage.addColumn("DEBUT_1_SAMEDI", "time");
|
115 |
createTablePlage.addColumn("DEBUT_1_DIMANCHE", "time");
|
110 |
createTablePlage.addColumn("DEBUT_1_DIMANCHE", "time");
|
116 |
|
111 |
|
117 |
createTablePlage.addColumn("DEBUT_2_LUNDI", "time");
|
112 |
createTablePlage.addColumn("DEBUT_2_LUNDI", "time");
|
118 |
createTablePlage.addColumn("DEBUT_2_MARDI", "time");
|
113 |
createTablePlage.addColumn("DEBUT_2_MARDI", "time");
|
119 |
createTablePlage.addColumn("DEBUT_2_MERCREDI", "time");
|
114 |
createTablePlage.addColumn("DEBUT_2_MERCREDI", "time");
|
120 |
createTablePlage.addColumn("DEBUT_2_JEUDI", "time");
|
115 |
createTablePlage.addColumn("DEBUT_2_JEUDI", "time");
|
121 |
createTablePlage.addColumn("DEBUT_2_VENDREDI", "time");
|
116 |
createTablePlage.addColumn("DEBUT_2_VENDREDI", "time");
|
122 |
createTablePlage.addColumn("DEBUT_2_SAMEDI", "time");
|
117 |
createTablePlage.addColumn("DEBUT_2_SAMEDI", "time");
|
123 |
createTablePlage.addColumn("DEBUT_2_DIMANCHE", "time");
|
118 |
createTablePlage.addColumn("DEBUT_2_DIMANCHE", "time");
|
124 |
|
119 |
|
125 |
createTablePlage.addColumn("DEBUT_3_LUNDI", "time");
|
120 |
createTablePlage.addColumn("DEBUT_3_LUNDI", "time");
|
126 |
createTablePlage.addColumn("DEBUT_3_MARDI", "time");
|
121 |
createTablePlage.addColumn("DEBUT_3_MARDI", "time");
|
127 |
createTablePlage.addColumn("DEBUT_3_MERCREDI", "time");
|
122 |
createTablePlage.addColumn("DEBUT_3_MERCREDI", "time");
|
128 |
createTablePlage.addColumn("DEBUT_3_JEUDI", "time");
|
123 |
createTablePlage.addColumn("DEBUT_3_JEUDI", "time");
|
129 |
createTablePlage.addColumn("DEBUT_3_VENDREDI", "time");
|
124 |
createTablePlage.addColumn("DEBUT_3_VENDREDI", "time");
|
130 |
createTablePlage.addColumn("DEBUT_3_SAMEDI", "time");
|
125 |
createTablePlage.addColumn("DEBUT_3_SAMEDI", "time");
|
131 |
createTablePlage.addColumn("DEBUT_3_DIMANCHE", "time");
|
126 |
createTablePlage.addColumn("DEBUT_3_DIMANCHE", "time");
|
132 |
|
127 |
|
133 |
createTablePlage.addColumn("FIN_1_LUNDI", "time");
|
128 |
createTablePlage.addColumn("FIN_1_LUNDI", "time");
|
134 |
createTablePlage.addColumn("FIN_1_MARDI", "time");
|
129 |
createTablePlage.addColumn("FIN_1_MARDI", "time");
|
135 |
createTablePlage.addColumn("FIN_1_MERCREDI", "time");
|
130 |
createTablePlage.addColumn("FIN_1_MERCREDI", "time");
|
136 |
createTablePlage.addColumn("FIN_1_JEUDI", "time");
|
131 |
createTablePlage.addColumn("FIN_1_JEUDI", "time");
|
137 |
createTablePlage.addColumn("FIN_1_VENDREDI", "time");
|
132 |
createTablePlage.addColumn("FIN_1_VENDREDI", "time");
|
138 |
createTablePlage.addColumn("FIN_1_SAMEDI", "time");
|
133 |
createTablePlage.addColumn("FIN_1_SAMEDI", "time");
|
139 |
createTablePlage.addColumn("FIN_1_DIMANCHE", "time");
|
134 |
createTablePlage.addColumn("FIN_1_DIMANCHE", "time");
|
140 |
|
135 |
|
141 |
createTablePlage.addColumn("FIN_2_LUNDI", "time");
|
136 |
createTablePlage.addColumn("FIN_2_LUNDI", "time");
|
142 |
createTablePlage.addColumn("FIN_2_MARDI", "time");
|
137 |
createTablePlage.addColumn("FIN_2_MARDI", "time");
|
143 |
createTablePlage.addColumn("FIN_2_MERCREDI", "time");
|
138 |
createTablePlage.addColumn("FIN_2_MERCREDI", "time");
|
144 |
createTablePlage.addColumn("FIN_2_JEUDI", "time");
|
139 |
createTablePlage.addColumn("FIN_2_JEUDI", "time");
|
145 |
createTablePlage.addColumn("FIN_2_VENDREDI", "time");
|
140 |
createTablePlage.addColumn("FIN_2_VENDREDI", "time");
|
146 |
createTablePlage.addColumn("FIN_2_SAMEDI", "time");
|
141 |
createTablePlage.addColumn("FIN_2_SAMEDI", "time");
|
147 |
createTablePlage.addColumn("FIN_2_DIMANCHE", "time");
|
142 |
createTablePlage.addColumn("FIN_2_DIMANCHE", "time");
|
148 |
|
143 |
|
149 |
createTablePlage.addColumn("FIN_3_LUNDI", "time");
|
144 |
createTablePlage.addColumn("FIN_3_LUNDI", "time");
|
150 |
createTablePlage.addColumn("FIN_3_MARDI", "time");
|
145 |
createTablePlage.addColumn("FIN_3_MARDI", "time");
|
151 |
createTablePlage.addColumn("FIN_3_MERCREDI", "time");
|
146 |
createTablePlage.addColumn("FIN_3_MERCREDI", "time");
|
152 |
createTablePlage.addColumn("FIN_3_JEUDI", "time");
|
147 |
createTablePlage.addColumn("FIN_3_JEUDI", "time");
|
153 |
createTablePlage.addColumn("FIN_3_VENDREDI", "time");
|
148 |
createTablePlage.addColumn("FIN_3_VENDREDI", "time");
|
154 |
createTablePlage.addColumn("FIN_3_SAMEDI", "time");
|
149 |
createTablePlage.addColumn("FIN_3_SAMEDI", "time");
|
155 |
createTablePlage.addColumn("FIN_3_DIMANCHE", "time");
|
150 |
createTablePlage.addColumn("FIN_3_DIMANCHE", "time");
|
156 |
|
151 |
|
157 |
// ADHERENT
|
152 |
// ADHERENT
|
158 |
final SQLCreateTable createTable = ctxt.getCreateTable("ADHERENT");
|
153 |
final SQLCreateTable createTable = ctxt.getCreateTable("ADHERENT");
|
159 |
|
154 |
|
160 |
createTable.addVarCharColumn("NUMERO_CARTE", 256);
|
155 |
createTable.addVarCharColumn("NUMERO_CARTE", 256);
|
161 |
createTable.addVarCharColumn("NOM", 256);
|
156 |
createTable.addVarCharColumn("NOM", 256);
|
162 |
|
157 |
|
163 |
createTable.addVarCharColumn("TEL", 256);
|
158 |
createTable.addVarCharColumn("TEL", 256);
|
164 |
createTable.addColumn("ACTIF", "boolean default false");
|
159 |
createTable.addColumn("ACTIF", "boolean default false");
|
165 |
createTable.addColumn("ADMIN", "boolean default false");
|
160 |
createTable.addColumn("ADMIN", "boolean default false");
|
166 |
createTable.addVarCharColumn("MAIL", 256);
|
161 |
createTable.addVarCharColumn("MAIL", 256);
|
167 |
createTable.addVarCharColumn("PRENOM", 256);
|
162 |
createTable.addVarCharColumn("PRENOM", 256);
|
168 |
createTable.addVarCharColumn("INFOS", 2048);
|
163 |
createTable.addVarCharColumn("INFOS", 2048);
|
169 |
createTable.addColumn("DATE_VALIDITE_INSCRIPTION", "date");
|
164 |
createTable.addColumn("DATE_VALIDITE_INSCRIPTION", "date");
|
170 |
createTable.addColumn("DATE_NAISSANCE", "date");
|
165 |
createTable.addColumn("DATE_NAISSANCE", "date");
|
171 |
|
166 |
|
172 |
createTable.addForeignColumn("ID_ADRESSE", addrElem.getTable());
|
167 |
createTable.addForeignColumn("ID_ADRESSE", addrElem.getTable());
|
173 |
createTable.addForeignColumn("ID_PLAGE_HORAIRE", new SQLName("PLAGE_HORAIRE"), SQLSyntax.ID_NAME, null);
|
168 |
createTable.addForeignColumn("ID_PLAGE_HORAIRE", new SQLName("PLAGE_HORAIRE"), SQLSyntax.ID_NAME, null);
|
174 |
}
|
169 |
}
|
175 |
// at least v1.0
|
170 |
// at least v1.0
|
176 |
|
171 |
|
177 |
if (dbVersion.getMerged() < ModuleVersion.getMerged(1, 1)) {
|
172 |
if (dbVersion.getMerged() < ModuleVersion.getMerged(1, 1)) {
|
178 |
// migrate from non-private
|
173 |
// migrate from non-private
|
179 |
final SQLTable adhT = ctxt.getRoot().getTable("ADHERENT");
|
174 |
final SQLTable adhT = ctxt.getRoot().getTable("ADHERENT");
|
180 |
final CustomerSQLElement clientElem = ctxt.getElementDirectory().getElement(CustomerSQLElement.class);
|
175 |
final CustomerSQLElement clientElem = ctxt.getElementDirectory().getElement(CustomerSQLElement.class);
|
181 |
final SQLTable clientT = clientElem.getTable();
|
176 |
final SQLTable clientT = clientElem.getTable();
|
182 |
ctxt.getAlterTable(clientT.getName()).addForeignColumn(CLIENT_ADH_FIELDNAME, adhT);
|
177 |
ctxt.getAlterTable(clientT.getName()).addForeignColumn(CLIENT_ADH_FIELDNAME, adhT);
|
183 |
// fill new field (no need to do anything in uninstall() since the field will be
|
178 |
// fill new field (no need to do anything in uninstall() since the field will be
|
184 |
// dropped and new clients shouldn't be dropped)
|
179 |
// dropped and new clients shouldn't be dropped)
|
185 |
if (adhT.getRowCount(false) > 0) {
|
180 |
if (adhT.getRowCount(false) > 0) {
|
186 |
ctxt.executeSQL();
|
181 |
ctxt.executeSQL();
|
187 |
this.setupElements(ctxt.getElementDirectory());
|
182 |
this.setupElements(ctxt.getElementDirectory());
|
188 |
// 1. fetch all clients
|
183 |
// 1. fetch all clients
|
189 |
final ListMap<String, SQLRow> clientByName = new ListMap<>();
|
184 |
final ListMap<String, SQLRow> clientByName = new ListMap<>();
|
190 |
final ListMap<String, SQLRow> clientByCode = new ListMap<>();
|
185 |
final ListMap<String, SQLRow> clientByCode = new ListMap<>();
|
191 |
for (final SQLRowValues clientR : SQLRowValuesListFetcher.create(new SQLRowValues(clientT).putNulls("NOM", "CODE")).fetch()) {
|
186 |
for (final SQLRowValues clientR : SQLRowValuesListFetcher.create(new SQLRowValues(clientT).putNulls("NOM", "CODE")).fetch()) {
|
192 |
final String normalized = normalize(clientR.getString("NOM"));
|
187 |
final String normalized = normalize(clientR.getString("NOM"));
|
193 |
clientByName.add(normalized, clientR.asRow());
|
188 |
clientByName.add(normalized, clientR.asRow());
|
194 |
clientByCode.add(clientR.getString("CODE"), clientR.asRow());
|
189 |
clientByCode.add(clientR.getString("CODE"), clientR.asRow());
|
195 |
}
|
190 |
}
|
196 |
// 2. for each ADHERENT, link it to a single matching CLIENT, or create a
|
191 |
// 2. for each ADHERENT, link it to a single matching CLIENT, or create a
|
197 |
// new one. Also fill CLIENT fields with duplicates from ADHERENT.
|
192 |
// new one. Also fill CLIENT fields with duplicates from ADHERENT.
|
198 |
// créer plutôt plus de clients : si besoin, fusion après coup.
|
193 |
// créer plutôt plus de clients : si besoin, fusion après coup.
|
199 |
final SQLRowValues adhToFetch = new SQLRowValues(adhT).putNulls("NOM", "PRENOM", "MAIL", "TEL", "DATE_NAISSANCE");
|
194 |
final SQLRowValues adhToFetch = new SQLRowValues(adhT).putNulls("NOM", "PRENOM", "MAIL", "TEL", "DATE_NAISSANCE");
|
200 |
adhToFetch.putRowValues("ID_ADRESSE").setAllToNull();
|
195 |
adhToFetch.putRowValues("ID_ADRESSE").setAllToNull();
|
201 |
final Map<SQLRow, SQLRow> updatedClientsAndAdh = new HashMap<>();
|
196 |
final Map<SQLRow, SQLRow> updatedClientsAndAdh = new HashMap<>();
|
202 |
|
197 |
|
203 |
for (final SQLRowValues adhR : SQLRowValuesListFetcher.create(adhToFetch).fetch(null, true)) {
|
198 |
for (final SQLRowValues adhR : SQLRowValuesListFetcher.create(adhToFetch).fetch(null, true)) {
|
204 |
final String firstName;
|
199 |
final String firstName;
|
205 |
final String code;
|
200 |
final String code;
|
206 |
SQLRow existingClient = null;
|
201 |
SQLRow existingClient = null;
|
207 |
if (HAS_CODE_IN_FIRST_NAME) {
|
202 |
if (HAS_CODE_IN_FIRST_NAME) {
|
208 |
final Matcher matcher = FIRST_NAME_PATTERN.matcher(adhR.getString("PRENOM"));
|
203 |
final Matcher matcher = FIRST_NAME_PATTERN.matcher(adhR.getString("PRENOM"));
|
209 |
if (!matcher.matches())
|
204 |
if (!matcher.matches())
|
210 |
throw new IllegalStateException("Couldn't match " + adhR);
|
205 |
throw new IllegalStateException("Couldn't match " + adhR);
|
211 |
firstName = matcher.group(1).trim();
|
206 |
firstName = matcher.group(1).trim();
|
212 |
code = matcher.group(2);
|
207 |
code = matcher.group(2);
|
213 |
} else {
|
208 |
} else {
|
214 |
firstName = adhR.getString("PRENOM");
|
209 |
firstName = adhR.getString("PRENOM");
|
215 |
code = null;
|
210 |
code = null;
|
216 |
}
|
211 |
}
|
217 |
if (!StringUtils.isEmpty(code)) {
|
212 |
if (!StringUtils.isEmpty(code)) {
|
218 |
existingClient = getUnique(clientByCode.get(code));
|
213 |
existingClient = getUnique(clientByCode.get(code));
|
219 |
}
|
214 |
}
|
220 |
final String firstLastName = firstName + " " + adhR.getString("NOM");
|
215 |
final String firstLastName = firstName + " " + adhR.getString("NOM");
|
221 |
if (existingClient == null) {
|
216 |
if (existingClient == null) {
|
222 |
existingClient = getUnique(clientByName.get(normalize(firstLastName)));
|
217 |
existingClient = getUnique(clientByName.get(normalize(firstLastName)));
|
223 |
}
|
218 |
}
|
224 |
final SQLRow newClient;
|
219 |
final SQLRow newClient;
|
225 |
if (existingClient != null && !updatedClientsAndAdh.containsKey(existingClient)) {
|
220 |
if (existingClient != null && !updatedClientsAndAdh.containsKey(existingClient)) {
|
226 |
updatedClientsAndAdh.put(existingClient, adhR.asRow());
|
221 |
updatedClientsAndAdh.put(existingClient, adhR.asRow());
|
227 |
// TODO use SQLElement.createFetcher()
|
222 |
// TODO use SQLElement.createFetcher()
|
228 |
final SQLRowValues clientToUpdateVals = SQLRowValuesListFetcher.create(clientElem.createGraph()).fetchOne(existingClient.getIDNumber(), true);
|
223 |
final SQLRowValues clientToUpdateVals = SQLRowValuesListFetcher.create(clientElem.createGraph()).fetchOne(existingClient.getIDNumber(), true);
|
229 |
// TODO use new UpdateAction(SQLElement.createContext())
|
224 |
// TODO use new UpdateAction(SQLElement.createContext())
|
230 |
final SQLRowValues newVals = fillFields(clientToUpdateVals.deepCopy(), adhR, false, addrElem);
|
225 |
final SQLRowValues newVals = fillFields(clientToUpdateVals.deepCopy(), adhR, false, addrElem);
|
231 |
newClient = clientElem.update(clientToUpdateVals, newVals).exec();
|
226 |
newClient = clientElem.update(clientToUpdateVals, newVals).exec();
|
232 |
} else {
|
227 |
} else {
|
233 |
// TODO use Logger
|
228 |
// TODO use Logger
|
234 |
if (existingClient != null) {
|
229 |
if (existingClient != null) {
|
235 |
System.err.println("While matching " + adhT + ", existing client " + existingClient + " already updated with " + updatedClientsAndAdh.get(existingClient)
|
230 |
System.err.println("While matching " + adhT + ", existing client " + existingClient + " already updated with " + updatedClientsAndAdh.get(existingClient)
|
236 |
+ " so creating new client for " + adhR);
|
231 |
+ " so creating new client for " + adhR);
|
237 |
} else {
|
232 |
} else {
|
238 |
System.err.println("While matching " + adhT + ", no client found for " + adhR);
|
233 |
System.err.println("While matching " + adhT + ", no client found for " + adhR);
|
239 |
}
|
234 |
}
|
240 |
// create new client row
|
235 |
// create new client row
|
241 |
// TODO use new InsertAction(SQLElement.createContext()) or at least
|
236 |
// TODO use new InsertAction(SQLElement.createContext()) or at least
|
242 |
// SQLElement.insert()
|
237 |
// SQLElement.insert()
|
243 |
final SQLRowValues vals = fillFields(new SQLRowValues(clientT).put("NOM", firstLastName), adhR, true, addrElem);
|
238 |
final SQLRowValues vals = fillFields(new SQLRowValues(clientT).put("NOM", firstLastName), adhR, true, addrElem);
|
244 |
if (!StringUtils.isEmpty(code))
|
239 |
if (!StringUtils.isEmpty(code))
|
245 |
vals.put("CODE", code);
|
240 |
vals.put("CODE", code);
|
246 |
newClient = vals.insert();
|
241 |
newClient = vals.insert();
|
247 |
}
|
242 |
}
|
248 |
final SQLRowValues contactVals = new SQLRowValues(ctxt.getElementDirectory().getElement(ContactSQLElement.class).getTable());
|
243 |
final SQLRowValues contactVals = new SQLRowValues(ctxt.getElementDirectory().getElement(ContactSQLElement.class).getTable());
|
249 |
contactVals.putForeignID("ID_CLIENT", newClient);
|
244 |
contactVals.putForeignID("ID_CLIENT", newClient);
|
250 |
contactVals.load(adhR.asRow(), Arrays.asList("NOM", "DATE_NAISSANCE"));
|
245 |
contactVals.load(adhR.asRow(), Arrays.asList("NOM", "DATE_NAISSANCE"));
|
251 |
contactVals.put("PRENOM", firstName);
|
246 |
contactVals.put("PRENOM", firstName);
|
252 |
contactVals.put("EMAIL", adhR.getString("MAIL"));
|
247 |
contactVals.put("EMAIL", adhR.getString("MAIL"));
|
253 |
contactVals.insert();
|
248 |
contactVals.insert();
|
254 |
}
|
249 |
}
|
255 |
|
250 |
|
256 |
ctxt.getAlterTable(adhT.getName()).dropColumn("ID_ADRESSE");
|
251 |
ctxt.getAlterTable(adhT.getName()).dropColumn("ID_ADRESSE");
|
257 |
}
|
252 |
}
|
258 |
}
|
253 |
}
|
259 |
}
|
254 |
}
|
260 |
|
255 |
|
261 |
protected SQLRow getUnique(final List<SQLRow> clientRows) {
|
256 |
protected SQLRow getUnique(final List<SQLRow> clientRows) {
|
262 |
return clientRows != null && clientRows.size() == 1 ? clientRows.get(0) : null;
|
257 |
return clientRows != null && clientRows.size() == 1 ? clientRows.get(0) : null;
|
263 |
}
|
258 |
}
|
264 |
|
259 |
|
265 |
private final SQLRowValues fillFields(final SQLRowValues clientVals, final SQLRowValues adhVals, final boolean useAdhID, final SQLElement addrElem) {
|
260 |
private final SQLRowValues fillFields(final SQLRowValues clientVals, final SQLRowValues adhVals, final boolean useAdhID, final SQLElement addrElem) {
|
266 |
clientVals.put(CLIENT_ADH_FIELDNAME, useAdhID ? adhVals.getIDNumber() : adhVals.deepCopy());
|
261 |
clientVals.put(CLIENT_ADH_FIELDNAME, useAdhID ? adhVals.getIDNumber() : adhVals.deepCopy());
|
267 |
concatField(clientVals, adhVals, "MAIL");
|
262 |
concatField(clientVals, adhVals, "MAIL");
|
268 |
concatField(clientVals, adhVals, "TEL");
|
263 |
concatField(clientVals, adhVals, "TEL");
|
269 |
final SQLRowValues adhAddr = (SQLRowValues) adhVals.getNonEmptyForeign("ID_ADRESSE");
|
264 |
final SQLRowValues adhAddr = (SQLRowValues) adhVals.getNonEmptyForeign("ID_ADRESSE");
|
270 |
if (adhAddr != null && !StringUtils.isEmpty(adhAddr.getString("VILLE"), true)) {
|
265 |
if (adhAddr != null && !StringUtils.isEmpty(adhAddr.getString("VILLE"), true)) {
|
271 |
clientVals.put("ID_ADRESSE", addrElem.createCopy(adhAddr, true, null));
|
266 |
clientVals.put("ID_ADRESSE", addrElem.createCopy(adhAddr, true, null));
|
272 |
}
|
267 |
}
|
273 |
return clientVals;
|
268 |
return clientVals;
|
274 |
}
|
269 |
}
|
275 |
|
270 |
|
276 |
private final void concatField(final SQLRowValues clientVals, final SQLRowValues adhVals, final String fieldName) {
|
271 |
private final void concatField(final SQLRowValues clientVals, final SQLRowValues adhVals, final String fieldName) {
|
277 |
final String adhStr = adhVals.getString(fieldName);
|
272 |
final String adhStr = adhVals.getString(fieldName);
|
278 |
if (StringUtils.isEmpty(adhStr, true))
|
273 |
if (StringUtils.isEmpty(adhStr, true))
|
279 |
return;
|
274 |
return;
|
280 |
final String clientStr = clientVals.getString(fieldName);
|
275 |
final String clientStr = clientVals.getString(fieldName);
|
281 |
if (StringUtils.isEmpty(clientStr, true)) {
|
276 |
if (StringUtils.isEmpty(clientStr, true)) {
|
282 |
clientVals.put(fieldName, adhStr);
|
277 |
clientVals.put(fieldName, adhStr);
|
283 |
} else {
|
278 |
} else {
|
284 |
clientVals.put(fieldName, clientStr + ", " + adhStr);
|
279 |
clientVals.put(fieldName, clientStr + ", " + adhStr);
|
285 |
}
|
280 |
}
|
286 |
}
|
281 |
}
|
287 |
|
282 |
|
288 |
static private final Pattern diacriticalPattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
|
283 |
static private final Pattern diacriticalPattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
|
289 |
static private final Pattern punctPattern = Pattern.compile("\\p{Punct}+");
|
284 |
static private final Pattern punctPattern = Pattern.compile("\\p{Punct}+");
|
290 |
static private final Pattern spacePattern = Pattern.compile("\\p{Space}+");
|
285 |
static private final Pattern spacePattern = Pattern.compile("\\p{Space}+");
|
291 |
|
286 |
|
292 |
// remove punctation, multiple spaces and accents
|
287 |
// remove punctation, multiple spaces and accents
|
293 |
static private String normalize(final String s) {
|
288 |
static private String normalize(final String s) {
|
294 |
final String noMarks = diacriticalPattern.matcher(Normalizer.normalize(s, Form.NFD)).replaceAll("");
|
289 |
final String noMarks = diacriticalPattern.matcher(Normalizer.normalize(s, Form.NFD)).replaceAll("");
|
295 |
final String noPunct = punctPattern.matcher(noMarks).replaceAll("_");
|
290 |
final String noPunct = punctPattern.matcher(noMarks).replaceAll("_");
|
296 |
return spacePattern.matcher(noPunct.trim()).replaceAll(" ").toLowerCase();
|
291 |
return spacePattern.matcher(noPunct.trim()).replaceAll(" ").toLowerCase();
|
297 |
}
|
292 |
}
|
298 |
|
293 |
|
299 |
@Override
|
294 |
@Override
|
300 |
protected void setupElements(SQLElementDirectory dir) {
|
295 |
protected void setupElements(SQLElementDirectory dir) {
|
301 |
super.setupElements(dir);
|
296 |
super.setupElements(dir);
|
302 |
|
297 |
|
303 |
final ComptaSQLConfElement entreeElement = new ComptaSQLConfElement("ENTREE", "une entrée", "entrées") {
|
298 |
final ComptaSQLConfElement entreeElement = new ComptaSQLConfElement("ENTREE", "une entrée", "entrées") {
|
304 |
|
299 |
|
305 |
@Override
|
300 |
@Override
|
306 |
protected List<String> getListFields() {
|
301 |
protected List<String> getListFields() {
|
307 |
final List<String> l = new ArrayList<String>();
|
302 |
final List<String> l = new ArrayList<String>();
|
308 |
l.add("DATE");
|
303 |
l.add("DATE");
|
309 |
l.add("NUMERO_CARTE");
|
304 |
l.add("NUMERO_CARTE");
|
310 |
l.add("ADHERENT");
|
305 |
l.add("ADHERENT");
|
311 |
l.add("MOTIF");
|
306 |
l.add("MOTIF");
|
312 |
l.add("ACCEPTE");
|
307 |
l.add("ACCEPTE");
|
313 |
return l;
|
308 |
return l;
|
314 |
}
|
309 |
}
|
315 |
|
310 |
|
316 |
@Override
|
311 |
@Override
|
317 |
public Set<String> getReadOnlyFields() {
|
312 |
public Set<String> getReadOnlyFields() {
|
318 |
Set<String> s = new HashSet<String>(super.getReadOnlyFields());
|
313 |
Set<String> s = new HashSet<String>(super.getReadOnlyFields());
|
319 |
s.add("NUMERO_CARTE");
|
314 |
s.add("NUMERO_CARTE");
|
320 |
return s;
|
315 |
return s;
|
321 |
}
|
316 |
}
|
322 |
|
317 |
|
323 |
@Override
|
318 |
@Override
|
324 |
protected List<String> getComboFields() {
|
319 |
protected List<String> getComboFields() {
|
325 |
final List<String> l = new ArrayList<String>();
|
320 |
final List<String> l = new ArrayList<String>();
|
326 |
l.add("NUMERO_CARTE");
|
321 |
l.add("NUMERO_CARTE");
|
327 |
l.add("DATE");
|
322 |
l.add("DATE");
|
328 |
return l;
|
323 |
return l;
|
329 |
}
|
324 |
}
|
330 |
|
325 |
|
331 |
@Override
|
326 |
@Override
|
332 |
public ListMap<String, String> getShowAs() {
|
327 |
public ListMap<String, String> getShowAs() {
|
333 |
return ListMap.singleton(null, getComboFields());
|
328 |
return ListMap.singleton(null, getComboFields());
|
334 |
}
|
329 |
}
|
335 |
|
330 |
|
336 |
@Override
|
331 |
@Override
|
337 |
public SQLComponent createComponent() {
|
332 |
public SQLComponent createComponent() {
|
338 |
return new UISQLComponent(this) {
|
333 |
return new UISQLComponent(this) {
|
339 |
@Override
|
334 |
@Override
|
340 |
protected void addViews() {
|
335 |
protected void addViews() {
|
341 |
this.addView("NUMERO_CARTE");
|
336 |
this.addView("NUMERO_CARTE");
|
342 |
this.addView("DATE");
|
337 |
this.addView("DATE");
|
343 |
}
|
338 |
}
|
344 |
};
|
339 |
};
|
345 |
}
|
340 |
}
|
346 |
};
|
341 |
};
|
347 |
dir.addSQLElement(entreeElement);
|
342 |
dir.addSQLElement(entreeElement);
|
348 |
dir.addSQLElement(new PlageHoraireSQLElement());
|
343 |
dir.addSQLElement(new PlageHoraireSQLElement());
|
349 |
dir.addSQLElement(new AdherentSQLElement());
|
344 |
dir.addSQLElement(new AdherentSQLElement());
|
350 |
}
|
345 |
}
|
351 |
|
346 |
|
352 |
private IListPanel getPanelEntree(boolean filtered) {
|
347 |
private IListPanel getPanelEntree(boolean filtered) {
|
353 |
final SQLElement element = Configuration.getInstance().getDirectory().getElement("ENTREE");
|
348 |
final SQLElement element = Configuration.getInstance().getDirectory().getElement("ENTREE");
|
354 |
|
349 |
|
355 |
final SQLTableModelSourceOnline tableModelEntree = element.getTableSource(true);
|
350 |
final SQLTableModelSourceOnline tableModelEntree = element.getTableSource(true);
|
356 |
|
351 |
|
357 |
if (filtered) {
|
352 |
if (filtered) {
|
358 |
Calendar cal = Calendar.getInstance();
|
353 |
Calendar cal = Calendar.getInstance();
|
359 |
cal.add(Calendar.DAY_OF_MONTH, -15);
|
354 |
cal.add(Calendar.DAY_OF_MONTH, -15);
|
360 |
Where wAttente = new Where(element.getTable().getField("DATE"), ">=", cal.getTime());
|
355 |
Where wAttente = new Where(element.getTable().getField("DATE"), ">=", cal.getTime());
|
361 |
tableModelEntree.getReq().setWhere(wAttente);
|
356 |
tableModelEntree.getReq().setWhere(wAttente);
|
362 |
}
|
357 |
}
|
363 |
tableModelEntree.getColumn(element.getTable().getField("DATE")).setRenderer(new DefaultTableCellRenderer() {
|
358 |
tableModelEntree.getColumn(element.getTable().getField("DATE")).setRenderer(new DefaultTableCellRenderer() {
|
364 |
|
359 |
|
365 |
DateFormat format = new SimpleDateFormat("EEEE dd MMMM yyyy HH:mm:ss");
|
360 |
DateFormat format = new SimpleDateFormat("EEEE dd MMMM yyyy HH:mm:ss");
|
366 |
|
361 |
|
367 |
@Override
|
362 |
@Override
|
368 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
363 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
369 |
final String format2 = format.format((Date) value);
|
364 |
final String format2 = format.format((Date) value);
|
370 |
return super.getTableCellRendererComponent(table, format2, isSelected, hasFocus, row, column);
|
365 |
return super.getTableCellRendererComponent(table, format2, isSelected, hasFocus, row, column);
|
371 |
|
366 |
|
372 |
}
|
367 |
}
|
373 |
});
|
368 |
});
|
374 |
|
369 |
|
375 |
final IListPanel panel = new ListeViewPanel(element, new IListe(tableModelEntree));
|
370 |
final IListPanel panel = new ListeViewPanel(element, new IListe(tableModelEntree));
|
376 |
|
371 |
|
377 |
final Action createAction = RowAction.createAction("Assigner à", (Icon) null, new IClosure<List<? extends SQLRowAccessor>>() {
|
372 |
final Action createAction = RowAction.createAction("Assigner à", (Icon) null, new IClosure<List<? extends SQLRowAccessor>>() {
|
378 |
@Override
|
373 |
@Override
|
379 |
public void executeChecked(List<? extends SQLRowAccessor> input) {
|
374 |
public void executeChecked(List<? extends SQLRowAccessor> input) {
|
380 |
SQLRowAccessor row = input.get(0);
|
375 |
SQLRowAccessor row = input.get(0);
|
381 |
PanelFrame frame = new PanelFrame(new AssignationPanel(row.getString("NUMERO_CARTE")), "Assignation d'une carte");
|
376 |
PanelFrame frame = new PanelFrame(new AssignationPanel(row.getString("NUMERO_CARTE")), "Assignation d'une carte");
|
382 |
frame.setLocationRelativeTo(null);
|
377 |
frame.setLocationRelativeTo(null);
|
383 |
frame.setVisible(true);
|
378 |
frame.setVisible(true);
|
384 |
|
379 |
|
385 |
}
|
380 |
}
|
386 |
});
|
381 |
});
|
387 |
|
382 |
|
388 |
panel.getListe().addRowAction(createAction);
|
383 |
panel.getListe().addRowAction(createAction);
|
389 |
|
384 |
|
390 |
return panel;
|
385 |
return panel;
|
391 |
}
|
386 |
}
|
392 |
|
387 |
|
393 |
@Override
|
388 |
@Override
|
394 |
protected void setupComponents(ComponentsContext ctxt) {
|
389 |
protected void setupComponents(ComponentsContext ctxt) {
|
395 |
final Group g = new Group("customerrelationship.customer.adherent", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
|
390 |
final Group g = new Group("customerrelationship.customer.adherent", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
|
396 |
ctxt.getElement("CLIENT").getDefaultGroup().add(g);
|
391 |
ctxt.getElement("CLIENT").getDefaultGroup().add(g);
|
397 |
g.addItem(CLIENT_ADH_FIELDNAME, new LayoutHints(true, true, true, true, true, true));
|
392 |
g.addItem(CLIENT_ADH_FIELDNAME, new LayoutHints(true, true, true, true, true, true));
|
398 |
ctxt.addFileDropHandler("ADHERENT", new FileDropHandler() {
|
393 |
ctxt.addFileDropHandler("ADHERENT", new FileDropHandler() {
|
399 |
|
394 |
|
400 |
@Override
|
395 |
@Override
|
401 |
public boolean handle(File f, Component source) {
|
396 |
public boolean handle(File f, Component source) {
|
402 |
AdherentImporter importer;
|
397 |
AdherentImporter importer;
|
403 |
try {
|
398 |
try {
|
404 |
importer = new AdherentImporter(f);
|
399 |
importer = new AdherentImporter(f);
|
405 |
importer.importAdherent();
|
400 |
importer.importAdherent();
|
406 |
} catch (Exception e) {
|
401 |
} catch (Exception e) {
|
407 |
e.printStackTrace();
|
402 |
e.printStackTrace();
|
408 |
}
|
403 |
}
|
409 |
return true;
|
404 |
return true;
|
410 |
}
|
405 |
}
|
411 |
|
406 |
|
412 |
@Override
|
407 |
@Override
|
413 |
public boolean canHandle(File f) {
|
408 |
public boolean canHandle(File f) {
|
414 |
String n = f.getName().toLowerCase();
|
409 |
String n = f.getName().toLowerCase();
|
415 |
return n.endsWith(".xls") || n.endsWith(".ods");
|
410 |
return n.endsWith(".xls") || n.endsWith(".ods");
|
416 |
}
|
411 |
}
|
417 |
});
|
412 |
});
|
418 |
}
|
413 |
}
|
419 |
|
414 |
|
420 |
@Override
|
415 |
@Override
|
421 |
protected void setupMenu(MenuContext ctxt) {
|
416 |
protected void setupMenu(MenuContext ctxt) {
|
422 |
ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des entrées") {
|
417 |
ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des entrées") {
|
423 |
|
418 |
|
424 |
@Override
|
419 |
@Override
|
425 |
public JFrame createFrame() {
|
420 |
public JFrame createFrame() {
|
426 |
|
421 |
|
427 |
return new IListFrame(getPanelEntree(false));
|
422 |
return new IListFrame(getPanelEntree(false));
|
428 |
}
|
423 |
}
|
429 |
}, MainFrame.LIST_MENU);
|
424 |
}, MainFrame.LIST_MENU);
|
430 |
ctxt.addMenuItem(new PreferencesAction(), MainFrame.FILE_MENU);
|
425 |
ctxt.addMenuItem(ctxt.getMenuAndActions().getAction("preferences"), MainFrame.FILE_MENU);
|
431 |
}
|
426 |
}
|
432 |
|
427 |
|
433 |
@Override
|
428 |
@Override
|
434 |
protected void start() {
|
429 |
protected void start() {
|
435 |
MainFrame.getInstance().getTabbedPane().addTab("Liste des entrées", getPanelEntree(true));
|
430 |
MainFrame.getInstance().getTabbedPane().addTab("Liste des entrées", getPanelEntree(true));
|
436 |
}
|
431 |
}
|
437 |
|
432 |
|
438 |
@Override
|
433 |
@Override
|
439 |
protected void stop() {
|
434 |
protected void stop() {
|
440 |
}
|
435 |
}
|
441 |
|
436 |
|
442 |
public static void main(String[] args) throws IOException {
|
- |
|
443 |
final File propsFile = new File("module.properties");
|
- |
|
444 |
|
- |
|
445 |
final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
|
- |
|
446 |
|
- |
|
447 |
final File distDir = new File("dist");
|
- |
|
448 |
FileUtils.mkdir_p(distDir);
|
- |
|
449 |
new ModulePackager(propsFile, new File("bin/")).writeToDir(distDir);
|
- |
|
450 |
new ModulePackager(propsFile, new File("bin/")).writeToDir(new File("../OpenConcerto/Modules"));
|
- |
|
451 |
|
- |
|
452 |
ModuleManager.getInstance().addFactoryAndStart(factory, false);
|
- |
|
453 |
|
- |
|
454 |
Gestion.main(args);
|
- |
|
455 |
|
- |
|
456 |
}
|
- |
|
457 |
|
- |
|
458 |
public final static String ENTREE_PREF = "entreeAdmin";
|
437 |
public final static String ENTREE_PREF = "entreeAdmin";
|
459 |
|
438 |
|
460 |
@Override
|
439 |
@Override
|
461 |
public List<ModulePreferencePanelDesc> getPrefDescriptors() {
|
440 |
public List<ModulePreferencePanelDesc> getPrefDescriptors(final DBRoot root) {
|
462 |
return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Gestion des entrées") {
|
441 |
return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Gestion des entrées") {
|
463 |
@Override
|
442 |
@Override
|
464 |
protected ModulePreferencePanel createPanel() {
|
443 |
protected ModulePreferencePanel createPanel() {
|
465 |
return new ModulePreferencePanel("Gestion des entrées") {
|
444 |
return new ModulePreferencePanel(root, "Gestion des entrées") {
|
466 |
@Override
|
445 |
@Override
|
467 |
protected void addViews() {
|
446 |
protected void addViews() {
|
468 |
|
- |
|
469 |
this.addView(new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "N'autoriser que les administrateurs à entrer ", ENTREE_PREF));
|
447 |
this.addView(new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "N'autoriser que les administrateurs à entrer ", ENTREE_PREF));
|
470 |
}
|
448 |
}
|
471 |
};
|
449 |
};
|
472 |
}
|
450 |
}
|
473 |
}.setLocal(false).setKeywords("entrée"));
|
451 |
}.setLocal(false).setKeywords("entrée"));
|
474 |
}
|
452 |
}
|
475 |
|
453 |
|
476 |
}
|
454 |
}
|