OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 144 Rev 156
Line 28... Line 28...
28
import org.openconcerto.sql.model.SQLSystem;
28
import org.openconcerto.sql.model.SQLSystem;
29
import org.openconcerto.sql.model.SQLTable;
29
import org.openconcerto.sql.model.SQLTable;
30
import org.openconcerto.sql.model.Where;
30
import org.openconcerto.sql.model.Where;
31
import org.openconcerto.sql.users.rights.UserRightsManager;
31
import org.openconcerto.sql.users.rights.UserRightsManager;
32
import org.openconcerto.ui.DefaultGridBagConstraints;
32
import org.openconcerto.ui.DefaultGridBagConstraints;
-
 
33
import org.openconcerto.utils.ExceptionHandler;
33
import org.openconcerto.utils.GestionDevise;
34
import org.openconcerto.utils.GestionDevise;
34
import org.openconcerto.utils.TableSorter;
35
import org.openconcerto.utils.TableSorter;
35
 
36
 
36
import java.awt.Dimension;
37
import java.awt.Dimension;
37
import java.awt.GridBagConstraints;
38
import java.awt.GridBagConstraints;
Line 40... Line 41...
40
import java.awt.event.ActionEvent;
41
import java.awt.event.ActionEvent;
41
import java.awt.event.ActionListener;
42
import java.awt.event.ActionListener;
42
import java.awt.event.MouseAdapter;
43
import java.awt.event.MouseAdapter;
43
import java.awt.event.MouseEvent;
44
import java.awt.event.MouseEvent;
44
import java.util.List;
45
import java.util.List;
45
import java.util.concurrent.ExecutionException;
-
 
46
 
46
 
47
import javax.swing.AbstractAction;
47
import javax.swing.AbstractAction;
48
import javax.swing.BorderFactory;
48
import javax.swing.BorderFactory;
49
import javax.swing.JButton;
49
import javax.swing.JButton;
50
import javax.swing.JFrame;
50
import javax.swing.JFrame;
51
import javax.swing.JLabel;
51
import javax.swing.JLabel;
-
 
52
import javax.swing.JOptionPane;
52
import javax.swing.JPanel;
53
import javax.swing.JPanel;
53
import javax.swing.JPopupMenu;
54
import javax.swing.JPopupMenu;
54
import javax.swing.JScrollPane;
55
import javax.swing.JScrollPane;
55
import javax.swing.JTabbedPane;
56
import javax.swing.JTabbedPane;
56
import javax.swing.JTable;
57
import javax.swing.JTable;
Line 109... Line 110...
109
 
110
 
