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 LeadVisitSQLElement extends ModuleElement {
21
 
22
    public LeadVisitSQLElement(AbstractModule module) {
23
        super(module, "LEAD_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_LEAD");
181 ilm 31
        l.add("INFORMATION");
32
        if (getTable().contains("ID_COMMERCIAL")) {
33
            l.add("ID_COMMERCIAL");
34
        }
35
 
140 ilm 36
        l.add("NEXTCONTACT_DATE");
37
        return l;
38
    }
39
 
40
    @Override
41
    protected List<String> getComboFields() {
42
        final List<String> l = new ArrayList<String>();
43
        l.add("DATE");
44
        l.add("ID_LEAD");
45
        return l;
46
    }
47
 
48
    @Override
49
    public ListMap<String, String> getShowAs() {
50
        return ListMap.singleton(null, getComboFields());
51
    }
52
 
53
    @Override
54
    public SQLComponent createComponent() {
55
        return new GroupSQLComponentWithService(this, new LeadVisitGroup()) {
56
 
57
            @Override
58
            public JComponent getLabel(String id) {
59
                if (id.equals("customerrelationship.lead.visit.content")) {
60
                    return new JLabelBold("Description de la visite");
61
                } else if (id.equals("customerrelationship.lead.visit.next")) {
62
                    return new JLabelBold("Suite à donner");
63
 
64
                }
65
                return super.getLabel(id);
66
            }
67
 
68
            @Override
69
            public JComponent createEditor(String id) {
70
                if (id.equals("INFORMATION")) {
71
                    final JTextArea jTextArea = new JTextArea();
72
                    jTextArea.setFont(new JLabel().getFont());
73
                    jTextArea.setMinimumSize(new Dimension(200, 150));
74
                    jTextArea.setPreferredSize(new Dimension(200, 150));
75
                    return new JScrollPane(jTextArea);
76
                } else if (id.equals("NEXTCONTACT_INFO")) {
77
                    final JTextArea jTextArea = new JTextArea();
78
                    jTextArea.setFont(new JLabel().getFont());
79
                    jTextArea.setMinimumSize(new Dimension(200, 50));
80
                    jTextArea.setPreferredSize(new Dimension(200, 50));
81
                    return new JScrollPane(jTextArea);
82
                } else if (id.equals("DATE")) {
83
                    return new JDate(true);
84
                }
85
                return super.createEditor(id);
86
            }
87
 
88
        };
89
    }
90
}