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