Dépôt officiel du code source de l'ERP OpenConcerto
/trunk/OpenConcerto/.classpath |
---|
37,5 → 37,6 |
<classpathentry kind="lib" path="lib/msv-20090415.jar"/> |
<classpathentry kind="lib" path="lib/jOpenCalendar.jar"/> |
<classpathentry kind="lib" path="lib/h2-1.3.175-dropTableRestrict.jar"/> |
<classpathentry kind="lib" path="lib/json-smart-1.3.1.jar"/> |
<classpathentry kind="output" path="bin"/> |
</classpath> |
/trunk/OpenConcerto/lib/json-smart-1.3.1.jar |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/lib/json-smart-1.3.1.jar |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/OpenConcerto/lib/jOpenCalendar.jar |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/BonLivraison.xml |
---|
18,6 → 18,15 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
/trunk/OpenConcerto/Configuration/Template/Default/Avoir.xml |
---|
20,6 → 20,16 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
/trunk/OpenConcerto/Configuration/Template/Default/Journaux.odsp |
---|
1,6 → 1,6 |
<odsp> |
<spliteveryrow> |
<sheet number="0">68</sheet> |
<sheet number="0">69</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
/trunk/OpenConcerto/Configuration/Template/Default/AvoirF.xml |
---|
21,6 → 21,15 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
/trunk/OpenConcerto/Configuration/Template/Default/FicheRelance.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/FactureFournisseur.xml |
---|
New file |
0,0 → 1,134 |
<?xml version="1.0" encoding="UTF-8" ?> |
<contentDocument> |
<element location="B1" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE" /> |
<field base="Common" table="SOCIETE_COMMON" name="NOM" /> |
</element> |
<element location="B2" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="ID_ADRESSE_COMMON"> |
<field base="Common" table="ADRESSE_COMMON" name="RUE" /> |
</field> |
</element> |
<element location="B3" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="ID_ADRESSE_COMMON"> |
<field base="Common" table="ADRESSE_COMMON" name="VILLE" type="villeCP" /> |
<field base="Common" table="ADRESSE_COMMON" name="VILLE" type="ville" /> |
<field base="Common" table="ADRESSE_COMMON" name="CEDEX" prefix="CEDEX " conditionField="HAS_CEDEX" /> |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE" /> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€" /> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN " /> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
<element location="B8" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_TEL" /> |
</element> |
<element location="B9" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_FAX" /> |
</element> |
<element location="B10" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="MAIL" /> |
</element> |
<element location="B13" type="fill"> |
<field name="NUMERO" /> |
</element> |
<element location="C13" type="fill"> |
<field name="DATE" /> |
</element> |
<element location="C16" type="fill"> |
<field name="NOM" /> |
</element> |
<element location="H10" type="fill"> |
<field name="ID_FOURNISSEUR"> |
<field name="TYPE" /> |
<field name="NOM" /> |
</field> |
</element> |
<element location="H11" type="fill"> |
<field name="ID_FOURNISSEUR"> |
<field name="ID_ADRESSE"> |
<field name="RUE" /> |
</field> |
</field> |
</element> |
<element location="H13" type="fill"> |
<field name="ID_FOURNISSEUR"> |
<field name="ID_ADRESSE"> |
<field name="VILLE" type="villeCP" /> |
<field name="VILLE" type="ville" /> |
<field name="CEDEX" prefix="CEDEX " conditionField="HAS_CEDEX" /> |
</field> |
</field> |
</element> |
<element location="L55" type="fill"> |
<field name="T_HT" type="devise" /> |
</element> |
<element location="L56" type="fill"> |
<field name="T_TVA" type="devise" /> |
</element> |
<element location="L57" type="fill"> |
<field name="T_TTC" type="devise" /> |
</element> |
<table endPageLine="57" firstLine="22" endLine="52" lastColumn="L" table="FACTURE_FOURNISSEUR_ELEMENT"> |
<element location="B" type="fill"> |
<field name="NOM" /> |
</element> |
<element location="G" type="fill"> |
<field name="PRIX_METRIQUE_HA_1" type="devise" /> |
<field name="ID_MODE_VENTE_ARTICLE"> |
<field name="CODE" prefix="€/" /> |
</field> |
</element> |
<element location="H" type="fill"> |
<field name="PA_HT" type="devise" /> |
</element> |
<element location="I" type="fill"> |
<field name="QTE" /> |
</element> |
<element location="J" type="fill"> |
<field name="ID_TAXE"> |
<field name="TAUX" op="/" number="100.0" /> |
</field> |
</element> |
<element location="K" type="fill"> |
<field name="T_POIDS" /> |
</element> |
<element location="L" type="fill"> |
<field name="T_PA_HT" type="devise" /> |
</element> |
</table> |
</contentDocument> |
/trunk/OpenConcerto/Configuration/Template/Default/FactureFournisseur.odsp |
---|
New file |
0,0 → 1,9 |
<odsp> |
<spliteveryrow> |
<sheet number="0">57</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
</odsp> |
/trunk/OpenConcerto/Configuration/Template/Default/CommandeClient.xml |
---|
18,6 → 18,15 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" name="NUM_NII" /> |
</element> |
/trunk/OpenConcerto/Configuration/Template/Default/FactureFournisseur.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/FactureFournisseur.ods |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/OpenConcerto/Configuration/Template/Default/BonReception.xml |
---|
New file |
0,0 → 1,134 |
<?xml version="1.0" encoding="UTF-8" ?> |
<contentDocument> |
<element location="B1" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE" /> |
<field base="Common" table="SOCIETE_COMMON" name="NOM" /> |
</element> |
<element location="B2" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="ID_ADRESSE_COMMON"> |
<field base="Common" table="ADRESSE_COMMON" name="RUE" /> |
</field> |
</element> |
<element location="B3" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="ID_ADRESSE_COMMON"> |
<field base="Common" table="ADRESSE_COMMON" name="VILLE" type="villeCP" /> |
<field base="Common" table="ADRESSE_COMMON" name="VILLE" type="ville" /> |
<field base="Common" table="ADRESSE_COMMON" name="CEDEX" prefix="CEDEX " conditionField="HAS_CEDEX" /> |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
<element location="B8" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_TEL" /> |
</element> |
<element location="B9" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_FAX" /> |
</element> |
<element location="B10" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="MAIL" /> |
</element> |
<element location="B13" type="fill"> |
<field name="NUMERO" /> |
</element> |
<element location="C13" type="fill"> |
<field name="DATE" /> |
</element> |
<element location="C16" type="fill"> |
<field name="NOM" /> |
</element> |
<element location="H10" type="fill"> |
<field name="ID_FOURNISSEUR"> |
<field name="TYPE" /> |
<field name="NOM" /> |
</field> |
</element> |
<element location="H11" type="fill"> |
<field name="ID_FOURNISSEUR"> |
<field name="ID_ADRESSE"> |
<field name="RUE" /> |
</field> |
</field> |
</element> |
<element location="H13" type="fill"> |
<field name="ID_FOURNISSEUR"> |
<field name="ID_ADRESSE"> |
<field name="VILLE" type="villeCP" /> |
<field name="VILLE" type="ville" /> |
<field name="CEDEX" prefix="CEDEX " conditionField="HAS_CEDEX" /> |
</field> |
</field> |
</element> |
<element location="L55" type="fill"> |
<field name="TOTAL_HT" type="devise" /> |
</element> |
<element location="L56" type="fill"> |
<field name="TOTAL_TVA" type="devise" /> |
</element> |
<element location="L57" type="fill"> |
<field name="TOTAL_TTC" type="devise" /> |
</element> |
<table endPageLine="57" firstLine="22" endLine="52" lastColumn="L" table="BON_RECEPTION_ELEMENT"> |
<element location="B" type="fill"> |
<field name="NOM" /> |
</element> |
<element location="G" type="fill"> |
<field name="PRIX_METRIQUE_HA_1" type="devise" /> |
<field name="ID_MODE_VENTE_ARTICLE"> |
<field name="CODE" prefix="€/" /> |
</field> |
</element> |
<element location="H" type="fill"> |
<field name="PA_HT" type="devise" /> |
</element> |
<element location="I" type="fill"> |
<field name="QTE" /> |
</element> |
<element location="J" type="fill"> |
<field name="ID_TAXE"> |
<field name="TAUX" op="/" number="100.0" /> |
</field> |
</element> |
<element location="K" type="fill"> |
<field name="T_POIDS" /> |
</element> |
<element location="L" type="fill"> |
<field name="T_PA_HT" type="devise" /> |
</element> |
</table> |
</contentDocument> |
/trunk/OpenConcerto/Configuration/Template/Default/EtatVentes.odsp |
---|
1,8 → 1,6 |
<odsp> |
<spliteveryrow> |
<sheet number="0">55</sheet> |
<sheet number="1">55</sheet> |
<sheet number="2">18</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
/trunk/OpenConcerto/Configuration/Template/Default/RepartitionAnalytique.odsp |
---|
New file |
0,0 → 1,9 |
<odsp> |
<spliteveryrow> |
<sheet number="0">68</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
</odsp> |
/trunk/OpenConcerto/Configuration/Template/Default/GrandLivre.odsp |
---|
1,6 → 1,6 |
<odsp> |
<spliteveryrow> |
<sheet number="0">68</sheet> |
<sheet number="0">69</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
/trunk/OpenConcerto/Configuration/Template/Default/Operations Report.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/Operations Report.ods |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/OpenConcerto/Configuration/Template/Default/BonReception.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/BonReception.ods |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/OpenConcerto/Configuration/Template/Default/FicheRelance.odsp |
---|
New file |
0,0 → 1,9 |
<odsp> |
<spliteveryrow> |
<sheet number="0">52</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
</odsp> |
/trunk/OpenConcerto/Configuration/Template/Default/FicheArticle.xml |
---|
New file |
0,0 → 1,30 |
<?xml version="1.0" encoding="UTF-8" ?> |
<contentDocument> |
<element location="C2" type="fill"> |
<field base="Societe" name="CODE"/> |
</element> |
<element location="C3" type="fill"> |
<field base="Societe" name="NOM"/> |
</element> |
<element location="C12" type="fill"> |
<field base="Societe" name="CODE_BARRE"/> |
</element> |
<element location="G12" type="fill"> |
<field base="Societe" name="NOM"/> |
</element> |
<element location="C14" type="fill"> |
<field base="Societe" name="ID_FAMILLE_ARTICLE"> |
<field base="Societe" name="NOM"/> |
</field> |
</element> |
</contentDocument> |
/trunk/OpenConcerto/Configuration/Template/Default/Commande.xml |
---|
19,6 → 19,15 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
/trunk/OpenConcerto/Configuration/Template/Default/FicheArticle.odsp |
---|
New file |
0,0 → 1,12 |
<odsp> |
<spliteveryrow> |
<sheet number="0">65</sheet> |
</spliteveryrow> |
+<offset x="40" y ="20"/> |
+<resize percent="85"/> |
+ |
+</odsp> |
\ No newline at end of file |
/trunk/OpenConcerto/Configuration/Template/Default/JournauxMois.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/VenteFactureSituation.xml |
---|
18,6 → 18,15 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
69,7 → 78,9 |
<element type="sales.account.command.total" location="J58" /> |
<element location="L58" type="sales.partial.value" /> |
<element location="L58" type="fill"> |
<field base="Societe" table="SAISIE_VENTE_FACTURE" name="T_HT" type="devise"/> |
</element> |
<element type="sales.account.total" location="L61" /> |
84,7 → 95,7 |
<element location="B63" type="fill"> |
<field name="ID_MODE_REGLEMENT"> |
<field name="NOM" prefix="Règlement souhaité" conditionField="COMPTANT" conditionExpValue="true" display="false" /> |
<field name="NOM" prefix="Facture acquitée par" conditionField="COMPTANT" conditionExpValue="false" display="false" /> |
<field name="NOM" prefix="Facture acquittée par" conditionField="COMPTANT" conditionExpValue="false" display="false" /> |
<field name="ID_TYPE_REGLEMENT"> |
<field name="NOM" valuesExpected="Indéfini" /> |
</field> |
/trunk/OpenConcerto/Configuration/Template/Default/VenteFacture.xml |
---|
18,6 → 18,16 |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
77,7 → 87,7 |
<element location="B63" type="fill"> |
<field name="ID_MODE_REGLEMENT"> |
<field name="NOM" prefix="Règlement souhaité" conditionField="COMPTANT" conditionExpValue="true" display="false" /> |
<field name="NOM" prefix="Facture acquitée par" conditionField="COMPTANT" conditionExpValue="false" display="false" /> |
<field name="NOM" prefix="Facture acquittée par" conditionField="COMPTANT" conditionExpValue="false" display="false" /> |
<field name="ID_TYPE_REGLEMENT"> |
<field name="NOM" valuesExpected="Indéfini" /> |
</field> |
89,7 → 99,7 |
</element> |
<element location="B64" type="fill"> |
<field name="DATE" type="DateEcheance" prefix="Règlement de cette facture au plus tard le " valuesExpected=" " /> |
<field name="DATE" type="DateEcheance" datePattern="dd/MM/yy" prefix="Règlement de cette facture au plus tard le " valuesExpected=" " /> |
</element> |
<element location="B64" type="fill"> |
/trunk/OpenConcerto/Configuration/Template/Default/BonReception.odsp |
---|
New file |
0,0 → 1,9 |
<odsp> |
<spliteveryrow> |
<sheet number="0">57</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
</odsp> |
/trunk/OpenConcerto/Configuration/Template/Default/RepartitionAnalytique.xml |
---|
New file |
0,0 → 1,44 |
<?xml version="1.0" encoding="UTF-8" ?> |
<contentDocument> |
<element0 location="E69" type="Value" ValueName="TOTAL_DEBIT"> |
</element0> |
<element0 location="F69" type="Value" ValueName="TOTAL_CREDIT"> |
</element0> |
<element0 location="G69" type="Value" ValueName="TOTAL_SOLDE"> |
</element0> |
<element0 location="A1" type="Value" ValueName="TITRE_1"> |
</element0> |
<element0 location="A2" type="Value" ValueName="TITRE_2"> |
</element0> |
<table0 firstLine="4" endLine="68" endPageLine="69" lastColumn="G" table="ECRITURE" pageRef="F1"> |
<element location="A" type="fill"> |
<field name="CLASSE" /> |
</element> |
<element location="B" type="fill"> |
<field name="POSTE_CODE" /> |
</element> |
<element location="C" type="fill"> |
<field name="POSTE_NOM" /> |
</element> |
<element location="E" type="fill"> |
<field name="DEBIT" /> |
</element> |
<element location="F" type="fill"> |
<field name="CREDIT" /> |
</element> |
<element location="G" type="fill"> |
<field name="SOLDE" /> |
</element> |
</table0> |
</contentDocument> |
/trunk/OpenConcerto/Configuration/Template/Default/FicheArticle.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/FicheArticle.ods |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/OpenConcerto/Configuration/Template/Default/JournauxMois.odsp |
---|
1,6 → 1,6 |
<odsp> |
<spliteveryrow> |
<sheet number="0">70</sheet> |
<sheet number="0">71</sheet> |
</spliteveryrow> |
<offset x="40" y ="20"/> |
<resize percent="85"/> |
/trunk/OpenConcerto/Configuration/Template/Default/Devis.xml |
---|
17,7 → 17,15 |
<field base="Common" name="VILLE" type="ville" /> |
</field> |
</element> |
<element location="B5" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="TYPE"/> |
<field base="Common" table="SOCIETE_COMMON" name="CAPITAL" prefix=" au capital de " suffix="€"/> |
</element> |
<element location="B6" type="fill"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_SIRET" prefix="N° de SIREN "/> |
</element> |
<element location="B7" type="replace" replacePattern="_"> |
<field base="Common" table="SOCIETE_COMMON" name="NUM_NII" /> |
</element> |
/trunk/OpenConcerto/Configuration/Template/Default/VenteFacture.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/RepartitionAnalytique.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/RepartitionAnalytique.ods |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/OpenConcerto/Configuration/Template/Default/Devis.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/Configuration/Template/Default/Journaux.ods |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/OpenConcerto/src/org/openconcerto/map/model/Ville.java |
---|
49,15 → 49,18 |
private static boolean loaded = false; |
private int nbMatch = 0; |
public synchronized static void init(final DatabaseAccessor d) { |
public synchronized static void init(final DatabaseAccessor d, final boolean loadFromFile) { |
await(); |
accessor = d; |
init = new Thread(new Runnable() { |
@Override |
public void run() { |
synchronized (Ville.class) { |
if (loadFromFile) { |
parseFile(); |
} |
final List<Ville> l = d.read(); |
for (final Ville ville : l) { |
addVilleSilently(ville); |
/trunk/OpenConcerto/src/org/openconcerto/ui/table/TimestampTableCellEditor.java |
---|
14,15 → 14,16 |
package org.openconcerto.ui.table; |
import org.openconcerto.ui.FormatEditor; |
import org.openconcerto.ui.PopupUtils; |
import org.openconcerto.ui.TimestampEditorPanel; |
import java.awt.Color; |
import java.awt.Component; |
import java.awt.Point; |
import java.awt.Rectangle; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyListener; |
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseEvent; |
import java.sql.Timestamp; |
import java.text.DateFormat; |
import java.util.Calendar; |
29,9 → 30,9 |
import java.util.Date; |
import java.util.EventObject; |
import javax.swing.BorderFactory; |
import javax.swing.JPopupMenu; |
import javax.swing.JTable; |
import javax.swing.Popup; |
import javax.swing.JTextField; |
import javax.swing.SwingUtilities; |
public class TimestampTableCellEditor extends FormatEditor implements ActionListener { |
38,9 → 39,9 |
private Calendar calendar; |
private Date currentvalue, initialvalue; |
private Popup aPopup; |
private JPopupMenu aPopup; |
private boolean popupOpen = false; |
private TimestampEditorPanel content = new TimestampEditorPanel(); |
private final TimestampEditorPanel content = new TimestampEditorPanel(); |
private boolean allowNull = true; |
public TimestampTableCellEditor(boolean showHour) { |
51,7 → 52,7 |
public TimestampTableCellEditor() { |
super(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); |
this.calendar = Calendar.getInstance(); |
this.content.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
this.content.setBorder(null); |
} |
public void setAllowNull(boolean b) { |
59,7 → 60,7 |
} |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column); |
final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column); |
Date time = (Date) value; |
if (time == null) { |
time = new Timestamp(System.currentTimeMillis()); |
68,9 → 69,9 |
this.calendar.setTime(time); |
this.currentvalue = time; |
this.initialvalue = time; |
Rectangle rect = table.getCellRect(row, column, true); |
Point p = new Point(rect.x, rect.y + table.getRowHeight(row)); |
SwingUtilities.convertPointToScreen(p, table); |
final Point p = new Point(0, 0 + table.getRowHeight(row)); |
if (this.aPopup != null) { |
this.content.removeActionListener(this); |
this.aPopup.hide(); |
77,8 → 78,50 |
this.aPopup = null; |
} |
this.aPopup = PopupUtils.createPopup(c, this.content, p.x, p.y); |
showPopup(); |
JTextField t = (JTextField) c; |
this.aPopup = new JPopupMenu(); |
this.aPopup.add(this.content); |
t.addMouseListener(new MouseAdapter() { |
@Override |
public void mousePressed(MouseEvent e) { |
// Invoke later to avoid paint issue |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
showPopup(c, p); |
} |
}); |
} |
}); |
t.addKeyListener(new KeyListener() { |
@Override |
public void keyTyped(KeyEvent e) { |
} |
@Override |
public void keyReleased(KeyEvent e) { |
} |
@Override |
public void keyPressed(KeyEvent e) { |
if (e.getKeyCode() == KeyEvent.VK_DOWN) { |
// Invoke later to avoid paint issue |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
showPopup(c, p); |
} |
}); |
} |
} |
}); |
this.content.setCellEditor(this); |
this.content.addActionListener(this); |
return c; |
90,25 → 133,32 |
super.cancelCellEditing(); |
} |
public boolean stopCellEditing() { |
hidePopup(); |
return super.stopCellEditing(); |
} |
public void hidePopup() { |
this.popupOpen = false; |
this.content.removeActionListener(this); |
if (this.aPopup != null) { |
this.aPopup.hide(); |
this.aPopup = null; |
this.aPopup.setVisible(false); |
} |
} |
public void showPopup() { |
public void showPopup(Component c, Point p) { |
this.popupOpen = true; |
this.aPopup.show(); |
this.aPopup.show(c, p.x, p.y); |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
content.requestFocus(); |
} |
}); |
} |
public boolean isPopupOpen() { |
return popupOpen; |
} |
public Object getCellEditorValue() { |
final Date v = (Date) super.getCellEditorValue(); |
long t = System.currentTimeMillis(); |
/trunk/OpenConcerto/src/org/openconcerto/ui/table/PercentRenderer.java |
---|
35,6 → 35,9 |
} |
public void setValue(Number value) { |
if (value == null) { |
value = Integer.valueOf(0); |
} |
v = value.intValue(); |
final String text = v + " %"; |
l1.setText(text); |
/trunk/OpenConcerto/src/org/openconcerto/ui/PrintPreviewFrame.java |
---|
34,11 → 34,9 |
import java.awt.print.PrinterJob; |
import javax.print.attribute.HashPrintRequestAttributeSet; |
import javax.swing.ImageIcon; |
import javax.swing.JButton; |
import javax.swing.JComboBox; |
import javax.swing.JFrame; |
import javax.swing.JLabel; |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
/trunk/OpenConcerto/src/org/openconcerto/ui/FrameUtil.java |
---|
29,9 → 29,12 |
public class FrameUtil { |
public static void show(final Window frame) { |
if (frame instanceof Frame) { |
// From Java 7, missing animation on Windows : |
// https://bugs.openjdk.java.net/browse/JDK-8037575 |
((Frame) frame).setState(Frame.NORMAL); |
} |
frame.setVisible(true); |
if (frame instanceof Frame) |
((Frame) frame).setState(Frame.NORMAL); |
frame.toFront(); |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateRangeTable.java |
---|
29,6 → 29,9 |
import java.util.Collections; |
import java.util.Date; |
import java.util.List; |
import java.util.logging.ConsoleHandler; |
import java.util.logging.Level; |
import java.util.logging.Logger; |
import javax.swing.JButton; |
import javax.swing.JFrame; |
40,8 → 43,6 |
import javax.swing.UIManager; |
import javax.swing.event.ListSelectionEvent; |
import javax.swing.event.ListSelectionListener; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
import javax.swing.table.DefaultTableCellRenderer; |
import javax.swing.table.TableColumn; |
200,7 → 201,7 |
} catch (final Exception e) { |
e.printStackTrace(); |
} |
// enableFocusLogging(); |
final JFrame f = new JFrame(); |
f.setContentPane(new DateRangeTable(true, false)); |
f.setSize(400, 300); |
212,6 → 213,19 |
} |
private static void enableFocusLogging() { |
// Obtain a reference to the logger |
Logger focusLog = Logger.getLogger("java.awt.focus.Component"); |
// The logger should log all messages |
focusLog.setLevel(Level.ALL); |
// Create a new handler |
ConsoleHandler handler = new ConsoleHandler(); |
// The handler must handle all messages |
handler.setLevel(Level.ALL); |
// Add the handler to the logger |
focusLog.addHandler(handler); |
} |
@SuppressWarnings("unchecked") |
public void clear() { |
fillFrom(Collections.EMPTY_LIST); |
/trunk/OpenConcerto/src/org/openconcerto/ui/date/DateRangePlannerPanel.java |
---|
25,6 → 25,7 |
import org.openconcerto.ui.date.EventProviders.Weekly; |
import org.openconcerto.ui.date.EventProviders.Yearly; |
import org.openconcerto.ui.date.EventProviders.YearlyDayOfWeekEventProvider; |
import org.openconcerto.utils.FileUtils; |
import org.openconcerto.utils.StringInputStream; |
import org.openconcerto.utils.TimeUtils; |
import org.openconcerto.utils.i18n.TM.MissingMode; |
42,6 → 43,8 |
import java.awt.event.ItemListener; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.io.File; |
import java.io.IOException; |
import java.text.DateFormat; |
import java.text.DateFormatSymbols; |
import java.util.ArrayList; |
133,6 → 136,10 |
private JRadioButton radioPeriodRepeat; |
private JRadioButton radioPeriodNeverEnd; |
protected boolean listenersEnabled = true; |
private DayOfWeek[] week; |
public DateRangePlannerPanel() { |
this.weekDays = new HashSet<DayOfWeek>(); |
this.setLayout(new GridBagLayout()); |
181,7 → 188,8 |
// |
long delta = timeEnd.getTimeInMillis() - timeStart.getTimeInMillis(); |
if (delta < 60 * 1000) { |
timeStart.setTimeInMillis(timeEnd.getTimeInMillis() - 60 * 1000); |
delta = 60 * 1000; |
timeStart.setTimeInMillis(timeEnd.getTimeInMillis() - delta); |
} |
duration.setValue(Integer.valueOf((int) (delta / (60 * 1000)))); |
189,13 → 197,12 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
long delta = timeEnd.getTimeInMillis() - timeStart.getTimeInMillis(); |
if (delta < 60 * 1000) { |
delta = 60 * 1000; |
} |
long ms = timeStart.getTimeInMillis() + ((Integer) duration.getValue()).intValue() * 60 * 1000; |
if (listenersEnabled) { |
long ms = timeStart.getTimeInMillis() + getSpinnerValue(duration) * 60 * 1000; |
ms = ms % (24 * 3600 * 1000); |
setTimeEnd(ms); |
} |
} |
}); |
204,10 → 211,11 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
if (listenersEnabled) { |
long delta = timeEnd.getTimeInMillis() - timeStart.getTimeInMillis(); |
if (delta < 60 * 1000) { |
if (delta < 0) { |
delta = 60 * 1000; |
long ms = timeEnd.getTimeInMillis() - ((Integer) duration.getValue()).intValue() * 60 * 1000; |
long ms = timeEnd.getTimeInMillis() - getSpinnerValue(duration) * 60 * 1000; |
if (ms < 0) { |
ms += 24 * 3600 * 1000; |
} |
217,6 → 225,7 |
setDuration(min); |
} |
} |
} |
}); |
duration.addChangeListener(new ChangeListener() { |
223,8 → 232,9 |
@Override |
public void stateChanged(ChangeEvent e) { |
if (listenersEnabled) { |
try { |
int min = Integer.valueOf(duration.getValue().toString()); |
int min = getSpinnerValue(duration); |
if (min > 0) { |
long ms = timeStart.getTimeInMillis() + min * 60 * 1000; |
ms = ms % (24 * 3600 * 1000); |
233,8 → 243,8 |
} catch (Exception ex) { |
// Nothing |
} |
} |
} |
}); |
return p; |
378,7 → 388,7 |
@Override |
public void stateChanged(ChangeEvent e) { |
if (dayEveryDay.getValue().toString().equals("1")) { |
if (getSpinnerValue(dayEveryDay) == 1) { |
labelEvery.setText("jour"); |
} else { |
labelEvery.setText("jours"); |
446,7 → 456,7 |
@Override |
public void stateChanged(ChangeEvent e) { |
if (weekIncrementSpinner.getValue().toString().equals("1")) { |
if (getSpinnerValue(weekIncrementSpinner) == 1) { |
labelEvery.setText("semaine, le :"); |
} else { |
labelEvery.setText("semaines, le :"); |
464,7 → 474,7 |
c.gridwidth = 1; |
final String[] namesOfDays = DateFormatSymbols.getInstance().getWeekdays(); |
final DayOfWeek[] week = DayOfWeek.getWeek(Calendar.getInstance()); |
week = DayOfWeek.getWeek(Calendar.getInstance()); |
final int weekLength = week.length; |
final int midWeek = weekLength / 2; |
for (int i = 0; i < weekLength; i++) { |
475,16 → 485,23 |
c.weightx = 0; |
} |
final JCheckBox cb = new JCheckBox(namesOfDays[d.getCalendarField()]); |
cb.addItemListener(new ItemListener() { |
cb.addActionListener(new ActionListener() { |
@Override |
public void itemStateChanged(ItemEvent e) { |
if (e.getStateChange() == ItemEvent.SELECTED) { |
public void actionPerformed(ActionEvent e) { |
// Do not use ItemListener in order to avoid issue on loading from xml |
if (cb.isSelected()) { |
weekDays.add(d); |
} else { |
weekDays.remove(d); |
if (weekDays.isEmpty()) { |
cb.setSelected(true); |
weekDays.add(d); |
} |
} |
} |
}); |
p.add(cb, c); |
weekCheckboxes.add(cb); |
496,12 → 513,15 |
c.gridx++; |
} |
} |
// Select first |
weekCheckboxes.get(0).setSelected(true); |
weekDays.add(week[0]); |
// |
return p; |
} |
protected final void setMonthIncrement(Object src) { |
this.monthIncrement = (Integer) ((JSpinner) src).getValue(); |
this.monthIncrement = getSpinnerValue((JSpinner) src); |
} |
// MONTH |
747,33 → 767,62 |
final DateRangePlannerPanel planner = new DateRangePlannerPanel(); |
p.setLayout(new BorderLayout()); |
p.add(planner, BorderLayout.CENTER); |
p.add(planner, BorderLayout.CENTER); |
JPanel tools = new JPanel(); |
p.add(tools, BorderLayout.SOUTH); |
final JButton b = new JButton("Print ranges"); |
p.add(b, BorderLayout.SOUTH); |
tools.add(b); |
b.addActionListener(new ActionListener() { |
@Override |
public void actionPerformed(ActionEvent e) { |
List<DateRange> ranges = planner.getRanges(); |
System.out.println("---- " + ranges.size() + " ranges :"); |
System.out.println("Printing " + ranges.size() + " ranges :"); |
for (DateRange dateRange : ranges) { |
System.out.println(dateRange); |
} |
final String configXML = planner.getConfigXML(); |
System.out.println(getDescriptionFromXML(configXML)); |
} |
}); |
final JButton bLoad = new JButton("Load"); |
tools.add(bLoad); |
bLoad.addActionListener(new ActionListener() { |
@Override |
public void actionPerformed(ActionEvent e) { |
System.out.println("Loading..."); |
try { |
String configXML = FileUtils.read(new File("test.xml")); |
System.out.println(configXML); |
try { |
planner.configureFromXML(configXML); |
} catch (Exception e1) { |
// TODO Auto-generated catch block |
e1.printStackTrace(); |
} |
long t1 = System.currentTimeMillis(); |
System.out.println(getDescriptionFromXML(configXML)); |
long t2 = System.currentTimeMillis(); |
System.out.println((t2 - t1) + "ms"); |
} |
}); |
final JButton bSave = new JButton("Save"); |
tools.add(bSave); |
bSave.addActionListener(new ActionListener() { |
@Override |
public void actionPerformed(ActionEvent e) { |
System.out.println("Saving..."); |
final String configXML = planner.getConfigXML(); |
System.out.println(configXML); |
try { |
FileUtils.write(configXML, new File("test.xml")); |
} catch (IOException e1) { |
e1.printStackTrace(); |
} |
} |
}); |
f.setContentPane(p); |
f.pack(); |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
807,7 → 856,7 |
eventCount = -1; |
} else { |
endDate = null; |
eventCount = ((Number) this.spinDateRangeCount.getValue()).intValue(); |
eventCount = getSpinnerValue(this.spinDateRangeCount); |
if (eventCount <= 0) |
throw new IllegalArgumentException("Negative event count : " + eventCount); |
} |
818,7 → 867,7 |
final EventProvider prov; |
if (type == Period.DAY) { |
if (dayRadio1.isSelected()) { |
final int incr = ((Number) dayEveryDay.getValue()).intValue(); |
final int incr = getSpinnerValue(dayEveryDay); |
prov = new Daily(incr); |
} else { |
prov = new Weekly(1, DayOfWeek.WORKING_DAYS); |
827,18 → 876,18 |
if (this.weekDays.isEmpty()) { |
prov = null; |
} else { |
final int incr = ((Number) this.weekIncrementSpinner.getValue()).intValue(); |
final int incr = getSpinnerValue(this.weekIncrementSpinner); |
prov = new Weekly(incr, this.weekDays); |
} |
} else if (type == Period.MONTH) { |
if (this.spinDayOfMonth.isEnabled()) { |
prov = new Monthly((Integer) this.spinDayOfMonth.getValue(), this.monthIncrement); |
prov = new Monthly(getSpinnerValue(this.spinDayOfMonth), this.monthIncrement); |
} else { |
prov = new MonthlyDayOfWeek((Integer) this.comboWeekOfMonth.getSelectedItem(), (DayOfWeek) this.comboWeekDayOfMonth.getSelectedItem(), this.monthIncrement); |
} |
} else if (type == Period.YEAR) { |
if (this.yearlyDayOfMonth.isEnabled()) { |
prov = new Yearly((Integer) this.yearlyDayOfMonth.getValue(), this.yearlyMonth, 1); |
prov = new Yearly(getSpinnerValue(this.yearlyDayOfMonth), this.yearlyMonth, 1); |
} else { |
prov = new YearlyDayOfWeekEventProvider((Integer) this.yearlyComboWeekOfMonth.getSelectedItem(), (DayOfWeek) this.yearlyComboWeekDayOfMonth.getSelectedItem(), this.yearlyMonth, 1); |
} |
925,7 → 974,7 |
if (f == Period.DAY.getCalendarField()) { |
b.append("<day every=\""); |
if (this.dayRadio1.isSelected()) { |
b.append(this.dayEveryDay.getValue()); |
b.append(getSpinnerValue(dayEveryDay)); |
} else { |
b.append("wd"); |
} |
932,7 → 981,7 |
b.append("\" />"); |
} else if (f == Period.WEEK.getCalendarField()) { |
b.append("<week every=\""); |
b.append(this.weekIncrementSpinner.getValue()); |
b.append(getSpinnerValue(weekIncrementSpinner)); |
b.append("\">"); |
for (JCheckBox cb : this.weekCheckboxes) { |
if (cb.isSelected()) { |
945,9 → 994,9 |
} else if (f == Period.MONTH.getCalendarField()) { |
if (this.monthRadio1.isSelected()) { |
b.append("<month day=\""); |
b.append(spinDayOfMonth.getValue()); |
b.append(getSpinnerValue(spinDayOfMonth)); |
b.append("\" every=\""); |
b.append(spinMonth2.getValue()); |
b.append(getSpinnerValue(spinMonth2)); |
b.append("\" />"); |
} else { |
b.append("<month weekOfMonth=\""); |
955,13 → 1004,13 |
b.append("\" dayOfMonth=\""); |
b.append(comboWeekDayOfMonth.getSelectedIndex()); |
b.append("\" every=\""); |
b.append(spinMonth3.getValue()); |
b.append(getSpinnerValue(spinMonth3)); |
b.append("\" />"); |
} |
} else if (f == Period.YEAR.getCalendarField()) { |
if (this.yearRadio1.isSelected()) { |
b.append("<year day=\""); |
b.append(this.yearlyDayOfMonth.getValue()); |
b.append(getSpinnerValue(this.yearlyDayOfMonth)); |
b.append("\" month=\""); |
b.append(this.yearMonthCombo.getSelectedIndex()); |
b.append("\" />"); |
989,7 → 1038,7 |
b.append("\""); |
} else if (this.radioPeriodRepeat.isSelected()) { |
b.append("repeat=\""); |
b.append(this.spinDateRangeCount.getValue().toString()); |
b.append(getSpinnerValue(spinDateRangeCount)); |
b.append("\""); |
} |
b.append("/>"); |
1006,8 → 1055,11 |
final Node nSchedule = l1.item(0); |
final long tStart = getAttributeAsLong(nSchedule, "start"); |
final long tStop = getAttributeAsLong(nSchedule, "end"); |
listenersEnabled = false; |
this.timeStart.setTimeInMillis(tStart); |
this.timeEnd.setTimeInMillis(tStop); |
this.timeStart.setTimeInMillis(tStart); |
this.duration.setValue((tStop - tStart) / (60 * 1000)); |
listenersEnabled = true; |
// Period |
final NodeList l2 = dom.getElementsByTagName("period"); |
final Node nPeriod = l2.item(0); |
1020,8 → 1072,10 |
if (l != null) { |
this.dayRadio1.setSelected(true); |
this.dayEveryDay.setValue(l); |
this.dayEveryDay.setEnabled(true); |
} else { |
this.dayRadio2.setSelected(false); |
this.dayRadio2.setSelected(true); |
this.dayEveryDay.setEnabled(false); |
} |
} else if (perioType == Period.WEEK.getCalendarField()) { |
this.radioPeriod.setValue(Period.WEEK); |
1029,10 → 1083,15 |
Integer e = getAttributeAsInteger(nWeek, "every"); |
this.weekIncrementSpinner.setValue(e); |
NodeList l = nWeek.getChildNodes(); |
weekDays.clear(); |
for (int i = 0; i < l.getLength(); i++) { |
Node n = l.item(i); |
this.weekCheckboxes.get(i).setSelected(n.getNodeName().equals("true")); |
final boolean selected = n.getNodeName().equals("true"); |
this.weekCheckboxes.get(i).setSelected(selected); |
if (selected) { |
weekDays.add(week[i]); |
} |
} |
} else if (perioType == Period.MONTH.getCalendarField()) { |
this.radioPeriod.setValue(Period.MONTH); |
final Node nMonth = nPeriod.getFirstChild(); |
1040,10 → 1099,23 |
if (d != null) { |
this.monthRadio1.setSelected(true); |
Integer every = getAttributeAsInteger(nMonth, "every"); |
spinDayOfMonth.setEnabled(true); |
spinMonth2.setEnabled(true); |
comboWeekOfMonth.setEnabled(false); |
comboWeekDayOfMonth.setEnabled(false); |
spinMonth3.setEnabled(false); |
// |
spinDayOfMonth.setValue(d); |
spinMonth2.setValue(every); |
} else { |
this.monthRadio2.setSelected(true); |
// |
spinDayOfMonth.setEnabled(false); |
spinMonth2.setEnabled(false); |
comboWeekOfMonth.setEnabled(true); |
comboWeekDayOfMonth.setEnabled(true); |
spinMonth3.setEnabled(true); |
// |
Integer weekOfMonth = getAttributeAsInteger(nMonth, "weekOfMonth"); |
Integer dayOfMonth = getAttributeAsInteger(nMonth, "dayOfMonth"); |
Integer every = getAttributeAsInteger(nMonth, "every"); |
1058,10 → 1130,22 |
if (d != null) { |
this.yearRadio1.setSelected(true); |
Integer m = getAttributeAsInteger(nYear, "month"); |
this.yearlyDayOfMonth.setEnabled(true); |
this.yearMonthCombo.setEnabled(true); |
this.yearlyComboWeekOfMonth.setEnabled(false); |
this.yearlyComboWeekDayOfMonth.setEnabled(false); |
this.yearMonthCombo2.setEnabled(false); |
// |
this.yearlyDayOfMonth.setValue(d); |
this.yearMonthCombo.setSelectedIndex(m.intValue()); |
} else { |
this.yearRadio2.setSelected(true); |
this.yearlyDayOfMonth.setEnabled(false); |
this.yearMonthCombo.setEnabled(false); |
this.yearlyComboWeekOfMonth.setEnabled(true); |
this.yearlyComboWeekDayOfMonth.setEnabled(true); |
this.yearMonthCombo2.setEnabled(true); |
Integer weekOfMonth = getAttributeAsInteger(nYear, "weekOfMonth"); |
this.yearlyComboWeekOfMonth.setSelectedIndex(weekOfMonth.intValue()); |
Integer weekDayOfMonth = getAttributeAsInteger(nYear, "weekDayOfMonth"); |
1082,11 → 1166,17 |
this.dateStart.setValue(new Date(start)); |
if (end != null) { |
this.radioPeriodEndAt.setSelected(true); |
this.dateEnd.setEnabled(true); |
this.spinDateRangeCount.setEnabled(false); |
this.dateEnd.setValue(new Date(end)); |
} else if (repeat != null) { |
this.radioPeriodRepeat.setSelected(true); |
this.dateEnd.setEnabled(false); |
this.spinDateRangeCount.setEnabled(true); |
this.spinDateRangeCount.setValue(repeat); |
} else { |
this.dateEnd.setEnabled(false); |
this.spinDateRangeCount.setEnabled(false); |
this.radioPeriodNeverEnd.setSelected(true); |
} |
1127,7 → 1217,11 |
final Node nWeek = nPeriod.getFirstChild(); |
Integer e = getAttributeAsInteger(nWeek, "every"); |
if (e == 1) { |
result += "toutes les semaines, le "; |
} else { |
result += "toutes les " + e + "semaines, le "; |
} |
NodeList l = nWeek.getChildNodes(); |
final String[] namesOfDays = DateFormatSymbols.getInstance().getWeekdays(); |
final DayOfWeek[] week = DayOfWeek.getWeek(Calendar.getInstance()); |
1210,7 → 1304,6 |
} |
} catch (Exception e) { |
e.printStackTrace(); |
} |
return result; |
} |
1262,34 → 1355,35 |
} |
public void setTimeEnd(final long ms) { |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
this.listenersEnabled = false; |
if (timeEnd.getTimeInMillis() != ms) { |
timeEnd.setTimeInMillis(ms); |
} |
this.listenersEnabled = true; |
} |
}); |
} |
public void setTimeStart(final long ms) { |
SwingUtilities.invokeLater(new Runnable() { |
@Override |
public void run() { |
this.listenersEnabled = false; |
if (timeStart.getTimeInMillis() != ms) { |
timeStart.setTimeInMillis(ms); |
} |
this.listenersEnabled = true; |
} |
}); |
} |
public void setDuration(final Integer min) { |
if (!((Integer) duration.getValue()).equals(min)) { |
this.listenersEnabled = false; |
if (getSpinnerValue(duration) != min) { |
duration.setValue(min); |
} |
this.listenersEnabled = true; |
} |
public int getSpinnerValue(JSpinner s) { |
final Object o = s.getValue(); |
if (o == null) |
return 0; |
return ((Number) o).intValue(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/TimeTextField.java |
---|
13,7 → 13,6 |
package org.openconcerto.ui; |
import java.awt.Dimension; |
import java.awt.event.KeyAdapter; |
import java.awt.event.KeyEvent; |
import java.util.Calendar; |
/trunk/OpenConcerto/src/org/openconcerto/ui/EnhancedTable.java |
---|
384,8 → 384,12 |
* resizingColumn.setPreferredWidth(resizingColumn.getWidth()); } |
*/ |
// Vu! Si on ne le fait pas, les colonnes sortent de la largeur |
try { |
super.columnMarginChanged(e); |
} catch (Exception ex) { |
// Can happen if editor removed |
ex.printStackTrace(); |
} |
resizeAndRepaint(); |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/preferences/PreferenceFrame.java |
---|
85,8 → 85,8 |
this.getContentPane().add(p1, c); |
this.setBackground(p1.getBackground()); |
this.getContentPane().setBackground(p1.getBackground()); |
this.setMinimumSize(new Dimension(800, 660)); |
this.setPreferredSize(new Dimension(800, 660)); |
this.setMinimumSize(new Dimension(880, 680)); |
this.setPreferredSize(new Dimension(880, 680)); |
prefTree.addTreeSelectionListener(this.mainPrefPanel); |
buttonClose.addActionListener(new ActionListener() { |
public void actionPerformed(ActionEvent e) { |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIDescriptor.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/ColumnsSpec.java |
---|
13,54 → 13,76 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONconverter; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import java.util.ArrayList; |
import java.util.Collections; |
import java.util.List; |
public class ColumnsSpec implements Externalizable, JSONAble { |
import org.jdom.Document; |
import org.jdom.Element; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class ColumnsSpec implements Externalizable, Transferable { |
private String id; |
// All the columns that could be displayed |
private List<ColumnSpec> columns; |
private List<ColumnSpec> columns = new ArrayList<ColumnSpec>(); |
// Ids visible in the table, in the same order of the display |
private List<String> visibleIds; |
private List<String> possibleColumnIds = new ArrayList<String>(); |
// Ids of the sorted columns |
private List<String> sortedIds; |
private List<String> sortedIds = new ArrayList<String>(); |
// number of fixed columns, used for vertical "split" |
private int fixedColumns; |
private Boolean allowMove = false; |
private Boolean allowResize = false; |
public ColumnsSpec() { |
// Serialization |
} |
public ColumnsSpec(String id, List<ColumnSpec> columns, List<String> visibleIds, List<String> sortedIds) { |
public ColumnsSpec(final JSONObject json) { |
this.fromJSON(json); |
} |
public ColumnsSpec(final String id, final List<ColumnSpec> columns, final List<String> possibleColumnIds, final List<String> sortedIds) throws IllegalArgumentException { |
// Id checks |
if (id == null) { |
throw new IllegalArgumentException("null id"); |
} |
this.id = id; |
this.columns = columns; |
// Visible checks |
if (visibleIds == null) { |
throw new IllegalArgumentException("null visible columns"); |
// Columns checks |
if (columns == null) { |
throw new IllegalArgumentException("null columns"); |
} |
if (visibleIds.isEmpty()) { |
throw new IllegalArgumentException("empty visible columns"); |
if (columns.isEmpty()) { |
throw new IllegalArgumentException("empty columns"); |
} |
this.columns = columns; |
this.visibleIds = visibleIds; |
// Sort checks |
if (sortedIds == null) { |
sortedIds = Collections.emptyList(); |
// Possible checks |
if (possibleColumnIds == null) { |
throw new IllegalArgumentException("null possible column ids"); |
} |
if (possibleColumnIds.isEmpty()) { |
throw new IllegalArgumentException("empty possible column ids"); |
} |
this.possibleColumnIds = possibleColumnIds; |
// Sort assign |
this.sortedIds = sortedIds; |
// Allow move assign |
this.allowMove = allowMove; |
// Allow resize assign |
this.allowMove = allowResize; |
} |
public String getId() { |
67,8 → 89,8 |
return this.id; |
} |
public List<String> getVisibleIds() { |
return this.visibleIds; |
public List<String> getPossibleColumnIds() { |
return this.possibleColumnIds; |
} |
public List<String> getSortedIds() { |
89,6 → 111,24 |
return this.columns.get(i); |
} |
public ColumnSpec setColumn(int i, final ColumnSpec column) { |
return this.columns.set(i, column); |
} |
public Boolean isAllowMove() { |
return this.allowMove; |
} |
public void setAllowMove(final boolean allowMove) { |
this.allowMove = allowMove; |
} |
public Boolean isAllowResize() { |
return this.allowResize; |
} |
public void setAllowResize(final boolean allowResize) { |
this.allowResize = allowResize; |
} |
public List<String> getColumnsIds() { |
ArrayList<String> result = new ArrayList<String>(this.columns.size()); |
for (ColumnSpec c : this.columns) { |
97,13 → 137,68 |
return result; |
} |
public void setUserPrefs(final Document columnsPrefs) { |
if (columnsPrefs != null) { |
// user preferences application |
final Element rootElement = columnsPrefs.getRootElement(); |
if (!rootElement.getName().equals("list")) { |
throw new IllegalArgumentException("invalid xml, roots node list expected but " + rootElement.getName() + " found"); |
} |
final List<Element> xmlColumns = rootElement.getChildren(); |
final int columnsCount = this.columns.size(); |
if (xmlColumns.size() != columnsCount) { |
throw new IllegalArgumentException("incorrect columns count in xml"); |
} |
for (int i = 0; i < columnsCount; i++) { |
final ColumnSpec columnSpec = this.columns.get(i); |
final String columnId = columnSpec.getId(); |
boolean find = false; |
for (int j = 0; j < columnsCount; j++) { |
final Element xmlColumn = xmlColumns.get(j); |
final String xmlColumnId = xmlColumn.getAttribute("id").getValue(); |
if (xmlColumnId.equals(columnId)) { |
if (!xmlColumn.getName().equals("column")) { |
throw new IllegalArgumentException("ColumnSpec setPrefs - Invalid xml, element node column expected but " + xmlColumn.getName() + " found"); |
} |
if (xmlColumn.getAttribute("width") == null || xmlColumn.getAttribute("min-width") == null || xmlColumn.getAttribute("max-width") == null) { |
throw new IllegalArgumentException("ColumnSpec setPrefs - Invalid column node for " + columnId + ", it must have attribute width, min-width, max-width"); |
} |
final int width = Integer.parseInt(xmlColumn.getAttribute("width").getValue()); |
final int maxWidth = Integer.parseInt(xmlColumn.getAttribute("max-width").getValue()); |
final int minWidth = Integer.parseInt(xmlColumn.getAttribute("min-width").getValue()); |
columnSpec.setPrefs(width, maxWidth, minWidth); |
if (i != j) { |
final ColumnSpec swap = this.columns.get(i); |
this.columns.set(i, this.columns.get(j)); |
this.columns.set(j, swap); |
} |
find = true; |
break; |
} |
} |
if (!find) { |
throw new IllegalArgumentException("xml contain unknow column: " + columnId); |
} |
} |
} |
} |
@Override |
public void writeExternal(ObjectOutput out) throws IOException { |
out.writeUTF(this.id); |
out.writeInt(this.fixedColumns); |
out.writeObject(this.columns); |
out.writeObject(this.visibleIds); |
out.writeObject(this.possibleColumnIds); |
out.writeObject(this.sortedIds); |
out.writeBoolean(this.allowMove); |
out.writeBoolean(this.allowResize); |
} |
@Override |
111,14 → 206,16 |
this.id = in.readUTF(); |
this.fixedColumns = in.readInt(); |
this.columns = (List<ColumnSpec>) in.readObject(); |
this.visibleIds = (List<String>) in.readObject(); |
this.possibleColumnIds = (List<String>) in.readObject(); |
this.sortedIds = (List<String>) in.readObject(); |
this.allowMove = in.readBoolean(); |
this.allowResize = in.readBoolean(); |
} |
public List<Object> getDefaultValues() { |
List<Object> l = new ArrayList<Object>(); |
for (String id : this.visibleIds) { |
Object v = getColumn(id).getDefaultValue(); |
final List<Object> l = new ArrayList<Object>(); |
for (ColumnSpec column : this.columns) { |
final Object v = column.getDefaultValue(); |
l.add(v); |
} |
return l; |
144,16 → 241,54 |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "ColumnsSpec"); |
result.put("id", this.id); |
result.put("fixed-columns", this.fixedColumns); |
if(this.sortedIds != null && this.sortedIds.size() > 0) { |
result.put("sorted-ids", this.sortedIds); |
} |
if(this.possibleColumnIds != null && this.possibleColumnIds.size() > 0) { |
result.put("possible-column-ids", this.possibleColumnIds); |
} |
if(this.columns != null && this.columns.size() > 0) { |
result.put("columns", JSONConverter.getJSON(this.columns)); |
} |
if(this.allowMove) { |
result.put("allow-move", JSONConverter.getJSON(true)); |
} |
if(this.allowResize) { |
result.put("allow-resize", JSONConverter.getJSON(true)); |
} |
return result; |
} |
result.append("\"id\":" + JSONconverter.getJSON(this.id) + ","); |
result.append("\"fixedColumns\":" + JSONconverter.getJSON(this.fixedColumns) + ","); |
result.append("\"sortedIds\":" + JSONconverter.getJSON(this.sortedIds) + ","); |
result.append("\"visibleIds\":" + JSONconverter.getJSON(this.visibleIds) + ","); |
result.append("\"columns\":" + JSONconverter.getJSON(this.columns)); |
@Override |
public void fromJSON(final JSONObject json) { |
this.id = (String) JSONConverter.getParameterFromJSON(json, "id", String.class); |
this.fixedColumns = (Integer) JSONConverter.getParameterFromJSON(json, "fixed-columns", Integer.class); |
this.allowMove = (Boolean) JSONConverter.getParameterFromJSON(json, "allow-move", Boolean.class, false); |
this.allowResize = (Boolean) JSONConverter.getParameterFromJSON(json, "allow-resize", Boolean.class, false); |
final JSONArray jsonSortedIds = (JSONArray) JSONConverter.getParameterFromJSON(json, "sorted-ids", JSONArray.class, null); |
if(jsonSortedIds != null) { |
this.sortedIds = (List<String>) (List<?>) jsonSortedIds; |
} |
final JSONArray jsonPossibleColumnIds = (JSONArray) JSONConverter.getParameterFromJSON(json, "possible-column-ids", JSONArray.class, null); |
if(jsonPossibleColumnIds != null) { |
this.possibleColumnIds = (List<String>) (List<?>) jsonPossibleColumnIds; |
} |
result.append("}"); |
return result.toString(); |
final JSONArray jsonColumns = (JSONArray) JSONConverter.getParameterFromJSON(json, "columns", JSONArray.class, null); |
if (jsonColumns != null) { |
final int columnsSize = jsonColumns.size(); |
for (int i = 0; i < columnsSize; i++) { |
final Object objColumnSpec = jsonColumns.get(i); |
if (!(objColumnSpec instanceof JSONObject)) { |
throw new IllegalArgumentException("invalid value for 'columns', List<ColumnSpec> expected"); |
} |
this.columns.add(new ColumnSpec((JSONObject) objColumnSpec)); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/InformationLine.java |
---|
New file |
0,0 → 1,40 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
public class InformationLine extends LightUILine { |
public InformationLine(final String id, final String key, final String value) { |
this.setGridAlignment(ALIGN_GRID); |
final LightUILabel keyElement = new LightUILabel(id + ".key." + key.replace(" ", ".").toLowerCase(), key, true); |
keyElement.setHorizontalAlignement(LightUIElement.HALIGN_RIGHT); |
add(keyElement); |
final LightUILabel valueElement = new LightUILabel(id + ".value." + key.replace(" ", ".").toLowerCase(), value); |
valueElement.setHorizontalAlignement(LightUIElement.HALIGN_LEFT); |
add(valueElement); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightControler.java |
---|
13,15 → 13,21 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONconverter; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONObject; |
public class LightControler implements Transferable { |
public class LightControler implements Externalizable, Transferable { |
/** |
* |
*/ |
private static final long serialVersionUID = 5894135825924339012L; |
private final String type, src, dest; |
private String type, src, dest; |
public static final String TYPE_ACTIVATION_ON_SELECTION = "activationOnSelection"; |
public static final String TYPE_ADD_DEFAULT = "addDefault"; |
public static final String TYPE_INSERT_DEFAULT = "insertDefault"; |
30,7 → 36,15 |
public static final String TYPE_UP = "up"; |
public static final String TYPE_DOWN = "down"; |
public LightControler(String type, String src, String dest) { |
public LightControler() { |
// Serialization |
} |
public LightControler(final JSONObject json) { |
this.fromJSON(json); |
} |
public LightControler(final String type, final String src, final String dest) { |
this.type = type; |
this.src = src; |
this.dest = dest; |
54,14 → 68,33 |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "LightControler"); |
result.put("type", this.type); |
result.put("src", this.src); |
result.put("dest", this.dest); |
return result; |
} |
result.append("\"type\":" + JSONconverter.getJSON(this.type) + ","); |
result.append("\"src\":" + JSONconverter.getJSON(this.src) + ","); |
result.append("\"dest\":" + JSONconverter.getJSON(this.dest)); |
@Override |
public void fromJSON(final JSONObject json) { |
this.type = (String) JSONConverter.getParameterFromJSON(json, "type", String.class); |
this.src = (String) JSONConverter.getParameterFromJSON(json, "src", String.class); |
this.dest = (String) JSONConverter.getParameterFromJSON(json, "dest", String.class); |
} |
result.append("}"); |
return result.toString(); |
@Override |
public void writeExternal(ObjectOutput out) throws IOException { |
out.writeUTF(this.type); |
out.writeUTF(this.src); |
out.writeUTF(this.dest); |
} |
@Override |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
this.type = in.readUTF(); |
this.src = in.readUTF(); |
this.dest = in.readUTF(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIButton.java |
---|
14,7 → 14,6 |
package org.openconcerto.ui.light; |
public class LightUIButton extends LightUIElement { |
public LightUIButton(String id, String label) { |
setType(LightUIElement.TYPE_BUTTON); |
setId(id); |
21,5 → 20,4 |
setGridWidth(1); |
setLabel(label); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/TableSpec.java |
---|
13,22 → 13,34 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONconverter; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONObject; |
public class TableSpec implements Transferable { |
private String id; |
private ColumnsSpec columns; |
private TableContent content; |
private RowSelectionSpec selection; |
private SearchSpec search; |
public TableSpec() { |
public TableSpec(final String tableId, final RowSelectionSpec selection, final ColumnsSpec columns) { |
this.id = tableId + ".spec"; |
this.selection = selection; |
this.columns = columns; |
} |
public TableSpec(final JSONObject json) { |
this.fromJSON(json); |
} |
public String getId() { |
return this.id; |
} |
public void setId(String id) { |
public void setId(final String id) { |
this.id = id; |
} |
36,7 → 48,7 |
return this.columns; |
} |
public void setColumns(ColumnsSpec columns) { |
public void setColumns(final ColumnsSpec columns) { |
this.columns = columns; |
} |
44,20 → 56,109 |
return this.content; |
} |
public void setContent(TableContent content) { |
public void setContent(final TableContent content) { |
this.content = content; |
} |
public RowSelectionSpec getSelection() { |
return this.selection; |
} |
public void setSelection(final RowSelectionSpec selection) { |
this.selection = selection; |
} |
public SearchSpec getSearch() { |
return this.search; |
} |
public void setSearch(final SearchSpec search) { |
this.search = search; |
} |
public void setRowEditorFromColumnSpec() { |
if (this.columns == null) { |
throw new IllegalArgumentException("ColumnsSpec must not be null for run thsi function"); |
} |
if (this.content != null) { |
final int columnsSize = this.columns.getColumnCount(); |
final List<Row> listRow = this.content.getRows(); |
if (listRow != null && listRow.size() > 0) { |
final int listRowSize = listRow.size(); |
for (int k = 0; k < columnsSize; k++) { |
final ColumnSpec columnSpec = this.columns.getColumn(k); |
final LightUIElement columnEditor = columnSpec.getEditor(); |
if (columnEditor != null) { |
System.out.println("TableSpec.setRowEditorFromColumnSpec() - Editor found for table: " + this.id + " and column: " + columnSpec.getId()); |
for (int l = 0; l < listRowSize; l++) { |
final Row row = listRow.get(l); |
if (row == null) { |
throw new IllegalArgumentException("Table: " + this.id + " has one or more rows null"); |
} |
final List<Object> rowValues = row.getValues(); |
if (rowValues == null) { |
throw new IllegalArgumentException("Table: " + this.id + " has null values for row " + row.getId()); |
} |
if (rowValues.size() < k) { |
throw new IllegalArgumentException("Table: " + this.id + " has incorrect values count for row " + row.getId()); |
} |
final LightUIElement rowEditor = columnEditor.clone(); |
rowEditor.setId(columnEditor.getId() + "." + String.valueOf(row.getId())); |
final Object value = rowValues.get(k); |
if (value != null) { |
rowEditor.setValue(rowValues.get(k).toString()); |
} else { |
rowEditor.setValue(null); |
} |
rowValues.set(k, rowEditor); |
} |
} |
} |
} else { |
System.out.println("TableSpec.setRowEditorFromColumnSpec() - TableContent without Row for table: " + this.id); |
} |
} else { |
System.out.println("TableSpec.setRowEditorFromColumnSpec() - TableContent null for table: " + this.id); |
} |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "TableSpec"); |
result.put("id", this.id); |
result.put("columns", JSONConverter.getJSON(this.columns)); |
result.put("content", JSONConverter.getJSON(this.content)); |
result.put("selection", JSONConverter.getJSON(this.selection)); |
result.put("search", JSONConverter.getJSON(this.search)); |
return result; |
} |
result.append("\"id\":" + JSONconverter.getJSON(this.id) + ","); |
result.append("\"columns\":" + JSONconverter.getJSON(this.columns) + ","); |
result.append("\"content\":" + JSONconverter.getJSON(this.content)); |
@Override |
public void fromJSON(final JSONObject json) { |
this.id = (String) JSONConverter.getParameterFromJSON(json, "id", String.class); |
result.append("}"); |
return result.toString(); |
final JSONObject jsonColumns = (JSONObject) JSONConverter.getParameterFromJSON(json, "columns", JSONObject.class); |
if (jsonColumns != null) { |
this.columns = new ColumnsSpec(jsonColumns); |
} |
final JSONObject jsonContent = (JSONObject) JSONConverter.getParameterFromJSON(json, "content", JSONObject.class); |
if (jsonContent != null) { |
this.content = new TableContent(jsonContent); |
} |
final JSONObject jsonSelection = (JSONObject) JSONConverter.getParameterFromJSON(json, "selection", JSONObject.class); |
if (jsonSelection != null) { |
this.selection = new RowSelectionSpec(jsonSelection); |
} |
final JSONObject jsonSearch = (JSONObject) JSONConverter.getParameterFromJSON(json, "search", JSONObject.class); |
if (jsonSearch != null) { |
this.search = new SearchSpec(jsonSearch); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUILabel.java |
---|
New file |
0,0 → 1,82 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import net.minidev.json.JSONObject; |
public class LightUILabel extends LightUIElement { |
boolean isTitle = false; |
// Init from json constructor |
public LightUILabel(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUILabel(final LightUILabel labelElement) { |
super(labelElement); |
this.isTitle = labelElement.isTitle; |
} |
public LightUILabel(final String id) { |
this.setType(TYPE_LABEL); |
this.setId(id); |
} |
public LightUILabel(final String id, final boolean isTitle) { |
this.setType(TYPE_LABEL); |
this.setId(id); |
this.isTitle = isTitle; |
} |
public LightUILabel(final String id, final String label) { |
this.setType(TYPE_LABEL); |
this.setLabel(label); |
this.setId(id); |
} |
public LightUILabel(final String id, final String label, final boolean title) { |
this.setType(TYPE_LABEL); |
this.setLabel(label); |
this.setId(id); |
this.isTitle = title; |
} |
@Override |
public LightUIElement clone() { |
return new LightUILabel(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
if (this.isTitle) { |
json.put("title", true); |
} |
return json; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/SimpleTextLine.java |
---|
New file |
0,0 → 1,39 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
public class SimpleTextLine extends LightUILine { |
public SimpleTextLine(final String cellId, final String text) { |
this(cellId, text, false, LightUIElement.HALIGN_LEFT); |
} |
public SimpleTextLine(final String cellId, final String text, final boolean title, final int horizontalAlignement) { |
final LightUILabel element = new LightUILabel(cellId, text, title); |
element.setHorizontalAlignement(horizontalAlignement); |
element.setFillWidth(true); |
this.add(element); |
this.setGridAlignment(LightUILine.ALIGN_LEFT); |
} |
public SimpleTextLine(final String cellId, final String text, final boolean title, final int horizontalAlignement, final int gridWidth) { |
final LightUILabel element = new LightUILabel(cellId, text, title); |
element.setHorizontalAlignement(horizontalAlignement); |
element.setFillWidth(true); |
element.setGridWidth(gridWidth); |
this.add(element); |
this.setGridAlignment(LightUILine.ALIGN_LEFT); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUITabbed.java |
---|
New file |
0,0 → 1,119 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.util.LinkedHashMap; |
import java.util.Map.Entry; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUITabbed extends LightUIElement { |
LinkedHashMap<String, LightUIPanel> tabs = new LinkedHashMap<String, LightUIPanel>(); |
String selectedTab; |
// Init from json constructor |
public LightUITabbed(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUITabbed(final LightUITabbed tabbedElement) { |
super(tabbedElement); |
this.tabs = tabbedElement.tabs; |
this.selectedTab = tabbedElement.selectedTab; |
} |
public LightUITabbed(final String id) { |
super(); |
this.setId(id); |
this.setType(TYPE_TABBED_UI); |
} |
public LightUIPanel getTab(final String title) { |
return this.tabs.get(title); |
} |
public LightUIPanel getTab(final int index) { |
final Object o = this.tabs.values().toArray()[index]; |
if(!(o instanceof LightUIPanel)) { |
throw new IllegalArgumentException("the value at " + String.valueOf(index) + " is not valid"); |
} |
return (LightUIPanel) o; |
} |
public void addTab(final String title, final LightUIPanel panel) { |
this.tabs.put(title, panel); |
} |
public void setSelectedTab(final String selectedTab) { |
this.selectedTab = selectedTab; |
} |
public int getTabsCount() { |
return this.tabs.size(); |
} |
public LightUIElement getElementById(final String id) { |
for(final LightUIPanel tab : this.tabs.values()) { |
final LightUIElement result = tab.getElementById(id); |
if(result != null) { |
return result; |
} |
} |
return null; |
} |
@Override |
public LightUIElement clone() { |
return new LightUITabbed(this); |
} |
@Override public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
json.put("selected-tab", this.selectedTab); |
final JSONArray jsonTabs = new JSONArray(); |
for(final Entry<String, LightUIPanel> entry : this.tabs.entrySet()) { |
final JSONObject jsonTab = new JSONObject(); |
jsonTab.put("title", entry.getKey()); |
jsonTab.put("panel", entry.getValue().toJSON()); |
jsonTabs.add(jsonTab); |
} |
json.put("tabs", jsonTabs); |
return json; |
} |
@Override public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
this.selectedTab = (String) JSONConverter.getParameterFromJSON(json, "selected-tab", String.class); |
final JSONArray jsonTabs = (JSONArray) JSONConverter.getParameterFromJSON(json, "tabs", JSONArray.class); |
this.tabs.clear(); |
if(jsonTabs != null) { |
for(final Object objTab : jsonTabs) { |
if(!(objTab instanceof JSONObject)) { |
throw new IllegalArgumentException("value for 'selected-tab' is invalid"); |
} |
final JSONObject jsonTab = (JSONObject) objTab; |
final String title = (String) JSONConverter.getParameterFromJSON(jsonTab, "title", String.class); |
final LightUIPanel panel = new LightUIPanel((JSONObject) JSONConverter.getParameterFromJSON(jsonTab, "panel", JSONObject.class)); |
this.tabs.put(title, panel); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/RowsBulk.java |
---|
13,9 → 13,6 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONconverter; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
24,6 → 21,11 |
import java.util.Collections; |
import java.util.List; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class RowsBulk implements Externalizable, JSONAble { |
private List<Row> rows; |
33,6 → 35,10 |
public RowsBulk() {// Serialization |
} |
public RowsBulk(final JSONObject json) { |
this.fromJSON(json); |
} |
public RowsBulk(List<Row> rows, int offset, int total) { |
this.rows = rows; |
this.offset = offset; |
113,14 → 119,26 |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "RowsBulk"); |
result.put("rows", JSONConverter.getJSON(this.rows)); |
result.put("offset", this.offset); |
result.put("total", this.total); |
return result; |
} |
result.append("\"rows\":" + JSONconverter.getJSON(this.rows) + ","); |
result.append("\"offset\":" + JSONconverter.getJSON(this.offset) + ","); |
result.append("\"total\":" + JSONconverter.getJSON(this.total)); |
@Override |
public void fromJSON(final JSONObject json) { |
this.offset = (Integer) JSONConverter.getParameterFromJSON(json, "offset", Integer.class); |
this.total = (Integer) JSONConverter.getParameterFromJSON(json, "total", Integer.class); |
result.append("}"); |
return result.toString(); |
final JSONArray jsonRows = (JSONArray) JSONConverter.getParameterFromJSON(json, "rows", JSONArray.class); |
this.rows = new ArrayList<Row>(); |
if (jsonRows != null) { |
for (final Object o : jsonRows) { |
this.rows.add(new Row((JSONObject) JSONConverter.getObjectFromJSON(o, JSONObject.class))); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUICheckBox.java |
---|
New file |
0,0 → 1,45 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import net.minidev.json.JSONObject; |
public class LightUICheckBox extends LightUIElement { |
public LightUICheckBox(final JSONObject json) { |
this.fromJSON(json); |
} |
public LightUICheckBox(final String id, final String label) { |
this.setType(TYPE_CHECKBOX); |
this.setId(id); |
this.setLabel(label); |
this.setValueType(LightUIElement.VALUE_TYPE_BOOLEAN); |
} |
public void setChecked(boolean checked) { |
if (checked) { |
this.setValue("true"); |
} else { |
this.setValue("false"); |
} |
} |
public boolean isChecked() { |
if (this.getValue() == null) { |
return false; |
} |
return this.getValue().equals("true"); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUITextField.java |
---|
17,5 → 17,6 |
public LightUITextField(String id) { |
this.setId(id); |
this.setType(TYPE_TEXT_FIELD); |
this.setValueType(LightUIElement.VALUE_TYPE_STRING); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIDropDownButton.java |
---|
New file |
0,0 → 1,89 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.util.LinkedHashMap; |
import java.util.Map.Entry; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUIDropDownButton extends LightUIElement { |
String title = null; |
LinkedHashMap<String, LightUIElement> tableActions = new LinkedHashMap<String, LightUIElement>(); |
public LightUIDropDownButton(final String id, final String title) { |
super(); |
this.setType(TYPE_DROPDOWN_BUTTON); |
this.setId(id); |
this.title = title; |
} |
// Init from json constructor |
public LightUIDropDownButton(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUIDropDownButton(final LightUIDropDownButton dropDownElement) { |
super(dropDownElement); |
this.title = dropDownElement.title; |
this.tableActions = dropDownElement.tableActions; |
} |
public void addAction(final String id, final LightUIElement button) { |
this.tableActions.put(id, button); |
} |
@Override |
public LightUIElement clone() { |
return new LightUIDropDownButton(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
json.put("title", this.title); |
final JSONArray jsonTableActions = new JSONArray(); |
for (Entry<String, LightUIElement> action : this.tableActions.entrySet()) { |
final JSONObject jsonAction = new JSONObject(); |
jsonAction.put("id", action.getKey()); |
jsonAction.put("button", action.getValue().toJSON()); |
jsonTableActions.add(jsonAction); |
} |
json.put("table-actions", jsonTableActions); |
return json; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
this.title = (String) JSONConverter.getParameterFromJSON(json, "title", String.class); |
final JSONArray jsonTabs = (JSONArray) JSONConverter.getParameterFromJSON(json, "table-actions", JSONArray.class); |
this.tableActions.clear(); |
if (jsonTabs != null) { |
for (final Object o : jsonTabs) { |
if (!(o instanceof JSONObject)) { |
throw new IllegalArgumentException("invalid value for 'table-actions', Map<String, LightUIElement> expected"); |
} |
final JSONObject jsonTableAction = (JSONObject) o; |
final String id = (String) JSONConverter.getParameterFromJSON(jsonTableAction, "id", String.class); |
final LightUIElement button = new LightUIElement((JSONObject) JSONConverter.getParameterFromJSON(jsonTableAction, "button", JSONObject.class)); |
this.tableActions.put(id, button); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIElement.java |
---|
15,11 → 15,12 |
import java.awt.Color; |
import java.io.PrintStream; |
import java.util.ArrayList; |
import java.util.List; |
import java.util.HashMap; |
import java.util.Map; |
import org.openconcerto.utils.io.JSONconverter; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONObject; |
public class LightUIElement implements Transferable { |
/** |
31,19 → 32,24 |
public static final int TYPE_TEXT_FIELD = 1; |
public static final int TYPE_DATE = 2; |
public static final int TYPE_COMBOBOX = 3; |
public static final int TYPE_LIST = 4; |
public static final int TYPE_TABLE = 4; |
public static final int TYPE_CHECKBOX = 5; |
public static final int TYPE_TABBED_UI = 6; |
public static final int TYPE_COMBOBOX_ELEMENT = 7; |
public static final int TYPE_DESCRIPTOR = 8; |
public static final int TYPE_PANEL = 8; |
public static final int TYPE_TREE = 9; |
public static final int TYPE_TEXT = 10; |
public static final int TYPE_SCROLLABLE = 11; |
public static final int TYPE_LIST = 12; |
public static final int TYPE_DROPDOWN_BUTTON = 13; |
public static final int TYPE_FRAME = 14; |
public static final int TYPE_BUTTON = 20; |
public static final int TYPE_BUTTON_WITH_CONTEXT = 21; |
public static final int TYPE_BUTTON_CANCEL = 22; |
public static final int TYPE_BUTTON_UNMANAGED = 23; |
public static final int TYPE_BUTTON_WITH_SELECTION_CONTEXT = 24; |
public static final int TYPE_BUTTON_LINK = 25; |
// valueType |
public static final int VALUE_TYPE_STRING = 0; |
public static final int VALUE_TYPE_INTEGER = 1; |
51,38 → 57,104 |
public static final int VALUE_TYPE_REF = 3; |
public static final int VALUE_TYPE_LIST = 4; |
public static final int VALUE_TYPE_DECIMAL = 5; |
public static final int VALUE_TYPE_BOOLEAN = 6; |
// actionType |
public static final int ACTION_TYPE_SELECTION = 0; |
public static final int ACTION_TYPE_REMOVE = 1; |
public static final int ACTION_TYPE_REFRESH = 2; |
// commitMode |
public static final int COMMIT_ONCE = 0; |
public static final int COMMIT_INTERACTIVE = 1; |
// horizontalAlignement |
public static final int HALIGN_RIGHT = 0; |
public static final int HALIGN_CENTER = 1; |
public static final int HALIGN_LEFT = 2; // Default |
// verticalAlignement |
public static final int VALIGN_TOP = 0; // Default |
public static final int VALIGN_CENTER = 1; |
public static final int VALIGN_BOTTOM = 2; |
// font size |
public static final int FONT_XXSMALL = 0; |
public static final int FONT_XSMALL = 1; |
public static final int FONT_SMALL = 2; // Default |
public static final int FONT_MEDIUM = 3; |
public static final int FONT_LARGE = 4; |
public static final int FONT_XLARGE = 5; |
public static final int FONT_XXLARGE = 6; |
// Type |
private int type; |
// Layout |
private int gridWidth; |
private Integer commitMode; |
private Integer fontSize = FONT_SMALL; |
private Integer gridWidth = 1; |
private Integer horizontalAlignement = HALIGN_LEFT; |
private Integer height = null; |
private Integer minInputSize; |
private Integer type; |
private Integer valueType; |
private Integer verticalAlignement = VALIGN_TOP; |
private Integer width = null; |
private boolean foldable = false; |
private boolean folded = false; |
private boolean fillWidth; |
// Values |
private boolean horizontallyResizable; |
private boolean required; |
private boolean verticallyResizable; |
private String displayPrecision;// "(1,2)" means that 0.159 is shown as 0.16 |
private String icon; |
private String id; |
private String label; |
private String toolTip; |
// Values |
private String value; |
private TableSpec rawContent; |
private int valueType; |
private int commitMode; |
private String valuePrecision;// "(6,2)" 999999.99 is the max |
private String displayPrecision;// "(1,2)" means that 0.159 is shown as 0.16 |
private String valueRange; // [-3.14,3.14] |
private int minInputSize; |
private List<LightUIDescriptor> tabs; |
// Colors |
private Color color; |
// Icon |
private String icon; |
private boolean required; |
private Color backgroundColor; |
private Color foreColor; |
private String toolTip; |
private boolean verticalyResizable; |
private boolean horizontalyResizable; |
private Map<Integer, String> actions = new HashMap<Integer, String>(); |
public LightUIElement() { |
} |
// Init from json constructor |
public LightUIElement(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUIElement(final LightUIElement element) { |
this.commitMode = element.commitMode; |
this.gridWidth = element.gridWidth; |
this.horizontalAlignement = element.horizontalAlignement; |
this.height = element.height; |
this.minInputSize = element.minInputSize; |
this.type = element.type; |
this.valueType = element.valueType; |
this.verticalAlignement = element.verticalAlignement; |
this.width = element.width; |
this.fontSize = element.fontSize; |
this.foldable = element.foldable; |
this.folded = element.folded; |
this.fillWidth = element.fillWidth; |
this.horizontallyResizable = element.horizontallyResizable; |
this.required = element.required; |
this.verticallyResizable = element.verticallyResizable; |
this.displayPrecision = element.displayPrecision; |
this.icon = element.icon; |
this.id = element.id; |
this.label = element.label; |
this.toolTip = element.toolTip; |
this.value = element.value; |
this.valuePrecision = element.valuePrecision; |
this.valueRange = element.valueRange; |
this.backgroundColor = element.backgroundColor; |
this.foreColor = element.foreColor; |
this.actions = element.actions; |
} |
public int getType() { |
return this.type; |
} |
99,6 → 171,22 |
this.gridWidth = gridWidth; |
} |
public boolean isFoldable() { |
return this.foldable; |
} |
public void setFoldable(boolean foldable) { |
this.foldable = foldable; |
} |
public boolean isFolded() { |
return this.folded; |
} |
public void setFolded(boolean folded) { |
this.folded = folded; |
} |
public boolean isFillWidth() { |
return this.fillWidth; |
} |
107,14 → 195,30 |
this.fillWidth = fillWidth; |
} |
public Color getColor() { |
return this.color; |
public Color getBackgroundColor() { |
return this.backgroundColor; |
} |
public void setColor(Color color) { |
this.color = color; |
public void setBackgroundColor(Color backgroundColor) { |
this.backgroundColor = backgroundColor; |
} |
public Color getForeColor() { |
return this.foreColor; |
} |
public int getFontSize() { |
return this.fontSize; |
} |
public void setFontSize(final int fontSize) { |
this.fontSize = fontSize; |
} |
public void setForeColor(Color foreColor) { |
this.foreColor = foreColor; |
} |
public String getIcon() { |
return this.icon; |
} |
195,6 → 299,22 |
this.minInputSize = minInputSize; |
} |
public Integer getHeight() { |
return this.height; |
} |
public void setHeight(Integer height) { |
this.height = height; |
} |
public Integer getWidth() { |
return this.width; |
} |
public void setWidth(Integer width) { |
this.width = width; |
} |
public boolean isRequired() { |
return this.required; |
} |
203,10 → 323,6 |
this.required = required; |
} |
public List<LightUIDescriptor> getTabs() { |
return this.tabs; |
} |
public String getToolTip() { |
return this.toolTip; |
} |
215,29 → 331,42 |
this.toolTip = toolTip; |
} |
public void addTab(LightUIDescriptor desc) { |
if (this.tabs == null) { |
this.tabs = new ArrayList<LightUIDescriptor>(5); |
public final boolean isVerticallyResizable() { |
return this.verticallyResizable; |
} |
this.tabs.add(desc); |
public final void setVerticalyResizable(boolean verticallyResizable) { |
this.verticallyResizable = verticallyResizable; |
} |
public final boolean isVerticalyResizable() { |
return this.verticalyResizable; |
public final boolean isHorizontalyResizable() { |
return this.horizontallyResizable; |
} |
public final void setVerticalyResizable(boolean verticalyResizable) { |
this.verticalyResizable = verticalyResizable; |
public final void setHorizontalyResizable(boolean horizontallyResizable) { |
this.horizontallyResizable = horizontallyResizable; |
} |
public final boolean isHorizontalyResizable() { |
return this.horizontalyResizable; |
public final Integer getHorizontalAlignement() { |
return this.horizontalAlignement; |
} |
public final void setHorizontalyResizable(boolean horizontalyResizable) { |
this.horizontalyResizable = horizontalyResizable; |
public final void setHorizontalAlignement(Integer horizontalAlignement) { |
this.horizontalAlignement = horizontalAlignement; |
} |
public final Integer getVerticalAlignement() { |
return this.verticalAlignement; |
} |
public final void setVerticalAlignement(Integer verticalAlignement) { |
this.verticalAlignement = verticalAlignement; |
} |
public final void addAction(final Integer actionType, final String actionId) { |
this.actions.put(actionType, actionId); |
} |
public void dump(PrintStream out) { |
String type = "?"; |
if (this.type == TYPE_CHECKBOX) { |
248,7 → 377,7 |
type = "label"; |
} else if (this.type == TYPE_TEXT_FIELD) { |
type = "textfield"; |
} else if (this.type == TYPE_LIST) { |
} else if (this.type == TYPE_TABLE) { |
type = "list"; |
} else if (this.type == TYPE_TABBED_UI) { |
type = "tabs"; |
292,61 → 421,236 |
if (this.label != null) { |
str += " label:" + this.label; |
} |
if (this.horizontalyResizable) { |
if (this.horizontallyResizable) { |
str += "|- H ->"; |
} |
if (this.verticalyResizable) { |
if (this.verticallyResizable) { |
str += "|- V ->"; |
} |
switch (this.fontSize) { |
case FONT_XXSMALL: |
str += " font: xx-small"; |
break; |
case FONT_XSMALL: |
str += " font: x-small"; |
break; |
case FONT_SMALL: |
str += " font: small"; |
break; |
case FONT_MEDIUM: |
str += " font: medium"; |
break; |
case FONT_LARGE: |
str += " font: large"; |
break; |
case FONT_XLARGE: |
str += " font: x-large"; |
break; |
case FONT_XXLARGE: |
str += " font: xx-large"; |
break; |
} |
switch (this.horizontalAlignement) { |
case HALIGN_RIGHT: |
str += " horiz-align: right"; |
break; |
case HALIGN_CENTER: |
str += " horiz-align: center"; |
break; |
case HALIGN_LEFT: |
str += " horiz-align: left"; |
break; |
} |
switch (this.verticalAlignement) { |
case HALIGN_RIGHT: |
str += " vert-align: top"; |
break; |
case HALIGN_CENTER: |
str += " vert-align: center"; |
break; |
case HALIGN_LEFT: |
str += " vert-align: bottom"; |
break; |
} |
out.println(str); |
} |
@Override |
public LightUIElement clone() { |
return new LightUIElement(this); |
} |
@Override |
public String toString() { |
return super.toString() + " " + this.id; |
} |
public TableSpec getRawContent() { |
return this.rawContent; |
@Override |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "LightUIElement"); |
result.put("id", this.id); |
if (this.backgroundColor != null) { |
result.put("background-color", JSONConverter.getJSON(this.backgroundColor)); |
} |
if (this.commitMode != null) { |
result.put("commit-mode", this.commitMode); |
} |
if (this.displayPrecision != null) { |
result.put("display-precision", this.displayPrecision); |
} |
if (this.foldable) { |
result.put("foldable", true); |
} |
if (this.folded) { |
result.put("folded", true); |
} |
if (this.fillWidth) { |
result.put("fill-width", true); |
} |
if (this.foreColor != null) { |
result.put("fore-color", JSONConverter.getJSON(this.foreColor)); |
} |
if (this.fontSize != FONT_SMALL) { |
result.put("font-size", this.fontSize); |
} |
if (this.gridWidth != null) { |
result.put("grid-width", this.gridWidth); |
} |
if (this.horizontallyResizable) { |
result.put("horizontally-resizable", true); |
} |
if (this.verticallyResizable) { |
result.put("vertically-resizable", true); |
} |
if (this.icon != null) { |
result.put("icon", this.icon); |
} |
if (this.label != null) { |
result.put("label", this.label); |
} |
if (this.minInputSize != null) { |
result.put("min-input-size", this.minInputSize); |
} |
if (this.required) { |
result.put("required", true); |
} |
if (this.toolTip != null) { |
result.put("tool-tip", this.toolTip); |
} |
public void setRawContent(TableSpec rawContent) { |
this.rawContent = rawContent; |
result.put("type", this.type); |
result.put("value", this.value); |
if (this.valuePrecision != null) { |
result.put("value-precision", this.valuePrecision); |
} |
if (this.valueRange != null) { |
result.put("value-range", this.valueRange); |
} |
if (this.valueType != null) { |
result.put("value-type", this.valueType); |
} |
if (this.width != null) { |
result.put("width", this.width); |
} |
if (this.height != null) { |
result.put("height", this.height); |
} |
if (this.horizontalAlignement != HALIGN_LEFT) { |
result.put("horizontal-alignement", this.horizontalAlignement); |
} |
if (this.verticalAlignement != VALIGN_TOP) { |
result.put("vertical-alignement", this.verticalAlignement); |
} |
if (!this.actions.isEmpty()) { |
result.put("actions", this.actions); |
} |
return result; |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public void fromJSON(final JSONObject json) { |
this.id = (String) JSONConverter.getParameterFromJSON(json, "id", String.class); |
this.commitMode = (Integer) JSONConverter.getParameterFromJSON(json, "commit-mode", Integer.class); |
this.displayPrecision = (String) JSONConverter.getParameterFromJSON(json, "display-precision", String.class); |
this.foldable = (Boolean) JSONConverter.getParameterFromJSON(json, "foldable", Boolean.class, false); |
this.folded = (Boolean) JSONConverter.getParameterFromJSON(json, "folded", Boolean.class, false); |
this.fillWidth = (Boolean) JSONConverter.getParameterFromJSON(json, "fill-width", Boolean.class, Boolean.FALSE); |
this.fontSize = (Integer) JSONConverter.getParameterFromJSON(json, "font-size", Integer.class, FONT_SMALL); |
this.gridWidth = (Integer) JSONConverter.getParameterFromJSON(json, "grid-width", Integer.class); |
this.horizontallyResizable = (Boolean) JSONConverter.getParameterFromJSON(json, "horizontally-resizable", Boolean.class, Boolean.FALSE); |
this.verticallyResizable = (Boolean) JSONConverter.getParameterFromJSON(json, "vertically-resizable", Boolean.class, Boolean.FALSE); |
this.icon = (String) JSONConverter.getParameterFromJSON(json, "icon", String.class); |
this.label = (String) JSONConverter.getParameterFromJSON(json, "label", String.class); |
this.minInputSize = (Integer) JSONConverter.getParameterFromJSON(json, "min-input-size", Integer.class); |
this.required = (Boolean) JSONConverter.getParameterFromJSON(json, "required", Boolean.class, Boolean.FALSE); |
this.toolTip = (String) JSONConverter.getParameterFromJSON(json, "tool-tip", String.class); |
this.type = (Integer) JSONConverter.getParameterFromJSON(json, "type", Integer.class); |
this.value = (String) JSONConverter.getParameterFromJSON(json, "value", String.class); |
this.valuePrecision = (String) JSONConverter.getParameterFromJSON(json, "value-precision", String.class); |
this.valueRange = (String) JSONConverter.getParameterFromJSON(json, "value-range", String.class); |
this.valueType = (Integer) JSONConverter.getParameterFromJSON(json, "value-type", Integer.class); |
this.width = (Integer) JSONConverter.getParameterFromJSON(json, "width", Integer.class); |
this.height = (Integer) JSONConverter.getParameterFromJSON(json, "height", Integer.class); |
this.horizontalAlignement = (Integer) JSONConverter.getParameterFromJSON(json, "horizontal-alignement", Integer.class, HALIGN_LEFT); |
this.verticalAlignement = (Integer) JSONConverter.getParameterFromJSON(json, "vertical-alignement", Integer.class, VALIGN_TOP); |
result.append("\"id\":" + JSONconverter.getJSON(this.id) + ","); |
if (this.color == null) { |
result.append("\"color\":null,"); |
} else { |
result.append("\"color\":{\"r\":" + String.valueOf(this.color.getRed()) + ", \"g\":" + String.valueOf(this.color.getGreen()) + ",\"b\":" + String.valueOf(this.color.getBlue()) + "},"); |
final JSONObject jsonBackgroundColor = (JSONObject) JSONConverter.getParameterFromJSON(json, "background-color", JSONObject.class); |
if (jsonBackgroundColor != null) { |
if (!jsonBackgroundColor.containsKey("r") || !jsonBackgroundColor.containsKey("g") || !jsonBackgroundColor.containsKey("b")) { |
throw new IllegalArgumentException("value for 'background-color' is invalid, it must contains attribute r, g, b"); |
} |
result.append("\"commitMode\":" + JSONconverter.getJSON(this.commitMode) + ","); |
result.append("\"displayPrecision\":" + JSONconverter.getJSON(this.displayPrecision) + ","); |
result.append("\"fillWidth\":" + JSONconverter.getJSON(this.fillWidth) + ","); |
result.append("\"gridWidth\":" + JSONconverter.getJSON(this.gridWidth) + ","); |
result.append("\"horizontalyResizable\":" + JSONconverter.getJSON(this.horizontalyResizable) + ","); |
result.append("\"verticalyResizable\":" + JSONconverter.getJSON(this.verticalyResizable) + ","); |
result.append("\"icon\":" + JSONconverter.getJSON(this.icon) + ","); |
result.append("\"label\":" + JSONconverter.getJSON(this.label) + ","); |
result.append("\"minInputSize\":" + JSONconverter.getJSON(this.minInputSize) + ","); |
result.append("\"rawContent\":" + JSONconverter.getJSON(this.rawContent) + ","); |
result.append("\"required\":" + JSONconverter.getJSON(this.required) + ","); |
result.append("\"tabs\":" + JSONconverter.getJSON(this.tabs) + ","); |
result.append("\"toolTip\":" + JSONconverter.getJSON(this.toolTip) + ","); |
result.append("\"type\":" + JSONconverter.getJSON(this.type) + ","); |
result.append("\"value\":" + JSONconverter.getJSON(this.value) + ","); |
result.append("\"valuePrecision\":" + JSONconverter.getJSON(this.valuePrecision) + ","); |
result.append("\"valueRange\":" + JSONconverter.getJSON(this.valueRange) + ","); |
result.append("\"valueType\":" + JSONconverter.getJSON(this.valueType)); |
final int r = (Integer) JSONConverter.getParameterFromJSON(jsonBackgroundColor, "r", Integer.class); |
final int g = (Integer) JSONConverter.getParameterFromJSON(jsonBackgroundColor, "g", Integer.class); |
final int b = (Integer) JSONConverter.getParameterFromJSON(jsonBackgroundColor, "b", Integer.class); |
this.backgroundColor = new Color(r, g, b); |
} |
result.append("}"); |
final JSONObject jsonForeColor = (JSONObject) JSONConverter.getParameterFromJSON(json, "fore-color", JSONObject.class); |
if (jsonForeColor != null) { |
if (!jsonForeColor.containsKey("r") || !jsonForeColor.containsKey("g") || !jsonForeColor.containsKey("b")) { |
throw new IllegalArgumentException("value for 'for-color' is invalid, it must contains attribute r, g, b"); |
} |
final int r = (Integer) JSONConverter.getParameterFromJSON(jsonForeColor, "r", Integer.class); |
final int g = (Integer) JSONConverter.getParameterFromJSON(jsonForeColor, "g", Integer.class); |
final int b = (Integer) JSONConverter.getParameterFromJSON(jsonForeColor, "b", Integer.class); |
this.foreColor = new Color(r, g, b); |
} |
} |
return result.toString(); |
public static LightUIElement createUIElementFromJSON(final JSONObject jsonElement) { |
final Integer elementType = (Integer) JSONConverter.getParameterFromJSON(jsonElement, "type", Integer.class, null); |
if(elementType == null) { |
throw new IllegalArgumentException("LightUIElement must contains attribute 'type'"); |
} |
LightUIElement lightElement = null; |
if (elementType == LightUIElement.TYPE_PANEL || elementType == LightUIElement.TYPE_SCROLLABLE) { |
lightElement = new LightUIPanel(jsonElement); |
} else if (elementType == LightUIElement.TYPE_LIST) { |
lightElement = new LightUIList(jsonElement); |
} else if (elementType == LightUIElement.TYPE_TABLE) { |
lightElement = new LightUITable(jsonElement); |
} else if (elementType == LightUIElement.TYPE_LABEL) { |
lightElement = new LightUILabel(jsonElement); |
} else if (elementType == LightUIElement.TYPE_DROPDOWN_BUTTON) { |
lightElement = new LightUIDropDownButton(jsonElement); |
} else if (elementType == LightUIElement.TYPE_CHECKBOX) { |
lightElement = new LightUICheckBox(jsonElement); |
} else if (elementType == LightUIElement.TYPE_COMBOBOX) { |
lightElement = new LightUICombo(jsonElement); |
} else if (elementType == LightUIElement.TYPE_TABBED_UI) { |
lightElement = new LightUITabbed(jsonElement); |
} else { |
lightElement = new LightUIElement(jsonElement); |
} |
return lightElement; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIButtonLink.java |
---|
New file |
0,0 → 1,30 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import net.minidev.json.JSONObject; |
public class LightUIButtonLink extends LightUIElement { |
// Init from json constructor |
public LightUIButtonLink(final JSONObject json) { |
this.fromJSON(json); |
} |
public LightUIButtonLink(final String id, final String displayText, final String filePath) { |
this.setId(id); |
this.setLabel(displayText); |
this.setValue(filePath); |
this.setType(LightUIElement.TYPE_BUTTON_LINK); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIFrame.java |
---|
New file |
0,0 → 1,98 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONObject; |
public class LightUIFrame extends LightUIElement { |
LightUIPanel mainPanel; |
Boolean active = false; |
String title; |
// Init from json constructor |
public LightUIFrame(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUIFrame(final LightUIFrame frame) { |
super(frame); |
this.mainPanel = frame.mainPanel; |
this.active = frame.active; |
this.title = frame.title; |
} |
public LightUIFrame(final String id) { |
this.setId(id); |
this.setType(TYPE_FRAME); |
} |
public LightUIPanel getMainPanel() { |
return this.mainPanel; |
} |
public void setMainPanel(final LightUIPanel mainPanel) { |
this.mainPanel = mainPanel; |
} |
public String getTitle() { |
return this.title; |
} |
public void setTitle(final String title) { |
this.title = title; |
} |
public boolean isActive() { |
return this.active; |
} |
public void setActive(final boolean active) { |
this.active = active; |
} |
public LightUIElement getElementById(final String elementId) { |
return this.mainPanel.getElementById(elementId); |
} |
@Override |
public LightUIElement clone() { |
return new LightUIFrame(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
json.put("main-panel", this.mainPanel.toJSON()); |
if(this.active) { |
json.put("active", true); |
} |
if(this.title != null) { |
json.put("title", this.title); |
} |
return json; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
final JSONObject jsonMainPanel = (JSONObject) JSONConverter.getParameterFromJSON(json, "main-panel", JSONObject.class, null); |
if(jsonMainPanel != null) { |
this.mainPanel = new LightUIPanel(jsonMainPanel); |
} |
this.active = (Boolean)JSONConverter.getParameterFromJSON(json, "active", Boolean.class, false); |
this.title = (String)JSONConverter.getParameterFromJSON(json, "title", String.class); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/RowSpec.java |
---|
13,14 → 13,17 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONconverter; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import java.util.List; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class RowSpec implements Externalizable, JSONAble { |
private String tableId; |
private String[] columnIds; |
29,6 → 32,10 |
// Serialization |
} |
public RowSpec(final JSONObject json) { |
this.fromJSON(json); |
} |
public RowSpec(String tableId, String[] columnIds) { |
this.tableId = tableId; |
this.columnIds = columnIds; |
79,18 → 86,47 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
this.tableId = in.readUTF(); |
this.columnIds = (String[]) in.readObject(); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "RowSpec"); |
result.put("table-id", this.tableId); |
result.put("column-ids", this.columnIds); |
return result; |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public void fromJSON(final JSONObject json) { |
this.tableId = (String) JSONConverter.getParameterFromJSON(json, "table-id", String.class); |
result.append("\"tableId\":" + JSONconverter.getJSON(this.tableId) + ","); |
result.append("\"columnIds\":" + JSONconverter.getJSON(this.columnIds)); |
final JSONArray jsonColumnIds = (JSONArray) json.get("column-ids"); |
if (jsonColumnIds != null) { |
try { |
this.columnIds = new String[jsonColumnIds.size()]; |
this.columnIds = ((List<String>) (List<?>) jsonColumnIds).toArray(this.columnIds); |
} catch (final Exception ex) { |
throw new IllegalArgumentException("invalid value for 'possible-column-ids', List<String> expected"); |
} |
} |
result.append("}"); |
return result.toString(); |
if (!json.containsKey("table-id") || (json.get("table-id") instanceof String)) { |
throw new IllegalArgumentException("value for 'value-type' not found or invalid"); |
} |
if (!json.containsKey("column-ids") || (json.get("column-ids") instanceof JSONArray)) { |
throw new IllegalArgumentException("value for 'value-type' not found or invalid"); |
} |
this.tableId = (String) json.get("table-id"); |
final int columnCount = jsonColumnIds.size(); |
this.columnIds = new String[columnCount]; |
for (int i = 0; i < columnCount; i++) { |
final Object jsonColumnId = jsonColumnIds.get(i); |
if (!(jsonColumnId instanceof String)) { |
throw new IllegalArgumentException("one or more column Ids are invalid in 'column-ids'"); |
} |
this.columnIds[i] = (String) jsonColumnId; |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIPanel.java |
---|
New file |
0,0 → 1,244 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.io.PrintStream; |
import java.util.ArrayList; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUIPanel extends LightUIElement implements Transferable { |
public static final int STYLE_DIV = 0; |
public static final int STYLE_TABLE = 1; |
private static final long serialVersionUID = -3399395824294128572L; |
private String title; |
private int panelStyle = STYLE_DIV; |
private List<LightUILine> lines = new ArrayList<LightUILine>(); |
private final List<LightControler> controlers = new ArrayList<LightControler>(); |
public LightUIPanel() { |
// Serialization |
} |
public LightUIPanel(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUIPanel(final LightUIPanel panelElement) { |
super(panelElement); |
this.title = panelElement.title; |
this.panelStyle = panelElement.panelStyle; |
this.lines = panelElement.lines; |
this.controlers.addAll(panelElement.controlers); |
} |
public LightUIPanel(String id) { |
this.setId(id); |
this.setType(TYPE_PANEL); |
} |
public void addLine(LightUILine line) { |
this.lines.add(line); |
} |
public void insertLine(final LightUILine line, final int index) { |
final int linesSize = this.lines.size(); |
if (index < 0 || index > linesSize - 1) { |
throw new IllegalArgumentException("index is out of bounds, it must be in [0 - " + String.valueOf(linesSize) + "] but this was found (" + String.valueOf(index) + ")"); |
} |
LightUILine swap = this.lines.get(index); |
this.lines.set(index, line); |
for (int i = index + 1; i < linesSize; i++) { |
final LightUILine tmpLine = this.lines.get(i); |
this.lines.set(i, swap); |
swap = tmpLine; |
} |
this.lines.add(swap); |
} |
public LightUILine getLastLine() { |
if (this.lines.size() == 0) { |
final LightUILine l = new LightUILine(); |
this.lines.add(l); |
return l; |
} |
return this.lines.get(this.lines.size() - 1); |
} |
public void dump(PrintStream out) { |
final int size = this.lines.size(); |
out.println("------LightUIPanel-----"); |
out.println("ID : " + this.getId()); |
out.println("Title : " + this.title); |
out.println(getId() + " : " + this.title); |
out.println("Line count : " + size + " lines "); |
for (int i = 0; i < size; i++) { |
LightUILine line = this.lines.get(i); |
out.println("LightUIPanel line " + i); |
line.dump(out); |
out.println(); |
} |
out.println("------------------------"); |
} |
public int getPanelType() { |
return this.panelStyle; |
} |
public void setPanelType(final int panelStyle) { |
this.panelStyle = panelStyle; |
} |
public LightUILine getLine(int i) { |
return this.lines.get(i); |
} |
public int getSize() { |
return this.lines.size(); |
} |
public String getTitle() { |
return this.title; |
} |
public void setTitle(String title) { |
this.title = title; |
} |
public void addControler(LightControler controler) { |
this.controlers.add(controler); |
} |
public List<LightControler> getControlers() { |
return this.controlers; |
} |
public void dumpControllers(PrintStream out) { |
dumpControllers(out, 0); |
} |
public void dumpControllers(PrintStream out, int depth) { |
addSpacer(out, depth); |
out.println("Contollers for id:" + this.getId() + " title: " + this.title); |
for (LightControler controler : this.controlers) { |
addSpacer(out, depth); |
out.println(controler); |
} |
final int size = this.lines.size(); |
addSpacer(out, depth); |
out.println(getId() + " : " + this.title); |
addSpacer(out, depth); |
out.println("LightUIPanel " + size + " lines "); |
for (int i = 0; i < size; i++) { |
final LightUILine line = this.lines.get(i); |
for (int j = 0; j < line.getSize(); j++) { |
final LightUIElement e = line.getElement(j); |
if (e instanceof LightUIPanel) { |
((LightUIPanel) e).dumpControllers(out, depth + 1); |
} |
} |
} |
} |
private void addSpacer(PrintStream out, int depth) { |
for (int i = 0; i < depth; i++) { |
out.print(" "); |
} |
} |
public boolean replaceElement(final LightUIElement pelement) { |
if (this.lines != null) { |
final int lineSize = this.lines.size(); |
for (int i = 0; i < lineSize; i++) { |
if (this.lines.get(i).replaceElement(pelement)) { |
return true; |
} |
} |
} |
return false; |
} |
public LightUIElement getElementById(final String id) { |
if (this.lines != null) { |
final int lineSize = this.lines.size(); |
for (int i = 0; i < lineSize; i++) { |
final LightUIElement element = this.lines.get(i).getElementById(id); |
if (element != null) { |
return element; |
} |
} |
} |
return null; |
} |
@Override |
public LightUIElement clone() { |
return new LightUIPanel(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject result = super.toJSON(); |
if (this.title != null) { |
result.put("title", this.title); |
} |
if(!this.lines.isEmpty()) { |
result.put("lines", JSONConverter.getJSON(this.lines)); |
} |
if (!this.controlers.isEmpty()) { |
result.put("controlers", JSONConverter.getJSON(this.controlers)); |
} |
if(this.panelStyle != STYLE_DIV) { |
result.put("panel-style", this.panelStyle); |
} |
return result; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
this.title = (String) JSONConverter.getParameterFromJSON(json, "title", String.class, null); |
this.panelStyle = (Integer) JSONConverter.getParameterFromJSON(json, "panel-style", Integer.class, STYLE_DIV); |
final JSONArray jsonLines = (JSONArray) JSONConverter.getParameterFromJSON(json, "lines", JSONArray.class, null); |
this.lines.clear(); |
if (jsonLines != null) { |
final int linesSize = jsonLines.size(); |
for (int i = 0; i < linesSize; i++) { |
final JSONObject jsonLine = (JSONObject) JSONConverter.getObjectFromJSON(jsonLines.get(i), JSONObject.class); |
this.lines.add(new LightUILine(jsonLine)); |
} |
} |
final JSONArray jsonControlers = (JSONArray) JSONConverter.getParameterFromJSON(json, "controlers", JSONArray.class); |
this.controlers.clear(); |
if (jsonControlers != null) { |
final int controlersSize = jsonControlers.size(); |
for (int i = 0; i < controlersSize; i++) { |
final JSONObject jsonControler = (JSONObject) JSONConverter.getObjectFromJSON(jsonControlers.get(i), JSONObject.class); |
this.controlers.add(new LightControler((JSONObject) jsonControler)); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/RowSelectionSpec.java |
---|
17,49 → 17,74 |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import java.util.ArrayList; |
import java.util.List; |
public class RowSelectionSpec implements Externalizable { |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class RowSelectionSpec implements Externalizable, JSONAble { |
private String tableId; |
private long[] ids; |
private List<Long> ids; |
/** |
* Define selected ids of a table. ids are ids from selected lines |
* */ |
*/ |
public RowSelectionSpec() { |
// Serialization |
} |
public RowSelectionSpec(String tableId, long[] ids) { |
public RowSelectionSpec(final JSONObject json) { |
this.fromJSON(json); |
} |
public RowSelectionSpec(String tableId, List<Long> ids) { |
this.init(tableId, ids); |
} |
public RowSelectionSpec(String tableId) { |
this.init(tableId, null); |
} |
private void init(final String tableId, final List<Long> ids) { |
this.tableId = tableId; |
if(ids != null) { |
this.ids = ids; |
} else { |
this.ids = new ArrayList<Long>(); |
} |
} |
public long[] getIds() { |
return ids; |
public List<Long> getIds() { |
return this.ids; |
} |
public String getTableId() { |
return tableId; |
return this.tableId; |
} |
@Override |
public String toString() { |
String r = "RowSelectionSpec:" + tableId + " : "; |
for (int i = 0; i < ids.length; i++) { |
if (i < ids.length - 1) { |
r += ids[i] + ", "; |
final StringBuilder r = new StringBuilder("RowSelectionSpec: ").append(this.tableId).append(" : "); |
final int idsSize = this.ids.size(); |
for (int i = 0; i < idsSize; i++) { |
if (i < idsSize - 1) { |
r.append(this.ids.get(i)).append(", "); |
} else { |
r += ids[i]; |
r.append(this.ids.get(i)); |
} |
} |
return r; |
return r.toString(); |
} |
@Override |
public void writeExternal(ObjectOutput out) throws IOException { |
try { |
out.writeUTF(tableId); |
out.writeObject(ids); |
out.writeUTF(this.tableId); |
out.writeObject(this.ids); |
} catch (Exception e) { |
e.printStackTrace(); |
69,9 → 94,28 |
@Override |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
tableId = in.readUTF(); |
ids = (long[]) in.readObject(); |
this.tableId = in.readUTF(); |
this.ids = (List<Long>) in.readObject(); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = new JSONObject(); |
json.put("class", "RowSelectionSpec"); |
json.put("table-id", this.tableId); |
json.put("ids", this.ids); |
return json; |
} |
@Override |
public void fromJSON(JSONObject json) { |
this.tableId = (String) JSONConverter.getParameterFromJSON(json, "table-id", String.class); |
final JSONArray jsonIds = (JSONArray) JSONConverter.getParameterFromJSON(json, "ids", JSONArray.class); |
this.ids = new ArrayList<Long>(); |
for (final Object jsonId : jsonIds) { |
this.ids.add((Long) JSONConverter.getObjectFromJSON(jsonId, Long.class)); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIScrollablePanel.java |
---|
13,22 → 13,9 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.Transferable; |
public class LightUIScrollablePanel extends LightUIDescriptor implements Transferable { |
public LightUIScrollablePanel(String id, int counterId) { |
super(id, counterId); |
this.setType(LightUIElement.TYPE_SCROLLABLE); |
} |
public class LightUIScrollablePanel extends LightUIPanel { |
public LightUIScrollablePanel(String id) { |
super(id); |
this.setType(LightUIElement.TYPE_SCROLLABLE); |
} |
@Override |
public String toJSON() { |
return super.toJSON(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIComboElement.java |
---|
13,7 → 13,13 |
package org.openconcerto.ui.light; |
import net.minidev.json.JSONObject; |
public class LightUIComboElement extends LightUIElement { |
public LightUIComboElement(final JSONObject json) { |
this.fromJSON(json); |
} |
public LightUIComboElement(String id) { |
this.setId(id); |
this.setType(TYPE_COMBOBOX_ELEMENT); |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/SearchContent.java |
---|
New file |
0,0 → 1,81 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONObject; |
public class SearchContent implements Transferable { |
private String column; |
private String text; |
private String type; |
private String operator; |
public SearchContent(final JSONObject json) { |
this.fromJSON(json); |
} |
public String getColumn() { |
return this.column; |
} |
public String getText() { |
return this.text; |
} |
public String getType() { |
return this.type; |
} |
public String getOperator() { |
return this.operator; |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = new JSONObject(); |
json.put("column", this.column); |
json.put("text", this.text); |
json.put("type", this.type); |
json.put("operator", this.operator); |
return json; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
if (!json.containsKey("column") || !(json.get("column") instanceof String)) { |
throw new IllegalArgumentException("value for 'column' not found or invalid"); |
} |
if (!json.containsKey("text") || !(json.get("text") instanceof String)) { |
throw new IllegalArgumentException("value for 'text' not found or invalid"); |
} |
if (!json.containsKey("type") || !(json.get("type") instanceof String)) { |
throw new IllegalArgumentException("value for 'type' not found or invalid"); |
} |
if (json.containsKey("operator")) { |
if (json.get("operator") != null) { |
if (!(json.get("operator") instanceof String)) { |
throw new IllegalArgumentException("value for 'operator' not found or invalid"); |
} else { |
this.operator = (String) json.get("operator"); |
} |
} |
} |
this.column = (String) json.get("column"); |
this.text = (String) json.get("text"); |
this.type = (String) json.get("type"); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIList.java |
---|
New file |
0,0 → 1,87 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.util.ArrayList; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.ui.StringWithId; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUIList extends LightUIElement { |
private ArrayList<StringWithId> values = new ArrayList<StringWithId>(); |
// Init from json constructor |
public LightUIList(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUIList(final LightUIList listElement) { |
super(listElement); |
this.values = listElement.values; |
} |
public LightUIList(String id, final ArrayList<StringWithId> values) { |
this.setId(id); |
this.setType(TYPE_LIST); |
this.values = values; |
} |
public ArrayList<StringWithId> getValues(){ |
return (ArrayList<StringWithId>) this.values.clone(); |
} |
@Override |
public LightUIElement clone() { |
return new LightUIList(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
json.put("class", "LightUIList"); |
json.put("values", this.values); |
return json; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
final JSONArray jsonValues = (JSONArray) JSONConverter.getParameterFromJSON(json, "values", JSONArray.class); |
this.values.clear(); |
if (jsonValues != null) { |
for (final Object jsonValue : jsonValues) { |
if (!(jsonValue instanceof JSONObject)) { |
throw new IllegalArgumentException("values of list must be json of StringWithId"); |
} |
this.values.add(new StringWithId((JSONObject) jsonValue)); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIButtonWithContext.java |
---|
21,5 → 21,4 |
setGridWidth(1); |
setLabel(label); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIDate.java |
---|
New file |
0,0 → 1,22 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
public class LightUIDate extends LightUIElement { |
public LightUIDate(String id) { |
this.setId(id); |
this.setType(TYPE_DATE); |
this.setValueType(LightUIElement.VALUE_TYPE_DATE); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/Row.java |
---|
13,9 → 13,6 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONconverter; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
23,15 → 20,29 |
import java.util.ArrayList; |
import java.util.List; |
import org.openconcerto.utils.io.JSONAble; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.ui.StringWithId; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class Row implements Externalizable, JSONAble { |
private long id; |
private List<Object> values; |
private Boolean fillWidth = false; |
private Boolean toggleable = false; |
private Boolean visible = true; |
public Row() { |
// Serialization |
} |
public Row(final JSONObject json) { |
this.fromJSON(json); |
} |
public Row(long id, int valueCount) { |
this.id = id; |
if (valueCount > 0) |
54,14 → 65,8 |
return this.id; |
} |
@Override |
public String toString() { |
return "Row id: " + this.id + " values: " + this.values; |
} |
public void addValue(Object v) { |
this.values.add(v); |
} |
public void setValue(int index, Object v) { |
68,11 → 73,37 |
this.values.set(index, v); |
} |
public Boolean isFillWidth() { |
return this.fillWidth; |
} |
public void setFillWidth(final Boolean fillWidth) { |
this.fillWidth = fillWidth; |
} |
public Boolean isToggleable() { |
return this.toggleable; |
} |
public void setToggleable(final Boolean toggleable) { |
this.toggleable = toggleable; |
} |
public Boolean isVisible() { |
return this.visible; |
} |
public void setVisible(final Boolean visible) { |
this.visible = visible; |
} |
@Override |
public void writeExternal(ObjectOutput out) throws IOException { |
out.writeLong(this.id); |
out.writeObject(this.values); |
out.writeBoolean(this.fillWidth); |
out.writeBoolean(this.toggleable); |
out.writeBoolean(this.visible); |
} |
@Override |
79,17 → 110,79 |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
this.id = in.readLong(); |
this.values = (List<Object>) in.readObject(); |
this.fillWidth = in.readBoolean(); |
this.toggleable = in.readBoolean(); |
this.visible = in.readBoolean(); |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.append("\"id\":" + JSONconverter.getJSON(this.id) + ","); |
result.append("\"values\":" + JSONconverter.getJSON(this.values)); |
result.put("class", "Row"); |
result.put("id", this.id); |
if(!this.values.isEmpty()) { |
result.put("values", JSONConverter.getJSON(this.values)); |
} |
if(this.fillWidth) { |
result.put("fill-width", true); |
} |
if(this.toggleable) { |
result.put("toggleable", true); |
} |
if(!this.visible) { |
result.put("visible", false); |
} |
result.append("}"); |
return result.toString(); |
return result; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
this.id = (Long) JSONConverter.getParameterFromJSON(json, "id", Long.class); |
this.fillWidth = (Boolean) JSONConverter.getParameterFromJSON(json, "fill-width", Boolean.class, false); |
this.toggleable = (Boolean) JSONConverter.getParameterFromJSON(json, "toggleable", Boolean.class, false); |
this.visible = (Boolean) JSONConverter.getParameterFromJSON(json, "visible", Boolean.class, true); |
final JSONArray jsonValues = (JSONArray) JSONConverter.getParameterFromJSON(json, "values", JSONArray.class); |
if (jsonValues != null) { |
final int valuesSize = jsonValues.size(); |
this.values = new ArrayList<Object>(valuesSize); |
for (int i = 0; i < valuesSize; i++) { |
Object objValue = jsonValues.get(i); |
if (objValue instanceof JSONObject) { |
final JSONObject jsonValue = (JSONObject) objValue; |
final String valueClassName = (String) JSONConverter.getParameterFromJSON(jsonValue, "class", String.class); |
if (valueClassName == null){ |
throw new IllegalArgumentException("null value store in ghost"); |
} |
if(valueClassName.equals(StringWithId.class.getSimpleName())) { |
objValue = new StringWithId(jsonValue); |
} else if (valueClassName.equals(LightUIElement.class.getSimpleName())) { |
objValue = LightUIElement.createUIElementFromJSON(jsonValue); |
} else { |
throw new IllegalArgumentException("invalid value for 'values', StringWithId or LightUIElement expected"); |
} |
} else { |
if(objValue instanceof String) { |
objValue = JSONConverter.getObjectFromJSON(objValue, String.class); |
} else if(objValue instanceof Integer) { |
objValue = JSONConverter.getObjectFromJSON(objValue, Integer.class); |
} else if(objValue instanceof Long) { |
objValue = JSONConverter.getObjectFromJSON(objValue, Long.class); |
} else if(objValue instanceof Boolean) { |
objValue = JSONConverter.getObjectFromJSON(objValue, Boolean.class); |
} else if(objValue != null) { |
throw new IllegalArgumentException("unknow type: " + objValue.getClass().getName()); |
} |
} |
this.values.add(objValue); |
} |
} |
} |
@Override |
public String toString() { |
return "Row id: " + this.id + " values: " + this.values; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/ColumnSpec.java |
---|
13,10 → 13,17 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONconverter; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import org.openconcerto.utils.ui.StringWithId; |
import net.minidev.json.JSONObject; |
public class ColumnSpec implements Transferable { |
public class ColumnSpec implements Externalizable, Transferable { |
// Must stay immutable |
private String id; |
25,19 → 32,50 |
// Default value (to add a new line) |
private Object defaultValue; |
private int width; |
private int maxWidth; |
private int minWidth; |
private boolean editable; |
private LightUIElement editors; |
public ColumnSpec(String id, Class<?> valueClass, String columnName, Object defaultValue, int width, boolean editable, LightUIElement editors) { |
public ColumnSpec() { |
// Serialization |
} |
public ColumnSpec(final JSONObject json) { |
this.fromJSON(json); |
} |
public ColumnSpec(final String id, final Class<?> valueClass, final String columnName, final Object defaultValue, final int width, final boolean editable, final LightUIElement editors) { |
this.init(id, valueClass, columnName, defaultValue, editable, editors); |
this.width = width; |
final int minWidth = width - 200; |
final int maxWidth = width + 200; |
this.minWidth = (minWidth < 0) ? 0 : minWidth; |
this.maxWidth = maxWidth; |
} |
public ColumnSpec(final String id, final Class<?> valueClass, final String columnName, final Object defaultValue, final boolean editable, final LightUIElement editors) { |
this.init(id, valueClass, columnName, defaultValue, editable, editors); |
this.setDefaultPrefs(); |
} |
private void init(final String id, final Class<?> valueClass, final String columnName, final Object defaultValue, final boolean editable, final LightUIElement editors) { |
this.id = id; |
this.valueClass = valueClass; |
this.columnName = columnName; |
this.defaultValue = defaultValue; |
this.width = width; |
this.editable = editable; |
this.editors = editors; |
} |
public void setPrefs(final int width, final int maxWidth, final int minWidth) { |
this.width = width; |
this.maxWidth = maxWidth; |
this.minWidth = minWidth; |
} |
public String getId() { |
return this.id; |
} |
70,6 → 108,22 |
this.defaultValue = defaultValue; |
} |
public int getMaxWidth() { |
return this.maxWidth; |
} |
public void setMaxWidth(final int maxWidth) { |
this.maxWidth = maxWidth; |
} |
public int getMinWidth() { |
return this.minWidth; |
} |
public void setMinWidth(final int minWidth) { |
this.minWidth = minWidth; |
} |
public int getWidth() { |
return this.width; |
} |
94,20 → 148,88 |
this.editors = editors; |
} |
private void setDefaultPrefs() { |
// TODO : Faire varier en fonction du type; |
this.width = 200; |
this.maxWidth = 500; |
this.minWidth = 50; |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public void writeExternal(ObjectOutput out) throws IOException { |
out.writeUTF(this.id); |
out.writeUTF(this.columnName); |
out.writeInt(this.width); |
out.writeInt(this.maxWidth); |
out.writeInt(this.minWidth); |
out.writeObject(this.defaultValue); |
out.writeBoolean(this.editable); |
out.writeObject(this.editors); |
out.writeObject(this.valueClass); |
} |
result.append("\"id\":" + JSONconverter.getJSON(this.id) + ","); |
result.append("\"columnName\":" + JSONconverter.getJSON(this.columnName) + ","); |
result.append("\"width\":" + JSONconverter.getJSON(this.width) + ","); |
result.append("\"defaultValue\":" + JSONconverter.getJSON(this.defaultValue) + ","); |
result.append("\"editable\":" + JSONconverter.getJSON(this.editable) + ","); |
result.append("\"editors\":" + JSONconverter.getJSON(this.editors) + ","); |
result.append("\"valueClass\":" + JSONconverter.getJSON(this.valueClass)); |
@Override |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
this.id = in.readUTF(); |
this.columnName = in.readUTF(); |
this.width = in.readInt(); |
this.maxWidth = in.readInt(); |
this.minWidth = in.readInt(); |
this.defaultValue = in.readObject(); |
this.editable = in.readBoolean(); |
this.editors = (LightUIElement) in.readObject(); |
this.valueClass = (Class<?>) in.readObject(); |
} |
result.append("}"); |
return result.toString(); |
@Override |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "ColumnSpec"); |
result.put("id", this.id); |
result.put("column-name", this.columnName); |
result.put("width", this.width); |
result.put("max-width", this.maxWidth); |
result.put("min-width", this.minWidth); |
if(this.defaultValue != null) { |
result.put("default-value", JSONConverter.getJSON(this.defaultValue)); |
} |
if (this.editable) { |
result.put("editable", true); |
} |
if(this.editors != null) { |
result.put("editors", JSONConverter.getJSON(this.editors)); |
} |
result.put("value-class", JSONConverter.getJSON(this.valueClass)); |
return result; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
this.id = (String) JSONConverter.getParameterFromJSON(json, "id", String.class); |
this.columnName = (String) JSONConverter.getParameterFromJSON(json, "column-name", String.class); |
this.width = (Integer) JSONConverter.getParameterFromJSON(json, "width", Integer.class); |
this.maxWidth = (Integer) JSONConverter.getParameterFromJSON(json, "max-width", Integer.class); |
this.minWidth = (Integer) JSONConverter.getParameterFromJSON(json, "min-width", Integer.class); |
this.editable = (Boolean) JSONConverter.getParameterFromJSON(json, "editable", Boolean.class, Boolean.FALSE); |
final JSONObject jsonDefaultValue = (JSONObject) JSONConverter.getParameterFromJSON(json, "default-value", JSONObject.class); |
if (jsonDefaultValue != null) { |
final String defaultValueClassName = (String) JSONConverter.getParameterFromJSON(jsonDefaultValue, "class", String.class); |
if (defaultValueClassName.equals(StringWithId.class.getSimpleName())) { |
this.defaultValue = new StringWithId(jsonDefaultValue); |
} |
} |
final JSONObject jsonEditors = (JSONObject) JSONConverter.getParameterFromJSON(json, "editors", JSONObject.class); |
if (jsonEditors != null) { |
this.editors = LightUIElement.createUIElementFromJSON(jsonEditors); |
} |
final String sValueClass = (String) JSONConverter.getParameterFromJSON(json, "value-class", String.class); |
if (sValueClass != null) { |
try { |
this.valueClass = Class.forName(sValueClass); |
} catch (Exception ex) { |
throw new IllegalArgumentException("invalid value for 'value-class', " + ex.getMessage()); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIButtonWithSelectionContext.java |
---|
New file |
0,0 → 1,43 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONObject; |
public class LightUIButtonWithSelectionContext extends LightUIElement { |
String tableId; |
public LightUIButtonWithSelectionContext(final String id, final String label, final String tableId) { |
this.setType(LightUIElement.TYPE_BUTTON_WITH_SELECTION_CONTEXT); |
this.setId(id); |
this.setGridWidth(1); |
this.setLabel(label); |
this.tableId = tableId; |
} |
@Override public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
this.tableId = (String) JSONConverter.getParameterFromJSON(json, "table-id", String.class); |
} |
@Override public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
json.put("table-id", this.tableId); |
return json; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUITable.java |
---|
New file |
0,0 → 1,114 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import net.minidev.json.JSONObject; |
public class LightUITable extends LightUIElement { |
private Boolean verticallyScrollable = false; |
private TableSpec tableSpec = null; |
// Init from json constructor |
public LightUITable(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUITable(final LightUITable tableElement) { |
super(tableElement); |
this.verticallyScrollable = tableElement.verticallyScrollable; |
this.tableSpec = tableElement.tableSpec; |
} |
public LightUITable(final String id) { |
this.setId(id); |
this.setType(LightUIElement.TYPE_TABLE); |
this.setFillWidth(true); |
} |
public TableSpec getTableSpec() { |
return this.tableSpec; |
} |
public void setTableSpec(final TableSpec tableSpec) { |
this.tableSpec = tableSpec; |
} |
public Boolean isVerticallyScrollable() { |
return this.verticallyScrollable; |
} |
public void setVerticallyScrollable(final Boolean verticallyScrollable) { |
this.verticallyScrollable = verticallyScrollable; |
} |
public LightUIElement getElementById(final String elementId) { |
if(this.tableSpec != null) { |
final TableContent content = this.tableSpec.getContent(); |
if(content != null) { |
final List<Row> listRows = content.getRows(); |
if(listRows != null && listRows.size() > 0) { |
for(final Row row : listRows) { |
final List<Object> rowValues = row.getValues(); |
for(final Object value : rowValues) { |
if(value instanceof LightUIElement) { |
final LightUIElement element = (LightUIElement) value; |
if(element.getId().equals(elementId)) { |
return element; |
} |
} |
} |
} |
} else { |
System.out.println("LightUITable.getElementById() - No rows for table: " + this.getId()); |
} |
} else { |
System.out.println("LightUITable.getElementById() - Null TableContent for table: " + this.getId()); |
} |
} else { |
System.out.println("LightUITable.getElementById() - Null TableSpec for table: " + this.getId()); |
} |
return null; |
} |
@Override |
public LightUIElement clone() { |
return new LightUITable(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
if(this.verticallyScrollable) { |
json.put("vertically-scrollable", true); |
} |
if(this.tableSpec != null) { |
json.put("table-spec", this.tableSpec.toJSON()); |
} |
return json; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
this.verticallyScrollable = (Boolean) JSONConverter.getParameterFromJSON(json, "vertically-scrollable", Boolean.class, false); |
final JSONObject jsonRawContent = (JSONObject) JSONConverter.getParameterFromJSON(json, "table-spec", JSONObject.class); |
if (jsonRawContent != null) { |
this.tableSpec = new TableSpec(jsonRawContent); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUILine.java |
---|
13,13 → 13,15 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONconverter; |
import org.openconcerto.utils.io.Transferable; |
import java.io.PrintStream; |
import java.util.ArrayList; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUILine implements Transferable { |
public static final int ALIGN_GRID = 0; |
27,87 → 29,235 |
public static final int ALIGN_RIGHT = 2; |
private static final long serialVersionUID = 4132718509484530435L; |
private int weightY; |
private boolean fillHeight; |
private int gridAlignment = ALIGN_GRID; |
private boolean elementMargin = false; |
private boolean fillHeight = false; |
private boolean footer = false; |
private List<LightUIElement> elements = new ArrayList<LightUIElement>(); |
private int gridAlignment = ALIGN_GRID; |
private int marginBottom = 0; |
private int marginLeft = 0; |
private int marginRight = 0; |
private int marginTop = 0; |
private int weightY = 0; |
public int getSize() { |
return this.elements.size(); |
private final List<LightUIElement> elements = new ArrayList<LightUIElement>(); |
public LightUILine() { |
} |
public void add(LightUIElement element) { |
this.elements.add(element); |
public LightUILine(final JSONObject json) { |
this.fromJSON(json); |
} |
public void setFooter(boolean footer) { |
public void setElementMargin(final boolean elementMargin) { |
this.elementMargin = elementMargin; |
} |
public boolean isElementMargin() { |
return this.elementMargin; |
} |
public void setFillHeight(final boolean fillHeight) { |
this.fillHeight = fillHeight; |
} |
public boolean isFillHeight() { |
return this.fillHeight; |
} |
public void setFooter(final boolean footer) { |
this.footer = footer; |
} |
public boolean getFooter() { |
public boolean isFooter() { |
return this.footer; |
} |
public void dump(PrintStream out) { |
int size = this.elements.size(); |
out.println("LightUILine " + size + " elements, weightY: " + this.weightY + " fillHeight: " + this.fillHeight); |
for (int i = 0; i < size; i++) { |
LightUIElement element = this.elements.get(i); |
out.print("Element " + i + " : "); |
element.dump(out); |
public int getGridAlignment() { |
return this.gridAlignment; |
} |
public void setGridAlignment(final int gridAlignment) { |
this.gridAlignment = gridAlignment; |
} |
public int getWidth() { |
int w = 0; |
final int size = this.elements.size(); |
for (int i = 0; i < size; i++) { |
w += this.elements.get(i).getGridWidth(); |
public int getMarginBottom() { |
return this.marginBottom; |
} |
return w; |
public void setMarginBottom(final int marginBottom) { |
this.marginBottom = marginBottom; |
} |
public int getMarginLeft() { |
return this.marginLeft; |
} |
public void setMarginLeft(final int marginLeft) { |
this.marginLeft = marginLeft; |
} |
public int getMarginRight() { |
return this.marginRight; |
} |
public void setMarginRight(final int marginRight) { |
this.marginRight = marginRight; |
} |
public int getMarginTop() { |
return this.marginTop; |
} |
public void setMarginTop(final int marginTop) { |
this.marginTop = marginTop; |
} |
public int getWeightY() { |
return this.weightY; |
} |
public void setWeightY(int weightY) { |
public void setWeightY(final int weightY) { |
this.weightY = weightY; |
} |
public boolean isFillHeight() { |
return this.fillHeight; |
public int getSize() { |
return this.elements.size(); |
} |
public void setFillHeight(boolean fillHeight) { |
this.fillHeight = fillHeight; |
public void add(final LightUIElement element) { |
this.elements.add(element); |
} |
public LightUIElement getElement(int i) { |
public LightUIElement getElement(final int i) { |
return this.elements.get(i); |
} |
public int getGridAlignment() { |
return this.gridAlignment; |
public int getWidth() { |
int w = 0; |
final int size = this.elements.size(); |
for (int i = 0; i < size; i++) { |
w += this.elements.get(i).getGridWidth(); |
} |
return w; |
} |
public void setGridAlignment(int gridAlignment) { |
this.gridAlignment = gridAlignment; |
public boolean replaceElement(final LightUIElement pElement) { |
final int cellSize = this.elements.size(); |
for (int i = 0; i < cellSize; i++) { |
final LightUIElement element = this.elements.get(i); |
if (element.getId() != null && element.getId().equals(pElement.getId())) { |
this.elements.set(i, pElement); |
return true; |
} |
if (element.getType() == LightUIElement.TYPE_PANEL) { |
if (((LightUIPanel) element).replaceElement(pElement)) { |
return true; |
} |
} |
} |
return false; |
} |
public LightUIElement getElementById(final String id) { |
final int cellSize = this.elements.size(); |
LightUIElement result = null; |
for (int i = 0; i < cellSize; i++) { |
final LightUIElement element = this.elements.get(i); |
if (element.getId() != null && element.getId().equals(id)) { |
return element; |
} |
if (element.getType() == LightUIElement.TYPE_PANEL) { |
result = ((LightUIPanel) element).getElementById(id); |
if (result != null) { |
return result; |
} |
} else if (element.getType() == LightUIElement.TYPE_TABLE) { |
result = ((LightUITable) element).getElementById(id); |
if (result != null) { |
return result; |
} |
} else if (element.getType() == LightUIElement.TYPE_TABBED_UI) { |
result = ((LightUITabbed) element).getElementById(id); |
if (result != null) { |
return result; |
} |
} |
} |
return null; |
} |
public void dump(final PrintStream out) { |
int size = this.elements.size(); |
out.println("LightUILine " + size + " elements, weightY: " + this.weightY + " fillHeight: " + this.fillHeight); |
for (int i = 0; i < size; i++) { |
LightUIElement element = this.elements.get(i); |
out.print("Element " + i + " : "); |
element.dump(out); |
} |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "LightUILine"); |
if (this.elementMargin) { |
result.put("element-margin", this.elementMargin); |
} |
if (this.fillHeight) { |
result.put("fill-height", true); |
} |
if (this.footer) { |
result.put("footer", true); |
} |
if (this.weightY != 0) { |
result.put("weight-y", this.weightY); |
} |
if (this.marginBottom != 0) { |
result.put("margin-bottom", this.marginBottom); |
} |
if (this.marginLeft != 0) { |
result.put("margin-left", this.marginLeft); |
} |
if (this.marginRight != 0) { |
result.put("margin-right", this.marginRight); |
} |
if (this.marginTop != 0) { |
result.put("margin-top", this.marginTop); |
} |
if (this.gridAlignment != ALIGN_GRID) { |
result.put("grid-alignment", this.gridAlignment); |
} |
if (!elements.isEmpty()) { |
result.put("elements", JSONConverter.getJSON(this.elements)); |
} |
return result; |
} |
result.append("\"weightY\":" + JSONconverter.getJSON(this.weightY) + ","); |
result.append("\"fillHeight\":" + JSONconverter.getJSON(this.fillHeight) + ","); |
result.append("\"gridAlignment\":" + JSONconverter.getJSON(this.gridAlignment) + ","); |
result.append("\"footer\":" + JSONconverter.getJSON(this.footer) + ","); |
result.append("\"elements\":" + JSONconverter.getJSON(this.elements)); |
@Override |
public void fromJSON(final JSONObject json) { |
result.append("}"); |
return result.toString(); |
this.elementMargin = (Boolean) JSONConverter.getParameterFromJSON(json, "element-margin", Boolean.class, Boolean.FALSE); |
this.fillHeight = (Boolean) JSONConverter.getParameterFromJSON(json, "fill-height", Boolean.class, Boolean.FALSE); |
this.footer = (Boolean) JSONConverter.getParameterFromJSON(json, "footer", Boolean.class, Boolean.FALSE); |
this.gridAlignment = (Integer) JSONConverter.getParameterFromJSON(json, "grid-alignment", Integer.class, ALIGN_GRID); |
this.marginBottom = (Integer) JSONConverter.getParameterFromJSON(json, "margin-bottom", Integer.class, 0); |
this.marginLeft = (Integer) JSONConverter.getParameterFromJSON(json, "margin-left", Integer.class, 0); |
this.marginRight = (Integer) JSONConverter.getParameterFromJSON(json, "margin-right", Integer.class, 0); |
this.marginTop = (Integer) JSONConverter.getParameterFromJSON(json, "margin-top", Integer.class, 0); |
this.weightY = (Integer) JSONConverter.getParameterFromJSON(json, "weight-y", Integer.class, 0); |
final JSONArray jsonElements = (JSONArray) JSONConverter.getParameterFromJSON(json, "elements", JSONArray.class); |
if (jsonElements != null) { |
for (final Object o : jsonElements) { |
final JSONObject jsonElement = (JSONObject) JSONConverter.getObjectFromJSON(o, JSONObject.class); |
if (jsonElement == null) { |
throw new IllegalArgumentException("null element in json parameter"); |
} |
final LightUIElement lightElement = LightUIElement.createUIElementFromJSON(jsonElement); |
this.elements.add(lightElement); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/SearchSpec.java |
---|
New file |
0,0 → 1,63 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.util.ArrayList; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class SearchSpec implements Transferable { |
private String tableId; |
private List<SearchContent> content; |
public SearchSpec(final String tableId) { |
this.tableId = tableId; |
} |
public SearchSpec(final JSONObject json) { |
this.fromJSON(json); |
} |
public String getTableId() { |
return this.tableId; |
} |
public List<SearchContent> getContent() { |
return this.content; |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = new JSONObject(); |
json.put("table-id", this.tableId); |
json.put("content", JSONConverter.getJSON(this.content)); |
return json; |
} |
@Override |
public void fromJSON(JSONObject json) { |
this.tableId = (String) JSONConverter.getParameterFromJSON(json, "table-id", String.class); |
final JSONArray jsonContent = (JSONArray) JSONConverter.getParameterFromJSON(json, "content", JSONArray.class); |
if (jsonContent != null) { |
this.content = new ArrayList<SearchContent>(); |
for (final Object o : jsonContent) { |
this.content.add(new SearchContent((JSONObject) JSONConverter.getObjectFromJSON(o, JSONObject.class))); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUIButtonUnmanaged.java |
---|
14,7 → 14,6 |
package org.openconcerto.ui.light; |
public class LightUIButtonUnmanaged extends LightUIElement { |
public LightUIButtonUnmanaged(String id, String label) { |
setType(LightUIElement.TYPE_BUTTON_UNMANAGED); |
setId(id); |
21,5 → 20,4 |
setGridWidth(1); |
setLabel(label); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/TableContent.java |
---|
13,51 → 13,83 |
package org.openconcerto.ui.light; |
import org.openconcerto.utils.io.JSONconverter; |
import org.openconcerto.utils.io.Transferable; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class TableContent implements Transferable { |
private static final long serialVersionUID = 3648381615123520834L; |
private String tableId; |
private List<Row> rows; |
private RowSpec spec; |
public TableContent() { |
// Serialization |
} |
public List<Row> getRows() { |
return this.rows; |
public TableContent(final String tableId) { |
this.init(tableId, null); |
} |
public void setRows(List<Row> rows) { |
public TableContent(final String tableId, final List<Row> rows) { |
this.init(tableId, rows); |
} |
public TableContent(final JSONObject json) { |
this.fromJSON(json); |
} |
private void init(final String tableId, final List<Row> rows) { |
this.tableId = tableId; |
if (rows != null) { |
this.rows = rows; |
} else { |
this.rows = new ArrayList<Row>(); |
} |
} |
public RowSpec getSpec() { |
return this.spec; |
public String getTableId() { |
return this.tableId; |
} |
public void setSpec(RowSpec spec) { |
this.spec = spec; |
public void setTableId(final String tableId) { |
this.tableId = tableId; |
} |
public List<Row> getRows() { |
return this.rows; |
} |
public void setRows(List<Row> rows) { |
this.rows = rows; |
} |
@Override |
public String toString() { |
return "TableContent of " + this.spec.getTableId() + " columns: " + new ArrayList<String>(Arrays.asList(this.spec.getIds())) + " : " + getRows().size() + " lines"; |
return "TableContent of " + this.tableId + " lines count : " + getRows().size(); |
} |
@Override |
public String toJSON() { |
final StringBuilder result = new StringBuilder("{"); |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "TableContent"); |
result.put("table-id", this.tableId); |
result.put("rows", JSONConverter.getJSON(this.rows)); |
return result; |
} |
result.append("\"rows\":" + JSONconverter.getJSON(this.rows) + ","); |
result.append("\"spec\":" + JSONconverter.getJSON(this.spec)); |
result.append("}"); |
return result.toString(); |
@Override |
public void fromJSON(final JSONObject json) { |
this.tableId = (String) JSONConverter.getParameterFromJSON(json, "table-id", String.class); |
final JSONArray jsonRows = (JSONArray) JSONConverter.getParameterFromJSON(json, "rows", JSONArray.class); |
if (jsonRows != null) { |
this.rows = new ArrayList<Row>(); |
for (final Object o : jsonRows) { |
this.rows.add(new Row((JSONObject) JSONConverter.getObjectFromJSON(o, JSONObject.class))); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUICombo.java |
---|
New file |
0,0 → 1,83 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui.light; |
import java.util.ArrayList; |
import java.util.List; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.ui.StringWithId; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUICombo extends LightUIElement { |
List<StringWithId> values = new ArrayList<StringWithId>(); |
// Init from json constructor |
public LightUICombo(final JSONObject json) { |
this.fromJSON(json); |
} |
// Clone constructor |
public LightUICombo(final LightUICombo combo) { |
super(combo); |
this.values = combo.values; |
} |
public LightUICombo(String id) { |
this.setId(id); |
this.setType(TYPE_COMBOBOX); |
} |
public void addValue(final StringWithId values) { |
this.values.add(values); |
} |
public void addValues(final List<StringWithId> values) { |
this.values.addAll(values); |
} |
@Override |
public LightUIElement clone() { |
return new LightUICombo(this); |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject json = super.toJSON(); |
final JSONArray jsonValues = new JSONArray(); |
for (final StringWithId value : this.values) { |
jsonValues.add(value.toJSON()); |
} |
json.put("values", jsonValues); |
return json; |
} |
@Override |
public void fromJSON(final JSONObject json) { |
super.fromJSON(json); |
final JSONArray jsonValues = (JSONArray) JSONConverter.getParameterFromJSON(json, "values", JSONArray.class); |
this.values.clear(); |
if (jsonValues != null) { |
for (final Object jsonValue : jsonValues) { |
if (!(jsonValue instanceof JSONObject)) { |
throw new IllegalArgumentException("value for 'values' is invalid"); |
} |
this.values.add(new StringWithId((JSONObject) jsonValue)); |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/group/LayoutHints.java |
---|
20,6 → 20,7 |
private final boolean visible; |
private final boolean largeWidth; |
private final boolean largeHeight; |
private boolean foldable = false; |
private final boolean showLabel; |
// true if the layouted element (group or label+editor) is visually separated from the others |
71,6 → 72,7 |
this.fillHeight = localHint.fillHeight; |
this.split = localHint.split; |
this.visible = localHint.visible; |
this.foldable = localHint.foldable; |
} |
public final LayoutHintsBuilder getBuilder() { |
78,6 → 80,14 |
.setVisible(this.visible); |
} |
public boolean isFoldable() { |
return this.foldable; |
} |
public void setFoldable(final boolean foldable) { |
this.foldable = foldable; |
} |
public boolean largeWidth() { |
return this.largeWidth; |
} |
/trunk/OpenConcerto/src/org/openconcerto/ui/group/Group.java |
---|
115,6 → 115,22 |
return getDescFromID(id) != null; |
} |
public final Collection<Group> getDescendantGroups() { |
final List<Group> res = new ArrayList<Group>(); |
this.getDescendantGroups(res); |
return res; |
} |
protected void getDescendantGroups(final Collection<Group> res) { |
for (final Tuple2<Item, Integer> t : this.list) { |
if (t.get0() instanceof Group) { |
Group g = (Group) t.get0(); |
res.add(g); |
g.getDescendantGroups(res); |
} |
} |
} |
@Override |
public final Collection<Item> getDescendantItems() { |
final List<Item> res = new ArrayList<Item>(); |
/trunk/OpenConcerto/src/org/openconcerto/ui/TimestampEditorPanel.java |
---|
23,6 → 23,10 |
import java.awt.Insets; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.awt.event.FocusEvent; |
import java.awt.event.FocusListener; |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyListener; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.sql.Timestamp; |
44,7 → 48,8 |
public class TimestampEditorPanel extends JPanel implements ActionListener { |
private TimeTextField time; |
private TimeSpinField timeSpinner; |
private TimeTextField timeText; |
private JPanel panelHour; |
private DatePickerPanel pickerPanel; |
private List<ActionListener> listeners = new Vector<ActionListener>(); |
52,6 → 57,10 |
private Calendar c = Calendar.getInstance(); |
public TimestampEditorPanel() { |
this(false); |
} |
public TimestampEditorPanel(boolean useSpinner) { |
c.set(Calendar.SECOND, 0); |
c.set(Calendar.MILLISECOND, 0); |
setLayout(new GridBagLayout()); |
72,9 → 81,16 |
labelHour.setFont(labelHour.getFont().deriveFont(Font.BOLD)); |
this.panelHour.add(labelHour, c); |
c.gridx++; |
this.time = new TimeTextField(); |
this.time.setMinimumSize(new Dimension(time.getPreferredSize())); |
this.panelHour.add(this.time, c); |
if (useSpinner) { |
this.timeSpinner = new TimeSpinField(); |
this.timeSpinner.setMinimumSize(new Dimension(timeSpinner.getPreferredSize())); |
this.panelHour.add(this.timeSpinner, c); |
} else { |
this.timeText = new TimeTextField(); |
this.timeText.grabFocus(); |
this.timeText.setFocusTraversalKeysEnabled(false); |
this.panelHour.add(this.timeText, c); |
} |
c.gridx++; |
final JButton buttonClose = new JButton(new ImageIcon(TimestampEditorPanel.class.getResource("close_popup_gray.png"))); |
92,6 → 108,7 |
buttonClose.setFocusPainted(false); |
buttonClose.setContentAreaFilled(false); |
buttonClose.setMargin(new Insets(1, 1, 1, 1)); |
buttonClose.setFocusable(false); |
c.gridx = 0; |
this.panelHour.setOpaque(false); |
this.add(this.panelHour, c); |
115,7 → 132,7 |
c.weighty = 1; |
c.insets = new Insets(0, 0, 0, 0); |
this.pickerPanel = new DatePickerPanel(); |
this.pickerPanel.setFocusable(false); |
add(this.pickerPanel, c); |
c.gridy++; |
129,7 → 146,8 |
fireTimeChangedPerformed(); |
} |
}); |
this.time.addPropertyChangeListener("value", new PropertyChangeListener() { |
if (useSpinner) { |
this.timeSpinner.addPropertyChangeListener("value", new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
137,9 → 155,55 |
fireTimeChangedPerformed(); |
} |
}); |
} else { |
this.timeText.addPropertyChangeListener("value", new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
stateChanged(); |
fireTimeChangedPerformed(); |
} |
}); |
this.timeText.addKeyListener(new KeyListener() { |
@Override |
public void keyTyped(KeyEvent e) { |
} |
@Override |
public void keyReleased(KeyEvent e) { |
if (e.getKeyCode() == KeyEvent.VK_TAB || e.getKeyCode() == KeyEvent.VK_ENTER) { |
if (aCellEditor != null) { |
aCellEditor.hidePopup(); |
} |
} |
} |
@Override |
public void keyPressed(KeyEvent e) { |
} |
}); |
this.timeText.addFocusListener(new FocusListener() { |
@Override |
public void focusLost(FocusEvent e) { |
if (aCellEditor != null) { |
aCellEditor.hidePopup(); |
} |
} |
@Override |
public void focusGained(FocusEvent e) { |
} |
}); |
} |
} |
public void setTime(Date time) { |
c.setTimeInMillis(time.getTime()); |
// update UI |
146,8 → 210,12 |
final int hour = c.get(Calendar.HOUR_OF_DAY); |
final int minute = c.get(Calendar.MINUTE); |
this.pickerPanel.setSelectedDate(c); |
this.time.setTime(hour, minute); |
if (timeSpinner != null) { |
this.timeSpinner.setTime(hour, minute); |
} else { |
timeText.setTime(hour, minute); |
} |
} |
public Timestamp getTime() { |
return new Timestamp(c.getTimeInMillis()); |
160,10 → 228,14 |
public void stateChanged() { |
c.setTime(pickerPanel.getSelectedDate()); |
c.set(Calendar.HOUR_OF_DAY, time.getHours()); |
c.set(Calendar.MINUTE, time.getMinutes()); |
if (timeSpinner != null) { |
c.set(Calendar.HOUR_OF_DAY, timeSpinner.getHours()); |
c.set(Calendar.MINUTE, timeSpinner.getMinutes()); |
} else { |
c.set(Calendar.HOUR_OF_DAY, timeText.getHours()); |
c.set(Calendar.MINUTE, timeText.getMinutes()); |
} |
} |
private void fireTimeChangedPerformed() { |
final int size = this.listeners.size(); |
190,6 → 262,12 |
this.panelHour.setVisible(b); |
} |
@Override |
public void requestFocus() { |
timeText.requestFocus(); |
timeText.setCaretPosition(0); |
} |
public static void main(String[] args) throws Exception { |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
JFrame f = new JFrame(); |
/trunk/OpenConcerto/src/org/openconcerto/ui/TimeSpinField.java |
---|
New file |
0,0 → 1,106 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.ui; |
import java.awt.FlowLayout; |
import java.util.Calendar; |
import javax.swing.JFrame; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JSpinner; |
import javax.swing.SpinnerNumberModel; |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeListener; |
public class TimeSpinField extends JPanel { |
private JSpinner spinHour, spinMinute; |
public TimeSpinField() { |
init(0, 0); |
} |
public TimeSpinField(boolean fillWithCurrentTime) { |
if (fillWithCurrentTime) { |
Calendar c = Calendar.getInstance(); |
init(c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); |
} else { |
init(0, 0); |
} |
} |
public TimeSpinField(int hour, int minute) { |
init(hour, minute); |
} |
private void init(int hour, int minute) { |
this.setLayout(new FlowLayout()); |
this.setOpaque(false); |
spinHour = new JSpinner(new SpinnerNumberModel(hour, 0, 23, 1)); |
spinMinute = new JSpinner(new SpinnerNumberModel(minute, 0, 59, 1)); |
setTime(hour, minute); |
spinHour.addChangeListener(new ChangeListener() { |
@Override |
public void stateChanged(ChangeEvent e) { |
firePropertyChange("value", null, null); |
} |
}); |
spinMinute.addChangeListener(new ChangeListener() { |
@Override |
public void stateChanged(ChangeEvent e) { |
firePropertyChange("value", null, null); |
} |
}); |
this.add(spinHour); |
this.add(new JLabel(" : ")); |
this.add(spinMinute); |
} |
public void setTime(int hour, int minute) { |
if (hour < 0 || hour > 23) { |
throw new IllegalArgumentException("Hour must be betwen 0 and 23 but is " + hour); |
} |
if (minute < 0 || minute > 59) { |
throw new IllegalArgumentException("Minute must be betwen 0 and 59 but is " + minute); |
} |
this.spinHour.setValue(hour); |
this.spinMinute.setValue(minute); |
} |
public int getHours() { |
return ((Number) this.spinHour.getValue()).intValue(); |
} |
public int getMinutes() { |
return ((Number) this.spinMinute.getValue()).intValue(); |
} |
public static void main(String[] args) { |
final JFrame f = new JFrame(); |
final TimeSpinField time = new TimeSpinField(true); |
time.setTime(10, 59); |
f.setContentPane(time); |
f.pack(); |
f.setLocationRelativeTo(null); |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
f.setVisible(true); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/SQLTableElement.java |
---|
340,6 → 340,11 |
Object result; |
if (this.getModifier() != null) { |
result = this.getModifier().getValueFrom(row, this); |
// Test pour corriger les incohérences de BD (ex: PRIX_METRIQUE_VT_1 = 30 et PV_HT=0) |
if (this.getElementClass() != null && Number.class.isAssignableFrom(this.getElementClass()) && !CompareUtils.equals(result, row.getObject(this.rowField))) { |
row.put(this.rowField, result); |
fireModification(row); |
} |
} else { |
result = row.getObject(this.getRowField()); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/SQLTableModelColumn.java |
---|
82,6 → 82,8 |
return res; |
} |
// not IFieldPath so that we can rely on FieldPath.equals() (to use |
// Set<FieldPath>.contains()) |
/** |
* The paths needed to {@link #show(SQLRowAccessor)}. |
* |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/TableAction.java |
---|
New file |
0,0 → 1,55 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.sql.view.list; |
import java.util.ArrayList; |
import java.util.List; |
public class TableAction { |
private String id = null; |
private List<RowAction> actions = new ArrayList<RowAction>(); |
public TableAction(final RowAction action) { |
this.id = action.getID(); |
this.actions.add(action); |
} |
public TableAction(final String id, final List<RowAction> actions) { |
this.id = id; |
this.actions.addAll(actions); |
} |
public String getId() { |
return this.id; |
} |
public RowAction getAction(final int index) { |
return this.actions.get(index); |
} |
public RowAction getAction(final String id) { |
final int size = this.actions.size(); |
for(int i = 0; i < size; i++) { |
final RowAction action = this.actions.get(i); |
if(action.getID().equals(id)) { |
return action; |
} |
} |
return null; |
} |
public int getActionsCount() { |
return this.actions.size(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/KeyTableCellRenderer.java |
---|
74,13 → 74,21 |
newValue = ((SQLRowValues) value).getString("CODE"); |
} else { |
int id = Integer.parseInt(value.toString()); |
if (id > 1) { |
final int id = Integer.parseInt(value.toString()); |
Number undefID = this.el.getTable().getUndefinedIDNumber(); |
if (undefID == null || id > undefID.intValue()) { |
IComboSelectionItem item = cacheMap.get(this.el).get(id); |
if (item != null) { |
newValue = item.getLabel(); |
} |
// else { |
// TODO créer une liste des ids à reloader |
// this.toSelect = value; |
// setText("Chargement ..."); |
// loadCacheAsynchronous(); |
// } |
} else { |
newValue = SQLTableElement.UNDEFINED_STRING; |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/IListe.java |
---|
1189,9 → 1189,13 |
final List<R> res = new ArrayList<R>(); |
for (int i = start; i <= stop; i++) { |
if (selectionModel.isSelectedIndex(i)) { |
try { |
res.add(getRow(i, clazz)); |
} catch (Exception e) { |
System.err.println("IListe.iterateSelectedRows() index " + i + " is selected but not in the model anymore."); |
} |
} |
} |
return res; |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/list/AutoCompletionManager.java |
---|
91,6 → 91,8 |
init(fromTableElement, fillFrom, table, tableModel, modeCompletion, req, foreign, new ValidStateChecker()); |
} |
private ITextArticleWithCompletionCellEditor articleCombo; |
public void init(final SQLTableElement fromTableElement, final SQLField fillFrom, RowValuesTable table, RowValuesTableModel tableModel, int modeCompletion, ComboSQLRequest req, boolean foreign, |
ValidStateChecker validStateChecker) { |
142,8 → 144,8 |
} |
} else if (cellEdit instanceof ITextArticleWithCompletionCellEditor) { |
final ITextArticleWithCompletionCellEditor combo = (ITextArticleWithCompletionCellEditor) cellEdit; |
combo.addSelectionListener(this); |
this.articleCombo = (ITextArticleWithCompletionCellEditor) cellEdit; |
this.articleCombo.addSelectionListener(this); |
} else { |
this.t = new ITextWithCompletion(req, true); |
286,6 → 288,8 |
this.t.setWhere(w); |
} else if (this.textComboCellEdit != null) { |
this.textComboCellEdit.setWhere(w); |
} else if (this.articleCombo != null) { |
this.articleCombo.setWhere(w); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/SQLMenuItemHelper.java |
---|
14,6 → 14,7 |
package org.openconcerto.sql.view; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.ui.FrameUtil; |
import org.openconcerto.utils.cc.IClosure; |
import java.awt.event.ActionEvent; |
193,7 → 194,7 |
@Override |
public void actionPerformed(ActionEvent e) { |
this.getFrame().setVisible(true); |
FrameUtil.show(this.getFrame()); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/view/IListPanel.java |
---|
142,6 → 142,7 |
protected EditFrame createFrame; |
private boolean selectRowOnAdd = true; |
private boolean showReadOnlyFrameOnDoubleClick = true; |
private boolean deaf = Boolean.getBoolean("org.openconcerto.sql.listPanel.deafEditPanel"); |
protected SearchListComponent searchComponent; |
239,7 → 240,7 |
@Override |
public void mouseClicked(MouseEvent e) { |
if (e.getClickCount() == 2) { |
if (IListPanel.this.showReadOnlyFrameOnDoubleClick && e.getClickCount() == 2) { |
final EditFrame frame; |
if ((e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) { |
if (this.listeningFrame == null) |
781,6 → 782,10 |
this.getListe().getJTable().setDragEnabled(b); |
} |
public void setShowReadOnlyFrameOnDoubleClick(boolean showReadOnlyFrameOnDoubleClick) { |
this.showReadOnlyFrameOnDoubleClick = showReadOnlyFrameOnDoubleClick; |
} |
public void setAddVisible(boolean b) { |
this.buttonAjouter.setVisible(b); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/StringWithId.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/light/LightUIDescriptorProvider.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/light/LightUIDescriptorFiller.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/light/LightUIPanelFiller.java |
---|
New file |
0,0 → 1,118 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.sql.ui.light; |
import java.util.Calendar; |
import java.util.List; |
import org.openconcerto.sql.Log; |
import org.openconcerto.sql.PropsConfiguration; |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.sqlobject.ElementComboBoxUtils; |
import org.openconcerto.ui.light.LightUIElement; |
import org.openconcerto.ui.light.LightUILine; |
import org.openconcerto.ui.light.LightUIPanel; |
import org.openconcerto.utils.ui.StringWithId; |
/** |
* Fill value from default or database |
*/ |
public class LightUIPanelFiller { |
private final LightUIPanel panel; |
public LightUIPanelFiller(LightUIPanel panel) { |
this.panel = panel; |
} |
public void fillWithDefaultValues() { |
final int lineCount = this.panel.getSize(); |
for (int i = 0; i < lineCount; i++) { |
final LightUILine l = this.panel.getLine(i); |
final int elementCount = l.getSize(); |
for (int j = 0; j < elementCount; j++) { |
final LightUIElement element = l.getElement(j); |
if (element.getType() == LightUIElement.TYPE_DATE) { |
// Set date to current server date |
element.setValue(String.valueOf(System.currentTimeMillis())); |
} |
} |
} |
} |
public void fillFromId(final PropsConfiguration configuration, final SQLTable table, final long id) { |
System.err.println("LightUIFrameFiller.fillFromId() " + id); |
final SQLRow row = table.getRow((int) id); |
this.fillFromRow(this.panel, configuration, table, row); |
} |
public void fillFromRow(final LightUIPanel panel, final PropsConfiguration configuration, final SQLTable table, final SQLRow row) { |
final int lineCount = panel.getSize(); |
for (int i = 0; i < lineCount; i++) { |
final LightUILine l = panel.getLine(i); |
final int elementCount = l.getSize(); |
for (int j = 0; j < elementCount; j++) { |
final LightUIElement element = l.getElement(j); |
final SQLField field = configuration.getFieldMapper().getSQLFieldForItem(element.getId()); |
int type = element.getType(); |
if (type == LightUIElement.TYPE_TEXT_FIELD) { |
if (field == null) { |
Log.get().severe("No field found for text field : " + element.getId()); |
continue; |
} |
element.setValue(row.getString(field.getName())); |
} else if (type == LightUIElement.TYPE_COMBOBOX_ELEMENT) { |
// send: id,value |
SQLTable foreignTable = field.getForeignTable(); |
final List<SQLField> fieldsToFetch = configuration.getDirectory().getElement(foreignTable).getComboRequest().getFields(); |
if (row.getObject(field.getName()) != null) { |
final Where where = new Where(foreignTable.getKey(), "=", row.getLong(field.getName())); |
List<SQLRowValues> fetchedRows = ElementComboBoxUtils.fetchRows(configuration, foreignTable, fieldsToFetch, where); |
if (fetchedRows.size() > 1) { |
throw new IllegalStateException("multiple rows fetched for id " + row.getID() + " on table " + table.getName()); |
} |
for (final SQLRowValues vals : fetchedRows) { |
StringWithId s = ElementComboBoxUtils.createItem(configuration, foreignTable, vals, fieldsToFetch); |
element.setValue(s.toCondensedString()); |
} |
} else { |
element.setValue(null); |
} |
} else if (type == LightUIElement.TYPE_CHECKBOX) { |
if (row.getBoolean(field.getName())) { |
element.setValue("true"); |
} else { |
element.setValue("false"); |
} |
} else if (type == LightUIElement.TYPE_DATE) { |
Calendar date = row.getDate(field.getName()); |
if (date != null) { |
element.setValue(String.valueOf(row.getDate(field.getName()).getTimeInMillis())); |
} |
} else if(type == LightUIElement.TYPE_PANEL) { |
this.fillFromRow((LightUIPanel) element, configuration, table, row); |
} |
} |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/light/ConvertorModifer.java |
---|
New file |
0,0 → 1,20 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.sql.ui.light; |
import org.openconcerto.ui.light.LightUIElement; |
public abstract class ConvertorModifer { |
public abstract void process(final LightUIElement element); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/light/GroupToLightUIConvertor.java |
---|
13,6 → 13,12 |
package org.openconcerto.sql.ui.light; |
import java.awt.Color; |
import java.sql.Timestamp; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.Map; |
import org.openconcerto.sql.Log; |
import org.openconcerto.sql.PropsConfiguration; |
import org.openconcerto.sql.model.FieldMapper; |
21,20 → 27,22 |
import org.openconcerto.ui.group.Item; |
import org.openconcerto.ui.group.LayoutHints; |
import org.openconcerto.ui.light.CustomEditorProvider; |
import org.openconcerto.ui.light.LightUIDescriptor; |
import org.openconcerto.ui.light.LightUICheckBox; |
import org.openconcerto.ui.light.LightUICombo; |
import org.openconcerto.ui.light.LightUIDate; |
import org.openconcerto.ui.light.LightUIElement; |
import org.openconcerto.ui.light.LightUIFrame; |
import org.openconcerto.ui.light.LightUILabel; |
import org.openconcerto.ui.light.LightUILine; |
import org.openconcerto.ui.light.LightUIPanel; |
import org.openconcerto.ui.light.LightUITextField; |
import org.openconcerto.utils.i18n.TranslationManager; |
import java.awt.Color; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.Map; |
public class GroupToLightUIConvertor { |
private final int maxColumnCount; |
private PropsConfiguration configuration; |
private Map<String, CustomEditorProvider> customEditorProviders = new HashMap<String, CustomEditorProvider>(); |
private Map<String, ConvertorModifer> modifers = new HashMap<String, ConvertorModifer>(); |
public GroupToLightUIConvertor(PropsConfiguration conf) { |
this(conf, 4); |
45,27 → 53,54 |
this.configuration = conf; |
} |
public LightUIDescriptor convert(Group group) { |
final LightUIDescriptor desc = new LightUIDescriptor(group.getId()); |
append(desc, group); |
return desc; |
public LightUIFrame convert(Group group) { |
final LightUIFrame frame = new LightUIFrame(group.getId()); |
final LightUIPanel mainPanel = new LightUIPanel(frame.getId() + ".panel"); |
append(mainPanel, group); |
frame.setMainPanel(mainPanel); |
final String frameTitle = TranslationManager.getInstance().getTranslationForItem(group.getId()); |
frame.setTitle(frameTitle); |
return frame; |
} |
private void append(LightUIDescriptor desc, Item item) { |
private void append(LightUIPanel panel, Item item) { |
if (item instanceof Group) { |
Group gr = (Group) item; |
final Group gr = (Group) item; |
int size = gr.getSize(); |
if(gr.getLocalHint().isFoldable()) { |
panel.setFoldable(true); |
String title = TranslationManager.getInstance().getTranslationForItem(item.getId()); |
if (title == null) { |
title = item.getId(); |
Log.get().warning("No translation for " + item.getId()); |
} |
panel.setTitle(title); |
} |
for (int i = 0; i < size; i++) { |
Item it = gr.getItem(i); |
append(desc, it); |
final Item it = gr.getItem(i); |
if(it instanceof Group) { |
final LightUIPanel childPanel = new LightUIPanel(it.getId()); |
this.append(childPanel, it); |
final LightUILine currentLine = new LightUILine(); |
currentLine.add(childPanel); |
panel.addLine(currentLine); |
} else { |
append(panel, it); |
} |
} |
if(this.modifers.containsKey(gr.getId())) { |
this.modifers.get(gr.getId()).process(panel); |
} |
} else { |
LayoutHints localHint = item.getLocalHint(); |
LightUILine currentLine = desc.getLastLine(); |
final LayoutHints localHint = item.getLocalHint(); |
LightUILine currentLine = panel.getLastLine(); |
if (localHint.isSeparated()) { |
if (currentLine.getWidth() > 0) { |
currentLine = new LightUILine(); |
desc.addLine(currentLine); |
panel.addLine(currentLine); |
} |
} |
if (localHint.fillHeight()) { |
76,19 → 111,17 |
currentLine.setWeightY(1); |
} |
if (currentLine.getWidth() >= maxColumnCount) { |
if (currentLine.getWidth() >= this.maxColumnCount) { |
currentLine = new LightUILine(); |
desc.addLine(currentLine); |
panel.addLine(currentLine); |
} |
LightUIElement elementLabel = null; |
LightUILabel elementLabel = null; |
if (localHint.showLabel()) { |
elementLabel = new LightUIElement(); |
elementLabel.setId(item.getId()); |
elementLabel.setType(LightUIElement.TYPE_LABEL); |
elementLabel = new LightUILabel(item.getId()); |
String label = TranslationManager.getInstance().getTranslationForItem(item.getId()); |
if (label == null) { |
label = item.getId(); |
elementLabel.setColor(Color.ORANGE); |
elementLabel.setBackgroundColor(Color.ORANGE); |
elementLabel.setToolTip("No translation for " + item.getId()); |
Log.get().warning("No translation for " + item.getId()); |
} |
104,47 → 137,57 |
} |
LightUIElement elementEditor = this.getCustomEditor(item.getId()); |
if (elementEditor == null) { |
elementEditor = new LightUIElement(); |
elementEditor.setId(item.getId()); |
FieldMapper fieldMapper = configuration.getFieldMapper(); |
FieldMapper fieldMapper = this.configuration.getFieldMapper(); |
if (fieldMapper == null) { |
throw new IllegalStateException("null field mapper"); |
} |
SQLField field = fieldMapper.getSQLFieldForItem(item.getId()); |
final SQLField field = fieldMapper.getSQLFieldForItem(item.getId()); |
if (field != null) { |
Class<?> javaType = field.getType().getJavaType(); |
if (field.isKey()) { |
elementEditor.setType(LightUIElement.TYPE_COMBOBOX_ELEMENT); |
elementEditor = new LightUICombo(item.getId()); |
elementEditor.setMinInputSize(20); |
} else if (javaType.equals(String.class)) { |
elementEditor.setType(LightUIElement.TYPE_TEXT_FIELD); |
elementEditor = new LightUITextField(item.getId()); |
elementEditor.setValue(""); |
elementEditor.setMinInputSize(10); |
} else if (javaType.equals(Date.class)) { |
elementEditor.setType(LightUIElement.TYPE_DATE); |
elementEditor = new LightUIDate(item.getId()); |
} else if(javaType.equals(Boolean.class)) { |
elementEditor = new LightUICheckBox(item.getId(), ""); |
} else if(javaType.equals(Timestamp.class)) { |
elementEditor = new LightUIDate(item.getId()); |
} else if (javaType.equals(Integer.class)) { |
elementEditor = new LightUITextField(item.getId()); |
elementEditor.setValueType(LightUIElement.VALUE_TYPE_INTEGER); |
} else { |
elementEditor.setType(LightUIElement.TYPE_TEXT_FIELD); |
elementEditor = new LightUITextField(item.getId()); |
Log.get().warning("unsupported type " + javaType.getName()); |
elementEditor.setValue("unsupported type " + javaType.getName()); |
} |
} else { |
elementEditor.setType(LightUIElement.TYPE_TEXT_FIELD); |
elementEditor = new LightUITextField(item.getId()); |
elementEditor.setMinInputSize(10); |
elementEditor.setToolTip("No field attached to " + item.getId()); |
Log.get().warning("No field attached to " + item.getId()); |
if (elementLabel != null) { |
elementLabel.setColor(Color.ORANGE); |
elementLabel.setBackgroundColor(Color.ORANGE); |
elementLabel.setToolTip("No field attached to " + item.getId()); |
} |
} |
} |
if(elementEditor != null) { |
if(this.modifers.containsKey(item.getId())) { |
this.modifers.get(item.getId()).process(elementEditor); |
} |
} |
if (localHint.isSplit()) { |
if (currentLine.getWidth() > 0) { |
currentLine = new LightUILine(); |
desc.addLine(currentLine); |
panel.addLine(currentLine); |
} |
} |
164,7 → 207,6 |
currentLine.add(elementEditor); |
} |
} |
private LightUIElement getCustomEditor(String id) { |
182,4 → 224,8 |
public void setCustomEditorProvider(String id, CustomEditorProvider provider) { |
this.customEditorProviders.put(id, provider); |
} |
public void addModifer(final String itemId, final ConvertorModifer modifer) { |
this.modifers.put(itemId, modifer); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/ui/light/LightUIFrameProvider.java |
---|
New file |
0,0 → 1,21 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.sql.ui.light; |
import org.openconcerto.sql.PropsConfiguration; |
import org.openconcerto.ui.light.LightUIFrame; |
public interface LightUIFrameProvider { |
LightUIFrame getUIFrame(PropsConfiguration configuration); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/ElementComboBoxUtils.java |
---|
27,11 → 27,11 |
import org.openconcerto.sql.model.graph.Link.Direction; |
import org.openconcerto.sql.model.graph.Path; |
import org.openconcerto.sql.request.BaseFillSQLRequest; |
import org.openconcerto.sql.ui.StringWithId; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.Tuple2; |
import org.openconcerto.utils.cc.IPredicate; |
import org.openconcerto.utils.cc.ITransformer; |
import org.openconcerto.utils.ui.StringWithId; |
import java.util.ArrayList; |
import java.util.Collections; |
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/ITextWithCompletion.java |
---|
361,12 → 361,8 |
private void updateAutoCompletion(boolean autoselectIfMatch) { |
System.err.println("---ITextWithCompletion.updateAutoCompletion() autoselectIfMatch:" + autoselectIfMatch); |
assert SwingUtilities.isEventDispatchThread(); |
if (!this.isCompletionEnabled() || this.isLoading) { |
System.err.println("ITextWithCompletion.updateAutoCompletion() autoselectIfMatch:" + autoselectIfMatch + " quick exit : is loading: " + this.isLoading + " completion enabled: " |
+ this.isCompletionEnabled()); |
return; |
} |
String t = this.text.getText().trim(); |
381,7 → 377,6 |
this.model.removeAllElements(); |
this.model.addAll(l); |
System.err.println("ITextWithCompletion.updateAutoCompletion() text:" + t + " : " + l.size() + " values found, this.selectAuto : " + this.selectAuto); |
if (l.size() > 0) { |
showPopup(); |
} else { |
400,7 → 395,6 |
break; |
} |
} |
System.err.println("ITextWithCompletion.updateAutoCompletion() text:" + t + " : " + l.size() + " values found, " + t + " found:" + found); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/ITextArticleWithCompletion.java |
---|
143,6 → 143,12 |
this.popup.setListEnabled(b); |
} |
private Where whereAdditionnal; |
public void setWhere(Where w) { |
this.whereAdditionnal = w; |
} |
public void setTextEditor(final JTextComponent atext) { |
if (atext == null) { |
throw new IllegalArgumentException("null textEditor"); |
158,6 → 164,7 |
// Complete si exactement la valeur souhaitée |
updateAutoCompletion(true); |
e.consume(); |
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) { |
if (ITextArticleWithCompletion.this.popup.isShowing()) { |
ITextArticleWithCompletion.this.popup.selectNext(); |
280,6 → 287,9 |
Where wMatchingCode = new Where(this.tableArticle.getField("CODE"), "=", aText); |
wMatchingCode = wMatchingCode.or(new Where(this.tableArticle.getField("NOM"), "=", aText)); |
wMatchingCode = wMatchingCode.or(new Where(this.tableArticle.getField("CODE_BARRE"), "=", aText)); |
if (this.whereAdditionnal != null) { |
wMatchingCode = wMatchingCode.and(this.whereAdditionnal); |
} |
selMatchingCode.setWhere(wMatchingCode); |
listSel.add(selMatchingCode); |
293,13 → 303,16 |
Where wContains = new Where(this.tableArticle.getField("CODE"), "LIKE", "%" + aText + "%"); |
wContains = wContains.or(new Where(this.tableArticle.getField("NOM"), "LIKE", "%" + aText + "%")); |
wContains = wContains.or(new Where(this.tableArticle.getField("CODE_BARRE"), "LIKE", "%" + aText + "%")); |
if (this.whereAdditionnal != null) { |
wContains = wContains.and(this.whereAdditionnal); |
} |
selContains.setWhere(wContains.and(wMatchingCode.not())); |
selContains.setLimit(SQL_RESULT_LIMIT); |
listSel.add(selContains); |
// CODE ARTICLE = aText |
final Where wNotSync = new Where(this.tableArticleFournisseur.getField("ID_ARTICLE"), "IS", (Object) null).or(new Where(this.tableArticleFournisseur.getField("ID_ARTICLE"), "=", |
this.tableArticleFournisseur.getUndefinedID())); |
final Where wNotSync = new Where(this.tableArticleFournisseur.getField("ID_ARTICLE"), "IS", (Object) null) |
.or(new Where(this.tableArticleFournisseur.getField("ID_ARTICLE"), "=", this.tableArticleFournisseur.getUndefinedID())); |
SQLSelect selMatchingCodeF = new SQLSelect(); |
// selMatchingCodeF.addSelectStar(this.tableArticleFournisseur); |
389,6 → 402,7 |
l = new ArrayList<IComboSelectionItem>(0); |
e.printStackTrace(); |
} |
// On cache la popup si le nombre de ligne change afin que sa taille soit correcte |
if (l.size() != model.getSize() && l.size() <= ITextWithCompletionPopUp.MAXROW) { |
hidePopup(); |
403,11 → 417,15 |
hidePopup(); |
} |
SQLRowAccessor newRow = selectedRow; |
IComboSelectionItem newSelectedItem = null; |
boolean found = false; |
for (Iterator<IComboSelectionItem> iter = l.iterator(); iter.hasNext();) { |
IComboSelectionItem element = iter.next(); |
if (element.getLabel().toLowerCase().contains(t.toLowerCase()) && autoselectIfMatch) { |
if ((element.getRow().getString("CODE_BARRE").toLowerCase().equals(t.toLowerCase()) || element.getRow().getString("CODE").toLowerCase().equals(t.toLowerCase())) |
&& autoselectIfMatch) { |
newRow = element.getRow(); |
newSelectedItem = element; |
hidePopup(); |
found = true; |
break; |
414,17 → 432,18 |
} |
} |
if (selectAuto && found && !CompareUtils.equals(newRow, selectedRow)) { |
selectedRow = newRow; |
final IComboSelectionItem selectedItem = newSelectedItem; |
SwingUtilities.invokeLater(new Runnable() { |
public void run() { |
ITextArticleWithCompletion.this.fireSelectionRow(ITextArticleWithCompletion.this.getSelectedRow()); |
itemSelected(selectedItem); |
} |
}); |
} |
if (!found) { |
selectedRow = null; |
fireSelectionRow(null); |
itemSelected(null); |
} |
} |
}; |
worker.execute(); |
504,7 → 523,6 |
throw new IllegalStateException("Not in Swing!"); |
} |
setCompletionEnabled(false); |
this.text.setText(label); |
if (label != null) { |
this.text.setCaretPosition(label.length()); |
526,6 → 544,7 |
private void fireSelectionRow(SQLRowAccessor row) { |
if (!this.isDispatching) { |
this.isDispatching = true; |
for (Iterator<SelectionRowListener> iter = this.listeners.iterator(); iter.hasNext();) { |
SelectionRowListener element = iter.next(); |
550,7 → 569,6 |
} |
public Object getText() { |
return this.text.getText(); |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/sqlobject/ITextArticleWithCompletionCellEditor.java |
---|
13,25 → 13,81 |
package org.openconcerto.sql.sqlobject; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLTable; |
import java.awt.Component; |
import java.awt.event.KeyAdapter; |
import java.awt.event.KeyEvent; |
import javax.swing.AbstractCellEditor; |
import javax.swing.BorderFactory; |
import javax.swing.JTable; |
import javax.swing.SwingUtilities; |
import javax.swing.table.TableCellEditor; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
public class ITextArticleWithCompletionCellEditor extends AbstractCellEditor implements TableCellEditor { |
private final ITextArticleWithCompletion text; |
private boolean listenersInited = false; |
public ITextArticleWithCompletionCellEditor(SQLTable tableArticle, SQLTable tableARticleFournisseur) { |
this.text = new ITextArticleWithCompletion(tableArticle, tableARticleFournisseur); |
this.text.setBorder(BorderFactory.createEmptyBorder()); |
} |
private void initListener(final JTable t) { |
if (!this.listenersInited) { |
this.listenersInited = true; |
this.text.getTextComp().addKeyListener(new KeyAdapter() { |
@Override |
public void keyPressed(KeyEvent e) { |
if (e.getKeyCode() == KeyEvent.VK_TAB) { |
final int column; |
final int row = t.getEditingRow(); |
// gestion tab ou shift+tab |
if (e.getModifiers() == KeyEvent.SHIFT_MASK) { |
column = t.getEditingColumn() - 1; |
} else { |
column = t.getEditingColumn() + 1; |
} |
SwingUtilities.invokeLater(new Runnable() { |
public void run() { |
if (t.getCellEditor() != null && t.getCellEditor().stopCellEditing()) { |
if (column >= 0 && column < t.getColumnCount()) { |
t.setColumnSelectionInterval(column, column); |
t.setRowSelectionInterval(row, row); |
// Need to postpone editCell because selection with |
// cancel |
// selection |
SwingUtilities.invokeLater(new Runnable() { |
public void run() { |
if (t.editCellAt(row, column)) { |
t.getEditorComponent().requestFocusInWindow(); |
} |
} |
}); |
} |
} |
} |
}); |
} else { |
if (e.getKeyCode() == KeyEvent.VK_SPACE && e.getModifiers() == KeyEvent.SHIFT_MASK) { |
e.setModifiers(0); |
} |
} |
} |
}); |
} |
} |
@Override |
public Object getCellEditorValue() { |
return this.text.getText(); |
} |
39,6 → 95,7 |
@Override |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
initListener(table); |
if (value != null) { |
this.text.setText((String) value); |
} else { |
63,4 → 120,8 |
public SQLRowAccessor getComboSelectedRow() { |
return this.text.getSelectedRow(); |
} |
public void setWhere(Where w) { |
this.text.setWhere(w); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/Configuration.java |
---|
16,6 → 16,23 |
*/ |
package org.openconcerto.sql; |
import java.io.File; |
import java.io.IOException; |
import java.io.StringReader; |
import java.util.List; |
import java.util.concurrent.Executor; |
import java.util.concurrent.ExecutorService; |
import java.util.concurrent.Executors; |
import javax.xml.parsers.DocumentBuilder; |
import javax.xml.parsers.DocumentBuilderFactory; |
import javax.xml.parsers.ParserConfigurationException; |
import org.w3c.dom.Document; |
import org.xml.sax.InputSource; |
import org.xml.sax.SAXException; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.element.SQLElementDirectory; |
import org.openconcerto.sql.model.DBFileCache; |
import org.openconcerto.sql.model.DBItemFileCache; |
25,16 → 42,13 |
import org.openconcerto.sql.model.FieldMapper; |
import org.openconcerto.sql.model.SQLBase; |
import org.openconcerto.sql.model.SQLFilter; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowListRSH; |
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.utils.FileUtils; |
import java.io.File; |
import java.io.IOException; |
import java.util.concurrent.Executor; |
import java.util.concurrent.ExecutorService; |
import java.util.concurrent.Executors; |
import net.jcip.annotations.GuardedBy; |
/** |
173,6 → 187,28 |
} |
/** |
* Get xml value from table FWK_LIST_PREFS for an user and a table. |
* |
* @throws ParserConfigurationException |
* @throws IOException |
* @throws SAXException |
*/ |
public Document getXMLConf(final long userId, final String idTable) throws ParserConfigurationException, SAXException, IOException { |
final SQLElement element = this.getDirectory().getElement("FWK_LIST_PREFS"); |
final SQLTable columnPrefsTable = element.getTable(); |
final SQLSelect select = new SQLSelect(); |
select.addSelectStar(columnPrefsTable); |
select.setWhere((new Where(columnPrefsTable.getField("ID_USER"), "=", userId)).and(new Where(columnPrefsTable.getField("ID_TABLE"), "=", idTable))); |
final List<SQLRow> rqResult = SQLRowListRSH.execute(select); |
if (rqResult != null && !rqResult.isEmpty()) { |
final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); |
final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); |
return docBuilder.parse(new InputSource(new StringReader(rqResult.get(0).getString("VALUE")))); |
} |
return null; |
} |
/** |
* An executor that should be used for background SQL requests. It can be used to limit the |
* concurrent number of database connections (as establishing a connection is expensive and the |
* server might have restrictions). |
/trunk/OpenConcerto/src/org/openconcerto/sql/request/FilteredFillSQLRequest.java |
---|
13,6 → 13,11 |
package org.openconcerto.sql.request; |
import java.util.Collection; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLDataSource; |
import org.openconcerto.sql.model.SQLFilter; |
28,12 → 33,6 |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.CompareUtils; |
import org.openconcerto.utils.Tuple2; |
import java.util.Collection; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import net.jcip.annotations.GuardedBy; |
import net.jcip.annotations.ThreadSafe; |
67,8 → 66,15 |
static public final int getRowCount(final SQLSelect sel, final SQLDataSource ds) { |
sel.clearForRowCount(); |
return ((Number) ds.executeScalar(sel.asString())).intValue(); |
System.out.println("FilteredFillSQLRequest.getRowCount() " + sel.asString()); |
Number executeScalar = (Number) ds.executeScalar(sel.asString()); |
if(executeScalar == null) { |
System.out.println("FilteredFillSQLRequest.getRowCount() select null"); |
return 0; |
} else { |
return executeScalar.intValue(); |
} |
} |
// never null (but can be <null, null>) |
@GuardedBy("this") |
/trunk/OpenConcerto/src/org/openconcerto/sql/element/GroupSQLComponent.java |
---|
79,17 → 79,15 |
super(element); |
this.group = group; |
this.hasAdditionnalFields = this.getElement().getAdditionalFields().size() > 0; |
this.additionnalFieldsGroup = getAdditionalFieldsGroup(group.getDescendantItems()); |
this.additionnalFieldsGroup = getAdditionalFieldsGroup(group.getDescendantGroups()); |
} |
private Group getAdditionalFieldsGroup(Collection<Item> items) { |
for (Item item : items) { |
if (item instanceof Group) { |
if (item.getId().endsWith("additionalElementFields")) { |
return (Group) item; |
private Group getAdditionalFieldsGroup(Collection<Group> items) { |
for (Group g : items) { |
if (g.getId().endsWith("additionalElementFields")) { |
return g; |
} |
} |
} |
return null; |
} |
162,8 → 160,14 |
if ((currentGroup == this.group && this.additionnalFieldsGroup == null) || (currentGroup == this.additionnalFieldsGroup)) { |
final Map<String, JComponent> additionalFields = this.getElement().getAdditionalFields(); |
for (String field : additionalFields.keySet()) { |
Item item = new Item(field); |
Item item = new Item(field, new LayoutHints(false, false, true, false, true, false)); |
int fill = c.fill; |
double weightx = c.weightx; |
c.weightx = 1; |
c.fill = GridBagConstraints.HORIZONTAL; |
layout(item, 100, x, level + 1, c, panel); |
c.weightx = weightx; |
c.fill = fill; |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/element/DefaultElementSQLObject.java |
---|
24,6 → 24,7 |
import org.openconcerto.utils.checks.ValidObject; |
import org.openconcerto.utils.checks.ValidState; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.GridLayout; |
215,6 → 216,8 |
this.editP.add(this.separator, c); |
} |
this.add(this.editP); |
// Lock minimum size |
this.setMinimumSize(new Dimension(this.getPreferredSize())); |
} |
return this.editP; |
} |
/trunk/OpenConcerto/src/org/openconcerto/sql/utils/BackupPanel.java |
---|
19,6 → 19,7 |
import org.openconcerto.sql.model.DBSystemRoot; |
import org.openconcerto.sql.model.SQLSystem; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.utils.Copy.FileExistsMode; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.JLabelBold; |
import org.openconcerto.ui.ReloadPanel; |
25,6 → 26,7 |
import org.openconcerto.ui.VFlowLayout; |
import org.openconcerto.ui.preferences.BackupProps; |
import org.openconcerto.utils.Backup; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.ExceptionHandler; |
import java.awt.Color; |
330,11 → 332,11 |
File fBase = new File(fDest, "Base"); |
Copy copy; |
try { |
copy = new Copy(true, fBase, sysRoot, false, false); |
final Collection<String> rootsToBackup = BackupPanel.this.listDb == null ? sysRoot.getChildrenNames() : BackupPanel.this.listDb; |
for (String db : rootsToBackup) { |
copy.applyTo(db, null); |
} |
copy = new Copy(true, fBase, FileExistsMode.DELETE, sysRoot, false, false); |
final Collection<String> rootsOrigin = BackupPanel.this.listDb == null ? sysRoot.getChildrenNames() : BackupPanel.this.listDb; |
copy.applyTo(null, BackupPanel.this.listDb == null ? null : CollectionUtils.<String, String> createMap(BackupPanel.this.listDb), null); |
sysRoot.setRootsToMap(rootsOrigin); |
sysRoot.reload(); |
} catch (SQLException e) { |
e.printStackTrace(); |
errors++; |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLDataSource.java |
---|
323,7 → 323,7 |
if (this.isCacheEnabled() && this.tables.size() > 0) |
// the general cache should wait for transactions to end, but the cache of transactions |
// must not. |
res = new SQLCache<List<?>, Object>(30, 30, "results of " + o.getClass().getSimpleName(), o == this); |
res = new SQLCache<List<?>, Object>(30, 120, "results of " + o.getClass().getSimpleName(), o == this); |
else |
res = null; |
return res; |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLTable.java |
---|
101,6 → 101,7 |
public static final String undefTable = SQLSchema.FWK_TABLENAME_PREFIX + "UNDEFINED_IDS"; |
// {SQLSchema=>{TableName=>UndefID}} |
private static final Map<SQLSchema, Map<String, Number>> UNDEFINED_IDs = new HashMap<SQLSchema, Map<String, Number>>(); |
private static final boolean AUTOFIX_UNDEFINED = false; |
@SuppressWarnings("unchecked") |
private static final Map<String, Number> getUndefIDs(final SQLSchema schema) { |
529,11 → 530,16 |
// empty table |
throw new IllegalStateException(this + " is empty, can not infer UNDEFINED_ID"); |
} else { |
final String update = "INSERT into " + new SQLName(this.getDBRoot().getName(), undefTable) + " VALUES('" + this.getName() + "', " + undef + ");"; |
final String update = "INSERT into " + new SQLName(this.getDBRoot().getName(), undefTable) + " (\"TABLENAME\",\"UNDEFINED_ID\") VALUES('" + this.getName() + "', " + undef + ");"; |
Log.get().config("the first row (which should be the undefined):\n" + update); |
return undef.intValue(); |
} |
} else if ("inDB".equals(policy)) { |
if (AUTOFIX_UNDEFINED) { |
final String update = "INSERT into " + new SQLName(this.getDBRoot().getName(), undefTable) + " (\"TABLENAME\",\"UNDEFINED_ID\") VALUES ('" + this.getName() + "',null );"; |
this.getDBSystemRoot().getDataSource().execute(update); |
return SQLRow.NONEXISTANT_ID; |
} |
throw new IllegalStateException("Not in " + new SQLName(this.getDBRoot().getName(), undefTable) + " : " + this.getName()); |
} else if (policy != null && !"nonexistant".equals(policy)) { |
final int res = Integer.parseInt(policy); |
/trunk/OpenConcerto/src/org/openconcerto/sql/model/SQLRequestLog.java |
---|
33,6 → 33,7 |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import java.util.Vector; |
import java.util.logging.Level; |
import javax.swing.JButton; |
55,7 → 56,7 |
private static final Color BG_PINK = new Color(254, 240, 240); |
private static final String ACTIVER_LA_CAPTURE = "Enable monitoring"; |
private static final String DESACTIVER_LA_CAPTURE = "Disable monitoring"; |
private static List<SQLRequestLog> list = new ArrayList<SQLRequestLog>(500); |
private static Vector<SQLRequestLog> list = new Vector<SQLRequestLog>(500); |
private static boolean enabled; |
private String query; |
private String comment; |
108,10 → 109,13 |
public static void log(String query, String comment, int connectionId, long starAtMs, long startTime, long afterCache, long afterQueryInfo, long afterExecute, long afterHandle, long endTime) { |
if (enabled) { |
if (list.size() < 50000) { |
final String ex = ExceptionUtils.getStackTrace(new Exception()); |
list.add(new SQLRequestLog(query, comment, connectionId, starAtMs, ex, SwingUtilities.isEventDispatchThread(), startTime, afterCache, afterQueryInfo, afterExecute, afterHandle, endTime)); |
list.add(new SQLRequestLog(query, comment, connectionId, starAtMs, ex, SwingUtilities.isEventDispatchThread(), startTime, afterCache, afterQueryInfo, afterExecute, afterHandle, |
endTime)); |
fireEvent(); |
} |
} |
count++; |
148,7 → 152,7 |
final long totalMs = getTotalMs(); |
final long totalSQLMs = getTotalSQLMs(); |
textInfo.setText("Total: " + totalMs + " ms, Swing: " + getTotalSwing() + " ms, SQL: " + totalSQLMs + " ms, processing: " + (totalMs - totalSQLMs) + " ms , " + getNbConnections() |
+ " conn., " + getNbThread() + " threads"); |
+ " conn., " + getNbThread() + " threads. Total: " + list.size() + " / " + count); |
} |
}); |
} |
585,7 → 589,7 |
} |
} |
protected static void highLight(SQLRequestLogModel model, TableRowSorter<TableModel> sorter, int s) { |
protected synchronized static void highLight(SQLRequestLogModel model, TableRowSorter<TableModel> sorter, int s) { |
if (s >= 0 && s < model.getRowCount()) { |
final SQLRequestLog rowAt = model.getRowAt(sorter.convertRowIndexToModel(s)); |
String req = rowAt.getQuery(); |
/trunk/OpenConcerto/src/org/openconcerto/utils/ui/StringWithId.java |
---|
New file |
0,0 → 1,105 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.utils.ui; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import org.openconcerto.utils.io.JSONConverter; |
import org.openconcerto.utils.io.Transferable; |
import net.minidev.json.JSONObject; |
public class StringWithId implements Transferable, Externalizable { |
private long id; |
// value is always trimed |
private String value; |
public StringWithId() { |
} |
public StringWithId(final JSONObject json) { |
this.fromJSON(json); |
} |
public StringWithId(long id, String value) { |
this.id = id; |
this.value = value.trim(); |
} |
public StringWithId(String condensedValue) { |
int index = condensedValue.indexOf(','); |
if (index <= 0) { |
throw new IllegalArgumentException("invalid condensed value " + condensedValue); |
} |
this.id = Long.parseLong(condensedValue.substring(0, index)); |
this.value = condensedValue.substring(index + 1).trim(); |
} |
public long getId() { |
return this.id; |
} |
public String getValue() { |
return this.value; |
} |
@Override |
public void writeExternal(ObjectOutput out) throws IOException { |
out.writeLong(this.id); |
out.writeUTF(this.value); |
} |
@Override |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
this.id = in.readLong(); |
this.value = in.readUTF().trim(); |
} |
@Override |
public String toString() { |
return this.value; |
} |
@Override |
public boolean equals(Object obj) { |
StringWithId o = (StringWithId) obj; |
return o.getId() == this.getId() && o.getValue().endsWith(this.getValue()); |
} |
@Override |
public int hashCode() { |
return (int) this.id + this.value.hashCode(); |
} |
public String toCondensedString() { |
return this.id + "," + this.value; |
} |
@Override |
public JSONObject toJSON() { |
final JSONObject result = new JSONObject(); |
result.put("class", "StringWithId"); |
result.put("id", this.id); |
result.put("value", this.value); |
return result; |
} |
@Override |
public void fromJSON(JSONObject json) { |
this.id = (Integer) JSONConverter.getParameterFromJSON(json, "id", Integer.class); |
this.value = (String) JSONConverter.getParameterFromJSON(json, "value", String.class); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/FileUtils.java |
---|
586,7 → 586,7 |
write(s, f, null, false); |
} |
public static void write(String s, File f, String charset, boolean append) throws IOException { |
public static void write(String s, File f, Charset charset, boolean append) throws IOException { |
final FileOutputStream fileStream = new FileOutputStream(f, append); |
final OutputStreamWriter out = charset == null ? new OutputStreamWriter(fileStream) : new OutputStreamWriter(fileStream, charset); |
final BufferedWriter w = new BufferedWriter(out); |
/trunk/OpenConcerto/src/org/openconcerto/utils/sync/HashWriter.java |
---|
76,7 → 76,12 |
public static byte[] getHash(File f) throws Exception { |
final MessageDigest hashSum = MessageDigest.getInstance("SHA-256"); |
final BufferedInputStream fb = new BufferedInputStream(new FileInputStream(f)); |
FileInputStream fIn = null; |
try { |
fIn = new FileInputStream(f); |
BufferedInputStream fb = null; |
try { |
fb = new BufferedInputStream(fIn); |
final byte[] buffer = new byte[BLOCK_SIZE]; |
int readSize = fb.read(buffer); |
while (readSize > 0) { |
85,7 → 90,21 |
// read |
readSize = fb.read(buffer); |
} |
} catch (Exception e) { |
throw new IOException(e); |
} finally { |
if (fb != null) { |
fb.close(); |
} |
} |
} catch (Exception e) { |
throw new IOException(e); |
} finally { |
if (fIn != null) { |
fIn.close(); |
} |
} |
byte[] fileHash = new byte[hashSum.getDigestLength()]; |
fileHash = hashSum.digest(); |
return fileHash; |
/trunk/OpenConcerto/src/org/openconcerto/utils/cc/HashingStrategy.java |
---|
New file |
0,0 → 1,20 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.utils.cc; |
public interface HashingStrategy<E> { |
int computeHashCode(E object); |
boolean equals(E object1, E object2); |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/cc/CustomEquals.java |
---|
New file |
0,0 → 1,237 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.utils.cc; |
import org.openconcerto.utils.CompareUtils; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.LinkedHashSet; |
import java.util.List; |
import java.util.Set; |
/** |
* Allow to create a proxy object which uses a {@link HashingStrategy}. |
* |
* @author Sylvain |
*/ |
public class CustomEquals { |
static private final HashingStrategy<Object> DEFAULT = new HashingStrategy<Object>() { |
@Override |
public boolean equals(Object object1, Object object2) { |
return CompareUtils.equals(object1, object2); |
} |
@Override |
public int computeHashCode(Object object) { |
return object == null ? 0 : object.hashCode(); |
} |
}; |
static private final HashingStrategy<Object> IDENTITY = new HashingStrategy<Object>() { |
@Override |
public boolean equals(Object object1, Object object2) { |
return object1 == object2; |
} |
@Override |
public int computeHashCode(Object object) { |
return System.identityHashCode(object); |
} |
}; |
static public HashingStrategy<Object> getDefault() { |
return DEFAULT; |
} |
static public HashingStrategy<Object> getIdentity() { |
return IDENTITY; |
} |
// only create sets if necessary |
static public final <S, T extends S> boolean equals(final Set<T> s1, final Set<T> s2, final HashingStrategy<S> s) { |
return equals(s1, s2, s, true); |
} |
static public final <S, T extends S> boolean equals(final List<T> s1, final List<T> s2, final HashingStrategy<S> s) { |
return equals(s1, s2, s, false); |
} |
/** |
* Test equality of 2 collections using the passed strategy. |
* |
* @param s1 the first collection. |
* @param s2 the second collection. |
* @param s the hashing strategy, <code>null</code> meaning the {@link #getDefault() default}. |
* @param set <code>true</code> if the passed collections should be used as a {@link Set}, |
* <code>false</code> for a {@link List}. |
* @return <code>true</code> if the 2 collections are equal using the passed parameters. |
*/ |
static public final <S, T extends S> boolean equals(final Collection<T> s1, final Collection<T> s2, final HashingStrategy<S> s, final boolean set) { |
final Collection<?> sA, sB; |
// if the caller ask that the collections are compared using Set or List make sure that they |
// already are. |
final Class<?> clazz = set ? Set.class : List.class; |
if ((s == null || s == DEFAULT) && clazz.isInstance(s1) && clazz.isInstance(s2)) { |
sA = s1; |
sB = s2; |
// boolean to only create collections if necessary (don't make callers create the empty |
// collections) |
} else if (set) { |
sA = ProxyFull.createSet(s, s1); |
sB = ProxyFull.createSet(s, s2); |
} else { |
sA = ProxyFull.createList(s, s1); |
sB = ProxyFull.createList(s, s2); |
} |
assert clazz.isInstance(sA) && clazz.isInstance(sB); |
return CompareUtils.equals(sA, sB); |
} |
static public class ProxyFull<S, E extends S> { |
static public final <S, E extends S> Set<ProxyFull<S, E>> createSet(final HashingStrategy<S> strategy, final Collection<E> coll) { |
return wrap(strategy, coll, new LinkedHashSet<ProxyFull<S, E>>()); |
} |
static public final <S, E extends S> List<ProxyFull<S, E>> createList(final HashingStrategy<S> strategy, final Collection<E> coll) { |
return wrap(strategy, coll, new ArrayList<ProxyFull<S, E>>()); |
} |
static public final <S, E extends S, C extends Collection<? super ProxyFull<S, E>>> C wrap(final HashingStrategy<S> strategy, final Collection<E> coll, final C res) { |
for (final E item : coll) { |
res.add(new ProxyFull<S, E>(item, strategy)); |
} |
return res; |
} |
static public final <T> Set<T> unwrapToSet(final Collection<? extends ProxyFull<?, T>> coll) { |
return unwrap(coll, new LinkedHashSet<T>()); |
} |
static public final <T> List<T> unwrapToList(final Collection<? extends ProxyFull<?, T>> coll) { |
return unwrap(coll, new ArrayList<T>()); |
} |
static public final <T, C extends Collection<? super T>> C unwrap(final Collection<? extends ProxyFull<?, T>> coll, final C res) { |
for (final ProxyFull<?, T> item : coll) { |
res.add(item.getDelegate()); |
} |
return res; |
} |
private final E delegate; |
private final HashingStrategy<S> strategy; |
/** |
* Create a proxy object that use a strategy to implement {@link #equals(Object)} and |
* {@link #hashCode()}. |
* |
* @param delegate the object to use. |
* @param strategy the strategy, <code>null</code> meaning use default implementation. |
*/ |
public ProxyFull(final E delegate, final HashingStrategy<S> strategy) { |
this.delegate = delegate; |
/** |
* Allow null strategy since the caller doesn't have to deal with generic limitations : |
* |
* <pre> |
* HashingStrategy<Constraint> strategy = sameSystem ? null : Constraint.getInterSystemHashStrategy(); |
* </pre> |
* |
* Otherwise if one have HashingStrategy<Object> and |
* HashingStrategy<Constraint> ProxyFull.createSet() can't be called since no Java |
* type can hold both those instances. In this class the two cases are handled |
* explicitly. |
*/ |
this.strategy = strategy; |
} |
public final E getDelegate() { |
return this.delegate; |
} |
public final HashingStrategy<S> getStrategy() { |
return this.strategy; |
} |
private final HashingStrategy<?> getInternalStrategy() { |
return this.strategy != null ? this.strategy : DEFAULT; |
} |
@Override |
public int hashCode() { |
// don't use getInternalStrategy() to avoid java warning |
if (this.strategy == null) |
return DEFAULT.computeHashCode(this.getDelegate()); |
else |
return this.getStrategy().computeHashCode(this.getDelegate()); |
} |
@Override |
public boolean equals(Object obj) { |
if (this == obj) |
return true; |
if (!(obj instanceof ProxyFull)) |
return false; |
final ProxyFull<?, ?> other = (ProxyFull<?, ?>) obj; |
// null and DEFAULT mean the same |
if (other.getInternalStrategy() != this.getInternalStrategy()) |
return false; |
// OK since same instance of strategy |
@SuppressWarnings("unchecked") |
final S delegate2 = (S) other.getDelegate(); |
final E delegate = this.getDelegate(); |
if (delegate == delegate2) |
return true; |
// don't use getInternalStrategy() to avoid java warning |
if (this.strategy == null) |
return DEFAULT.equals(this.getDelegate(), delegate2); |
else |
return this.strategy.equals(this.getDelegate(), delegate2); |
} |
} |
/** |
* A simple subclass to save some typing and improve legibility. |
* |
* @author Sylvain |
* @param <E> type of item |
*/ |
static public class Proxy<E> extends ProxyFull<E, E> { |
static public final <T> List<Proxy<T>> createList(final HashingStrategy<T> strategy, final Collection<T> coll) { |
return wrap(strategy, coll, new ArrayList<Proxy<T>>()); |
} |
static public final <T> Set<Proxy<T>> createSet(final HashingStrategy<T> strategy, final Collection<T> coll) { |
return wrap(strategy, coll, new LinkedHashSet<Proxy<T>>()); |
} |
static public final <T, C extends Collection<? super Proxy<T>>> C wrap(final HashingStrategy<T> strategy, final Collection<T> coll, final C res) { |
for (final T item : coll) { |
res.add(new Proxy<T>(item, strategy)); |
} |
return res; |
} |
public Proxy(E delegate, HashingStrategy<E> strategy) { |
super(delegate, strategy); |
} |
} |
private CustomEquals() { |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/NumberUtils.java |
---|
13,13 → 13,13 |
package org.openconcerto.utils; |
import org.openconcerto.utils.convertor.NumberConvertor; |
import java.math.BigDecimal; |
import java.math.BigInteger; |
import java.util.concurrent.atomic.AtomicInteger; |
import java.util.concurrent.atomic.AtomicLong; |
import org.openconcerto.utils.convertor.NumberConvertor; |
public class NumberUtils { |
/** |
276,4 → 276,11 |
} |
return res; |
} |
public static int ensureInt(long l) { |
if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { |
throw new IllegalArgumentException("long value " + String.valueOf(l) + " cannot be cast to int without changing its value."); |
} |
return (int) l; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/StreamUtils.java |
---|
15,6 → 15,7 |
import java.io.BufferedOutputStream; |
import java.io.BufferedWriter; |
import java.io.ByteArrayOutputStream; |
import java.io.File; |
import java.io.FileOutputStream; |
import java.io.IOException; |
83,6 → 84,20 |
} |
} |
/** |
* Read until the end of the stream is reached. NOTE : since this method didn't create the |
* stream, it doesn't close it. |
* |
* @param ins the stream to read from. |
* @return the bytes. |
* @throws IOException if an error occurs. |
*/ |
public static byte[] read(final InputStream ins) throws IOException { |
final ByteArrayOutputStream out = new ByteArrayOutputStream(512); |
copy(ins, out); |
return out.toByteArray(); |
} |
public static void writeln(final String s, final OutputStream out) throws IOException { |
write(s + "\n", out); |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/NoneSelectedButtonGroup.java |
---|
New file |
0,0 → 1,29 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.utils; |
import javax.swing.ButtonGroup; |
import javax.swing.ButtonModel; |
public class NoneSelectedButtonGroup extends ButtonGroup { |
@Override |
public void setSelected(ButtonModel model, boolean selected) { |
if (selected) { |
super.setSelected(model, selected); |
} else { |
clearSelection(); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/Nombre.java |
---|
13,6 → 13,11 |
package org.openconcerto.utils; |
import java.util.ArrayList; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
/** |
* @author ilm |
* |
19,22 → 24,13 |
*/ |
public class Nombre { |
private int nb; |
static final String[] ref0 = { "zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", |
"dix huit", "dix neuf", "vingt" }; |
static final String[] ref10 = { "zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "soixante", "quatre vingt", "quatre vingt", "cent" }; |
static final String[] refmult = { "mille", "million", "milliard", "billion", "trillion" };// 3,6,9,12,15 |
static int[] puissanceMille = { 0, 1000, 1000000, 1000000000 }; |
static final String[] ref0Eng = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", |
"seventeen", "eighteen", "nineteen", "twenty" }; |
static final String[] ref10Eng = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", "hundred" }; |
static final String[] refmultEng = { "thousand", "million", "billion", "billion", "trillion" };// 3,6,9,12,15 |
public static int FR = 0; |
public static int EN = 1; |
private int language = FR; |
public static int ES = 2; |
public static int PL = 3; |
private final NombreLocal local; |
public Nombre(int i) { |
this(i, FR); |
42,36 → 38,42 |
public Nombre(int i, int language) { |
this.nb = i; |
this.language = language; |
if (language == EN) { |
this.local = new NombreLocalEN(); |
} else if (language == PL) { |
this.local = new NombreLocalPL(); |
} else if (language == ES) { |
this.local = new NombreLocalES(); |
} else { |
this.local = new NombreLocalFR(); |
} |
} |
public Nombre(int i, NombreLocal local) { |
this.nb = i; |
this.local = local; |
} |
public String getText() { |
StringBuffer result = new StringBuffer(); |
if (this.nb < 0) |
result.append("moins "); |
result.append(this.local.negatifLabel); |
if (this.nb <= 20) { |
result.append(language == FR ? ref0[this.nb] : ref0Eng[this.nb]); |
if (this.local.getNombrePredefini(this.nb) != null) { |
result.append(this.local.getNombrePredefini(this.nb)); |
} else if (this.nb < 100) { |
int decimal = this.nb / 10; |
int unit = this.nb % 10; |
result.append(language == FR ? ref10[decimal] : ref10Eng[decimal]); |
result.append(this.local.getDizaine(decimal)); |
if (this.language == EN || (decimal != 7 && decimal != 9)) { |
if (unit > 0) { // trente, quarante.. |
if (unit == 1) { |
result.append(language == FR ? " et" : " and"); |
if (this.local.separateurDizaineLabel != null && this.local.separateurDizaineLabel.length() > 0) { |
result.append(" " + this.local.separateurDizaineLabel); |
} |
result.append(" " + (language == FR ? ref0[unit] : ref0Eng[unit])); |
result.append(" " + this.local.getNombrePredefini(unit)); |
} |
} else { |
if (unit == 1) { |
result.append(language == FR ? " et" : " and"); |
} |
result.append(" " + (language == FR ? ref0[unit + 10] : ref0Eng[unit + 10])); |
} |
} else { |
79,14 → 81,17 |
int cent = this.nb / 100; |
if (cent == 1) { |
result.append(language == FR ? "cent" : "one hundred"); |
if (this.local.getNombrePredefini(cent * 100) != null) { |
result.append(this.local.getNombrePredefini(cent * 100)); |
} else { |
result.append((language == FR ? ref0[cent] : ref0Eng[cent]) + (language == FR ? " cent" : " hundred")); |
result.append(this.local.getNombrePredefini(cent) + " " + this.local.getDizaine(10)); |
} |
int reste = this.nb - (cent * 100); |
if (reste > 0) { |
Nombre d = new Nombre(reste, language); |
Nombre d = new Nombre(reste, this.local); |
if (this.local.separateurDizaineLabel != null && this.local.separateurDizaineLabel.length() > 0) { |
result.append(" " + this.local.separateurDizaineLabel); |
} |
result.append(" " + d.getText()); |
} |
} else { |
100,9 → 105,9 |
if (val > 0) { |
if (val > 1 && (i - 1) > 0) { |
result.append(new Nombre(val, this.language).getText() + " " + (language == FR ? refmult[i - 1] : refmultEng[i - 1]) + "s "); |
result.append(new Nombre(val, this.local).getText() + " " + this.local.getMult(i - 1) + "s "); |
} else { |
result.append(new Nombre(val, this.language).getText() + " " + (language == FR ? refmult[i - 1] : refmultEng[i - 1]) + " "); |
result.append(new Nombre(val, this.local).getText() + " " + this.local.getMult(i - 1) + " "); |
} |
} |
cumul += val * puissancei; |
110,11 → 115,12 |
int val = this.nb % 1000; |
if (val > 0) { |
result.append(new Nombre(val, this.language).getText()); |
result.append(new Nombre(val, this.local).getText()); |
} |
} |
} |
System.err.println(result.toString().trim()); |
return result.toString().trim(); |
} |
122,4 → 128,178 |
return String.valueOf(r); |
} |
public NombreLocal getLocal() { |
return local; |
} |
public class NombreLocal { |
protected final Map<Integer, String> nombrePredefini = new HashMap<Integer, String>(); |
protected final List<String> dizaine = new ArrayList<String>(); |
protected final List<String> mult = new ArrayList<String>(); |
protected final String separateurLabel, separateurDizaineLabel, negatifLabel; |
public NombreLocal(String sep, String sepDizaine, String neg) { |
this.negatifLabel = neg; |
this.separateurLabel = sep; |
this.separateurDizaineLabel = sepDizaine; |
} |
public String getDizaine(int index) { |
return dizaine.get(index); |
} |
public String getMult(int index) { |
return mult.get(index); |
} |
public String getNombrePredefini(int value) { |
return nombrePredefini.get(value); |
} |
public String getSeparateurLabel() { |
return separateurLabel; |
} |
} |
private class NombreLocalFR extends NombreLocal { |
final String[] ref0 = { "zéro", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", "dix huit", |
"dix neuf", "vingt" }; |
final String[] ref10 = { "zéro", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "soixante", "quatre vingt", "quatre vingt", "cent" }; |
final String[] refmult = { "mille", "million", "milliard", "billion", "trillion" };// 3,6,9,12,15 |
public NombreLocalFR() { |
super("et", "", "moins"); |
for (int i = 0; i < ref0.length; i++) { |
nombrePredefini.put(i, ref0[i]); |
} |
for (int i = 0; i < ref10.length; i++) { |
dizaine.add(ref10[i]); |
} |
for (int i = 0; i < refmult.length; i++) { |
mult.add(refmult[i]); |
} |
nombrePredefini.put(21, "vingt et un"); |
nombrePredefini.put(31, "trente et un"); |
nombrePredefini.put(41, "quarante et un"); |
nombrePredefini.put(51, "cinquante et un"); |
nombrePredefini.put(61, "soixante et un"); |
nombrePredefini.put(70, "soixante dix"); |
nombrePredefini.put(71, "soixante et onze"); |
nombrePredefini.put(72, "soixante douze"); |
nombrePredefini.put(73, "soixante treize"); |
nombrePredefini.put(74, "soixante quatorze"); |
nombrePredefini.put(75, "soixante quinze"); |
nombrePredefini.put(76, "soixante seize"); |
nombrePredefini.put(77, "soixante dix sept"); |
nombrePredefini.put(78, "soixante dix huit"); |
nombrePredefini.put(79, "soixante dix neuf"); |
nombrePredefini.put(90, "quatre vingt dix"); |
nombrePredefini.put(91, "quatre vingt onze"); |
nombrePredefini.put(92, "quatre vingt douze"); |
nombrePredefini.put(93, "quatre vingt treize"); |
nombrePredefini.put(94, "quatre vingt quatorze"); |
nombrePredefini.put(95, "quatre vingt quinze"); |
nombrePredefini.put(96, "quatre vingt seize"); |
nombrePredefini.put(97, "quatre vingt dix sept"); |
nombrePredefini.put(98, "quatre vingt dix huit"); |
nombrePredefini.put(99, "quatre vingt dix neuf"); |
nombrePredefini.put(100, "cent"); |
} |
} |
private class NombreLocalEN extends NombreLocal { |
final String[] ref0 = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", |
"eighteen", "nineteen", "twenty" }; |
final String[] ref10 = { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", "hundred" }; |
final String[] refmult = { "thousand", "million", "billion", "billion", "trillion" };// 3,6,9,12,15 |
public NombreLocalEN() { |
super("and", "", "moins"); |
for (int i = 0; i < ref0.length; i++) { |
nombrePredefini.put(i, ref0[i]); |
} |
for (int i = 0; i < ref10.length; i++) { |
dizaine.add(ref10[i]); |
} |
for (int i = 0; i < refmult.length; i++) { |
mult.add(refmult[i]); |
} |
nombrePredefini.put(100, "one hundred"); |
} |
} |
private class NombreLocalPL extends NombreLocal { |
final String[] ref0 = { "zero", "jeden", "dwa", "trzy", "cztery", "pięć", "sześć", "siedem", "osiem", "dziewięć", "diesięć", "jedenaście", "dwanaście", "trzynaście", "czternaście", |
"piętnaście", "szesnaście", "siedemnaście", "osiemnaście", "dziewiętnaście", "dwadzieścia" }; |
final String[] ref10 = { "zero", "dziesięć", "dwadzieścia", "trzydzieści", "czterdzieści", "pięćdziesiąt", "sześćdziesiąt", "siedemdziesiąt", "osiemdziesiąt", "dziewięćdziesiąt", "sto" }; |
final String[] refmult = { "tysiąć", "milion", "miliard", "bilion", "trilion" }; |
public NombreLocalPL() { |
super("i", "", "moins"); |
for (int i = 0; i < ref0.length; i++) { |
nombrePredefini.put(i, ref0[i]); |
} |
for (int i = 0; i < ref10.length; i++) { |
dizaine.add(ref10[i]); |
} |
for (int i = 0; i < refmult.length; i++) { |
mult.add(refmult[i]); |
} |
nombrePredefini.put(100, "sto"); |
nombrePredefini.put(200, "dwiescie"); |
nombrePredefini.put(300, "trysta"); |
nombrePredefini.put(400, "czterysta"); |
nombrePredefini.put(500, "pięćdziesiąt"); |
nombrePredefini.put(600, "seiscientos"); |
nombrePredefini.put(700, "setecientos"); |
nombrePredefini.put(800, "ochocientos"); |
nombrePredefini.put(900, "novecientos"); |
} |
} |
private class NombreLocalES extends NombreLocal { |
final String[] ref0 = { "cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve", "diez", "once", "doce", "trece", "catorce", "quince", "dieciseis", "diecisiete", |
"dieciocho", "diecinueve", "veinte" }; |
final String[] ref10 = { "cero", "diez", "veinte", "treinta", "cuarenta", "cincuenta", "sesenta", "setenta", "ochenta", "noventa", "cien" }; |
final String[] refmult = { "mil", "millón", "millar", "billón", "trillón" }; |
public NombreLocalES() { |
super("y", "y", "moins"); |
for (int i = 0; i < ref0.length; i++) { |
nombrePredefini.put(i, ref0[i]); |
} |
for (int i = 0; i < ref10.length; i++) { |
dizaine.add(ref10[i]); |
} |
for (int i = 0; i < refmult.length; i++) { |
mult.add(refmult[i]); |
} |
nombrePredefini.put(100, "cien"); |
nombrePredefini.put(21, "veintiuno"); |
nombrePredefini.put(22, "veintidos"); |
nombrePredefini.put(23, "veintitrés"); |
nombrePredefini.put(24, "veinticuatro"); |
nombrePredefini.put(25, "veinticinco"); |
nombrePredefini.put(26, "veintiséis"); |
nombrePredefini.put(27, "veintisiete"); |
nombrePredefini.put(28, "veintiocho"); |
nombrePredefini.put(29, "veintinueve"); |
nombrePredefini.put(200, "doscientos"); |
nombrePredefini.put(300, "trescientos"); |
nombrePredefini.put(400, "cuatrocientos"); |
nombrePredefini.put(500, "quinientos"); |
nombrePredefini.put(600, "seiscientos"); |
nombrePredefini.put(700, "setecientos"); |
nombrePredefini.put(800, "ochocientos"); |
nombrePredefini.put(900, "novecientos"); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/io/JSONconverter.java |
---|
File deleted |
/trunk/OpenConcerto/src/org/openconcerto/utils/io/JSONConverter.java |
---|
New file |
0,0 → 1,152 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.utils.io; |
import java.awt.Color; |
import java.sql.Date; |
import java.sql.Timestamp; |
import java.text.SimpleDateFormat; |
import java.util.Calendar; |
import java.util.List; |
import java.util.regex.Matcher; |
import java.util.regex.Pattern; |
import javax.xml.bind.DatatypeConverter; |
import org.openconcerto.utils.NumberUtils; |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class JSONConverter { |
final static Pattern pattern = Pattern.compile("d{4}-[01]d-[0-3]dT[0-2]d:[0-5]d:[0-5]d.d+([+-][0-2]d:[0-5]d|Z)"); |
public static Object getJSON(Object param) { |
Object result = null; |
if (param != null) { |
if (param instanceof JSONAble) { |
result = ((JSONAble) param).toJSON(); |
} else if (param instanceof Timestamp) { |
final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); |
result = df.format((Timestamp) param); |
} else if (param instanceof Class<?>) { |
result = ((Class<?>) param).getName(); |
} else if (param instanceof Iterable) { |
final Iterable<?> tmp = (Iterable<?>) param; |
final JSONArray jsonArray = new JSONArray(); |
for (Object o : tmp) { |
jsonArray.add(getJSON(o)); |
} |
result = jsonArray; |
} else if (param instanceof Color) { |
if (param != null) { |
final Color paramColor = (Color) param; |
final JSONObject jsonColor = new JSONObject(); |
jsonColor.put("r", paramColor.getRed()); |
jsonColor.put("g", paramColor.getGreen()); |
jsonColor.put("b", paramColor.getBlue()); |
result = jsonColor; |
} |
} else { |
result = param; |
} |
} |
return result; |
} |
public static Object getObjectFromJSON(final Object o, final Class<?> type) { |
Object result = null; |
if (o != null && !o.equals("null")) { |
if (type == Integer.class) { |
if (!o.getClass().isAssignableFrom(Long.class)) { |
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'"); |
} else { |
try { |
result = NumberUtils.ensureInt((Long) o); |
} catch (IllegalArgumentException ex) { |
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "', " + ex.getMessage()); |
} |
} |
} else if (type == Date.class) { |
if (!o.getClass().isAssignableFrom(String.class)) { |
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'"); |
} |
final String sparam = (String) o; |
final Matcher matcher = pattern.matcher(sparam); |
if (matcher.find()) { |
final Calendar c = DatatypeConverter.parseDateTime(sparam); |
result = c.getTime(); |
} else { |
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "', the format is not valid"); |
} |
} else { |
if (!o.getClass().isAssignableFrom(type)) { |
throw new IllegalArgumentException("object (" + o.getClass().getName() + ") is not assignable for '" + type + "'"); |
} |
result = o; |
} |
} |
return result; |
} |
public static Object getParameterFromJSON(final JSONObject json, final String key, final Class<?> type) { |
return getParameterFromJSON(json, key, type, null); |
} |
public static Object getParameterFromJSON(final JSONObject json, final String key, final Class<?> type, Object defaultValue) { |
Object o = defaultValue; |
if (json.containsKey(key)) { |
o = json.get(key); |
if (o == null || o.equals("null")) { |
o = null; |
} else { |
if (type == Integer.class) { |
if (!o.getClass().isAssignableFrom(Long.class)) { |
throw new IllegalArgumentException("value for '" + key + "' is invalid"); |
} else { |
try { |
o = NumberUtils.ensureInt((Long) o); |
} catch (IllegalArgumentException ex) { |
throw new IllegalArgumentException("value for '" + key + "' is invalid, " + ex.getMessage()); |
} |
} |
} else { |
if (!o.getClass().isAssignableFrom(type)) { |
throw new IllegalArgumentException("value for '" + key + "' is invalid"); |
} |
} |
} |
} |
return o; |
} |
// TODO move to another class |
public static boolean listInstanceOf(Object object, Class<?> c) { |
if (object instanceof List<?>) { |
final List<?> list = (List<?>) object; |
final int listSize = list.size(); |
for (int i = 0; i < listSize; i++) { |
if (!c.isInstance(list.get(i))) { |
return false; |
} |
} |
} else { |
return false; |
} |
return true; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/utils/io/JSONAble.java |
---|
13,6 → 13,10 |
package org.openconcerto.utils.io; |
import net.minidev.json.JSONObject; |
public interface JSONAble { |
public abstract String toJSON(); |
public JSONObject toJSON(); |
public void fromJSON(JSONObject json); |
} |
/trunk/OpenConcerto/src/org/openconcerto/task/element/FWKListPrefs.java |
---|
New file |
0,0 → 1,38 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.task.element; |
import java.util.List; |
import org.openconcerto.sql.element.ConfSQLElement; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.model.DBRoot; |
public class FWKListPrefs extends ConfSQLElement { |
public FWKListPrefs(final DBRoot rootSociety) { |
super(rootSociety.findTable("FWK_LIST_PREFS", true)); |
} |
@Override |
protected List<String> getListFields() { |
// TODO Auto-generated method stub |
return null; |
} |
@Override |
public SQLComponent createComponent() { |
// TODO Auto-generated method stub |
return null; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/task/element/FWKSessionState.java |
---|
New file |
0,0 → 1,38 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.task.element; |
import java.util.List; |
import org.openconcerto.sql.element.ConfSQLElement; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.model.DBRoot; |
public class FWKSessionState extends ConfSQLElement { |
public FWKSessionState(final DBRoot rootSociety) { |
super(rootSociety.findTable("FWK_SESSION_STATE", true)); |
} |
@Override |
protected List<String> getListFields() { |
// TODO Auto-generated method stub |
return null; |
} |
@Override |
public SQLComponent createComponent() { |
// TODO Auto-generated method stub |
return null; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/task/config/ComptaBasePropsConfiguration.java |
---|
13,6 → 13,16 |
package org.openconcerto.task.config; |
import java.io.File; |
import java.io.FileNotFoundException; |
import java.io.InputStream; |
import java.sql.SQLException; |
import java.util.Arrays; |
import java.util.Collections; |
import java.util.Properties; |
import com.jcraft.jsch.Session; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.PropsConfiguration; |
import org.openconcerto.sql.element.ConfSQLElement; |
27,6 → 37,8 |
import org.openconcerto.sql.users.UserCommonSQLElement; |
import org.openconcerto.sql.users.rights.RightSQLElement; |
import org.openconcerto.sql.users.rights.UserRightSQLElement; |
import org.openconcerto.task.element.FWKListPrefs; |
import org.openconcerto.task.element.FWKSessionState; |
import org.openconcerto.task.element.TaskRightSQLElement; |
import org.openconcerto.task.element.TaskSQLElement; |
import org.openconcerto.utils.DesktopEnvironment; |
34,16 → 46,6 |
import org.openconcerto.utils.LogUtils; |
import org.openconcerto.utils.ProductInfo; |
import java.io.File; |
import java.io.FileNotFoundException; |
import java.io.InputStream; |
import java.sql.SQLException; |
import java.util.Arrays; |
import java.util.Collections; |
import java.util.Properties; |
import com.jcraft.jsch.Session; |
public abstract class ComptaBasePropsConfiguration extends PropsConfiguration { |
public abstract void setUpSocieteDataBaseConnexion(int base); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/HistoriqueClientBilanPanel.java |
---|
455,7 → 455,7 |
} else if (HistoriqueClientBilanPanel.this.nbChequesNonEncaisses == nb) { |
HistoriqueClientBilanPanel.this.labelCheques.setText(" " + nb + " chèques non encaissés d'un montant total de " + total + " € HT"); |
} else { |
HistoriqueClientBilanPanel.this.labelCheques.setText(" " + nb + " chèques non d'un montant total de " + total + " € HT dont " |
HistoriqueClientBilanPanel.this.labelCheques.setText(" " + nb + " chèques d'un montant total de " + total + " € HT dont " |
+ HistoriqueClientBilanPanel.this.nbChequesNonEncaisses + " non encaissés"); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/reports/history/ui/ListeHistoriquePanel.java |
---|
116,7 → 116,8 |
id = row.getID(); |
} |
for (int i = 0; i < ListeHistoriquePanel.this.vectListePanel.size(); i++) { |
final int size = ListeHistoriquePanel.this.vectListePanel.size(); |
for (int i = 0; i < size; i++) { |
IListPanel liste = ListeHistoriquePanel.this.vectListePanel.get(i); |
// remove listener |
247,6 → 248,8 |
if (request.getAllFields().containsAll(where.getFields())) { |
request.setWhere(where); |
} |
} else { |
request.setWhere(Where.FALSE); |
} |
if (elt.getTable().contains("ID_MOUVEMENT")) { |
565,6 → 568,10 |
return this.vectListePanel.get(index).getListe(); |
} |
public IListPanel getListePanel(int index) { |
return this.vectListePanel.get(index); |
} |
public void fireListesChanged() { |
final int size = this.vectListePanel.size(); |
for (int i = 0; i < size; i++) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/FactureFournisseurSQLComponent.java |
---|
13,6 → 13,24 |
package org.openconcerto.erp.core.supplychain.order.component; |
import java.awt.Color; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.math.BigDecimal; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
import javax.swing.event.DocumentEvent; |
import javax.swing.event.DocumentListener; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
22,7 → 40,9 |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
import org.openconcerto.erp.core.supplychain.order.ui.FactureFournisseurItemTable; |
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet; |
import org.openconcerto.erp.generationEcritures.GenerationMvtFactureFournisseur; |
import org.openconcerto.erp.panel.PanelOOSQLComponent; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.DefaultElementSQLObject; |
44,34 → 64,16 |
import org.openconcerto.ui.TitledSeparator; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.preferences.DefaultProps; |
import org.openconcerto.utils.text.SimpleDocumentListener; |
import java.awt.Color; |
import java.awt.FlowLayout; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
import javax.swing.event.DocumentEvent; |
import javax.swing.event.DocumentListener; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
public class FactureFournisseurSQLComponent extends TransfertBaseSQLComponent { |
private FactureFournisseurItemTable table = new FactureFournisseurItemTable(); |
private final JCheckBox checkImpression = new JCheckBox("Imprimer"); |
private final JCheckBox checkVisu = new JCheckBox("Visualiser"); |
private final ITextArea infos = new ITextArea(3, 3); |
private ElementComboBox fourn = new ElementComboBox(); |
private ElementComboBox comptePCE = new ElementComboBox(); |
private DefaultElementSQLObject compAdr; |
private PanelOOSQLComponent panelOO; |
final JPanel panelAdrSpec = new JPanel(new GridBagLayout()); |
private JDate dateCommande = new JDate(); |
148,6 → 150,7 |
c.gridwidth = 1; |
final ElementComboBox boxDevise = new ElementComboBox(); |
final JTextField fieldTaux = new JTextField(15); |
if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE, false)) { |
// Devise |
c.gridx = 0; |
156,7 → 159,7 |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c); |
c.gridx = GridBagConstraints.RELATIVE; |
c.gridx++; |
c.gridwidth = 1; |
c.weightx = 1; |
c.weighty = 0; |
163,7 → 166,25 |
c.fill = GridBagConstraints.NONE; |
this.add(boxDevise, c); |
this.addView(boxDevise, "ID_DEVISE"); |
if (getTable().contains("TAUX_APPLIQUE")) { |
// Devise |
c.gridx++; |
c.weightx = 0; |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(new JLabel(getLabelFor("TAUX_APPLIQUE"), SwingConstants.RIGHT), c); |
c.gridx++; |
c.gridwidth = 1; |
c.weightx = 1; |
c.weighty = 0; |
c.fill = GridBagConstraints.NONE; |
DefaultGridBagConstraints.lockMinimumSize(fieldTaux); |
this.add(fieldTaux, c); |
this.addView(fieldTaux, "TAUX_APPLIQUE"); |
} |
} |
// Compte pce |
c.gridx = 0; |
235,7 → 256,19 |
} |
}); |
fieldTaux.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
BigDecimal tauxConversion = null; |
if (fieldTaux.getText().trim().length() > 0) { |
tauxConversion = new BigDecimal(fieldTaux.getText()); |
} |
table.setTauxConversion(tauxConversion); |
} |
}); |
} |
this.fourn.addModelListener("wantedID", new PropertyChangeListener() { |
260,12 → 293,15 |
c.fill = GridBagConstraints.HORIZONTAL; |
c.anchor = GridBagConstraints.WEST; |
JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
panelOO.add(this.checkImpression, c); |
panelOO.add(this.checkVisu, c); |
c.gridx = 0; |
c.gridy++; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.SOUTHEAST; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(panelOO, c); |
this.panelOO = new PanelOOSQLComponent(this); |
this.add(this.panelOO, c); |
addSQLObject(textNom, "NOM"); |
addRequiredSQLObject(dateCommande, "DATE"); |
addRequiredSQLObject(numero, "NUMERO"); |
388,6 → 424,14 |
addRequiredSQLObject(fieldTTC, "T_TTC"); |
addRequiredSQLObject(fieldService, "T_SERVICE"); |
// Disable |
this.allowEditable("T_HT", false); |
this.allowEditable("T_TVA", false); |
this.allowEditable("T_TTC", false); |
this.allowEditable("T_SERVICE", false); |
this.allowEditable("T_POIDS", false); |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null, |
(getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null)); |
470,6 → 514,10 |
new GenerationMvtFactureFournisseur(getTable().getRow(idFacture)); |
final FactureFournisseurXmlSheet sheet = new FactureFournisseurXmlSheet(getTable().getRow(idFacture)); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); |
return idFacture; |
} |
492,6 → 540,9 |
} else { |
new GenerationMvtFactureFournisseur(row); |
} |
final FactureFournisseurXmlSheet sheet = new FactureFournisseurXmlSheet(row); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); |
} |
public void setDefaults() { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/SaisieAchatSQLComponent.java |
---|
420,9 → 420,7 |
e.printStackTrace(); |
} |
} |
new GenerationMvtSaisieAchat(getTable().getRow(id)); |
new Thread(new GenerationMvtSaisieAchat(getTable().getRow(id))).start(); |
return id; |
} |
530,7 → 528,7 |
eltEcr.archiveMouvementProfondeur(idMvt, false); |
// regenere les ecritures |
new GenerationMvtSaisieAchat(row, idMvt); |
new Thread(new GenerationMvtSaisieAchat(row, idMvt)).start(); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/component/CommandeSQLComponent.java |
---|
14,6 → 14,7 |
package org.openconcerto.erp.core.supplychain.order.component; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.component.AdresseSQLComponent; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement; |
21,15 → 22,18 |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.common.ui.TotalPanel; |
import org.openconcerto.erp.core.finance.tax.model.TaxeCache; |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement; |
import org.openconcerto.erp.core.supplychain.order.ui.CommandeItemTable; |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater; |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate; |
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet; |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel; |
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet; |
import org.openconcerto.erp.panel.PanelOOSQLComponent; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.erp.utils.TM; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.DefaultElementSQLObject; |
import org.openconcerto.sql.element.ElementSQLObject; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLBackgroundTableCache; |
import org.openconcerto.sql.model.SQLInjector; |
50,7 → 54,9 |
import org.openconcerto.ui.FormLayouter; |
import org.openconcerto.ui.JDate; |
import org.openconcerto.ui.TitledSeparator; |
import org.openconcerto.ui.component.ComboLockedMode; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.component.ITextCombo; |
import org.openconcerto.ui.preferences.DefaultProps; |
import org.openconcerto.utils.ExceptionHandler; |
82,10 → 88,10 |
public class CommandeSQLComponent extends TransfertBaseSQLComponent { |
private CommandeItemTable table = new CommandeItemTable(); |
private PanelOOSQLComponent panelOO; |
private JUniqueTextField numeroUniqueCommande; |
private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO"); |
private final JCheckBox checkImpression = new JCheckBox("Imprimer"); |
private final JCheckBox checkVisu = new JCheckBox("Visualiser"); |
private final ITextArea infos = new ITextArea(3, 3); |
private ElementComboBox fourn = new ElementComboBox(); |
final JCheckBox boxLivrClient = new JCheckBox("Livrer directement le client"); |
166,6 → 172,35 |
this.addRequiredSQLObject(boxEnCours, "EN_COURS"); |
} |
if (getTable().contains("DATE_RECEPTION_DEMANDEE")) { |
// Date |
JLabel labelDateRecptDemande = new JLabel(getLabelFor("DATE_RECEPTION_DEMANDEE")); |
labelDateRecptDemande.setHorizontalAlignment(SwingConstants.RIGHT); |
c.gridx = 0; |
c.gridy++; |
c.weightx = 0; |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(labelDateRecptDemande, c); |
c.gridx++; |
c.fill = GridBagConstraints.NONE; |
JDate dateRecptDemande = new JDate(); |
this.add(dateRecptDemande, c); |
this.addView(dateRecptDemande, "DATE_RECEPTION_DEMANDEE", REQ); |
JLabel labelDateRecptConfirme = new JLabel(getLabelFor("DATE_RECEPTION_CONFIRMEE")); |
labelDateRecptConfirme.setHorizontalAlignment(SwingConstants.RIGHT); |
c.gridx++; |
c.weightx = 0; |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(labelDateRecptConfirme, c); |
c.gridx++; |
c.fill = GridBagConstraints.NONE; |
JDate dateRecptConfirme = new JDate(); |
this.add(dateRecptConfirme, c); |
this.addView(dateRecptConfirme, "DATE_RECEPTION_CONFIRMEE"); |
} |
// Fournisseur |
if (getTable().contains("ID_CONTACT_FOURNISSEUR")) { |
c.gridx = 0; |
189,7 → 224,6 |
@Override |
public void propertyChange(PropertyChangeEvent arg0) { |
// TODO Raccord de méthode auto-généré |
if (fourn.getSelectedRow() != null) { |
boxContactFournisseur.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=", fourn.getSelectedRow().getID())); |
} else { |
224,7 → 258,8 |
// c.gridy++; |
this.addView("ID_ADRESSE"); |
final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp(); |
final ElementSQLObject componentPrincipale = (ElementSQLObject) this.getView("ID_ADRESSE"); |
((AdresseSQLComponent) componentPrincipale.getSQLChild()).setDestinataireVisible(true); |
final JCheckBox boxLivr = new JCheckBox("Livré par le fournisseur"); |
this.add(boxLivr, c); |
this.addSQLObject(boxLivr, "LIVRAISON_F"); |
416,7 → 451,7 |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c); |
c.gridx = GridBagConstraints.RELATIVE; |
c.gridx++; |
c.gridwidth = 1; |
c.weightx = 1; |
c.weighty = 0; |
428,7 → 463,6 |
@Override |
public void propertyChange(PropertyChangeEvent arg0) { |
// TODO Raccord de méthode auto-généré |
if (fourn.getSelectedRow() != null) { |
boxDevise.setValue(fourn.getSelectedRow().getForeignID("ID_DEVISE")); |
} else { |
437,8 → 471,29 |
} |
}); |
if (getTable().contains("INCOTERM")) { |
// Incoterm |
c.gridx++; |
c.weightx = 0; |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(new JLabel(getLabelFor("INCOTERM"), SwingConstants.RIGHT), c); |
c.gridx++; |
c.gridwidth = 1; |
c.weightx = 1; |
c.weighty = 0; |
c.fill = GridBagConstraints.NONE; |
ITextCombo box = new ITextCombo(ComboLockedMode.LOCKED); |
for (String s : ReferenceArticleSQLElement.CONDITIONS) { |
box.addItem(s); |
} |
this.add(box, c); |
this.addView(box, "INCOTERM", REQ); |
} |
} |
// Reference |
c.gridx = 0; |
c.gridy++; |
485,7 → 540,6 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
table.setDevise(boxDevise.getSelectedRow()); |
} |
}); |
} |
504,15 → 558,13 |
c.gridx = 0; |
c.gridy++; |
c.fill = GridBagConstraints.HORIZONTAL; |
c.anchor = GridBagConstraints.WEST; |
JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
panelOO.add(this.checkImpression, c); |
panelOO.add(this.checkVisu, c); |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.SOUTHEAST; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(panelOO, c); |
this.panelOO = new PanelOOSQLComponent(this); |
this.add(this.panelOO, c); |
addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR"); |
addSQLObject(textNom, "NOM"); |
addRequiredSQLObject(dateCommande, "DATE"); |
655,6 → 707,14 |
addRequiredSQLObject(fieldTTC, "T_TTC"); |
addRequiredSQLObject(fieldService, "T_SERVICE"); |
// Disable |
this.allowEditable("T_HT", false); |
this.allowEditable("T_TVA", false); |
this.allowEditable("T_TTC", false); |
this.allowEditable("T_SERVICE", false); |
final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT, textRemiseHT, fieldService, null, fieldDevise, null, null, |
(getTable().contains("ID_TAXE_PORT") ? comboTaxePort : null)); |
700,7 → 760,6 |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
// TODO Raccord de méthode auto-généré |
totalTTC.updateTotal(); |
} |
}); |
747,7 → 806,7 |
// generation du document |
final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(idCommande)); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(this.checkVisu.isSelected(), this.checkImpression.isSelected(), true); |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); |
// incrémentation du numéro auto |
if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.numeroUniqueCommande.getText().trim())) { |
778,7 → 837,7 |
public void select(SQLRowAccessor r) { |
if (!getTable().contains("LIVRAISON_F") && r != null && !r.isUndefined()) { |
SQLRowAccessor adr = r.getForeign("ID_ADRESSE"); |
SQLRowAccessor adr = (r.getFields().contains("ID_ADRESSE") ? r.getForeign("ID_ADRESSE") : null); |
boxLivrClient.setSelected(adr != null && !adr.isUndefined()); |
panelAdrSpec.setVisible(boxLivrClient.isSelected()); |
842,7 → 901,7 |
// generation du document |
final CommandeXmlSheet sheet = new CommandeXmlSheet(getTable().getRow(id)); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(this.checkVisu.isSelected(), this.checkImpression.isSelected(), true); |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/FactureFournisseurSQLElement.java |
---|
13,20 → 13,25 |
package org.openconcerto.erp.core.supplychain.order.element; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.supplychain.order.component.FactureFournisseurSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
import java.util.ArrayList; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.supplychain.order.component.FactureFournisseurSQLComponent; |
import org.openconcerto.erp.generationDoc.gestcomm.FactureFournisseurXmlSheet; |
import org.openconcerto.erp.model.MouseSheetXmlListeListener; |
import org.openconcerto.sql.element.SQLComponent; |
public class FactureFournisseurSQLElement extends ComptaSQLConfElement { |
public FactureFournisseurSQLElement() { |
super("FACTURE_FOURNISSEUR", "une facture fournisseur", "factures fournisseur"); |
MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(FactureFournisseurXmlSheet.class); |
mouseSheetXmlListeListener.setGenerateHeader(true); |
mouseSheetXmlListeListener.setShowHeader(true); |
getRowActions().addAll(mouseSheetXmlListeListener.getRowActions()); |
} |
protected List<String> getListFields() { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/element/CommandeSQLElement.java |
---|
22,6 → 22,7 |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.element.TreesOfSQLRows; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.view.EditFrame; |
28,6 → 29,7 |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.utils.ExceptionHandler; |
import java.awt.event.ActionEvent; |
import java.sql.SQLException; |
57,7 → 59,21 |
factureAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
getRowActions().add(factureAction); |
PredicateRowAction tagValidAction = new PredicateRowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
final SQLRowValues asRowValues = IListe.get(e).getSelectedRow().asRow().createEmptyUpdateRow(); |
asRowValues.put("EN_COURS", Boolean.FALSE); |
try { |
asRowValues.commit(); |
} catch (SQLException e1) { |
ExceptionHandler.handle("Une erreur est survenue pour notifier la commande valider", e1); |
} |
} |
}, false, "supplychain.order.valid"); |
tagValidAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
getRowActions().add(tagValidAction); |
} |
protected List<String> getListFields() { |
final List<String> l = new ArrayList<String>(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/order/action/ListeDesCommandesAction.java |
---|
13,26 → 13,49 |
package org.openconcerto.erp.core.supplychain.order.action; |
import java.awt.event.ActionEvent; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.List; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.Action; |
import javax.swing.JFrame; |
import org.openconcerto.erp.action.CreateFrameAbstractAction; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent; |
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet; |
import org.openconcerto.erp.model.MouseSheetXmlListeListener; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.FieldPath; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLRowValuesListFetcher; |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.SQLSelectJoin; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.model.graph.Path; |
import org.openconcerto.sql.model.graph.PathBuilder; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.ListeAddPanel; |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
import org.openconcerto.ui.table.PercentTableCellRenderer; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.DecimalUtils; |
import org.openconcerto.utils.cc.ITransformer; |
import java.awt.event.ActionEvent; |
import java.util.ArrayList; |
import java.util.List; |
import javax.swing.AbstractAction; |
import javax.swing.Action; |
import javax.swing.JFrame; |
public class ListeDesCommandesAction extends CreateFrameAbstractAction { |
public ListeDesCommandesAction() { |
super(); |
40,8 → 63,28 |
} |
public JFrame createFrame() { |
final IListFrame frame = new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("COMMANDE"))); |
final SQLElement elementCmd = Configuration.getInstance().getDirectory().getElement("COMMANDE"); |
final SQLTableModelSourceOnline tableSource = elementCmd.getTableSource(true); |
BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement réception", BigDecimal.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
return getAvancement(r); |
} |
@Override |
public Set<FieldPath> getPaths() { |
final Path p = new PathBuilder(elementCmd.getTable()).addTable("TR_COMMANDE").addTable("BON_RECEPTION").build(); |
return CollectionUtils.createSet(new FieldPath(p, "TOTAL_HT")); |
} |
}; |
tableSource.getColumns().add(colAvancement); |
colAvancement.setRenderer(new PercentTableCellRenderer()); |
final IListFrame frame = new IListFrame(new ListeAddPanel(elementCmd, new IListe(tableSource))); |
frame.getPanel().getListe().addIListeActions(new MouseSheetXmlListeListener(CommandeXmlSheet.class) { |
@Override |
public List<RowAction> addToMenu() { |
48,8 → 91,34 |
// Transfert vers BR |
PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).getSelectedRows(), "BON_RECEPTION"); |
final List<SQLRowValues> selectedRows = IListe.get(e).getSelectedRows(); |
EditFrame f = TransfertBaseSQLComponent.openTransfertFrame(selectedRows, "BON_RECEPTION"); |
BonReceptionSQLComponent comp = (BonReceptionSQLComponent) f.getSQLComponent(); |
final SQLTable tableElt = comp.getElement().getTable().getTable("BON_RECEPTION_ELEMENT"); |
SQLRowValues rowVals = new SQLRowValues(tableElt); |
rowVals.put("QTE_UNITAIRE", null); |
rowVals.put("QTE", null); |
rowVals.put("ID_ARTICLE", null); |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals); |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() { |
@Override |
public SQLSelect transformChecked(SQLSelect input) { |
List<Integer> ids = new ArrayList<Integer>(selectedRows.size()); |
for (SQLRowValues sqlRowValues : selectedRows) { |
ids.add(sqlRowValues.getID()); |
} |
SQLSelectJoin joinBR = input.addJoin("RIGHT", tableElt.getTable("BON_RECEPTION_ELEMENT").getField("ID_BON_RECEPTION")); |
SQLSelectJoin joinTR = input.addBackwardJoin("RIGHT", tableElt.getTable("TR_COMMANDE").getField("ID_BON_RECEPTION"), joinBR.getJoinedTable().getAlias()); |
joinTR.setWhere(new Where(joinTR.getJoinedTable().getField("ID_COMMANDE"), ids)); |
System.err.println(input.asString()); |
return input; |
} |
}); |
comp.loadQuantity(fetcher.fetch()); |
} |
}, false, "supplychain.order.create.receipt"); |
bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
63,4 → 132,22 |
return frame; |
} |
private BigDecimal getAvancement(SQLRowAccessor r) { |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE")); |
long totalFact = 0; |
long total = r.getLong("T_HT"); |
for (SQLRowAccessor row : rows) { |
if (!row.isForeignEmpty("ID_BON_RECEPTION")) { |
SQLRowAccessor rowFact = row.getForeign("ID_BON_RECEPTION"); |
Long l = rowFact.getLong("TOTAL_HT"); |
totalFact += l; |
} |
} |
if (total > 0) { |
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP); |
} else { |
return BigDecimal.ONE.movePointRight(2); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/action/ListeDesReliquatsBonsReceptionsAction.java |
---|
New file |
0,0 → 1,56 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.erp.core.supplychain.receipt.action; |
import javax.swing.Action; |
import javax.swing.JFrame; |
import org.openconcerto.erp.action.CreateFrameAbstractAction; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.ListeAddPanel; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
public class ListeDesReliquatsBonsReceptionsAction extends CreateFrameAbstractAction { |
public ListeDesReliquatsBonsReceptionsAction() { |
super(); |
this.putValue(Action.NAME, "Liste des reliquats de bons de réceptions"); |
} |
public JFrame createFrame() { |
final SQLElement element = Configuration.getInstance().getDirectory().getElement("RELIQUAT_BR"); |
final SQLTableModelSourceOnline tableSource = element.getTableSource(true); |
final IListFrame frame = new IListFrame(new ListeAddPanel(element, new IListe(tableSource))); |
// // Date panel |
// IListFilterDatePanel datePanel = new IListFilterDatePanel(frame.getPanel().getListe(), |
// element.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap()); |
// GridBagConstraints c = new DefaultGridBagConstraints(); |
// c.gridwidth = GridBagConstraints.REMAINDER; |
// c.fill = GridBagConstraints.NONE; |
// c.weightx = 0; |
// c.gridy++; |
// c.gridy++; |
// c.anchor = GridBagConstraints.CENTER; |
// datePanel.setFilterOnDefault(); |
// frame.getPanel().add(datePanel, c); |
return frame; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/action/ListeDesBonsReceptionsAction.java |
---|
15,19 → 15,34 |
import org.openconcerto.erp.action.CreateFrameAbstractAction; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel; |
import org.openconcerto.erp.core.supplychain.receipt.element.BonReceptionSQLElement; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.FieldPath; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.graph.Path; |
import org.openconcerto.sql.model.graph.PathBuilder; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.ListeAddPanel; |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.ui.table.PercentTableCellRenderer; |
import org.openconcerto.utils.CollectionUtils; |
import org.openconcerto.utils.DecimalUtils; |
import java.awt.GridBagConstraints; |
import java.awt.event.ActionEvent; |
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseEvent; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.util.Collection; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.Action; |
43,33 → 58,27 |
public JFrame createFrame() { |
final SQLElement element = Configuration.getInstance().getDirectory().getElement("BON_RECEPTION"); |
final IListFrame frame = new IListFrame(new ListeAddPanel(element)); |
frame.getPanel().getListe().getJTable().addMouseListener(new MouseAdapter() { |
final SQLTableModelSourceOnline tableSource = element.getTableSource(true); |
public void mousePressed(MouseEvent mouseEvent) { |
BaseSQLTableModelColumn colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) { |
if (mouseEvent.getButton() == MouseEvent.BUTTON3 && frame.getPanel().getListe().getSelectedId() > 1) { |
System.err.println("Display Menu"); |
JPopupMenu menuDroit = new JPopupMenu(); |
@Override |
protected Object show_(SQLRowAccessor r) { |
final SQLRow rowCmd = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete().getTable("BON_RECEPTION").getRow(frame.getPanel().getListe().getSelectedId()); |
return getAvancement(r); |
} |
// Transfert vers facture |
AbstractAction factureAction = (new AbstractAction("Transfert vers facture") { |
public void actionPerformed(ActionEvent e) { |
transfertFactureFournisseur(rowCmd); |
@Override |
public Set<FieldPath> getPaths() { |
final Path p = new PathBuilder(element.getTable()).addTable("TR_BON_RECEPTION").addTable("FACTURE_FOURNISSEUR").build(); |
return CollectionUtils.createSet(new FieldPath(p, "T_HT")); |
} |
}); |
}; |
tableSource.getColumns().add(colAvancement); |
colAvancement.setRenderer(new PercentTableCellRenderer()); |
menuDroit.add(factureAction); |
final IListFrame frame = new IListFrame(new ListeAddPanel(element, new IListe(tableSource))); |
menuDroit.pack(); |
menuDroit.show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y); |
menuDroit.setVisible(true); |
} |
} |
}); |
// Date panel |
IListFilterDatePanel datePanel = new IListFilterDatePanel(frame.getPanel().getListe(), element.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap()); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
85,6 → 94,24 |
return frame; |
} |
private BigDecimal getAvancement(SQLRowAccessor r) { |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_BON_RECEPTION")); |
long totalFact = 0; |
long total = (r.getObject("TOTAL_HT") == null ? 0 : r.getLong("TOTAL_HT")); |
for (SQLRowAccessor row : rows) { |
if (!row.isForeignEmpty("ID_FACTURE_FOURNISSEUR")) { |
SQLRowAccessor rowFact = row.getForeign("ID_FACTURE_FOURNISSEUR"); |
Long l = rowFact.getLong("T_HT"); |
totalFact += l; |
} |
} |
if (total > 0) { |
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP); |
} else { |
return BigDecimal.ONE.movePointRight(2); |
} |
} |
/** |
* Transfert en Facture |
* |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/ui/BonReceptionItemTable.java |
---|
13,12 → 13,24 |
package org.openconcerto.erp.core.supplychain.receipt.ui; |
import java.awt.event.ActionEvent; |
import java.math.BigDecimal; |
import java.util.ArrayList; |
import java.util.List; |
import javax.swing.AbstractAction; |
import org.openconcerto.erp.core.common.ui.AbstractAchatArticleItemTable; |
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
public class BonReceptionItemTable extends AbstractAchatArticleItemTable { |
private ReliquatRowValuesTable reliquatTable; |
@Override |
protected String getConfigurationFileName() { |
return "Table_Bon_Reception.xml"; |
25,8 → 37,41 |
} |
public void setReliquatTable(ReliquatRowValuesTable reliquatTable) { |
this.reliquatTable = reliquatTable; |
} |
@Override |
public SQLElement getSQLElement() { |
return Configuration.getInstance().getDirectory().getElement("BON_RECEPTION_ELEMENT"); |
} |
@Override |
public boolean isUsedBiasedDevise() { |
return false; |
} |
@Override |
protected List<AbstractAction> getAdditionnalMouseAction(final int rowIndex) { |
List<AbstractAction> actions = new ArrayList<AbstractAction>(); |
actions.addAll(super.getAdditionnalMouseAction(rowIndex)); |
actions.add(new AbstractAction("Ajouter un reliquat") { |
@Override |
public void actionPerformed(ActionEvent e) { |
if (reliquatTable != null) { |
SQLRowAccessor sqlRowArticleChildElement = getRowValuesTable().getRowValuesTableModel().getRowValuesAt(rowIndex); |
final SQLRowValues row2Insert = new SQLRowValues(reliquatTable.getDefaultRowValues()); |
row2Insert.put("ID_BON_RECEPTION_ELEMENT", sqlRowArticleChildElement); |
row2Insert.put("QTE", 1); |
row2Insert.put("QTE_UNITAIRE", BigDecimal.ONE); |
reliquatTable.getRowValuesTable().getRowValuesTableModel().addRow(row2Insert); |
} |
} |
}); |
return actions; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/component/BonReceptionSQLComponent.java |
---|
13,6 → 13,32 |
package org.openconcerto.erp.core.supplychain.receipt.component; |
import java.awt.Color; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.Insets; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.sql.SQLException; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JSeparator; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
import javax.swing.SwingUtilities; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
import org.apache.commons.dbutils.handlers.ArrayListHandler; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
19,11 → 45,13 |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement; |
import org.openconcerto.erp.core.supplychain.receipt.element.BonReceptionSQLElement; |
import org.openconcerto.erp.core.sales.product.ui.ReliquatRowValuesTable; |
import org.openconcerto.erp.core.supplychain.receipt.ui.BonReceptionItemTable; |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater; |
import org.openconcerto.erp.core.supplychain.stock.element.StockItemsUpdater.TypeStockUpdate; |
import org.openconcerto.erp.core.supplychain.stock.element.StockLabel; |
import org.openconcerto.erp.generationDoc.gestcomm.BonReceptionXmlSheet; |
import org.openconcerto.erp.panel.PanelOOSQLComponent; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
49,32 → 77,9 |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.GestionDevise; |
import java.awt.Color; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.Insets; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.sql.SQLException; |
import java.util.List; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JSeparator; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
import javax.swing.SwingUtilities; |
import javax.swing.event.TableModelEvent; |
import javax.swing.event.TableModelListener; |
import org.apache.commons.dbutils.handlers.ArrayListHandler; |
public class BonReceptionSQLComponent extends TransfertBaseSQLComponent { |
private BonReceptionItemTable tableBonItem; |
private ReliquatRowValuesTable tableBonReliquatItem; |
private ElementComboBox selectCommande; |
private ElementComboBox fournisseur; |
private JUniqueTextField textNumeroUnique; |
84,6 → 89,7 |
private final DeviseField textTotalTTC = new DeviseField(); |
private final JTextField textPoidsTotal = new JTextField(6); |
private final JTextField textReference = new JTextField(25); |
private PanelOOSQLComponent panelOO; |
private JDate date = new JDate(true); |
public BonReceptionSQLComponent() { |
340,6 → 346,30 |
this.add(panelTotalTTC, c); |
c.anchor = GridBagConstraints.WEST; |
if (getTable().getDBRoot().contains("RELIQUAT_BR")) { |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.weightx = 1; |
c.fill = GridBagConstraints.HORIZONTAL; |
c.gridx = 0; |
c.gridy++; |
TitledSeparator sep = new TitledSeparator("Reliquat de kits"); |
c.insets = new Insets(10, 2, 1, 2); |
this.add(sep, c); |
c.insets = new Insets(2, 2, 1, 2); |
// Reliquat du bon |
this.tableBonReliquatItem = new ReliquatRowValuesTable("RELIQUAT_BR"); |
c.gridx = 0; |
c.gridy++; |
c.weightx = 1; |
c.weighty = 1; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.fill = GridBagConstraints.BOTH; |
this.add(this.tableBonReliquatItem, c); |
this.tableBonItem.setReliquatTable(tableBonReliquatItem); |
} |
/******************************************************************************************* |
* * INFORMATIONS COMPLEMENTAIRES |
******************************************************************************************/ |
366,6 → 396,15 |
this.add(textInfos, c); |
c.gridx = 0; |
c.gridy++; |
c.fill = GridBagConstraints.NONE; |
c.anchor = GridBagConstraints.SOUTHEAST; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.panelOO = new PanelOOSQLComponent(this); |
this.add(this.panelOO, c); |
this.addRequiredSQLObject(date, "DATE"); |
this.addSQLObject(textInfos, "INFOS"); |
this.addSQLObject(this.textReference, "NOM"); |
416,7 → 455,9 |
idBon = super.insert(order); |
try { |
this.tableBonItem.updateField("ID_BON_RECEPTION", idBon); |
if (this.tableBonReliquatItem != null) { |
this.tableBonReliquatItem.updateField("ID_BON_RECEPTION_ORIGINE", idBon); |
} |
this.tableBonItem.createArticle(idBon, this.getElement()); |
// incrémentation du numéro auto |
441,6 → 482,11 |
} |
} |
}); |
// generation du document |
final BonReceptionXmlSheet sheet = new BonReceptionXmlSheet(getTable().getRow(idBonFinal)); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); |
} catch (Exception e) { |
throw new IllegalStateException(e); |
} |
461,6 → 507,46 |
return this.tableBonItem.getRowValuesTable(); |
} |
public void loadFromReliquat(List<SQLRowValues> l) { |
this.tableBonItem.insertFromReliquat(l); |
this.tableBonItem.setEnabled(false); |
} |
public void loadQuantity(List<SQLRowValues> l) { |
Map<Integer, SQLRowValues> map = new HashMap<Integer, SQLRowValues>(); |
for (SQLRowValues sqlRowValues : l) { |
if (!sqlRowValues.isForeignEmpty("ID_ARTICLE")) { |
final int foreignID = sqlRowValues.getForeignID("ID_ARTICLE"); |
if (!map.containsKey(foreignID)) { |
map.put(foreignID, sqlRowValues); |
} else { |
SQLRowValues vals = map.get(foreignID); |
if (sqlRowValues.getInt("QTE") > 0) { |
if (sqlRowValues.getBigDecimal("QTE_UNITAIRE").equals(BigDecimal.ONE) || sqlRowValues.getInt("QTE") > 1) { |
vals.put("QTE", vals.getInt("QTE") + sqlRowValues.getInt("QTE")); |
} else { |
vals.put("QTE_UNITAIRE", vals.getBigDecimal("QTE_UNITAIRE").add(sqlRowValues.getBigDecimal("QTE_UNITAIRE"))); |
} |
} |
} |
} |
} |
int count = this.tableBonItem.getModel().getRowCount(); |
for (int i = 0; i < count; i++) { |
SQLRowValues r = this.tableBonItem.getModel().getRowValuesAt(i); |
SQLRowValues rowTR = map.get(r.getForeignID("ID_ARTICLE")); |
if (rowTR != null && !rowTR.isUndefined()) { |
if (r.getInt("QTE") > 0) { |
if (r.getBigDecimal("QTE_UNITAIRE").equals(BigDecimal.ONE) || r.getInt("QTE") > 1) { |
this.tableBonItem.getModel().putValue(r.getInt("QTE") - rowTR.getInt("QTE"), i, "QTE"); |
} else { |
this.tableBonItem.getModel().putValue(r.getBigDecimal("QTE_UNITAIRE").subtract(rowTR.getBigDecimal("QTE_UNITAIRE")), i, "QTE_UNITAIRE"); |
} |
} |
} |
} |
} |
@Override |
public void update() { |
477,6 → 563,9 |
// Mise à jour de l'élément |
super.update(); |
this.tableBonItem.updateField("ID_BON_RECEPTION", getSelectedID()); |
if (tableBonReliquatItem != null) { |
this.tableBonReliquatItem.updateField("ID_BON_RECEPTION_ORIGINE", getSelectedID()); |
} |
this.tableBonItem.createArticle(getSelectedID(), this.getElement()); |
final int id = getSelectedID(); |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() { |
509,6 → 598,10 |
} |
} |
}); |
// generation du document |
final BonReceptionXmlSheet sheet = new BonReceptionXmlSheet(getTable().getRow(id)); |
sheet.createDocumentAsynchronous(); |
sheet.showPrintAndExportAsynchronous(this.panelOO.isVisualisationSelected(), this.panelOO.isImpressionSelected(), true); |
} |
} |
605,11 → 698,29 |
}, row, row.getReferentRows(getTable().getTable("BON_RECEPTION_ELEMENT")), |
getTable().contains("CREATE_VIRTUAL_STOCK") && row.getBoolean("CREATE_VIRTUAL_STOCK") ? TypeStockUpdate.REAL_VIRTUAL_RECEPT : TypeStockUpdate.REAL_RECEPT); |
if (getTable().getDBRoot().contains("RELIQUAT_BR")) { |
List<SQLRow> l = row.getReferentRows(getTable().getTable("RELIQUAT_BR")); |
for (SQLRow sqlRow : l) { |
stockUpdater.addReliquat(sqlRow.getForeign("ID_ARTICLE"), sqlRow.getInt("QTE"), sqlRow.getBigDecimal("QTE_UNITAIRE")); |
} |
} |
stockUpdater.update(); |
} |
@Override |
public void select(SQLRowAccessor r) { |
super.select(r); |
if (this.tableBonReliquatItem != null) { |
this.tableBonReliquatItem.getRowValuesTable().clear(); |
if (r != null) { |
this.tableBonReliquatItem.getRowValuesTable().insertFrom("ID_BON_RECEPTION_ORIGINE", r.asRowValues()); |
} |
} |
} |
@Override |
protected void refreshAfterSelect(SQLRowAccessor rSource) { |
if (this.date.getValue() != null) { |
this.tableBonItem.setDateDevise(this.date.getValue()); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/receipt/element/BonReceptionSQLElement.java |
---|
13,10 → 13,26 |
package org.openconcerto.erp.core.supplychain.receipt.element; |
import java.awt.event.ActionEvent; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.ImageIcon; |
import javax.swing.JFrame; |
import org.apache.commons.dbutils.handlers.ArrayListHandler; |
import org.openconcerto.erp.config.Gestion; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.supplychain.order.component.SaisieAchatSQLComponent; |
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent; |
import org.openconcerto.erp.generationDoc.gestcomm.BonReceptionXmlSheet; |
import org.openconcerto.erp.model.MouseSheetXmlListeListener; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.element.SQLElement; |
25,29 → 41,52 |
import org.openconcerto.sql.model.SQLSelect; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.utils.CollectionMap; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import javax.swing.ImageIcon; |
import javax.swing.JFrame; |
import org.apache.commons.dbutils.handlers.ArrayListHandler; |
public class BonReceptionSQLElement extends ComptaSQLConfElement { |
public BonReceptionSQLElement() { |
super("BON_RECEPTION", "un bon de réception", "Bons de réception"); |
PredicateRowAction actionsTRFA = new PredicateRowAction(new AbstractAction("Transfert vers facture fournisseur") { |
public void actionPerformed(ActionEvent e) { |
TransfertBaseSQLComponent.openTransfertFrame(IListe.get(e).getSelectedRows(), "FACTURE_FOURNISSEUR"); |
} |
}, true); |
actionsTRFA.setPredicate(IListeEvent.getNonEmptySelectionPredicate()); |
PredicateRowAction actionTRSimple = new PredicateRowAction(new AbstractAction("Transfert vers facture simple") { |
public void actionPerformed(ActionEvent e) { |
transfertFacture(IListe.get(e).getSelectedRow().getID()); |
} |
}, false); |
actionTRSimple.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
getRowActions().add(actionsTRFA); |
getRowActions().add(actionTRSimple); |
MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(BonReceptionXmlSheet.class); |
mouseSheetXmlListeListener.setGenerateHeader(true); |
mouseSheetXmlListeListener.setShowHeader(true); |
getRowActions().addAll(mouseSheetXmlListeListener.getRowActions()); |
} |
@Override |
public CollectionMap<String, String> getShowAs() { |
final CollectionMap<String, String> res = new CollectionMap<String, String>(); |
res.putAll(null, "NUMERO", "DATE"); |
return res; |
} |
protected List<String> getListFields() { |
final List<String> l = new ArrayList<String>(); |
l.add("NUMERO"); |
l.add("DATE"); |
l.add("ID_FOURNISSEUR"); |
l.add("TOTAL_HT"); |
l.add("INFOS"); |
return l; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockItem.java |
---|
90,8 → 90,9 |
/ (stockItemComponent.getQty() * stockItemComponent.getQtyUnit().doubleValue()))); |
} |
this.realQty = real; |
this.virtualQty = virtual; |
// La quantité du kit ne peut être négative |
this.realQty = Math.max(0, real); |
this.virtualQty = Math.max(0, virtual); |
} |
public void fillCommandeFournisseur(ListMap<SQLRow, SQLRowValues> cmd) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/stock/element/StockItemsUpdater.java |
---|
13,10 → 13,27 |
package org.openconcerto.erp.core.supplychain.stock.element; |
import java.awt.GraphicsEnvironment; |
import java.io.IOException; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.sql.SQLException; |
import java.text.SimpleDateFormat; |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.List; |
import javax.swing.JOptionPane; |
import javax.swing.SwingUtilities; |
import org.apache.commons.dbutils.ResultSetHandler; |
import org.openconcerto.erp.core.sales.product.model.ProductComponent; |
import org.openconcerto.erp.core.sales.product.model.ProductHelper; |
import org.openconcerto.erp.core.supplychain.stock.element.StockItem.TypeStockMouvement; |
import org.openconcerto.sql.model.ConnectionHandlerNoSetup; |
import org.openconcerto.sql.model.DBRoot; |
import org.openconcerto.sql.model.SQLDataSource; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.model.SQLRowValues; |
25,24 → 42,13 |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.utils.SQLUtils; |
import org.openconcerto.utils.DecimalUtils; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.ListMap; |
import org.openconcerto.utils.RTInterruptedException; |
import org.openconcerto.utils.Tuple3; |
import org.openconcerto.utils.cc.ITransformer; |
import java.awt.GraphicsEnvironment; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.sql.SQLException; |
import java.text.SimpleDateFormat; |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.List; |
import javax.swing.JOptionPane; |
import javax.swing.SwingUtilities; |
import org.apache.commons.dbutils.ResultSetHandler; |
public class StockItemsUpdater { |
private final StockLabel label; |
96,6 → 102,12 |
this.headless = headless; |
} |
List<Tuple3<SQLRowAccessor, Integer, BigDecimal>> reliquat = new ArrayList<Tuple3<SQLRowAccessor, Integer, BigDecimal>>(); |
public void addReliquat(SQLRowAccessor article, int qte, BigDecimal qteUnit) { |
reliquat.add(Tuple3.create(article, qte, qteUnit)); |
} |
List<String> requests = new ArrayList<String>(); |
public void update() throws SQLException { |
111,6 → 123,7 |
final ListMap<SQLRow, SQLRowValues> cmd = new ListMap<SQLRow, SQLRowValues>(); |
for (StockItem stockItem : stockItems) { |
if (stockItem.isStockInit()) { |
requests.add(stockItem.getUpdateRequest()); |
} else { |
126,12 → 139,22 |
stockItem.fillCommandeFournisseur(cmd); |
} |
List<? extends ResultSetHandler> handlers = new ArrayList<ResultSetHandler>(requests.size()); |
final List<? extends ResultSetHandler> handlers = new ArrayList<ResultSetHandler>(requests.size()); |
for (String s : requests) { |
handlers.add(null); |
} |
// FIXME FIRE TABLE CHANGED TO UPDATE ILISTE ?? |
try { |
SQLUtils.executeAtomic(stockTable.getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() { |
@Override |
public Object handle(SQLDataSource ds) throws SQLException, IOException { |
SQLUtils.executeMultiple(stockTable.getDBSystemRoot(), requests, handlers); |
return null; |
} |
}); |
} catch (IOException e) { |
ExceptionHandler.handle("Erreur de la mise à jour des stocks!", e); |
} |
final DBRoot root = this.rowSource.getTable().getDBRoot(); |
if (root.contains("ARTICLE_ELEMENT")) { |
224,6 → 247,7 |
for (int i = index; i < items.size(); i++) { |
SQLRowAccessor r = items.get(i); |
if (!r.getTable().contains("NIVEAU") || r.getInt("NIVEAU") >= 1) { |
// On ne calcul pas les stocks pour les éléments ayant des fils (le mouvement de |
// stock |
// des fils impactera les stocks automatiquement) |
242,6 → 266,7 |
} |
} |
} |
} |
/** |
* Récupére les stocks associés aux articles non composés (inclus les fils des nomenclatures) et |
284,12 → 309,19 |
if (productComp.getProduct().getBoolean("GESTION_STOCK")) { |
StockItem stockItem = new StockItem(productComp.getProduct()); |
double qteFinal = productComp.getQty().doubleValue(); |
// reliquat |
for (Tuple3<SQLRowAccessor, Integer, BigDecimal> t : reliquat) { |
if (stockItem.getArticle() != null && stockItem.getArticle().equalsAsRow(t.get0())) { |
double qteFinalReliquat = t.get2().multiply(new BigDecimal(t.get1()), DecimalUtils.HIGH_PRECISION).doubleValue(); |
qteFinal -= qteFinalReliquat; |
} |
} |
if (!this.type.isEntry()) { |
qteFinal = -qteFinal; |
} |
stockItem.updateQty(qteFinal, this.type.getType()); |
stockItems.add(stockItem); |
if (this.createMouvementStock) { |
final Date time = this.rowSource.getDate("DATE").getTime(); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/component/MouvementStockSQLComponent.java |
---|
17,6 → 17,7 |
import org.openconcerto.sql.element.BaseSQLComponent; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.sqlobject.SQLTextCombo; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
113,6 → 114,13 |
} |
@Override |
protected SQLRowValues createDefaults() { |
SQLRowValues rowVals = new SQLRowValues(getTable()); |
rowVals.put("REEL", Boolean.TRUE); |
return rowVals; |
} |
@Override |
public int insert(SQLRow order) { |
int id = super.insert(order); |
((MouvementStockSQLElement) getElement()).updateStock(Arrays.asList(getTable().getRow(id)), false); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/supplychain/supplier/component/FournisseurSQLComponent.java |
---|
16,19 → 16,6 |
*/ |
package org.openconcerto.erp.core.supplychain.supplier.component; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.event.ActionListener; |
import java.sql.SQLException; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable; |
54,6 → 41,20 |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.component.InteractionMode; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.event.ActionListener; |
import java.sql.SQLException; |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JScrollPane; |
import javax.swing.JTabbedPane; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
public class FournisseurSQLComponent extends BaseSQLComponent { |
public FournisseurSQLComponent(SQLElement elt) { |
193,6 → 194,37 |
this.addView(devise, "ID_DEVISE"); |
} |
if (getTable().contains("ALG_REGISTRE")) { |
c.gridy++; |
c.gridx = 0; |
c.weightx = 0; |
this.add(new JLabel(getLabelFor("ALG_REGISTRE"), SwingConstants.RIGHT), c); |
c.gridx++; |
c.weightx = 1; |
JTextField fieldRegistre = new JTextField(20); |
this.add(fieldRegistre, c); |
this.addView(fieldRegistre, "ALG_REGISTRE"); |
c.gridx++; |
c.weightx = 0; |
this.add(new JLabel(getLabelFor("ALG_MATRICULE"), SwingConstants.RIGHT), c); |
c.gridx++; |
c.weightx = 1; |
JTextField fieldMatricule = new JTextField(20); |
this.add(fieldMatricule, c); |
this.addView(fieldMatricule, "ALG_MATRICULE"); |
c.gridy++; |
c.gridx = 0; |
c.weightx = 0; |
this.add(new JLabel(getLabelFor("ALG_ARTICLE"), SwingConstants.RIGHT), c); |
c.gridx++; |
c.weightx = 1; |
JTextField fieldArticle = new JTextField(20); |
this.add(fieldArticle, c); |
this.addView(fieldArticle, "ALG_ARTICLE"); |
} |
// Champ Module |
c.gridx = 0; |
c.gridy++; |
201,6 → 233,9 |
this.setAdditionalFieldsPanel(new FormLayouter(addP, 2)); |
this.add(addP, c); |
// Tabbed |
JTabbedPane tabbedPane = new JTabbedPane(); |
JPanel panelAdresse = new JPanel(new GridBagLayout()); |
GridBagConstraints cAdr = new DefaultGridBagConstraints(); |
// Adresse |
216,6 → 251,8 |
this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP); |
cAdr.gridy++; |
cAdr.fill = GridBagConstraints.HORIZONTAL; |
cAdr.weightx = 1; |
panelAdresse.add((ElementSQLObject) this.getView("ID_ADRESSE"), cAdr); |
// Selection de 2eme adresse |
225,22 → 262,13 |
this.comp2.setCreated(true); |
panelAdresse.add(this.comp2, cAdr); |
c.gridx = 0; |
c.gridy++; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.weightx = 1; |
c.fill = GridBagConstraints.NONE; |
this.add(panelAdresse, c); |
c.gridx = 0; |
c.gridy++; |
c.weightx = 0; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.fill = GridBagConstraints.NONE; |
this.checkEnlevement = new JCheckBox("Adresse d'enlèvement identique"); |
cAdr.gridx = 0; |
cAdr.gridy++; |
cAdr.gridwidth = GridBagConstraints.REMAINDER; |
panelAdresse.add(this.checkEnlevement, cAdr); |
tabbedPane.add("Adresses", panelAdresse); |
this.add(this.checkEnlevement, c); |
c.fill = GridBagConstraints.HORIZONTAL; |
this.checkEnlevement.setSelected(true); |
this.sep2.setVisible(false); |
this.checkEnlevement.addActionListener(new ActionListener() { |
262,21 → 290,22 |
}); |
// Contact |
final TitledSeparator sepContact = new TitledSeparator("Contacts fournisseurs"); |
c.weightx = 1; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.gridx = 0; |
c.gridy++; |
this.add(sepContact, c); |
JPanel panelContact = new JPanel(new GridBagLayout()); |
this.table = new ContactItemTable(this.defaultContactRowVals); |
this.table.setPreferredSize(new Dimension(this.table.getSize().width, 150)); |
GridBagConstraints cContact = new DefaultGridBagConstraints(); |
cContact.fill = GridBagConstraints.BOTH; |
cContact.weightx = 1; |
cContact.weighty = 1; |
panelContact.add(this.table, cContact); |
tabbedPane.add("Contacts", panelContact); |
c.gridx = 0; |
c.gridy++; |
c.anchor = GridBagConstraints.WEST; |
c.fill = GridBagConstraints.BOTH; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(this.table, c); |
this.add(tabbedPane, c); |
// Mode de régelement |
TitledSeparator reglSep = new TitledSeparator(getLabelFor("ID_MODE_REGLEMENT")); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLComponent.java |
---|
13,35 → 13,12 |
package org.openconcerto.erp.core.customerrelationship.customer.element; |
import java.awt.Component; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.sql.SQLException; |
import java.util.Date; |
import java.util.HashSet; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.Icon; |
import javax.swing.JCheckBox; |
import javax.swing.JComponent; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JTabbedPane; |
import javax.swing.JTextField; |
import javax.swing.event.DocumentEvent; |
import javax.swing.event.DocumentListener; |
import com.lowagie.text.Font; |
import org.openconcerto.erp.core.common.component.AdresseSQLComponent; |
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement; |
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.erp.utils.TM; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.TM; |
import org.openconcerto.sql.element.ElementSQLObject; |
import org.openconcerto.sql.element.GroupSQLComponent; |
import org.openconcerto.sql.element.SQLElement; |
50,6 → 27,7 |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.model.SQLTable; |
import org.openconcerto.sql.model.UndefinedRowValuesCache; |
import org.openconcerto.sql.preferences.SQLPreferences; |
import org.openconcerto.sql.sqlobject.JUniqueTextField; |
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo; |
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu; |
67,6 → 45,30 |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.component.InteractionMode; |
import java.awt.Component; |
import java.awt.Dimension; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.sql.SQLException; |
import java.util.Date; |
import java.util.HashSet; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.Icon; |
import javax.swing.JCheckBox; |
import javax.swing.JComponent; |
import javax.swing.JLabel; |
import javax.swing.JPanel; |
import javax.swing.JTabbedPane; |
import javax.swing.JTextField; |
import javax.swing.event.DocumentEvent; |
import javax.swing.event.DocumentListener; |
import com.lowagie.text.Font; |
public class CustomerSQLComponent extends GroupSQLComponent { |
private ContactItemTable table; |
private AdresseClientItemTable adresseTable = new AdresseClientItemTable(); |
128,7 → 130,7 |
} |
}); |
return t; |
} else if (id.equals("GROUPE") || id.equals("CENTRE_GESTION") || id.equals("METHODE_RELANCE")) { |
} else if (id.equals("GROUPE") || id.equals("FORME_JURIDIQUE") || id.equals("CENTRE_GESTION") || id.equals("METHODE_RELANCE")) { |
return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false); |
} else if (id.equals("SITE_INTERNET")) { |
return new TextFieldWithWebBrowsing(); |
186,7 → 188,8 |
}); |
return textFax; |
} |
return super.createEditor(id); |
JComponent c = super.createEditor(id); |
return c; |
} |
@Override |
203,7 → 206,8 |
} else if (id.equals("customerrelationship.customer.address")) { |
return new JLabelBold("Adresses du client"); |
} |
return super.getLabel(id); |
JComponent c = super.getLabel(id); |
return c; |
} |
@Override |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerGroup.java |
---|
17,20 → 17,24 |
import org.openconcerto.ui.group.LayoutHints; |
public class CustomerGroup extends Group { |
public final static String ID = "customerrelationship.customer.default"; |
public CustomerGroup() { |
super("customerrelationship.customer.default"); |
super(ID); |
final Group g = new Group("customerrelationship.customer.identifier"); |
g.addItem("CODE"); |
g.addItem("DATE"); |
g.addItem("FORME_JURIDIQUE"); |
g.addItem("GROUPE"); |
g.addItem("NOM", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
g.addItem("CATEGORIES"); |
g.addItem("GROUPE"); |
g.addItem("RESPONSABLE"); |
g.addItem("ID_PAYS"); |
g.addItem("TEL"); |
g.addItem("TEL_P"); |
g.addItem("MAIL", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
g.addItem("FAX"); |
g.addItem("MAIL", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
g.addItem("SITE_INTERNET", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
g.addItem("SIRET"); |
38,8 → 42,11 |
g.addItem("BLOQUE"); |
g.addItem("BLOQUE_LIVRAISON"); |
this.add(g); |
// this.add(new Group("customerrelationship.customer.additionalElementFields")); |
final Group gAddress = new Group("customerrelationship.customer.address", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS); |
// gAddress.addItem("ID_ADRESSE", new LayoutHints(true, true, true, true, true, false, true, |
// true)); |
55,6 → 62,7 |
this.add(gContact); |
final Group gPayment = new Group("customerrelationship.customer.payment", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS); |
gPayment.addItem("RIB", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
gPayment.addItem("CENTRE_GESTION", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
gPayment.addItem("ID_MODE_REGLEMENT", new LayoutHints(true, true, true, true, true, false, true, true)); |
gPayment.addItem("ID_COMPTE_PCE"); |
74,9 → 82,9 |
this.add(gState); |
final Group gInfo = new Group("customerrelationship.customer.info", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS); |
gInfo.addItem("INFOS", new LayoutHints(true, true, true, true, true, true, true, true)); |
gInfo.addItem("COMMENTAIRES", new LayoutHints(true, true, true, true, true, true, true, true)); |
this.add(gInfo); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactSQLElementBase.java |
---|
13,6 → 13,12 |
package org.openconcerto.erp.core.customerrelationship.customer.element; |
import java.util.ArrayList; |
import java.util.Collections; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
import org.openconcerto.sql.element.ConfSQLElement; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.element.SQLElement; |
24,12 → 30,6 |
import org.openconcerto.utils.CollectionMap; |
import org.openconcerto.utils.ExceptionHandler; |
import java.util.ArrayList; |
import java.util.Collections; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Set; |
public abstract class ContactSQLElementBase extends ConfSQLElement { |
public ContactSQLElementBase() { |
160,6 → 160,14 |
if (getTable().contains("SERVICE")) |
this.addView("SERVICE"); |
if (getTable().contains("TYPE")) { |
this.addView("TYPE"); |
} |
if (getTable().contains("PAYS")) { |
this.addView("PAYS"); |
} |
if (getTable().contains("NOM_ASSISTANTE")) |
this.addView("NOM_ASSISTANTE"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/ContactItemTable.java |
---|
78,6 → 78,21 |
SQLTableElement tableElementMail = new SQLTableElement(elt.getTable().getField("EMAIL")); |
list.add(tableElementMail); |
if (elt.getTable().contains("TYPE")) { |
SQLTableElement tableElementType = new SQLTableElement(elt.getTable().getField("TYPE")); |
list.add(tableElementType); |
} |
if (elt.getTable().contains("SERVICE")) { |
SQLTableElement tableElementService = new SQLTableElement(elt.getTable().getField("SERVICE")); |
list.add(tableElementService); |
} |
if (elt.getTable().contains("PAYS")) { |
SQLTableElement tableElementPays = new SQLTableElement(elt.getTable().getField("PAYS")); |
list.add(tableElementPays); |
} |
if (elt.getTable().contains("ENVOI_RAPPORT_MAIL")) { |
SQLTableElement tableElementEnvoiMail = new SQLTableElement(elt.getTable().getField("ENVOI_RAPPORT_MAIL")); |
list.add(tableElementEnvoiMail); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/element/CustomerSQLElement.java |
---|
13,6 → 13,7 |
package org.openconcerto.erp.core.customerrelationship.customer.element; |
import org.openconcerto.sql.element.GlobalMapper; |
import org.openconcerto.sql.element.GroupSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
20,8 → 21,9 |
public CustomerSQLElement() { |
super(); |
setDefaultGroup(new CustomerGroup()); |
final CustomerGroup group = new CustomerGroup(); |
GlobalMapper.getInstance().map(CustomerGroup.ID, group); |
setDefaultGroup(group); |
} |
@Override |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/customerrelationship/customer/ui/AdresseClientItemTable.java |
---|
110,6 → 110,18 |
this.province = new SQLTableElement(e.getTable().getField("PROVINCE")); |
list.add(this.province); |
if (e.getTable().contains("DEPARTEMENT")) { |
// DEPARTEMENT |
SQLTableElement dpt = new SQLTableElement(e.getTable().getField("DEPARTEMENT")); |
list.add(dpt); |
} |
if (e.getTable().contains("DISTRICT")) { |
// DISTRICT |
SQLTableElement district = new SQLTableElement(e.getTable().getField("DISTRICT")); |
list.add(district); |
} |
// Pays |
this.pays = new SQLTableElement(e.getTable().getField("PAYS")); |
list.add(this.pays); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/model/Currency.java |
---|
30,6 → 30,7 |
static { |
mapSymbol = new HashMap<String, String>(); |
mapSymbol.put("ALL", "Lek"); |
mapSymbol.put("AED", "Dhs"); |
mapSymbol.put("AFN", "؋"); |
mapSymbol.put("ARS", "$"); |
mapSymbol.put("AWG", "ƒ"); |
56,6 → 57,7 |
mapSymbol.put("HRK", "kn"); |
mapSymbol.put("CUP", "₱"); |
mapSymbol.put("CZK", "Kč"); |
mapSymbol.put("DZD", "D.A."); |
mapSymbol.put("DKK", "kr"); |
mapSymbol.put("DOP", "RD$"); |
mapSymbol.put("XCD", "$"); |
91,6 → 93,7 |
mapSymbol.put("LBP", "£"); |
mapSymbol.put("LRD", "$"); |
mapSymbol.put("LTL", "Lt"); |
mapSymbol.put("MAD", "MAD"); |
mapSymbol.put("MKD", "ден"); |
mapSymbol.put("MYR", "RM"); |
mapSymbol.put("MUR", "₨"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/EcritureSQLElement.java |
---|
157,6 → 157,9 |
listEcriture.add("LETTRAGE"); |
listEcriture.add("ID_COMPTE_PCE"); |
listEcriture.add("ID_MOUVEMENT"); |
if (getTable().contains("NOM_PIECE")) { |
listEcriture.add("NOM_PIECE"); |
} |
listEcriture.add("NOM"); |
listEcriture.add("DATE_LETTRAGE"); |
listEcriture.add("DATE"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/element/PosteAnalytiqueSQLElement.java |
---|
27,6 → 27,7 |
import javax.swing.JCheckBox; |
import javax.swing.JLabel; |
import javax.swing.JTextField; |
import javax.swing.SwingConstants; |
public class PosteAnalytiqueSQLElement extends ComptaSQLConfElement { |
54,7 → 55,7 |
public void addViews() { |
this.setLayout(new GridBagLayout()); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
final JLabel labelNom = new JLabel(getLabelFor("NOM")); |
final JLabel labelNom = new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT); |
this.add(labelNom, c); |
c.gridx++; |
63,23 → 64,25 |
this.add(obj, c); |
this.addRequiredSQLObject(obj, "NOM"); |
c.gridx = 0; |
c.gridy++; |
this.add(new JLabel(getLabelFor("ID_AXE_ANALYTIQUE"), SwingConstants.RIGHT), c); |
c.gridx++; |
ElementComboBox boxAxe = new ElementComboBox(); |
this.add(boxAxe, c); |
this.addView(boxAxe, "ID_AXE_ANALYTIQUE", REQ); |
c.gridy++; |
c.gridx = 0; |
c.weightx = 0; |
this.add(new JLabel(getLabelFor("DEFAULT")), c); |
// this.add(new JLabel(getLabelFor("DEFAULT")), c); |
c.gridx++; |
JCheckBox box = new JCheckBox("DEFAULT"); |
JCheckBox box = new JCheckBox(getLabelFor("DEFAULT")); |
c.weightx = 1; |
this.add(box, c); |
this.addRequiredSQLObject(box, "DEFAULT"); |
c.gridx = 0; |
c.gridy++; |
this.add(new JLabel(getLabelFor("ID_AXE_ANALYTIQUE")), c); |
c.gridx++; |
ElementComboBox boxAxe = new ElementComboBox(); |
this.add(boxAxe, c); |
this.addView(boxAxe, "ID_AXE_ANALYTIQUE", REQ); |
} |
}; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033A.java |
---|
113,10 → 113,11 |
// 237* ) |
// Racine = "109, 201, 203, 205, 208, 237" |
// S014=201...205+208+237+232 |
// Fix Abaque 208 - 2087 |
long v014 = this.sommeCompte.sommeCompteFils("109", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("201", this.dateDebut, this.dateFin) |
+ this.sommeCompte.sommeCompteFils("203", this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("232", this.dateDebut, this.dateFin) |
+ this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompte(2088, 2089, true, this.dateDebut, this.dateFin) |
+ this.sommeCompte.soldeCompte(2080, 2086, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin); |
+ this.sommeCompte.sommeCompteFils("205", this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompte(208, 208, true, this.dateDebut, this.dateFin) |
- this.sommeCompte.soldeCompte(2087, 2087, true, this.dateDebut, this.dateFin) + this.sommeCompte.sommeCompteFils("237", this.dateDebut, this.dateFin); |
this.m.put("ACTIF1.1", GestionDevise.currencyToString(v014, false)); |
// 016 -SommeSolde( 280, 280* ) - SommeSolde(2905) - SommeSolde (2908) |
234,7 → 235,7 |
// 050 SommeSolde( 30, 36* ) |
// Racine = "31-36, 38" |
// S050=31...36 |
long v050 = this.sommeCompte.soldeCompte(31, 35, true, this.dateDebut, this.dateFin); |
long v050 = this.sommeCompte.soldeCompte(30, 35, true, this.dateDebut, this.dateFin); |
this.m.put("ACTIF1.5", GestionDevise.currencyToString(v050, false)); |
// 052 -SommeSolde( 390, 396*) |
693,7 → 694,7 |
// 164 -SommeSolde( 4190, 4195* ) |
// Racine = "4191" |
// S164=-4191 |
long v164 = -this.sommeCompte.soldeCompte(4191, 4191, true, this.dateDebut, this.dateFin); |
long v164 = -this.sommeCompte.soldeCompte(4191, 4191, true, this.dateDebut, this.dateFin) + this.sommeCompte.soldeCompteCrediteur(510, 517, true, this.dateDebut, this.dateFin); |
this.m.put("PASSIF3.26", GestionDevise.currencyToString(v164, false)); |
// 152 |
894,6 → 895,7 |
this.dateDebut = dateDeb; |
this.dateFin = dateFin; |
this.sommeCompte = new SommeCompte(posteAnalytique); |
// this.sommeCompte.setRemoveClotureCompte(true); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/Map2033B.java |
---|
13,14 → 13,6 |
package org.openconcerto.erp.core.finance.accounting.report; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.config.Gestion; |
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte; |
import org.openconcerto.erp.preferences.TemplateNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.utils.GestionDevise; |
import java.io.File; |
import java.text.DateFormat; |
import java.text.SimpleDateFormat; |
32,6 → 24,14 |
import javax.swing.JProgressBar; |
import javax.swing.SwingUtilities; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.config.Gestion; |
import org.openconcerto.erp.core.finance.accounting.model.SommeCompte; |
import org.openconcerto.erp.preferences.TemplateNXProps; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.utils.GestionDevise; |
public class Map2033B extends Thread { |
private Map<String, String> m; |
private static final DateFormat format = new SimpleDateFormat("ddMMyyyy"); |
201,8 → 201,9 |
******************************************************************************************/ |
// 238 SommeSolde( 600, 602* )+SommeSolde( 6090, 6092* ) |
// S238=601+602+6091+6092 |
long v238 = this.sommeCompte.soldeCompte(601, 602, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(6090, 6092, true, this.dateDeb, this.dateFin) |
+ this.sommeCompte.soldeCompte(6081, 6082, true, this.dateDeb, this.dateFin); |
// FIX Abaque ajout 609 |
long v238 = this.sommeCompte.soldeCompte(601, 602, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(609, 609, true, this.dateDeb, this.dateFin) |
- this.sommeCompte.soldeCompte(6093, 6099, true, this.dateDeb, this.dateFin) + this.sommeCompte.soldeCompte(6081, 6082, true, this.dateDeb, this.dateFin); |
this.m.put("CHARGES3.10", GestionDevise.currencyToString(v238, false)); |
// 212 |
276,7 → 277,7 |
* CHARGES SOCIALES |
******************************************************************************************/ |
// 252 SommeSolde( 645, 647* ) |
long v252 = this.sommeCompte.soldeCompte(645, 648, true, this.dateDeb, this.dateFin); |
long v252 = this.sommeCompte.soldeCompte(645, 647, true, this.dateDeb, this.dateFin); |
this.m.put("CHARGES3.15", GestionDevise.currencyToString(v252, false)); |
// 221 |
516,6 → 517,7 |
this.dateDeb = dateDeb; |
this.dateFin = dateFin; |
this.sommeCompte = new SommeCompte(rowPosteAnalytique); |
// this.sommeCompte.setRemoveClotureCompte(true); |
} |
public Map2033B(JProgressBar b) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/report/VentilationAnalytiquePanel.java |
---|
68,12 → 68,17 |
GridBagConstraints c = new DefaultGridBagConstraints(); |
this.add(labelPoste, c); |
c.gridx++; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(box, c); |
c.gridx++; |
c.gridx = 0; |
c.gridy++; |
c.gridwidth = 1; |
c.fill = GridBagConstraints.NONE; |
c.weightx = 0; |
this.add(new JLabel("Période du", SwingConstants.RIGHT), c); |
c.gridx++; |
c.weightx = 1; |
c.weightx = 0; |
this.add(this.dateDeb, c); |
// Chargement des valeurs par défaut |
// String valueDateDeb = DefaultNXProps.getInstance().getStringProperty("JournauxDateDeb"); |
86,11 → 91,17 |
c.gridx++; |
c.weightx = 0; |
this.add(new JLabel("Au"), c); |
c.gridx++; |
c.weightx = 1; |
c.weightx = 0; |
this.add(this.dateEnd, c); |
c.gridx++; |
c.weightx = 1; |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(new JLabel(), c); |
final JButton buttonValid = new JButton(new AbstractAction("Valider") { |
@Override |
115,7 → 126,11 |
} |
}); |
c.gridx++; |
c.gridx = 0; |
c.gridy++; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.anchor = GridBagConstraints.EAST; |
c.fill = GridBagConstraints.NONE; |
this.add(buttonValid, c); |
// Check validity |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/action/ListeDesPostesAnalytiquesAction.java |
---|
New file |
0,0 → 1,41 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.erp.core.finance.accounting.action; |
import javax.swing.Action; |
import javax.swing.JFrame; |
import org.openconcerto.erp.action.CreateFrameAbstractAction; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.view.IListFrame; |
import org.openconcerto.sql.view.ListeAddPanel; |
public class ListeDesPostesAnalytiquesAction extends CreateFrameAbstractAction { |
public ListeDesPostesAnalytiquesAction() { |
super(); |
this.putValue(Action.NAME, "Liste des postes analytiques"); |
} |
public JFrame createFrame() { |
final SQLElement analytique = Configuration.getInstance().getDirectory().getElement("POSTE_ANALYTIQUE"); |
final IListFrame frame = new IListFrame(new ListeAddPanel(analytique)); |
return frame; |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SaisieKmItemTable.java |
---|
197,7 → 197,7 |
m.put("NOM", compteRow.getString("NOM")); |
if (ecrRow.getTable().contains("NOM_PIECE")) { |
m.put("NOM_PIECE", compteRow.getString("NOM_PIECE")); |
m.put("NOM_PIECE", ecrRow.getString("NOM_PIECE")); |
} |
if (contrePasser) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/PointagePanel.java |
---|
259,6 → 259,7 |
// Liste des ecritures |
final EcritureSQLElement ecritureElem = Configuration.getInstance().getDirectory().getElement(EcritureSQLElement.class); |
this.ecriturePanel = new ListPanelEcritures(ecritureElem, new IListe(ecritureElem.createPointageTableSource())); |
this.ecriturePanel.setShowReadOnlyFrameOnDoubleClick(false); |
c.gridx = 0; |
c.gridy++; |
c.weighty = 1; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/SuppressionEcrituresPanel.java |
---|
33,6 → 33,7 |
import javax.swing.JButton; |
import javax.swing.JFrame; |
import javax.swing.JLabel; |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
import javax.swing.SwingUtilities; |
90,10 → 91,15 |
buttonOK.addActionListener(new ActionListener() { |
public void actionPerformed(ActionEvent e) { |
((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose(); |
try { |
EcritureSQLElement elt = (EcritureSQLElement) Configuration.getInstance().getDirectory().getElement("ECRITURE"); |
elt.archiveMouvement(idMvt); |
((JFrame) SwingUtilities.getRoot(SuppressionEcrituresPanel.this)).dispose(); |
} catch (Exception ex) { |
JOptionPane.showMessageDialog(null, "Impossible de supprimer le mouvement associé.\n" + ex.getMessage()); |
} |
} |
}); |
buttonCancel.addActionListener(new ActionListener() { |
public void actionPerformed(ActionEvent e) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/CompteGestCommPreferencePanel.java |
---|
41,7 → 41,7 |
public class CompteGestCommPreferencePanel extends DefaultPreferencePanel { |
private ISQLCompteSelector selCompteTVAIntraComm, selCompteFourn, selCompteAchat, selCompteClient, selCompteVenteProduits, selCompteVenteService, selCompteTVACol, selCompteTVADed, |
selCompteTVAImmo, selCompteAchatIntra, selCompteFactor; |
selCompteTVAImmo, selCompteAchatIntra, selCompteFactor, selComptePortSoumis, selComptePortNonSoumis; |
private ElementComboBox selJrnlFactor; |
private final static SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete(); |
private static final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE"); |
189,6 → 189,40 |
this.selJrnlFactor.init(Configuration.getInstance().getDirectory().getElement("JOURNAL")); |
this.add(this.selJrnlFactor, c); |
/** |
* Frais de port sur vente |
*/ |
c.gridy++; |
c.gridx = 0; |
TitledSeparator sepPort = new TitledSeparator("Ports sur vente"); |
c.insets = separatorInsets; |
c.gridwidth = GridBagConstraints.REMAINDER; |
this.add(sepPort, c); |
c.insets = normalInsets; |
c.gridwidth = 1; |
// Compte TVA Collectee |
c.gridy++; |
c.weightx = 0; |
this.add(new JLabel("Compte Port soumis à TVA"), c); |
c.weightx = 1; |
c.gridx++; |
this.selComptePortSoumis = new ISQLCompteSelector(); |
this.selComptePortSoumis.init(); |
this.add(this.selComptePortSoumis, c); |
// Compte TVA Deductible |
c.gridy++; |
c.weightx = 0; |
c.gridx = 0; |
this.add(new JLabel("Compte Port non soumis à TVA)"), c); |
c.weightx = 1; |
c.gridx++; |
this.selComptePortNonSoumis = new ISQLCompteSelector(); |
this.selComptePortNonSoumis.init(); |
this.add(this.selComptePortNonSoumis, c); |
/******************************************************************************************* |
* TVA |
******************************************************************************************/ |
268,6 → 302,8 |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_VENTE", this.selCompteTVACol.getValue()); |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_INTRA", this.selCompteTVAIntraComm.getValue()); |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_TVA_IMMO", this.selCompteTVAImmo.getValue()); |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_PORT_SOUMIS", this.selComptePortSoumis.getValue()); |
this.rowPrefCompteVals.put("ID_COMPTE_PCE_PORT_NON_SOUMIS", this.selComptePortNonSoumis.getValue()); |
DefaultNXProps.getInstance().setProperty("HideCompteClient", String.valueOf(this.checkHideCompteClient.isSelected())); |
DefaultNXProps.getInstance().setProperty("HideCompteFacture", String.valueOf(this.checkHideCompteFacture.isSelected())); |
DefaultNXProps.getInstance().setProperty("HideAnalytique", String.valueOf(this.checkHideAnalytique.isSelected())); |
322,6 → 358,16 |
value = ComptePCESQLElement.getId(compte); |
this.selCompteClient.setValue(value); |
// Port |
compte = ComptePCESQLElement.getComptePceDefault("PortVenteSoumisTVA"); |
value = ComptePCESQLElement.getId(compte); |
this.selComptePortSoumis.setValue(value); |
// Port non soumis |
compte = ComptePCESQLElement.getComptePceDefault("PortVenteNonSoumisTVA"); |
value = ComptePCESQLElement.getId(compte); |
this.selComptePortNonSoumis.setValue(value); |
// TVA Coll |
compte = ComptePCESQLElement.getComptePceDefault("TVACollectee"); |
value = ComptePCESQLElement.getId(compte); |
370,7 → 416,8 |
setComboValues(selCompteFourn, "ID_COMPTE_PCE_FOURNISSEUR", "Fournisseurs"); |
setComboValues(selCompteClient, "ID_COMPTE_PCE_CLIENT", "Clients"); |
setComboValues(selComptePortSoumis, "ID_COMPTE_PCE_PORT_SOUMIS", "PortVenteSoumisTVA"); |
setComboValues(selComptePortNonSoumis, "ID_COMPTE_PCE_PORT_NON_SOUMIS", "PortVenteNonSoumisTVA"); |
setComboValues(selCompteTVACol, "ID_COMPTE_PCE_TVA_VENTE", "TVACollectee"); |
setComboValues(selCompteTVADed, "ID_COMPTE_PCE_TVA_ACHAT", "TVADeductible"); |
setComboValues(selCompteTVAIntraComm, "ID_COMPTE_PCE_TVA_INTRA", "TVAIntraComm"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/accounting/ui/BalanceCellRenderer.java |
---|
19,6 → 19,7 |
import java.awt.Component; |
import javax.swing.JTable; |
import javax.swing.SwingConstants; |
public class BalanceCellRenderer extends CompteCellRenderer { |
38,7 → 39,7 |
} |
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
this.setHorizontalAlignment(SwingConstants.LEFT); |
if (!isSelected) { |
// si le numéro compte est composé d'un seul chiffre |
final int length = numeroCompte.length(); |
70,6 → 71,7 |
if (value != null && value.getClass() == Long.class) { |
this.setText(GestionDevise.currencyToString(((Long) value).longValue())); |
this.setHorizontalAlignment(SwingConstants.RIGHT); |
} |
return this; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/finance/tax/element/TaxeSQLElement.java |
---|
158,6 → 158,33 |
ISQLCompteSelector compteDed = new ISQLCompteSelector(); |
this.add(compteDed, c); |
JLabel labelCompteVente = new JLabel(getLabelFor("ID_COMPTE_PCE_VENTE"), SwingConstants.RIGHT); |
c.fill = GridBagConstraints.HORIZONTAL; |
c.gridwidth = 1; |
c.gridx = 0; |
c.gridy++; |
this.add(labelCompteVente, c); |
c.gridx++; |
c.weightx = 1; |
c.gridwidth = GridBagConstraints.REMAINDER; |
ISQLCompteSelector compteVente = new ISQLCompteSelector(); |
this.add(compteVente, c); |
JLabel labelCompteVenteS = new JLabel(getLabelFor("ID_COMPTE_PCE_VENTE_SERVICE"), SwingConstants.RIGHT); |
c.gridx = 0; |
c.gridy++; |
c.weightx = 0; |
c.gridwidth = 1; |
c.fill = GridBagConstraints.HORIZONTAL; |
this.add(labelCompteVenteS, c); |
c.gridx++; |
c.weightx = 1; |
c.gridwidth = GridBagConstraints.REMAINDER; |
ISQLCompteSelector compteVenteS = new ISQLCompteSelector(); |
this.add(compteVenteS, c); |
// Spacer |
c.gridy++; |
c.weighty = 1; |
166,7 → 193,10 |
this.addSQLObject(compteCol, "ID_COMPTE_PCE_COLLECTE"); |
this.addSQLObject(compteDed, "ID_COMPTE_PCE_DED"); |
this.addSQLObject(compteVente, "ID_COMPTE_PCE_VENTE"); |
this.addSQLObject(compteVenteS, "ID_COMPTE_PCE_VENTE_SERVICE"); |
this.addRequiredSQLObject(fieldNom, "NOM"); |
this.addRequiredSQLObject(fieldTaux, "TAUX"); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/ui/EditionFichePayePanel.java |
---|
34,6 → 34,7 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.util.Calendar; |
import java.util.Date; |
import javax.swing.AbstractAction; |
import javax.swing.BorderFactory; |
40,6 → 41,7 |
import javax.swing.JButton; |
import javax.swing.JFrame; |
import javax.swing.JLabel; |
import javax.swing.JOptionPane; |
import javax.swing.JPanel; |
import javax.swing.JPopupMenu; |
import javax.swing.JProgressBar; |
187,9 → 189,20 |
// props.setProperty("AnneeEditionPaye", textAnnee.getText()); |
props.store(); |
java.sql.Date du = new java.sql.Date(dateDeb.getDate().getTime()); |
java.sql.Date au = new java.sql.Date(dateFin.getDate().getTime()); |
final Date dateStart = dateDeb.getDate(); |
if (dateStart == null) { |
JOptionPane.showMessageDialog(EditionFichePayePanel.this, "Date de début manquante."); |
return; |
} |
java.sql.Date du = new java.sql.Date(dateStart.getTime()); |
final Date dateEnd = dateFin.getDate(); |
if (dateEnd == null) { |
JOptionPane.showMessageDialog(EditionFichePayePanel.this, "Date de fin manquante."); |
return; |
} |
java.sql.Date au = new java.sql.Date(dateEnd.getTime()); |
// model.validationFiche(textAnnee.getText(), selMois.getSelectedId(), du, au); |
model.validationFiche(textAnnee.getValue().toString(), selMois.getSelectedId(), du, au); |
} catch (Exception ex) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/humanresources/payroll/element/RubriqueCotisationSQLElement.java |
---|
23,6 → 23,7 |
import org.openconcerto.sql.element.SQLElement; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import org.openconcerto.utils.NoneSelectedButtonGroup; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
65,8 → 66,9 |
l.add("TX_SAL"); |
l.add("BRUT"); |
l.add("PART_CSG"); |
l.add("PART_CSG_SANS_ABATTEMENT"); |
l.add("IMPOSABLE"); |
l.add("PART_PAT_IMPOSABLE"); |
return l; |
} |
231,11 → 233,25 |
JCheckBox checkImpo = new JCheckBox(getLabelFor("IMPOSABLE")); |
panelProp.add(checkImpo, cPanel); |
// Patronale imposable |
cPanel.gridy++; |
JCheckBox checkPartPatrImposable = new JCheckBox(getLabelFor("PART_PAT_IMPOSABLE")); |
panelProp.add(checkPartPatrImposable, cPanel); |
// Part csg |
cPanel.gridy++; |
JCheckBox checkPartPatr = new JCheckBox(getLabelFor("PART_CSG")); |
panelProp.add(checkPartPatr, cPanel); |
// Part csg |
cPanel.gridy++; |
JCheckBox checkPartPatrSansAbattement = new JCheckBox(getLabelFor("PART_CSG_SANS_ABATTEMENT")); |
panelProp.add(checkPartPatrSansAbattement, cPanel); |
NoneSelectedButtonGroup group = new NoneSelectedButtonGroup(); |
group.add(checkPartPatrSansAbattement); |
group.add(checkPartPatr); |
// Brut |
cPanel.gridy++; |
JCheckBox checkBrut = new JCheckBox(getLabelFor("BRUT")); |
301,7 → 317,9 |
this.addSQLObject(this.formuleTxSal, "TX_SAL"); |
this.addSQLObject(checkBrut, "BRUT"); |
this.addSQLObject(checkPartPatr, "PART_CSG"); |
this.addSQLObject(checkPartPatrSansAbattement, "PART_CSG_SANS_ABATTEMENT"); |
this.addSQLObject(checkImpo, "IMPOSABLE"); |
this.addSQLObject(checkPartPatrImposable, "PART_PAT_IMPOSABLE"); |
this.addRequiredSQLObject(comboSelTypeImpression, "ID_IMPRESSION_RUBRIQUE"); |
selSalarie.addValueListener(new PropertyChangeListener() { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/action/ListeDesCommandesClientAction.java |
---|
119,99 → 119,7 |
} |
}); |
} |
final List<RowAction> allowedActions = new ArrayList<RowAction>(); |
// Transfert vers facture |
PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
transfertBonLivraisonClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.deliverynote"); |
// Transfert vers facture |
RowAction factureAction = new RowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
transfertFactureClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.invoice") { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.isEmpty()) { |
return false; |
} else if (selection.size() > 1) { |
return true; |
} else { |
BigDecimal d = getAvancement(selection.get(0)); |
return d.signum() == 0; |
} |
} |
}; |
// Transfert vers facture intermédiaire |
RowAction acompteAction = new RowAction(new AbstractAction("Créer une facture intermédiaire") { |
public void actionPerformed(ActionEvent e) { |
transfertAcompteClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.account") { |
BigDecimal cent = BigDecimal.ONE.movePointRight(2); |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.isEmpty() || selection.size() > 1) { |
return false; |
} else { |
BigDecimal d = getAvancement(selection.get(0)); |
return NumberUtils.compare(d, cent) != 0; |
} |
} |
}; |
// Transfert vers facture solde |
RowAction soldeAction = new RowAction(new AbstractAction("Facturer le solde") { |
public void actionPerformed(ActionEvent e) { |
transfertSoldeClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.account.solde") { |
BigDecimal cent = BigDecimal.ONE.movePointRight(2); |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.isEmpty() || selection.size() > 1) { |
return false; |
} else { |
BigDecimal d = getAvancement(selection.get(0)); |
return NumberUtils.compare(d, cent) != 0 && NumberUtils.compare(d, BigDecimal.ZERO) != 0; |
} |
} |
}; |
// Transfert vers commande |
PredicateRowAction cmdAction = new PredicateRowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
final int selectedId = IListe.get(e).getSelectedId(); |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() { |
@Override |
public void run() { |
final CommandeClientSQLElement elt = (CommandeClientSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT"); |
elt.transfertCommande(selectedId); |
} |
}); |
} |
}, false, "sales.order.create.supplier.order"); |
cmdAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
allowedActions.add(bonAction); |
allowedActions.add(factureAction); |
allowedActions.add(acompteAction); |
allowedActions.add(soldeAction); |
allowedActions.add(cmdAction); |
this.colAvancement = new BaseSQLTableModelColumn("Avancement facturation", BigDecimal.class) { |
@Override |
228,7 → 136,7 |
}; |
tableSource.getColumns().add(this.colAvancement); |
this.colAvancement.setRenderer(new PercentTableCellRenderer()); |
final ListeAddPanel panel = getPanel(eltCmd, tableSource, allowedActions); |
final ListeAddPanel panel = getPanel(eltCmd, tableSource); |
return panel; |
} |
250,7 → 158,7 |
} |
} |
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource, final List<RowAction> allowedActions) { |
private ListeAddPanel getPanel(final SQLElement eltCmd, final SQLTableModelSourceOnline tableSource) { |
final ListeAddPanel panel = new ListeAddPanel(eltCmd, new IListe(tableSource)) { |
@Override |
protected void createUI() { |
303,13 → 211,6 |
// Date panel |
final IListFilterDatePanel datePanel = new IListFilterDatePanel(panel.getListe(), eltCmd.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap()); |
panel.getListe().addIListeActions(new MouseSheetXmlListeListener(CommandeClientXmlSheet.class) { |
@Override |
public List<RowAction> addToMenu() { |
return allowedActions; |
} |
}.getRowActions()); |
datePanel.setFilterOnDefault(); |
final JPanel bottomPanel = new JPanel(); |
329,40 → 230,4 |
return panel; |
} |
/** |
* Transfert en BL |
* |
* @param row |
*/ |
private void transfertBonLivraisonClient(List<SQLRowValues> rows) { |
TransfertBaseSQLComponent.openTransfertFrame(rows, "BON_DE_LIVRAISON"); |
} |
/** |
* Transfert en Facture |
* |
* @param row |
*/ |
private void transfertFactureClient(List<SQLRowValues> rows) { |
TransfertBaseSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE"); |
} |
/** |
* Transfert en Facture |
* |
* @param row |
*/ |
private void transfertAcompteClient(List<SQLRowValues> rows) { |
TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSituationSQLComponent.ID); |
} |
/** |
* Transfert en Facture |
* |
* @param row |
*/ |
private void transfertSoldeClient(List<SQLRowValues> rows) { |
TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSoldeSQLComponent.ID); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/component/CommandeClientSQLComponent.java |
---|
312,6 → 312,9 |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) { |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID); |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) { |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL")); |
} |
int idClient = rowClient.getID(); |
comboContact.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_CLIENT"), "=", idClient)); |
} else { |
322,6 → 325,9 |
}); |
} |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) { |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE"); |
final AddressChoiceUI addressUI = new AddressChoiceUI(); |
addressUI.addToUI(this, c); |
333,10 → 339,16 |
System.err.println("SET WHERE ID_CLIENT = " + wantedID); |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) { |
addressUI.getComboAdrF().getRequest() |
.setWhere(new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId()))); |
addressUI.getComboAdrL().getRequest() |
.setWhere(new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId()))); |
addressUI |
.getComboAdrF() |
.getRequest() |
.setWhere( |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId()))); |
addressUI |
.getComboAdrL() |
.getRequest() |
.setWhere( |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId()))); |
} else { |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE); |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE); |
343,8 → 355,8 |
} |
} |
}); |
} |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ORDER_PACKAGING_MANAGEMENT, true)) { |
// Emballage |
c.gridy++; |
463,8 → 475,14 |
if (getTable().contains("PREBILAN")) { |
addSQLObject(fieldHA, "PREBILAN"); |
} else if (getTable().contains("T_HA")) { |
this.allowEditable("T_HA", false); |
addSQLObject(fieldHA, "T_HA"); |
} |
// Disable |
this.allowEditable("T_HT", false); |
this.allowEditable("T_TVA", false); |
this.allowEditable("T_TTC", false); |
this.allowEditable("T_SERVICE", false); |
JTextField poids = new JTextField(); |
SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/order/element/CommandeClientSQLElement.java |
---|
13,11 → 13,41 |
package org.openconcerto.erp.core.sales.order.element; |
import java.awt.Component; |
import java.awt.event.ActionEvent; |
import java.io.IOException; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.Collection; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Map; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.JLabel; |
import javax.swing.JTable; |
import javax.swing.SwingUtilities; |
import javax.swing.table.DefaultTableCellRenderer; |
import org.apache.commons.dbutils.ResultSetHandler; |
import org.apache.commons.dbutils.handlers.ArrayListHandler; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.component.TransfertGroupSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.sales.account.VenteFactureSituationSQLComponent; |
import org.openconcerto.erp.core.sales.account.VenteFactureSoldeSQLComponent; |
import org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent; |
import org.openconcerto.erp.core.sales.order.report.CommandeClientXmlSheet; |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient; |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement; |
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement; |
import org.openconcerto.erp.model.MouseSheetXmlListeListener; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.SQLComponent; |
28,6 → 58,7 |
import org.openconcerto.sql.model.SQLField; |
import org.openconcerto.sql.model.SQLInjector; |
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.SQLRowValuesListFetcher; |
39,6 → 70,7 |
import org.openconcerto.sql.utils.SQLUtils; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.sql.view.list.SQLTableModelColumn; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
46,30 → 78,9 |
import org.openconcerto.utils.DecimalUtils; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.ListMap; |
import org.openconcerto.utils.NumberUtils; |
import org.openconcerto.utils.cc.ITransformer; |
import java.awt.Component; |
import java.awt.event.ActionEvent; |
import java.io.IOException; |
import java.math.BigDecimal; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.HashSet; |
import java.util.List; |
import java.util.Map; |
import java.util.Set; |
import javax.swing.AbstractAction; |
import javax.swing.JLabel; |
import javax.swing.JOptionPane; |
import javax.swing.JTable; |
import javax.swing.SwingUtilities; |
import javax.swing.table.DefaultTableCellRenderer; |
import org.apache.commons.dbutils.ResultSetHandler; |
import org.apache.commons.dbutils.handlers.ArrayListHandler; |
public class CommandeClientSQLElement extends ComptaSQLConfElement { |
public CommandeClientSQLElement() { |
134,8 → 145,108 |
getRowActions().add(actionFacture); |
} |
final List<RowAction> allowedActions = new ArrayList<RowAction>(); |
// Transfert vers facture |
PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
transfertBonLivraisonClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.deliverynote"); |
// Transfert vers facture |
RowAction factureAction = new RowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
transfertFactureClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.invoice") { |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.isEmpty()) { |
return false; |
} else if (selection.size() > 1) { |
return true; |
} else { |
BigDecimal d = getAvancement(selection.get(0)); |
return d.signum() == 0; |
} |
} |
}; |
// Transfert vers facture intermédiaire |
RowAction acompteAction = new RowAction(new AbstractAction("Créer une facture intermédiaire") { |
public void actionPerformed(ActionEvent e) { |
transfertAcompteClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.account") { |
BigDecimal cent = BigDecimal.ONE.movePointRight(2); |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.isEmpty() || selection.size() > 1) { |
return false; |
} else { |
BigDecimal d = getAvancement(selection.get(0)); |
return NumberUtils.compare(d, cent) != 0; |
} |
} |
}; |
// Transfert vers facture solde |
RowAction soldeAction = new RowAction(new AbstractAction("Facturer le solde") { |
public void actionPerformed(ActionEvent e) { |
transfertSoldeClient(IListe.get(e).getSelectedRows()); |
} |
}, false, "sales.order.create.account.solde") { |
BigDecimal cent = BigDecimal.ONE.movePointRight(2); |
@Override |
public boolean enabledFor(List<SQLRowValues> selection) { |
if (selection.isEmpty() || selection.size() > 1) { |
return false; |
} else { |
BigDecimal d = getAvancement(selection.get(0)); |
return NumberUtils.compare(d, cent) != 0 && NumberUtils.compare(d, BigDecimal.ZERO) != 0; |
} |
} |
}; |
// Transfert vers commande |
PredicateRowAction cmdAction = new PredicateRowAction(new AbstractAction() { |
public void actionPerformed(ActionEvent e) { |
final int selectedId = IListe.get(e).getSelectedId(); |
ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor().execute(new Runnable() { |
@Override |
public void run() { |
final CommandeClientSQLElement elt = (CommandeClientSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE_CLIENT"); |
elt.transfertCommande(selectedId); |
} |
}); |
} |
}, false, "sales.order.create.supplier.order"); |
cmdAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
MouseSheetXmlListeListener mouseSheetXmlListeListener = new MouseSheetXmlListeListener(CommandeClientXmlSheet.class); |
mouseSheetXmlListeListener.setGenerateHeader(true); |
mouseSheetXmlListeListener.setShowHeader(true); |
allowedActions.add(bonAction); |
allowedActions.add(factureAction); |
allowedActions.add(acompteAction); |
allowedActions.add(soldeAction); |
allowedActions.add(cmdAction); |
allowedActions.addAll(mouseSheetXmlListeListener.getRowActions()); |
getRowActions().addAll(allowedActions); |
} |
public SQLRow getNextCommandeToPrepare() { |
final SQLTable tableCmd = getTable(); |
SQLSelect sel = new SQLSelect(); |
465,10 → 576,65 |
rowValsElt.put("T_PA_HT", ((BigDecimal) rowValsElt.getObject("PA_HT")).multiply(new BigDecimal(rowValsElt.getInt("QTE")), DecimalUtils.HIGH_PRECISION)); |
rowValsElt.put("T_PA_TTC", |
((BigDecimal) rowValsElt.getObject("T_PA_HT")).multiply(new BigDecimal((rowValsElt.getForeign("ID_TAXE").getFloat("TAUX") / 100.0 + 1.0)), DecimalUtils.HIGH_PRECISION)); |
rowValsElt.put("ID_DEVISE", rowCmd.getForeignRow("ID_TARIF").getForeignID("ID_DEVISE")); |
map.add(rowArticleFind.getForeignRow("ID_FOURNISSEUR"), rowValsElt); |
} |
MouvementStockSQLElement.createCommandeF(map, rowCmd.getForeignRow("ID_TARIF").getForeignRow("ID_DEVISE"), rowCmd.getString("NUMERO") + " - " + rowCmd.getString("NOM")); |
} |
/** |
* Transfert en BL |
* |
* @param row |
*/ |
public void transfertBonLivraisonClient(List<SQLRowValues> rows) { |
TransfertBaseSQLComponent.openTransfertFrame(rows, "BON_DE_LIVRAISON"); |
} |
/** |
* Transfert en Facture |
* |
* @param row |
*/ |
public void transfertFactureClient(List<SQLRowValues> rows) { |
TransfertBaseSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE"); |
} |
/** |
* Transfert en Facture |
* |
* @param row |
*/ |
public void transfertAcompteClient(List<SQLRowValues> rows) { |
TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSituationSQLComponent.ID); |
} |
/** |
* Transfert en Facture |
* |
* @param row |
*/ |
public void transfertSoldeClient(List<SQLRowValues> rows) { |
TransfertGroupSQLComponent.openTransfertFrame(rows, "SAISIE_VENTE_FACTURE", VenteFactureSoldeSQLComponent.ID); |
} |
private BigDecimal getAvancement(SQLRowAccessor r) { |
Collection<? extends SQLRowAccessor> rows = r.getReferentRows(r.getTable().getTable("TR_COMMANDE_CLIENT")); |
long totalFact = 0; |
long total = r.getLong("T_HT"); |
for (SQLRowAccessor row : rows) { |
if (!row.isForeignEmpty("ID_SAISIE_VENTE_FACTURE")) { |
SQLRowAccessor rowFact = row.getForeign("ID_SAISIE_VENTE_FACTURE"); |
Long l = rowFact.getLong("T_HT"); |
totalFact += l; |
} |
} |
if (total > 0) { |
return new BigDecimal(totalFact).divide(new BigDecimal(total), DecimalUtils.HIGH_PRECISION).movePointRight(2).setScale(2, RoundingMode.HALF_UP); |
} else { |
return BigDecimal.ONE.movePointRight(2); |
} |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSoldeEditGroup.java |
---|
29,6 → 29,9 |
this.add(g); |
final Group gAdd = new Group("sales.invoice.partial.additionalElementFields"); |
this.add(gAdd); |
final Group gCustomer = new Group("sales.invoice.partial.balance.customer"); |
gCustomer.addItem("sales.invoice.customer", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
add(gCustomer); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/PartialInvoiceEditGroup.java |
---|
28,6 → 28,8 |
g.addItem("sales.invoice.partial.amount"); |
this.add(g); |
final Group gAdd = new Group("sales.invoice.partial.additionalElementFields"); |
this.add(gAdd); |
final Group gCustomer = new Group("sales.invoice.customer"); |
gCustomer.addItem("sales.invoice.customer", LayoutHints.DEFAULT_LARGE_FIELD_HINTS); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/account/VenteFactureSituationSQLComponent.java |
---|
38,6 → 38,7 |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.list.RowValuesTable; |
import org.openconcerto.sql.view.list.SQLTableElement; |
import org.openconcerto.ui.JComponentUtils; |
import org.openconcerto.ui.JDate; |
import org.openconcerto.ui.component.ITextArea; |
import org.openconcerto.ui.group.Group; |
45,6 → 46,7 |
import org.openconcerto.utils.text.SimpleDocumentListener; |
import java.awt.Component; |
import java.awt.Dimension; |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.math.BigDecimal; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureItemSQLElement.java |
---|
15,6 → 15,7 |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.sql.Configuration; |
21,6 → 22,8 |
import org.openconcerto.sql.element.BaseSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
import java.awt.GridBagConstraints; |
56,6 → 59,13 |
return l; |
} |
@Override |
protected SQLTableModelSourceOnline createTableSource() { |
SQLTableModelSourceOnline table = super.createTableSource(); |
return table; |
} |
/* |
* (non-Javadoc) |
* |
73,7 → 83,9 |
l.add("PRIX_METRIQUE_VT_1"); |
l.add("ID_MODE_VENTE_ARTICLE"); |
} |
if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) { |
l.add("PA_HT"); |
} |
l.add("PV_HT"); |
l.add("QTE"); |
l.add("T_PV_HT"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/element/SaisieVenteFactureSQLElement.java |
---|
17,6 → 17,7 |
import org.openconcerto.erp.config.Gestion; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.core.common.ui.PanelFrame; |
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement; |
53,6 → 54,7 |
import org.openconcerto.sql.request.ListSQLRequest; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.users.UserManager; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel; |
import org.openconcerto.sql.view.EditPanel.EditMode; |
228,8 → 230,9 |
l.add("ID_CLIENT"); |
l.add("ID_MODE_REGLEMENT"); |
l.add("ID_COMMERCIAL"); |
if (!UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) { |
l.add("T_HA"); |
} |
l.add("T_HT"); |
l.add("T_TTC"); |
l.add("INFOS"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/report/VenteFactureElementXmlSheet.java |
---|
14,6 → 14,7 |
package org.openconcerto.erp.core.sales.invoice.report; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.model.SQLRow; |
import org.openconcerto.sql.model.SQLTable; |
public class VenteFactureElementXmlSheet extends VenteFactureXmlSheet { |
23,6 → 24,10 |
this(id.intValue()); |
} |
public VenteFactureElementXmlSheet(SQLRow row) { |
super(row.getForeignRow("ID_SAISIE_VENTE_FACTURE")); |
} |
public VenteFactureElementXmlSheet(int id) { |
super(tableFactureElt.getRow(id).getForeignRow("ID_SAISIE_VENTE_FACTURE")); |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/ui/GenListeVentePanel.java |
---|
30,6 → 30,7 |
import java.awt.GridBagLayout; |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.util.ArrayList; |
import java.util.List; |
import javax.swing.JButton; |
113,9 → 114,13 |
sel2.addSelectStar(tableAvoir); |
sel2.setWhere(new Where(tableAvoir.getField("DATE"), GenListeVentePanel.this.du.getDate(), GenListeVentePanel.this.au.getDate())); |
sel2.setDistinct(true); |
l.addAll((List<SQLRow>) dataSource.execute(sel2.asString(), SQLRowListRSH.createFromSelect(sel2, tableAvoir))); |
ListeVenteXmlSheet sheet = new ListeVenteXmlSheet(l, GenListeVentePanel.this.du.getDate(), GenListeVentePanel.this.au.getDate(), GenListeVentePanel.this.bar); |
List<SQLRow> l2 = (List<SQLRow>) dataSource.execute(sel2.asString(), SQLRowListRSH.createFromSelect(sel2, tableAvoir)); |
List<SQLRow> lTotal = new ArrayList<SQLRow>(); |
lTotal.addAll(l); |
lTotal.addAll(l2); |
ListeVenteXmlSheet sheet = new ListeVenteXmlSheet(lTotal, GenListeVentePanel.this.du.getDate(), GenListeVentePanel.this.au.getDate(), GenListeVentePanel.this.bar); |
sheet.createDocumentAsynchronous().get(); |
sheet.showPrintAndExport(true, false, false); |
} catch (Exception e) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/invoice/component/SaisieVenteFactureSQLComponent.java |
---|
41,6 → 41,7 |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel; |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.ElementSQLObject; |
83,6 → 84,7 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeListener; |
import java.math.BigDecimal; |
import java.math.RoundingMode; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.Date; |
106,7 → 108,10 |
private AbstractArticleItemTable tableFacture; |
private JLabel labelAffaire = new JLabel("Affaire"); |
private final JDate dateSaisie = new JDate(true); |
private DeviseField textPortHT, textAvoirTTC, textRemiseHT, fieldTTC, textTotalAvoir; |
private DeviseField textPortHT, textAvoirTTC, textRemiseHT, fieldTTC, textNetAPayer; |
private DeviseField totalTimbre, netPayer; |
private JTextField tauxTimbre; |
private SQLElement factureElt = Configuration.getInstance().getDirectory().getElement("SAISIE_VENTE_FACTURE"); |
private SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_CLIENT").getTable(); |
public static final SQLTable TABLE_ADRESSE = Configuration.getInstance().getDirectory().getElement("ADRESSE").getTable(); |
132,6 → 137,7 |
protected TotalPanel totalTTC; |
private final boolean displayDpt; |
private final ElementComboBox comboDpt = new ElementComboBox(); |
private final boolean gestionTimbre; |
// Type intervention |
private SQLTextCombo textTypeMission = new SQLTextCombo(); |
141,7 → 147,9 |
int idCli = SaisieVenteFactureSQLComponent.this.comboClient.getWantedID(); |
if (idCli > 1) { |
SQLRow rowCli = SaisieVenteFactureSQLComponent.this.client.getTable().getRow(idCli); |
if (!rowCli.isForeignEmpty("ID_COMMERCIAL")) { |
comboCommercial.setValue(rowCli.getForeignID("ID_COMMERCIAL")); |
} |
if (getMode() == SQLComponent.Mode.INSERTION || !isFilling()) { |
SQLElement sqleltModeRegl = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT"); |
int idModeRegl = rowCli.getInt("ID_MODE_REGLEMENT"); |
185,6 → 193,7 |
this.defaultNum = this.tableNum.getRow(defaultNum); |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
this.displayDpt = prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_DPT, false); |
this.gestionTimbre = prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.GESTION_TIMBRE_FISCAL, false); |
} |
public SaisieVenteFactureSQLComponent() { |
421,6 → 430,9 |
this.comboClient.addValueListener(this.changeClientListener); |
// SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
// if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) { |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE"); |
final org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI addressUI = new org.openconcerto.erp.core.customerrelationship.customer.ui.AddressChoiceUI(); |
450,6 → 462,7 |
} |
} |
}); |
// } |
// Contact |
this.contact = new ElementComboBox(); |
693,6 → 706,14 |
JTextField poids = new JTextField(); |
addSQLObject(poids, "T_POIDS"); |
// Disable |
this.allowEditable("T_HA", false); |
this.allowEditable("T_HT", false); |
this.allowEditable("T_TVA", false); |
this.allowEditable("T_TTC", false); |
this.allowEditable("T_SERVICE", false); |
this.allowEditable("T_POIDS", false); |
totalTTC = new TotalPanel(this.tableFacture, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null, (getTable().contains( |
"ID_TAXE_PORT") ? boxTaxePort : null)); |
DefaultGridBagConstraints.lockMinimumSize(totalTTC); |
710,6 → 731,19 |
c.weighty = 0; |
this.add(panelBottom, c); |
// Ligne : Timbre |
c.gridy++; |
c.gridx = 0; |
c.weightx = 1; |
c.weighty = 0; |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.anchor = GridBagConstraints.EAST; |
c.fill = GridBagConstraints.HORIZONTAL; |
final JPanel timbrePanel = createTimbrePanel(); |
this.add(timbrePanel, c); |
timbrePanel.setVisible(this.gestionTimbre); |
// Ligne : Avoir |
c.gridy++; |
c.gridx = 0; |
779,11 → 813,39 |
this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
calculTimbre(); |
refreshText(); |
} |
}); |
if (this.checkTaux != null) { |
this.checkTaux.addActionListener(new ActionListener() { |
@Override |
public void actionPerformed(ActionEvent e) { |
calculTimbre(); |
refreshText(); |
} |
}); |
} |
this.tauxTimbre.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
calculTimbre(); |
refreshText(); |
} |
}); |
this.totalTimbre.getDocument().addDocumentListener(new SimpleDocumentListener() { |
@Override |
public void update(DocumentEvent e) { |
refreshText(); |
} |
}); |
this.selAvoir.addValueListener(new PropertyChangeListener() { |
public void propertyChange(PropertyChangeEvent evt) { |
910,6 → 972,20 |
} |
private void calculTimbre() { |
totalTimbre.setValue(0L); |
if (gestionTimbre && this.checkTaux != null && this.checkTaux.isSelected()) { |
if (tauxTimbre.getText().trim().length() != 0) { |
BigDecimal taux = new BigDecimal(tauxTimbre.getText()); |
Long ttc = fieldTTC.getValue(); |
if (ttc != null) { |
long timbreValue = taux.multiply(new BigDecimal(ttc)).movePointLeft(2).setScale(0, RoundingMode.HALF_UP).longValue(); |
totalTimbre.setValue(timbreValue); |
} |
} |
} |
} |
private JPanel createPanelAvoir() { |
JPanel panelAvoir = new JPanel(new GridBagLayout()); |
panelAvoir.setOpaque(false); |
925,19 → 1001,52 |
this.selAvoir.setAddIconVisible(false); |
panelAvoir.add(this.selAvoir, cA); |
final JLabel labelTotalAvoir = new JLabel("Total à régler"); |
this.textTotalAvoir = new DeviseField(); |
this.textTotalAvoir.setEditable(false); |
this.textNetAPayer = new DeviseField(); |
this.textNetAPayer.setEditable(false); |
cA.gridx++; |
cA.weightx = 0; |
panelAvoir.add(labelTotalAvoir, cA); |
cA.gridx++; |
cA.weightx = 0; |
panelAvoir.add(this.textTotalAvoir, cA); |
this.textTotalAvoir.setHorizontalAlignment(SwingConstants.RIGHT); |
panelAvoir.add(this.textNetAPayer, cA); |
addView(textNetAPayer, "NET_A_PAYER"); |
this.textNetAPayer.setHorizontalAlignment(SwingConstants.RIGHT); |
return panelAvoir; |
} |
private JCheckBox checkTaux; |
private JPanel createTimbrePanel() { |
JPanel panelTimbre = new JPanel(new GridBagLayout()); |
panelTimbre.setOpaque(false); |
GridBagConstraints cA = new DefaultGridBagConstraints(); |
this.checkTaux = new JCheckBox(getLabelFor("SOUMIS_TIMBRE_FISCAL") + " " + getLabelFor("TAUX_TIMBRE_FISCAL")); |
checkTaux.setHorizontalAlignment(SwingConstants.RIGHT); |
cA.weightx = 1; |
checkTaux.setHorizontalAlignment(SwingConstants.RIGHT); |
panelTimbre.add(checkTaux, cA); |
cA.weightx = 0; |
cA.gridx++; |
this.tauxTimbre = new JTextField(8); |
panelTimbre.add(this.tauxTimbre, cA); |
final JLabel labelTotalTimbre = new JLabel(getLabelFor("TOTAL_TIMBRE_FISCAL")); |
this.totalTimbre = new DeviseField(); |
this.totalTimbre.setEditable(false); |
cA.gridx++; |
cA.weightx = 0; |
panelTimbre.add(labelTotalTimbre, cA); |
cA.gridx++; |
cA.weightx = 0; |
panelTimbre.add(this.totalTimbre, cA); |
this.totalTimbre.setHorizontalAlignment(SwingConstants.RIGHT); |
this.addView(checkTaux, "SOUMIS_TIMBRE_FISCAL"); |
this.addView(tauxTimbre, "TAUX_TIMBRE_FISCAL"); |
this.addView(totalTimbre, "TOTAL_TIMBRE_FISCAL"); |
return panelTimbre; |
} |
private void setCompteServiceVisible(boolean b) { |
this.compteSelService.setVisible(b); |
this.labelCompteServ.setVisible(b); |
945,10 → 1054,17 |
private void refreshText() { |
Number n = this.fieldTTC.getValue(); |
long totalAvoirTTC = 0; |
long netAPayer = 0; |
long ttc = 0; |
if (n != null) { |
netAPayer = n.longValue(); |
ttc = n.longValue(); |
} |
if (this.selAvoir.getSelectedId() > 1) { |
SQLTable tableAvoir = Configuration.getInstance().getDirectory().getElement("AVOIR_CLIENT").getTable(); |
if (n != null) { |
long ttc = n.longValue(); |
SQLRow rowAvoir = tableAvoir.getRow(this.selAvoir.getSelectedId()); |
long totalAvoir = ((Number) rowAvoir.getObject("MONTANT_TTC")).longValue(); |
totalAvoir -= ((Number) rowAvoir.getObject("MONTANT_SOLDE")).longValue(); |
963,24 → 1079,22 |
long l = ttc - totalAvoir; |
if (l < 0) { |
l = 0; |
this.textAvoirTTC.setValue(ttc); |
totalAvoirTTC = ttc; |
} else { |
this.textAvoirTTC.setValue(totalAvoir); |
totalAvoirTTC = totalAvoir; |
} |
this.textTotalAvoir.setValue(l); |
} else { |
this.textTotalAvoir.setValue(0l); |
netAPayer = l; |
} |
} else { |
if (n != null) { |
this.textTotalAvoir.setValue(n.longValue()); |
} else { |
this.textTotalAvoir.setValue(0l); |
} |
this.textAvoirTTC.setValue(0l); |
if (this.gestionTimbre) { |
Long timbre = this.totalTimbre.getValue(); |
if (timbre != null) { |
netAPayer += timbre; |
} |
} |
this.textNetAPayer.setValue(netAPayer); |
this.textAvoirTTC.setValue(totalAvoirTTC); |
} |
public int insert(SQLRow order) { |
return commit(order); |
1181,8 → 1295,6 |
this.tableFacture.createArticle(idSaisieVF, this.getElement()); |
createDocument(rowFacture); |
int idMvt = -1; |
if (!this.checkPrevisionnelle.isSelected()) { |
if (getMode() == Mode.MODIFICATION) { |
1267,6 → 1379,7 |
doWithRow.process(rowFacture); |
} |
} |
createDocument(rowFacture); |
} |
} catch (Exception e) { |
1532,6 → 1645,10 |
vals.put("ID_COMMERCIAL", rowsComm.getID()); |
} |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
Double d = prefs.getDouble(GestionCommercialeGlobalPreferencePanel.TAUX_TIMBRE_FISCAL, Double.valueOf(1)); |
vals.put("TAUX_TIMBRE_FISCAL", new BigDecimal(d)); |
vals.put("TOTAL_TIMBRE_FISCAL", 0L); |
// User |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance()); |
if (getTable().contains("ID_NUMEROTATION_AUTO")) { |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisItemSQLElement.java |
---|
15,6 → 15,7 |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable; |
import org.openconcerto.erp.core.common.ui.DeviseField; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.erp.utils.KDUtils; |
23,15 → 24,16 |
import org.openconcerto.sql.element.UISQLComponent; |
import org.openconcerto.sql.model.SQLRowAccessor; |
import org.openconcerto.sql.sqlobject.ElementComboBox; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline; |
import org.openconcerto.utils.ExceptionHandler; |
import org.openconcerto.utils.FileUtils; |
import java.awt.event.ActionEvent; |
import java.io.File; |
import java.io.IOException; |
import java.util.ArrayList; |
import java.util.List; |
57,7 → 59,9 |
l.add("PRIX_METRIQUE_VT_1"); |
l.add("ID_MODE_VENTE_ARTICLE"); |
} |
if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) { |
l.add("PA_HT"); |
} |
l.add("PV_HT"); |
l.add("QTE"); |
66,6 → 70,13 |
return l; |
} |
@Override |
protected SQLTableModelSourceOnline createTableSource() { |
SQLTableModelSourceOnline table = super.createTableSource(); |
return table; |
} |
protected List<String> getComboFields() { |
final List<String> l = new ArrayList<String>(); |
l.add("CODE"); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/element/DevisSQLElement.java |
---|
17,6 → 17,7 |
import org.openconcerto.erp.config.Gestion; |
import org.openconcerto.erp.core.common.component.TransfertBaseSQLComponent; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable; |
import org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent; |
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement; |
import org.openconcerto.erp.core.sales.quote.component.DevisSQLComponent; |
45,8 → 46,8 |
import org.openconcerto.sql.model.graph.Path; |
import org.openconcerto.sql.request.ListSQLRequest; |
import org.openconcerto.sql.sqlobject.ElementComboBoxUtils; |
import org.openconcerto.sql.ui.StringWithId; |
import org.openconcerto.sql.ui.light.GroupToLightUIConvertor; |
import org.openconcerto.sql.users.UserManager; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel; |
64,11 → 65,14 |
import org.openconcerto.ui.light.CustomEditorProvider; |
import org.openconcerto.ui.light.LightControler; |
import org.openconcerto.ui.light.LightUIComboElement; |
import org.openconcerto.ui.light.LightUIDescriptor; |
import org.openconcerto.ui.light.LightUIElement; |
import org.openconcerto.ui.light.LightUIFrame; |
import org.openconcerto.ui.light.LightUILine; |
import org.openconcerto.ui.light.LightUIPanel; |
import org.openconcerto.ui.light.LightUITable; |
import org.openconcerto.ui.light.LightUITextField; |
import org.openconcerto.ui.light.Row; |
import org.openconcerto.ui.light.RowSelectionSpec; |
import org.openconcerto.ui.light.TableContent; |
import org.openconcerto.ui.light.TableSpec; |
import org.openconcerto.ui.table.TimestampTableCellRenderer; |
79,6 → 83,7 |
import org.openconcerto.utils.FileUtils; |
import org.openconcerto.utils.ListMap; |
import org.openconcerto.utils.cc.ITransformer; |
import org.openconcerto.utils.ui.StringWithId; |
import java.awt.Desktop; |
import java.awt.event.ActionEvent; |
101,6 → 106,10 |
import javax.swing.JOptionPane; |
import javax.swing.SwingWorker; |
import org.jdom.Document; |
import org.jdom.Element; |
import org.jdom.input.DOMBuilder; |
public class DevisSQLElement extends ComptaSQLConfElement { |
public static final String TABLENAME = "DEVIS"; |
162,11 → 171,11 |
private SQLElement eltClient = Configuration.getInstance().getDirectory().getElement(((ComptaPropsConfiguration) Configuration.getInstance()).getRootSociete().getTable("CLIENT")); |
public void actionPerformed(ActionEvent e) { |
if (edit == null) { |
edit = new EditFrame(eltClient, EditMode.MODIFICATION); |
if (this.edit == null) { |
this.edit = new EditFrame(this.eltClient, EditMode.MODIFICATION); |
} |
edit.selectionId(IListe.get(e).getSelectedRow().getForeignID("ID_CLIENT")); |
edit.setVisible(true); |
this.edit.selectionId(IListe.get(e).getSelectedRow().getForeignID("ID_CLIENT")); |
this.edit.setVisible(true); |
} |
}, false); |
actionClient.setPredicate(IListeEvent.getSingleSelectionPredicate()); |
525,7 → 534,9 |
l.add("ID_CLIENT"); |
l.add("OBJET"); |
l.add("ID_COMMERCIAL"); |
if (UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) { |
l.add("T_HA"); |
} |
l.add("T_HT"); |
l.add("T_TTC"); |
l.add("INFOS"); |
535,8 → 546,54 |
return l; |
} |
@Override |
protected SQLTableModelSourceOnline createTableSource() { |
SQLTableModelSourceOnline table = super.createTableSource(); |
final BaseSQLTableModelColumn colAdrLiv = new BaseSQLTableModelColumn("Adresse de livraison", String.class) { |
@Override |
protected Object show_(SQLRowAccessor r) { |
SQLRowAccessor rowAd; |
if (!r.isForeignEmpty("ID_ADRESSE_LIVRAISON")) { |
rowAd = r.getForeign("ID_ADRESSE_LIVRAISON"); |
} else if (!r.getForeign("ID_CLIENT").isForeignEmpty("ID_ADRESSE_L")) { |
rowAd = r.getForeign("ID_CLIENT").getForeign("ID_ADRESSE_L"); |
} else { |
rowAd = r.getForeign("ID_CLIENT").getForeign("ID_ADRESSE"); |
} |
String lib = rowAd.getString("LIBELLE") + " " + rowAd.getString("VILLE"); |
return lib; |
} |
@Override |
public Set<FieldPath> getPaths() { |
SQLTable devisTable = getTable(); |
Path p = new Path(devisTable); |
p = p.add(devisTable.getField("ID_CLIENT")); |
p = p.add(p.getLast().getField("ID_ADRESSE_L")); |
Path p2 = new Path(devisTable); |
p2 = p2.add(devisTable.getField("ID_CLIENT")); |
p2 = p2.add(p2.getLast().getField("ID_ADRESSE")); |
Path p3 = new Path(devisTable); |
p3 = p3.add(devisTable.getField("ID_ADRESSE_LIVRAISON")); |
return CollectionUtils.createSet(new FieldPath(p, "LIBELLE"), new FieldPath(p, "VILLE"), new FieldPath(p2, "LIBELLE"), new FieldPath(p2, "VILLE"), new FieldPath(p3, "LIBELLE"), |
new FieldPath(p3, "VILLE")); |
} |
}; |
table.getColumns().add(3, colAdrLiv); |
return table; |
} |
@Override |
public CollectionMap<String, String> getShowAs() { |
CollectionMap<String, String> map = new CollectionMap<String, String>(); |
603,63 → 660,123 |
} |
@Override |
public LightUIDescriptor getUIDescriptorForModification(PropsConfiguration configuration, long quoteId) { |
public LightUIFrame createUIFrameForModification(PropsConfiguration configuration, long id, long userId) { |
final GroupToLightUIConvertor convertor = new GroupToLightUIConvertor(configuration); |
convertor.setCustomEditorProvider("sales.quote.items.list", getItemsCustomEditorProvider(configuration, quoteId)); |
final LightUIDescriptor desc = convertor.convert(getGroupForModification()); |
convertor.setCustomEditorProvider("sales.quote.items.list", getItemsCustomEditorProvider(configuration, id)); |
final LightUIFrame desc = convertor.convert(getGroupForModification()); |
return desc; |
} |
public LightUIDescriptor getUIDescriptorForCreation(PropsConfiguration configuration) { |
public LightUIFrame createUIFrameForCreation(final PropsConfiguration configuration, final long userId) { |
final GroupToLightUIConvertor convertor = new GroupToLightUIConvertor(configuration); |
convertor.setCustomEditorProvider("sales.quote.items.list", getItemsCustomEditorProvider(configuration, -1)); |
final LightUIDescriptor desc = convertor.convert(getGroupForCreation()); |
final LightUIFrame desc = convertor.convert(getGroupForCreation()); |
return desc; |
} |
CustomEditorProvider getItemsCustomEditorProvider(final PropsConfiguration configuration, final long quoteId) { |
CustomEditorProvider getItemsCustomEditorProvider(final PropsConfiguration configuration, final long quoteId) throws IllegalArgumentException { |
return new CustomEditorProvider() { |
@Override |
public LightUIElement createUIElement(String id) { |
LightUIElement eList = new LightUIElement(); |
eList.setId(id); |
eList.setType(LightUIElement.TYPE_LIST); |
eList.setFillWidth(true); |
ColumnSpec c1 = new ColumnSpec("sales.quote.item.style", StringWithId.class, "Style", new StringWithId(2, "Normal"), 50, true, new LightUIComboElement("sales.quote.item.style")); |
ColumnSpec c2 = new ColumnSpec("sales.quote.item.code", String.class, "Code", "", 50, true, new LightUITextField("sales.quote.item.code")); |
ColumnSpec c3 = new ColumnSpec("sales.quote.item.label", String.class, "Nom", "", 50, true, new LightUITextField("sales.quote.item.name")); |
ColumnSpec c4 = new ColumnSpec("sales.quote.item.description", String.class, "Descriptif", "", 50, true, new LightUITextField("sales.quote.item.description")); |
ColumnSpec c5 = new ColumnSpec("sales.quote.item.purchase.unit.price", BigDecimal.class, "P.U. Achat HT", new BigDecimal(0), 50, true, new LightUITextField( |
final ColumnSpec c1 = new ColumnSpec("sales.quote.item.style", StringWithId.class, "Style", new StringWithId(2, "Normal"), true, new LightUIComboElement("sales.quote.item.style")); |
final ColumnSpec c2 = new ColumnSpec("sales.quote.item.code", String.class, "Code", "", true, new LightUITextField("sales.quote.item.code")); |
final ColumnSpec c3 = new ColumnSpec("sales.quote.item.label", String.class, "Nom", "", true, new LightUITextField("sales.quote.item.name")); |
final ColumnSpec c4 = new ColumnSpec("sales.quote.item.description", String.class, "Descriptif", "", true, new LightUITextField("sales.quote.item.description")); |
final ColumnSpec c5 = new ColumnSpec("sales.quote.item.purchase.unit.price", BigDecimal.class, "P.U. Achat HT", new BigDecimal(0), true, new LightUITextField( |
"sales.quote.item.purchase.unit.price")); |
ColumnSpec c6 = new ColumnSpec("sales.quote.item.sales.unit.price", BigDecimal.class, "P.U. Vente HT", new BigDecimal(0), 50, true, new LightUITextField( |
final ColumnSpec c6 = new ColumnSpec("sales.quote.item.sales.unit.price", BigDecimal.class, "P.U. Vente HT", new BigDecimal(0), true, new LightUITextField( |
"sales.quote.item.sales.unit.price")); |
ColumnSpec c7 = new ColumnSpec("sales.quote.item.quantity", Integer.class, "Quantité", new BigDecimal(1), 50, true, new LightUITextField("sales.quote.item.quantity")); |
final ColumnSpec c7 = new ColumnSpec("sales.quote.item.quantity", Integer.class, "Quantité", new BigDecimal(1), true, new LightUITextField("sales.quote.item.quantity")); |
List<ColumnSpec> cols = new ArrayList<ColumnSpec>(); |
cols.add(c1); |
cols.add(c2); |
cols.add(c3); |
cols.add(c4); |
cols.add(c5); |
cols.add(c6); |
cols.add(c7); |
List<String> visibleIds = new ArrayList<String>(); |
for (ColumnSpec c : cols) { |
visibleIds.add(c.getId()); |
final List<ColumnSpec> columnsSpec = new ArrayList<ColumnSpec>(); |
final List<String> possibleColumnIds = new ArrayList<String>(); |
columnsSpec.add(c1); |
columnsSpec.add(c2); |
columnsSpec.add(c3); |
columnsSpec.add(c4); |
columnsSpec.add(c5); |
columnsSpec.add(c6); |
columnsSpec.add(c7); |
for (ColumnSpec c : columnsSpec) { |
possibleColumnIds.add(c.getId()); |
} |
ColumnsSpec columsSpec = new ColumnsSpec("sales.quote.items", cols, visibleIds, null); |
final String lId = "sales.quote.items"; |
final long userId = UserManager.getUserID(); |
Document columnsPrefs = null; |
try { |
final DOMBuilder in = new DOMBuilder(); |
final org.w3c.dom.Document w3cDoc = Configuration.getInstance().getXMLConf(userId, lId); |
if (w3cDoc != null) { |
columnsPrefs = in.build(w3cDoc); |
} |
} catch (Exception ex) { |
throw new IllegalArgumentException("DevisSQLElement getItemsCustomEditorProvider - Failed to get ColumnPrefs for descriptor " + lId + " and for user " + userId + "\n" |
+ ex.getMessage()); |
} |
final TableSpec rawContent = new TableSpec(); |
rawContent.setColumns(columsSpec); |
final Element rootElement = columnsPrefs.getRootElement(); |
if (!rootElement.getName().equals("list")) { |
throw new IllegalArgumentException("invalid xml, roots node list expected but " + rootElement.getName() + " found"); |
} |
final List<Element> xmlColumns = rootElement.getChildren(); |
final int columnsCount = columnsSpec.size(); |
if (xmlColumns.size() != columnsCount) { |
throw new IllegalArgumentException("incorrect columns count in xml"); |
} |
for (int i = 0; i < columnsCount; i++) { |
final ColumnSpec columnSpec = columnsSpec.get(i); |
final String columnId = columnSpec.getId(); |
boolean find = false; |
for (int j = 0; j < columnsCount; j++) { |
final Element xmlColumn = xmlColumns.get(j); |
final String xmlColumnId = xmlColumn.getAttribute("id").getValue(); |
if (xmlColumnId.equals(columnId)) { |
if (!xmlColumn.getName().equals("column")) { |
throw new IllegalArgumentException("ColumnSpec setPrefs - Invalid xml, element node column expected but " + xmlColumn.getName() + " found"); |
} |
if (xmlColumn.getAttribute("width") == null || xmlColumn.getAttribute("min-width") == null || xmlColumn.getAttribute("max-width") == null) { |
throw new IllegalArgumentException("ColumnSpec setPrefs - Invalid column node for " + columnId + ", it must have attribute width, min-width, max-width"); |
} |
final int width = Integer.parseInt(xmlColumn.getAttribute("width").getValue()); |
final int maxWidth = Integer.parseInt(xmlColumn.getAttribute("max-width").getValue()); |
final int minWidth = Integer.parseInt(xmlColumn.getAttribute("min-width").getValue()); |
columnSpec.setPrefs(width, maxWidth, minWidth); |
if (i != j) { |
final ColumnSpec swap = columnsSpec.get(i); |
columnsSpec.set(i, columnsSpec.get(j)); |
columnsSpec.set(j, swap); |
} |
find = true; |
break; |
} |
} |
if (!find) { |
throw new IllegalArgumentException("xml contain unknow column: " + columnId); |
} |
} |
final ColumnsSpec cSpec = new ColumnsSpec(lId, columnsSpec, possibleColumnIds, null); |
cSpec.setAllowMove(true); |
cSpec.setAllowResize(true); |
final RowSelectionSpec selectionSpec = new RowSelectionSpec(id); |
final TableSpec tSpec = new TableSpec(id, selectionSpec, cSpec); |
tSpec.setColumns(cSpec); |
if (quoteId > 0) { |
// send: id,value |
SQLTable table = configuration.getDirectory().getElement("DEVIS_ELEMENT").getTable(); |
final SQLTable table = configuration.getDirectory().getElement("DEVIS_ELEMENT").getTable(); |
final List<SQLField> fieldsToFetch = new ArrayList<SQLField>(); |
for (ColumnSpec cs : cols) { |
for (ColumnSpec cs : columnsSpec) { |
String colId = cs.getId(); |
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId); |
if (f != null) { |
674,9 → 791,9 |
List<Row> rows = new ArrayList<Row>(); |
for (final SQLRowValues vals : fetchedRows) { |
Row r = new Row(vals.getID(), cols.size()); |
Row r = new Row(vals.getID(), columnsSpec.size()); |
List<Object> values = new ArrayList<Object>(); |
for (ColumnSpec cs : cols) { |
for (ColumnSpec cs : columnsSpec) { |
String colId = cs.getId(); |
SQLField f = configuration.getFieldMapper().getSQLFieldForItem(colId); |
if (f != null) { |
706,13 → 823,14 |
TableContent tableContent = new TableContent(); |
tableContent.setRows(rows); |
// tableContent.setSpec(new RowSpec()); |
rawContent.setContent(tableContent); |
tSpec.setContent(tableContent); |
} |
eList.setRawContent(rawContent); |
final LightUITable eList = new LightUITable(id); |
eList.setTableSpec(tSpec); |
LightUIDescriptor desc = new LightUIDescriptor("sales.quote.items.list"); |
LightUIPanel desc = new LightUIPanel("sales.quote.items.list"); |
desc.setGridWidth(1); |
desc.setFillWidth(true); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/ui/ListeDesDevisPanel.java |
---|
14,6 → 14,7 |
package org.openconcerto.erp.core.sales.quote.ui; |
import org.openconcerto.erp.config.ComptaPropsConfiguration; |
import org.openconcerto.erp.core.common.ui.AbstractVenteArticleItemTable; |
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel; |
import org.openconcerto.erp.core.common.ui.IListTotalPanel; |
import org.openconcerto.erp.core.sales.invoice.ui.DateEnvoiRenderer; |
29,6 → 30,7 |
import org.openconcerto.sql.model.Where; |
import org.openconcerto.sql.model.graph.Path; |
import org.openconcerto.sql.model.graph.PathBuilder; |
import org.openconcerto.sql.users.rights.UserRightsManager; |
import org.openconcerto.sql.view.ListeAddPanel; |
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn; |
import org.openconcerto.sql.view.list.IListe; |
380,7 → 382,8 |
} |
}, IListTotalPanel.Type.MOYENNE_MARGE)); |
total = new IListTotalPanel(pane.getListe(), fields, null, "Total Global"); |
} else if (this.eltDevis.getTable().getFieldsName().contains("T_HA") && pane.getListe().getSource().getColumns(this.eltDevis.getTable().getField("T_HA")) != null) { |
} else if (this.eltDevis.getTable().getFieldsName().contains("T_HA") && pane.getListe().getSource().getColumns(this.eltDevis.getTable().getField("T_HA")) != null |
&& UserRightsManager.getCurrentUserRights().haveRight(AbstractVenteArticleItemTable.SHOW_PRIX_ACHAT_CODE)) { |
total = new IListTotalPanel(pane.getListe(), Arrays.asList(this.eltDevis.getTable().getField("T_HA"), this.eltDevis.getTable().getField("T_HT"))); |
} else { |
total = new IListTotalPanel(pane.getListe(), Arrays.asList(this.eltDevis.getTable().getField("T_HT"))); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/quote/component/DevisSQLComponent.java |
---|
31,6 → 31,7 |
import org.openconcerto.erp.core.sales.quote.ui.DevisItemTable; |
import org.openconcerto.erp.panel.PanelOOSQLComponent; |
import org.openconcerto.erp.preferences.GestionClientPreferencePanel; |
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel; |
import org.openconcerto.map.ui.ITextComboVilleViewer; |
import org.openconcerto.sql.Configuration; |
import org.openconcerto.sql.element.BaseSQLComponent; |
292,6 → 293,20 |
this.add(comboClient, c); |
addRequiredSQLObject(comboClient, "ID_CLIENT"); |
comboClient.addModelListener("wantedID", new PropertyChangeListener() { |
@Override |
public void propertyChange(PropertyChangeEvent evt) { |
int wantedID = comboClient.getWantedID(); |
if (wantedID != SQLRow.NONEXISTANT_ID && wantedID >= SQLRow.MIN_VALID_ID) { |
final SQLRow rowClient = getTable().getForeignTable("ID_CLIENT").getRow(wantedID); |
if (!rowClient.isForeignEmpty("ID_COMMERCIAL")) { |
comboCommercial.setValue(rowClient.getForeignID("ID_COMMERCIAL")); |
} |
} |
} |
}); |
if (this.displayDpt) { |
c.gridx++; |
c.gridwidth = 1; |
329,6 → 344,8 |
} |
final ElementComboBox boxTarif = new ElementComboBox(); |
SQLPreferences prefs = SQLPreferences.getMemCached(getTable().getDBRoot()); |
if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.ADDRESS_SPEC, true)) { |
final SQLElement adrElement = getElement().getForeignElement("ID_ADRESSE"); |
final AddressChoiceUI addressUI = new AddressChoiceUI(); |
345,12 → 362,14 |
.getComboAdrF() |
.getRequest() |
.setWhere( |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice.getId()))); |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Invoice |
.getId()))); |
addressUI |
.getComboAdrL() |
.getRequest() |
.setWhere( |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery.getId()))); |
new Where(adrElement.getTable().getField("ID_CLIENT"), "=", wantedID).and(new Where(adrElement.getTable().getField("TYPE"), "=", AdresseType.Delivery |
.getId()))); |
} else { |
addressUI.getComboAdrF().getRequest().setWhere(Where.FALSE); |
addressUI.getComboAdrL().getRequest().setWhere(Where.FALSE); |
357,7 → 376,7 |
} |
} |
}); |
} |
if (getTable().contains("ID_CONTACT")) { |
// Contact Client |
c.gridx = 0; |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/model/ProductHelper.java |
---|
328,7 → 328,7 |
int id = v.getForeignID("ID_ARTICLE"); |
int qte = v.getInt("QTE"); |
final BigDecimal unitCost = costs.get(Long.valueOf(id)); |
BigDecimal lineCost = unitCost.multiply(BigDecimal.valueOf(qte)); |
BigDecimal lineCost = unitCost.multiply(BigDecimal.valueOf(qte)).multiply(v.getBigDecimal("QTE_UNITAIRE")); |
if (cost == null) { |
cost = BigDecimal.ZERO; |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ReferenceArticleSQLComponent.java |
---|
23,6 → 23,9 |
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement; |
import org.openconcerto.erp.core.sales.product.ui.ArticleDesignationTable; |
import org.openconcerto.erp.core.sales.product.ui.ArticleTarifTable; |
import org.openconcerto.erp.core.sales.product.ui.ProductItemListTable; |
import org.openconcerto.erp.core.sales.product.ui.ProductQtyPriceListTable; |
import org.openconcerto.erp.core.sales.product.ui.RowValuesTableEditionPanel; |
import org.openconcerto.erp.model.ISQLCompteSelector; |
import org.openconcerto.erp.preferences.DefaultNXProps; |
import org.openconcerto.erp.preferences.GestionArticleGlobalPreferencePanel; |
91,6 → 94,8 |
private ArticleDesignationTable tableDes = new ArticleDesignationTable(); |
private ArticleTarifTable tableTarifVente = new ArticleTarifTable(this); |
private ProductQtyPriceListTable tableTarifQteVente = new ProductQtyPriceListTable(this); |
private ProductItemListTable tableBom; |
private final JTextField textMarge = new JTextField(15); |
private DocumentListener pieceHAArticle = new SimpleDocumentListener() { |
194,7 → 199,10 |
public ReferenceArticleSQLComponent(SQLElement elt) { |
super(elt); |
if (elt.getTable().getDBRoot().contains("ARTICLE_ELEMENT")) { |
this.tableBom = new ProductItemListTable(); |
} |
} |
@Override |
public void select(SQLRowAccessor r) { |
203,6 → 211,10 |
this.checkObs.setVisible(true); |
this.tableTarifVente.setArticleValues(r); |
this.tableTarifVente.insertFrom("ID_ARTICLE", r.getID()); |
this.tableTarifQteVente.insertFrom("ID_ARTICLE", r.getID()); |
if (this.tableBom != null) { |
this.tableBom.insertFrom("ID_ARTICLE_PARENT", r.getID()); |
} |
this.tableDes.insertFrom("ID_ARTICLE", r.getID()); |
if (this.codeFournisseurTable != null) { |
this.codeFournisseurTable.insertFrom("ID_ARTICLE", r.getID()); |
339,7 → 351,11 |
c.weightx = 1; |
c.weighty = 1; |
pane.add("Tarifs de vente", createTarifPanel()); |
pane.add("Tarifs de vente spéciaux", createTarifPanel()); |
pane.add("Tarifs de vente par quantité", createTarifQtePanel()); |
if (this.tableBom != null) { |
pane.add("Nomenclature", createBOMpanel()); |
} |
pane.add("Exportation", createExportationPanel()); |
pane.add("Achat", createAchatPanel()); |
pane.add("Stock", createStockPanel()); |
751,16 → 767,18 |
if (rowTarif == null || rowTarif.isUndefined()) { |
return; |
} |
int nbRows = tableTarifVente.getModel().getRowCount(); |
// int nbRows = tableTarifVente.getModel().getRowCount(); |
for (int i = 0; i < nbRows; i++) { |
SQLRowValues rowVals = tableTarifVente.getModel().getRowValuesAt(i); |
int idTarif = Integer.parseInt(rowVals.getObject("ID_TARIF").toString()); |
if (idTarif == rowTarif.getID()) { |
JOptionPane.showMessageDialog(null, "Impossible d'ajouter.\nLe tarif est déjà présent dans la liste!"); |
return; |
} |
} |
// FIXME Check with qty |
// for (int i = 0; i < nbRows; i++) { |
// SQLRowValues rowVals = tableTarifVente.getModel().getRowValuesAt(i); |
// int idTarif = Integer.parseInt(rowVals.getObject("ID_TARIF").toString()); |
// if (idTarif == rowTarif.getID()) { |
// JOptionPane.showMessageDialog(null, |
// "Impossible d'ajouter.\nLe tarif est déjà présent dans la liste!"); |
// return; |
// } |
// } |
SQLRowValues rowVals = new SQLRowValues(Configuration.getInstance().getBase().getTable("ARTICLE_TARIF")); |
if (getSelectedID() > 1) { |
785,6 → 803,38 |
return panel; |
} |
private JPanel createBOMpanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.fill = GridBagConstraints.BOTH; |
c.weightx = 1; |
c.weighty = 1; |
c.gridx = 0; |
c.fill = GridBagConstraints.BOTH; |
this.tableBom.setOpaque(false); |
panel.add(new RowValuesTableEditionPanel(this.tableBom), c); |
return panel; |
} |
private JPanel createTarifQtePanel() { |
JPanel panel = new JPanel(new GridBagLayout()); |
panel.setOpaque(false); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
c.gridwidth = GridBagConstraints.REMAINDER; |
c.fill = GridBagConstraints.BOTH; |
c.weightx = 1; |
c.weighty = 1; |
c.gridx = 0; |
c.fill = GridBagConstraints.BOTH; |
this.tableTarifQteVente.setOpaque(false); |
panel.add(new RowValuesTableEditionPanel(this.tableTarifQteVente), c); |
return panel; |
} |
protected void getMontantPanel(final GridBagConstraints c, DefaultProps props) { |
c.gridx = 0; |
c.gridy++; |
1126,6 → 1176,11 |
public void update() { |
super.update(); |
this.tableTarifVente.updateField("ID_ARTICLE", getSelectedID()); |
this.tableTarifQteVente.updateField("ID_ARTICLE", getSelectedID()); |
if (this.tableBom != null) { |
this.tableBom.updateField("ID_ARTICLE_PARENT", getSelectedID()); |
} |
this.tableDes.updateField("ID_ARTICLE", getSelectedID()); |
if (this.codeFournisseurTable != null) { |
this.codeFournisseurTable.updateField("ID_ARTICLE", getSelectedID()); |
1184,6 → 1239,10 |
public int insert(SQLRow order) { |
int id = super.insert(order); |
this.tableTarifVente.updateField("ID_ARTICLE", id); |
this.tableTarifQteVente.updateField("ID_ARTICLE", id); |
if (this.tableBom != null) { |
this.tableBom.updateField("ID_ARTICLE_PARENT", id); |
} |
this.tableDes.updateField("ID_ARTICLE", id); |
if (this.codeFournisseurTable != null) { |
this.codeFournisseurTable.updateField("ID_ARTICLE", id); |
1195,9 → 1254,7 |
protected SQLRowValues createDefaults() { |
SQLRowValues rowVals = new SQLRowValues(getTable()); |
SQLRow row = getTable().getRow(getTable().getUndefinedID()); |
rowVals.put("ID_TAXE", row.getInt("ID_TAXE")); |
rowVals.put("ID_TAXE", TaxeCache.getCache().getFirstTaxe().getID()); |
rowVals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE); |
rowVals.put("ID_MODE_VENTE_ARTICLE", ReferenceArticleSQLElement.A_LA_PIECE); |
selectModeVente(ReferenceArticleSQLElement.A_LA_PIECE); |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/component/ProductItemGroup.java |
---|
New file |
0,0 → 1,27 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.erp.core.sales.product.component; |
import org.openconcerto.ui.group.Group; |
public class ProductItemGroup extends Group { |
public ProductItemGroup() { |
super("sales.product.bom.default"); |
addItem("sales.product.bom.product"); |
addItem("sales.product.bom.quantity"); |
addItem("sales.product.bom.unit"); |
} |
} |
/trunk/OpenConcerto/src/org/openconcerto/erp/core/sales/product/element/ReliquatSQLElement.java |
---|
New file |
0,0 → 1,188 |
/* |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
* |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved. |
* |
* The contents of this file are subject to the terms of the GNU General Public License Version 3 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific |
* language governing permissions and limitations under the License. |
* |
* When distributing the software, include this License Header Notice in each file. |
*/ |
package org.openconcerto.erp.core.sales.product.element; |
import java.awt.GridBagConstraints; |
import java.awt.GridBagLayout; |
import java.awt.event.ActionEvent; |
import java.sql.SQLException; |
import java.util.ArrayList; |
import java.util.List; |
import javax.swing.AbstractAction; |
import javax.swing.JLabel; |
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement; |
import org.openconcerto.erp.core.sales.invoice.ui.FactureAffacturerTable; |
import org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent; |
import org.openconcerto.sql.element.BaseSQLComponent; |
import org.openconcerto.sql.element.SQLComponent; |
import org.openconcerto.sql.model.SQLRowValues; |
import org.openconcerto.sql.view.EditFrame; |
import org.openconcerto.sql.view.EditPanel.EditMode; |
import org.openconcerto.sql.view.EditPanelListener; |
import org.openconcerto.sql.view.list.IListe; |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent; |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction; |
import org.openconcerto.ui.DefaultGridBagConstraints; |
public class ReliquatSQLElement extends ComptaSQLConfElement { |
private final String tableBonName; |
static public class ReliquatBRSQLElement extends ReliquatSQLElement { |
public ReliquatBRSQLElement() { |
super("RELIQUAT_BR", "un reliquat de BR", "reliquats de BR", "BON_RECEPTION"); |
} |
@Override |
protected String createCode() { |
return createCodeFromPackage() + ".reliquatbr"; |
} |
} |
public ReliquatSQLElement(final String tableName, final String singularName, final String pluralName, final String tableBonName) { |
super(tableName, singularName, pluralName); |
this.tableBonName = tableBonName; |
PredicateRowAction actionTR = new PredicateRowAction(new AbstractAction("Transfert vers Bon") { |
@Override |
public void actionPerformed(ActionEvent e) { |
final List<SQLRowValues> rows = IListe.get(e).getSelectedRows(); |
EditFrame frame = new EditFrame(getForeignElement("ID_" + tableBonName), EditMode.CREATION); |
frame.addEditPanelListener(new EditPanelListener() { |
@Override |
public void modified() { |
} |
@Override |
public void inserted(int id) { |
for (SQLRowValues rowVals : rows) { |
try { |
SQLRowValues upRowVals = rowVals.createEmptyUpdateRow(); |
upRowVals.put("ID_BON_RECEPTION", id); |
upRowVals.update(); |
} catch (SQLException exn) { |
exn.printStackTrace(); |
} |
} |
} |
@Override |
public void deleted() { |
} |
@Override |
public void cancelled() { |
} |
}); |
BonReceptionSQLComponent comp = (BonReceptionSQLComponent) frame.getSQLComponent(); |
comp.loadFromReliquat(rows); |
frame.setVisible(true); |
} |
}, true); |
actionTR.setPredicate(IListeEvent.getNonEmptySelectionPredicate()); |
getRowActions().add(actionTR); |
} |
public ReliquatSQLElement() { |
this("RELIQUAT_BL", "un reliquat de BL", "reliquats de BL", "BON_DE_LIVRAISON"); |
} |
@Override |
protected String getParentFFName() { |
return "ID_" + this.tableBonName; |
} |
protected List<String> getListFields() { |
final List<String> l = new ArrayList<String>(); |
// l.add("DATE"); |
l.add("ID_" + this.tableBonName + "_ORIGINE"); |
l.add("ID_ARTICLE"); |
l.add("QTE_UNITAIRE"); |
l.add("ID_UNITE_VENTE"); |
l.add("QTE"); |
l.add("ID_" + this.tableBonName); |
return l; |
} |
protected List<String> getComboFields() { |
final List<String> l = new ArrayList<String>(); |
l.add("DATE"); |
l.add("QTE"); |
return l; |
} |
/* |
* (non-Javadoc) |
* |
* @see org.openconcerto.devis.SQLElement#getComponent() |
*/ |
public SQLComponent createComponent() { |
return new BaseSQLComponent(this) { |
FactureAffacturerTable table = new FactureAffacturerTable(null); |
public void addViews() { |
// FIXME CREATION DE L'UI |
this.setLayout(new GridBagLayout()); |
GridBagConstraints c = new DefaultGridBagConstraints(); |
this.add(new JLabel(getLabelFor("NB_FACT")), c); |
// c.gridx++; |
// c.weightx = 1; |
// JTextField fieldNbFact = new JTextField(); |
// this.add(fieldNbFact, c); |
// |
// c.gridx++; |
// c.weightx = 0; |
// this.add(new JLabel(getLabelFor("MONTANT_FACT")), c); |
// c.gridx++; |
// c.weightx = 1; |
// DeviseField fieldMontantFact = new DeviseField(); |
// this.add(fieldMontantFact, c); |
// |
// c.gridx++; |
// c.weightx = 0; |
// this.add(new JLabel(getLabelFor("DATE")), c); |
// c.gridx++; |
// |
// JDate date = new JDate(); |
// this.add(date, c); |
// |
// c.gridwidth = GridBagConstraints.REMAINDER; |
// c.gridx = 0; |
// c.gridy++; |
// this.add(this.table, c); |
// |
// this.addView(fieldNbFact, "NB_FACT"); |
// this.addSQLObject(fieldMontantFact, "MONTANT_FACT"); |
// this.addView(date, "DATE"); |
} |
}; |
} |
@Override |
protected String createCode() { |
return createCodeFromPackage() + ".reliquatbl"; |
} |
} |