Dépôt officiel du code source de l'ERP OpenConcerto
Blame | Last modification | View Log | RSS feed
/*
* 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.reports.history.ui;
import org.openconcerto.erp.core.common.ui.IListTotalPanel;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import java.awt.GridBagConstraints;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JFrame;
public class HistoriqueArticleFrame {
private PanelFrame panelFrame;
private ListeHistoriquePanel listPanel;
public HistoriqueArticleFrame(SQLElement articleElt) {
// List<String> l = new ArrayList<String>();
Map<String, List<String>> mapList = new HashMap<String, List<String>>();
mapList.put("Proposés", Arrays.asList("DEVIS_ELEMENT"));
mapList.put("Commandés (clients)", Arrays.asList("COMMANDE_CLIENT_ELEMENT"));
mapList.put("Livrés", Arrays.asList("BON_DE_LIVRAISON_ELEMENT"));
mapList.put("Facturés", Arrays.asList("SAISIE_VENTE_FACTURE_ELEMENT"));
mapList.put("Commandés (fournisseurs)", Arrays.asList("COMMANDE_ELEMENT"));
this.listPanel = new ListeHistoriquePanel("Articles", JListSQLTablePanel.createComboRequest(articleElt, true), mapList, null, null, null);
for (int i = 0; i < 4; i++) {
IListPanel panel = this.listPanel.getListePanel(i);
final SQLTable primaryTable = panel.getListe().getSource().getPrimaryTable();
List<SQLField> asList = new ArrayList<>();
asList.add(primaryTable.getField("QTE"));
if (primaryTable.contains("T_PV_HT")) {
asList.add(primaryTable.getField("T_PV_HT"));
} else {
asList.add(primaryTable.getField("T_PA_HT"));
}
IListTotalPanel totalPanel = new IListTotalPanel(panel.getListe(), asList);
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy += 2;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
panel.add(totalPanel, c);
}
this.panelFrame = new PanelFrame(this.listPanel, "Historique client");
this.panelFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
listPanel.removeAllTableListener();
};
});
this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public PanelFrame getFrame() {
return this.panelFrame;
}
public void selectId(int id) {
this.listPanel.selectIDinJList(id);
}
public void setVisible(boolean b) {
this.panelFrame.setVisible(b);
}
}