OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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