OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 21 | Rev 83 | Go to most recent revision | Details | Compare with Previous | 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) {
21 ilm 41
        this(defaultRow, Configuration.getInstance().getDirectory().getElement(defaultRow.getTable()));
42
    }
43
 
44
    private ContactItemTable(SQLRowValues defaultRow, SQLElement elt) {
18 ilm 45
        this.setLayout(new GridBagLayout());
46
        GridBagConstraints c = new GridBagConstraints();
47
        c.gridwidth = 1;
48
        c.gridheight = 1;
49
        c.gridx = 0;
50
        c.gridy = 0;
51
        c.fill = GridBagConstraints.HORIZONTAL;
52
        c.weightx = 1;
53
        c.weighty = 0;
54
 
55
        List<SQLTableElement> list = new Vector<SQLTableElement>();
56
        SQLTableElement tableElementTitre = new SQLTableElement(elt.getTable().getField("ID_TITRE_PERSONNEL"));
57
        list.add(tableElementTitre);
58
 
59
        SQLTableElement tableElementNom = new SQLTableElement(elt.getTable().getField("NOM"));
60
        list.add(tableElementNom);
61
 
62
        SQLTableElement tableElementPrenom = new SQLTableElement(elt.getTable().getField("PRENOM"));
63
        list.add(tableElementPrenom);
64
 
65
        SQLTableElement tableElementFonction = new SQLTableElement(elt.getTable().getField("FONCTION"));
66
        list.add(tableElementFonction);
67
 
68
        SQLTableElement tableElementTel = new SQLTableElement(elt.getTable().getField("TEL_DIRECT"));
69
        list.add(tableElementTel);
70
 
71
        SQLTableElement tableElementFax = new SQLTableElement(elt.getTable().getField("FAX"));
72
        list.add(tableElementFax);
73
 
74
        SQLTableElement tableElementTelP = new SQLTableElement(elt.getTable().getField("TEL_MOBILE"));
75
        list.add(tableElementTelP);
76
 
77
        SQLTableElement tableElementMail = new SQLTableElement(elt.getTable().getField("EMAIL"));
78
        list.add(tableElementMail);
79
 
80
        final RowValuesTableModel model = new RowValuesTableModel(elt, list, elt.getTable().getField("NOM"), false, defaultRow);
81
 
73 ilm 82
        this.table = new RowValuesTable(model, new File(Configuration.getInstance().getConfDir(), "Table" + File.separator + "Table_Contact.xml"));
18 ilm 83
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
84
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
85
        this.comp = new RowValuesTableControlPanel(this.table);
86
        this.add(this.comp, c);
87
 
88
        c.gridy++;
89
        c.fill = GridBagConstraints.BOTH;
90
        c.weightx = 1;
91
        c.weighty = 1;
92
        this.add(new JScrollPane(this.table), c);
93
        this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
94
    }
95
 
96
    public void updateField(String field, int id) {
97
        this.table.updateField(field, id);
98
    }
99
 
73 ilm 100
    public void insertFrom(String field, SQLRowValues row) {
101
        this.table.insertFrom(field, row);
102
    }
103
 
18 ilm 104
    public void insertFrom(String field, int id) {
105
        this.table.insertFrom(field, id);
106
    }
107
 
108
    public RowValuesTableModel getModel() {
109
        return this.table.getRowValuesTableModel();
110
    }
111
 
112
    public void setEditable(boolean b) {
113
        this.comp.setEditable(b);
114
        this.table.setEditable(b);
115
    }
116
 
117
}