OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 21 | 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.sales.product.ui;
15
 
16
import org.openconcerto.erp.panel.ITreeSelection;
17
import org.openconcerto.sql.Configuration;
18
import org.openconcerto.sql.element.SQLElement;
19
import org.openconcerto.ui.DefaultGridBagConstraints;
20
 
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26
 
27
import javax.swing.JButton;
28
import javax.swing.JCheckBox;
29
import javax.swing.JPanel;
21 ilm 30
import javax.swing.JScrollPane;
18 ilm 31
import javax.swing.JSeparator;
32
 
33
public class FamilleArticlePanel extends JPanel {
83 ilm 34
    private final SQLElement elt;
18 ilm 35
    private final JCheckBox box = new JCheckBox("Masquer les articles obsoletes");
83 ilm 36
    private final ITreeSelection treeSel;
18 ilm 37
 
83 ilm 38
    public FamilleArticlePanel(SQLElement elt) {
18 ilm 39
        super(new GridBagLayout());
83 ilm 40
 
41
        this.elt = elt;
42
        this.treeSel = new ITreeSelection(elt);
18 ilm 43
        final GridBagConstraints c = new DefaultGridBagConstraints();
44
        c.fill = GridBagConstraints.BOTH;
45
        c.weightx = 1;
46
        c.weighty = 1;
47
        c.gridwidth = GridBagConstraints.REMAINDER;
48
        c.insets = new Insets(0, 0, 0, 0);
49
        treeSel.init(null);
21 ilm 50
        this.add(new JScrollPane(treeSel), c);
18 ilm 51
        // Separateur
52
        c.weighty = 0;
53
        c.gridy++;
54
        this.add(new JSeparator(JSeparator.HORIZONTAL), c);
55
 
56
        // Ligne de boutons
57
        c.insets = new Insets(2, 2, 1, 2);
58
        c.gridy++;
59
        c.gridwidth = 1;
60
        c.gridx = 0;
61
        c.weighty = 0;
62
        final JButton add = new JButton("Ajouter");
63
        this.add(add, c);
64
        c.gridx++;
65
        final JButton remove = new JButton("Supprimer");
66
        this.add(remove, c);
67
        c.gridx++;
68
        final JButton modifier = new JButton("Modifier");
69
        this.add(modifier, c);
70
 
71
        // Checkbox pour masquer les produits obsoletes
72
        c.gridy++;
73
        c.gridx = 0;
74
        c.gridwidth = GridBagConstraints.REMAINDER;
75
        this.add(box, c);
76
 
77
        // Etat
78
 
79
        box.setSelected(true);
80
 
81
        // Listeners
82
        add.addActionListener(new ActionListener() {
83
            @Override
84
            public void actionPerformed(final ActionEvent event) {
85
                treeSel.addElement(treeSel.getSelectedID());
86
            }
87
        });
88
 
89
        remove.addActionListener(new ActionListener() {
90
            @Override
91
            public void actionPerformed(final ActionEvent event) {
92
                treeSel.removeElement(treeSel.getSelectedID());
93
            }
94
        });
95
 
96
        modifier.addActionListener(new ActionListener() {
97
            @Override
98
            public void actionPerformed(final ActionEvent event) {
99
                treeSel.modifyElement(treeSel.getSelectedID());
100
            }
101
        });
102
    }
103
 
104
    public ITreeSelection getFamilleTree() {
105
        return this.treeSel;
106
    }
107
 
108
    public JCheckBox getCheckObsolete() {
109
        return this.box;
110
    }
111
}