OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 147 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 147 Rev 164
Line 1... Line 1...
1
package org.openconcerto.modules.finance.accounting.exchangerates;
1
package org.openconcerto.modules.finance.accounting.exchangerates;
2
 
2
 
3
import java.awt.GraphicsEnvironment;
3
import java.awt.GraphicsEnvironment;
4
import java.io.File;
-
 
5
import java.io.IOException;
4
import java.io.IOException;
6
import java.math.BigDecimal;
5
import java.math.BigDecimal;
7
import java.sql.ResultSet;
6
import java.sql.ResultSet;
8
import java.sql.SQLException;
7
import java.sql.SQLException;
9
import java.util.ArrayList;
8
import java.util.ArrayList;
Line 17... Line 16...
17
 
16
 
18
import javax.swing.JOptionPane;
17
import javax.swing.JOptionPane;
19
 
18
 
20
import org.apache.commons.dbutils.ResultSetHandler;
19
import org.apache.commons.dbutils.ResultSetHandler;
21
import org.openconcerto.erp.config.ComptaPropsConfiguration;
20
import org.openconcerto.erp.config.ComptaPropsConfiguration;
22
import org.openconcerto.erp.config.Gestion;
-
 
23
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
21
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
24
import org.openconcerto.erp.modules.AbstractModule;
22
import org.openconcerto.erp.modules.AbstractModule;
25
import org.openconcerto.erp.modules.DBContext;
23
import org.openconcerto.erp.modules.DBContext;
26
import org.openconcerto.erp.modules.ModuleFactory;
24
import org.openconcerto.erp.modules.ModuleFactory;
27
import org.openconcerto.erp.modules.ModuleManager;
-
 
28
import org.openconcerto.erp.modules.ModulePackager;
-
 
29
import org.openconcerto.erp.modules.ModulePreferencePanel;
25
import org.openconcerto.erp.modules.ModulePreferencePanel;
30
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
26
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
31
import org.openconcerto.erp.modules.ModuleVersion;
-
 
32
import org.openconcerto.erp.modules.RuntimeModuleFactory;
-
 
33
import org.openconcerto.sql.model.DBRoot;
27
import org.openconcerto.sql.model.DBRoot;
34
import org.openconcerto.sql.model.SQLBase;
28
import org.openconcerto.sql.model.SQLBase;
35
import org.openconcerto.sql.model.SQLRequestLog;
-
 
36
import org.openconcerto.sql.model.SQLRow;
29
import org.openconcerto.sql.model.SQLRow;
37
import org.openconcerto.sql.model.SQLRowListRSH;
30
import org.openconcerto.sql.model.SQLRowListRSH;
38
import org.openconcerto.sql.model.SQLSelect;
31
import org.openconcerto.sql.model.SQLSelect;
39
import org.openconcerto.sql.model.SQLTable;
32
import org.openconcerto.sql.model.SQLTable;
40
import org.openconcerto.sql.model.Where;
33
import org.openconcerto.sql.model.Where;
41
import org.openconcerto.sql.ui.ConnexionPanel;
-
 
42
import org.openconcerto.sql.utils.SQLUtils;
34
import org.openconcerto.sql.utils.SQLUtils;
43
import org.openconcerto.utils.PrefType;
35
import org.openconcerto.utils.PrefType;
44
 
36
 
45
public final class Module extends AbstractModule {
37
public final class Module extends AbstractModule {
46
 
38
 
47
    public static final String TABLE_EXPENSE = "EXPENSE";
39
    public static final String TABLE_EXPENSE = "EXPENSE";
48
    public static final String TABLE_EXPENSE_STATE = "EXPENSE_STATE";
40
    public static final String TABLE_EXPENSE_STATE = "EXPENSE_STATE";
49
    public static final String EXPENSE_RATE_NOT_DOWNLOAD_PREF = "EXPENSE_RATE_NOT_DOWNLOAD_PREF";
41
    public static final String EXPENSE_RATE_NOT_DOWNLOAD_PREF = "EXPENSE_RATE_NOT_DOWNLOAD_PREF";
50
    public static ModuleVersion MODULE_VERSION = new ModuleVersion(1, 0);
-
 
51
    private CurrencyConverter commercialConverter = null;
42
    private CurrencyConverter commercialConverter = null;
52
 
43
 
53
    public Module(ModuleFactory f) throws IOException {
44
    public Module(ModuleFactory f) throws IOException {
54
        super(f);
45
        super(f);
55
    }
46
    }
Line 64... Line 55...
64
    }
55
    }
65
 
56
 
66
    @Override
57
    @Override
67
    protected void start() {
58
    protected void start() {
68
        final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
59
        final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
69
        Boolean b = ModuleManager.getInstance().getFactories().get("org.openconcerto.modules.finance.accounting.exchangerates").get(Module.MODULE_VERSION).getSQLPreferences(root)
-
 
70
                .getBoolean(EXPENSE_RATE_NOT_DOWNLOAD_PREF, false);
60
        Boolean b = getFactory().getSQLPreferences(root).getBoolean(EXPENSE_RATE_NOT_DOWNLOAD_PREF, false);
71
        if (!b) {
61
        if (!b) {
72
            final Thread t = new Thread() {
62
            final Thread t = new Thread() {
73
                public void run() {
63
                public void run() {
74
                    // Wait 1s to prevent too many internet access at startup
64
                    // Wait 1s to prevent too many internet access at startup
75
                    try {
65
                    try {
Line 136... Line 126...
136
            }
126
            }
137
        }
127
        }
138
    }
128
    }
139
 
129
 
140
    @Override
130
    @Override
141
    public List<ModulePreferencePanelDesc> getPrefDescriptors() {
131
    public List<ModulePreferencePanelDesc> getPrefDescriptors(final DBRoot root) {
142
        return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Gestion des devises") {
132
        return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Gestion des devises") {
143
            @Override
133
            @Override
144
            protected ModulePreferencePanel createPanel() {
134
            protected ModulePreferencePanel createPanel() {
145
                return new ModulePreferencePanel("Gestion des devises") {
135
                return new ModulePreferencePanel(root, "Gestion des devises") {
146
                    @Override
136
                    @Override
147
                    protected void addViews() {
137
                    protected void addViews() {
148
 
-
 
149
                        final SQLPrefView<Boolean> view = new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Ne pas télécharger les nouveaux taux au lancement du logiciel",
138
                        final SQLPrefView<Boolean> view = new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Ne pas télécharger les nouveaux taux au lancement du logiciel",
150
                                EXPENSE_RATE_NOT_DOWNLOAD_PREF);
139
                                EXPENSE_RATE_NOT_DOWNLOAD_PREF);
151
                        this.addView(view);
140
                        this.addView(view);
152
                    }
141
                    }
153
                };
142
                };
Line 265... Line 254...
265
 
254
 
266
    @Override
255
    @Override
267
    protected void stop() {
256
    protected void stop() {
268
    }
257
    }
269
 
258
 
270
    public static void main(String[] args) throws IOException {
-
 
271
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
-
 
272
        final File propsFile = new File("module.properties");
-
 
273
        System.out.println(propsFile.getAbsolutePath());
-
 
274
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
-
 
275
        SQLRequestLog.setEnabled(true);
-
 
276
        SQLRequestLog.showFrame();
-
 
277
        // uncomment to create and use the jar
-
 
278
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
-
 
279
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
-
 
280
        // final ModuleFactory factory = new JarModuleFactory(jar);
-
 
281
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
-
 
282
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
-
 
283
        Gestion.main(args);
-
 
284
    }
-
 
285
 
-
 
286
}
259
}