OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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