18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
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.finance.payment.component;
|
|
|
15 |
|
80 |
ilm |
16 |
import org.openconcerto.erp.config.Log;
|
83 |
ilm |
17 |
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
|
177 |
ilm |
18 |
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
|
18 |
ilm |
19 |
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
|
|
|
20 |
import org.openconcerto.erp.model.BanqueModifiedListener;
|
|
|
21 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
|
|
22 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
23 |
import org.openconcerto.sql.model.SQLBackgroundTableCache;
|
|
|
24 |
import org.openconcerto.sql.model.SQLRow;
|
|
|
25 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
26 |
import org.openconcerto.sql.model.Where;
|
|
|
27 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
|
|
28 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
29 |
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
|
21 |
ilm |
30 |
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
|
18 |
ilm |
31 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
|
|
32 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
33 |
import org.openconcerto.ui.JDate;
|
|
|
34 |
import org.openconcerto.ui.component.ITextCombo;
|
80 |
ilm |
35 |
import org.openconcerto.utils.CollectionUtils;
|
18 |
ilm |
36 |
|
|
|
37 |
import java.awt.Dimension;
|
|
|
38 |
import java.awt.GridBagConstraints;
|
|
|
39 |
import java.awt.GridBagLayout;
|
|
|
40 |
import java.awt.event.ItemEvent;
|
|
|
41 |
import java.awt.event.ItemListener;
|
|
|
42 |
import java.beans.PropertyChangeEvent;
|
|
|
43 |
import java.beans.PropertyChangeListener;
|
177 |
ilm |
44 |
import java.util.Date;
|
18 |
ilm |
45 |
import java.util.HashMap;
|
|
|
46 |
import java.util.Map;
|
80 |
ilm |
47 |
import java.util.Set;
|
18 |
ilm |
48 |
|
|
|
49 |
import javax.swing.ButtonGroup;
|
|
|
50 |
import javax.swing.JCheckBox;
|
|
|
51 |
import javax.swing.JLabel;
|
|
|
52 |
import javax.swing.JPanel;
|
|
|
53 |
import javax.swing.JRadioButton;
|
|
|
54 |
import javax.swing.JTextField;
|
|
|
55 |
import javax.swing.event.EventListenerList;
|
|
|
56 |
|
|
|
57 |
public class ModeDeReglementSQLComponent extends BaseSQLComponent {
|
|
|
58 |
|
80 |
ilm |
59 |
static private enum Mode {
|
|
|
60 |
ECHEANCE, CHEQUE, VIREMENT
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
static public final int MONTH_END = 31;
|
|
|
64 |
static public final int AT_INVOICE_DATE = 0;
|
|
|
65 |
|
|
|
66 |
private final ElementComboBox boxBanque = new ElementComboBox(true, 20);
|
|
|
67 |
private final JPanel panelBanque = new JPanel(new GridBagLayout());
|
|
|
68 |
private final JPanel panelEcheance = new JPanel(new GridBagLayout());
|
18 |
ilm |
69 |
private final EventListenerList banqueModifiedListenerList = new EventListenerList();
|
|
|
70 |
private final SQLRequestComboBox comboTypeReglement = new SQLRequestComboBox();
|
|
|
71 |
private ITextCombo comboA;
|
80 |
ilm |
72 |
private final ITextCombo comboLe = new SQLTextCombo();
|
|
|
73 |
private final SQLSearchableTextCombo comboBanque = new SQLSearchableTextCombo();
|
|
|
74 |
private final JRadioButton buttonFinMois = new JRadioButton("fin de mois");
|
|
|
75 |
private final JRadioButton buttonDateFacture = new JRadioButton("date de facturation");
|
|
|
76 |
private final JRadioButton buttonLe = new JRadioButton("le");
|
|
|
77 |
private final JCheckBox checkboxComptant = new JCheckBox("Comptant");
|
|
|
78 |
private final JDate dateDepot = new JDate(false);
|
|
|
79 |
private final JDate dateVirt = new JDate(false);
|
|
|
80 |
private final JDate dateCheque = new JDate(false);
|
|
|
81 |
private final JTextField numeroChq = new JTextField();
|
|
|
82 |
private final JTextField nom = new JTextField(30);
|
18 |
ilm |
83 |
private JPanel panelActive = null;
|
80 |
ilm |
84 |
private final Map<Mode, JPanel> m = new HashMap<Mode, JPanel>();
|
18 |
ilm |
85 |
|
|
|
86 |
private int rowIdMode;
|
|
|
87 |
|
80 |
ilm |
88 |
private void setComponentModeEnabled(final SQLRow rowTypeRegl) {
|
18 |
ilm |
89 |
|
80 |
ilm |
90 |
if (rowTypeRegl != null && this.rowIdMode != rowTypeRegl.getID()) {
|
|
|
91 |
this.rowIdMode = rowTypeRegl.getID();
|
|
|
92 |
System.err.println("ModeDeReglementNGSQLComponent.setComponentModeEnabled() " + this.rowIdMode);
|
18 |
ilm |
93 |
} else {
|
|
|
94 |
|
|
|
95 |
return;
|
|
|
96 |
}
|
|
|
97 |
|
80 |
ilm |
98 |
final ButtonGroup group = new ButtonGroup();
|
18 |
ilm |
99 |
group.add(this.buttonFinMois);
|
|
|
100 |
group.add(this.buttonDateFacture);
|
|
|
101 |
group.add(this.buttonLe);
|
|
|
102 |
|
80 |
ilm |
103 |
final Boolean forceLater = rowTypeRegl.getBoolean("ECHEANCE");
|
|
|
104 |
final Boolean forceNow = rowTypeRegl.getBoolean("COMPTANT");
|
|
|
105 |
if (forceLater && forceNow)
|
|
|
106 |
Log.get().warning("Force opposite for " + rowTypeRegl);
|
18 |
ilm |
107 |
|
80 |
ilm |
108 |
this.allowEditable(this.getView(this.checkboxComptant), !forceLater && !forceNow);
|
18 |
ilm |
109 |
|
80 |
ilm |
110 |
if (forceLater) {
|
18 |
ilm |
111 |
this.checkboxComptant.setSelected(false);
|
|
|
112 |
}
|
80 |
ilm |
113 |
if (forceNow) {
|
18 |
ilm |
114 |
this.checkboxComptant.setSelected(true);
|
|
|
115 |
}
|
|
|
116 |
|
80 |
ilm |
117 |
updatePanel();
|
18 |
ilm |
118 |
}
|
|
|
119 |
|
80 |
ilm |
120 |
public ModeDeReglementSQLComponent(final SQLElement elt) {
|
18 |
ilm |
121 |
super(elt);
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
// private
|
80 |
ilm |
125 |
private final JPanel infosCheque = new JPanel(new GridBagLayout());
|
|
|
126 |
private final JPanel infosVirt = new JPanel(new GridBagLayout());
|
18 |
ilm |
127 |
|
80 |
ilm |
128 |
@Override
|
|
|
129 |
protected Set<String> createRequiredNames() {
|
|
|
130 |
return CollectionUtils.createSet("ID_TYPE_REGLEMENT");
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
@Override
|
18 |
ilm |
134 |
public void addViews() {
|
|
|
135 |
|
|
|
136 |
this.setLayout(new GridBagLayout());
|
|
|
137 |
|
80 |
ilm |
138 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
18 |
ilm |
139 |
|
|
|
140 |
c.fill = GridBagConstraints.NONE;
|
|
|
141 |
c.anchor = GridBagConstraints.WEST;
|
|
|
142 |
|
|
|
143 |
/*******************************************************************************************
|
|
|
144 |
* SELECTION DU MODE DE REGLEMENT
|
|
|
145 |
******************************************************************************************/
|
|
|
146 |
this.comboA = new SQLTextCombo(false);
|
83 |
ilm |
147 |
|
|
|
148 |
final GridBagConstraints cB = new DefaultGridBagConstraints();
|
|
|
149 |
this.panelBanque.setOpaque(false);
|
|
|
150 |
this.panelBanque.add(new JLabel(getLabelFor("ID_" + BanqueSQLElement.TABLENAME)), cB);
|
|
|
151 |
cB.weightx = 1;
|
|
|
152 |
cB.gridx++;
|
|
|
153 |
this.panelBanque.add(this.boxBanque, cB);
|
|
|
154 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
155 |
c.weightx = 1;
|
|
|
156 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
157 |
this.add(this.panelBanque, c);
|
|
|
158 |
|
|
|
159 |
c.gridwidth = 1;
|
|
|
160 |
c.weightx = 0;
|
|
|
161 |
c.fill = GridBagConstraints.NONE;
|
18 |
ilm |
162 |
c.gridy++;
|
|
|
163 |
c.gridheight = 1;
|
|
|
164 |
this.add(new JLabel("Règlement par"), c);
|
|
|
165 |
|
|
|
166 |
this.comboTypeReglement.setPreferredSize(new Dimension(80, new JTextField().getPreferredSize().height));
|
|
|
167 |
DefaultGridBagConstraints.lockMinimumSize(this.comboTypeReglement);
|
|
|
168 |
c.gridx++;
|
|
|
169 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
170 |
this.add(this.comboTypeReglement, c);
|
|
|
171 |
c.gridheight = 1;
|
|
|
172 |
// Mode de règlement
|
|
|
173 |
c.gridx++;
|
|
|
174 |
DefaultGridBagConstraints.lockMinimumSize(this.checkboxComptant);
|
83 |
ilm |
175 |
this.checkboxComptant.setOpaque(false);
|
18 |
ilm |
176 |
this.add(this.checkboxComptant, c);
|
|
|
177 |
|
|
|
178 |
// Infos sur le reglement, depend du type de reglement et du comptant oui/non
|
|
|
179 |
c.gridy++;
|
|
|
180 |
c.gridx = 0;
|
|
|
181 |
c.weightx = 1;
|
|
|
182 |
c.gridwidth = 3;
|
|
|
183 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
184 |
c.gridheight = GridBagConstraints.REMAINDER;
|
|
|
185 |
createPanelChequeComptant();
|
|
|
186 |
this.add(this.infosCheque, c);
|
|
|
187 |
createPanelVirementComptant();
|
|
|
188 |
this.add(this.infosVirt, c);
|
|
|
189 |
createPanelEcheance();
|
|
|
190 |
this.add(this.panelEcheance, c);
|
|
|
191 |
|
80 |
ilm |
192 |
this.addView(this.comboTypeReglement, "ID_TYPE_REGLEMENT");
|
|
|
193 |
this.addView(this.checkboxComptant, "COMPTANT");
|
|
|
194 |
|
|
|
195 |
// cheque
|
18 |
ilm |
196 |
this.addSQLObject(this.comboBanque, "ETS");
|
80 |
ilm |
197 |
this.addSQLObject(this.numeroChq, "NUMERO");
|
18 |
ilm |
198 |
this.addSQLObject(this.dateCheque, "DATE");
|
80 |
ilm |
199 |
this.addSQLObject(this.dateDepot, "DATE_DEPOT");
|
|
|
200 |
|
|
|
201 |
// virement
|
18 |
ilm |
202 |
this.addSQLObject(this.nom, "NOM");
|
80 |
ilm |
203 |
this.addSQLObject(this.dateVirt, "DATE_VIREMENT");
|
|
|
204 |
|
18 |
ilm |
205 |
this.addRequiredSQLObject(this.comboA, "AJOURS");
|
80 |
ilm |
206 |
this.addSQLObject(this.buttonDateFacture, "DATE_FACTURE");
|
|
|
207 |
this.addSQLObject(this.buttonFinMois, "FIN_MOIS");
|
18 |
ilm |
208 |
this.addRequiredSQLObject(this.comboLe, "LENJOUR");
|
|
|
209 |
|
|
|
210 |
// Listeners
|
|
|
211 |
|
83 |
ilm |
212 |
this.addSQLObject(this.boxBanque, "ID_" + BanqueSQLElement.TABLENAME);
|
|
|
213 |
this.boxBanque.setButtonsVisible(false);
|
|
|
214 |
this.boxBanque.setOpaque(false);
|
|
|
215 |
this.boxBanque.addModelListener("wantedID", new PropertyChangeListener() {
|
|
|
216 |
@Override
|
|
|
217 |
public void propertyChange(final PropertyChangeEvent evt) {
|
|
|
218 |
final Integer i = ModeDeReglementSQLComponent.this.boxBanque.getWantedID();
|
|
|
219 |
final int value = (i == null) ? -1 : Integer.valueOf(i);
|
|
|
220 |
fireBanqueIdChange(value);
|
|
|
221 |
}
|
|
|
222 |
});
|
|
|
223 |
|
18 |
ilm |
224 |
this.comboTypeReglement.addValueListener(new PropertyChangeListener() {
|
|
|
225 |
|
|
|
226 |
@Override
|
80 |
ilm |
227 |
public void propertyChange(final PropertyChangeEvent evt) {
|
|
|
228 |
final Integer id = ModeDeReglementSQLComponent.this.comboTypeReglement.getValue();
|
18 |
ilm |
229 |
if (id != null && id > 1) {
|
|
|
230 |
|
80 |
ilm |
231 |
final SQLRow ligneTypeReg = SQLBackgroundTableCache.getInstance().getCacheForTable(getTable().getBase().getTable("TYPE_REGLEMENT")).getRowFromId(id);
|
18 |
ilm |
232 |
setComponentModeEnabled(ligneTypeReg);
|
|
|
233 |
}
|
|
|
234 |
}
|
|
|
235 |
});
|
|
|
236 |
|
80 |
ilm |
237 |
this.buttonLe.addItemListener(new ItemListener() {
|
|
|
238 |
@Override
|
|
|
239 |
public void itemStateChanged(final ItemEvent e) {
|
|
|
240 |
allowEditable(getView(ModeDeReglementSQLComponent.this.comboLe), e.getStateChange() == ItemEvent.SELECTED && !ModeDeReglementSQLComponent.this.checkboxComptant.isSelected());
|
|
|
241 |
}
|
|
|
242 |
});
|
|
|
243 |
// initial value
|
|
|
244 |
this.allowEditable(this.getView(this.comboLe), false);
|
|
|
245 |
|
18 |
ilm |
246 |
this.buttonFinMois.addItemListener(new ItemListener() {
|
|
|
247 |
@Override
|
80 |
ilm |
248 |
public void itemStateChanged(final ItemEvent e) {
|
18 |
ilm |
249 |
// System.err.println("Fin de mois");
|
80 |
ilm |
250 |
if (e.getStateChange() == ItemEvent.SELECTED) {
|
|
|
251 |
ModeDeReglementSQLComponent.this.comboLe.setValue(String.valueOf(MONTH_END));
|
18 |
ilm |
252 |
}
|
|
|
253 |
}
|
|
|
254 |
});
|
|
|
255 |
|
|
|
256 |
this.buttonDateFacture.addItemListener(new ItemListener() {
|
|
|
257 |
@Override
|
80 |
ilm |
258 |
public void itemStateChanged(final ItemEvent e) {
|
18 |
ilm |
259 |
// System.err.println("Date de facturation");
|
80 |
ilm |
260 |
if (e.getStateChange() == ItemEvent.SELECTED) {
|
|
|
261 |
ModeDeReglementSQLComponent.this.comboLe.setValue(String.valueOf(AT_INVOICE_DATE));
|
18 |
ilm |
262 |
}
|
|
|
263 |
}
|
|
|
264 |
});
|
|
|
265 |
|
80 |
ilm |
266 |
this.getView(this.comboLe).addValueListener(new PropertyChangeListener() {
|
|
|
267 |
@Override
|
|
|
268 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
269 |
final Number newVal = (Number) evt.getNewValue();
|
|
|
270 |
if (newVal != null && newVal.intValue() != AT_INVOICE_DATE && newVal.intValue() != MONTH_END) {
|
|
|
271 |
ModeDeReglementSQLComponent.this.buttonLe.setSelected(true);
|
|
|
272 |
}
|
|
|
273 |
}
|
|
|
274 |
});
|
|
|
275 |
|
|
|
276 |
this.checkboxComptant.addItemListener(new ItemListener() {
|
|
|
277 |
@Override
|
|
|
278 |
public void itemStateChanged(final ItemEvent e) {
|
|
|
279 |
setEcheanceEnabled(e.getStateChange() == ItemEvent.DESELECTED);
|
|
|
280 |
}
|
|
|
281 |
});
|
18 |
ilm |
282 |
}
|
|
|
283 |
|
177 |
ilm |
284 |
public void addDateCompListener(JDate dateParent) {
|
|
|
285 |
dateParent.addPropertyChangeListener(new PropertyChangeListener() {
|
|
|
286 |
|
|
|
287 |
@Override
|
|
|
288 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
289 |
ModeDeReglementSQLComponent.this.currentDate = dateParent.getValue();
|
|
|
290 |
refreshDatePrev();
|
|
|
291 |
}
|
|
|
292 |
});
|
|
|
293 |
dateParent.addValueListener(new PropertyChangeListener() {
|
|
|
294 |
|
|
|
295 |
@Override
|
|
|
296 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
297 |
ModeDeReglementSQLComponent.this.currentDate = dateParent.getValue();
|
|
|
298 |
refreshDatePrev();
|
|
|
299 |
}
|
|
|
300 |
});
|
|
|
301 |
}
|
|
|
302 |
|
|
|
303 |
private void refreshDatePrev() {
|
|
|
304 |
if (this.currentDate != null) {
|
|
|
305 |
int aJ = this.comboA.getValue().trim().length() == 0 ? 0 : Integer.valueOf(this.comboA.getValue());
|
|
|
306 |
int nJ = this.comboLe.getValue().trim().length() == 0 ? 0 : Integer.valueOf(this.comboLe.getValue());
|
|
|
307 |
Date d = ModeDeReglementSQLElement.calculDate(aJ, nJ, this.currentDate);
|
|
|
308 |
this.datePrev.setDate(d);
|
|
|
309 |
} else {
|
|
|
310 |
this.datePrev.setDate(null);
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
|
|
|
314 |
private JDate datePrev = new JDate();
|
|
|
315 |
private Date currentDate = null;
|
|
|
316 |
|
18 |
ilm |
317 |
private void createPanelEcheance() {
|
|
|
318 |
|
80 |
ilm |
319 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
18 |
ilm |
320 |
c.fill = GridBagConstraints.NONE;
|
|
|
321 |
this.panelEcheance.setOpaque(false);
|
|
|
322 |
this.panelEcheance.add(new JLabel("A"), c);
|
|
|
323 |
c.gridx++;
|
|
|
324 |
c.gridwidth = 1;
|
|
|
325 |
this.comboA.setMinimumSize(new Dimension(60, this.comboA.getMinimumSize().height));
|
|
|
326 |
this.comboA.setPreferredSize(new Dimension(60, this.comboA.getMinimumSize().height));
|
|
|
327 |
this.comboA.setMaximumSize(new Dimension(60, this.comboA.getMinimumSize().height));
|
177 |
ilm |
328 |
this.comboA.addValueListener(new PropertyChangeListener() {
|
|
|
329 |
|
|
|
330 |
@Override
|
|
|
331 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
332 |
refreshDatePrev();
|
|
|
333 |
}
|
|
|
334 |
});
|
18 |
ilm |
335 |
this.panelEcheance.add(this.comboA, c);
|
|
|
336 |
c.gridx += 1;
|
|
|
337 |
c.gridwidth = 1;
|
|
|
338 |
this.panelEcheance.add(new JLabel("jours,"), c);
|
|
|
339 |
c.gridx++;
|
|
|
340 |
c.weightx = 1;
|
|
|
341 |
c.gridwidth = 2;
|
|
|
342 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
343 |
this.buttonDateFacture.setOpaque(false);
|
|
|
344 |
this.panelEcheance.add(this.buttonDateFacture, c);
|
177 |
ilm |
345 |
|
18 |
ilm |
346 |
c.gridy++;
|
177 |
ilm |
347 |
c.gridx = 0;
|
|
|
348 |
c.weightx = 1;
|
|
|
349 |
c.gridwidth = 1;
|
|
|
350 |
// ((BaseSQLComponent)((ElementSQLObject)getSQLParent()).getSQLParent()).getView("DATE");
|
|
|
351 |
this.panelEcheance.add(new JLabel("Soit le"), c);
|
|
|
352 |
c.gridx++;
|
|
|
353 |
c.gridwidth = 1;
|
|
|
354 |
this.datePrev.setEnabled(false);
|
|
|
355 |
this.panelEcheance.add(this.datePrev, c);
|
|
|
356 |
|
|
|
357 |
// c.gridy++;
|
|
|
358 |
c.gridwidth = 2;
|
|
|
359 |
c.gridx = 3;
|
18 |
ilm |
360 |
c.weightx = 0;
|
|
|
361 |
c.fill = GridBagConstraints.NONE;
|
|
|
362 |
this.buttonFinMois.setOpaque(false);
|
|
|
363 |
this.panelEcheance.add(this.buttonFinMois, c);
|
|
|
364 |
c.gridy++;
|
|
|
365 |
c.gridwidth = 1;
|
|
|
366 |
this.buttonLe.setOpaque(false);
|
|
|
367 |
this.panelEcheance.add(this.buttonLe, c);
|
|
|
368 |
|
|
|
369 |
c.gridx++;
|
|
|
370 |
this.comboLe.setMinimumSize(new Dimension(60, this.comboLe.getMinimumSize().height));
|
|
|
371 |
this.comboLe.setPreferredSize(new Dimension(60, this.comboLe.getMinimumSize().height));
|
|
|
372 |
this.comboLe.setMaximumSize(new Dimension(60, this.comboLe.getMinimumSize().height));
|
177 |
ilm |
373 |
this.comboLe.addValueListener(new PropertyChangeListener() {
|
|
|
374 |
|
|
|
375 |
@Override
|
|
|
376 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
377 |
refreshDatePrev();
|
|
|
378 |
}
|
|
|
379 |
});
|
18 |
ilm |
380 |
this.panelEcheance.add(this.comboLe, c);
|
|
|
381 |
this.panelActive = this.panelEcheance;
|
80 |
ilm |
382 |
this.m.put(Mode.ECHEANCE, this.panelEcheance);
|
18 |
ilm |
383 |
|
80 |
ilm |
384 |
DefaultGridBagConstraints.lockMinimumSize(this.panelEcheance);
|
18 |
ilm |
385 |
|
|
|
386 |
}
|
|
|
387 |
|
|
|
388 |
public void createPanelChequeComptant() {
|
|
|
389 |
// this.infosCheque.setBorder(BorderFactory.createTitledBorder("Informations Chèque"));
|
80 |
ilm |
390 |
final GridBagConstraints cCheque = new DefaultGridBagConstraints();
|
18 |
ilm |
391 |
this.infosCheque.add(new JLabel("Banque"), cCheque);
|
|
|
392 |
cCheque.gridx++;
|
|
|
393 |
|
|
|
394 |
this.infosCheque.add(this.comboBanque, cCheque);
|
|
|
395 |
cCheque.gridx++;
|
|
|
396 |
this.infosCheque.add(new JLabel("N°"), cCheque);
|
|
|
397 |
cCheque.gridx++;
|
|
|
398 |
DefaultGridBagConstraints.lockMinimumSize(this.numeroChq);
|
|
|
399 |
this.infosCheque.add(this.numeroChq, cCheque);
|
|
|
400 |
cCheque.gridy++;
|
|
|
401 |
cCheque.gridx = 0;
|
|
|
402 |
this.infosCheque.add(new JLabel("Daté du"), cCheque);
|
|
|
403 |
cCheque.gridx++;
|
|
|
404 |
|
|
|
405 |
this.infosCheque.add(this.dateCheque, cCheque);
|
|
|
406 |
|
80 |
ilm |
407 |
final JLabel labelDepot = new JLabel("A déposer après le");
|
18 |
ilm |
408 |
cCheque.gridx++;
|
|
|
409 |
DefaultGridBagConstraints.lockMinimumSize(this.infosCheque);
|
|
|
410 |
this.infosCheque.add(labelDepot, cCheque);
|
|
|
411 |
|
|
|
412 |
cCheque.gridx++;
|
|
|
413 |
this.infosCheque.add(this.dateDepot, cCheque);
|
80 |
ilm |
414 |
this.m.put(Mode.CHEQUE, this.infosCheque);
|
18 |
ilm |
415 |
this.infosCheque.setVisible(false);
|
83 |
ilm |
416 |
this.infosCheque.setOpaque(false);
|
80 |
ilm |
417 |
DefaultGridBagConstraints.lockMinimumSize(this.infosCheque);
|
18 |
ilm |
418 |
}
|
|
|
419 |
|
|
|
420 |
public void createPanelVirementComptant() {
|
|
|
421 |
// this.infosVirt.setBorder(BorderFactory.createTitledBorder("Informations Virement"));
|
80 |
ilm |
422 |
final GridBagConstraints cCheque = new DefaultGridBagConstraints();
|
18 |
ilm |
423 |
cCheque.weightx = 1;
|
|
|
424 |
this.infosVirt.add(new JLabel("Libellé"), cCheque);
|
|
|
425 |
cCheque.gridx++;
|
|
|
426 |
|
|
|
427 |
this.infosVirt.add(this.nom, cCheque);
|
|
|
428 |
cCheque.gridy++;
|
|
|
429 |
cCheque.gridx = 0;
|
|
|
430 |
cCheque.fill = GridBagConstraints.NONE;
|
|
|
431 |
cCheque.weightx = 0;
|
|
|
432 |
this.infosVirt.add(new JLabel("Daté du"), cCheque);
|
|
|
433 |
cCheque.gridx++;
|
|
|
434 |
|
|
|
435 |
this.infosVirt.add(this.dateVirt, cCheque);
|
80 |
ilm |
436 |
this.m.put(Mode.VIREMENT, this.infosVirt);
|
18 |
ilm |
437 |
this.infosVirt.setVisible(false);
|
80 |
ilm |
438 |
DefaultGridBagConstraints.lockMinimumSize(this.infosVirt);
|
18 |
ilm |
439 |
}
|
|
|
440 |
|
80 |
ilm |
441 |
private void updatePanel() {
|
|
|
442 |
final Integer typeReglt = this.comboTypeReglement.getValue();
|
|
|
443 |
if (typeReglt == null)
|
|
|
444 |
return;
|
|
|
445 |
final boolean comptant = this.checkboxComptant.isSelected();
|
|
|
446 |
|
|
|
447 |
final Mode mode;
|
|
|
448 |
if (comptant && typeReglt == TypeReglementSQLElement.CHEQUE) {
|
|
|
449 |
mode = Mode.CHEQUE;
|
|
|
450 |
} else if (comptant && typeReglt == TypeReglementSQLElement.TRAITE) {
|
|
|
451 |
mode = Mode.VIREMENT;
|
|
|
452 |
} else {
|
|
|
453 |
mode = Mode.ECHEANCE;
|
|
|
454 |
}
|
|
|
455 |
replacePanel(mode);
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
private void replacePanel(final Mode mode) {
|
|
|
459 |
final JPanel panel = this.m.get(mode);
|
18 |
ilm |
460 |
if (panel != this.panelActive) {
|
|
|
461 |
// System.err.println("replace panel " + mode);
|
|
|
462 |
this.panelActive.setVisible(false);
|
|
|
463 |
panel.setVisible(true);
|
|
|
464 |
this.panelActive = panel;
|
|
|
465 |
}
|
|
|
466 |
}
|
|
|
467 |
|
80 |
ilm |
468 |
private void fireBanqueIdChange(final int id) {
|
|
|
469 |
final BanqueModifiedListener[] l = this.banqueModifiedListenerList.getListeners(BanqueModifiedListener.class);
|
|
|
470 |
for (final BanqueModifiedListener banqueModifiedListener : l) {
|
18 |
ilm |
471 |
banqueModifiedListener.idChange(id);
|
|
|
472 |
}
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
// Active/Desactive le panel pour specifie la date d'echeance
|
80 |
ilm |
476 |
private void setEcheanceEnabled(final boolean b) {
|
18 |
ilm |
477 |
// System.err.println("set echeance to " + b);
|
80 |
ilm |
478 |
this.allowEditable(this.getView(this.comboA), b);
|
|
|
479 |
this.allowEditable(this.getView(this.comboLe), b && this.buttonLe.isSelected());
|
|
|
480 |
this.allowEditable(this.getView(this.buttonFinMois), b);
|
|
|
481 |
this.allowEditable(this.getView(this.buttonDateFacture), b);
|
18 |
ilm |
482 |
this.buttonLe.setEnabled(b);
|
|
|
483 |
if (!b) {
|
|
|
484 |
this.comboA.setValue("0");
|
80 |
ilm |
485 |
this.buttonDateFacture.setSelected(true);
|
18 |
ilm |
486 |
} else {
|
80 |
ilm |
487 |
// TODO factor with createDefaults()
|
18 |
ilm |
488 |
this.comboA.setValue("30");
|
80 |
ilm |
489 |
this.buttonFinMois.setSelected(true);
|
18 |
ilm |
490 |
}
|
|
|
491 |
|
80 |
ilm |
492 |
updatePanel();
|
18 |
ilm |
493 |
}
|
|
|
494 |
|
80 |
ilm |
495 |
// ATTN sometimes overwritten by ModeReglementDefautPrefPanel.getDefaultRow(true);
|
|
|
496 |
@Override
|
18 |
ilm |
497 |
protected SQLRowValues createDefaults() {
|
|
|
498 |
final SQLRowValues vals = new SQLRowValues(getTable());
|
80 |
ilm |
499 |
vals.put("COMPTANT", Boolean.FALSE);
|
18 |
ilm |
500 |
vals.put("AJOURS", 30);
|
80 |
ilm |
501 |
vals.put("FIN_MOIS", Boolean.TRUE);
|
18 |
ilm |
502 |
return vals;
|
|
|
503 |
}
|
|
|
504 |
|
80 |
ilm |
505 |
public void setWhereBanque(final Where w) {
|
18 |
ilm |
506 |
if (this.boxBanque != null && this.boxBanque.isShowing()) {
|
|
|
507 |
final ComboSQLRequest request = this.boxBanque.getRequest();
|
|
|
508 |
if (request != null) {
|
|
|
509 |
request.setWhere(w);
|
|
|
510 |
this.boxBanque.fillCombo();
|
|
|
511 |
}
|
|
|
512 |
}
|
|
|
513 |
}
|
|
|
514 |
|
80 |
ilm |
515 |
public void setSelectedIdBanque(final int id) {
|
18 |
ilm |
516 |
this.boxBanque.setValue(id);
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
public int getSelectedIdBanque() {
|
|
|
520 |
return this.boxBanque.getSelectedId();
|
|
|
521 |
}
|
|
|
522 |
|
80 |
ilm |
523 |
public void addBanqueModifiedListener(final BanqueModifiedListener e) {
|
18 |
ilm |
524 |
this.banqueModifiedListenerList.add(BanqueModifiedListener.class, e);
|
|
|
525 |
}
|
|
|
526 |
}
|