OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 21 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 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.customerrelationship.customer.element;
15
 
16
import org.openconcerto.sql.Configuration;
17
import org.openconcerto.sql.element.SQLElement;
18
import org.openconcerto.sql.model.SQLRowValues;
19
import org.openconcerto.sql.view.list.RowValuesTable;
20
import org.openconcerto.sql.view.list.RowValuesTableControlPanel;
21
import org.openconcerto.sql.view.list.RowValuesTableModel;
22
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
23
import org.openconcerto.sql.view.list.SQLTableElement;
24
 
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.io.File;
28
import java.util.List;
29
import java.util.Vector;
30
 
31
import javax.swing.JPanel;
32
import javax.swing.JScrollPane;
33
import javax.swing.ToolTipManager;
34
 
35
public class ContactItemTable extends JPanel {
36
 
37
    private RowValuesTable table;
38
    final RowValuesTableControlPanel comp;
39
 
40
    public ContactItemTable(SQLRowValues defaultRow) {
41
        this.setLayout(new GridBagLayout());
42
        GridBagConstraints c = new GridBagConstraints();
43
        c.gridwidth = 1;
44
        c.gridheight = 1;
45
        c.gridx = 0;
46
        c.gridy = 0;
47
        c.fill = GridBagConstraints.HORIZONTAL;
48
        c.weightx = 1;
49
        c.weighty = 0;
50
 
51
        SQLElement elt = Configuration.getInstance().getDirectory().getElement("CONTACT");
52
 
53
        List<SQLTableElement> list = new Vector<SQLTableElement>();
54
        SQLTableElement tableElementTitre = new SQLTableElement(elt.getTable().getField("ID_TITRE_PERSONNEL"));
55
        list.add(tableElementTitre);
56
 
57
        SQLTableElement tableElementNom = new SQLTableElement(elt.getTable().getField("NOM"));
58
        list.add(tableElementNom);
59
 
60
        SQLTableElement tableElementPrenom = new SQLTableElement(elt.getTable().getField("PRENOM"));
61
        list.add(tableElementPrenom);
62
 
63
        SQLTableElement tableElementFonction = new SQLTableElement(elt.getTable().getField("FONCTION"));
64
        list.add(tableElementFonction);
65
 
66
        SQLTableElement tableElementTel = new SQLTableElement(elt.getTable().getField("TEL_DIRECT"));
67
        list.add(tableElementTel);
68
 
69
        SQLTableElement tableElementFax = new SQLTableElement(elt.getTable().getField("FAX"));
70
        list.add(tableElementFax);
71
 
72
        SQLTableElement tableElementTelP = new SQLTableElement(elt.getTable().getField("TEL_MOBILE"));
73
        list.add(tableElementTelP);
74
 
75
        SQLTableElement tableElementMail = new SQLTableElement(elt.getTable().getField("EMAIL"));
76
        list.add(tableElementMail);
77
 
78
        final RowValuesTableModel model = new RowValuesTableModel(elt, list, elt.getTable().getField("NOM"), false, defaultRow);
79
 
80
        this.table = new RowValuesTable(model, new File(Configuration.getInstance().getConfDir() + "Table" + File.separator + "Table_Contact.xml"));
81
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
82
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
83
        this.comp = new RowValuesTableControlPanel(this.table);
84
        this.add(this.comp, c);
85
 
86
        c.gridy++;
87
        c.fill = GridBagConstraints.BOTH;
88
        c.weightx = 1;
89
        c.weighty = 1;
90
        this.add(new JScrollPane(this.table), c);
91
        this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
92
    }
93
 
94
    public void updateField(String field, int id) {
95
 
96
        this.table.updateField(field, id);
97
    }
98
 
99
    public void insertFrom(String field, int id) {
100
 
101
        this.table.insertFrom(field, id);
102
    }
103
 
104
    public RowValuesTableModel getModel() {
105
 
106
        return this.table.getRowValuesTableModel();
107
    }
108
 
109
    public void setEditable(boolean b) {
110
        this.comp.setEditable(b);
111
        this.table.setEditable(b);
112
    }
113
 
114
}