Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* Créé le 3 juin 2012
|
2 |
* Créé le 3 juin 2012
|
3 |
*/
|
3 |
*/
|
4 |
package org.openconcerto.modules.project;
|
4 |
package org.openconcerto.modules.project;
|
5 |
|
5 |
|
- |
|
6 |
import java.awt.Component;
|
- |
|
7 |
import java.awt.FileDialog;
|
- |
|
8 |
import java.awt.Frame;
|
6 |
import java.awt.GridBagConstraints;
|
9 |
import java.awt.GridBagConstraints;
|
- |
|
10 |
import java.awt.event.ActionEvent;
|
7 |
import java.awt.event.WindowAdapter;
|
11 |
import java.awt.event.WindowAdapter;
|
8 |
import java.awt.event.WindowEvent;
|
12 |
import java.awt.event.WindowEvent;
|
9 |
import java.io.File;
|
13 |
import java.io.File;
|
- |
|
14 |
import java.io.FilenameFilter;
|
- |
|
15 |
import java.io.IOException;
|
- |
|
16 |
import java.sql.SQLException;
|
10 |
import java.util.Arrays;
|
17 |
import java.util.Arrays;
|
11 |
import java.util.HashMap;
|
18 |
import java.util.HashMap;
|
12 |
import java.util.LinkedHashMap;
|
19 |
import java.util.LinkedHashMap;
|
13 |
import java.util.List;
|
20 |
import java.util.List;
|
14 |
import java.util.Map;
|
21 |
import java.util.Map;
|
15 |
|
22 |
|
- |
|
23 |
import javax.swing.AbstractAction;
|
16 |
import javax.swing.JFrame;
|
24 |
import javax.swing.JFrame;
|
- |
|
25 |
import javax.swing.JOptionPane;
|
17 |
import javax.swing.event.TableModelEvent;
|
26 |
import javax.swing.event.TableModelEvent;
|
18 |
import javax.swing.event.TableModelListener;
|
27 |
import javax.swing.event.TableModelListener;
|
19 |
|
28 |
|
20 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
29 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
21 |
import org.openconcerto.erp.config.Gestion;
|
30 |
import org.openconcerto.erp.config.Gestion;
|
22 |
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
|
31 |
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
|
- |
|
32 |
import org.openconcerto.erp.core.supplychain.order.action.ImportProductsToOrder;
|
23 |
import org.openconcerto.sql.Configuration;
|
33 |
import org.openconcerto.sql.Configuration;
|
24 |
import org.openconcerto.sql.model.SQLBase;
|
34 |
import org.openconcerto.sql.model.SQLBase;
|
25 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
35 |
import org.openconcerto.sql.request.ComboSQLRequest;
|
26 |
import org.openconcerto.sql.view.IListPanel;
|
36 |
import org.openconcerto.sql.view.IListPanel;
|
- |
|
37 |
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
|
- |
|
38 |
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
|
27 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
39 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
28 |
import org.openconcerto.ui.PanelFrame;
|
40 |
import org.openconcerto.ui.PanelFrame;
|
- |
|
41 |
import org.openconcerto.ui.SwingThreadUtils;
|
29 |
import org.openconcerto.ui.state.WindowStateManager;
|
42 |
import org.openconcerto.ui.state.WindowStateManager;
|
30 |
|
43 |
|
31 |
public class ProjectHistory {
|
44 |
public class ProjectHistory {
|
32 |
private PanelFrame panelFrame;
|
45 |
private PanelFrame panelFrame;
|
33 |
private ListeHistoriquePanel listPanel;
|
46 |
private ListeHistoriquePanel listPanel;
|
Line 50... |
Line 63... |
50 |
final Map<String, List<String>> mapList = new LinkedHashMap<String, List<String>>();
|
63 |
final Map<String, List<String>> mapList = new LinkedHashMap<String, List<String>>();
|
51 |
mapList.put("Devis", Arrays.asList("DEVIS"));
|
64 |
mapList.put("Devis", Arrays.asList("DEVIS"));
|
52 |
mapList.put("Bons de commande", Arrays.asList("COMMANDE_CLIENT"));
|
65 |
mapList.put("Bons de commande", Arrays.asList("COMMANDE_CLIENT"));
|
53 |
mapList.put("Factures", Arrays.asList("SAISIE_VENTE_FACTURE"));
|
66 |
mapList.put("Factures", Arrays.asList("SAISIE_VENTE_FACTURE"));
|
54 |
mapList.put("Avoirs", Arrays.asList("AVOIR_CLIENT"));
|
67 |
mapList.put("Avoirs", Arrays.asList("AVOIR_CLIENT"));
|
- |
|
68 |
mapList.put("Demandes d'achat", Arrays.asList("DEMANDE_ACHAT_ELEMENT"));
|
- |
|
69 |
mapList.put("Demandes de prix", Arrays.asList("DEMANDE_PRIX"));
|
- |
|
70 |
mapList.put("Commandes", Arrays.asList("COMMANDE"));
|
55 |
mapList.put("Achats", Arrays.asList("SAISIE_ACHAT"));
|
71 |
mapList.put("Achats", Arrays.asList("SAISIE_ACHAT"));
|
56 |
|
72 |
|
57 |
if (Configuration.getInstance().getRoot().findTable("AFFAIRE_TEMPS") != null) {
|
73 |
if (Configuration.getInstance().getRoot().findTable("AFFAIRE_TEMPS") != null) {
|
58 |
mapList.put("Temps", Arrays.asList("AFFAIRE_TEMPS"));
|
74 |
mapList.put("Temps", Arrays.asList("AFFAIRE_TEMPS"));
|
59 |
}
|
75 |
}
|
Line 79... |
Line 95... |
79 |
devisPanel.updateDevis(listeDevis.getListe());
|
95 |
devisPanel.updateDevis(listeDevis.getListe());
|
80 |
devisPanel.updateTimeDevis(listeDevis.getListe());
|
96 |
devisPanel.updateTimeDevis(listeDevis.getListe());
|
81 |
}
|
97 |
}
|
82 |
});
|
98 |
});
|
83 |
|
99 |
|
- |
|
100 |
final IListPanel listeDmdAchat = listPanel.getIListePanelFromTableName("DEMANDE_ACHAT_ELEMENT");
|
- |
|
101 |
PredicateRowAction actionDrop = new PredicateRowAction(new AbstractAction("Importer depuis Fichier Inventor") {
|
- |
|
102 |
|
- |
|
103 |
@Override
|
- |
|
104 |
public void actionPerformed(ActionEvent e) {
|
- |
|
105 |
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
|
- |
|
106 |
final FileDialog fd = new FileDialog(frame, "Import fichier inventor", FileDialog.LOAD);
|
- |
|
107 |
fd.setFilenameFilter(new FilenameFilter() {
|
- |
|
108 |
@Override
|
- |
|
109 |
public boolean accept(File dir, String name) {
|
- |
|
110 |
return name.endsWith(".xls");
|
- |
|
111 |
}
|
- |
|
112 |
});
|
- |
|
113 |
fd.setVisible(true);
|
- |
|
114 |
if (fd.getFile() != null) {
|
- |
|
115 |
|
- |
|
116 |
ImportProductsToOrder importer = new ImportProductsToOrder();
|
- |
|
117 |
|
- |
|
118 |
int a = JOptionPane.showConfirmDialog(frame, "Etes vous sûr de vouloir importer ces éléments dans l'affaire N°" + listPanel.getSelectedRow().getString("NUMERO") + "?",
|
- |
|
119 |
"Import invertor", JOptionPane.YES_NO_OPTION);
|
- |
|
120 |
if (a == JOptionPane.YES_OPTION) {
|
- |
|
121 |
importer.setRowAffaire(listPanel.getSelectedRow());
|
- |
|
122 |
try {
|
- |
|
123 |
importer.importFile(new File(fd.getDirectory(), fd.getFile()), b.getTable("DEMANDE_ACHAT_ELEMENT").getDBRoot());
|
- |
|
124 |
listeDmdAchat.getListe().getModel().updateAll();
|
- |
|
125 |
} catch (IOException e1) {
|
- |
|
126 |
org.openconcerto.utils.ExceptionHandler.handle("Erreur lors de l'import du fichier!", e1);
|
- |
|
127 |
} catch (SQLException e1) {
|
- |
|
128 |
org.openconcerto.utils.ExceptionHandler.handle("Erreur lors de l'import du fichier!", e1);
|
- |
|
129 |
}
|
- |
|
130 |
}
|
- |
|
131 |
}
|
- |
|
132 |
}
|
- |
|
133 |
}, true);
|
- |
|
134 |
actionDrop.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
|
- |
|
135 |
listeDmdAchat.getListe().addIListeAction(actionDrop);
|
- |
|
136 |
|
84 |
final IListPanel listeCmd = listPanel.getIListePanelFromTableName("COMMANDE_CLIENT");
|
137 |
final IListPanel listeCmd = listPanel.getIListePanelFromTableName("COMMANDE_CLIENT");
|
85 |
final ProjectHistoryCmdBottomPanel cmdPanel = new ProjectHistoryCmdBottomPanel();
|
138 |
final ProjectHistoryCmdBottomPanel cmdPanel = new ProjectHistoryCmdBottomPanel();
|
86 |
|
139 |
|
87 |
listeCmd.add(cmdPanel, c);
|
140 |
listeCmd.add(cmdPanel, c);
|
88 |
listeCmd.getListe().getTableModel().addTableModelListener(new TableModelListener() {
|
141 |
listeCmd.getListe().getTableModel().addTableModelListener(new TableModelListener() {
|
Line 119... |
Line 172... |
119 |
|
172 |
|
120 |
}
|
173 |
}
|
121 |
|
174 |
|
122 |
public PanelFrame getFrame() {
|
175 |
public PanelFrame getFrame() {
|
123 |
this.panelFrame.setIconImages(Gestion.getFrameIcon());
|
176 |
this.panelFrame.setIconImages(Gestion.getFrameIcon());
|
124 |
final WindowStateManager stateManager = new WindowStateManager(this.panelFrame, new File(Configuration.getInstance().getConfDir(), "Configuration" + File.separator + "Frame" + File.separator
|
177 |
final WindowStateManager stateManager = new WindowStateManager(this.panelFrame,
|
125 |
+ "HistoAffaires.xml"), true);
|
178 |
new File(Configuration.getInstance().getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + "HistoAffaires.xml"), true);
|
126 |
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
179 |
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
127 |
this.panelFrame.pack();
|
180 |
this.panelFrame.pack();
|
128 |
this.panelFrame.setLocationRelativeTo(null);
|
181 |
this.panelFrame.setLocationRelativeTo(null);
|
129 |
stateManager.loadState();
|
182 |
stateManager.loadState();
|
130 |
return this.panelFrame;
|
183 |
return this.panelFrame;
|