144 |
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.
|
144 |
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 |
/*
|
|
|
15 |
* Créé le 23 avr. 2012
|
|
|
16 |
*/
|
|
|
17 |
package org.openconcerto.erp.core.finance.tax.action;
|
|
|
18 |
|
|
|
19 |
import org.openconcerto.erp.generationDoc.gestcomm.ReportingTaxeComplementaireSheetXML;
|
|
|
20 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
21 |
import org.openconcerto.ui.JDate;
|
|
|
22 |
|
|
|
23 |
import java.awt.GridBagConstraints;
|
|
|
24 |
import java.awt.GridBagLayout;
|
|
|
25 |
import java.awt.event.ActionEvent;
|
|
|
26 |
import java.beans.PropertyChangeEvent;
|
|
|
27 |
import java.beans.PropertyChangeListener;
|
|
|
28 |
import java.util.Calendar;
|
182 |
ilm |
29 |
import java.util.Collections;
|
144 |
ilm |
30 |
import java.util.concurrent.ExecutionException;
|
|
|
31 |
|
|
|
32 |
import javax.swing.AbstractAction;
|
|
|
33 |
import javax.swing.JButton;
|
|
|
34 |
import javax.swing.JLabel;
|
|
|
35 |
import javax.swing.JPanel;
|
|
|
36 |
|
|
|
37 |
public class ReportingTaxeComplementairePanel extends JPanel {
|
|
|
38 |
|
|
|
39 |
public ReportingTaxeComplementairePanel() {
|
|
|
40 |
super(new GridBagLayout());
|
|
|
41 |
|
|
|
42 |
JLabel labelCom = new JLabel("Période du ");
|
|
|
43 |
|
|
|
44 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
45 |
this.add(labelCom, c);
|
|
|
46 |
c.gridx++;
|
|
|
47 |
final JDate dateDeb = new JDate();
|
|
|
48 |
this.add(dateDeb, c);
|
|
|
49 |
c.gridx++;
|
|
|
50 |
JLabel labelYear = new JLabel("au");
|
|
|
51 |
final JDate dateFin = new JDate();
|
|
|
52 |
|
|
|
53 |
Calendar cal = Calendar.getInstance();
|
|
|
54 |
cal.set(Calendar.MONTH, Calendar.JANUARY);
|
|
|
55 |
cal.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
56 |
dateDeb.setValue(cal.getTime());
|
|
|
57 |
|
|
|
58 |
this.add(labelYear, c);
|
|
|
59 |
c.gridx++;
|
|
|
60 |
this.add(dateFin, c);
|
|
|
61 |
cal.set(Calendar.MONTH, Calendar.DECEMBER);
|
|
|
62 |
cal.set(Calendar.DAY_OF_MONTH, 31);
|
|
|
63 |
dateFin.setValue(cal.getTime());
|
|
|
64 |
|
|
|
65 |
final JButton buttonValid = new JButton(new AbstractAction("Valider") {
|
|
|
66 |
|
|
|
67 |
@Override
|
|
|
68 |
public void actionPerformed(ActionEvent e) {
|
|
|
69 |
|
|
|
70 |
new Thread() {
|
|
|
71 |
public void run() {
|
|
|
72 |
ReportingTaxeComplementaireSheetXML sheet = new ReportingTaxeComplementaireSheetXML(dateDeb.getValue(), dateFin.getValue());
|
|
|
73 |
try {
|
|
|
74 |
sheet.createDocument();
|
|
|
75 |
} catch (InterruptedException exn) {
|
|
|
76 |
exn.printStackTrace();
|
|
|
77 |
} catch (ExecutionException exn) {
|
|
|
78 |
exn.printStackTrace();
|
|
|
79 |
}
|
182 |
ilm |
80 |
sheet.showPrintAndExport(true, false, false, Collections.emptyList());
|
144 |
ilm |
81 |
|
|
|
82 |
};
|
|
|
83 |
}.start();
|
|
|
84 |
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
});
|
|
|
88 |
c.gridx++;
|
|
|
89 |
// buttonValid.setEnabled(false);
|
|
|
90 |
this.add(buttonValid, c);
|
|
|
91 |
dateDeb.addValueListener(new PropertyChangeListener() {
|
|
|
92 |
|
|
|
93 |
@Override
|
|
|
94 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
95 |
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null);
|
|
|
96 |
}
|
|
|
97 |
});
|
|
|
98 |
dateFin.addValueListener(new PropertyChangeListener() {
|
|
|
99 |
|
|
|
100 |
@Override
|
|
|
101 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
102 |
buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null);
|
|
|
103 |
}
|
|
|
104 |
});
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
}
|