OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 93 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
93 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.
93 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.accounting.report;
18
 
19
import org.openconcerto.erp.config.ComptaPropsConfiguration;
20
import org.openconcerto.sql.Configuration;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.ui.DefaultGridBagConstraints;
23
import org.openconcerto.ui.JDate;
24
 
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.event.ActionEvent;
28
import java.beans.PropertyChangeEvent;
29
import java.beans.PropertyChangeListener;
182 ilm 30
import java.util.Collections;
93 ilm 31
import java.util.Date;
32
import java.util.concurrent.ExecutionException;
33
 
34
import javax.swing.AbstractAction;
35
import javax.swing.JButton;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38
import javax.swing.SwingConstants;
39
 
40
public class RepartitionAnalytiquePanel extends JPanel {
41
 
42
    private final JDate dateDeb, dateEnd;
43
 
44
    public RepartitionAnalytiquePanel() {
45
        super(new GridBagLayout());
46
 
47
        SQLRow rowSociete = ((ComptaPropsConfiguration) Configuration.getInstance()).getRowSociete();
48
        SQLRow rowExercice = Configuration.getInstance().getBase().getTable("EXERCICE_COMMON").getRow(rowSociete.getInt("ID_EXERCICE_COMMON"));
49
 
50
        this.dateDeb = new JDate();
51
        this.dateEnd = new JDate();
52
 
53
        GridBagConstraints c = new DefaultGridBagConstraints();
54
 
55
        this.add(new JLabel("Période du", SwingConstants.RIGHT), c);
56
        c.gridx++;
57
        c.weightx = 1;
58
        this.add(this.dateDeb, c);
59
        this.dateDeb.setValue((Date) rowExercice.getObject("DATE_DEB"));
60
 
61
        c.gridx++;
62
        c.weightx = 0;
63
        this.add(new JLabel("Au"), c);
64
        c.gridx++;
65
        c.weightx = 1;
66
        this.add(this.dateEnd, c);
67
 
68
        final JButton buttonValid = new JButton(new AbstractAction("Valider") {
69
 
70
            @Override
71
            public void actionPerformed(ActionEvent e) {
72
 
73
                new Thread() {
74
                    public void run() {
75
                        RepartitionAnalytiqueSheetXML sheet = new RepartitionAnalytiqueSheetXML(dateDeb.getDate(), dateEnd.getDate());
76
                        try {
77
                            sheet.createDocument();
182 ilm 78
                            sheet.showPrintAndExport(true, false, false, Collections.emptyList());
93 ilm 79
                        } catch (InterruptedException e) {
80
                            e.printStackTrace();
81
                        } catch (ExecutionException e) {
82
                            e.printStackTrace();
83
                        }
84
                    };
85
                }.start();
86
 
87
            }
88
        });
89
        c.gridx++;
90
        this.add(buttonValid, c);
91
 
92
        // Check validity
93
        buttonValid.setEnabled(false);
94
        final PropertyChangeListener listener = new PropertyChangeListener() {
95
 
96
            @Override
97
            public void propertyChange(PropertyChangeEvent evt) {
98
                buttonValid.setEnabled(dateDeb.getValue() != null && dateEnd.getValue() != null);
99
 
100
            }
101
        };
102
        dateEnd.addValueListener(listener);
103
        dateDeb.addValueListener(listener);
104
    }
105
 
106
}