47 |
ilm |
1 |
package org.openconcerto.modules.google.docs;
|
|
|
2 |
|
|
|
3 |
import java.io.File;
|
|
|
4 |
import java.io.IOException;
|
|
|
5 |
import java.util.Arrays;
|
|
|
6 |
import java.util.List;
|
|
|
7 |
|
|
|
8 |
import javax.swing.UIManager;
|
|
|
9 |
|
|
|
10 |
import org.openconcerto.erp.config.Gestion;
|
|
|
11 |
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
|
|
|
12 |
import org.openconcerto.erp.core.sales.quote.element.DevisSQLElement;
|
|
|
13 |
import org.openconcerto.erp.modules.AbstractModule;
|
|
|
14 |
import org.openconcerto.erp.modules.ComponentsContext;
|
|
|
15 |
import org.openconcerto.erp.modules.DBContext;
|
|
|
16 |
import org.openconcerto.erp.modules.ModuleFactory;
|
|
|
17 |
import org.openconcerto.erp.modules.ModuleManager;
|
|
|
18 |
import org.openconcerto.erp.modules.ModulePackager;
|
|
|
19 |
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
|
|
|
20 |
import org.openconcerto.erp.modules.RuntimeModuleFactory;
|
|
|
21 |
import org.openconcerto.erp.storage.StorageEngines;
|
|
|
22 |
|
|
|
23 |
import org.openconcerto.sql.element.SQLElementDirectory;
|
|
|
24 |
import org.openconcerto.sql.ui.ConnexionPanel;
|
|
|
25 |
import org.openconcerto.ui.preferences.PreferencePanel;
|
|
|
26 |
import org.openconcerto.utils.FileUtils;
|
|
|
27 |
|
|
|
28 |
public final class Module extends AbstractModule {
|
|
|
29 |
private final GoogleDocsStorageEngine engine = new GoogleDocsStorageEngine();
|
|
|
30 |
|
|
|
31 |
public Module(ModuleFactory f) throws IOException {
|
|
|
32 |
super(f);
|
|
|
33 |
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
@Override
|
|
|
37 |
protected void install(DBContext ctxt) {
|
|
|
38 |
super.install(ctxt);
|
|
|
39 |
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
@Override
|
|
|
43 |
protected void setupElements(SQLElementDirectory dir) {
|
|
|
44 |
super.setupElements(dir);
|
|
|
45 |
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
@Override
|
|
|
49 |
protected void setupComponents(ComponentsContext ctxt) {
|
|
|
50 |
ctxt.addListAction(SaisieVenteFactureSQLElement.TABLENAME, new GoogleDocsListAction());
|
|
|
51 |
ctxt.addListAction(DevisSQLElement.TABLENAME, new GoogleDocsListAction());
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
@Override
|
|
|
55 |
protected void start() {
|
|
|
56 |
StorageEngines.getInstance().addEngine(engine);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
@Override
|
|
|
60 |
public List<ModulePreferencePanelDesc> getPrefDescriptors() {
|
|
|
61 |
return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("OVH") {
|
|
|
62 |
@Override
|
|
|
63 |
protected PreferencePanel createPanel() {
|
|
|
64 |
return new GoogleDocsPreferencePanel();
|
|
|
65 |
}
|
|
|
66 |
});
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
@Override
|
|
|
70 |
protected void stop() {
|
|
|
71 |
StorageEngines.getInstance().removeEngine(engine);
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public static void main(String[] args) throws Exception {
|
|
|
75 |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
|
76 |
|
|
|
77 |
System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
|
|
|
78 |
final File propsFile = new File("gestionModule.properties");
|
|
|
79 |
|
|
|
80 |
final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
|
|
|
81 |
|
|
|
82 |
// uncomment to create and use the jar
|
|
|
83 |
final File distDir = new File("dist");
|
|
|
84 |
FileUtils.mkdir_p(distDir);
|
|
|
85 |
new ModulePackager(propsFile, new File("bin/")).writeToDir(distDir);
|
|
|
86 |
new ModulePackager(propsFile, new File("bin/")).writeToDir(new File("../OpenConcerto/Modules"));
|
|
|
87 |
|
|
|
88 |
ModuleManager.getInstance().addFactoryAndStart(factory, false);
|
|
|
89 |
Gestion.main(args);
|
|
|
90 |
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
}
|