OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Blame | Last modification | View Log | RSS feed

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011-2019 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.
 */
 
 /*
 * Créé le 3 juin 2012
 */
package org.openconcerto.erp.core.sales.product.element;

import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.core.reports.history.ui.ListeHistoriquePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.request.ComboSQLRequest;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.ui.state.WindowStateManager;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.swing.JFrame;

public class ListeTarifClient {
    private PanelFrame panelFrame;
    private ListeHistoriquePanel listPanel;

    public ListeHistoriquePanel getHistoriquePanel() {
        return this.listPanel;
    }

    public ListeTarifClient(DBRoot root) {

        Map<String, List<String>> mapList = new LinkedHashMap<String, List<String>>();
        mapList.put("Tarifs", Arrays.asList("ARTICLE_TARIF"));

        ComboSQLRequest request = new ComboSQLRequest(root.getTable("TARIF"), Arrays.asList("NOM"));
        request.setFieldSeparator(" ");

        this.listPanel = new ListeHistoriquePanel("Tarifs", request, mapList, null, null, null, true, null, null);

        this.panelFrame = new PanelFrame(this.listPanel, "Tarifs");
        this.panelFrame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                listPanel.removeAllTableListener();
            };
        });

        this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    
    
    public void setSelectedId(int id) {
        this.listPanel.selectIDinJList(id);
    }

    public PanelFrame getFrame() {

        this.panelFrame.setIconImages(Gestion.getFrameIcon());

        WindowStateManager stateManager = new WindowStateManager(this.panelFrame,
                new File(Configuration.getInstance().getConfDir(), "Configuration" + File.separator + "Frame" + File.separator + "TarifArticleClient.xml"), true);

        this.panelFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.panelFrame.pack();

        this.panelFrame.setLocationRelativeTo(null);

        stateManager.loadState();

        return this.panelFrame;
    }
}