OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 25
Line 13... Line 13...
13
 
13
 
14
 package org.openconcerto.erp.panel;
14
 package org.openconcerto.erp.panel;
15
 
15
 
16
import org.openconcerto.erp.generationDoc.AbstractSheetXml;
16
import org.openconcerto.erp.generationDoc.AbstractSheetXml;
17
import org.openconcerto.sql.model.SQLRow;
17
import org.openconcerto.sql.model.SQLRow;
-
 
18
import org.openconcerto.sql.model.SQLRowAccessor;
18
import org.openconcerto.ui.DefaultGridBagConstraints;
19
import org.openconcerto.ui.DefaultGridBagConstraints;
-
 
20
import org.openconcerto.utils.ExceptionHandler;
19
 
21
 
20
import java.awt.FlowLayout;
22
import java.awt.FlowLayout;
21
import java.awt.GridBagConstraints;
23
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
24
import java.awt.GridBagLayout;
23
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionEvent;
Line 43... Line 45...
43
     * 
45
     * 
44
     */
46
     */
45
    private static final long serialVersionUID = -1653555706074122489L;
47
    private static final long serialVersionUID = -1653555706074122489L;
46
    private final Class<? extends AbstractSheetXml> clazz;
48
    private final Class<? extends AbstractSheetXml> clazz;
47
    private final JPanel panel;
49
    private final JPanel panel;
48
    private final List<SQLRow> liste;
50
    private final List<SQLRowAccessor> liste;
49
    private final JLabel operation = new JLabel("");
51
    private final JLabel operation = new JLabel("");
50
    private final JProgressBar bar = new JProgressBar();
52
    private final JProgressBar bar = new JProgressBar();
51
    private final JSpinner spin;
53
    private final JSpinner spin;
52
    Thread thread;
54
    Thread thread;
53
    private boolean cancelOp = false;
55
    private boolean cancelOp = false;
54
 
56
 
55
    private final JButton valid, cancel;
57
    private final JButton valid, cancel;
56
 
58
 
57
    public ListeFastPrintFrame(final List<SQLRow> liste, final Class<? extends AbstractSheetXml> clazz) {
59
    public ListeFastPrintFrame(final List<SQLRowAccessor> liste, final Class<? extends AbstractSheetXml> clazz) {
58
        this.panel = new JPanel(new GridBagLayout());
60
        this.panel = new JPanel(new GridBagLayout());
59
        this.liste = liste;
61
        this.liste = liste;
60
        this.clazz = clazz;
62
        this.clazz = clazz;
61
        final GridBagConstraints c = new DefaultGridBagConstraints();
63
        final GridBagConstraints c = new DefaultGridBagConstraints();
62
        // c.gridwidth = GridBagConstraints.REMAINDER;
64
        // c.gridwidth = GridBagConstraints.REMAINDER;
63
        // FIXME Add Preferences nombre de copies par defaut
65
        // FIXME Add Preferences nombre de copies par defaut
64
        final SQLRow row = this.liste.get(0);
66
        final SQLRowAccessor row = this.liste.get(0);
65
 
67
 
66
        final AbstractSheetXml bSheet = this.createAbstractSheet(row);
68
        final AbstractSheetXml bSheet = this.createAbstractSheet(row.asRow());
67
        if (this.liste.size() <= 1) {
69
        if (this.liste.size() <= 1) {
68
            this.panel.add(new JLabel("Lancer l'impression document"), c);
70
            this.panel.add(new JLabel("Lancer l'impression document"), c);
69
        } else {
71
        } else {
70
            this.panel.add(new JLabel("Lancer l'impression des " + this.liste.size() + " documents"), c);
72
            this.panel.add(new JLabel("Lancer l'impression des " + this.liste.size() + " documents"), c);
71
        }
73
        }
Line 149... Line 151...
149
                    public void run() {
151
                    public void run() {
150
                        ListeFastPrintFrame.this.bar.setStringPainted(true);
152
                        ListeFastPrintFrame.this.bar.setStringPainted(true);
151
                        ListeFastPrintFrame.this.bar.setString("0/" + ListeFastPrintFrame.this.liste.size());
153
                        ListeFastPrintFrame.this.bar.setString("0/" + ListeFastPrintFrame.this.liste.size());
152
                    }
154
                    }
153
                });
155
                });
154
                for (final SQLRow rowAt : ListeFastPrintFrame.this.liste) {
156
                for (final SQLRowAccessor rowAt : ListeFastPrintFrame.this.liste) {
155
 
157
 
156
                    final AbstractSheetXml bSheet = ListeFastPrintFrame.this.createAbstractSheet(rowAt);
158
                    final AbstractSheetXml bSheet = ListeFastPrintFrame.this.createAbstractSheet(rowAt.asRow());
157
                    if (!bSheet.isFileODSExist()) {
159
                    if (!bSheet.getGeneratedFile().exists()) {
158
 
160
 
159
                        try {
161
                        try {
160
                            SwingUtilities.invokeLater(new Runnable() {
162
                            SwingUtilities.invokeLater(new Runnable() {
161
                                public void run() {
163
                                public void run() {
162
                                    ListeFastPrintFrame.this.operation.setText("Création du document " + bSheet.getFileName());
164
                                    ListeFastPrintFrame.this.operation.setText("Création du document " + bSheet.getGeneratedFile());
163
                                }
165
                                }
164
                            });
166
                            });
165
                            bSheet.genere(false, false).get();
167
                            bSheet.createDocument();
166
                        } catch (final InterruptedException e) {
-
 
167
                            // TODO Auto-generated catch block
168
                            bSheet.showPrintAndExportAsynchronous(false, false, true);
168
                            e.printStackTrace();
-
 
169
                        } catch (final ExecutionException e) {
169
                        } catch (Exception e) {
170
                            // TODO Auto-generated catch block
170
                            ExceptionHandler.handle("Erreur lors de l'impression du document " + bSheet.getGeneratedFile());
171
                            e.printStackTrace();
-
 
172
                        }
171
                        }
173
                    }
172
                    }
174
 
173
 
175
                    SwingUtilities.invokeLater(new Runnable() {
174
                    SwingUtilities.invokeLater(new Runnable() {
176
                        public void run() {
175
                        public void run() {
177
                            ListeFastPrintFrame.this.operation.setText("Impression du document " + bSheet.getFileName());
176
                            ListeFastPrintFrame.this.operation.setText("Impression du document " + bSheet.getGeneratedFile());
178
                        }
177
                        }
179
                    });
178
                    });
180
                    bSheet.fastPrintDocument(copies);
179
                    bSheet.fastPrintDocument(copies);
181
                    final int progress = ++i;
180
                    final int progress = ++i;
182
                    SwingUtilities.invokeLater(new Runnable() {
181
                    SwingUtilities.invokeLater(new Runnable() {