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