OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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