OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | 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.config.ComptaPropsConfiguration;
21 ilm 17
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable;
18
import org.openconcerto.erp.core.common.ui.TotalPanel;
18 ilm 19
import org.openconcerto.erp.preferences.DefaultNXProps;
20
import org.openconcerto.sql.Configuration;
21
import org.openconcerto.ui.DefaultGridBagConstraints;
93 ilm 22
import org.openconcerto.ui.VerticalLayout;
18 ilm 23
import org.openconcerto.ui.preferences.DefaultPreferencePanel;
24
import org.openconcerto.ui.preferences.DefaultProps;
25
 
26
import java.awt.GridBagConstraints;
27
import java.awt.GridBagLayout;
28
import java.awt.event.ItemEvent;
29
import java.awt.event.ItemListener;
30
 
31
import javax.swing.BorderFactory;
32
import javax.swing.JCheckBox;
33
import javax.swing.JPanel;
34
 
35
public class GestionArticlePreferencePanel extends DefaultPreferencePanel {
36
 
93 ilm 37
    private final JCheckBox checkModeVente, checkLongueur, checkLargeur, checkPoids;
18 ilm 38
    private final JCheckBox checkService, checkVenteComptoir, checkShowPoids, checkShowStyle, checkSFE;
156 ilm 39
    private final JCheckBox  checkMarge;
73 ilm 40
    private JCheckBox checkSite;
18 ilm 41
 
42
    public GestionArticlePreferencePanel() {
43
        super();
44
        setLayout(new GridBagLayout());
45
        final GridBagConstraints c = new DefaultGridBagConstraints();
46
        c.anchor = GridBagConstraints.NORTHWEST;
47
        c.weightx = 1;
48
 
49
        this.checkSFE = new JCheckBox("Activer la vente de formation");
50
        this.checkService = new JCheckBox("Activer la gestion de vente de service");
51
        this.checkLargeur = new JCheckBox("Largeurs");
52
        this.checkLongueur = new JCheckBox("Longueurs");
53
        this.checkPoids = new JCheckBox("Poids");
54
        this.checkShowStyle = new JCheckBox("Voir la colonne Style");
55
        this.checkModeVente = new JCheckBox("Activer le mode de vente spécifique");
56
        this.checkVenteComptoir = new JCheckBox("Activer le mode vente comptoir");
57
        this.checkShowPoids = new JCheckBox("Voir le Poids");
21 ilm 58
        this.checkMarge = new JCheckBox("Afficher le taux de marque au lieu du taux de marge");
18 ilm 59
 
19 ilm 60
 
21 ilm 61
        this.add(this.checkMarge, c);
62
        c.gridy++;
18 ilm 63
        this.add(this.checkService, c);
64
        c.gridy++;
65
        this.add(this.checkVenteComptoir, c);
66
        c.gridy++;
67
        this.add(this.checkShowPoids, c);
68
        c.gridy++;
69
        this.add(this.checkShowStyle, c);
70
        c.gridy++;
71
        this.add(this.checkModeVente, c);
72
 
73
        final JPanel panelGestionArticle = new JPanel();
74
        panelGestionArticle.setBorder(BorderFactory.createTitledBorder("Gérer les"));
75
        panelGestionArticle.setLayout(new VerticalLayout());
76
        panelGestionArticle.add(this.checkLargeur);
77
        panelGestionArticle.add(this.checkLongueur);
78
        panelGestionArticle.add(this.checkPoids);
79
 
80
        c.gridy++;
81
        c.weighty = 1;
82
        this.add(panelGestionArticle, c);
83
 
84
        setValues();
85
 
86
        this.checkModeVente.addItemListener(new ItemListener() {
87
            public void itemStateChanged(final ItemEvent e) {
88
                enableAdvancedMode(GestionArticlePreferencePanel.this.checkModeVente.isSelected());
89
            }
90
        });
91
    }
92
 
93
    @Override
94
    public void storeValues() {
95
        final DefaultProps props = DefaultNXProps.getInstance();
96
 
97
        props.setProperty("ArticleLongueur", String.valueOf(this.checkLongueur.isSelected()));
98
        props.setProperty("ArticleLargeur", String.valueOf(this.checkLargeur.isSelected()));
99
        props.setProperty("ArticlePoids", String.valueOf(this.checkPoids.isSelected()));
100
        props.setProperty("ArticleShowPoids", String.valueOf(this.checkShowPoids.isSelected()));
101
        props.setProperty("ArticleShowStyle", String.valueOf(this.checkShowStyle.isSelected()));
102
        props.setProperty("ArticleModeVenteAvance", String.valueOf(this.checkModeVente.isSelected()));
103
        props.setProperty("ArticleService", String.valueOf(this.checkService.isSelected()));
104
        props.setProperty("ArticleSFE", String.valueOf(this.checkSFE.isSelected()));
73 ilm 105
        if (this.checkSite != null) {
106
            props.setProperty("ShowSiteFacture", String.valueOf(this.checkSite.isSelected()));
107
        }
18 ilm 108
        props.setProperty("ArticleVenteComptoir", String.valueOf(this.checkVenteComptoir.isSelected()));
21 ilm 109
        props.setProperty(TotalPanel.MARGE_MARQUE, String.valueOf(this.checkMarge.isSelected()));
18 ilm 110
        props.store();
111
    }
112
 
113
    @Override
114
    public void restoreToDefaults() {
115
        this.checkModeVente.setSelected(false);
21 ilm 116
        this.checkShowPoids.setSelected(false);
117
        this.checkShowStyle.setSelected(false);
18 ilm 118
        enableAdvancedMode(false);
119
        this.checkService.setSelected(true);
120
        this.checkSFE.setSelected(false);
41 ilm 121
        this.checkVenteComptoir.setSelected(true);
21 ilm 122
        this.checkMarge.setSelected(false);
73 ilm 123
        if (this.checkSite != null) {
124
            this.checkSite.setSelected(false);
125
        }
18 ilm 126
    }
127
 
128
    @Override
129
    public String getTitleName() {
130
        return "Gestion des articles";
131
    }
132
 
133
    private void setValues() {
134
        final DefaultProps props = DefaultNXProps.getInstance();
135
        // service
136
        final String service = props.getStringProperty("ArticleService");
137
        final Boolean bService = Boolean.valueOf(service);
138
        this.checkService.setSelected(bService == null || bService.booleanValue());
139
 
140
        // SFE
141
        final String sfe = props.getStringProperty("ArticleSFE");
142
        final Boolean bSfe = Boolean.valueOf(sfe);
143
        this.checkSFE.setSelected(bSfe != null && bSfe.booleanValue());
144
 
145
        // vente comptoir
41 ilm 146
        final Boolean bVenteComptoir = DefaultNXProps.getInstance().getBooleanValue("ArticleVenteComptoir", true);
18 ilm 147
        this.checkVenteComptoir.setSelected(bVenteComptoir != null && bVenteComptoir.booleanValue());
148
 
149
        // longueur
150
        final String longueur = props.getStringProperty("ArticleLongueur");
151
        final Boolean bLong = Boolean.valueOf(longueur);
152
        this.checkLongueur.setSelected(bLong == null || bLong.booleanValue());
153
 
154
        // Largeur
155
        final String largeur = props.getStringProperty("ArticleLargeur");
156
        final Boolean bLarg = Boolean.valueOf(largeur);
157
        this.checkLargeur.setSelected(bLarg == null || bLarg.booleanValue());
158
 
159
        // Poids
160
        final String poids = props.getStringProperty("ArticlePoids");
161
        final Boolean bPoids = Boolean.valueOf(poids);
162
        this.checkPoids.setSelected(bPoids == null || bPoids.booleanValue());
163
 
164
        // Show Poids
21 ilm 165
        this.checkShowPoids.setSelected(props.getBooleanValue("ArticleShowPoids", false));
18 ilm 166
 
167
        // Show Style
21 ilm 168
        this.checkShowStyle.setSelected(props.getBooleanValue("ArticleShowStyle", false));
18 ilm 169
 
156 ilm 170
 
21 ilm 171
        // Devise
172
        this.checkMarge.setSelected(props.getBooleanValue(TotalPanel.MARGE_MARQUE, false));
173
 
18 ilm 174
        // Mode vente
175
        final String modeVente = props.getStringProperty("ArticleModeVenteAvance");
176
        final Boolean bModeVente = Boolean.valueOf(modeVente);
177
        this.checkModeVente.setSelected(bModeVente == null || bModeVente.booleanValue());
178
        enableAdvancedMode(bModeVente == null || bModeVente.booleanValue());
179
 
73 ilm 180
        // Site
181
        if (this.checkSite != null) {
182
            // Show Style
183
            final String s = props.getStringProperty("ShowSiteFacture");
184
            final Boolean b = s.equalsIgnoreCase("true");
185
            this.checkSite.setSelected(b != null && b);
186
        }
18 ilm 187
    }
188
 
189
    /**
190
     * Active le mode de gestion avancé avec les metriques
191
     */
192
    private void enableAdvancedMode(final boolean b) {
193
        this.checkLargeur.setEnabled(b);
194
        this.checkLongueur.setEnabled(b);
195
        this.checkPoids.setEnabled(b);
196
    }
197
 
198
}