OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 19 | Rev 67 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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.accounting.ui;
15
 
16
import org.openconcerto.erp.core.common.ui.PanelFrame;
17
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
18
import org.openconcerto.sql.element.SQLElement;
19
import org.openconcerto.sql.model.SQLRow;
20
import org.openconcerto.sql.model.Where;
21
import org.openconcerto.sql.view.EditFrame;
22
import org.openconcerto.sql.view.EditPanel;
23
import org.openconcerto.sql.view.ListeAddPanel;
24
import org.openconcerto.sql.view.list.IListe;
25
 
26
import java.awt.event.ActionEvent;
27
 
28
import javax.swing.JButton;
29
 
30
public class ListeGestCommEltPanel extends ListeAddPanel {
31
 
32
    private EditFrame editModifyFrame, editReadOnlyFrame;
33
 
41 ilm 34
    private ListeGestCommEltPanel(SQLElement elem, boolean showAdd, Where w, String variant) {
18 ilm 35
        // TODO verifier que l'element contient la clef etrangere ID_MOUVEMENT
19 ilm 36
        this(elem, new IListe(elem.createTableSource(w)), showAdd);
18 ilm 37
    }
38
 
39
    public ListeGestCommEltPanel(SQLElement elem, IListe l) {
40
        this(elem, l, false);
41
    }
19 ilm 42
 
18 ilm 43
    public ListeGestCommEltPanel(SQLElement elem, IListe l, boolean showAdd) {
44
        super(elem, l);
45
        this.setAddVisible(showAdd);
46
        this.setOpaque(false);
47
    }
48
 
49
    public ListeGestCommEltPanel(SQLElement elem, boolean showAdd) {
41 ilm 50
        this(elem, showAdd, null, null);
18 ilm 51
    }
52
 
53
    public ListeGestCommEltPanel(SQLElement elem) {
54
        this(elem, false);
55
    }
56
 
41 ilm 57
    public ListeGestCommEltPanel(SQLElement elem, Where w, String variant) {
58
        this(elem, false, w, variant);
59
    }
60
 
18 ilm 61
    public ListeGestCommEltPanel(SQLElement elem, Where w) {
41 ilm 62
        this(elem, false, w, null);
18 ilm 63
    }
64
 
65
    protected void handleAction(JButton source, ActionEvent evt) {
66
 
67
        SQLRow row = this.getElement().getTable().getRow(this.getListe().getSelectedId());
68
 
69
        if (row != null && row.getID() > 1) {
70
            final int idMvt = row.getInt("ID_MOUVEMENT");
71
            if (source == this.buttonEffacer) {
72
 
73
                if (idMvt > 1) {
74
                    PanelFrame frame = new PanelFrame(new SuppressionEcrituresPanel(idMvt), "Suppression");
75
                    frame.pack();
76
                    frame.setLocationRelativeTo(null);
77
                    frame.setResizable(false);
78
                    frame.setVisible(true);
79
                } else {
80
                    super.handleAction(source, evt);
81
                }
82
            } else {
83
                if (source == this.buttonModifier) {
84
 
85
                    if (MouvementSQLElement.isEditable(idMvt)) {
86
                        if (this.editModifyFrame == null) {
87
                            this.editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
88
                        }
89
                        this.editModifyFrame.selectionId(this.getListe().getSelectedId());
90
                        this.editModifyFrame.setVisible(true);
91
                    } else {
92
                        if (this.editReadOnlyFrame == null) {
93
                            this.editReadOnlyFrame = new EditFrame(this.element, EditPanel.READONLY);
94
                        }
95
                        this.editReadOnlyFrame.selectionId(this.getListe().getSelectedId());
96
                        this.editReadOnlyFrame.setVisible(true);
97
                    }
98
                } else {
99
                    super.handleAction(source, evt);
100
                }
101
            }
102
        } else {
103
            super.handleAction(source, evt);
104
        }
105
    }
106
}