OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 89 → Rev 99

/trunk/Modules/Module Fidelity Card/module.properties
1,6 → 1,6
# [\p{Alnum}_.]{3,}
id=org.openconcerto.modules.label
entryPoint=ModuleLabel
id=org.openconcerto.modules.card
entryPoint=ModuleCard
# \p{Digit}(\.\p{Digit}+)?
version=1.0
contact=ILM Informatique
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/LabelFrame.java
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/ModuleResources.properties
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/SQLElementNames_en.xml
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/LabelPanel.java
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/ModuleResources_fr.properties
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/SQLElementNames_fr.xml
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/labels_en.xml
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/ModuleLabel.java
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/LabelRenderer.java
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/label/labels_fr.xml
File deleted
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/ModuleResources.properties
New file
0,0 → 1,2
name=Fidelity card
description=Adds fidelity card for clients
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/SQLElementNames_en.xml
New file
0,0 → 1,3
<translations>
<element refid="org.openconcerto.modules.card/FIDELITY_CARD" name="fidelity card" />
</translations>
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/ModuleCard.java
New file
0,0 → 1,142
package org.openconcerto.modules.card;
 
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import org.openconcerto.erp.config.MainFrame;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.AlterTableRestricted;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.DBContext;
import org.openconcerto.erp.modules.MenuContext;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.erp.modules.ModulePreferencePanel;
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement.ReferenceAction;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.element.UISQLComponent;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.utils.CollectionMap;
import org.openconcerto.utils.PrefType;
 
public final class ModuleCard extends AbstractModule {
 
private static final String TABLE_NAME = "FIDELITY_CARD";
 
public ModuleCard(ModuleFactory f) throws IOException {
super(f);
 
}
 
@Override
protected void install(DBContext ctxt) {
super.install(ctxt);
// TODO use version to upgrade
if (!ctxt.getTablesPreviouslyCreated().contains(TABLE_NAME)) {
final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_NAME);
createTable.addVarCharColumn("SERIAL", 64);
createTable.addColumn("POINTS", "int NOT NULL DEFAULT 0");
createTable.addDateAndTimeColumn("EXPIRATION_DATE");
 
final AlterTableRestricted alterTable = ctxt.getAlterTable("CLIENT");
alterTable.addForeignColumn("ID_FIDELITY_CARD", createTable);
}
}
 
@Override
protected void setupElements(SQLElementDirectory dir) {
super.setupElements(dir);
final ModuleElement fidCardElement = new ModuleElement(this, TABLE_NAME) {
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("SERIAL");
l.add("POINTS");
l.add("EXPIRATION_DATE");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("SERIAL");
l.add("POINTS");
return l;
}
 
@Override
public CollectionMap<String, String> getShowAs() {
return CollectionMap.singleton(null, getComboFields());
}
 
@Override
protected SQLComponent createComponent() {
return new UISQLComponent(this) {
@Override
protected void addViews() {
this.addView("SERIAL");
this.addView("POINTS");
this.addView("EXPIRATION_DATE");
}
};
}
};
 
dir.addSQLElement(fidCardElement);
final SQLTable clientT = fidCardElement.getTable().findReferentTable("CLIENT");
// do not delete a client
dir.getElement(clientT).setAction("ID_FIDELITY_CARD", ReferenceAction.SET_EMPTY);
}
 
@Override
protected void setupComponents(ComponentsContext ctxt) {
ctxt.putAdditionalField("CLIENT", "ID_FIDELITY_CARD");
}
 
@Override
protected void setupMenu(MenuContext ctxt) {
ctxt.addMenuItem(ctxt.createListAction(TABLE_NAME), MainFrame.LIST_MENU);
}
 
@Override
protected void start() {
}
 
@Override
public List<ModulePreferencePanelDesc> getPrefDescriptors() {
return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Préf") {
@Override
protected ModulePreferencePanel createPanel() {
return new ModulePreferencePanel("Mon super titre") {
@Override
protected void addViews() {
this.addView(new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Un booléen", "boolPref").setDefaultValue(Boolean.TRUE));
this.addView(new SQLPrefView<String>(PrefType.STRING_TYPE, 12, "Du texte", "textPref").setDefaultValue("court"));
this.addView(new SQLPrefView<Double>(PrefType.DOUBLE_TYPE, "Un double", "doublePref"));
}
};
}
}, new ModulePreferencePanelDesc("Préf2") {
@Override
protected ModulePreferencePanel createPanel() {
return new ModulePreferencePanel("Mon super titre") {
@Override
protected void addViews() {
this.addView(new SQLPrefView<String>(PrefType.STRING_TYPE, 512, "Du texte", "textPref").setDefaultValue("long texte"));
this.addView(new SQLPrefView<Long>(PrefType.LONG_TYPE, "Un long", "longPref"));
}
};
}
}.setLocal(false).setKeywords("toto", "vélo"));
}
 
@Override
protected void stop() {
}
}
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/ModuleResources_fr.properties
New file
0,0 → 1,2
name=Carte de fidélité
description=Ajoute une carte de fidélité pour les clients
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/SQLElementNames_fr.xml
New file
0,0 → 1,4
<translations>
<element refid="org.openconcerto.modules.card/FIDELITY_CARD" nameClass="feminine" name="carte de fidélité"
namePlural="cartes de fidélité" />
</translations>
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/labels_en.xml
New file
0,0 → 1,11
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<TABLE name="CLIENT">
<FIELD name="ID_FIDELITY_CARD" label="Fidelity card" />
</TABLE>
<TABLE name="FIDELITY_CARD">
<FIELD name="POINTS" label="Points" />
<FIELD name="SERIAL" label="Serial number" />
<FIELD name="EXPIRATION_DATE" label="Expiration date" />
</TABLE>
</ROOT>
/trunk/Modules/Module Fidelity Card/src/org/openconcerto/modules/card/labels_fr.xml
New file
0,0 → 1,11
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<TABLE name="CLIENT">
<FIELD name="ID_FIDELITY_CARD" label="Carte de fidélité" />
</TABLE>
<TABLE name="FIDELITY_CARD">
<FIELD name="POINTS" label="Points" />
<FIELD name="SERIAL" label="Numéro de série" />
<FIELD name="EXPIRATION_DATE" label="Date limite" />
</TABLE>
</ROOT>