OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 41 | Rev 80 | 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
 
67 ilm 49
    public ListeGestCommEltPanel(SQLElement elem, IListe l, String variant) {
50
        // TODO verifier que l'element contient la clef etrangere ID_MOUVEMENT
51
        super(elem, l, variant);
52
        this.setAddVisible(false);
53
        this.setOpaque(false);
54
    }
55
 
18 ilm 56
    public ListeGestCommEltPanel(SQLElement elem, boolean showAdd) {
41 ilm 57
        this(elem, showAdd, null, null);
18 ilm 58
    }
59
 
60
    public ListeGestCommEltPanel(SQLElement elem) {
61
        this(elem, false);
62
    }
63
 
41 ilm 64
    public ListeGestCommEltPanel(SQLElement elem, Where w, String variant) {
65
        this(elem, false, w, variant);
66
    }
67
 
18 ilm 68
    public ListeGestCommEltPanel(SQLElement elem, Where w) {
41 ilm 69
        this(elem, false, w, null);
18 ilm 70
    }
71
 
72
    protected void handleAction(JButton source, ActionEvent evt) {
73
 
74
        SQLRow row = this.getElement().getTable().getRow(this.getListe().getSelectedId());
75
 
76
        if (row != null && row.getID() > 1) {
77
            final int idMvt = row.getInt("ID_MOUVEMENT");
78
            if (source == this.buttonEffacer) {
79
 
80
                if (idMvt > 1) {
81
                    PanelFrame frame = new PanelFrame(new SuppressionEcrituresPanel(idMvt), "Suppression");
82
                    frame.pack();
83
                    frame.setLocationRelativeTo(null);
84
                    frame.setResizable(false);
85
                    frame.setVisible(true);
86
                } else {
87
                    super.handleAction(source, evt);
88
                }
89
            } else {
90
                if (source == this.buttonModifier) {
91
 
92
                    if (MouvementSQLElement.isEditable(idMvt)) {
93
                        if (this.editModifyFrame == null) {
94
                            this.editModifyFrame = new EditFrame(this.element, EditPanel.MODIFICATION);
95
                        }
96
                        this.editModifyFrame.selectionId(this.getListe().getSelectedId());
97
                        this.editModifyFrame.setVisible(true);
98
                    } else {
99
                        if (this.editReadOnlyFrame == null) {
100
                            this.editReadOnlyFrame = new EditFrame(this.element, EditPanel.READONLY);
101
                        }
102
                        this.editReadOnlyFrame.selectionId(this.getListe().getSelectedId());
103
                        this.editReadOnlyFrame.setVisible(true);
104
                    }
105
                } else {
106
                    super.handleAction(source, evt);
107
                }
108
            }
109
        } else {
110
            super.handleAction(source, evt);
111
        }
112
    }
113
}