75 |
ilm |
1 |
/*
|
|
|
2 |
* Créé le 3 juin 2012
|
|
|
3 |
*/
|
|
|
4 |
package org.openconcerto.modules.project;
|
|
|
5 |
|
|
|
6 |
import java.awt.GridBagConstraints;
|
|
|
7 |
import java.awt.event.WindowAdapter;
|
|
|
8 |
import java.awt.event.WindowEvent;
|
|
|
9 |
import java.io.File;
|
|
|
10 |
import java.util.Arrays;
|
128 |
ilm |
11 |
import java.util.HashMap;
|
75 |
ilm |
12 |
import java.util.LinkedHashMap;
|
|
|
13 |
import java.util.List;
|
|
|
14 |
import java.util.Map;
|
|
|
15 |
|
|
|
16 |
import javax.swing.JFrame;
|
|
|
17 |
import javax.swing.event.TableModelEvent;
|
|
|
18 |
import javax.swing.event.TableModelListener;
|
|
|
19 |
|
|
|
20 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
21 |
import org.openconcerto.erp.config.Gestion;
|
|
|
22 |
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
|
|
|
23 |
import org.openconcerto.sql.Configuration;
|
|
|
24 |
import org.openconcerto.sql.model.SQLBase;
|
|
|
25 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
|
|
26 |
import org.openconcerto.sql.view.IListPanel;
|
|
|
27 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
28 |
import org.openconcerto.ui.PanelFrame;
|
|
|
29 |
import org.openconcerto.ui.state.WindowStateManager;
|
|
|
30 |
|
|
|
31 |
public class ProjectHistory {
|
|
|
32 |
private PanelFrame panelFrame;
|
|
|
33 |
private ListeHistoriquePanel listPanel;
|
|
|
34 |
|
|
|
35 |
public ListeHistoriquePanel getHistoriquePanel() {
|
|
|
36 |
return this.listPanel;
|
|
|
37 |
}
|
|
|
38 |
|
128 |
ilm |
39 |
private static Map<String, List<String>> moduleTab = new HashMap<String, List<String>>();
|
|
|
40 |
|
|
|
41 |
public static void addTab(String tabName, List<String> table) {
|
|
|
42 |
moduleTab.put(tabName, table);
|
|
|
43 |
}
|
|
|
44 |
|
75 |
ilm |
45 |
public ProjectHistory() {
|
|
|
46 |
|
|
|
47 |
final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration.getInstance());
|
|
|
48 |
final SQLBase b = comptaPropsConfiguration.getSQLBaseSociete();
|
|
|
49 |
|
|
|
50 |
final Map<String, List<String>> mapList = new LinkedHashMap<String, List<String>>();
|
|
|
51 |
mapList.put("Devis", Arrays.asList("DEVIS"));
|
|
|
52 |
mapList.put("Bons de commande", Arrays.asList("COMMANDE_CLIENT"));
|
|
|
53 |
mapList.put("Factures", Arrays.asList("SAISIE_VENTE_FACTURE"));
|
|
|
54 |
mapList.put("Avoirs", Arrays.asList("AVOIR_CLIENT"));
|
128 |
ilm |
55 |
mapList.put("Achats", Arrays.asList("SAISIE_ACHAT"));
|
75 |
ilm |
56 |
|
|
|
57 |
if (Configuration.getInstance().getRoot().findTable("AFFAIRE_TEMPS") != null) {
|
|
|
58 |
mapList.put("Temps", Arrays.asList("AFFAIRE_TEMPS"));
|
|
|
59 |
}
|
|
|
60 |
|
128 |
ilm |
61 |
mapList.putAll(moduleTab);
|
|
|
62 |
|
75 |
ilm |
63 |
final ComboSQLRequest request = new org.openconcerto.sql.request.ComboSQLRequest(b.getTable("AFFAIRE"), Arrays.asList("NUMERO", "ID_CLIENT"));
|
|
|
64 |
request.setUndefLabel("Toutes les affaires");
|
|
|
65 |
request.setFieldSeparator(" ");
|
|
|
66 |
|
88 |
ilm |
67 |
this.listPanel = new ListeHistoriquePanel("Affaires", request, mapList, null, null, "Toutes les affaires", true, null, null);
|
75 |
ilm |
68 |
|
|
|
69 |
final IListPanel listeDevis = listPanel.getIListePanelFromTableName("DEVIS");
|
|
|
70 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
71 |
c.gridy = 4;
|
|
|
72 |
c.fill = GridBagConstraints.BOTH;
|
|
|
73 |
final ProjectHistoryDevisBottomPanel devisPanel = new ProjectHistoryDevisBottomPanel();
|
|
|
74 |
listeDevis.add(devisPanel, c);
|
|
|
75 |
listeDevis.getListe().getTableModel().addTableModelListener(new TableModelListener() {
|
|
|
76 |
|
|
|
77 |
@Override
|
|
|
78 |
public void tableChanged(TableModelEvent e) {
|
|
|
79 |
devisPanel.updateDevis(listeDevis.getListe());
|
|
|
80 |
devisPanel.updateTimeDevis(listeDevis.getListe());
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
|
|
|
84 |
final IListPanel listeCmd = listPanel.getIListePanelFromTableName("COMMANDE_CLIENT");
|
|
|
85 |
final ProjectHistoryCmdBottomPanel cmdPanel = new ProjectHistoryCmdBottomPanel();
|
|
|
86 |
|
|
|
87 |
listeCmd.add(cmdPanel, c);
|
|
|
88 |
listeCmd.getListe().getTableModel().addTableModelListener(new TableModelListener() {
|
|
|
89 |
|
|
|
90 |
@Override
|
|
|
91 |
public void tableChanged(TableModelEvent e) {
|
|
|
92 |
cmdPanel.updateCmd(listeCmd.getListe());
|
|
|
93 |
cmdPanel.updateTimeCmd(listeCmd.getListe());
|
|
|
94 |
}
|
|
|
95 |
});
|
|
|
96 |
|
88 |
ilm |
97 |
// If time tracking is installed
|
75 |
ilm |
98 |
final IListPanel listeTemps = listPanel.getIListePanelFromTableName("AFFAIRE_TEMPS");
|
88 |
ilm |
99 |
if (listeTemps != null) {
|
|
|
100 |
final ProjectHistoryTimeBottomPanel timePanel = new ProjectHistoryTimeBottomPanel();
|
|
|
101 |
listeTemps.add(timePanel, c);
|
|
|
102 |
listeTemps.getListe().getTableModel().addTableModelListener(new TableModelListener() {
|
75 |
ilm |
103 |
|
88 |
ilm |
104 |
@Override
|
|
|
105 |
public void tableChanged(TableModelEvent e) {
|
|
|
106 |
timePanel.updateTime(listeTemps.getListe());
|
|
|
107 |
}
|
|
|
108 |
});
|
|
|
109 |
}
|
|
|
110 |
// History
|
75 |
ilm |
111 |
this.panelFrame = new PanelFrame(this.listPanel, "Historique affaires");
|
|
|
112 |
this.panelFrame.addWindowListener(new WindowAdapter() {
|
|
|
113 |
public void windowClosing(WindowEvent e) {
|
|
|
114 |
listPanel.removeAllTableListener();
|
|
|
115 |
};
|
|
|
116 |
});
|
|
|
117 |
|
|
|
118 |
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
|
119 |
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
public PanelFrame getFrame() {
|
|
|
123 |
this.panelFrame.setIconImages(Gestion.getFrameIcon());
|
|
|
124 |
final WindowStateManager stateManager = new WindowStateManager(this.panelFrame, new File(Configuration.getInstance().getConfDir(), "Configuration" + File.separator + "Frame" + File.separator
|
|
|
125 |
+ "HistoAffaires.xml"), true);
|
|
|
126 |
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
|
127 |
this.panelFrame.pack();
|
|
|
128 |
this.panelFrame.setLocationRelativeTo(null);
|
|
|
129 |
stateManager.loadState();
|
|
|
130 |
return this.panelFrame;
|
|
|
131 |
}
|
|
|
132 |
}
|