110
    public void loadAsynchronous() {
111
    public void loadAsynchronous() {
111
        // On recupere les differentes classes
112
        // On recupere les differentes classes
112
        List<ClasseCompte> liste = ClasseCompte.getClasseCompte();
113
        List<ClasseCompte> liste = ClasseCompte.getClasseCompte();
113
 
114
 
114
        if (liste.size() != 0) {
115
        if (!liste.isEmpty()) {
115
            for (int k = 0; k < liste.size(); k++) {
116
            for (int k = 0; k < liste.size(); k++) {
116
 
117
 
117
                final ClasseCompte ccTmp = liste.get(k);
118
                final ClasseCompte ccTmp = liste.get(k);
118
                fireLoading(true);
119
                fireLoading(true);
119
                new SwingWorker<JPanel, Object>() {
120
                new SwingWorker<JPanel, Object>() {
120
                    @Override
121
                    @Override
121
                    protected JPanel doInBackground() throws Exception {
122
                    protected JPanel doInBackground() throws Exception {
122
                        // TODO Auto-generated method stub
-
 
123
                        return initClassePanel(ccTmp);
123
                        return initClassePanel(ccTmp);
124
 
-
 
125
                    }
124
                    }
126
 
125
 
127
                    @Override
126
                    @Override
128
                    protected void done() {
127
                    protected void done() {
129
                        JPanel initClassePanel;
128
                        JPanel initClassePanel;
130
                        try {
129
                        try {
131
                            initClassePanel = get();
130
                            initClassePanel = get();
132
 
-
 
133
                            initClassePanel.setOpaque(false);
131
                            initClassePanel.setOpaque(false);
134
 
-
 
135
                            final JScrollPane scrollPane = new JScrollPane(initClassePanel);
132
                            final JScrollPane scrollPane = new JScrollPane(initClassePanel);
136
                            scrollPane.setOpaque(false);
133
                            scrollPane.setOpaque(false);
137
                            scrollPane.setBorder(null);
134
                            scrollPane.setBorder(null);
138
                            scrollPane.getViewport().setOpaque(false);
135
                            scrollPane.getViewport().setOpaque(false);
139
                            // On créer les comptes de chaque classe
136
                            // On créer les comptes de chaque classe
140
                            GrandLivrePanel.this.tabbedClasse.addTab(ccTmp.getNom(), scrollPane);
137
                            GrandLivrePanel.this.tabbedClasse.addTab(ccTmp.getNom(), scrollPane);
141
 
-
 
142
                        } catch (InterruptedException e) {
-
 
143
                            // TODO Auto-generated catch block
-
 
144
                            e.printStackTrace();
-
 
145
                        } catch (ExecutionException e) {
138
                        } catch (Exception e) {
146
                            // TODO Auto-generated catch block
139
                            ExceptionHandler.handle("erreur " + ccTmp.getNom(), e);
147
                            e.printStackTrace();
-
 
148
                        }
140
                        }
149
                        fireLoading(false);
141
                        fireLoading(false);
150
                        super.done();
142
                        super.done();
151
                    }
143
                    }
152
                }.execute();
144
                }.execute();
Line 193... Line 185...
193
        sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
185
        sel.addSelect(ecritureTable.getField("CREDIT"), "SUM");
194
 
186
 
195
        String function = "REGEXP";
187
        String function = "REGEXP";
196
        String match = cc.getTypeNumeroCompte();
188
        String match = cc.getTypeNumeroCompte();
197
        if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
189
        if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
198
            // function = "SIMILAR TO";
-
 
199
            function = "~";
190
            function = "~";
200
            // match = cc.getTypeNumeroCompte().replace(".*", "%");
-
 
201
        }
191
        }
202
 
192
 
203
        Where w = new Where(compteTable.getField("NUMERO"), function, match);
193
        Where w = new Where(compteTable.getField("NUMERO"), function, match);
204
        Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey());
194
        Where w2 = new Where(ecritureTable.getField("ID_COMPTE_PCE"), "=", compteTable.getKey());
205
 
195
 
Line 217... Line 207...
217
 
207
 
218
        List myList = (List) ob;
208
        List myList = (List) ob;
219
 
209
 
220
        JLabel labelTotalClasse = new JLabel();
210
        JLabel labelTotalClasse = new JLabel();
221
        labelTotalClasse.setOpaque(false);
211
        labelTotalClasse.setOpaque(false);
222
        if (myList.size() != 0) {
212
        if (!myList.isEmpty()) {
223
 
213
 
224
            /***************************************************************************************
214
            /***************************************************************************************
225
             * Création des Panels de chaque compte
215
             * Création des Panels de chaque compte
226
             **************************************************************************************/
216
             **************************************************************************************/
227
            // c.weighty = 1;
-
 
228
            for (int i = 0; i < myList.size(); i++) {
217
            for (int i = 0; i < myList.size(); i++) {
229
 
218
 
230
                Object[] objTmp = (Object[]) myList.get(i);
219
                Object[] objTmp = (Object[]) myList.get(i);
231
 
220
 
232
                final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(), objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(),
221
                final Compte compteTmp = new Compte(((Number) objTmp[0]).intValue(), objTmp[1].toString(), objTmp[2].toString(), "", ((Number) objTmp[3]).longValue(),
Line 283... Line 272...
283
        boutonShow.setHorizontalAlignment(SwingConstants.RIGHT);
272
        boutonShow.setHorizontalAlignment(SwingConstants.RIGHT);
284
 
273
 
285
        // Total du Compte
274
        // Total du Compte
286
        JLabel labelCompteDebit = new JLabel("Total Debit : " + GestionDevise.currencyToString(compte.getTotalDebit()));
275
        JLabel labelCompteDebit = new JLabel("Total Debit : " + GestionDevise.currencyToString(compte.getTotalDebit()));
287
        JLabel labelCompteCredit = new JLabel(" Credit : " + GestionDevise.currencyToString(compte.getTotalCredit()));
276
        JLabel labelCompteCredit = new JLabel(" Credit : " + GestionDevise.currencyToString(compte.getTotalCredit()));
288
        // labelCompte.setFont(new Font(labelCompte.getFont().getFontName(), Font.BOLD, 12));
-
 
289
        labelCompteDebit.setHorizontalAlignment(SwingUtilities.LEFT);
277
        labelCompteDebit.setHorizontalAlignment(SwingUtilities.LEFT);
290
        labelCompteCredit.setHorizontalAlignment(SwingUtilities.LEFT);
278
        labelCompteCredit.setHorizontalAlignment(SwingUtilities.LEFT);
291
 
279
 
292
        JLabel labelTmp = new JLabel(compte.getNumero() + " " + compte.getNom());
280
        JLabel labelTmp = new JLabel(compte.getNumero() + " " + compte.getNom());
293
        labelTmp.setHorizontalAlignment(SwingUtilities.LEFT);
281
        labelTmp.setHorizontalAlignment(SwingUtilities.LEFT);
Line 303... Line 291...
303
            private boolean isShow = false;
291
            private boolean isShow = false;
304
            private JScrollPane scroll = null;
292
            private JScrollPane scroll = null;
305
 
293
 
306
            public void actionPerformed(ActionEvent e) {
294
            public void actionPerformed(ActionEvent e) {
307
 
295
 
308
                System.err.println(this.isShow);
-
 
309
                // Afficher la JTable du compte
296
                // Afficher la JTable du compte
310
                if (!this.isShow) {
297
                if (!this.isShow) {
311
                    // if (this.scroll == null) {
-
 
312
                    System.err.println(compte);
-
 
313
                    JTable tableCpt = createJTableCompte(compte);
-
 
314
 
298
 
-
 
299
                    JTable tableCpt = createJTableCompte(compte);
-
 
300
                    if (tableCpt == null) {
-
 
301
                        JOptionPane.showMessageDialog(GrandLivrePanel.this, "Aucune écriture");
-
 
302
                        return;
-
 
303
                    } else {
315
                    this.scroll = new JScrollPane(tableCpt);
304
                        this.scroll = new JScrollPane(tableCpt);
316
 
305
 
317
                    // calcul de la taille du JScrollPane
306
                        // calcul de la taille du JScrollPane
318
                    Dimension d;
307
                        Dimension d;
319
                    System.err.println(tableCpt);
-
 
320
                    if (tableCpt.getPreferredSize().height > 200) {
308
                        if (tableCpt.getPreferredSize().height > 200) {
321
                        d = new Dimension(this.scroll.getPreferredSize().width, 200);
309
                            d = new Dimension(this.scroll.getPreferredSize().width, 200);
322
                    } else {
310
                        } else {
323
                        d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30);
311
                            d = new Dimension(this.scroll.getPreferredSize().width, tableCpt.getPreferredSize().height + 30);
324
                    }
312
                        }
Line 328... Line 316...
328
                    c.gridwidth = 4;
316
                        c.gridwidth = 4;
329
                    c.weightx = 1;
317
                        c.weightx = 1;
330
                    c.fill = GridBagConstraints.HORIZONTAL;
318
                        c.fill = GridBagConstraints.HORIZONTAL;
331
                    c.anchor = GridBagConstraints.NORTHWEST;
319
                        c.anchor = GridBagConstraints.NORTHWEST;
332
                    panelCompte.add(this.scroll, c);
320
                        panelCompte.add(this.scroll, c);
333
                    /*
-
 
334
                     * } else { this.scroll.setVisible(true); }
-
 
335
                     */
-
 
336
 
321
 
-
 
322
                    }
337
                } else {
323
                } else {
338
                    // if (this.scroll != null) {
324
                    if (this.scroll != null) {
339
                    panelCompte.remove(this.scroll);
325
                        panelCompte.remove(this.scroll);
340
                    System.out.println("Hide scrollPane");
-
 
341
                    // this.scroll.setVisible(false);
-
 
342
 
-
 
343
                    // this.scroll.repaint();
326
                    }
344
                    panelCompte.repaint();
327
                    panelCompte.repaint();
345
                    panelCompte.revalidate();
328
                    panelCompte.revalidate();
346
                    // }
-
 
347
                }
329
                }
348
 
330
 
349
                this.isShow = !this.isShow;
331
                this.isShow = !this.isShow;
350
                SwingUtilities.getRoot(panelCompte).repaint();
332
                SwingUtilities.getRoot(panelCompte).repaint();
351
            }
333
            }
Line 374... Line 356...
374
                tableTmp.getColumnModel().getColumn(j).setCellRenderer(ecritureRenderer);
356
                tableTmp.getColumnModel().getColumn(j).setCellRenderer(ecritureRenderer);
375
            }
357
            }
376
 
358
 
377
            // Gestion de la souris sur la JTable
359
            // Gestion de la souris sur la JTable
378
            tableTmp.addMouseListener(new MouseAdapter() {
360
            tableTmp.addMouseListener(new MouseAdapter() {
379
 
-
 
-
 
361
                @Override
380
                public void mousePressed(final MouseEvent mE) {
362
                public void mousePressed(final MouseEvent mE) {
381
 
363
 
382
                    if (mE.getButton() == MouseEvent.BUTTON3) {
364
                    if (mE.getButton() == MouseEvent.BUTTON3) {
383
                        JPopupMenu menuDroit = new JPopupMenu();
365
                        JPopupMenu menuDroit = new JPopupMenu();
384
 
366