Dépôt officiel du code source de l'ERP OpenConcerto
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/ModuleOperation.java |
---|
34,7 → 34,6 |
import org.openconcerto.sql.utils.SQLCreateTable; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.RowAction; |
import org.openconcerto.sql.view.list.action.ListEvent; |
import org.openconcerto.ui.FrameUtil; |
import org.openconcerto.utils.i18n.TranslationManager; |
113,7 → 112,7 |
} |
}, true) { |
@Override |
public boolean enabledFor(List<SQLRowValues> values) { |
public boolean enabledFor(IListeEvent evt) { |
return true; |
} |
/trunk/Modules/Module Project/src/org/openconcerto/modules/project/Module.java |
---|
86,7 → 86,6 |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.RowAction; |
import org.openconcerto.sql.view.list.action.ListEvent; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.FrameUtil; |
import org.openconcerto.ui.PanelFrame; |
244,7 → 243,7 |
RowAction cloneAction = eltDevis.getCloneAction(); |
eltDevis.getRowActions().add(cloneAction); |
MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(eltDevis, DevisXmlSheet.class); |
MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(DevisXmlSheet.class); |
mouseSheetXmlListeListener.setGenerateHeader(true); |
mouseSheetXmlListeListener.setShowHeader(true); |
eltDevis.getRowActions().addAll(mouseSheetXmlListeListener.getRowActions()); |
314,9 → 313,9 |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> evt) { |
if (evt.size() == 1) { |
SQLRowAccessor r = evt.get(0); |
public boolean enabledFor(IListeEvent evt) { |
if (evt.getSelectedRows().size() == 1) { |
SQLRowAccessor r = evt.getSelectedRow(); |
return !r.isForeignEmpty("ID_AFFAIRE"); |
} |
return false; |
358,9 → 357,9 |
}, false) { |
@Override |
public boolean enabledFor(List<SQLRowValues> evt) { |
if (evt.size() == 1) { |
SQLRowAccessor r = evt.get(0); |
public boolean enabledFor(IListeEvent evt) { |
if (evt.getSelectedRows().size() == 1) { |
SQLRowAccessor r = evt.getSelectedRow(); |
Collection<? extends SQLRowAccessor> l = r.getReferentRows(r.getTable().getTable("AFFAIRE")); |
return l.size() > 0; |
} |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/DateProcessor.java |
---|
26,7 → 26,7 |
} |
@Override |
public void process(List<SQLRowAccessor> r) throws SQLException { |
public void process(List<SQLRowValues> r) throws SQLException { |
final Date date = d.getDate(); |
for (SQLRowAccessor sqlRowAccessor : r) { |
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow(); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BooleanProcessor.java |
---|
37,7 → 37,7 |
} |
@Override |
public void process(List<SQLRowAccessor> r) throws SQLException { |
public void process(List<SQLRowValues> r) throws SQLException { |
if (bTrue.isSelected()) { |
for (SQLRowAccessor sqlRowAccessor : r) { |
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow(); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchProcessor.java |
---|
10,7 → 10,7 |
boolean checkParameters(); |
void process(List<SQLRowAccessor> r) throws SQLException; |
void process(List<SQLRowValues> r) throws SQLException; |
void processBeforeUpdate(SQLRowAccessor from, SQLRowValues to); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchField.java |
---|
18,11 → 18,9 |
private final SQLRowAccessor foreignLinkRow; |
private final SQLFieldTranslator translator; |
private final SQLElement elementLink; |
private final SQLElementDirectory dir; |
public BatchField(SQLElementDirectory dir, SQLField field, SQLRowAccessor foreignLinkRow) { |
this.field = field; |
this.dir = dir; |
this.foreignLinkRow = foreignLinkRow; |
this.translator = dir.getTranslator(); |
33,14 → 31,6 |
} |
} |
private SQLField fieldToMatch; |
private Object matchingValue; |
public void setDefaultMatchingValue(SQLField fieldToMatch, Object value) { |
this.fieldToMatch = fieldToMatch; |
this.matchingValue = value; |
} |
public SQLField getField() { |
return field; |
} |
49,18 → 39,8 |
return foreignLinkRow; |
} |
public SQLField getFieldToMatch() { |
return fieldToMatch; |
} |
public Object getMatchingValue() { |
return matchingValue; |
} |
public String getComboName() { |
if (this.fieldToMatch != null) { |
return this.dir.getElement(this.fieldToMatch.getTable()).getPluralName() + " " + this.translator.getLabelFor(this.field) + " " + this.matchingValue; |
} else if (this.foreignLinkRow == null) { |
if (this.foreignLinkRow == null) { |
return this.translator.getLabelFor(this.field); |
} else { |
return this.elementLink.getPluralName() + " " + this.foreignLinkRow.getString("NOM") + " " + this.translator.getLabelFor(this.field); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/Module.java |
---|
13,7 → 13,6 |
import org.openconcerto.erp.modules.ModuleFactory; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
31,12 → 30,11 |
super.setupComponents(ctxt); |
final SQLElement element = ctxt.getElement("ARTICLE"); |
final RowAction.PredicateRowAction editAction = new RowAction.PredicateRowAction( |
new AbstractAction("Traitement par lot...") { |
final RowAction.PredicateRowAction editAction = new RowAction.PredicateRowAction(new AbstractAction("Traitement par lot...") { |
@Override |
public void actionPerformed(ActionEvent e) { |
final List<SQLRowAccessor> rows = IListe.get(e).getSelectedRowAccessors(); |
final List<SQLRowValues> rows = IListe.get(e).getSelectedRows(); |
final int size = rows.size(); |
if (size > 0) { |
final JFrame f = new JFrame(); |
55,8 → 53,7 |
}; |
f.setContentPane( |
new BatchEditorPanel(ctxt.getElement("ARTICLE").getDirectory(), rows, filter)); |
f.setContentPane(new BatchEditorPanel(ctxt.getElement("ARTICLE").getDirectory(), rows, filter)); |
f.pack(); |
f.setMinimumSize(new Dimension(400, 300)); |
f.setLocationRelativeTo(IListe.get(e)); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/NumberProcessor.java |
---|
13,14 → 13,9 |
import javax.swing.JRadioButton; |
import javax.swing.JTextField; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
import org.openconcerto.erp.utils.ConvertDevise; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.UpdateBuilder; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
public class NumberProcessor extends JPanel implements BatchProcessor { |
111,51 → 106,20 |
} |
@Override |
public void process(List<SQLRowAccessor> r) throws SQLException { |
public void process(List<SQLRowValues> r) throws SQLException { |
if (bReplace.isSelected()) { |
BigDecimal v = new BigDecimal(this.tReplace.getText().trim()); |
final SQLField fieldToMatch = batchfield.getFieldToMatch(); |
if (fieldToMatch != null) { |
UpdateBuilder build = new UpdateBuilder(fieldToMatch.getTable()); |
build.setObject(batchfield.getField().getName(), (BigDecimal) decimalToFieldType(v)); |
build.setWhere( |
Where.inValues(fieldToMatch.getTable().getField("ID_" + r.get(0).getTable().getName()), SQLRow.getIDs(r)).and(new Where(fieldToMatch, "=", batchfield.getMatchingValue()))); |
fieldToMatch.getTable().getDBSystemRoot().getDataSource().execute(build.asString()); |
} else { |
for (SQLRowAccessor sqlRowAccessor : r) { |
if (batchfield.getForeignLinkRow() != null) { |
final List<SQLRow> referentRow = batchfield.getReferentRows(sqlRowAccessor); |
if (referentRow.isEmpty()) { |
SQLRowValues rowVals = new SQLRowValues(batchfield.getField().getTable()); |
rowVals.put("ID_" + sqlRowAccessor.getTable().getName(), sqlRowAccessor.getID()); |
rowVals.put("ID_" + batchfield.getForeignLinkRow().getTable().getName(), batchfield.getForeignLinkRow().getID()); |
rowVals.put(batchfield.getField().getName(), decimalToFieldType(v)); |
final BigDecimal taux = BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(sqlRowAccessor.getForeignID("ID_TAXE"))); |
final BigDecimal ht = (BigDecimal) decimalToFieldType(v); |
final BigDecimal ttc = ConvertDevise.getTtcFromHt(ht, taux, rowVals.getTable().getField("PV_TTC").getType().getDecimalDigits()); |
rowVals.put("PV_TTC", ttc); |
rowVals.put("PRIX_METRIQUE_VT_1", decimalToFieldType(v)); |
rowVals.commit(); |
} else { |
for (SQLRow sqlRowT : referentRow) { |
SQLRowValues rowValues = sqlRowT.createEmptyUpdateRow(); |
rowValues.put(batchfield.getField().getName(), decimalToFieldType(v)); |
if (!batchfield.getField().getName().equals("QTE_MIN") && !batchfield.getField().getName().equals("POURCENT_REMISE")) { |
// processBeforeUpdate(sqlRowT, rowValues); |
final BigDecimal taux = sqlRowT.isForeignEmpty("ID_TAXE") ? BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(sqlRowAccessor.getForeignID("ID_TAXE"))) |
: BigDecimal.valueOf(TaxeCache.getCache().getTauxFromId(sqlRowT.getForeignID("ID_TAXE"))); |
final BigDecimal ht = rowValues.getBigDecimal("PV_HT"); |
final BigDecimal ttc = ConvertDevise.getTtcFromHt(ht, taux, rowValues.getTable().getField("PV_TTC").getType().getDecimalDigits()); |
rowValues.put("PV_TTC", ttc); |
rowValues.put("PRIX_METRIQUE_VT_1", ht); |
} |
processBeforeUpdate(sqlRowT, rowValues); |
rowValues.update(); |
} |
} |
} else { |
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow(); |
rowValues.put(batchfield.getField().getName(), decimalToFieldType(v)); |
163,7 → 127,6 |
rowValues.update(); |
} |
} |
} |
} else if (bAdd.isSelected()) { |
String t = this.tAdd.getText().trim(); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/ReferenceProcessor.java |
---|
41,7 → 41,7 |
} |
@Override |
public void process(List<SQLRowAccessor> r) throws SQLException { |
public void process(List<SQLRowValues> r) throws SQLException { |
for (SQLRowAccessor sqlRowAccessor : r) { |
final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow(); |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/ForbiddenFieldName.java |
---|
4,6 → 4,6 |
public static boolean isAllowed(String field) { |
String f = field.toUpperCase(); |
return !(f.equals("ARCHIVE") || f.equals("ORDRE") || f.equals("ID_USER_CREATE") || f.equals("ID_USER_COMMON_CREATE") || f.equals("ID_USER_MODIFY") || f.equals("ID_USER_COMMON_MODIFY") |
|| f.equals("MODIFICATION_DATE") || f.equals("CREATION_DATE")|| f.equals("QTE_MIN")); |
|| f.equals("MODIFICATION_DATE") || f.equals("CREATION_DATE")); |
} |
} |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/StringProcessor.java |
---|
134,7 → 134,7 |
} |
@Override |
public void process(List<SQLRowAccessor> r) throws SQLException { |
public void process(List<SQLRowValues> r) throws SQLException { |
if (bReplace.isSelected()) { |
final String t = ensureSize(tReplace.getText()); |
for (SQLRowAccessor sqlRowAccessor : r) { |
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchEditorPanel.java |
---|
8,11 → 8,9 |
import java.awt.event.ActionListener; |
import java.awt.event.ItemEvent; |
import java.awt.event.ItemListener; |
import java.math.BigDecimal; |
import java.util.ArrayList; |
import java.util.Collections; |
import java.util.Comparator; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
29,11 → 27,10 |
import org.openconcerto.sql.element.SQLElementDirectory; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowListRSH; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.request.SQLFieldTranslator; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.JLabelBold; |
42,7 → 39,7 |
public class BatchEditorPanel extends JPanel { |
public BatchEditorPanel(final SQLElementDirectory dir, final List<SQLRowAccessor> rows, FieldFilter filter) { |
public BatchEditorPanel(final SQLElementDirectory dir, final List<SQLRowValues> rows, FieldFilter filter) { |
SQLFieldTranslator translator = dir.getTranslator(); |
Set<SQLField> fields = rows.get(0).getTable().getFields(); |
List<BatchField> f = new ArrayList<BatchField>(); |
53,8 → 50,6 |
} |
} |
} |
// Tarif |
SQLTable tableTarif = rows.get(0).getTable().getTable("TARIF"); |
SQLTable tableArticleTarif = rows.get(0).getTable().getTable("ARTICLE_TARIF"); |
SQLSelect sel = new SQLSelect(); |
67,47 → 62,6 |
} |
} |
// Tarif Promo |
SQLTable tableTarifPromo = rows.get(0).getTable().getTable("TARIF_PROMOTION"); |
SQLTable tableArticleTarifPromo = rows.get(0).getTable().getTable("ARTICLE_TARIF_PROMOTION"); |
SQLSelect selT = new SQLSelect(); |
selT.addSelectStar(tableTarifPromo); |
List<SQLRow> rowTarifP = SQLRowListRSH.execute(selT); |
for (SQLRow sqlRow : rowTarifP) { |
f.add(new BatchField(dir, tableArticleTarifPromo.getField("PV_HT"), sqlRow)); |
} |
// Tarif quantite |
SQLTable tableTarifQte = rows.get(0).getTable().getTable("TARIF_QUANTITE"); |
SQLSelect selQ = new SQLSelect(); |
selQ.addSelectStar(tableTarifQte); |
Where w = Where.inValues(tableTarifQte.getField("ID_" + rows.get(0).getTable().getName()), SQLRow.getIDs(rows)); |
selQ.setWhere(w); |
List<SQLRow> rowTarifQ = SQLRowListRSH.execute(selQ); |
Set<BigDecimal> qtes = new HashSet<>(); |
for (SQLRow sqlRow : rowTarifQ) { |
final BigDecimal qte = sqlRow.getBigDecimal("QUANTITE"); |
if (!qtes.contains(qte)) { |
qtes.add(qte); |
final BatchField batchFieldQte = new BatchField(dir, sqlRow.getTable().getField("PRIX_METRIQUE_VT_1"), null); |
batchFieldQte.setDefaultMatchingValue(sqlRow.getTable().getField("QUANTITE"), qte); |
f.add(batchFieldQte); |
final BatchField batchFieldRemise = new BatchField(dir, sqlRow.getTable().getField("POURCENT_REMISE"), null); |
batchFieldRemise.setDefaultMatchingValue(sqlRow.getTable().getField("QUANTITE"), qte); |
f.add(batchFieldRemise); |
} |
} |
// Stock |
SQLTable tableDepotStock = rows.get(0).getTable().getTable("DEPOT_STOCK"); |
SQLTable tableStock = tableDepotStock.getTable("STOCK"); |
SQLSelect selDepot = new SQLSelect(); |
selDepot.addSelectStar(tableDepotStock); |
List<SQLRow> rowDepot = SQLRowListRSH.execute(selDepot); |
for (SQLRow sqlRow : rowDepot) { |
f.add(new BatchField(dir, tableStock.getField("QTE_MIN"), sqlRow)); |
} |
Collections.sort(f, new Comparator<BatchField>() { |
@Override |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ImagePrintable.java |
---|
File deleted |
\ No newline at end of file |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/GPLPrinterPanel.java |
---|
File deleted |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ModuleLabel.java |
---|
8,10 → 8,8 |
import java.io.IOException; |
import java.nio.charset.StandardCharsets; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.LinkedHashMap; |
import java.util.List; |
import java.util.Map; |
import java.util.Map.Entry; |
import java.util.TreeMap; |
23,7 → 21,6 |
import org.openconcerto.erp.modules.AbstractModule; |
import org.openconcerto.erp.modules.ComponentsContext; |
import org.openconcerto.erp.modules.ModuleFactory; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
40,8 → 37,6 |
public final class ModuleLabel extends AbstractModule { |
final LinkedHashMap<String, String> zplTemplates = new LinkedHashMap<String, String>(); |
final LinkedHashMap<String, String> gplTemplates = new LinkedHashMap<String, String>(); |
private Map<String, File> dirMap = new HashMap<>(); |
public ModuleLabel(ModuleFactory f) throws IOException { |
super(f); |
59,7 → 54,7 |
public void actionPerformed(ActionEvent arg0) { |
final IListe list = IListe.get(arg0); |
final List<Integer> selectedIDs = list.getSelection().getSelectedIDs(); |
final SQLTable tArticle = list.getSelectedRowAccessors().get(0).getTable(); |
final SQLTable tArticle = list.getSelectedRows().get(0).getTable(); |
final SwingWorker<List<RowValuesLabel>, String> wworker = new SwingWorker<List<RowValuesLabel>, String>() { |
@Override |
219,68 → 214,12 |
final JFrame f = new JFrame(); |
final IListe list = IListe.get(arg0); |
final int idProduct = list.getSelection().getSelectedID(); |
final SQLTable tArticle = list.getSelectedRowAccessors().get(0).getTable(); |
final SQLTable tArticle = list.getSelectedRows().get(0).getTable(); |
final SwingWorker<SQLRowValues, String> wworker = new SwingWorker<SQLRowValues, String>() { |
@Override |
protected SQLRowValues doInBackground() throws Exception { |
SQLRowValues rArticle = new SQLRowValues(tArticle); |
rArticle.putNulls(tArticle.getFieldsName()); |
for (SQLField f : tArticle.getFields()) { |
if (f.getName().startsWith("ID_ARTICLE_DECLINAISON_")) { |
SQLRowValues rowValsDecl = rArticle.putRowValues(f.getName()); |
rowValsDecl.putNulls(f.getForeignTable().getFieldsName()); |
} |
} |
final List<SQLRowValues> fetchRow = SQLRowValuesListFetcher.create(rArticle).fetch(new Where(tArticle.getKey(), "=", idProduct)); |
return fetchRow.get(0); |
} |
@Override |
protected void done() { |
try { |
final SQLRowValues values = get(); |
p.initUI(values); |
f.setTitle(entry.getKey()); |
f.setContentPane(p); |
f.pack(); |
f.setLocationRelativeTo(null); |
f.setVisible(true); |
} catch (Exception e) { |
ExceptionHandler.handle("Erreur d'impression", e); |
} |
} |
}; |
wworker.execute(); |
} |
}, true, false); |
action.setPredicate(IListeEvent.createSelectionCountPredicate(1, 1)); |
ctxt.getElement("ARTICLE").getRowActions().add(action); |
} |
} |
if (!gplTemplates.isEmpty()) { |
for (final Entry<String, String> entry : gplTemplates.entrySet()) { |
final String gpl = entry.getValue(); |
final PredicateRowAction action = new PredicateRowAction(new AbstractAction("Imprimer l'étiquette " + entry.getKey()) { |
@Override |
public void actionPerformed(ActionEvent arg0) { |
final GPLPrinterPanel p = new GPLPrinterPanel(gpl, getDir(entry.getKey())); |
final JFrame f = new JFrame(); |
final IListe list = IListe.get(arg0); |
final int idProduct = list.getSelection().getSelectedID(); |
final SQLTable tArticle = list.getSelectedRowAccessors().get(0).getTable(); |
final SwingWorker<SQLRowValues, String> wworker = new SwingWorker<SQLRowValues, String>() { |
@Override |
protected SQLRowValues doInBackground() throws Exception { |
final SQLRow row = tArticle.getRow(idProduct); |
row.fetchValues(); |
return row.asRowValues(); |
314,10 → 253,6 |
} |
protected File getDir(String value) { |
return dirMap.get(value); |
} |
@Override |
protected void start() { |
329,44 → 264,23 |
System.err.println("ModuleLabel.readTemplates() " + templatesDir.getAbsolutePath()); |
File[] files = templatesDir.listFiles(); |
if (files != null) { |
LinkedHashMap<String, String> zmap = new LinkedHashMap<>(); |
LinkedHashMap<String, String> gmap = new LinkedHashMap<>(); |
LinkedHashMap<String, String> map = new LinkedHashMap<>(); |
for (File f : files) { |
if (f.getName().endsWith(".zpl")) { |
try { |
String zpl = FileUtils.read(f, StandardCharsets.UTF_8); |
String name = f.getName().substring(0, f.getName().length() - 4).trim(); |
zmap.put(name, zpl); |
dirMap.put(name, templatesDir); |
map.put(name, zpl); |
System.err.println("ModuleLabel.readTemplates() add " + name); |
} catch (Exception e) { |
System.err.println(this.getClass().getCanonicalName() + "start() cannot read zpl template : " + f.getAbsolutePath() + " : " + e.getMessage()); |
} |
} else if (f.getName().endsWith(".graphicspl")) { |
try { |
String zpl = FileUtils.read(f, StandardCharsets.UTF_8); |
String name = f.getName().substring(0, f.getName().length() - ".graphicspl".length()).trim(); |
gmap.put(name, zpl); |
dirMap.put(name, templatesDir); |
} catch (Exception e) { |
System.err.println(this.getClass().getCanonicalName() + "start() cannot read graphicspl template : " + f.getAbsolutePath() + " : " + e.getMessage()); |
} |
} |
} |
// Tri de la map par clef |
final TreeMap<String, String> copy1 = new TreeMap<>(zmap); |
zplTemplates.clear(); |
zplTemplates.putAll(copy1); |
final TreeMap<String, String> copy2 = new TreeMap<>(gmap); |
gplTemplates.clear(); |
gplTemplates.putAll(copy2); |
final TreeMap<String, String> copy = new TreeMap<>(map); |
this.zplTemplates.clear(); |
this.zplTemplates.putAll(copy); |
} |
} else { |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ZPLPrinterPanel.java |
---|
13,7 → 13,6 |
import java.io.FileOutputStream; |
import java.io.IOException; |
import java.io.StringReader; |
import java.math.BigDecimal; |
import java.net.Socket; |
import java.nio.charset.StandardCharsets; |
import java.text.DecimalFormat; |
90,26 → 89,25 |
public ZPLPrinterPanel(String zpl) { |
this.zpl = zpl; |
this.variables = getVariables(zpl); |
this.knownVariables.add("product.code"); |
this.knownVariables.add("product.name"); |
this.knownVariables.add("product.material"); |
this.knownVariables.add("product.color"); |
this.knownVariables.add("product.size"); |
this.knownVariables.add("product.ean13"); |
this.knownVariables.add("product.price"); |
this.knownVariables.add("product.pricewithtax"); |
knownVariables.add("product.code"); |
knownVariables.add("product.name"); |
knownVariables.add("product.material"); |
knownVariables.add("product.ean13"); |
knownVariables.add("product.price"); |
knownVariables.add("product.pricewithtax"); |
// |
this.mapName.put("product.name", "Nom"); |
this.mapName.put("product.code", "Code"); |
this.mapName.put("product.ean13", "Code à barres"); |
this.mapName.put("product.price", "Prix HT"); |
this.mapName.put("product.pricewithtax", "Prix TTC"); |
this.mapName.put("product.treatment", "Traitement"); |
this.mapName.put("product.origin", "Origine"); |
this.mapName.put("product.batch", "Lot"); |
this.mapName.put("product.size", "Taille"); |
this.mapName.put("product.color", "Couleur"); |
this.mapName.put("product.material", "Matière"); |
mapName.put("product.name", "Nom"); |
mapName.put("product.code", "Code"); |
mapName.put("product.ean13", "Code à barres"); |
mapName.put("product.price", "Prix HT"); |
mapName.put("product.pricewithtax", "Prix TTC"); |
mapName.put("product.treatment", "Traitement"); |
mapName.put("product.origin", "Origine"); |
mapName.put("product.batch", "Lot"); |
mapName.put("product.size", "Taille"); |
mapName.put("product.color", "Couleur"); |
mapName.put("product.material", "Matière"); |
} |
private final File getPrefFile() { |
130,7 → 128,7 |
System.out.println(file.getAbsolutePath()); |
if (file.exists()) { |
try { |
this.properties.load(new FileInputStream(file)); |
properties.load(new FileInputStream(file)); |
} catch (IOException e) { |
e.printStackTrace(); |
} |
145,7 → 143,7 |
Set<String> added = new HashSet<>(); |
for (String v : this.knownVariables) { |
if (this.variables.contains(v)) { |
if (variables.contains(v)) { |
// Non editable |
String label = getName(v); |
c.gridx = 0; |
160,7 → 158,7 |
txt.setText(value); |
txt.setEditable(false); |
} |
this.editorMap.put(v, txt); |
editorMap.put(v, txt); |
this.add(txt, c); |
added.add(v); |
c.gridy++; |
176,7 → 174,7 |
c.gridx++; |
c.weightx = 1; |
JTextField txt = new JTextField(20); |
this.editorMap.put(v, txt); |
editorMap.put(v, txt); |
this.add(txt, c); |
added.add(v); |
c.gridy++; |
235,15 → 233,15 |
c.anchor = GridBagConstraints.SOUTHEAST; |
// Restore state from properties |
if (this.properties.getOrDefault("printerType", "local").equals("local")) { |
if (properties.getOrDefault("printerType", "local").equals("local")) { |
radioLocalPrinter.setSelected(true); |
} else { |
radioNetworkPrinter.setSelected(true); |
} |
textPrinterIP.setText(this.properties.getOrDefault("printerIp", "").toString()); |
portZPL.setValue(Long.parseLong(this.properties.getOrDefault("printerPort", "9100").toString())); |
nbLabels.setValue(Long.parseLong(this.properties.getOrDefault("nbLabels", "1").toString())); |
delayLabels.setValue(Long.parseLong(this.properties.getOrDefault("delay", "800").toString())); |
textPrinterIP.setText(properties.getOrDefault("printerIp", "").toString()); |
portZPL.setValue(Long.parseLong(properties.getOrDefault("printerPort", "9100").toString())); |
nbLabels.setValue(Long.parseLong(properties.getOrDefault("nbLabels", "1").toString())); |
delayLabels.setValue(Long.parseLong(properties.getOrDefault("delay", "800").toString())); |
JButton printButton = new JButton("Imprimer"); |
254,16 → 252,16 |
public void actionPerformed(ActionEvent e) { |
try { |
if (radioLocalPrinter.isSelected()) { |
ZPLPrinterPanel.this.properties.put("printerType", "local"); |
properties.put("printerType", "local"); |
} else { |
ZPLPrinterPanel.this.properties.put("printerType", "network"); |
ZPLPrinterPanel.this.properties.put("printerIp", textPrinterIP.getText()); |
ZPLPrinterPanel.this.properties.put("printerPort", portZPL.getValue().toString()); |
properties.put("printerType", "network"); |
properties.put("printerIp", textPrinterIP.getText()); |
properties.put("printerPort", portZPL.getValue().toString()); |
} |
ZPLPrinterPanel.this.properties.put("nbLabels", nbLabels.getValue().toString()); |
ZPLPrinterPanel.this.properties.put("delay", delayLabels.getValue().toString()); |
properties.put("nbLabels", nbLabels.getValue().toString()); |
properties.put("delay", delayLabels.getValue().toString()); |
// Save Prefs |
ZPLPrinterPanel.this.properties.store(new FileOutputStream(getPrefFile()), ""); |
properties.store(new FileOutputStream(getPrefFile()), ""); |
} catch (Exception e1) { |
ExceptionHandler.handle("Erreur de sauvegarde de " + getPrefFile().getAbsolutePath(), e1); |
} |
298,10 → 296,10 |
final PrinterJob pj1 = PrinterJob.getPrinterJob(); |
if (pj1.printDialog()) { |
final PrintService ps = pj1.getPrintService(); |
final DocPrintJob pj = ps.createPrintJob(); |
final SimpleDoc doc = new SimpleDoc(data, DocFlavor.BYTE_ARRAY.AUTOSENSE, null); |
final int nb = ((Number) nbLabels.getValue()).intValue(); |
for (int i = 0; i < nb; i++) { |
final DocPrintJob pj = ps.createPrintJob(); |
final SimpleDoc doc = new SimpleDoc(data, DocFlavor.BYTE_ARRAY.AUTOSENSE, null); |
pj.print(doc, null); |
Thread.sleep(((Number) delayLabels.getValue()).intValue()); |
} |
359,7 → 357,6 |
if (row == null) { |
return null; |
} |
System.err.println("ZPLPrinterPanel.getValueAsString()" + variableName + " : " + row); |
if (variableName.equals("product.code")) { |
return row.getString("CODE"); |
} else if (variableName.equals("product.name")) { |
367,31 → 364,17 |
} else if (variableName.equals("product.ean13")) { |
return row.getString("CODE_BARRE"); |
} else if (variableName.equals("product.price")) { |
final BigDecimal bigDecimal = row.getBigDecimal("PV_HT"); |
return new DecimalFormat("#0.00").format(bigDecimal); |
return new DecimalFormat("#0.00").format(row.getBigDecimal("PV_HT")); |
} else if (variableName.equals("product.pricewithtax")) { |
final BigDecimal bigDecimal = row.getBigDecimal("PV_TTC"); |
return new DecimalFormat("#0.00").format(bigDecimal); |
return new DecimalFormat("#0.00").format(row.getBigDecimal("PV_TTC")); |
} else if (variableName.equals("product.material")) { |
return row.getString("MATIERE"); |
} else if (variableName.equals("product.color")) { |
if (row.getTable().contains("ID_ARTICLE_DECLINAISON_COULEUR")) { |
if (row.getObject("ID_ARTICLE_DECLINAISON_COULEUR") != null && !row.isForeignEmpty("ID_ARTICLE_DECLINAISON_COULEUR")) { |
return row.getForeign("ID_ARTICLE_DECLINAISON_COULEUR").getString("NOM"); |
} |
} |
} else if (variableName.equals("product.size")) { |
if (row.getTable().contains("ID_ARTICLE_DECLINAISON_TAILLE")) { |
if (row.getObject("ID_ARTICLE_DECLINAISON_TAILLE") != null && !row.isForeignEmpty("ID_ARTICLE_DECLINAISON_TAILLE")) { |
return row.getForeign("ID_ARTICLE_DECLINAISON_TAILLE").getString("NOM"); |
} |
} |
} |
return ""; |
} |
public String getName(String variableName) { |
String n = this.mapName.get(variableName); |
String n = mapName.get(variableName); |
if (n == null) { |
return variableName; |
} |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/gs1/GS1Util.java |
---|
21,7 → 21,6 |
// character. |
// ]d2 : GS1 DataMatrix : Standard AI element strings |
private static final String GS1_DATAMATRIX_SCANNER_PREFIX = "]d2"; |
private static final String GS1_DATAMATRIX_SCANNER_PREFIX_2 = "]D2"; |
// ]Q3 : GS1 QR Code : Standard AI element strings |
private static final String GS1_QRCODE_SCANNER_PREFIX = "]Q3"; |
// ]J1 : GS1 DotCode : Standard AI element strings |
52,8 → 51,7 |
} |
public GS1AIElements parseFromScanner(String scan) throws GS1ParseException { |
if (scan.startsWith(GS1_DATAMATRIX_SCANNER_PREFIX) || scan.startsWith(GS1_DATAMATRIX_SCANNER_PREFIX_2) || scan.startsWith(GS1_128_SCANNER_PREFIX) || scan.startsWith(GS1_DATABAR_SCANNER_PREFIX) |
|| scan.startsWith(GS1_QRCODE_SCANNER_PREFIX)) { |
if (scan.startsWith(GS1_DATAMATRIX_SCANNER_PREFIX) || scan.startsWith(GS1_128_SCANNER_PREFIX) || scan.startsWith(GS1_DATABAR_SCANNER_PREFIX) || scan.startsWith(GS1_QRCODE_SCANNER_PREFIX)) { |
return parse(scan.substring(3)); |
} |
return parse(scan); |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/GPLDemoFrame.java |
---|
File deleted |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/GPLRenderer.java |
---|
96,9 → 96,7 |
String fileName = element.getAttribute("file"); |
int x = Math.round(ratio * Integer.parseInt(element.getAttribute("x"))); |
int y = Math.round(ratio * Integer.parseInt(element.getAttribute("y"))); |
final File input = new File(graphicsPL.getImageDir(), fileName); |
if (input.exists()) { |
BufferedImage img = ImageIO.read(input); |
BufferedImage img = ImageIO.read(new File(graphicsPL.getImageDir(), fileName)); |
int w = Math.round(ratio * img.getWidth()); |
int h = Math.round(ratio * img.getHeight()); |
if (element.hasAttribute("width")) { |
108,9 → 106,6 |
h = Math.round(ratio * Integer.parseInt(element.getAttribute("height"))); |
} |
drawImage(x, y, w, h, img); |
} else { |
throw new IllegalStateException(input.getAbsolutePath() + " not found"); |
} |
} else if (name.equals("barcode")) { |
int x = Math.round(ratio * Integer.parseInt(element.getAttribute("x"))); |
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/graphicspl/GraphicsPL.java |
---|
24,8 → 24,8 |
import org.xml.sax.SAXException; |
public class GraphicsPL { |
private String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><graphicspl height=\"400\" width=\"600\"/>"; |
private Document doc; |
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><graphicspl height=\"400\" width=\"600\"/>"; |
Document doc; |
private File imgDir; |
public static void main(String[] args) throws Exception { |
75,7 → 75,6 |
final BufferedImage img = createImage(ratio); |
g2d.drawImage(img, (int) Math.round(pf.getImageableX()), (int) Math.round(pf.getImageableY()), width, height, null); |
} catch (ParserConfigurationException | SAXException | IOException e) { |
e.printStackTrace(); |
throw new PrinterException(e.getMessage()); |
} |
return PAGE_EXISTS; |
83,13 → 82,13 |
}; |
} |
public String getZPL() throws IOException { |
private String getZPL() throws IOException { |
final ZPLRenderer renderer = new ZPLRenderer(); |
renderer.render(this); |
return renderer.getZPL(); |
} |
public BufferedImage createImage(float ratio) throws ParserConfigurationException, SAXException, IOException { |
private BufferedImage createImage(float ratio) throws ParserConfigurationException, SAXException, IOException { |
final Element root = this.doc.getDocumentElement(); |
final int width = Math.round(ratio * Integer.parseInt(root.getAttribute("width"))); |
final int height = Math.round(ratio * Integer.parseInt(root.getAttribute("height"))); |
107,7 → 106,7 |
return this.doc; |
} |
public void load(File file) throws ParserConfigurationException, SAXException, IOException { |
private void load(File file) throws ParserConfigurationException, SAXException, IOException { |
this.xml = new String(Files.readAllBytes(file.toPath())); |
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
// factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); |
118,17 → 117,6 |
this.imgDir = file.getParentFile(); |
} |
public void load(String str, File imageDir) throws ParserConfigurationException, SAXException, IOException { |
this.xml = str; |
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
// factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); |
final DocumentBuilder builder = factory.newDocumentBuilder(); |
final ByteArrayInputStream input = new ByteArrayInputStream(this.xml.getBytes(StandardCharsets.UTF_8)); |
this.doc = builder.parse(input); |
this.doc.getDocumentElement().normalize(); |
this.imgDir = imageDir; |
} |
public File getImageDir() { |
return this.imgDir; |
} |
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/BonCommandeAboPanel.java |
---|
50,7 → 50,7 |
@Override |
protected List<RowAction> getAdditionnalRowActions() { |
return new MouseSheetXmlListeListener(this.eltCmd, CommandeClientXmlSheet.class).getRowActions(); |
return new MouseSheetXmlListeListener(CommandeClientXmlSheet.class).getRowActions(); |
} |
} |
/trunk/Modules/Module Subscription/src/org/openconcerto/modules/subscription/panel/FacturesAboPanel.java |
---|
134,7 → 134,7 |
@Override |
protected List<RowAction> getAdditionnalRowActions() { |
return new MouseSheetXmlListeListener(this.eltFact, VenteFactureXmlSheet.class).getRowActions(); |
return new MouseSheetXmlListeListener(VenteFactureXmlSheet.class).getRowActions(); |
} |
} |
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketSQLComponent.java |
---|
49,7 → 49,7 |
} |
SQLRowValues rowValsHisto = new SQLRowValues(getTable().getTable(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY)); |
rowValsHisto.put("INFORMATION", "Ouverture du ticket"); |
// rowValsHisto.put("DATE", row.getObject("DATE")); |
rowValsHisto.put("DATE", row.getObject("DATE")); |
rowValsHisto.put("ID_USER_COMMON", row.getForeignID("ID_USER_COMMON")); |
rowValsHisto.put("ID_" + getTable().getName(), createEmptyUpdateRow); |
createEmptyUpdateRow.commit(); |
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketSheetXML.java |
---|
10,7 → 10,7 |
public class CustomerSupportTicketSheetXML extends AbstractSheetXMLWithDate { |
public static String TEMPLATE_ID = "TicketSupport"; |
public static String TEMPLATE_ID = "CustomerSupportTicket"; |
public static String TEMPLATE_PROPERTY_NAME = "LocationCmd"; |
// private static final Tuple2<String, String> tuple = Tuple2.create("LocationDmd", |
22,7 → 22,7 |
@Override |
public String getReference() { |
return this.row.getString("NUMBER"); |
return this.row.getString("NUMERO"); |
} |
// FIXME Prefs printer location |
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/SuiviTicketPanel.java |
---|
179,12 → 179,6 |
Collections.sort(histoRowsOrder, new Comparator<SQLRowAccessor>() { |
@Override |
public int compare(SQLRowAccessor o1, SQLRowAccessor o2) { |
if (o1.getObject("DATE") == null) { |
return -1; |
} |
if (o2.getObject("DATE") == null) { |
return 1; |
} |
return o2.getDate("DATE").compareTo(o1.getDate("DATE")); |
} |
}); |
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketSQLElement.java |
---|
92,7 → 92,7 |
addHistoriqueAction.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE)); |
getRowActions().add(addHistoriqueAction); |
MouseSheetXmlListeListener l = new MouseSheetXmlListeListener(this, CustomerSupportTicketSheetXML.class); |
MouseSheetXmlListeListener l = new MouseSheetXmlListeListener(CustomerSupportTicketSheetXML.class); |
getRowActions().addAll(l.getRowActions()); |
} |