OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
156 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.supplychain.stock.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
174 ilm 17
import org.openconcerto.erp.core.common.ui.ListeViewPanel;
156 ilm 18
import org.openconcerto.sql.element.BaseSQLComponent;
19
import org.openconcerto.sql.element.SQLComponent;
174 ilm 20
import org.openconcerto.sql.element.SQLElement;
21
import org.openconcerto.sql.model.SQLRowAccessor;
22
import org.openconcerto.sql.model.Where;
23
import org.openconcerto.sql.view.IListFrame;
24
import org.openconcerto.sql.view.list.IListe;
25
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
26
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
156 ilm 27
import org.openconcerto.ui.DefaultGridBagConstraints;
174 ilm 28
import org.openconcerto.ui.FrameUtil;
156 ilm 29
import org.openconcerto.utils.ListMap;
30
 
31
import java.awt.GridBagConstraints;
32
import java.awt.GridBagLayout;
174 ilm 33
import java.awt.event.ActionEvent;
156 ilm 34
import java.util.ArrayList;
35
import java.util.List;
36
 
174 ilm 37
import javax.swing.AbstractAction;
156 ilm 38
import javax.swing.JLabel;
39
import javax.swing.JTextField;
40
 
41
public class DepotStockSQLElement extends ComptaSQLConfElement {
42
 
43
    public static int DEFAULT_ID = 2;
44
 
45
    public DepotStockSQLElement() {
46
        super("DEPOT_STOCK", "un dépôt", "dépôts");
174 ilm 47
 
48
        PredicateRowAction actionStock = new PredicateRowAction(new AbstractAction("Voir le détails du stock") {
49
 
50
            @Override
51
            public void actionPerformed(ActionEvent e) {
52
                SQLRowAccessor selRow = IListe.get(e).getSelectedRow();
53
                final SQLElement elementStock = getDirectory().getElement("STOCK");
54
                IListFrame frame = new IListFrame(
55
                        new ListeViewPanel(elementStock, new IListe(elementStock.createTableSource(new Where(elementStock.getTable().getField("ID_DEPOT_STOCK"), "=", selRow.getID())))));
56
                FrameUtil.showPacked(frame);
57
 
58
            }
59
        }, true);
60
        actionStock.setPredicate(IListeEvent.getSingleSelectionPredicate());
61
        getRowActions().add(actionStock);
156 ilm 62
    }
63
 
64
    protected List<String> getListFields() {
65
        final List<String> l = new ArrayList<String>();
66
        l.add("NOM");
67
        return l;
68
    }
69
 
70
    protected List<String> getComboFields() {
71
        final List<String> l = new ArrayList<String>();
72
        l.add("NOM");
73
        return l;
74
    }
75
 
76
    @Override
77
    public ListMap<String, String> getShowAs() {
78
        return ListMap.singleton(null, "NOM");
79
    }
80
 
81
    /*
82
     * (non-Javadoc)
83
     *
84
     * @see org.openconcerto.devis.SQLElement#getComponent()
85
     */
86
    public SQLComponent createComponent() {
87
 
88
        return new BaseSQLComponent(this) {
89
 
90
            public void addViews() {
91
                this.setLayout(new GridBagLayout());
92
                final GridBagConstraints c = new DefaultGridBagConstraints();
93
 
94
                // Qté Réelle
95
                JLabel labelQteR = new JLabel(getLabelFor("NOM"));
96
                this.add(labelQteR, c);
97
 
98
                c.gridx++;
99
                JTextField textNom = new JTextField(25);
100
                this.add(textNom, c);
101
 
102
                this.addSQLObject(textNom, "NOM");
103
            }
104
        };
105
    }
106
 
107
    @Override
108
    protected String createCode() {
109
        return createCodeOfPackage() + ".depot";
110
    }
111
}