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