18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
182 |
ilm |
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
18 |
ilm |
5 |
*
|
|
|
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
|
|
|
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.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.reports.history.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
|
|
|
17 |
import org.openconcerto.erp.core.common.ui.PanelFrame;
|
|
|
18 |
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
|
|
|
19 |
import org.openconcerto.erp.core.finance.accounting.ui.ListeGestCommEltPanel;
|
|
|
20 |
import org.openconcerto.erp.core.finance.accounting.ui.SuppressionEcrituresPanel;
|
|
|
21 |
import org.openconcerto.erp.core.sales.invoice.report.VenteFactureElementXmlSheet;
|
|
|
22 |
import org.openconcerto.erp.core.sales.quote.ui.EtatDevisRenderer;
|
149 |
ilm |
23 |
import org.openconcerto.erp.core.supplychain.order.action.ImportProductsToOrder;
|
18 |
ilm |
24 |
import org.openconcerto.erp.generationDoc.AbstractSheetXml;
|
|
|
25 |
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
|
|
|
26 |
import org.openconcerto.sql.Configuration;
|
|
|
27 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
28 |
import org.openconcerto.sql.element.SQLElementDirectory;
|
177 |
ilm |
29 |
import org.openconcerto.sql.model.AliasedTable;
|
80 |
ilm |
30 |
import org.openconcerto.sql.model.SQLDataSource;
|
18 |
ilm |
31 |
import org.openconcerto.sql.model.SQLField;
|
142 |
ilm |
32 |
import org.openconcerto.sql.model.SQLFieldsSet;
|
18 |
ilm |
33 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
34 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
144 |
ilm |
35 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
41 |
ilm |
36 |
import org.openconcerto.sql.model.SQLRowValues;
|
144 |
ilm |
37 |
import org.openconcerto.sql.model.SQLSelect;
|
18 |
ilm |
38 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
39 |
import org.openconcerto.sql.model.Where;
|
65 |
ilm |
40 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
67 |
ilm |
41 |
import org.openconcerto.sql.request.ListSQLRequest;
|
18 |
ilm |
42 |
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
|
|
|
43 |
import org.openconcerto.sql.view.IListPanel;
|
|
|
44 |
import org.openconcerto.sql.view.ListeAddPanel;
|
|
|
45 |
import org.openconcerto.sql.view.list.IListe;
|
149 |
ilm |
46 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
18 |
ilm |
47 |
import org.openconcerto.sql.view.list.ITableModel;
|
149 |
ilm |
48 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
65 |
ilm |
49 |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
|
18 |
ilm |
50 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
41 |
ilm |
51 |
import org.openconcerto.ui.FrameUtil;
|
149 |
ilm |
52 |
import org.openconcerto.ui.SwingThreadUtils;
|
|
|
53 |
import org.openconcerto.utils.ExceptionHandler;
|
144 |
ilm |
54 |
import org.openconcerto.utils.cc.ITransformer;
|
18 |
ilm |
55 |
|
28 |
ilm |
56 |
import java.awt.Color;
|
149 |
ilm |
57 |
import java.awt.Component;
|
|
|
58 |
import java.awt.FileDialog;
|
28 |
ilm |
59 |
import java.awt.Font;
|
149 |
ilm |
60 |
import java.awt.Frame;
|
18 |
ilm |
61 |
import java.awt.GridBagConstraints;
|
|
|
62 |
import java.awt.GridBagLayout;
|
|
|
63 |
import java.awt.Insets;
|
|
|
64 |
import java.awt.event.ActionEvent;
|
|
|
65 |
import java.awt.event.ActionListener;
|
149 |
ilm |
66 |
import java.io.File;
|
|
|
67 |
import java.io.FilenameFilter;
|
|
|
68 |
import java.io.IOException;
|
177 |
ilm |
69 |
import java.math.BigDecimal;
|
18 |
ilm |
70 |
import java.math.BigInteger;
|
149 |
ilm |
71 |
import java.sql.SQLException;
|
18 |
ilm |
72 |
import java.util.ArrayList;
|
|
|
73 |
import java.util.Collections;
|
|
|
74 |
import java.util.HashMap;
|
|
|
75 |
import java.util.List;
|
|
|
76 |
import java.util.Map;
|
80 |
ilm |
77 |
import java.util.Random;
|
41 |
ilm |
78 |
import java.util.Set;
|
18 |
ilm |
79 |
import java.util.Vector;
|
|
|
80 |
|
149 |
ilm |
81 |
import javax.swing.AbstractAction;
|
18 |
ilm |
82 |
import javax.swing.BorderFactory;
|
|
|
83 |
import javax.swing.JButton;
|
|
|
84 |
import javax.swing.JFrame;
|
80 |
ilm |
85 |
import javax.swing.JOptionPane;
|
18 |
ilm |
86 |
import javax.swing.JPanel;
|
|
|
87 |
import javax.swing.JSplitPane;
|
|
|
88 |
import javax.swing.JTabbedPane;
|
|
|
89 |
import javax.swing.JTable;
|
|
|
90 |
import javax.swing.SwingUtilities;
|
28 |
ilm |
91 |
import javax.swing.UIManager;
|
|
|
92 |
import javax.swing.border.Border;
|
|
|
93 |
import javax.swing.border.TitledBorder;
|
18 |
ilm |
94 |
import javax.swing.event.AncestorEvent;
|
|
|
95 |
import javax.swing.event.AncestorListener;
|
|
|
96 |
import javax.swing.event.ListSelectionEvent;
|
|
|
97 |
import javax.swing.event.ListSelectionListener;
|
|
|
98 |
import javax.swing.event.TableModelListener;
|
|
|
99 |
import javax.swing.table.TableCellRenderer;
|
41 |
ilm |
100 |
import javax.swing.table.TableModel;
|
18 |
ilm |
101 |
|
|
|
102 |
public class ListeHistoriquePanel extends JPanel {
|
|
|
103 |
|
|
|
104 |
private final Vector<IListPanel> vectListePanel = new Vector<IListPanel>();
|
|
|
105 |
private Map<Integer, List<TableModelListener>> mapListener = new HashMap<Integer, List<TableModelListener>>();
|
|
|
106 |
private JListSQLTablePanel jListePanel;
|
|
|
107 |
|
|
|
108 |
private Map<SQLTable, SQLField> listFieldMap = new HashMap<SQLTable, SQLField>();
|
|
|
109 |
private Map<String, Where> whereList = new HashMap<String, Where>();
|
|
|
110 |
private static Map<SQLElement, Class<? extends AbstractSheetXml>> elementSheet = new HashMap<SQLElement, Class<? extends AbstractSheetXml>>();
|
61 |
ilm |
111 |
private String undefinedLabel;
|
18 |
ilm |
112 |
|
|
|
113 |
static {
|
|
|
114 |
SQLElementDirectory dir = Configuration.getInstance().getDirectory();
|
|
|
115 |
elementSheet.put(dir.getElement("SAISIE_VENTE_FACTURE_ELEMENT"), VenteFactureElementXmlSheet.class);
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
// Filtre à partir de la JList sur les IListe
|
|
|
119 |
private final ListSelectionListener listListener = new ListSelectionListener() {
|
|
|
120 |
|
|
|
121 |
public void valueChanged(ListSelectionEvent e) {
|
67 |
ilm |
122 |
if (e != null && e.getValueIsAdjusting()) {
|
|
|
123 |
return;
|
|
|
124 |
}
|
18 |
ilm |
125 |
int selectIndex = ListeHistoriquePanel.this.jListePanel.getSelectedIndex();
|
|
|
126 |
|
|
|
127 |
SQLRowAccessor row = ListeHistoriquePanel.this.jListePanel.getModel().getRowAt(selectIndex);
|
61 |
ilm |
128 |
|
177 |
ilm |
129 |
if ((row == null || row.isUndefined()) && ListeHistoriquePanel.this.undefinedLabel == null) {
|
61 |
ilm |
130 |
return;
|
|
|
131 |
}
|
|
|
132 |
|
19 |
ilm |
133 |
int id = SQLRow.NONEXISTANT_ID;
|
18 |
ilm |
134 |
if (row != null) {
|
|
|
135 |
id = row.getID();
|
|
|
136 |
}
|
|
|
137 |
|
94 |
ilm |
138 |
final int size = ListeHistoriquePanel.this.vectListePanel.size();
|
|
|
139 |
for (int i = 0; i < size; i++) {
|
18 |
ilm |
140 |
IListPanel liste = ListeHistoriquePanel.this.vectListePanel.get(i);
|
132 |
ilm |
141 |
// TODO : verifier la pertinence de remove / add
|
18 |
ilm |
142 |
// remove listener
|
|
|
143 |
if (ListeHistoriquePanel.this.mapListener.get(i) != null) {
|
|
|
144 |
List<TableModelListener> l = ListeHistoriquePanel.this.mapListener.get(i);
|
|
|
145 |
for (TableModelListener listener : l) {
|
|
|
146 |
liste.getListe().getTableModel().removeTableModelListener(listener);
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
Where w = null;
|
|
|
151 |
final SQLTable table = liste.getElement().getTable();
|
142 |
ilm |
152 |
for (final Where wTmp : ListeHistoriquePanel.this.whereList.values()) {
|
|
|
153 |
if (new SQLFieldsSet(wTmp.getFields()).getTables().contains(liste.getListe().getRequest().getPrimaryTable())) {
|
|
|
154 |
w = wTmp.and(w);
|
80 |
ilm |
155 |
}
|
|
|
156 |
}
|
|
|
157 |
|
18 |
ilm |
158 |
if (id > 1) {
|
|
|
159 |
if (ListeHistoriquePanel.this.listFieldMap != null && ListeHistoriquePanel.this.listFieldMap.get(table) != null) {
|
|
|
160 |
SQLField field = ListeHistoriquePanel.this.listFieldMap.get(table);
|
|
|
161 |
Where w2 = new Where(field, "=", table.getForeignTable(field.getName()).getKey());
|
|
|
162 |
w2 = w2.and(new Where(table.getForeignTable(field.getName()).getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id));
|
19 |
ilm |
163 |
liste.getListe().getRequest().setWhere(w2.and(w));
|
18 |
ilm |
164 |
} else {
|
177 |
ilm |
165 |
if (liste.getElement().getTable().equals(ListeHistoriquePanel.this.jListePanel.getModel().getTable())) {
|
|
|
166 |
final Where whereMatch = new Where(table.getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id);
|
|
|
167 |
if ((table.getName().equals("COMMANDE_ELEMENT") || table.getName().equals("BON_RECEPTION_ELEMENT"))
|
|
|
168 |
&& ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName().equals("AFFAIRE")) {
|
|
|
169 |
|
|
|
170 |
// FIXME alias forcé à la main, voir pour remplacer avec un
|
|
|
171 |
// selectTransformer
|
|
|
172 |
final String tablePere = table.getName().replaceAll("_ELEMENT", "");
|
|
|
173 |
AliasedTable tableAlias = new AliasedTable(table.getTable(tablePere), "tAlias__ID_" + tablePere + "__" + tablePere);
|
|
|
174 |
final int idAffaire = id;
|
|
|
175 |
Where wPere = new Where(tableAlias.getField("ID_AFFAIRE"), "=", idAffaire);
|
|
|
176 |
liste.getListe().getRequest().setWhere(whereMatch.or(wPere).and(w));
|
|
|
177 |
// whereMatch = whereMatch.or(new Where(new
|
|
|
178 |
// AliasedTable(table.getForeignTable("ID_"+tablePere),
|
|
|
179 |
// alias).getField("ID_AFFAIRE"), "=", id));
|
|
|
180 |
|
|
|
181 |
} else {
|
|
|
182 |
liste.getListe().getRequest().setWhere(whereMatch.and(w));
|
|
|
183 |
}
|
28 |
ilm |
184 |
} else {
|
177 |
ilm |
185 |
if ((table.getName().equals("MOUVEMENT_STOCK")) && ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName().equals("AFFAIRE")) {
|
|
|
186 |
|
|
|
187 |
final String tableStock = "STOCK";
|
|
|
188 |
AliasedTable tableAlias = new AliasedTable(table.getTable(tableStock), "tAlias__ID_" + tableStock + "__" + tableStock);
|
|
|
189 |
final int idAffaire = table.getTable("AFFAIRE").getRow(id).getForeignID("ID_DEPOT_STOCK");
|
|
|
190 |
Where w2 = new Where(table.getField("REEL"), "=", Boolean.TRUE);
|
|
|
191 |
w2 = w2.and(new Where(table.getField("SOURCE"), "=", ""));
|
|
|
192 |
Where wPere = new Where(tableAlias.getField("ID_DEPOT_STOCK"), "=", idAffaire).and(w2);
|
|
|
193 |
liste.getListe().getRequest().setWhere(wPere);
|
|
|
194 |
|
|
|
195 |
} else {
|
|
|
196 |
final Where whereMatch = new Where(table.getField("ID_" + ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName()), "=", id);
|
|
|
197 |
if ((table.getName().equals("FACTURE_FOURNISSEUR_ELEMENT") || table.getName().equals("COMMANDE_ELEMENT") || table.getName().equals("BON_RECEPTION_ELEMENT"))
|
|
|
198 |
&& ListeHistoriquePanel.this.jListePanel.getModel().getTable().getName().equals("AFFAIRE")) {
|
|
|
199 |
|
|
|
200 |
// FIXME alias forcé à la main, voir pour remplacer avec un
|
|
|
201 |
// selectTransformer
|
|
|
202 |
final String tablePere = table.getName().replaceAll("_ELEMENT", "");
|
|
|
203 |
AliasedTable tableAlias = new AliasedTable(table.getTable(tablePere), "tAlias__ID_" + tablePere + "__" + tablePere);
|
|
|
204 |
final int idAffaire = id;
|
|
|
205 |
Where wPere = new Where(tableAlias.getField("ID_AFFAIRE"), "=", idAffaire);
|
|
|
206 |
liste.getListe().getRequest().setWhere(whereMatch.or(wPere).and(w).and(new Where(table.getField("PA_HT"), "!=", BigDecimal.ZERO)));
|
|
|
207 |
|
|
|
208 |
} else {
|
|
|
209 |
liste.getListe().getRequest().setWhere(whereMatch.and(w));
|
|
|
210 |
}
|
|
|
211 |
}
|
28 |
ilm |
212 |
}
|
18 |
ilm |
213 |
}
|
|
|
214 |
} else {
|
19 |
ilm |
215 |
liste.getListe().getRequest().setWhere(w);
|
18 |
ilm |
216 |
}
|
132 |
ilm |
217 |
liste.getListe().getModel().setCellsEditable(false);
|
18 |
ilm |
218 |
// Set renderer
|
|
|
219 |
setRenderer(liste);
|
|
|
220 |
|
|
|
221 |
// Set listener
|
|
|
222 |
if (ListeHistoriquePanel.this.mapListener.get(i) != null) {
|
|
|
223 |
List<TableModelListener> l = ListeHistoriquePanel.this.mapListener.get(i);
|
|
|
224 |
for (TableModelListener listener : l) {
|
|
|
225 |
liste.getListe().getTableModel().addTableModelListener(listener);
|
|
|
226 |
if (elementSheet.get(liste.getElement()) != null) {
|
182 |
ilm |
227 |
liste.getListe().addIListeActions(new MouseSheetXmlListeListener(liste.getElement(), elementSheet.get(liste.getElement())).getRowActions());
|
18 |
ilm |
228 |
}
|
|
|
229 |
}
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
}
|
|
|
233 |
}
|
|
|
234 |
};
|
|
|
235 |
|
67 |
ilm |
236 |
public ListeHistoriquePanel(final String title, final ComboSQLRequest req, Map<String, List<String>> listTableOnglet, JPanel panelBottom, Map<SQLTable, SQLField> listFieldMap, Where where) {
|
|
|
237 |
this(title, req, listTableOnglet, panelBottom, listFieldMap, "Tous", where);
|
61 |
ilm |
238 |
}
|
|
|
239 |
|
65 |
ilm |
240 |
public ListeHistoriquePanel(final String title, final ComboSQLRequest req, Map<String, List<String>> listTableOnglet, JPanel panelBottom, Map<SQLTable, SQLField> listFieldMap,
|
67 |
ilm |
241 |
String undefinedLabel, Where where) {
|
83 |
ilm |
242 |
this(title, req, listTableOnglet, panelBottom, listFieldMap, undefinedLabel, false, where, null);
|
65 |
ilm |
243 |
}
|
|
|
244 |
|
144 |
ilm |
245 |
public ListeHistoriquePanel(final String title, final ComboSQLRequest req, Map<String, List<String>> listTableOnglet, JPanel panelBottom, Map<SQLTable, SQLField> listFieldMap,
|
|
|
246 |
String undefinedLabel, final boolean sourceWithOutTransformer, Where where, SQLTableModelSourceOnline tableSource) {
|
|
|
247 |
this(title, req, listTableOnglet, panelBottom, listFieldMap, undefinedLabel, sourceWithOutTransformer, where, tableSource, null);
|
|
|
248 |
}
|
|
|
249 |
|
18 |
ilm |
250 |
// TODO verifier que les tables contiennent bien la clef etrangere
|
|
|
251 |
/**
|
|
|
252 |
* @param title titre de la JList
|
65 |
ilm |
253 |
* @param req table à afficher la JListSQLTablePanel
|
18 |
ilm |
254 |
* @param listTableOnglet liste des tables à afficher
|
|
|
255 |
* @param panelBottom panel à afficher en bas de la frame
|
|
|
256 |
* @param listFieldMap jointure d'une table pour utiliser le filtre si la table ne contient pas
|
|
|
257 |
* de foreignKey pointant sur tableList
|
61 |
ilm |
258 |
* @param undefinedLabel label pour l'indéfini permettant de tout sélectionner, null si
|
|
|
259 |
* l'undefined n'est pas à inclure.
|
67 |
ilm |
260 |
* @param where
|
18 |
ilm |
261 |
*/
|
65 |
ilm |
262 |
public ListeHistoriquePanel(final String title, final ComboSQLRequest req, Map<String, List<String>> listTableOnglet, JPanel panelBottom, Map<SQLTable, SQLField> listFieldMap,
|
144 |
ilm |
263 |
String undefinedLabel, final boolean sourceWithOutTransformer, final Where where, SQLTableModelSourceOnline tableSource, Map<String, String> splitWithField) {
|
18 |
ilm |
264 |
super();
|
|
|
265 |
this.setLayout(new GridBagLayout());
|
|
|
266 |
GridBagConstraints c = new GridBagConstraints();
|
|
|
267 |
c.insets = new Insets(2, 2, 1, 2);
|
|
|
268 |
c.anchor = GridBagConstraints.WEST;
|
|
|
269 |
c.fill = GridBagConstraints.BOTH;
|
|
|
270 |
c.gridheight = 1;
|
|
|
271 |
c.gridwidth = 1;
|
|
|
272 |
c.gridx = 0;
|
|
|
273 |
c.gridy = 0;
|
|
|
274 |
c.weightx = 1;
|
|
|
275 |
c.weighty = 1;
|
|
|
276 |
|
|
|
277 |
this.listFieldMap = listFieldMap;
|
|
|
278 |
|
|
|
279 |
// Onglet de IListe
|
|
|
280 |
JTabbedPane tabbedPane = new JTabbedPane();
|
|
|
281 |
|
28 |
ilm |
282 |
for (String key : listTableOnglet.keySet()) {
|
18 |
ilm |
283 |
|
28 |
ilm |
284 |
List<String> listPanelTable = listTableOnglet.get(key);
|
18 |
ilm |
285 |
|
28 |
ilm |
286 |
JPanel tabbedPanel = new JPanel(new GridBagLayout());
|
41 |
ilm |
287 |
tabbedPanel.setOpaque(false);
|
28 |
ilm |
288 |
GridBagConstraints c2 = new DefaultGridBagConstraints();
|
|
|
289 |
c2.fill = GridBagConstraints.BOTH;
|
|
|
290 |
c2.weightx = 1;
|
|
|
291 |
c2.weighty = 1;
|
|
|
292 |
c2.gridy = GridBagConstraints.RELATIVE;
|
18 |
ilm |
293 |
|
28 |
ilm |
294 |
for (int i = 0; i < listPanelTable.size(); i++) {
|
|
|
295 |
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(listPanelTable.get(i));
|
|
|
296 |
|
144 |
ilm |
297 |
List<SQLRow> splitter = new ArrayList<SQLRow>();
|
|
|
298 |
|
|
|
299 |
final String splitField = (splitWithField == null ? null : splitWithField.get(elt.getTable().getName()));
|
|
|
300 |
if (splitField != null) {
|
|
|
301 |
SQLTable tableSplit = elt.getTable().getForeignTable(splitField);
|
|
|
302 |
SQLSelect sel = new SQLSelect();
|
|
|
303 |
sel.addSelectStar(tableSplit);
|
|
|
304 |
List<SQLRow> result = SQLRowListRSH.execute(sel);
|
|
|
305 |
splitter.addAll(result);
|
83 |
ilm |
306 |
} else {
|
144 |
ilm |
307 |
splitter.add(null);
|
83 |
ilm |
308 |
}
|
144 |
ilm |
309 |
JTabbedPane tabbed = new JTabbedPane();
|
|
|
310 |
for (int splitIndex = 0; splitIndex < splitter.size(); splitIndex++) {
|
|
|
311 |
final SQLRow sqlRow = splitter.get(splitIndex);
|
|
|
312 |
IListPanel liste;
|
|
|
313 |
final SQLTableModelSourceOnline createTableSource;
|
|
|
314 |
if (tableSource == null) {
|
|
|
315 |
createTableSource = elt.getTableSource(true);
|
|
|
316 |
} else {
|
|
|
317 |
createTableSource = tableSource;
|
67 |
ilm |
318 |
}
|
144 |
ilm |
319 |
final ListSQLRequest request = createTableSource.getReq();
|
|
|
320 |
if (sourceWithOutTransformer) {
|
|
|
321 |
request.setSelectTransf(null);
|
|
|
322 |
}
|
|
|
323 |
if (sqlRow != null) {
|
|
|
324 |
if (splitIndex == 0) {
|
|
|
325 |
request.setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
28 |
ilm |
326 |
|
144 |
ilm |
327 |
@Override
|
|
|
328 |
public SQLSelect transformChecked(SQLSelect input) {
|
|
|
329 |
Where w = new Where(input.getTable(createTableSource.getPrimaryTable().getName()).getField(splitField), "=", sqlRow.getID());
|
|
|
330 |
Where w2 = new Where(input.getTable(createTableSource.getPrimaryTable().getName()).getField(splitField), "=", sqlRow.getTable().getUndefinedID());
|
|
|
331 |
w2 = w2.or(new Where(input.getTable(createTableSource.getPrimaryTable().getName()).getField(splitField), "=", (Object) null));
|
|
|
332 |
input.setWhere(w.or(w2));
|
|
|
333 |
return input;
|
|
|
334 |
}
|
|
|
335 |
});
|
|
|
336 |
} else {
|
|
|
337 |
request.setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
67 |
ilm |
338 |
|
144 |
ilm |
339 |
@Override
|
|
|
340 |
public SQLSelect transformChecked(SQLSelect input) {
|
|
|
341 |
Where w = new Where(input.getTable(createTableSource.getPrimaryTable().getName()).getField(splitField), "=", sqlRow.getID());
|
|
|
342 |
input.setWhere(w);
|
|
|
343 |
return input;
|
|
|
344 |
}
|
|
|
345 |
});
|
|
|
346 |
}
|
|
|
347 |
}
|
|
|
348 |
if (where != null) {
|
|
|
349 |
if (new SQLFieldsSet(where.getFields()).getTables().contains(request.getPrimaryTable())) {
|
|
|
350 |
request.setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
67 |
ilm |
351 |
|
144 |
ilm |
352 |
@Override
|
149 |
ilm |
353 |
public SQLSelect transformChecked(SQLSelect input) {
|
144 |
ilm |
354 |
input.setWhere(where);
|
|
|
355 |
return input;
|
|
|
356 |
}
|
|
|
357 |
});
|
|
|
358 |
// request.setWhere(where);
|
|
|
359 |
}
|
|
|
360 |
}
|
156 |
ilm |
361 |
// Evite de charger les listes completes à la création de la fenetre
|
|
|
362 |
request.setWhere(Where.FALSE);
|
28 |
ilm |
363 |
|
144 |
ilm |
364 |
if (elt.getTable().contains("ID_MOUVEMENT")) {
|
|
|
365 |
|
|
|
366 |
liste = new ListeGestCommEltPanel(elt, new IListe(createTableSource), "historique-" + title) {
|
|
|
367 |
|
|
|
368 |
protected void handleAction(JButton source, ActionEvent evt) {
|
|
|
369 |
|
|
|
370 |
if (elt.getTable().contains("ID_MOUVEMENT")) {
|
|
|
371 |
SQLRow row = getListe().fetchSelectedRow();
|
|
|
372 |
if (source == this.buttonModifier) {
|
|
|
373 |
MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT"));
|
28 |
ilm |
374 |
} else {
|
144 |
ilm |
375 |
if (source == this.buttonEffacer) {
|
|
|
376 |
PanelFrame f = new PanelFrame(new SuppressionEcrituresPanel(row.getInt("ID_MOUVEMENT")), "Suppresion d'une pièce");
|
|
|
377 |
f.setLocationRelativeTo(null);
|
|
|
378 |
f.setResizable(false);
|
|
|
379 |
f.setVisible(true);
|
|
|
380 |
} else {
|
|
|
381 |
super.handleAction(source, evt);
|
|
|
382 |
}
|
28 |
ilm |
383 |
}
|
144 |
ilm |
384 |
} else {
|
|
|
385 |
super.handleAction(source, evt);
|
18 |
ilm |
386 |
}
|
|
|
387 |
}
|
144 |
ilm |
388 |
};
|
18 |
ilm |
389 |
|
177 |
ilm |
390 |
} else
|
67 |
ilm |
391 |
|
177 |
ilm |
392 |
{
|
|
|
393 |
|
144 |
ilm |
394 |
liste = new ListeAddPanel(elt, new IListe(createTableSource), "historique-" + title) {
|
|
|
395 |
@Override
|
|
|
396 |
protected void handleAction(JButton source, ActionEvent evt) {
|
|
|
397 |
if (source == this.buttonAjouter) {
|
|
|
398 |
// toujours remplir la createFrame avec la ligne sélectionnée
|
|
|
399 |
// car la frame écoute la sélection mais pas les modif, et se
|
|
|
400 |
// reset
|
|
|
401 |
// qd on la ferme
|
|
|
402 |
// donc si on clic ajouter, on ferme, on modif la ligne, on clic
|
|
|
403 |
// ajouter
|
|
|
404 |
// on doit reremplir l'EditFrame
|
|
|
405 |
int selectIndex = ListeHistoriquePanel.this.jListePanel.getSelectedIndex();
|
|
|
406 |
SQLRowAccessor row = ListeHistoriquePanel.this.jListePanel.getModel().getRowAt(selectIndex);
|
|
|
407 |
if (row != null && !row.isUndefined()) {
|
|
|
408 |
SQLTable table = this.getCreateFrame().getSQLComponent().getElement().getTable();
|
|
|
409 |
Set<SQLField> fields = table.getForeignKeys(ListeHistoriquePanel.this.jListePanel.getModel().getTable());
|
|
|
410 |
if (fields != null && fields.size() > 0) {
|
|
|
411 |
SQLRowValues rowVals = new SQLRowValues(table);
|
|
|
412 |
rowVals.put(((SQLField) fields.toArray()[0]).getName(), row.getID());
|
|
|
413 |
this.getCreateFrame().getSQLComponent().resetValue();
|
|
|
414 |
this.getCreateFrame().getSQLComponent().select(rowVals);
|
|
|
415 |
}
|
41 |
ilm |
416 |
}
|
144 |
ilm |
417 |
FrameUtil.show(this.getCreateFrame());
|
|
|
418 |
} else {
|
|
|
419 |
super.handleAction(source, evt);
|
41 |
ilm |
420 |
}
|
|
|
421 |
}
|
144 |
ilm |
422 |
};
|
149 |
ilm |
423 |
if (createTableSource.getPrimaryTable().getName().equals("DEMANDE_ACHAT_ELEMENT")) {
|
|
|
424 |
final ListeAddPanel listeDmd = (ListeAddPanel) liste;
|
|
|
425 |
PredicateRowAction actionDrop = new PredicateRowAction(new AbstractAction("Importer depuis Fichier Inventor") {
|
|
|
426 |
|
|
|
427 |
@Override
|
|
|
428 |
public void actionPerformed(ActionEvent e) {
|
|
|
429 |
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
|
|
|
430 |
final FileDialog fd = new FileDialog(frame, "Import fichier inventor", FileDialog.LOAD);
|
|
|
431 |
fd.setFilenameFilter(new FilenameFilter() {
|
|
|
432 |
@Override
|
|
|
433 |
public boolean accept(File dir, String name) {
|
|
|
434 |
return name.endsWith(".xls");
|
|
|
435 |
}
|
|
|
436 |
});
|
|
|
437 |
fd.setVisible(true);
|
|
|
438 |
if (fd.getFile() != null) {
|
|
|
439 |
|
|
|
440 |
ImportProductsToOrder importer = new ImportProductsToOrder();
|
|
|
441 |
if (getSelectedRow() == null) {
|
|
|
442 |
JOptionPane.showMessageDialog(frame, "Import impossible! Aucune affaire sélectionnée.");
|
|
|
443 |
} else {
|
|
|
444 |
int a = JOptionPane.showConfirmDialog(frame,
|
|
|
445 |
"Etes vous sûr de vouloir importer ces éléments dans l'affaire N°" + getSelectedRow().getString("NUMERO") + "?", "Import invertor",
|
|
|
446 |
JOptionPane.YES_NO_OPTION);
|
|
|
447 |
if (a == JOptionPane.YES_OPTION) {
|
|
|
448 |
importer.setRowAffaire(getSelectedRow());
|
|
|
449 |
importer.setRowFamille(sqlRow);
|
|
|
450 |
try {
|
|
|
451 |
importer.importFile(new File(fd.getDirectory(), fd.getFile()), createTableSource.getPrimaryTable().getDBRoot());
|
|
|
452 |
listeDmd.getListe().getModel().updateAll();
|
|
|
453 |
} catch (IOException e1) {
|
|
|
454 |
ExceptionHandler.handle("Erreur lors de l'import du fichier!", e1);
|
|
|
455 |
} catch (SQLException e1) {
|
|
|
456 |
ExceptionHandler.handle("Erreur lors de l'import du fichier!", e1);
|
|
|
457 |
}
|
|
|
458 |
}
|
|
|
459 |
}
|
|
|
460 |
}
|
|
|
461 |
}
|
|
|
462 |
}, true);
|
|
|
463 |
actionDrop.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
|
|
|
464 |
liste.getListe().addIListeAction(actionDrop);
|
182 |
ilm |
465 |
} else if (createTableSource.getPrimaryTable().getName().endsWith("_ELEMENT")) {
|
|
|
466 |
liste.setAddVisible(false);
|
|
|
467 |
liste.setShowReadOnlyFrameOnDoubleClick(false);
|
|
|
468 |
liste.setModifyVisible(false);
|
|
|
469 |
liste.setDeleteVisible(false);
|
149 |
ilm |
470 |
}
|
144 |
ilm |
471 |
}
|
19 |
ilm |
472 |
|
144 |
ilm |
473 |
this.vectListePanel.add(liste);
|
18 |
ilm |
474 |
|
144 |
ilm |
475 |
setRenderer(liste);
|
|
|
476 |
if (elementSheet.get(liste.getElement()) != null) {
|
182 |
ilm |
477 |
liste.getListe().addIListeActions(new MouseSheetXmlListeListener(liste.getElement(), elementSheet.get(liste.getElement())).getRowActions());
|
144 |
ilm |
478 |
}
|
|
|
479 |
liste.getListe().getModel().setCellsEditable(false);
|
|
|
480 |
liste.setOpaque(false);
|
28 |
ilm |
481 |
|
144 |
ilm |
482 |
liste.setBorder(null);
|
|
|
483 |
liste.getListe().getModel().setHibernateDelay(-1);
|
28 |
ilm |
484 |
|
144 |
ilm |
485 |
if (listPanelTable.size() > 1) {
|
|
|
486 |
Font f = UIManager.getFont("TitledBorder.font");
|
|
|
487 |
f = f.deriveFont(Font.BOLD);
|
|
|
488 |
Border b = UIManager.getBorder("TitledBorder.border");
|
|
|
489 |
b = BorderFactory.createLineBorder(Color.BLACK);
|
|
|
490 |
liste.setBorder(BorderFactory.createTitledBorder(b, elt.getPluralName(), TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, f));
|
|
|
491 |
}
|
|
|
492 |
if (sqlRow != null) {
|
|
|
493 |
String titleTab;
|
|
|
494 |
if (splitIndex == 0) {
|
|
|
495 |
titleTab = sqlRow.getString("NOM") + " et non classés";
|
|
|
496 |
tabbedPanel.add(tabbed, c2);
|
|
|
497 |
} else {
|
|
|
498 |
titleTab = sqlRow.getString("NOM");
|
|
|
499 |
}
|
|
|
500 |
tabbed.add(titleTab, liste);
|
28 |
ilm |
501 |
|
144 |
ilm |
502 |
} else {
|
|
|
503 |
tabbedPanel.add(liste, c2);
|
|
|
504 |
}
|
|
|
505 |
}
|
18 |
ilm |
506 |
}
|
|
|
507 |
|
28 |
ilm |
508 |
tabbedPane.add(key, tabbedPanel);
|
18 |
ilm |
509 |
}
|
|
|
510 |
|
|
|
511 |
// Left Panel
|
65 |
ilm |
512 |
this.undefinedLabel = undefinedLabel;
|
|
|
513 |
this.jListePanel = new JListSQLTablePanel(req, undefinedLabel);
|
18 |
ilm |
514 |
|
|
|
515 |
// Right panel
|
|
|
516 |
JPanel rightPanel = new JPanel();
|
|
|
517 |
rightPanel.setLayout(new GridBagLayout());
|
|
|
518 |
GridBagConstraints cRight = new DefaultGridBagConstraints();
|
|
|
519 |
cRight.fill = GridBagConstraints.BOTH;
|
|
|
520 |
cRight.weightx = 1;
|
|
|
521 |
cRight.weighty = 1;
|
|
|
522 |
rightPanel.add(tabbedPane, cRight);
|
|
|
523 |
|
|
|
524 |
if (panelBottom != null) {
|
|
|
525 |
cRight.fill = GridBagConstraints.HORIZONTAL;
|
|
|
526 |
cRight.weightx = 1;
|
|
|
527 |
cRight.weighty = 0;
|
|
|
528 |
cRight.gridy++;
|
|
|
529 |
panelBottom.setBorder(BorderFactory.createTitledBorder("Récapitulatif"));
|
|
|
530 |
rightPanel.add(panelBottom, cRight);
|
|
|
531 |
}
|
|
|
532 |
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.jListePanel, rightPanel);
|
|
|
533 |
split.setBorder(null);
|
|
|
534 |
split.setDividerLocation(275);
|
|
|
535 |
this.add(split, c);
|
|
|
536 |
|
|
|
537 |
JButton buttonClose = new JButton("Fermer");
|
|
|
538 |
c.gridy++;
|
|
|
539 |
c.weightx = 0;
|
|
|
540 |
c.weighty = 0;
|
|
|
541 |
c.fill = GridBagConstraints.NONE;
|
|
|
542 |
c.anchor = GridBagConstraints.EAST;
|
|
|
543 |
this.add(buttonClose, c);
|
|
|
544 |
|
|
|
545 |
buttonClose.addActionListener(new ActionListener() {
|
|
|
546 |
public void actionPerformed(ActionEvent event) {
|
|
|
547 |
((JFrame) SwingUtilities.getRoot(ListeHistoriquePanel.this)).dispose();
|
|
|
548 |
}
|
|
|
549 |
});
|
|
|
550 |
|
|
|
551 |
this.addAncestorListener(new AncestorListener() {
|
|
|
552 |
@Override
|
|
|
553 |
public void ancestorAdded(AncestorEvent event) {
|
177 |
ilm |
554 |
ListeHistoriquePanel.this.jListePanel.addListSelectionListener(ListeHistoriquePanel.this.listListener);
|
18 |
ilm |
555 |
}
|
|
|
556 |
|
|
|
557 |
@Override
|
|
|
558 |
public void ancestorMoved(AncestorEvent event) {
|
19 |
ilm |
559 |
|
18 |
ilm |
560 |
}
|
|
|
561 |
|
|
|
562 |
@Override
|
|
|
563 |
public void ancestorRemoved(AncestorEvent event) {
|
182 |
ilm |
564 |
ListeHistoriquePanel.this.vectListePanel.clear();
|
|
|
565 |
ListeHistoriquePanel.this.mapListener = null;
|
177 |
ilm |
566 |
ListeHistoriquePanel.this.jListePanel.removeListSelectionListener(ListeHistoriquePanel.this.listListener);
|
182 |
ilm |
567 |
ListeHistoriquePanel.this.jListePanel.removeAllTableListener();
|
|
|
568 |
ListeHistoriquePanel.this.jListePanel = null;
|
|
|
569 |
ListeHistoriquePanel.this.listFieldMap = null;
|
|
|
570 |
ListeHistoriquePanel.this.whereList = null;
|
18 |
ilm |
571 |
}
|
|
|
572 |
});
|
80 |
ilm |
573 |
|
18 |
ilm |
574 |
}
|
|
|
575 |
|
|
|
576 |
public void selectIDinJList(int id) {
|
41 |
ilm |
577 |
this.jListePanel.selectID(id);
|
18 |
ilm |
578 |
}
|
|
|
579 |
|
132 |
ilm |
580 |
public void selectFirstIDinJList() {
|
|
|
581 |
this.jListePanel.selectFirstID();
|
|
|
582 |
}
|
|
|
583 |
|
18 |
ilm |
584 |
private void setRenderer(IListPanel liste) {
|
|
|
585 |
|
19 |
ilm |
586 |
SQLElement propositionItemElement = Configuration.getInstance().getDirectory().getElement("PROPOSITION_ELEMENT");
|
18 |
ilm |
587 |
SQLElement devisElement = Configuration.getInstance().getDirectory().getElement("DEVIS");
|
|
|
588 |
JTable table = liste.getListe().getJTable();
|
|
|
589 |
TableCellRenderer rend = null;
|
19 |
ilm |
590 |
if (liste.getElement().getClass() == devisElement.getClass()) {
|
18 |
ilm |
591 |
rend = new EtatDevisRenderer();
|
|
|
592 |
} else {
|
19 |
ilm |
593 |
rend = new DeviseNiceTableCellRenderer();
|
18 |
ilm |
594 |
}
|
|
|
595 |
for (int j = 0; j < table.getColumnCount(); j++) {
|
|
|
596 |
if (rend instanceof EtatDevisRenderer) {
|
|
|
597 |
table.getColumnModel().getColumn(j).setCellRenderer(rend);
|
|
|
598 |
} else {
|
|
|
599 |
if (table.getColumnClass(j) == Long.class || table.getColumnClass(j) == BigInteger.class) {
|
|
|
600 |
table.getColumnModel().getColumn(j).setCellRenderer(rend);
|
|
|
601 |
}
|
|
|
602 |
}
|
|
|
603 |
}
|
|
|
604 |
}
|
|
|
605 |
|
|
|
606 |
public void addListSelectionListener(ListSelectionListener l) {
|
|
|
607 |
this.jListePanel.addListSelectionListener(l);
|
177 |
ilm |
608 |
System.out.println("ListeHistoriquePanel.addListSelectionListener()" + this.jListePanel);
|
18 |
ilm |
609 |
}
|
|
|
610 |
|
|
|
611 |
public void removeListSelectionListener(ListSelectionListener l) {
|
|
|
612 |
this.jListePanel.removeListSelectionListener(l);
|
|
|
613 |
}
|
|
|
614 |
|
|
|
615 |
public SQLRowAccessor getSelectedRow() {
|
182 |
ilm |
616 |
// FIXME null pointer avec historique client frame, surement un pb de garbage
|
|
|
617 |
if (this.jListePanel == null) {
|
|
|
618 |
return null;
|
|
|
619 |
}
|
|
|
620 |
if (this.jListePanel.getModel() == null) {
|
|
|
621 |
return null;
|
|
|
622 |
}
|
|
|
623 |
|
18 |
ilm |
624 |
return this.jListePanel.getModel().getRowAt(this.jListePanel.getSelectedIndex());
|
|
|
625 |
}
|
|
|
626 |
|
|
|
627 |
public void addWhere(String key, Where w) {
|
|
|
628 |
this.whereList.put(key, w);
|
|
|
629 |
this.listListener.valueChanged(null);
|
|
|
630 |
}
|
|
|
631 |
|
|
|
632 |
public void removeWhere(String key) {
|
|
|
633 |
this.whereList.remove(key);
|
|
|
634 |
this.listListener.valueChanged(null);
|
|
|
635 |
}
|
|
|
636 |
|
|
|
637 |
public void removeAllWhere() {
|
|
|
638 |
for (String key : this.whereList.keySet()) {
|
|
|
639 |
this.whereList.remove(key);
|
|
|
640 |
}
|
|
|
641 |
this.listListener.valueChanged(null);
|
|
|
642 |
}
|
|
|
643 |
|
|
|
644 |
public Map<String, Where> getWhere() {
|
|
|
645 |
return this.whereList;
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
public List<Integer> getListId(String tableName) {
|
|
|
649 |
IListe liste = getIListeFromTableName(tableName);
|
|
|
650 |
List<Integer> listeIds = null;
|
|
|
651 |
if (liste != null) {
|
177 |
ilm |
652 |
ITableModel m = liste.getModel();
|
|
|
653 |
int size = m.getRowCount();
|
|
|
654 |
listeIds = new ArrayList<>(size);
|
18 |
ilm |
655 |
for (int i = 0; i < size; i++) {
|
177 |
ilm |
656 |
try {
|
|
|
657 |
listeIds.add(m.idFromIndex(i));
|
|
|
658 |
} catch (Exception e) {
|
|
|
659 |
e.printStackTrace();
|
|
|
660 |
}
|
18 |
ilm |
661 |
}
|
177 |
ilm |
662 |
|
18 |
ilm |
663 |
} else {
|
67 |
ilm |
664 |
listeIds = Collections.emptyList();
|
18 |
ilm |
665 |
}
|
|
|
666 |
return listeIds;
|
|
|
667 |
}
|
|
|
668 |
|
|
|
669 |
public void removeAllTableListener() {
|
41 |
ilm |
670 |
this.jListePanel.removeAllTableListener();
|
18 |
ilm |
671 |
for (Integer i : this.mapListener.keySet()) {
|
177 |
ilm |
672 |
IListPanel panel = this.vectListePanel.get(i);
|
18 |
ilm |
673 |
List<TableModelListener> l = this.mapListener.get(i);
|
|
|
674 |
for (TableModelListener tableModelListener : l) {
|
|
|
675 |
final IListe liste = panel.getListe();
|
41 |
ilm |
676 |
if (liste != null) {
|
|
|
677 |
final TableModel tableModel = liste.getTableModel();
|
|
|
678 |
if (tableModel != null) {
|
|
|
679 |
tableModel.removeTableModelListener(tableModelListener);
|
|
|
680 |
}
|
|
|
681 |
}
|
18 |
ilm |
682 |
}
|
|
|
683 |
|
|
|
684 |
}
|
|
|
685 |
}
|
|
|
686 |
|
|
|
687 |
public void addListenerTable(TableModelListener listener, String tableName) {
|
|
|
688 |
IListe liste = getIListeFromTableName(tableName);
|
|
|
689 |
int index = getIndexFromTableName(tableName);
|
|
|
690 |
if (liste != null) {
|
132 |
ilm |
691 |
liste.getModel().addTableModelListener(listener);
|
93 |
ilm |
692 |
List<TableModelListener> l = this.mapListener.get(index);
|
18 |
ilm |
693 |
if (l == null) {
|
|
|
694 |
l = new ArrayList<TableModelListener>();
|
|
|
695 |
this.mapListener.put(index, l);
|
|
|
696 |
}
|
|
|
697 |
l.add(listener);
|
|
|
698 |
}
|
|
|
699 |
}
|
|
|
700 |
|
|
|
701 |
/**
|
|
|
702 |
* Permet d'obtenir la IListe correspondant au nom d'une table
|
|
|
703 |
*
|
|
|
704 |
* @param tableName nom de la table
|
|
|
705 |
* @return la Iliste associée, dans le cas échéant null
|
|
|
706 |
*/
|
|
|
707 |
|
28 |
ilm |
708 |
public IListe getIListeFromTableName(String tableName) {
|
67 |
ilm |
709 |
IListPanel liste = getIListePanelFromTableName(tableName);
|
|
|
710 |
if (liste == null) {
|
|
|
711 |
return null;
|
|
|
712 |
} else {
|
|
|
713 |
return liste.getListe();
|
|
|
714 |
}
|
|
|
715 |
}
|
|
|
716 |
|
|
|
717 |
/**
|
|
|
718 |
* Permet d'obtenir la IListe correspondant au nom d'une table
|
|
|
719 |
*
|
|
|
720 |
* @param tableName nom de la table
|
|
|
721 |
* @return la Iliste associée, dans le cas échéant null
|
|
|
722 |
*/
|
|
|
723 |
|
|
|
724 |
public IListPanel getIListePanelFromTableName(String tableName) {
|
|
|
725 |
IListPanel liste = null;
|
80 |
ilm |
726 |
final int size = this.vectListePanel.size();
|
|
|
727 |
for (int i = 0; i < size; i++) {
|
18 |
ilm |
728 |
IListPanel listeTmp = this.vectListePanel.get(i);
|
|
|
729 |
// FIXME Null pointer Exception when client deleted
|
|
|
730 |
if (listeTmp != null) {
|
|
|
731 |
IListe list = listeTmp.getListe();
|
|
|
732 |
if (list != null) {
|
|
|
733 |
final ITableModel model = list.getModel();
|
|
|
734 |
if (model != null) {
|
|
|
735 |
if (model.getTable().getName().equalsIgnoreCase(tableName)) {
|
67 |
ilm |
736 |
liste = listeTmp;
|
18 |
ilm |
737 |
}
|
|
|
738 |
}
|
|
|
739 |
}
|
|
|
740 |
}
|
|
|
741 |
}
|
|
|
742 |
return liste;
|
|
|
743 |
}
|
|
|
744 |
|
|
|
745 |
/**
|
144 |
ilm |
746 |
* Permet d'obtenir la IListe correspondant au nom d'une table
|
|
|
747 |
*
|
|
|
748 |
* @param tableName nom de la table
|
|
|
749 |
* @return la Iliste associée, dans le cas échéant null
|
|
|
750 |
*/
|
|
|
751 |
|
|
|
752 |
public List<IListPanel> getAllIListePanelFromTableName(String tableName) {
|
|
|
753 |
List<IListPanel> liste = new ArrayList<IListPanel>();
|
|
|
754 |
final int size = this.vectListePanel.size();
|
|
|
755 |
for (int i = 0; i < size; i++) {
|
|
|
756 |
IListPanel listeTmp = this.vectListePanel.get(i);
|
|
|
757 |
// FIXME Null pointer Exception when client deleted
|
|
|
758 |
if (listeTmp != null) {
|
|
|
759 |
IListe list = listeTmp.getListe();
|
|
|
760 |
if (list != null) {
|
|
|
761 |
final ITableModel model = list.getModel();
|
|
|
762 |
if (model != null) {
|
|
|
763 |
if (model.getTable().getName().equalsIgnoreCase(tableName)) {
|
|
|
764 |
liste.add(listeTmp);
|
|
|
765 |
}
|
|
|
766 |
}
|
|
|
767 |
}
|
|
|
768 |
}
|
|
|
769 |
}
|
|
|
770 |
return liste;
|
|
|
771 |
}
|
|
|
772 |
|
|
|
773 |
/**
|
18 |
ilm |
774 |
* Permet d'obtenir la position dans le vecteur correspondant au nom d'une table
|
|
|
775 |
*
|
|
|
776 |
* @param tableName nom de la table
|
|
|
777 |
* @return -1 si la table n'est pas dans le vecteur
|
|
|
778 |
*/
|
|
|
779 |
private int getIndexFromTableName(String tableName) {
|
80 |
ilm |
780 |
final int size = this.vectListePanel.size();
|
|
|
781 |
for (int i = 0; i < size; i++) {
|
|
|
782 |
final IListPanel listeTmp = this.vectListePanel.get(i);
|
|
|
783 |
final String name = listeTmp.getListe().getModel().getTable().getName();
|
|
|
784 |
if (name.equalsIgnoreCase(tableName)) {
|
18 |
ilm |
785 |
return i;
|
|
|
786 |
}
|
|
|
787 |
}
|
|
|
788 |
return -1;
|
|
|
789 |
}
|
|
|
790 |
|
19 |
ilm |
791 |
public IListe getListe(int index) {
|
|
|
792 |
return this.vectListePanel.get(index).getListe();
|
|
|
793 |
}
|
|
|
794 |
|
94 |
ilm |
795 |
public IListPanel getListePanel(int index) {
|
|
|
796 |
return this.vectListePanel.get(index);
|
|
|
797 |
}
|
|
|
798 |
|
18 |
ilm |
799 |
public void fireListesChanged() {
|
67 |
ilm |
800 |
final int size = this.vectListePanel.size();
|
|
|
801 |
for (int i = 0; i < size; i++) {
|
|
|
802 |
final IListPanel listeTmp = this.vectListePanel.get(i);
|
|
|
803 |
final ITableModel model = listeTmp.getListe().getModel();
|
|
|
804 |
model.fireTableDataChanged();
|
|
|
805 |
model.fireTableStructureChanged();
|
18 |
ilm |
806 |
}
|
|
|
807 |
|
|
|
808 |
}
|
67 |
ilm |
809 |
|
18 |
ilm |
810 |
}
|