OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
140 ilm 1
package org.openconcerto.modules.customerrelationship.lead.visit;
2
 
3
import java.awt.Dimension;
4
import java.util.ArrayList;
5
import java.util.List;
6
 
7
import javax.swing.JComponent;
8
import javax.swing.JLabel;
9
import javax.swing.JScrollPane;
10
import javax.swing.JTextArea;
11
 
12
import org.openconcerto.erp.modules.AbstractModule;
13
import org.openconcerto.erp.modules.ModuleElement;
14
import org.openconcerto.modules.customerrelationship.lead.GroupSQLComponentWithService;
15
import org.openconcerto.sql.element.SQLComponent;
16
import org.openconcerto.ui.JDate;
17
import org.openconcerto.ui.JLabelBold;
18
import org.openconcerto.utils.ListMap;
19
 
20
public class CustomerVisitSQLElement extends ModuleElement {
21
 
22
    public CustomerVisitSQLElement(AbstractModule module) {
23
        super(module, "CUSTOMER_VISIT");
24
    }
25
 
26
    @Override
27
    protected List<String> getListFields() {
28
        final List<String> l = new ArrayList<String>();
29
        l.add("DATE");
30
        l.add("ID_CLIENT");
181 ilm 31
        l.add("INFORMATION");
32
        if (getTable().contains("ID_COMMERCIAL")) {
33
            l.add("ID_COMMERCIAL");
34
        }
140 ilm 35
        l.add("NEXTCONTACT_DATE");
36
        return l;
37
    }
38
 
39
    @Override
40
    protected List<String> getComboFields() {
41
        final List<String> l = new ArrayList<String>();
42
        l.add("DATE");
43
        l.add("ID_CLIENT");
44
        return l;
45
    }
46
 
47
    @Override
48
    public ListMap<String, String> getShowAs() {
49
        return ListMap.singleton(null, getComboFields());
50
    }
51
 
52
    @Override
53
    public SQLComponent createComponent() {
54
        return new GroupSQLComponentWithService(this, new CustomerVisitGroup()) {
55
 
56
            @Override
57
            public JComponent getLabel(String id) {
58
                if (id.equals("customerrelationship.customer.visit.content")) {
59
                    return new JLabelBold("Description de la visite");
60
                } else if (id.equals("customerrelationship.customer.visit.next")) {
61
                    return new JLabelBold("Suite à donner");
62
                }
63
                return super.getLabel(id);
64
            }
65
 
66
            @Override
67
            public JComponent createEditor(String id) {
68
                if (id.equals("INFORMATION")) {
69
                    final JTextArea jTextArea = new JTextArea();
70
                    jTextArea.setFont(new JLabel().getFont());
71
                    jTextArea.setMinimumSize(new Dimension(200, 150));
72
                    jTextArea.setPreferredSize(new Dimension(200, 150));
73
                    return new JScrollPane(jTextArea);
74
                } else if (id.equals("NEXTCONTACT_INFO")) {
75
                    final JTextArea jTextArea = new JTextArea();
76
                    jTextArea.setFont(new JLabel().getFont());
77
                    jTextArea.setMinimumSize(new Dimension(200, 50));
78
                    jTextArea.setPreferredSize(new Dimension(200, 50));
79
                    return new JScrollPane(jTextArea);
80
                } else if (id.equals("DATE")) {
81
                    return new JDate(true);
82
                }
83
                return super.createEditor(id);
84
            }
85
 
86
        };
87
    }
88
}